1 diff -NurpP --minimal linux-2.6.10/Documentation/vserver/debug.txt linux-2.6.10-vs1.9.3.17/Documentation/vserver/debug.txt
2 --- linux-2.6.10/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.10-vs1.9.3.17/Documentation/vserver/debug.txt 2004-12-26 19:40:35.000000000 +0100
27 + 0 1 "alloc_vx_info(%d) = %p\n"
28 + "dealloc_vx_info(%p)"
29 + "loc_vx_info(%d) = %p (not available)"
30 + "loc_vx_info(%d) = %p (found)"
31 + "loc_vx_info(%d) = %p (new)"
33 + 1 2 "alloc_vx_info(%d)*"
35 + "locate_vx_info(%d)"
37 + 2 4 "get_vx_info(%p[#%d.%d])"
38 + "put_vx_info(%p[#%d.%d])"
40 + 3 8 "set_vx_info(%p[#%d.%d.%d])"
41 + "clr_vx_info(%p[#%d.%d.%d])"
42 + "rcu_free_vx_info(%p): uc=%d"
44 + 4 16 "__hash_vx_info: %p[#%d]"
45 + "__unhash_vx_info: %p[#%d]"
46 + "__vx_dynamic_id: [#%d]"
48 + 5 32 "vx_migrate_task(%p,%p[#%d.%d])"
49 + "task_get_vx_info(%p)"
51 + 6 64 "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
53 + 7 128 "vx_propagate_xid(%p[#%d.%d]): %d"
58 + 0 1 "alloc_nx_info() = %p"
59 + "dealloc_nx_info(%p)"
60 + "loc_nx_info(%d) = %p (not available)"
61 + "loc_nx_info(%d) = %p (found)"
62 + "loc_nx_info(%d) = %p (new)"
64 + 1 2 "alloc_nx_info(%d)*"
67 + 2 4 "get_nx_info(%p[#%d.%d])"
68 + "put_nx_info(%p[#%d.%d])"
70 + 3 8 "set_nx_info(%p[#%d.%d.%d])"
71 + "clr_nx_info(%p[#%d.%d.%d])"
72 + "rcu_free_nx_info(%p): uc=%d"
74 + 4 16 "__hash_nx_info: %p[#%d]"
75 + "__unhash_nx_info: %p[#%d]"
76 + "__nx_dynamic_id: [#%d]"
78 + 5 32 "nx_migrate_task(%p,%p[#%d.%d])"
79 + "task_get_nx_info(%p)"
89 + 0 1 "alloc_dl_info(%p,%d) = %p"
90 + "dealloc_dl_info(%p)"
91 + "locate_dl_info(%p,#%d) = %p"
93 + 1 2 "alloc_dl_info(%p,%d)*"
95 + 2 4 "get_dl_info(%p[#%d.%d])"
96 + "put_dl_info(%p[#%d.%d])"
98 + 3 8 "rcu_free_dl_info(%p)"
99 + "__hash_dl_info: %p[#%d]"
100 + "__unhash_dl_info: %p[#%d]"
103 + 4 16 "ALLOC (%p,#%d)%c inode (%d)"
104 + "FREE (%p,#%d)%c inode"
106 + 5 32 "ALLOC (%p,#%d)%c %lld bytes (%d)"
107 + "FREE (%p,#%d)%c %lld bytes"
109 + 6 64 "ADJUST: %lld,%lld on %d,%d [mult=%d]"
111 + 7 128 "ext3_has_free_blocks(%p): free=%u, root=%u"
112 + "ext3_has_free_blocks(%p): %u<%u+1, %c, %u!=%u r=%d"
123 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
124 + "vx_rmap_tgid: %p/%llx: %d -> %d"
145 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
147 + 3 8 "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
148 + "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
150 + 4 16 "ip_route_connect(%p) %p,%p;%lx"
152 + 5 32 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
154 + 6 64 "sk: %p [#%d] (from %d)"
155 + "sk,req: %p [#%d] (from %d)"
156 + "sk,egf: %p [#%d] (from %d)"
157 + "sk,egn: %p [#%d] (from %d)"
158 + "tw: %p [#%d] (from %d)"
160 + 7 128 "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
161 + "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
168 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
169 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
171 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
172 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
173 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
176 diff -NurpP --minimal linux-2.6.10/Makefile linux-2.6.10-vs1.9.3.17/Makefile
177 --- linux-2.6.10/Makefile 2004-12-25 01:54:42.000000000 +0100
178 +++ linux-2.6.10-vs1.9.3.17/Makefile 2005-01-06 07:53:34.000000000 +0100
184 +EXTRAVERSION = -vs1.9.3.17
188 diff -NurpP --minimal linux-2.6.10/arch/alpha/Kconfig linux-2.6.10-vs1.9.3.17/arch/alpha/Kconfig
189 --- linux-2.6.10/arch/alpha/Kconfig 2004-10-23 05:05:56.000000000 +0200
190 +++ linux-2.6.10-vs1.9.3.17/arch/alpha/Kconfig 2004-12-26 19:40:21.000000000 +0100
191 @@ -594,6 +594,8 @@ source "arch/alpha/oprofile/Kconfig"
193 source "arch/alpha/Kconfig.debug"
195 +source "kernel/vserver/Kconfig"
197 source "security/Kconfig"
199 source "crypto/Kconfig"
200 diff -NurpP --minimal linux-2.6.10/arch/alpha/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/alpha/kernel/ptrace.c
201 --- linux-2.6.10/arch/alpha/kernel/ptrace.c 2004-12-25 01:54:42.000000000 +0100
202 +++ linux-2.6.10-vs1.9.3.17/arch/alpha/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
203 @@ -288,6 +288,8 @@ do_sys_ptrace(long request, long pid, lo
204 read_unlock(&tasklist_lock);
207 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
210 if (request == PTRACE_ATTACH) {
211 ret = ptrace_attach(child);
212 diff -NurpP --minimal linux-2.6.10/arch/alpha/kernel/systbls.S linux-2.6.10-vs1.9.3.17/arch/alpha/kernel/systbls.S
213 --- linux-2.6.10/arch/alpha/kernel/systbls.S 2004-10-23 05:05:56.000000000 +0200
214 +++ linux-2.6.10-vs1.9.3.17/arch/alpha/kernel/systbls.S 2004-12-26 19:40:23.000000000 +0100
215 @@ -291,7 +291,7 @@ sys_call_table:
216 .quad alpha_ni_syscall /* 270 */
217 .quad alpha_ni_syscall
218 .quad alpha_ni_syscall
219 - .quad alpha_ni_syscall
220 + .quad sys_vserver /* 273 sys_vserver */
221 .quad alpha_ni_syscall
222 .quad alpha_ni_syscall /* 275 */
223 .quad alpha_ni_syscall
224 diff -NurpP --minimal linux-2.6.10/arch/arm/Kconfig linux-2.6.10-vs1.9.3.17/arch/arm/Kconfig
225 --- linux-2.6.10/arch/arm/Kconfig 2004-12-25 01:54:42.000000000 +0100
226 +++ linux-2.6.10-vs1.9.3.17/arch/arm/Kconfig 2004-12-26 19:40:21.000000000 +0100
227 @@ -709,6 +709,8 @@ source "drivers/mmc/Kconfig"
229 source "arch/arm/Kconfig.debug"
231 +source "kernel/vserver/Kconfig"
233 source "security/Kconfig"
235 source "crypto/Kconfig"
236 diff -NurpP --minimal linux-2.6.10/arch/arm/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/arm/kernel/ptrace.c
237 --- linux-2.6.10/arch/arm/kernel/ptrace.c 2004-12-25 01:54:42.000000000 +0100
238 +++ linux-2.6.10-vs1.9.3.17/arch/arm/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
239 @@ -754,6 +754,8 @@ asmlinkage int sys_ptrace(long request,
240 read_unlock(&tasklist_lock);
243 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
247 if (pid == 1) /* you may not mess with init */
248 diff -NurpP --minimal linux-2.6.10/arch/arm26/Kconfig linux-2.6.10-vs1.9.3.17/arch/arm26/Kconfig
249 --- linux-2.6.10/arch/arm26/Kconfig 2004-10-23 05:05:57.000000000 +0200
250 +++ linux-2.6.10-vs1.9.3.17/arch/arm26/Kconfig 2004-12-26 19:40:21.000000000 +0100
251 @@ -216,6 +216,8 @@ source "drivers/usb/Kconfig"
253 source "arch/arm26/Kconfig.debug"
255 +source "kernel/vserver/Kconfig"
257 source "security/Kconfig"
259 source "crypto/Kconfig"
260 diff -NurpP --minimal linux-2.6.10/arch/arm26/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/arm26/kernel/ptrace.c
261 --- linux-2.6.10/arch/arm26/kernel/ptrace.c 2004-12-25 01:54:43.000000000 +0100
262 +++ linux-2.6.10-vs1.9.3.17/arch/arm26/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
263 @@ -691,6 +691,8 @@ asmlinkage int sys_ptrace(long request,
264 read_unlock(&tasklist_lock);
267 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
271 if (pid == 1) /* you may not mess with init */
272 diff -NurpP --minimal linux-2.6.10/arch/cris/Kconfig linux-2.6.10-vs1.9.3.17/arch/cris/Kconfig
273 --- linux-2.6.10/arch/cris/Kconfig 2004-10-23 05:05:57.000000000 +0200
274 +++ linux-2.6.10-vs1.9.3.17/arch/cris/Kconfig 2004-12-26 19:40:21.000000000 +0100
275 @@ -169,6 +169,8 @@ source "drivers/usb/Kconfig"
277 source "arch/cris/Kconfig.debug"
279 +source "kernel/vserver/Kconfig"
281 source "security/Kconfig"
283 source "crypto/Kconfig"
284 diff -NurpP --minimal linux-2.6.10/arch/h8300/Kconfig linux-2.6.10-vs1.9.3.17/arch/h8300/Kconfig
285 --- linux-2.6.10/arch/h8300/Kconfig 2004-10-23 05:05:57.000000000 +0200
286 +++ linux-2.6.10-vs1.9.3.17/arch/h8300/Kconfig 2004-12-26 19:40:21.000000000 +0100
287 @@ -183,6 +183,8 @@ source "fs/Kconfig"
289 source "arch/h8300/Kconfig.debug"
291 +source "kernel/vserver/Kconfig"
293 source "security/Kconfig"
295 source "crypto/Kconfig"
296 diff -NurpP --minimal linux-2.6.10/arch/h8300/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/h8300/kernel/ptrace.c
297 --- linux-2.6.10/arch/h8300/kernel/ptrace.c 2004-12-25 01:54:43.000000000 +0100
298 +++ linux-2.6.10-vs1.9.3.17/arch/h8300/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
299 @@ -80,6 +80,8 @@ asmlinkage int sys_ptrace(long request,
300 read_unlock(&tasklist_lock);
303 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
307 if (pid == 1) /* you may not mess with init */
308 diff -NurpP --minimal linux-2.6.10/arch/i386/Kconfig linux-2.6.10-vs1.9.3.17/arch/i386/Kconfig
309 --- linux-2.6.10/arch/i386/Kconfig 2004-12-25 01:54:43.000000000 +0100
310 +++ linux-2.6.10-vs1.9.3.17/arch/i386/Kconfig 2004-12-26 19:40:36.000000000 +0100
311 @@ -553,6 +553,14 @@ config X86_IO_APIC
312 depends on !SMP && X86_UP_IOAPIC
316 + int "Timer Frequency (100-20000)"
320 + This allows you to specify the frequency at which the
321 + kernel timer interrupt will occur.
325 depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2) && !X86_NUMAQ
326 @@ -720,6 +728,46 @@ config HIGHMEM64G
331 + prompt "Memory Split User Space"
334 + A different Userspace/Kernel split allows you to
335 + utilize up to alsmost 3GB of RAM without the requirement
336 + for HIGHMEM. It also increases the available lowmem.
339 + bool "3.0GB/1.0GB Kernel (Default)"
341 + This is the default split of 3GB userspace to 1GB kernel
342 + space, which will result in about 860MB of lowmem.
345 + bool "2.5GB/1.5GB Kernel"
347 + This split provides 2.5GB userspace and 1.5GB kernel
348 + space, which will result in about 1370MB of lowmem.
351 + bool "2.0GB/2.0GB Kernel"
353 + This split provides 2GB userspace and 2GB kernel
354 + space, which will result in about 1880MB of lowmem.
357 + bool "1.5GB/2.5GB Kernel"
359 + This split provides 1.5GB userspace and 2.5GB kernel
360 + space, which will result in about 2390MB of lowmem.
363 + bool "1.0GB/3.0GB Kernel"
365 + This split provides 1GB userspace and 3GB kernel
366 + space, which will result in about 2900MB of lowmem.
372 depends on HIGHMEM64G || HIGHMEM4G
373 @@ -1194,6 +1242,8 @@ source "arch/i386/oprofile/Kconfig"
375 source "arch/i386/Kconfig.debug"
377 +source "kernel/vserver/Kconfig"
379 source "security/Kconfig"
381 source "crypto/Kconfig"
382 diff -NurpP --minimal linux-2.6.10/arch/i386/kernel/apic.c linux-2.6.10-vs1.9.3.17/arch/i386/kernel/apic.c
383 --- linux-2.6.10/arch/i386/kernel/apic.c 2004-12-25 01:54:43.000000000 +0100
384 +++ linux-2.6.10-vs1.9.3.17/arch/i386/kernel/apic.c 2005-01-02 10:57:33.000000000 +0100
385 @@ -877,23 +877,18 @@ static unsigned int __init get_8254_time
386 /* next tick in 8254 can be caught by catching timer wraparound */
387 static void __init wait_8254_wraparound(void)
389 - unsigned int curr_count, prev_count=~0;
391 + unsigned int curr_count, prev_count;
393 curr_count = get_8254_timer_count();
396 prev_count = curr_count;
397 curr_count = get_8254_timer_count();
398 - delta = curr_count-prev_count;
401 - * This limit for delta seems arbitrary, but it isn't, it's
402 - * slightly above the level of error a buggy Mercury/Neptune
403 - * chipset timer can cause.
405 + /* workaround for broken Mercury/Neptune */
406 + if (prev_count >= curr_count + 0x100)
407 + curr_count = get_8254_timer_count();
409 - } while (delta < 300);
410 + } while (prev_count >= curr_count);
414 diff -NurpP --minimal linux-2.6.10/arch/i386/kernel/cpu/proc.c linux-2.6.10-vs1.9.3.17/arch/i386/kernel/cpu/proc.c
415 --- linux-2.6.10/arch/i386/kernel/cpu/proc.c 2004-12-25 01:54:44.000000000 +0100
416 +++ linux-2.6.10-vs1.9.3.17/arch/i386/kernel/cpu/proc.c 2004-12-26 19:40:36.000000000 +0100
417 @@ -121,8 +121,8 @@ static int show_cpuinfo(struct seq_file
418 seq_printf(m, " %s", x86_cap_flags[i]);
420 seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",
421 - c->loops_per_jiffy/(500000/HZ),
422 - (c->loops_per_jiffy/(5000/HZ)) % 100);
423 + HZ*(c->loops_per_jiffy >> 3)/62500,
424 + (HZ*(c->loops_per_jiffy >> 3)/625) % 100);
428 diff -NurpP --minimal linux-2.6.10/arch/i386/kernel/entry.S linux-2.6.10-vs1.9.3.17/arch/i386/kernel/entry.S
429 --- linux-2.6.10/arch/i386/kernel/entry.S 2004-12-25 01:54:44.000000000 +0100
430 +++ linux-2.6.10-vs1.9.3.17/arch/i386/kernel/entry.S 2004-12-26 19:40:23.000000000 +0100
431 @@ -849,7 +849,7 @@ ENTRY(sys_call_table)
432 .long sys_tgkill /* 270 */
434 .long sys_fadvise64_64
435 - .long sys_ni_syscall /* sys_vserver */
438 .long sys_get_mempolicy
439 .long sys_set_mempolicy
440 diff -NurpP --minimal linux-2.6.10/arch/i386/kernel/io_apic.c linux-2.6.10-vs1.9.3.17/arch/i386/kernel/io_apic.c
441 --- linux-2.6.10/arch/i386/kernel/io_apic.c 2004-12-25 01:54:44.000000000 +0100
442 +++ linux-2.6.10-vs1.9.3.17/arch/i386/kernel/io_apic.c 2005-01-02 10:43:41.000000000 +0100
443 @@ -1764,7 +1764,7 @@ static int __init timer_irq_works(void)
446 /* Let ten ticks pass... */
447 - mdelay((10 * 1000) / HZ);
448 + mdelay((10 * 1000) / HZ + 1);
451 * Expect a few ticks at least, to be sure some possible
452 diff -NurpP --minimal linux-2.6.10/arch/i386/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/i386/kernel/ptrace.c
453 --- linux-2.6.10/arch/i386/kernel/ptrace.c 2004-12-25 01:54:44.000000000 +0100
454 +++ linux-2.6.10-vs1.9.3.17/arch/i386/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
455 @@ -278,6 +278,8 @@ asmlinkage int sys_ptrace(long request,
456 read_unlock(&tasklist_lock);
459 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
463 if (pid == 1) /* you may not mess with init */
464 diff -NurpP --minimal linux-2.6.10/arch/i386/kernel/smpboot.c linux-2.6.10-vs1.9.3.17/arch/i386/kernel/smpboot.c
465 --- linux-2.6.10/arch/i386/kernel/smpboot.c 2004-10-23 05:05:58.000000000 +0200
466 +++ linux-2.6.10-vs1.9.3.17/arch/i386/kernel/smpboot.c 2004-12-26 19:40:36.000000000 +0100
467 @@ -1024,8 +1024,8 @@ static void __init smp_boot_cpus(unsigne
469 "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
471 - bogosum/(500000/HZ),
472 - (bogosum/(5000/HZ))%100);
473 + HZ*(bogosum >> 3)/62500,
474 + (HZ*(bogosum >> 3)/625) % 100);
476 Dprintk("Before bogocount - setting activated=1.\n");
478 diff -NurpP --minimal linux-2.6.10/arch/i386/kernel/sys_i386.c linux-2.6.10-vs1.9.3.17/arch/i386/kernel/sys_i386.c
479 --- linux-2.6.10/arch/i386/kernel/sys_i386.c 2004-08-14 12:56:23.000000000 +0200
480 +++ linux-2.6.10-vs1.9.3.17/arch/i386/kernel/sys_i386.c 2004-12-26 19:40:30.000000000 +0100
482 #include <linux/mman.h>
483 #include <linux/file.h>
484 #include <linux/utsname.h>
485 +#include <linux/vs_cvirt.h>
487 #include <asm/uaccess.h>
489 @@ -217,7 +218,7 @@ asmlinkage int sys_uname(struct old_utsn
493 - err=copy_to_user(name, &system_utsname, sizeof (*name));
494 + err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
496 return err?-EFAULT:0;
498 @@ -225,6 +226,7 @@ asmlinkage int sys_uname(struct old_utsn
499 asmlinkage int sys_olduname(struct oldold_utsname __user * name)
502 + struct new_utsname *ptr;
506 @@ -233,15 +235,16 @@ asmlinkage int sys_olduname(struct oldol
510 - error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
511 + ptr = vx_new_utsname();
512 + error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
513 error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
514 - error |= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
515 + error |= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
516 error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
517 - error |= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
518 + error |= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
519 error |= __put_user(0,name->release+__OLD_UTS_LEN);
520 - error |= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
521 + error |= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
522 error |= __put_user(0,name->version+__OLD_UTS_LEN);
523 - error |= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
524 + error |= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN);
525 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
528 diff -NurpP --minimal linux-2.6.10/arch/i386/kernel/traps.c linux-2.6.10-vs1.9.3.17/arch/i386/kernel/traps.c
529 --- linux-2.6.10/arch/i386/kernel/traps.c 2004-12-25 01:54:44.000000000 +0100
530 +++ linux-2.6.10-vs1.9.3.17/arch/i386/kernel/traps.c 2005-01-02 10:28:58.000000000 +0100
533 #include <linux/irq.h>
534 #include <linux/module.h>
535 +#include <linux/vserver/debug.h>
537 #include "mach_traps.h"
539 @@ -306,6 +307,7 @@ void die(const char * str, struct pt_reg
541 static int die_counter;
544 if (die.lock_owner != smp_processor_id()) {
546 spin_lock_irq(&die.lock);
547 @@ -340,6 +342,7 @@ void die(const char * str, struct pt_reg
550 spin_unlock_irq(&die.lock);
551 + vxh_dump_history();
553 panic("Fatal exception in interrupt");
555 diff -NurpP --minimal linux-2.6.10/arch/i386/mm/hugetlbpage.c linux-2.6.10-vs1.9.3.17/arch/i386/mm/hugetlbpage.c
556 --- linux-2.6.10/arch/i386/mm/hugetlbpage.c 2004-12-25 01:54:44.000000000 +0100
557 +++ linux-2.6.10-vs1.9.3.17/arch/i386/mm/hugetlbpage.c 2004-12-26 19:40:35.000000000 +0100
558 @@ -42,7 +42,8 @@ static void set_huge_pte(struct mm_struc
562 - mm->rss += (HPAGE_SIZE / PAGE_SIZE);
563 + // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
564 + vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
567 pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
568 @@ -82,7 +83,8 @@ int copy_hugetlb_page_range(struct mm_st
569 ptepage = pte_page(entry);
571 set_pte(dst_pte, entry);
572 - dst->rss += (HPAGE_SIZE / PAGE_SIZE);
573 + // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
574 + vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
578 @@ -218,7 +220,8 @@ void unmap_hugepage_range(struct vm_area
579 page = pte_page(pte);
582 - mm->rss -= (end - start) >> PAGE_SHIFT;
583 + // mm->rss -= (end - start) >> PAGE_SHIFT;
584 + vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
585 flush_tlb_range(vma, start, end);
588 diff -NurpP --minimal linux-2.6.10/arch/ia64/Kconfig linux-2.6.10-vs1.9.3.17/arch/ia64/Kconfig
589 --- linux-2.6.10/arch/ia64/Kconfig 2004-10-23 05:05:58.000000000 +0200
590 +++ linux-2.6.10-vs1.9.3.17/arch/ia64/Kconfig 2004-12-26 19:40:21.000000000 +0100
591 @@ -387,6 +387,8 @@ source "arch/ia64/oprofile/Kconfig"
593 source "arch/ia64/Kconfig.debug"
595 +source "kernel/vserver/Kconfig"
597 source "security/Kconfig"
599 source "crypto/Kconfig"
600 diff -NurpP --minimal linux-2.6.10/arch/ia64/ia32/binfmt_elf32.c linux-2.6.10-vs1.9.3.17/arch/ia64/ia32/binfmt_elf32.c
601 --- linux-2.6.10/arch/ia64/ia32/binfmt_elf32.c 2004-12-25 01:54:44.000000000 +0100
602 +++ linux-2.6.10-vs1.9.3.17/arch/ia64/ia32/binfmt_elf32.c 2004-12-26 19:40:35.000000000 +0100
603 @@ -199,7 +199,7 @@ ia64_elf32_init (struct pt_regs *regs)
605 ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
607 - unsigned long stack_base;
608 + unsigned long stack_base, grow;
609 struct vm_area_struct *mpnt;
610 struct mm_struct *mm = current->mm;
612 @@ -216,8 +216,10 @@ ia32_setup_arg_pages (struct linux_binpr
616 - if (security_vm_enough_memory((IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
618 + grow = (IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
620 + if (security_vm_enough_memory(grow) ||
621 + !vx_vmpages_avail(mm, grow)) {
622 kmem_cache_free(vm_area_cachep, mpnt);
625 @@ -242,7 +244,9 @@ ia32_setup_arg_pages (struct linux_binpr
626 kmem_cache_free(vm_area_cachep, mpnt);
629 - current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt);
630 + // current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt);
631 + vx_vmpages_sub(current->mm, current->mm->total_vm - vma_pages(mpnt));
632 + current->mm->stack_vm = current->mm->total_vm;
635 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
636 diff -NurpP --minimal linux-2.6.10/arch/ia64/kernel/entry.S linux-2.6.10-vs1.9.3.17/arch/ia64/kernel/entry.S
637 --- linux-2.6.10/arch/ia64/kernel/entry.S 2004-12-25 01:54:44.000000000 +0100
638 +++ linux-2.6.10-vs1.9.3.17/arch/ia64/kernel/entry.S 2004-12-26 19:40:23.000000000 +0100
639 @@ -1526,7 +1526,7 @@ sys_call_table:
641 data8 sys_mq_getsetattr
642 data8 sys_ni_syscall // reserved for kexec_load
643 - data8 sys_ni_syscall // reserved for vserver
645 data8 sys_waitid // 1270
647 data8 sys_request_key
648 diff -NurpP --minimal linux-2.6.10/arch/ia64/kernel/perfmon.c linux-2.6.10-vs1.9.3.17/arch/ia64/kernel/perfmon.c
649 --- linux-2.6.10/arch/ia64/kernel/perfmon.c 2004-12-25 01:54:44.000000000 +0100
650 +++ linux-2.6.10-vs1.9.3.17/arch/ia64/kernel/perfmon.c 2004-12-26 19:40:35.000000000 +0100
652 #include <linux/mount.h>
653 #include <linux/version.h>
654 #include <linux/bitops.h>
655 +#include <linux/vs_memory.h>
656 +#include <linux/vs_cvirt.h>
658 #include <asm/errno.h>
659 #include <asm/intrinsics.h>
660 @@ -2341,7 +2343,8 @@ pfm_smpl_buffer_alloc(struct task_struct
662 insert_vm_struct(mm, vma);
664 - mm->total_vm += size >> PAGE_SHIFT;
665 + // mm->total_vm += size >> PAGE_SHIFT;
666 + vx_vmpages_add(mm, size >> PAGE_SHIFT);
667 vm_stat_account(vma);
668 up_write(&task->mm->mmap_sem);
670 diff -NurpP --minimal linux-2.6.10/arch/ia64/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/ia64/kernel/ptrace.c
671 --- linux-2.6.10/arch/ia64/kernel/ptrace.c 2004-12-25 01:54:44.000000000 +0100
672 +++ linux-2.6.10-vs1.9.3.17/arch/ia64/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
673 @@ -1326,6 +1326,9 @@ sys_ptrace (long request, pid_t pid, uns
674 read_unlock(&tasklist_lock);
677 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
681 if (pid == 1) /* no messing around with init! */
683 diff -NurpP --minimal linux-2.6.10/arch/ia64/mm/fault.c linux-2.6.10-vs1.9.3.17/arch/ia64/mm/fault.c
684 --- linux-2.6.10/arch/ia64/mm/fault.c 2004-12-25 01:54:44.000000000 +0100
685 +++ linux-2.6.10-vs1.9.3.17/arch/ia64/mm/fault.c 2004-12-26 19:40:35.000000000 +0100
687 #include <linux/mm.h>
688 #include <linux/smp_lock.h>
689 #include <linux/interrupt.h>
690 +#include <linux/vs_memory.h>
692 #include <asm/pgtable.h>
693 #include <asm/processor.h>
694 @@ -33,12 +34,19 @@ expand_backing_store (struct vm_area_str
696 grow = PAGE_SIZE >> PAGE_SHIFT;
697 if (address - vma->vm_start > current->signal->rlim[RLIMIT_STACK].rlim_cur
698 - || (((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->signal->rlim[RLIMIT_AS].rlim_cur))
699 + || (((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) >
700 + current->signal->rlim[RLIMIT_AS].rlim_cur))
702 + if (!vx_vmpages_avail(vma->vm_mm, grow) ||
703 + ((vma->vm_flags & VM_LOCKED) &&
704 + !vx_vmlocked_avail(vma->vm_mm, grow)))
706 vma->vm_end += PAGE_SIZE;
707 - vma->vm_mm->total_vm += grow;
708 + // vma->vm_mm->total_vm += grow;
709 + vx_vmpages_add(vma->vm_mm, grow);
710 if (vma->vm_flags & VM_LOCKED)
711 - vma->vm_mm->locked_vm += grow;
712 + // vma->vm_mm->locked_vm += grow;
713 + vx_vmlocked_add(vma->vm_mm, grow);
714 __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, grow);
717 diff -NurpP --minimal linux-2.6.10/arch/ia64/mm/hugetlbpage.c linux-2.6.10-vs1.9.3.17/arch/ia64/mm/hugetlbpage.c
718 --- linux-2.6.10/arch/ia64/mm/hugetlbpage.c 2004-08-14 12:55:32.000000000 +0200
719 +++ linux-2.6.10-vs1.9.3.17/arch/ia64/mm/hugetlbpage.c 2004-12-26 19:40:35.000000000 +0100
720 @@ -65,7 +65,8 @@ set_huge_pte (struct mm_struct *mm, stru
724 - mm->rss += (HPAGE_SIZE / PAGE_SIZE);
725 + // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
726 + vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
729 pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
730 @@ -108,7 +109,8 @@ int copy_hugetlb_page_range(struct mm_st
731 ptepage = pte_page(entry);
733 set_pte(dst_pte, entry);
734 - dst->rss += (HPAGE_SIZE / PAGE_SIZE);
735 + // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
736 + vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
740 @@ -249,7 +251,8 @@ void unmap_hugepage_range(struct vm_area
744 - mm->rss -= (end - start) >> PAGE_SHIFT;
745 + // mm->rss -= (end - start) >> PAGE_SHIFT;
746 + vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
747 flush_tlb_range(vma, start, end);
750 diff -NurpP --minimal linux-2.6.10/arch/m68k/Kconfig linux-2.6.10-vs1.9.3.17/arch/m68k/Kconfig
751 --- linux-2.6.10/arch/m68k/Kconfig 2004-12-25 01:54:45.000000000 +0100
752 +++ linux-2.6.10-vs1.9.3.17/arch/m68k/Kconfig 2004-12-26 19:40:22.000000000 +0100
753 @@ -659,6 +659,8 @@ source "fs/Kconfig"
755 source "arch/m68k/Kconfig.debug"
757 +source "kernel/vserver/Kconfig"
759 source "security/Kconfig"
761 source "crypto/Kconfig"
762 diff -NurpP --minimal linux-2.6.10/arch/m68k/atari/stram.c linux-2.6.10-vs1.9.3.17/arch/m68k/atari/stram.c
763 --- linux-2.6.10/arch/m68k/atari/stram.c 2004-08-14 12:55:48.000000000 +0200
764 +++ linux-2.6.10-vs1.9.3.17/arch/m68k/atari/stram.c 2004-12-26 19:40:35.000000000 +0100
765 @@ -635,7 +635,8 @@ static inline void unswap_pte(struct vm_
766 set_pte(dir, pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
770 + // ++vma->vm_mm->rss;
771 + vx_rsspages_inc(vma->vm_mm);
774 static inline void unswap_pmd(struct vm_area_struct * vma, pmd_t *dir,
775 diff -NurpP --minimal linux-2.6.10/arch/m68k/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/m68k/kernel/ptrace.c
776 --- linux-2.6.10/arch/m68k/kernel/ptrace.c 2004-12-25 01:54:45.000000000 +0100
777 +++ linux-2.6.10-vs1.9.3.17/arch/m68k/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
778 @@ -140,6 +140,8 @@ asmlinkage int sys_ptrace(long request,
779 read_unlock(&tasklist_lock);
782 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
786 if (pid == 1) /* you may not mess with init */
787 diff -NurpP --minimal linux-2.6.10/arch/m68knommu/Kconfig linux-2.6.10-vs1.9.3.17/arch/m68knommu/Kconfig
788 --- linux-2.6.10/arch/m68knommu/Kconfig 2004-12-25 01:54:45.000000000 +0100
789 +++ linux-2.6.10-vs1.9.3.17/arch/m68knommu/Kconfig 2004-12-26 19:40:23.000000000 +0100
790 @@ -581,6 +581,8 @@ source "fs/Kconfig"
792 source "arch/m68knommu/Kconfig.debug"
794 +source "kernel/vserver/Kconfig"
796 source "security/Kconfig"
798 source "crypto/Kconfig"
799 diff -NurpP --minimal linux-2.6.10/arch/m68knommu/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/m68knommu/kernel/ptrace.c
800 --- linux-2.6.10/arch/m68knommu/kernel/ptrace.c 2004-12-25 01:54:45.000000000 +0100
801 +++ linux-2.6.10-vs1.9.3.17/arch/m68knommu/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
802 @@ -124,6 +124,8 @@ asmlinkage int sys_ptrace(long request,
803 read_unlock(&tasklist_lock);
806 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
810 if (pid == 1) /* you may not mess with init */
811 diff -NurpP --minimal linux-2.6.10/arch/mips/Kconfig linux-2.6.10-vs1.9.3.17/arch/mips/Kconfig
812 --- linux-2.6.10/arch/mips/Kconfig 2004-12-25 01:54:45.000000000 +0100
813 +++ linux-2.6.10-vs1.9.3.17/arch/mips/Kconfig 2004-12-26 19:40:23.000000000 +0100
814 @@ -1581,6 +1581,8 @@ source "fs/Kconfig"
816 source "arch/mips/Kconfig.debug"
818 +source "kernel/vserver/Kconfig"
820 source "security/Kconfig"
822 source "crypto/Kconfig"
823 diff -NurpP --minimal linux-2.6.10/arch/mips/kernel/irixelf.c linux-2.6.10-vs1.9.3.17/arch/mips/kernel/irixelf.c
824 --- linux-2.6.10/arch/mips/kernel/irixelf.c 2004-12-25 01:54:46.000000000 +0100
825 +++ linux-2.6.10-vs1.9.3.17/arch/mips/kernel/irixelf.c 2004-12-26 19:40:35.000000000 +0100
826 @@ -684,7 +684,8 @@ static int load_irix_binary(struct linux
827 /* Do this so that we can load the interpreter, if need be. We will
828 * change some of these later.
830 - current->mm->rss = 0;
831 + // current->mm->rss = 0;
832 + vx_rsspages_sub(current->mm, current->mm->rss);
833 setup_arg_pages(bprm, EXSTACK_DEFAULT);
834 current->mm->start_stack = bprm->p;
836 diff -NurpP --minimal linux-2.6.10/arch/mips/kernel/linux32.c linux-2.6.10-vs1.9.3.17/arch/mips/kernel/linux32.c
837 --- linux-2.6.10/arch/mips/kernel/linux32.c 2004-08-14 12:55:35.000000000 +0200
838 +++ linux-2.6.10-vs1.9.3.17/arch/mips/kernel/linux32.c 2004-12-26 19:40:30.000000000 +0100
839 @@ -1208,7 +1208,7 @@ asmlinkage long sys32_newuname(struct ne
843 - if (copy_to_user(name,&system_utsname,sizeof *name))
844 + if (copy_to_user(name, vx_new_utsname(), sizeof *name))
848 diff -NurpP --minimal linux-2.6.10/arch/mips/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/mips/kernel/ptrace.c
849 --- linux-2.6.10/arch/mips/kernel/ptrace.c 2004-12-25 01:54:46.000000000 +0100
850 +++ linux-2.6.10-vs1.9.3.17/arch/mips/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
851 @@ -76,6 +76,8 @@ asmlinkage int sys_ptrace(long request,
852 read_unlock(&tasklist_lock);
855 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
859 if (pid == 1) /* you may not mess with init */
860 diff -NurpP --minimal linux-2.6.10/arch/mips/kernel/syscall.c linux-2.6.10-vs1.9.3.17/arch/mips/kernel/syscall.c
861 --- linux-2.6.10/arch/mips/kernel/syscall.c 2004-12-25 01:54:46.000000000 +0100
862 +++ linux-2.6.10-vs1.9.3.17/arch/mips/kernel/syscall.c 2004-12-26 19:40:30.000000000 +0100
864 #include <linux/msg.h>
865 #include <linux/shm.h>
866 #include <linux/compiler.h>
867 +#include <linux/vs_cvirt.h>
869 #include <asm/branch.h>
870 #include <asm/cachectl.h>
871 @@ -212,7 +213,7 @@ out:
873 asmlinkage int sys_uname(struct old_utsname * name)
875 - if (name && !copy_to_user(name, &system_utsname, sizeof (*name)))
876 + if (name && !copy_to_user(name, vx_new_utsname(), sizeof (*name)))
880 @@ -223,21 +224,23 @@ asmlinkage int sys_uname(struct old_utsn
881 asmlinkage int sys_olduname(struct oldold_utsname * name)
884 + struct new_utsname *ptr;
888 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
891 - error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
892 + ptr = vx_new_utsname();
893 + error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
894 error -= __put_user(0,name->sysname+__OLD_UTS_LEN);
895 - error -= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
896 + error -= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
897 error -= __put_user(0,name->nodename+__OLD_UTS_LEN);
898 - error -= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
899 + error -= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
900 error -= __put_user(0,name->release+__OLD_UTS_LEN);
901 - error -= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
902 + error -= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
903 error -= __put_user(0,name->version+__OLD_UTS_LEN);
904 - error -= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
905 + error -= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN);
906 error = __put_user(0,name->machine+__OLD_UTS_LEN);
907 error = error ? -EFAULT : 0;
909 @@ -263,10 +266,10 @@ asmlinkage int _sys_sysmips(int cmd, lon
912 down_write(&uts_sem);
913 - strncpy(system_utsname.nodename, nodename, len);
914 + strncpy(vx_new_uts(nodename), nodename, len);
915 nodename[__NEW_UTS_LEN] = '\0';
916 - strlcpy(system_utsname.nodename, nodename,
917 - sizeof(system_utsname.nodename));
918 + strlcpy(vx_new_uts(nodename), nodename,
919 + sizeof(vx_new_uts(nodename)));
923 diff -NurpP --minimal linux-2.6.10/arch/mips/kernel/sysirix.c linux-2.6.10-vs1.9.3.17/arch/mips/kernel/sysirix.c
924 --- linux-2.6.10/arch/mips/kernel/sysirix.c 2004-12-25 01:54:46.000000000 +0100
925 +++ linux-2.6.10-vs1.9.3.17/arch/mips/kernel/sysirix.c 2004-12-26 19:40:35.000000000 +0100
927 #include <linux/socket.h>
928 #include <linux/security.h>
929 #include <linux/syscalls.h>
930 +#include <linux/vs_cvirt.h>
932 #include <asm/ptrace.h>
933 #include <asm/page.h>
934 @@ -582,7 +583,8 @@ asmlinkage int irix_brk(unsigned long br
936 * Check if we have enough memory..
938 - if (security_vm_enough_memory((newbrk-oldbrk) >> PAGE_SHIFT)) {
939 + if (security_vm_enough_memory((newbrk-oldbrk) >> PAGE_SHIFT) ||
940 + !vx_vmpages_avail(mm, (newbrk-oldbrk) >> PAGE_SHIFT)) {
944 diff -NurpP --minimal linux-2.6.10/arch/parisc/Kconfig linux-2.6.10-vs1.9.3.17/arch/parisc/Kconfig
945 --- linux-2.6.10/arch/parisc/Kconfig 2004-10-23 05:05:59.000000000 +0200
946 +++ linux-2.6.10-vs1.9.3.17/arch/parisc/Kconfig 2004-12-26 19:40:23.000000000 +0100
947 @@ -190,6 +190,8 @@ source "arch/parisc/oprofile/Kconfig"
949 source "arch/parisc/Kconfig.debug"
951 +source "kernel/vserver/Kconfig"
953 source "security/Kconfig"
955 source "crypto/Kconfig"
956 diff -NurpP --minimal linux-2.6.10/arch/parisc/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/parisc/kernel/ptrace.c
957 --- linux-2.6.10/arch/parisc/kernel/ptrace.c 2004-12-25 01:54:47.000000000 +0100
958 +++ linux-2.6.10-vs1.9.3.17/arch/parisc/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
959 @@ -110,6 +110,9 @@ long sys_ptrace(long request, pid_t pid,
960 read_unlock(&tasklist_lock);
963 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
967 if (pid == 1) /* no messing around with init! */
969 diff -NurpP --minimal linux-2.6.10/arch/parisc/kernel/sys_parisc32.c linux-2.6.10-vs1.9.3.17/arch/parisc/kernel/sys_parisc32.c
970 --- linux-2.6.10/arch/parisc/kernel/sys_parisc32.c 2004-12-25 01:54:47.000000000 +0100
971 +++ linux-2.6.10-vs1.9.3.17/arch/parisc/kernel/sys_parisc32.c 2004-12-26 19:40:30.000000000 +0100
972 @@ -680,6 +680,7 @@ asmlinkage int sys32_sysinfo(struct sysi
975 seq = read_seqbegin(&xtime_lock);
976 + /* requires vx virtualization */
977 val.uptime = jiffies / HZ;
979 val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
980 diff -NurpP --minimal linux-2.6.10/arch/ppc/Kconfig linux-2.6.10-vs1.9.3.17/arch/ppc/Kconfig
981 --- linux-2.6.10/arch/ppc/Kconfig 2004-12-25 01:54:48.000000000 +0100
982 +++ linux-2.6.10-vs1.9.3.17/arch/ppc/Kconfig 2004-12-26 19:40:23.000000000 +0100
983 @@ -1211,6 +1211,8 @@ source "arch/ppc/oprofile/Kconfig"
985 source "arch/ppc/Kconfig.debug"
987 +source "kernel/vserver/Kconfig"
989 source "security/Kconfig"
991 source "crypto/Kconfig"
992 diff -NurpP --minimal linux-2.6.10/arch/ppc/kernel/misc.S linux-2.6.10-vs1.9.3.17/arch/ppc/kernel/misc.S
993 --- linux-2.6.10/arch/ppc/kernel/misc.S 2004-12-25 01:54:48.000000000 +0100
994 +++ linux-2.6.10-vs1.9.3.17/arch/ppc/kernel/misc.S 2004-12-26 19:40:23.000000000 +0100
995 @@ -1435,7 +1435,7 @@ _GLOBAL(sys_call_table)
996 .long ppc_fadvise64_64
997 .long sys_ni_syscall /* 255 - rtas (used on ppc64) */
998 .long sys_ni_syscall /* 256 reserved for sys_debug_setcontext */
999 - .long sys_ni_syscall /* 257 reserved for vserver */
1001 .long sys_ni_syscall /* 258 reserved for new sys_remap_file_pages */
1002 .long sys_ni_syscall /* 259 reserved for new sys_mbind */
1003 .long sys_ni_syscall /* 260 reserved for new sys_get_mempolicy */
1004 diff -NurpP --minimal linux-2.6.10/arch/ppc/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/ppc/kernel/ptrace.c
1005 --- linux-2.6.10/arch/ppc/kernel/ptrace.c 2004-12-25 01:54:48.000000000 +0100
1006 +++ linux-2.6.10-vs1.9.3.17/arch/ppc/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
1007 @@ -262,6 +262,8 @@ int sys_ptrace(long request, long pid, l
1008 read_unlock(&tasklist_lock);
1011 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1015 if (pid == 1) /* you may not mess with init */
1016 diff -NurpP --minimal linux-2.6.10/arch/ppc/kernel/syscalls.c linux-2.6.10-vs1.9.3.17/arch/ppc/kernel/syscalls.c
1017 --- linux-2.6.10/arch/ppc/kernel/syscalls.c 2004-08-14 12:56:22.000000000 +0200
1018 +++ linux-2.6.10-vs1.9.3.17/arch/ppc/kernel/syscalls.c 2004-12-26 19:40:30.000000000 +0100
1020 #include <linux/utsname.h>
1021 #include <linux/file.h>
1022 #include <linux/unistd.h>
1023 +#include <linux/vs_cvirt.h>
1025 #include <asm/uaccess.h>
1026 #include <asm/ipc.h>
1027 @@ -229,7 +230,7 @@ int sys_uname(struct old_utsname __user
1030 down_read(&uts_sem);
1031 - if (name && !copy_to_user(name, &system_utsname, sizeof (*name)))
1032 + if (name && !copy_to_user(name, vx_new_utsname(), sizeof (*name)))
1036 @@ -238,6 +239,7 @@ int sys_uname(struct old_utsname __user
1037 int sys_olduname(struct oldold_utsname __user * name)
1040 + struct new_utsname *ptr;
1044 @@ -245,15 +247,16 @@ int sys_olduname(struct oldold_utsname _
1047 down_read(&uts_sem);
1048 - error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
1049 + ptr = vx_new_utsname();
1050 + error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
1051 error -= __put_user(0,name->sysname+__OLD_UTS_LEN);
1052 - error -= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
1053 + error -= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
1054 error -= __put_user(0,name->nodename+__OLD_UTS_LEN);
1055 - error -= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
1056 + error -= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
1057 error -= __put_user(0,name->release+__OLD_UTS_LEN);
1058 - error -= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
1059 + error -= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
1060 error -= __put_user(0,name->version+__OLD_UTS_LEN);
1061 - error -= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
1062 + error -= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN);
1063 error = __put_user(0,name->machine+__OLD_UTS_LEN);
1066 diff -NurpP --minimal linux-2.6.10/arch/ppc64/Kconfig linux-2.6.10-vs1.9.3.17/arch/ppc64/Kconfig
1067 --- linux-2.6.10/arch/ppc64/Kconfig 2004-12-25 01:54:48.000000000 +0100
1068 +++ linux-2.6.10-vs1.9.3.17/arch/ppc64/Kconfig 2004-12-26 19:40:23.000000000 +0100
1069 @@ -374,6 +374,8 @@ source "arch/ppc64/oprofile/Kconfig"
1071 source "arch/ppc64/Kconfig.debug"
1073 +source "kernel/vserver/Kconfig"
1075 source "security/Kconfig"
1078 diff -NurpP --minimal linux-2.6.10/arch/ppc64/kernel/misc.S linux-2.6.10-vs1.9.3.17/arch/ppc64/kernel/misc.S
1079 --- linux-2.6.10/arch/ppc64/kernel/misc.S 2004-12-25 01:54:49.000000000 +0100
1080 +++ linux-2.6.10-vs1.9.3.17/arch/ppc64/kernel/misc.S 2004-12-26 19:40:23.000000000 +0100
1081 @@ -951,7 +951,7 @@ _GLOBAL(sys_call_table32)
1082 .llong .ppc32_fadvise64_64 /* 32bit only fadvise64_64 */
1083 .llong .ppc_rtas /* 255 */
1084 .llong .sys_ni_syscall /* 256 reserved for sys_debug_setcontext */
1085 - .llong .sys_ni_syscall /* 257 reserved for vserver */
1086 + .llong .sys_vserver
1087 .llong .sys_ni_syscall /* 258 reserved for new sys_remap_file_pages */
1088 .llong .compat_sys_mbind
1089 .llong .compat_sys_get_mempolicy /* 260 */
1090 diff -NurpP --minimal linux-2.6.10/arch/ppc64/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/ppc64/kernel/ptrace.c
1091 --- linux-2.6.10/arch/ppc64/kernel/ptrace.c 2004-12-25 01:54:49.000000000 +0100
1092 +++ linux-2.6.10-vs1.9.3.17/arch/ppc64/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
1093 @@ -76,6 +76,8 @@ int sys_ptrace(long request, long pid, l
1094 read_unlock(&tasklist_lock);
1097 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1101 if (pid == 1) /* you may not mess with init */
1102 diff -NurpP --minimal linux-2.6.10/arch/ppc64/kernel/sys_ppc32.c linux-2.6.10-vs1.9.3.17/arch/ppc64/kernel/sys_ppc32.c
1103 --- linux-2.6.10/arch/ppc64/kernel/sys_ppc32.c 2004-12-25 01:54:49.000000000 +0100
1104 +++ linux-2.6.10-vs1.9.3.17/arch/ppc64/kernel/sys_ppc32.c 2004-12-26 19:40:30.000000000 +0100
1106 #include <linux/ptrace.h>
1107 #include <linux/aio_abi.h>
1108 #include <linux/elf.h>
1109 +#include <linux/vs_cvirt.h>
1111 #include <net/scm.h>
1112 #include <net/sock.h>
1113 @@ -1173,6 +1174,7 @@ asmlinkage long sys32_time(compat_time_t
1114 asmlinkage int sys32_olduname(struct oldold_utsname __user * name)
1117 + struct new_utsname *ptr;
1121 @@ -1180,15 +1182,16 @@ asmlinkage int sys32_olduname(struct old
1124 down_read(&uts_sem);
1125 - error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
1126 + ptr = vx_new_utsname();
1127 + error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
1128 error -= __put_user(0,name->sysname+__OLD_UTS_LEN);
1129 - error -= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
1130 + error -= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
1131 error -= __put_user(0,name->nodename+__OLD_UTS_LEN);
1132 - error -= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
1133 + error -= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
1134 error -= __put_user(0,name->release+__OLD_UTS_LEN);
1135 - error -= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
1136 + error -= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
1137 error -= __put_user(0,name->version+__OLD_UTS_LEN);
1138 - error -= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
1139 + error -= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN);
1140 error = __put_user(0,name->machine+__OLD_UTS_LEN);
1143 diff -NurpP --minimal linux-2.6.10/arch/ppc64/mm/hugetlbpage.c linux-2.6.10-vs1.9.3.17/arch/ppc64/mm/hugetlbpage.c
1144 --- linux-2.6.10/arch/ppc64/mm/hugetlbpage.c 2004-12-25 01:54:49.000000000 +0100
1145 +++ linux-2.6.10-vs1.9.3.17/arch/ppc64/mm/hugetlbpage.c 2004-12-26 19:40:35.000000000 +0100
1146 @@ -153,7 +153,8 @@ static void set_huge_pte(struct mm_struc
1150 - mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1151 + // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1152 + vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
1155 pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
1156 @@ -311,7 +312,8 @@ int copy_hugetlb_page_range(struct mm_st
1158 ptepage = pte_page(entry);
1160 - dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1161 + // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1162 + vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
1163 set_pte(dst_pte, entry);
1166 @@ -421,7 +423,8 @@ void unmap_hugepage_range(struct vm_area
1170 - mm->rss -= (end - start) >> PAGE_SHIFT;
1171 + // mm->rss -= (end - start) >> PAGE_SHIFT;
1172 + vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
1173 flush_tlb_pending();
1176 diff -NurpP --minimal linux-2.6.10/arch/s390/Kconfig linux-2.6.10-vs1.9.3.17/arch/s390/Kconfig
1177 --- linux-2.6.10/arch/s390/Kconfig 2004-10-23 05:06:01.000000000 +0200
1178 +++ linux-2.6.10-vs1.9.3.17/arch/s390/Kconfig 2004-12-26 19:40:23.000000000 +0100
1179 @@ -461,6 +461,8 @@ source "arch/s390/oprofile/Kconfig"
1181 source "arch/s390/Kconfig.debug"
1183 +source "kernel/vserver/Kconfig"
1185 source "security/Kconfig"
1187 source "crypto/Kconfig"
1188 diff -NurpP --minimal linux-2.6.10/arch/s390/kernel/compat_exec.c linux-2.6.10-vs1.9.3.17/arch/s390/kernel/compat_exec.c
1189 --- linux-2.6.10/arch/s390/kernel/compat_exec.c 2004-12-25 01:54:49.000000000 +0100
1190 +++ linux-2.6.10-vs1.9.3.17/arch/s390/kernel/compat_exec.c 2004-12-26 19:40:35.000000000 +0100
1193 int setup_arg_pages32(struct linux_binprm *bprm, int executable_stack)
1195 - unsigned long stack_base;
1196 + unsigned long stack_base, grow;
1197 struct vm_area_struct *mpnt;
1198 struct mm_struct *mm = current->mm;
1200 @@ -53,7 +53,10 @@ int setup_arg_pages32(struct linux_binpr
1204 - if (security_vm_enough_memory((STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))>>PAGE_SHIFT)) {
1205 + grow = (STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
1207 + if (security_vm_enough_memory(grow) ||
1208 + !vx_vmpages_avail(mm, grow)) {
1209 kmem_cache_free(vm_area_cachep, mpnt);
1212 @@ -73,7 +76,9 @@ int setup_arg_pages32(struct linux_binpr
1213 kmem_cache_free(vm_area_cachep, mpnt);
1216 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
1217 + // mm->stack_vm = mm->total_vm = vma_pages(mpnt);
1218 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
1219 + mm->stack_vm = mm->total_vm;
1222 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
1223 diff -NurpP --minimal linux-2.6.10/arch/s390/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/s390/kernel/ptrace.c
1224 --- linux-2.6.10/arch/s390/kernel/ptrace.c 2004-12-25 01:54:49.000000000 +0100
1225 +++ linux-2.6.10-vs1.9.3.17/arch/s390/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
1226 @@ -698,9 +698,11 @@ sys_ptrace(long request, long pid, long
1227 read_unlock(&tasklist_lock);
1230 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1233 ret = do_ptrace(child, request, addr, data);
1236 put_task_struct(child);
1239 diff -NurpP --minimal linux-2.6.10/arch/s390/kernel/syscalls.S linux-2.6.10-vs1.9.3.17/arch/s390/kernel/syscalls.S
1240 --- linux-2.6.10/arch/s390/kernel/syscalls.S 2004-12-25 01:54:49.000000000 +0100
1241 +++ linux-2.6.10-vs1.9.3.17/arch/s390/kernel/syscalls.S 2004-12-26 19:40:23.000000000 +0100
1242 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
1243 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
1244 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
1245 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
1246 -NI_SYSCALL /* reserved for vserver */
1247 +SYSCALL(sys_vserver,sys_vserver,sys_vserver)
1248 SYSCALL(s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
1249 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
1250 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
1251 diff -NurpP --minimal linux-2.6.10/arch/sh/Kconfig linux-2.6.10-vs1.9.3.17/arch/sh/Kconfig
1252 --- linux-2.6.10/arch/sh/Kconfig 2004-12-25 01:54:49.000000000 +0100
1253 +++ linux-2.6.10-vs1.9.3.17/arch/sh/Kconfig 2004-12-26 19:40:23.000000000 +0100
1254 @@ -784,6 +784,8 @@ source "arch/sh/oprofile/Kconfig"
1256 source "arch/sh/Kconfig.debug"
1258 +source "kernel/vserver/Kconfig"
1260 source "security/Kconfig"
1262 source "crypto/Kconfig"
1263 diff -NurpP --minimal linux-2.6.10/arch/sh/kernel/kgdb_stub.c linux-2.6.10-vs1.9.3.17/arch/sh/kernel/kgdb_stub.c
1264 --- linux-2.6.10/arch/sh/kernel/kgdb_stub.c 2004-08-14 12:54:51.000000000 +0200
1265 +++ linux-2.6.10-vs1.9.3.17/arch/sh/kernel/kgdb_stub.c 2004-12-26 19:40:30.000000000 +0100
1266 @@ -412,7 +412,7 @@ static struct task_struct *get_thread(in
1267 if (pid == PID_MAX) pid = 0;
1269 /* First check via PID */
1270 - thread = find_task_by_pid(pid);
1271 + thread = find_task_by_real_pid(pid);
1275 diff -NurpP --minimal linux-2.6.10/arch/sh/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/sh/kernel/ptrace.c
1276 --- linux-2.6.10/arch/sh/kernel/ptrace.c 2004-12-25 01:54:49.000000000 +0100
1277 +++ linux-2.6.10-vs1.9.3.17/arch/sh/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
1278 @@ -108,6 +108,8 @@ asmlinkage int sys_ptrace(long request,
1279 read_unlock(&tasklist_lock);
1282 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1286 if (pid == 1) /* you may not mess with init */
1287 diff -NurpP --minimal linux-2.6.10/arch/sh/mm/hugetlbpage.c linux-2.6.10-vs1.9.3.17/arch/sh/mm/hugetlbpage.c
1288 --- linux-2.6.10/arch/sh/mm/hugetlbpage.c 2004-08-14 12:55:33.000000000 +0200
1289 +++ linux-2.6.10-vs1.9.3.17/arch/sh/mm/hugetlbpage.c 2004-12-26 19:40:35.000000000 +0100
1290 @@ -62,7 +62,8 @@ static void set_huge_pte(struct mm_struc
1294 - mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1295 + // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1296 + vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
1299 entry = pte_mkwrite(pte_mkdirty(mk_pte(page,
1300 @@ -115,7 +116,8 @@ int copy_hugetlb_page_range(struct mm_st
1301 pte_val(entry) += PAGE_SIZE;
1304 - dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1305 + // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1306 + vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
1310 @@ -206,7 +208,8 @@ void unmap_hugepage_range(struct vm_area
1314 - mm->rss -= (end - start) >> PAGE_SHIFT;
1315 + // mm->rss -= (end - start) >> PAGE_SHIFT;
1316 + vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
1317 flush_tlb_range(vma, start, end);
1320 diff -NurpP --minimal linux-2.6.10/arch/sh64/mm/hugetlbpage.c linux-2.6.10-vs1.9.3.17/arch/sh64/mm/hugetlbpage.c
1321 --- linux-2.6.10/arch/sh64/mm/hugetlbpage.c 2004-08-14 12:55:10.000000000 +0200
1322 +++ linux-2.6.10-vs1.9.3.17/arch/sh64/mm/hugetlbpage.c 2004-12-26 19:40:35.000000000 +0100
1323 @@ -62,8 +62,8 @@ static void set_huge_pte(struct mm_struc
1327 - mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1329 + // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1330 + vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
1332 entry = pte_mkwrite(pte_mkdirty(mk_pte(page,
1333 vma->vm_page_prot)));
1334 @@ -115,7 +115,8 @@ int copy_hugetlb_page_range(struct mm_st
1335 pte_val(entry) += PAGE_SIZE;
1338 - dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1339 + // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1340 + vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
1344 @@ -206,7 +207,8 @@ void unmap_hugepage_range(struct vm_area
1348 - mm->rss -= (end - start) >> PAGE_SHIFT;
1349 + // mm->rss -= (end - start) >> PAGE_SHIFT;
1350 + vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
1351 flush_tlb_range(vma, start, end);
1354 diff -NurpP --minimal linux-2.6.10/arch/sparc/Kconfig linux-2.6.10-vs1.9.3.17/arch/sparc/Kconfig
1355 --- linux-2.6.10/arch/sparc/Kconfig 2004-12-25 01:54:50.000000000 +0100
1356 +++ linux-2.6.10-vs1.9.3.17/arch/sparc/Kconfig 2004-12-26 19:40:23.000000000 +0100
1357 @@ -380,6 +380,8 @@ source "drivers/char/watchdog/Kconfig"
1359 source "arch/sparc/Kconfig.debug"
1361 +source "kernel/vserver/Kconfig"
1363 source "security/Kconfig"
1365 source "crypto/Kconfig"
1366 diff -NurpP --minimal linux-2.6.10/arch/sparc/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/sparc/kernel/ptrace.c
1367 --- linux-2.6.10/arch/sparc/kernel/ptrace.c 2004-12-25 01:54:50.000000000 +0100
1368 +++ linux-2.6.10-vs1.9.3.17/arch/sparc/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
1369 @@ -321,6 +321,10 @@ asmlinkage void do_ptrace(struct pt_regs
1370 pt_error_return(regs, ESRCH);
1373 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) {
1374 + pt_error_return(regs, ESRCH);
1378 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1379 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1380 diff -NurpP --minimal linux-2.6.10/arch/sparc/kernel/sys_sparc.c linux-2.6.10-vs1.9.3.17/arch/sparc/kernel/sys_sparc.c
1381 --- linux-2.6.10/arch/sparc/kernel/sys_sparc.c 2004-08-14 12:55:10.000000000 +0200
1382 +++ linux-2.6.10-vs1.9.3.17/arch/sparc/kernel/sys_sparc.c 2004-12-26 19:40:30.000000000 +0100
1384 #include <linux/utsname.h>
1385 #include <linux/smp.h>
1386 #include <linux/smp_lock.h>
1387 +#include <linux/vs_cvirt.h>
1389 #include <asm/uaccess.h>
1390 #include <asm/ipc.h>
1391 @@ -471,13 +472,13 @@ asmlinkage int sys_getdomainname(char __
1393 down_read(&uts_sem);
1395 - nlen = strlen(system_utsname.domainname) + 1;
1396 + nlen = strlen(vx_new_uts(domainname)) + 1;
1400 if (len > __NEW_UTS_LEN)
1402 - if (copy_to_user(name, system_utsname.domainname, len))
1403 + if (copy_to_user(name, vx_new_uts(domainname), len))
1407 diff -NurpP --minimal linux-2.6.10/arch/sparc/kernel/systbls.S linux-2.6.10-vs1.9.3.17/arch/sparc/kernel/systbls.S
1408 --- linux-2.6.10/arch/sparc/kernel/systbls.S 2004-12-25 01:54:50.000000000 +0100
1409 +++ linux-2.6.10-vs1.9.3.17/arch/sparc/kernel/systbls.S 2004-12-26 19:40:23.000000000 +0100
1410 @@ -72,7 +72,7 @@ sys_call_table:
1411 /*250*/ .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1412 /*255*/ .long sys_nis_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1413 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1414 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
1415 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1416 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1417 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1418 /*280*/ .long sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl
1419 diff -NurpP --minimal linux-2.6.10/arch/sparc64/Kconfig linux-2.6.10-vs1.9.3.17/arch/sparc64/Kconfig
1420 --- linux-2.6.10/arch/sparc64/Kconfig 2004-12-25 01:54:50.000000000 +0100
1421 +++ linux-2.6.10-vs1.9.3.17/arch/sparc64/Kconfig 2004-12-26 19:40:23.000000000 +0100
1422 @@ -597,6 +597,8 @@ source "arch/sparc64/oprofile/Kconfig"
1424 source "arch/sparc64/Kconfig.debug"
1426 +source "kernel/vserver/Kconfig"
1428 source "security/Kconfig"
1430 source "crypto/Kconfig"
1431 diff -NurpP --minimal linux-2.6.10/arch/sparc64/kernel/binfmt_aout32.c linux-2.6.10-vs1.9.3.17/arch/sparc64/kernel/binfmt_aout32.c
1432 --- linux-2.6.10/arch/sparc64/kernel/binfmt_aout32.c 2004-12-25 01:54:50.000000000 +0100
1433 +++ linux-2.6.10-vs1.9.3.17/arch/sparc64/kernel/binfmt_aout32.c 2004-12-26 19:40:35.000000000 +0100
1435 #include <linux/binfmts.h>
1436 #include <linux/personality.h>
1437 #include <linux/init.h>
1438 +#include <linux/vs_memory.h>
1440 #include <asm/system.h>
1441 #include <asm/uaccess.h>
1442 @@ -239,7 +240,8 @@ static int load_aout32_binary(struct lin
1443 current->mm->brk = ex.a_bss +
1444 (current->mm->start_brk = N_BSSADDR(ex));
1446 - current->mm->rss = 0;
1447 + // current->mm->rss = 0;
1448 + vx_rsspages_sub(current->mm, current->mm->rss);
1449 current->mm->mmap = NULL;
1450 compute_creds(bprm);
1451 current->flags &= ~PF_FORKNOEXEC;
1452 diff -NurpP --minimal linux-2.6.10/arch/sparc64/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/sparc64/kernel/ptrace.c
1453 --- linux-2.6.10/arch/sparc64/kernel/ptrace.c 2004-12-25 01:54:50.000000000 +0100
1454 +++ linux-2.6.10-vs1.9.3.17/arch/sparc64/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
1455 @@ -172,6 +172,10 @@ asmlinkage void do_ptrace(struct pt_regs
1456 pt_error_return(regs, ESRCH);
1459 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) {
1460 + pt_error_return(regs, ESRCH);
1464 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1465 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1466 diff -NurpP --minimal linux-2.6.10/arch/sparc64/kernel/sys_sparc.c linux-2.6.10-vs1.9.3.17/arch/sparc64/kernel/sys_sparc.c
1467 --- linux-2.6.10/arch/sparc64/kernel/sys_sparc.c 2004-08-14 12:55:33.000000000 +0200
1468 +++ linux-2.6.10-vs1.9.3.17/arch/sparc64/kernel/sys_sparc.c 2004-12-26 19:40:30.000000000 +0100
1470 #include <linux/syscalls.h>
1471 #include <linux/ipc.h>
1472 #include <linux/personality.h>
1473 +#include <linux/vs_cvirt.h>
1475 #include <asm/uaccess.h>
1476 #include <asm/ipc.h>
1477 @@ -465,13 +466,13 @@ asmlinkage long sys_getdomainname(char _
1479 down_read(&uts_sem);
1481 - nlen = strlen(system_utsname.domainname) + 1;
1482 + nlen = strlen(vx_new_uts(domainname)) + 1;
1486 if (len > __NEW_UTS_LEN)
1488 - if (copy_to_user(name, system_utsname.domainname, len))
1489 + if (copy_to_user(name, vx_new_uts(domainname), len))
1493 diff -NurpP --minimal linux-2.6.10/arch/sparc64/kernel/systbls.S linux-2.6.10-vs1.9.3.17/arch/sparc64/kernel/systbls.S
1494 --- linux-2.6.10/arch/sparc64/kernel/systbls.S 2004-12-25 01:54:50.000000000 +0100
1495 +++ linux-2.6.10-vs1.9.3.17/arch/sparc64/kernel/systbls.S 2004-12-26 19:40:23.000000000 +0100
1496 @@ -73,7 +73,7 @@ sys_call_table32:
1497 /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
1498 .word sys_ni_syscall, sys32_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
1499 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
1500 - .word sys_timer_delete, sys32_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
1501 + .word sys_timer_delete, sys32_timer_create, sys_vserver, compat_sys_io_setup, sys_io_destroy
1502 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
1503 .word sys_mq_timedsend, sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
1504 /*280*/ .word sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl
1505 @@ -139,7 +139,7 @@ sys_call_table:
1506 /*250*/ .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
1507 .word sys_ni_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
1508 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
1509 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
1510 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
1511 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
1512 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
1513 /*280*/ .word sys_nis_syscall, sys_add_key, sys_request_key, sys_keyctl
1514 diff -NurpP --minimal linux-2.6.10/arch/sparc64/mm/hugetlbpage.c linux-2.6.10-vs1.9.3.17/arch/sparc64/mm/hugetlbpage.c
1515 --- linux-2.6.10/arch/sparc64/mm/hugetlbpage.c 2004-08-14 12:55:47.000000000 +0200
1516 +++ linux-2.6.10-vs1.9.3.17/arch/sparc64/mm/hugetlbpage.c 2004-12-26 19:40:35.000000000 +0100
1517 @@ -59,7 +59,8 @@ static void set_huge_pte(struct mm_struc
1521 - mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1522 + // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1523 + vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
1526 entry = pte_mkwrite(pte_mkdirty(mk_pte(page,
1527 @@ -112,7 +113,8 @@ int copy_hugetlb_page_range(struct mm_st
1528 pte_val(entry) += PAGE_SIZE;
1531 - dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1532 + // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1533 + vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
1537 @@ -203,7 +205,8 @@ void unmap_hugepage_range(struct vm_area
1541 - mm->rss -= (end - start) >> PAGE_SHIFT;
1542 + // mm->rss -= (end - start) >> PAGE_SHIFT;
1543 + vx_rsspages_sub(mm, (end - start) >> PAGE_SHIFT);
1544 flush_tlb_range(vma, start, end);
1547 diff -NurpP --minimal linux-2.6.10/arch/um/Kconfig linux-2.6.10-vs1.9.3.17/arch/um/Kconfig
1548 --- linux-2.6.10/arch/um/Kconfig 2004-12-25 01:54:50.000000000 +0100
1549 +++ linux-2.6.10-vs1.9.3.17/arch/um/Kconfig 2004-12-26 19:40:23.000000000 +0100
1550 @@ -250,6 +250,8 @@ source "net/Kconfig"
1554 +source "kernel/vserver/Kconfig"
1556 source "security/Kconfig"
1558 source "crypto/Kconfig"
1559 diff -NurpP --minimal linux-2.6.10/arch/um/kernel/process_kern.c linux-2.6.10-vs1.9.3.17/arch/um/kernel/process_kern.c
1560 --- linux-2.6.10/arch/um/kernel/process_kern.c 2004-12-25 01:54:50.000000000 +0100
1561 +++ linux-2.6.10-vs1.9.3.17/arch/um/kernel/process_kern.c 2004-12-26 19:40:14.000000000 +0100
1563 #include "linux/spinlock.h"
1564 #include "linux/proc_fs.h"
1565 #include "linux/ptrace.h"
1566 +#include "linux/vs_cvirt.h"
1568 #include "asm/unistd.h"
1569 #include "asm/mman.h"
1570 #include "asm/segment.h"
1571 diff -NurpP --minimal linux-2.6.10/arch/um/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/um/kernel/ptrace.c
1572 --- linux-2.6.10/arch/um/kernel/ptrace.c 2004-12-25 01:54:50.000000000 +0100
1573 +++ linux-2.6.10-vs1.9.3.17/arch/um/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
1574 @@ -55,6 +55,8 @@ long sys_ptrace(long request, long pid,
1575 read_unlock(&tasklist_lock);
1578 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1582 if (pid == 1) /* you may not mess with init */
1583 diff -NurpP --minimal linux-2.6.10/arch/um/kernel/sys_call_table.c linux-2.6.10-vs1.9.3.17/arch/um/kernel/sys_call_table.c
1584 --- linux-2.6.10/arch/um/kernel/sys_call_table.c 2004-10-23 05:06:02.000000000 +0200
1585 +++ linux-2.6.10-vs1.9.3.17/arch/um/kernel/sys_call_table.c 2004-12-26 19:40:24.000000000 +0100
1586 @@ -51,6 +51,7 @@ extern syscall_handler_t old_mmap_i386;
1587 extern syscall_handler_t old_select;
1588 extern syscall_handler_t sys_modify_ldt;
1589 extern syscall_handler_t sys_rt_sigsuspend;
1590 +extern syscall_handler_t sys_vserver;
1592 syscall_handler_t *sys_call_table[] = {
1593 [ __NR_restart_syscall ] = (syscall_handler_t *) sys_restart_syscall,
1594 @@ -305,7 +306,7 @@ syscall_handler_t *sys_call_table[] = {
1595 [ __NR_tgkill ] (syscall_handler_t *) sys_tgkill,
1596 [ __NR_utimes ] (syscall_handler_t *) sys_utimes,
1597 [ __NR_fadvise64_64 ] (syscall_handler_t *) sys_fadvise64_64,
1598 - [ __NR_vserver ] (syscall_handler_t *) sys_ni_syscall,
1599 + [ __NR_vserver ] (syscall_handler_t *) sys_vserver,
1602 [ LAST_SYSCALL + 1 ... NR_syscalls ] =
1603 diff -NurpP --minimal linux-2.6.10/arch/um/kernel/syscall_kern.c linux-2.6.10-vs1.9.3.17/arch/um/kernel/syscall_kern.c
1604 --- linux-2.6.10/arch/um/kernel/syscall_kern.c 2004-12-25 01:54:50.000000000 +0100
1605 +++ linux-2.6.10-vs1.9.3.17/arch/um/kernel/syscall_kern.c 2004-12-26 19:40:30.000000000 +0100
1607 #include "linux/unistd.h"
1608 #include "linux/slab.h"
1609 #include "linux/utime.h"
1610 +#include <linux/vs_cvirt.h>
1612 #include "asm/mman.h"
1613 #include "asm/uaccess.h"
1614 #include "asm/ipc.h"
1615 @@ -224,7 +226,7 @@ long sys_uname(struct old_utsname * name
1618 down_read(&uts_sem);
1619 - err=copy_to_user(name, &system_utsname, sizeof (*name));
1620 + err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
1622 return err?-EFAULT:0;
1624 @@ -232,6 +234,7 @@ long sys_uname(struct old_utsname * name
1625 long sys_olduname(struct oldold_utsname * name)
1628 + struct new_utsname *ptr;
1632 @@ -240,19 +243,20 @@ long sys_olduname(struct oldold_utsname
1634 down_read(&uts_sem);
1636 - error = __copy_to_user(&name->sysname,&system_utsname.sysname,
1637 + ptr = vx_new_utsname();
1638 + error = __copy_to_user(&name->sysname,ptr->sysname,
1640 error |= __put_user(0,name->sysname+__OLD_UTS_LEN);
1641 - error |= __copy_to_user(&name->nodename,&system_utsname.nodename,
1642 + error |= __copy_to_user(&name->nodename,ptr->nodename,
1644 error |= __put_user(0,name->nodename+__OLD_UTS_LEN);
1645 - error |= __copy_to_user(&name->release,&system_utsname.release,
1646 + error |= __copy_to_user(&name->release,ptr->release,
1648 error |= __put_user(0,name->release+__OLD_UTS_LEN);
1649 - error |= __copy_to_user(&name->version,&system_utsname.version,
1650 + error |= __copy_to_user(&name->version,ptr->version,
1652 error |= __put_user(0,name->version+__OLD_UTS_LEN);
1653 - error |= __copy_to_user(&name->machine,&system_utsname.machine,
1654 + error |= __copy_to_user(&name->machine,ptr->machine,
1656 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
1658 diff -NurpP --minimal linux-2.6.10/arch/v850/Kconfig linux-2.6.10-vs1.9.3.17/arch/v850/Kconfig
1659 --- linux-2.6.10/arch/v850/Kconfig 2004-10-23 05:06:02.000000000 +0200
1660 +++ linux-2.6.10-vs1.9.3.17/arch/v850/Kconfig 2004-12-26 19:40:23.000000000 +0100
1661 @@ -304,6 +304,8 @@ source "drivers/usb/Kconfig"
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.10/arch/v850/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/v850/kernel/ptrace.c
1671 --- linux-2.6.10/arch/v850/kernel/ptrace.c 2004-12-25 01:54:50.000000000 +0100
1672 +++ linux-2.6.10-vs1.9.3.17/arch/v850/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
1673 @@ -138,6 +138,8 @@ int sys_ptrace(long request, long pid, l
1674 read_unlock(&tasklist_lock);
1677 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1681 if (pid == 1) /* you may not mess with init */
1682 diff -NurpP --minimal linux-2.6.10/arch/x86_64/Kconfig linux-2.6.10-vs1.9.3.17/arch/x86_64/Kconfig
1683 --- linux-2.6.10/arch/x86_64/Kconfig 2004-12-25 01:54:50.000000000 +0100
1684 +++ linux-2.6.10-vs1.9.3.17/arch/x86_64/Kconfig 2004-12-26 19:40:23.000000000 +0100
1685 @@ -440,6 +440,8 @@ source "arch/x86_64/oprofile/Kconfig"
1687 source "arch/x86_64/Kconfig.debug"
1689 +source "kernel/vserver/Kconfig"
1691 source "security/Kconfig"
1693 source "crypto/Kconfig"
1694 diff -NurpP --minimal linux-2.6.10/arch/x86_64/ia32/ia32_aout.c linux-2.6.10-vs1.9.3.17/arch/x86_64/ia32/ia32_aout.c
1695 --- linux-2.6.10/arch/x86_64/ia32/ia32_aout.c 2004-12-25 01:54:50.000000000 +0100
1696 +++ linux-2.6.10-vs1.9.3.17/arch/x86_64/ia32/ia32_aout.c 2004-12-26 19:40:35.000000000 +0100
1698 #include <linux/binfmts.h>
1699 #include <linux/personality.h>
1700 #include <linux/init.h>
1701 +#include <linux/vs_memory.h>
1703 #include <asm/system.h>
1704 #include <asm/uaccess.h>
1705 @@ -310,7 +311,8 @@ static int load_aout_binary(struct linux
1706 (current->mm->start_brk = N_BSSADDR(ex));
1707 current->mm->free_area_cache = TASK_UNMAPPED_BASE;
1709 - current->mm->rss = 0;
1710 + // current->mm->rss = 0;
1711 + vx_rsspages_sub(current->mm, current->mm->rss);
1712 current->mm->mmap = NULL;
1713 compute_creds(bprm);
1714 current->flags &= ~PF_FORKNOEXEC;
1715 diff -NurpP --minimal linux-2.6.10/arch/x86_64/ia32/ia32_binfmt.c linux-2.6.10-vs1.9.3.17/arch/x86_64/ia32/ia32_binfmt.c
1716 --- linux-2.6.10/arch/x86_64/ia32/ia32_binfmt.c 2004-12-25 01:54:50.000000000 +0100
1717 +++ linux-2.6.10-vs1.9.3.17/arch/x86_64/ia32/ia32_binfmt.c 2004-12-26 19:40:35.000000000 +0100
1718 @@ -331,7 +331,7 @@ static void elf32_init(struct pt_regs *r
1720 int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
1722 - unsigned long stack_base;
1723 + unsigned long stack_base, grow;
1724 struct vm_area_struct *mpnt;
1725 struct mm_struct *mm = current->mm;
1727 @@ -348,7 +348,10 @@ int setup_arg_pages(struct linux_binprm
1731 - if (security_vm_enough_memory((IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))>>PAGE_SHIFT)) {
1732 + grow = (IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
1734 + if (security_vm_enough_memory(grow) ||
1735 + !vx_vmpages_avail(mm, grow)) {
1736 kmem_cache_free(vm_area_cachep, mpnt);
1739 @@ -373,7 +376,9 @@ int setup_arg_pages(struct linux_binprm
1740 kmem_cache_free(vm_area_cachep, mpnt);
1743 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
1744 + // mm->stack_vm = mm->total_vm = vma_pages(mpnt);
1745 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
1746 + mm->stack_vm = mm->total_vm;
1749 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
1750 diff -NurpP --minimal linux-2.6.10/arch/x86_64/ia32/ia32entry.S linux-2.6.10-vs1.9.3.17/arch/x86_64/ia32/ia32entry.S
1751 --- linux-2.6.10/arch/x86_64/ia32/ia32entry.S 2004-12-25 01:54:50.000000000 +0100
1752 +++ linux-2.6.10-vs1.9.3.17/arch/x86_64/ia32/ia32entry.S 2004-12-26 19:40:24.000000000 +0100
1753 @@ -575,7 +575,7 @@ ia32_sys_call_table:
1754 .quad sys_tgkill /* 270 */
1755 .quad compat_sys_utimes
1756 .quad sys32_fadvise64_64
1757 - .quad quiet_ni_syscall /* sys_vserver */
1760 .quad compat_sys_get_mempolicy /* 275 */
1761 .quad sys_set_mempolicy
1762 diff -NurpP --minimal linux-2.6.10/arch/x86_64/ia32/sys_ia32.c linux-2.6.10-vs1.9.3.17/arch/x86_64/ia32/sys_ia32.c
1763 --- linux-2.6.10/arch/x86_64/ia32/sys_ia32.c 2004-12-25 01:54:50.000000000 +0100
1764 +++ linux-2.6.10-vs1.9.3.17/arch/x86_64/ia32/sys_ia32.c 2004-12-26 19:40:30.000000000 +0100
1765 @@ -924,6 +924,7 @@ asmlinkage long sys32_mmap2(unsigned lon
1766 asmlinkage long sys32_olduname(struct oldold_utsname __user * name)
1769 + struct new_utsname *ptr;
1773 @@ -932,13 +933,14 @@ asmlinkage long sys32_olduname(struct ol
1775 down_read(&uts_sem);
1777 - error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
1778 + ptr = vx_new_utsname();
1779 + error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN);
1780 __put_user(0,name->sysname+__OLD_UTS_LEN);
1781 - __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
1782 + __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN);
1783 __put_user(0,name->nodename+__OLD_UTS_LEN);
1784 - __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN);
1785 + __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN);
1786 __put_user(0,name->release+__OLD_UTS_LEN);
1787 - __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN);
1788 + __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN);
1789 __put_user(0,name->version+__OLD_UTS_LEN);
1791 char *arch = "x86_64";
1792 @@ -961,7 +963,7 @@ long sys32_uname(struct old_utsname __us
1795 down_read(&uts_sem);
1796 - err=copy_to_user(name, &system_utsname, sizeof (*name));
1797 + err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
1799 if (personality(current->personality) == PER_LINUX32)
1800 err |= copy_to_user(&name->machine, "i686", 5);
1801 diff -NurpP --minimal linux-2.6.10/arch/x86_64/kernel/ptrace.c linux-2.6.10-vs1.9.3.17/arch/x86_64/kernel/ptrace.c
1802 --- linux-2.6.10/arch/x86_64/kernel/ptrace.c 2004-12-25 01:54:50.000000000 +0100
1803 +++ linux-2.6.10-vs1.9.3.17/arch/x86_64/kernel/ptrace.c 2004-12-26 19:40:28.000000000 +0100
1804 @@ -209,6 +209,8 @@ asmlinkage long sys_ptrace(long request,
1805 read_unlock(&tasklist_lock);
1808 + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1812 if (pid == 1) /* you may not mess with init */
1813 diff -NurpP --minimal linux-2.6.10/arch/x86_64/kernel/sys_x86_64.c linux-2.6.10-vs1.9.3.17/arch/x86_64/kernel/sys_x86_64.c
1814 --- linux-2.6.10/arch/x86_64/kernel/sys_x86_64.c 2004-08-14 12:55:35.000000000 +0200
1815 +++ linux-2.6.10-vs1.9.3.17/arch/x86_64/kernel/sys_x86_64.c 2004-12-26 19:40:30.000000000 +0100
1817 #include <linux/file.h>
1818 #include <linux/utsname.h>
1819 #include <linux/personality.h>
1820 +#include <linux/vs_cvirt.h>
1822 #include <asm/uaccess.h>
1823 #include <asm/ipc.h>
1824 @@ -146,7 +147,7 @@ asmlinkage long sys_uname(struct new_uts
1827 down_read(&uts_sem);
1828 - err = copy_to_user(name, &system_utsname, sizeof (*name));
1829 + err = copy_to_user(name, vx_new_utsname(), sizeof (*name));
1831 if (personality(current->personality) == PER_LINUX32)
1832 err |= copy_to_user(&name->machine, "i686", 5);
1833 diff -NurpP --minimal linux-2.6.10/drivers/acpi/osl.c linux-2.6.10-vs1.9.3.17/drivers/acpi/osl.c
1834 --- linux-2.6.10/drivers/acpi/osl.c 2004-12-25 01:54:51.000000000 +0100
1835 +++ linux-2.6.10-vs1.9.3.17/drivers/acpi/osl.c 2004-12-26 19:40:36.000000000 +0100
1836 @@ -937,7 +937,7 @@ acpi_os_wait_semaphore(
1837 // TODO: A better timeout algorithm?
1840 - static const int quantum_ms = 1000/HZ;
1841 + static const int quantum_ms = (HZ>1000)?1:(1000/HZ);
1843 ret = down_trylock(sem);
1844 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
1845 diff -NurpP --minimal linux-2.6.10/drivers/block/floppy.c linux-2.6.10-vs1.9.3.17/drivers/block/floppy.c
1846 --- linux-2.6.10/drivers/block/floppy.c 2004-12-25 01:54:52.000000000 +0100
1847 +++ linux-2.6.10-vs1.9.3.17/drivers/block/floppy.c 2004-12-26 19:40:36.000000000 +0100
1848 @@ -359,7 +359,11 @@ static int inr; /* size of reply buffe
1849 #define R_SECTOR (reply_buffer[5])
1850 #define R_SIZECODE (reply_buffer[6])
1853 #define SEL_DLY (2*HZ/100)
1855 +#define SEL_DLY (255)
1859 * this struct defines the different floppy drive types.
1860 @@ -4090,7 +4094,7 @@ static void __init daring(int *ints, int
1861 FD_SILENT_DCL_CLEAR;
1863 default_drive_params[i].params.select_delay =
1866 default_drive_params[i].params.flags &=
1867 ~FD_SILENT_DCL_CLEAR;
1869 diff -NurpP --minimal linux-2.6.10/drivers/char/dtlk.c linux-2.6.10-vs1.9.3.17/drivers/char/dtlk.c
1870 --- linux-2.6.10/drivers/char/dtlk.c 2004-12-25 01:54:52.000000000 +0100
1871 +++ linux-2.6.10-vs1.9.3.17/drivers/char/dtlk.c 2004-12-26 19:40:36.000000000 +0100
1872 @@ -198,7 +198,7 @@ static ssize_t dtlk_write(struct file *f
1873 up to 250 usec for the RDY bit to
1876 - retries < loops_per_jiffy / (4000/HZ);
1877 + retries < HZ*(loops_per_jiffy >> 3)/500;
1879 if (inb_p(dtlk_port_tts) &
1881 @@ -445,7 +445,7 @@ for (i = 0; i < 10; i++) \
1883 dtlk_write_bytes("\0012I\r", 4);
1885 - __delay(50 * loops_per_jiffy / (1000/HZ));
1886 + __delay(50 * (loops_per_jiffy >> 3) * HZ / 125);
1887 outb_p(0xff, dtlk_port_lpc);
1890 diff -NurpP --minimal linux-2.6.10/drivers/char/pcmcia/synclink_cs.c linux-2.6.10-vs1.9.3.17/drivers/char/pcmcia/synclink_cs.c
1891 --- linux-2.6.10/drivers/char/pcmcia/synclink_cs.c 2004-12-25 01:54:53.000000000 +0100
1892 +++ linux-2.6.10-vs1.9.3.17/drivers/char/pcmcia/synclink_cs.c 2004-12-26 19:40:36.000000000 +0100
1893 @@ -571,7 +571,11 @@ static dev_link_t *mgslpc_attach(void)
1894 INIT_WORK(&info->task, bh_handler, info);
1895 info->max_frame_size = 4096;
1896 info->close_delay = 5*HZ/10;
1898 info->closing_wait = 30*HZ;
1900 + info->closing_wait = 65534;
1902 init_waitqueue_head(&info->open_wait);
1903 init_waitqueue_head(&info->close_wait);
1904 init_waitqueue_head(&info->status_event_wait_q);
1905 diff -NurpP --minimal linux-2.6.10/drivers/char/synclink.c linux-2.6.10-vs1.9.3.17/drivers/char/synclink.c
1906 --- linux-2.6.10/drivers/char/synclink.c 2004-12-25 01:54:54.000000000 +0100
1907 +++ linux-2.6.10-vs1.9.3.17/drivers/char/synclink.c 2004-12-26 19:40:36.000000000 +0100
1908 @@ -4378,7 +4378,11 @@ struct mgsl_struct* mgsl_allocate_device
1909 INIT_WORK(&info->task, mgsl_bh_handler, info);
1910 info->max_frame_size = 4096;
1911 info->close_delay = 5*HZ/10;
1913 info->closing_wait = 30*HZ;
1915 + info->closing_wait = 65534;
1917 init_waitqueue_head(&info->open_wait);
1918 init_waitqueue_head(&info->close_wait);
1919 init_waitqueue_head(&info->status_event_wait_q);
1920 diff -NurpP --minimal linux-2.6.10/drivers/char/synclinkmp.c linux-2.6.10-vs1.9.3.17/drivers/char/synclinkmp.c
1921 --- linux-2.6.10/drivers/char/synclinkmp.c 2004-12-25 01:54:54.000000000 +0100
1922 +++ linux-2.6.10-vs1.9.3.17/drivers/char/synclinkmp.c 2004-12-26 19:40:36.000000000 +0100
1923 @@ -3831,7 +3831,11 @@ SLMP_INFO *alloc_dev(int adapter_num, in
1924 INIT_WORK(&info->task, bh_handler, info);
1925 info->max_frame_size = 4096;
1926 info->close_delay = 5*HZ/10;
1928 info->closing_wait = 30*HZ;
1930 + info->closing_wait = 65534;
1932 init_waitqueue_head(&info->open_wait);
1933 init_waitqueue_head(&info->close_wait);
1934 init_waitqueue_head(&info->status_event_wait_q);
1935 diff -NurpP --minimal linux-2.6.10/drivers/char/tty_io.c linux-2.6.10-vs1.9.3.17/drivers/char/tty_io.c
1936 --- linux-2.6.10/drivers/char/tty_io.c 2004-12-25 01:54:54.000000000 +0100
1937 +++ linux-2.6.10-vs1.9.3.17/drivers/char/tty_io.c 2004-12-26 19:40:30.000000000 +0100
1939 #include <linux/vt_kern.h>
1940 #include <linux/selection.h>
1941 #include <linux/devfs_fs_kernel.h>
1942 +#include <linux/vs_cvirt.h>
1944 #include <linux/kmod.h>
1946 @@ -2092,13 +2093,16 @@ static int tiocsctty(struct tty_struct *
1948 static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
1952 * (tty == real_tty) is a cheap way of
1953 * testing if the tty is NOT a master pty.
1955 if (tty == real_tty && current->signal->tty != real_tty)
1957 - return put_user(real_tty->pgrp, p);
1959 + pgrp = vx_map_pid(real_tty->pgrp);
1960 + return put_user(pgrp, p);
1963 static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
1964 @@ -2116,6 +2120,8 @@ static int tiocspgrp(struct tty_struct *
1966 if (get_user(pgrp, p))
1969 + pgrp = vx_rmap_pid(pgrp);
1972 if (session_of_pgrp(pgrp) != current->signal->session)
1973 diff -NurpP --minimal linux-2.6.10/drivers/usb/serial/io_edgeport.c linux-2.6.10-vs1.9.3.17/drivers/usb/serial/io_edgeport.c
1974 --- linux-2.6.10/drivers/usb/serial/io_edgeport.c 2004-12-25 01:55:15.000000000 +0100
1975 +++ linux-2.6.10-vs1.9.3.17/drivers/usb/serial/io_edgeport.c 2004-12-26 19:40:36.000000000 +0100
1976 @@ -1817,8 +1817,13 @@ static int get_serial_info(struct edgepo
1977 tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
1978 tmp.xmit_fifo_size = edge_port->maxTxCredits;
1979 tmp.baud_base = 9600;
1981 tmp.close_delay = 5*HZ;
1982 tmp.closing_wait = 30*HZ;
1984 + tmp.close_delay = 2*HZ;
1985 + tmp.closing_wait = 65534;
1987 // tmp.custom_divisor = state->custom_divisor;
1988 // tmp.hub6 = state->hub6;
1989 // tmp.io_type = state->io_type;
1990 diff -NurpP --minimal linux-2.6.10/fs/attr.c linux-2.6.10-vs1.9.3.17/fs/attr.c
1991 --- linux-2.6.10/fs/attr.c 2004-08-14 12:54:50.000000000 +0200
1992 +++ linux-2.6.10-vs1.9.3.17/fs/attr.c 2004-12-26 19:40:34.000000000 +0100
1994 #include <linux/fcntl.h>
1995 #include <linux/quotaops.h>
1996 #include <linux/security.h>
1997 +#include <linux/proc_fs.h>
1998 +#include <linux/devpts_fs.h>
1999 +#include <linux/vserver/debug.h>
2001 /* Taken over from the old code... */
2003 @@ -55,6 +58,28 @@ int inode_change_ok(struct inode *inode,
2004 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
2008 + /* Check for evil vserver activity */
2009 + if (vx_check(0, VX_ADMIN))
2012 + if (IS_BARRIER(inode)) {
2013 + vxwprintk(1, "xid=%d messing with the barrier.",
2014 + vx_current_xid());
2017 + switch (inode->i_sb->s_magic) {
2018 + case PROC_SUPER_MAGIC:
2019 + vxwprintk(1, "xid=%d messing with the procfs.",
2020 + vx_current_xid());
2022 + case DEVPTS_SUPER_MAGIC:
2023 + if (vx_check(inode->i_xid, VX_IDENT))
2025 + vxwprintk(1, "xid=%d messing with the devpts.",
2026 + vx_current_xid());
2032 @@ -63,6 +88,24 @@ error:
2034 EXPORT_SYMBOL(inode_change_ok);
2036 +int inode_setattr_flags(struct inode *inode, unsigned int flags)
2038 + unsigned int oldflags, newflags;
2040 + oldflags = inode->i_flags;
2041 + newflags = oldflags & ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER);
2042 + if (flags & ATTR_FLAG_IMMUTABLE)
2043 + newflags |= S_IMMUTABLE;
2044 + if (flags & ATTR_FLAG_IUNLINK)
2045 + newflags |= S_IUNLINK;
2046 + if (flags & ATTR_FLAG_BARRIER)
2047 + newflags |= S_BARRIER;
2049 + if (oldflags ^ newflags)
2050 + inode->i_flags = newflags;
2054 int inode_setattr(struct inode * inode, struct iattr * attr)
2056 unsigned int ia_valid = attr->ia_valid;
2057 @@ -86,6 +129,8 @@ int inode_setattr(struct inode * inode,
2058 inode->i_uid = attr->ia_uid;
2059 if (ia_valid & ATTR_GID)
2060 inode->i_gid = attr->ia_gid;
2061 + if (ia_valid & ATTR_XID)
2062 + inode->i_xid = attr->ia_xid;
2063 if (ia_valid & ATTR_ATIME)
2064 inode->i_atime = attr->ia_atime;
2065 if (ia_valid & ATTR_MTIME)
2066 @@ -99,6 +144,8 @@ int inode_setattr(struct inode * inode,
2068 inode->i_mode = mode;
2070 + if (ia_valid & ATTR_ATTR_FLAG)
2071 + inode_setattr_flags(inode, attr->ia_attr_flags);
2072 mark_inode_dirty(inode);
2075 @@ -114,6 +161,8 @@ int setattr_mask(unsigned int ia_valid)
2076 dn_mask |= DN_ATTRIB;
2077 if (ia_valid & ATTR_GID)
2078 dn_mask |= DN_ATTRIB;
2079 + if (ia_valid & ATTR_XID)
2080 + dn_mask |= DN_ATTRIB;
2081 if (ia_valid & ATTR_SIZE)
2082 dn_mask |= DN_MODIFY;
2083 /* both times implies a utime(s) call */
2084 @@ -177,7 +226,8 @@ int notify_change(struct dentry * dentry
2085 error = security_inode_setattr(dentry, attr);
2087 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2088 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
2089 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2090 + (ia_valid & ATTR_XID && attr->ia_xid != inode->i_xid))
2091 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
2093 error = inode_setattr(inode, attr);
2094 diff -NurpP --minimal linux-2.6.10/fs/binfmt_aout.c linux-2.6.10-vs1.9.3.17/fs/binfmt_aout.c
2095 --- linux-2.6.10/fs/binfmt_aout.c 2004-12-25 01:55:19.000000000 +0100
2096 +++ linux-2.6.10-vs1.9.3.17/fs/binfmt_aout.c 2004-12-26 19:40:35.000000000 +0100
2098 #include <linux/binfmts.h>
2099 #include <linux/personality.h>
2100 #include <linux/init.h>
2101 +#include <linux/vs_memory.h>
2103 #include <asm/system.h>
2104 #include <asm/uaccess.h>
2105 @@ -314,7 +315,8 @@ static int load_aout_binary(struct linux
2106 (current->mm->start_brk = N_BSSADDR(ex));
2107 current->mm->free_area_cache = current->mm->mmap_base;
2109 - current->mm->rss = 0;
2110 + // current->mm->rss = 0;
2111 + vx_rsspages_sub(current->mm, current->mm->rss);
2112 current->mm->mmap = NULL;
2113 compute_creds(bprm);
2114 current->flags &= ~PF_FORKNOEXEC;
2115 diff -NurpP --minimal linux-2.6.10/fs/binfmt_elf.c linux-2.6.10-vs1.9.3.17/fs/binfmt_elf.c
2116 --- linux-2.6.10/fs/binfmt_elf.c 2004-12-25 01:55:19.000000000 +0100
2117 +++ linux-2.6.10-vs1.9.3.17/fs/binfmt_elf.c 2004-12-26 19:40:35.000000000 +0100
2119 #include <linux/pagemap.h>
2120 #include <linux/security.h>
2121 #include <linux/syscalls.h>
2122 +#include <linux/vs_memory.h>
2124 #include <asm/uaccess.h>
2125 #include <asm/param.h>
2126 @@ -734,7 +735,8 @@ static int load_elf_binary(struct linux_
2128 /* Do this so that we can load the interpreter, if need be. We will
2129 change some of these later */
2130 - current->mm->rss = 0;
2131 + // current->mm->rss = 0;
2132 + vx_rsspages_sub(current->mm, current->mm->rss);
2133 current->mm->free_area_cache = current->mm->mmap_base;
2134 retval = setup_arg_pages(bprm, executable_stack);
2136 diff -NurpP --minimal linux-2.6.10/fs/binfmt_flat.c linux-2.6.10-vs1.9.3.17/fs/binfmt_flat.c
2137 --- linux-2.6.10/fs/binfmt_flat.c 2004-12-25 01:55:19.000000000 +0100
2138 +++ linux-2.6.10-vs1.9.3.17/fs/binfmt_flat.c 2004-12-26 19:40:35.000000000 +0100
2140 #include <linux/personality.h>
2141 #include <linux/init.h>
2142 #include <linux/flat.h>
2143 +#include <linux/vs_memory.h>
2145 #include <asm/byteorder.h>
2146 #include <asm/system.h>
2147 @@ -650,7 +651,8 @@ static int load_flat_file(struct linux_b
2148 current->mm->start_brk = datapos + data_len + bss_len;
2149 current->mm->brk = (current->mm->start_brk + 3) & ~3;
2150 current->mm->context.end_brk = memp + ksize((void *) memp) - stack_len;
2151 - current->mm->rss = 0;
2152 + // current->mm->rss = 0;
2153 + vx_rsspages_sub(current->mm, current->mm->rss);
2156 if (flags & FLAT_FLAG_KTRACE)
2157 diff -NurpP --minimal linux-2.6.10/fs/binfmt_som.c linux-2.6.10-vs1.9.3.17/fs/binfmt_som.c
2158 --- linux-2.6.10/fs/binfmt_som.c 2004-08-14 12:55:19.000000000 +0200
2159 +++ linux-2.6.10-vs1.9.3.17/fs/binfmt_som.c 2004-12-26 19:40:35.000000000 +0100
2161 #include <linux/shm.h>
2162 #include <linux/personality.h>
2163 #include <linux/init.h>
2164 +#include <linux/vs_memory.h>
2166 #include <asm/uaccess.h>
2167 #include <asm/pgtable.h>
2168 @@ -259,7 +260,8 @@ load_som_binary(struct linux_binprm * bp
2169 create_som_tables(bprm);
2171 current->mm->start_stack = bprm->p;
2172 - current->mm->rss = 0;
2173 + // current->mm->rss = 0;
2174 + vx_rsspages_sub(current->mm, current->mm->rss);
2177 printk("(start_brk) %08lx\n" , (unsigned long) current->mm->start_brk);
2178 diff -NurpP --minimal linux-2.6.10/fs/devpts/inode.c linux-2.6.10-vs1.9.3.17/fs/devpts/inode.c
2179 --- linux-2.6.10/fs/devpts/inode.c 2004-12-25 01:55:20.000000000 +0100
2180 +++ linux-2.6.10-vs1.9.3.17/fs/devpts/inode.c 2004-12-26 19:40:30.000000000 +0100
2181 @@ -31,6 +31,15 @@ static struct xattr_handler *devpts_xatt
2185 +static int devpts_permission(struct inode *inode, int mask, struct nameidata *nd)
2187 + int ret = -EACCES;
2189 + if (vx_check(inode->i_xid, VX_IDENT))
2190 + ret = generic_permission(inode, mask, NULL);
2194 struct inode_operations devpts_file_inode_operations = {
2195 #ifdef CONFIG_DEVPTS_FS_XATTR
2196 .setxattr = generic_setxattr,
2197 @@ -38,6 +47,7 @@ struct inode_operations devpts_file_inod
2198 .listxattr = generic_listxattr,
2199 .removexattr = generic_removexattr,
2201 + .permission = devpts_permission,
2204 static struct vfsmount *devpts_mnt;
2205 @@ -88,6 +98,68 @@ static int devpts_remount(struct super_b
2209 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2211 + struct dentry *dentry = filp->f_dentry;
2212 + struct dentry *cursor = filp->private_data;
2213 + struct list_head *p, *q = &cursor->d_child;
2215 + int i = filp->f_pos;
2219 + ino = dentry->d_inode->i_ino;
2220 + if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
2226 + ino = parent_ino(dentry);
2227 + if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0)
2233 + spin_lock(&dcache_lock);
2234 + if (filp->f_pos == 2) {
2236 + list_add(q, &dentry->d_subdirs);
2238 + for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
2239 + struct dentry *next;
2240 + next = list_entry(p, struct dentry, d_child);
2241 + if (d_unhashed(next) || !next->d_inode)
2243 + if (!vx_check(next->d_inode->i_xid, VX_IDENT))
2246 + spin_unlock(&dcache_lock);
2247 + if (filldir(dirent, next->d_name.name,
2248 + next->d_name.len, filp->f_pos,
2249 + next->d_inode->i_ino, DT_CHR) < 0)
2251 + spin_lock(&dcache_lock);
2252 + /* next is still alive */
2258 + spin_unlock(&dcache_lock);
2263 +static struct file_operations devpts_dir_operations = {
2264 + .open = dcache_dir_open,
2265 + .release = dcache_dir_close,
2266 + .llseek = dcache_dir_lseek,
2267 + .read = generic_read_dir,
2268 + .readdir = devpts_readdir,
2271 static struct super_operations devpts_sops = {
2272 .statfs = simple_statfs,
2273 .remount_fs = devpts_remount,
2274 @@ -114,8 +186,9 @@ devpts_fill_super(struct super_block *s,
2275 inode->i_uid = inode->i_gid = 0;
2276 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2277 inode->i_op = &simple_dir_inode_operations;
2278 - inode->i_fop = &simple_dir_operations;
2279 + inode->i_fop = &devpts_dir_operations;
2281 + inode->i_xid = vx_current_xid();
2283 devpts_root = s->s_root = d_alloc_root(inode);
2285 @@ -174,6 +247,7 @@ int devpts_pty_new(struct tty_struct *tt
2286 inode->i_gid = config.setgid ? config.gid : current->fsgid;
2287 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2288 init_special_inode(inode, S_IFCHR|config.mode, device);
2289 + inode->i_xid = vx_current_xid();
2290 inode->i_op = &devpts_file_inode_operations;
2291 inode->u.generic_ip = tty;
2293 diff -NurpP --minimal linux-2.6.10/fs/exec.c linux-2.6.10-vs1.9.3.17/fs/exec.c
2294 --- linux-2.6.10/fs/exec.c 2004-12-25 01:55:20.000000000 +0100
2295 +++ linux-2.6.10-vs1.9.3.17/fs/exec.c 2004-12-26 19:40:35.000000000 +0100
2297 #include <linux/security.h>
2298 #include <linux/syscalls.h>
2299 #include <linux/rmap.h>
2300 +#include <linux/vs_memory.h>
2302 #include <asm/uaccess.h>
2303 #include <asm/mmu_context.h>
2304 @@ -320,7 +321,8 @@ void install_arg_page(struct vm_area_str
2310 + vx_rsspages_inc(mm);
2311 lru_cache_add_active(page);
2312 set_pte(pte, pte_mkdirty(pte_mkwrite(mk_pte(
2313 page, vma->vm_page_prot))));
2314 @@ -404,7 +406,8 @@ int setup_arg_pages(struct linux_binprm
2318 - if (security_vm_enough_memory(arg_size >> PAGE_SHIFT)) {
2319 + if (security_vm_enough_memory(arg_size >> PAGE_SHIFT) ||
2320 + !vx_vmpages_avail(mm, arg_size >> PAGE_SHIFT)) {
2321 kmem_cache_free(vm_area_cachep, mpnt);
2324 @@ -438,7 +441,9 @@ int setup_arg_pages(struct linux_binprm
2325 kmem_cache_free(vm_area_cachep, mpnt);
2328 - mm->stack_vm = mm->total_vm = vma_pages(mpnt);
2329 + // mm->stack_vm = mm->total_vm = vma_pages(mpnt);
2330 + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
2331 + mm->stack_vm = mm->total_vm;
2334 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
2335 diff -NurpP --minimal linux-2.6.10/fs/ext2/balloc.c linux-2.6.10-vs1.9.3.17/fs/ext2/balloc.c
2336 --- linux-2.6.10/fs/ext2/balloc.c 2004-10-23 05:06:16.000000000 +0200
2337 +++ linux-2.6.10-vs1.9.3.17/fs/ext2/balloc.c 2004-12-26 19:40:35.000000000 +0100
2339 #include <linux/quotaops.h>
2340 #include <linux/sched.h>
2341 #include <linux/buffer_head.h>
2342 +#include <linux/vs_dlimit.h>
2345 * balloc.c contains the blocks allocation and deallocation routines
2346 @@ -108,6 +109,8 @@ static int reserve_blocks(struct super_b
2347 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
2348 root_blocks = le32_to_cpu(es->s_r_blocks_count);
2350 + DLIMIT_ADJUST_BLOCK(sb, vx_current_xid(), &free_blocks, &root_blocks);
2352 if (free_blocks < count)
2353 count = free_blocks;
2355 @@ -258,6 +261,7 @@ do_more:
2359 + DLIMIT_FREE_BLOCK(sb, inode->i_xid, freed);
2360 release_blocks(sb, freed);
2361 DQUOT_FREE_BLOCK(inode, freed);
2363 @@ -361,6 +365,10 @@ int ext2_new_block(struct inode *inode,
2367 + if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, es_alloc)) {
2372 ext2_debug ("goal=%lu.\n", goal);
2374 @@ -508,6 +516,8 @@ got_block:
2377 group_release_blocks(sb, group_no, desc, gdp_bh, group_alloc);
2378 + DLIMIT_FREE_BLOCK(sb, inode->i_xid, es_alloc);
2380 release_blocks(sb, es_alloc);
2382 DQUOT_FREE_BLOCK(inode, dq_alloc);
2383 diff -NurpP --minimal linux-2.6.10/fs/ext2/ialloc.c linux-2.6.10-vs1.9.3.17/fs/ext2/ialloc.c
2384 --- linux-2.6.10/fs/ext2/ialloc.c 2004-10-23 05:06:16.000000000 +0200
2385 +++ linux-2.6.10-vs1.9.3.17/fs/ext2/ialloc.c 2004-12-26 19:40:35.000000000 +0100
2387 #include <linux/backing-dev.h>
2388 #include <linux/buffer_head.h>
2389 #include <linux/random.h>
2390 +#include <linux/vs_dlimit.h>
2395 @@ -124,6 +126,7 @@ void ext2_free_inode (struct inode * ino
2396 if (!is_bad_inode(inode)) {
2397 /* Quota is already initialized in iput() */
2398 ext2_xattr_delete_inode(inode);
2399 + DLIMIT_FREE_INODE(sb, inode->i_xid);
2400 DQUOT_FREE_INODE(inode);
2403 @@ -465,6 +468,15 @@ struct inode *ext2_new_inode(struct inod
2405 return ERR_PTR(-ENOMEM);
2407 + if (sb->s_flags & MS_TAGXID)
2408 + inode->i_xid = vx_current_xid();
2412 + if (DLIMIT_ALLOC_INODE(sb, inode->i_xid)) {
2419 @@ -579,7 +591,8 @@ got:
2420 inode->i_blocks = 0;
2421 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2422 memset(ei->i_data, 0, sizeof(ei->i_data));
2423 - ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
2424 + ei->i_flags = EXT2_I(dir)->i_flags &
2425 + ~(EXT2_BTREE_FL|EXT2_IUNLINK_FL|EXT2_BARRIER_FL);
2427 ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
2428 /* dirsync is only applied to directories */
2429 @@ -620,12 +633,15 @@ got:
2433 + DLIMIT_FREE_INODE(sb, inode->i_xid);
2434 inode->i_flags |= S_NOQUOTA;
2437 return ERR_PTR(err);
2440 + DLIMIT_FREE_INODE(sb, inode->i_xid);
2442 make_bad_inode(inode);
2444 return ERR_PTR(err);
2445 diff -NurpP --minimal linux-2.6.10/fs/ext2/inode.c linux-2.6.10-vs1.9.3.17/fs/ext2/inode.c
2446 --- linux-2.6.10/fs/ext2/inode.c 2004-12-25 01:55:20.000000000 +0100
2447 +++ linux-2.6.10-vs1.9.3.17/fs/ext2/inode.c 2004-12-26 19:40:34.000000000 +0100
2449 #include <linux/writeback.h>
2450 #include <linux/buffer_head.h>
2451 #include <linux/mpage.h>
2452 +#include <linux/vserver/xid.h>
2456 @@ -52,6 +53,8 @@ static inline int ext2_inode_is_fast_sym
2457 inode->i_blocks - ea_blocks == 0);
2460 +static void ext2_truncate_nocheck (struct inode * inode);
2463 * Called at the last iput() if i_nlink is zero.
2465 @@ -65,7 +68,7 @@ void ext2_delete_inode (struct inode * i
2468 if (inode->i_blocks)
2469 - ext2_truncate (inode);
2470 + ext2_truncate_nocheck(inode);
2471 ext2_free_inode (inode);
2474 @@ -865,7 +868,7 @@ static void ext2_free_branches(struct in
2475 ext2_free_data(inode, p, q);
2478 -void ext2_truncate (struct inode * inode)
2479 +static void ext2_truncate_nocheck(struct inode * inode)
2481 __le32 *i_data = EXT2_I(inode)->i_data;
2482 int addr_per_block = EXT2_ADDR_PER_BLOCK(inode->i_sb);
2483 @@ -882,8 +885,6 @@ void ext2_truncate (struct inode * inode
2485 if (ext2_inode_is_fast_symlink(inode))
2487 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2490 ext2_discard_prealloc(inode);
2492 @@ -1005,17 +1006,28 @@ Egdp:
2493 return ERR_PTR(-EIO);
2496 +void ext2_truncate (struct inode * inode)
2498 + if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2500 + ext2_truncate_nocheck(inode);
2503 void ext2_set_inode_flags(struct inode *inode)
2505 unsigned int flags = EXT2_I(inode)->i_flags;
2507 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2508 + inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_IUNLINK|S_BARRIER|S_NOATIME|S_DIRSYNC);
2509 if (flags & EXT2_SYNC_FL)
2510 inode->i_flags |= S_SYNC;
2511 if (flags & EXT2_APPEND_FL)
2512 inode->i_flags |= S_APPEND;
2513 if (flags & EXT2_IMMUTABLE_FL)
2514 inode->i_flags |= S_IMMUTABLE;
2515 + if (flags & EXT2_IUNLINK_FL)
2516 + inode->i_flags |= S_IUNLINK;
2517 + if (flags & EXT2_BARRIER_FL)
2518 + inode->i_flags |= S_BARRIER;
2519 if (flags & EXT2_NOATIME_FL)
2520 inode->i_flags |= S_NOATIME;
2521 if (flags & EXT2_DIRSYNC_FL)
2522 @@ -1028,6 +1040,8 @@ void ext2_read_inode (struct inode * ino
2523 ino_t ino = inode->i_ino;
2524 struct buffer_head * bh;
2525 struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh);
2530 #ifdef CONFIG_EXT2_FS_POSIX_ACL
2531 @@ -1038,12 +1052,17 @@ void ext2_read_inode (struct inode * ino
2534 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2535 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2536 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2537 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2538 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2539 if (!(test_opt (inode->i_sb, NO_UID32))) {
2540 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2541 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2542 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2543 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2545 + inode->i_uid = INOXID_UID(XID_TAG(inode), uid, gid);
2546 + inode->i_gid = INOXID_GID(XID_TAG(inode), uid, gid);
2547 + inode->i_xid = INOXID_XID(XID_TAG(inode), uid, gid,
2548 + le16_to_cpu(raw_inode->i_raw_xid));
2550 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2551 inode->i_size = le32_to_cpu(raw_inode->i_size);
2552 inode->i_atime.tv_sec = le32_to_cpu(raw_inode->i_atime);
2553 @@ -1136,8 +1155,8 @@ static int ext2_update_inode(struct inod
2554 struct ext2_inode_info *ei = EXT2_I(inode);
2555 struct super_block *sb = inode->i_sb;
2556 ino_t ino = inode->i_ino;
2557 - uid_t uid = inode->i_uid;
2558 - gid_t gid = inode->i_gid;
2559 + uid_t uid = XIDINO_UID(XID_TAG(inode), inode->i_uid, inode->i_xid);
2560 + gid_t gid = XIDINO_GID(XID_TAG(inode), inode->i_gid, inode->i_xid);
2561 struct buffer_head * bh;
2562 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2564 @@ -1172,6 +1191,9 @@ static int ext2_update_inode(struct inod
2565 raw_inode->i_uid_high = 0;
2566 raw_inode->i_gid_high = 0;
2568 +#ifdef CONFIG_INOXID_INTERN
2569 + raw_inode->i_raw_xid = cpu_to_le16(inode->i_xid);
2571 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2572 raw_inode->i_size = cpu_to_le32(inode->i_size);
2573 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2574 @@ -1249,6 +1271,27 @@ int ext2_sync_inode(struct inode *inode)
2575 return sync_inode(inode, &wbc);
2578 +int ext2_setattr_flags(struct inode *inode, unsigned int flags)
2580 + unsigned int oldflags, newflags;
2582 + oldflags = EXT2_I(inode)->i_flags;
2583 + newflags = oldflags &
2584 + ~(EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL | EXT2_BARRIER_FL);
2585 + if (flags & ATTR_FLAG_IMMUTABLE)
2586 + newflags |= EXT2_IMMUTABLE_FL;
2587 + if (flags & ATTR_FLAG_IUNLINK)
2588 + newflags |= EXT2_IUNLINK_FL;
2589 + if (flags & ATTR_FLAG_BARRIER)
2590 + newflags |= EXT2_BARRIER_FL;
2592 + if (oldflags ^ newflags) {
2593 + EXT2_I(inode)->i_flags = newflags;
2594 + inode->i_ctime = CURRENT_TIME;
2599 int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
2601 struct inode *inode = dentry->d_inode;
2602 @@ -1258,11 +1301,15 @@ int ext2_setattr(struct dentry *dentry,
2605 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2606 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2607 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2608 + (iattr->ia_valid & ATTR_XID && iattr->ia_xid != inode->i_xid)) {
2609 error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0;
2613 + if (iattr->ia_valid & ATTR_ATTR_FLAG)
2614 + ext2_setattr_flags(inode, iattr->ia_attr_flags);
2616 error = inode_setattr(inode, iattr);
2617 if (!error && (iattr->ia_valid & ATTR_MODE))
2618 error = ext2_acl_chmod(inode);
2619 diff -NurpP --minimal linux-2.6.10/fs/ext2/ioctl.c linux-2.6.10-vs1.9.3.17/fs/ext2/ioctl.c
2620 --- linux-2.6.10/fs/ext2/ioctl.c 2004-08-14 12:56:24.000000000 +0200
2621 +++ linux-2.6.10-vs1.9.3.17/fs/ext2/ioctl.c 2004-12-26 19:40:30.000000000 +0100
2622 @@ -49,7 +49,9 @@ int ext2_ioctl (struct inode * inode, st
2624 * This test looks nicer. Thanks to Pauline Middelink
2626 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2627 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2628 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2629 + EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL))) {
2630 if (!capable(CAP_LINUX_IMMUTABLE))
2633 diff -NurpP --minimal linux-2.6.10/fs/ext2/namei.c linux-2.6.10-vs1.9.3.17/fs/ext2/namei.c
2634 --- linux-2.6.10/fs/ext2/namei.c 2004-12-25 01:55:20.000000000 +0100
2635 +++ linux-2.6.10-vs1.9.3.17/fs/ext2/namei.c 2004-12-26 19:40:34.000000000 +0100
2639 #include <linux/pagemap.h>
2640 +#include <linux/vserver/xid.h>
2644 @@ -81,6 +82,7 @@ static struct dentry *ext2_lookup(struct
2645 inode = iget(dir->i_sb, ino);
2647 return ERR_PTR(-EACCES);
2648 + vx_propagate_xid(nd, inode);
2651 return d_splice_alias(inode, dentry);
2652 diff -NurpP --minimal linux-2.6.10/fs/ext2/super.c linux-2.6.10-vs1.9.3.17/fs/ext2/super.c
2653 --- linux-2.6.10/fs/ext2/super.c 2004-12-25 01:55:20.000000000 +0100
2654 +++ linux-2.6.10-vs1.9.3.17/fs/ext2/super.c 2004-12-26 19:40:34.000000000 +0100
2655 @@ -250,7 +250,7 @@ enum {
2656 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
2657 Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
2658 Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, Opt_nobh,
2659 - Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl,
2660 + Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, Opt_tagxid,
2661 Opt_ignore, Opt_err,
2664 @@ -279,6 +279,7 @@ static match_table_t tokens = {
2665 {Opt_nouser_xattr, "nouser_xattr"},
2667 {Opt_noacl, "noacl"},
2668 + {Opt_tagxid, "tagxid"},
2669 {Opt_ignore, "grpquota"},
2670 {Opt_ignore, "noquota"},
2671 {Opt_ignore, "quota"},
2672 @@ -342,6 +343,11 @@ static int parse_options (char * options
2674 set_opt (sbi->s_mount_opt, NO_UID32);
2676 +#ifndef CONFIG_INOXID_NONE
2678 + set_opt (sbi->s_mount_opt, TAG_XID);
2682 #ifdef CONFIG_EXT2_CHECK
2683 set_opt (sbi->s_mount_opt, CHECK);
2684 @@ -624,6 +630,8 @@ static int ext2_fill_super(struct super_
2685 if (!parse_options ((char *) data, sbi))
2688 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAG_XID)
2689 + sb->s_flags |= MS_TAGXID;
2690 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2691 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2693 diff -NurpP --minimal linux-2.6.10/fs/ext2/xattr.c linux-2.6.10-vs1.9.3.17/fs/ext2/xattr.c
2694 --- linux-2.6.10/fs/ext2/xattr.c 2004-12-25 01:55:20.000000000 +0100
2695 +++ linux-2.6.10-vs1.9.3.17/fs/ext2/xattr.c 2004-12-26 19:40:35.000000000 +0100
2697 #include <linux/mbcache.h>
2698 #include <linux/quotaops.h>
2699 #include <linux/rwsem.h>
2700 +#include <linux/vs_dlimit.h>
2704 @@ -643,8 +644,12 @@ ext2_xattr_set2(struct inode *inode, str
2706 ea_bdebug(new_bh, "reusing block");
2709 + if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, 1))
2712 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
2713 + DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
2714 unlock_buffer(new_bh);
2717 @@ -724,6 +729,7 @@ ext2_xattr_set2(struct inode *inode, str
2718 /* Decrement the refcount only. */
2719 HDR(old_bh)->h_refcount = cpu_to_le32(
2720 le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
2721 + DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
2722 DQUOT_FREE_BLOCK(inode, 1);
2723 mark_buffer_dirty(old_bh);
2724 ea_bdebug(old_bh, "refcount now=%d",
2725 @@ -779,6 +785,7 @@ ext2_xattr_delete_inode(struct inode *in
2726 mark_buffer_dirty(bh);
2728 sync_dirty_buffer(bh);
2729 + DLIMIT_FREE_BLOCK(inode->i_sb, inode->i_xid, 1);
2730 DQUOT_FREE_BLOCK(inode, 1);
2732 ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
2733 diff -NurpP --minimal linux-2.6.10/fs/ext3/balloc.c linux-2.6.10-vs1.9.3.17/fs/ext3/balloc.c
2734 --- linux-2.6.10/fs/ext3/balloc.c 2004-12-25 01:55:20.000000000 +0100
2735 +++ linux-2.6.10-vs1.9.3.17/fs/ext3/balloc.c 2004-12-26 19:40:35.000000000 +0100
2737 #include <linux/ext3_jbd.h>
2738 #include <linux/quotaops.h>
2739 #include <linux/buffer_head.h>
2740 +#include <linux/vs_dlimit.h>
2743 * balloc.c contains the blocks allocation and deallocation routines
2744 @@ -462,8 +463,10 @@ void ext3_free_blocks(handle_t *handle,
2747 ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
2748 - if (dquot_freed_blocks)
2749 + if (dquot_freed_blocks) {
2750 + DLIMIT_FREE_BLOCK(sb, inode->i_xid, dquot_freed_blocks);
2751 DQUOT_FREE_BLOCK(inode, dquot_freed_blocks);
2756 @@ -1091,18 +1094,32 @@ out:
2760 -static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
2761 +static int ext3_has_free_blocks(struct super_block *sb)
2763 - int free_blocks, root_blocks;
2764 + struct ext3_sb_info *sbi = EXT3_SB(sb);
2765 + int free_blocks, root_blocks, cond;
2767 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
2768 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
2769 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
2771 + vxdprintk(VXD_CBIT(dlim, 3),
2772 + "ext3_has_free_blocks(%p): free=%u, root=%u",
2773 + sb, free_blocks, root_blocks);
2775 + DLIMIT_ADJUST_BLOCK(sb, vx_current_xid(), &free_blocks, &root_blocks);
2777 + cond = (free_blocks < root_blocks + 1 &&
2778 + !capable(CAP_SYS_RESOURCE) &&
2779 sbi->s_resuid != current->fsuid &&
2780 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
2784 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
2786 + vxdprintk(VXD_CBIT(dlim, 3),
2787 + "ext3_has_free_blocks(%p): %u<%u+1, %c, %u!=%u r=%d",
2788 + sb, free_blocks, root_blocks,
2789 + !capable(CAP_SYS_RESOURCE)?'1':'0',
2790 + sbi->s_resuid, current->fsuid, cond?0:1);
2792 + return (cond ? 0 : 1);
2796 @@ -1113,7 +1130,7 @@ static int ext3_has_free_blocks(struct e
2798 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
2800 - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
2801 + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
2804 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
2805 @@ -1168,6 +1185,8 @@ int ext3_new_block(handle_t *handle, str
2809 + if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, 1))
2813 es = EXT3_SB(sb)->s_es;
2814 @@ -1184,7 +1203,7 @@ int ext3_new_block(handle_t *handle, str
2815 if (test_opt(sb, RESERVATION) &&
2816 S_ISREG(inode->i_mode) && (windowsz > 0))
2818 - if (!ext3_has_free_blocks(sbi)) {
2819 + if (!ext3_has_free_blocks(sb)) {
2823 @@ -1360,6 +1379,9 @@ allocated:
2827 + if (!performed_allocation)
2828 + DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
2832 ext3_std_error(sb, fatal);
2833 diff -NurpP --minimal linux-2.6.10/fs/ext3/ialloc.c linux-2.6.10-vs1.9.3.17/fs/ext3/ialloc.c
2834 --- linux-2.6.10/fs/ext3/ialloc.c 2004-12-25 01:55:20.000000000 +0100
2835 +++ linux-2.6.10-vs1.9.3.17/fs/ext3/ialloc.c 2004-12-26 19:40:35.000000000 +0100
2837 #include <linux/buffer_head.h>
2838 #include <linux/random.h>
2839 #include <linux/bitops.h>
2840 +#include <linux/vs_dlimit.h>
2842 #include <asm/byteorder.h>
2844 @@ -125,6 +126,7 @@ void ext3_free_inode (handle_t *handle,
2847 ext3_xattr_delete_inode(handle, inode);
2848 + DLIMIT_FREE_INODE(sb, inode->i_xid);
2849 DQUOT_FREE_INODE(inode);
2852 @@ -443,6 +445,16 @@ struct inode *ext3_new_inode(handle_t *h
2853 inode = new_inode(sb);
2855 return ERR_PTR(-ENOMEM);
2857 + if (sb->s_flags & MS_TAGXID)
2858 + inode->i_xid = vx_current_xid();
2862 + if (DLIMIT_ALLOC_INODE(sb, inode->i_xid)) {
2869 @@ -566,7 +578,8 @@ got:
2870 ei->i_dir_start_lookup = 0;
2873 - ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL;
2874 + ei->i_flags = EXT3_I(dir)->i_flags &
2875 + ~(EXT3_INDEX_FL|EXT3_IUNLINK_FL|EXT3_BARRIER_FL);
2877 ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL);
2878 /* dirsync only applies to directories */
2879 @@ -618,6 +631,7 @@ got:
2880 ext3_debug("allocating inode %lu\n", inode->i_ino);
2883 + DLIMIT_FREE_INODE(sb, inode->i_xid);
2884 ext3_std_error(sb, err);
2887 @@ -627,6 +641,7 @@ really_out:
2891 + DLIMIT_FREE_INODE(sb, inode->i_xid);
2892 inode->i_flags |= S_NOQUOTA;
2895 diff -NurpP --minimal linux-2.6.10/fs/ext3/inode.c linux-2.6.10-vs1.9.3.17/fs/ext3/inode.c
2896 --- linux-2.6.10/fs/ext3/inode.c 2004-12-25 01:55:20.000000000 +0100
2897 +++ linux-2.6.10-vs1.9.3.17/fs/ext3/inode.c 2004-12-26 19:40:34.000000000 +0100
2899 #include <linux/writeback.h>
2900 #include <linux/mpage.h>
2901 #include <linux/uio.h>
2902 +#include <linux/vserver/xid.h>
2906 @@ -178,6 +179,8 @@ static int ext3_journal_test_restart(han
2907 return ext3_journal_restart(handle, blocks_for_truncate(inode));
2910 +static void ext3_truncate_nocheck (struct inode *inode);
2913 * Called at the last iput() if i_nlink is zero.
2915 @@ -201,7 +204,7 @@ void ext3_delete_inode (struct inode * i
2918 if (inode->i_blocks)
2919 - ext3_truncate(inode);
2920 + ext3_truncate_nocheck(inode);
2922 * Kill off the orphan record which ext3_truncate created.
2923 * AKPM: I think this can be inside the above `if'.
2924 @@ -2048,7 +2051,7 @@ static void ext3_free_branches(handle_t
2925 * ext3_truncate() run will find them and release them.
2928 -void ext3_truncate(struct inode * inode)
2929 +void ext3_truncate_nocheck(struct inode * inode)
2932 struct ext3_inode_info *ei = EXT3_I(inode);
2933 @@ -2069,8 +2072,6 @@ void ext3_truncate(struct inode * inode)
2935 if (ext3_inode_is_fast_symlink(inode))
2937 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2940 ext3_discard_reservation(inode);
2942 @@ -2380,17 +2381,28 @@ has_buffer:
2946 +void ext3_truncate(struct inode * inode)
2948 + if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2950 + ext3_truncate_nocheck(inode);
2953 void ext3_set_inode_flags(struct inode *inode)
2955 unsigned int flags = EXT3_I(inode)->i_flags;
2957 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2958 + inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_IUNLINK|S_BARRIER|S_NOATIME|S_DIRSYNC);
2959 if (flags & EXT3_SYNC_FL)
2960 inode->i_flags |= S_SYNC;
2961 if (flags & EXT3_APPEND_FL)
2962 inode->i_flags |= S_APPEND;
2963 if (flags & EXT3_IMMUTABLE_FL)
2964 inode->i_flags |= S_IMMUTABLE;
2965 + if (flags & EXT3_IUNLINK_FL)
2966 + inode->i_flags |= S_IUNLINK;
2967 + if (flags & EXT3_BARRIER_FL)
2968 + inode->i_flags |= S_BARRIER;
2969 if (flags & EXT3_NOATIME_FL)
2970 inode->i_flags |= S_NOATIME;
2971 if (flags & EXT3_DIRSYNC_FL)
2972 @@ -2404,6 +2416,8 @@ void ext3_read_inode(struct inode * inod
2973 struct ext3_inode_info *ei = EXT3_I(inode);
2974 struct buffer_head *bh;
2979 #ifdef CONFIG_EXT3_FS_POSIX_ACL
2980 ei->i_acl = EXT3_ACL_NOT_CACHED;
2981 @@ -2416,12 +2430,17 @@ void ext3_read_inode(struct inode * inod
2983 raw_inode = ext3_raw_inode(&iloc);
2984 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2985 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2986 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2987 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2988 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2989 if(!(test_opt (inode->i_sb, NO_UID32))) {
2990 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2991 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2992 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2993 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2995 + inode->i_uid = INOXID_UID(XID_TAG(inode), uid, gid);
2996 + inode->i_gid = INOXID_GID(XID_TAG(inode), uid, gid);
2997 + inode->i_xid = INOXID_XID(XID_TAG(inode), uid, gid,
2998 + le16_to_cpu(raw_inode->i_raw_xid));
3000 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3001 inode->i_size = le32_to_cpu(raw_inode->i_size);
3002 inode->i_atime.tv_sec = le32_to_cpu(raw_inode->i_atime);
3003 @@ -2529,6 +2548,8 @@ static int ext3_do_update_inode(handle_t
3004 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
3005 struct ext3_inode_info *ei = EXT3_I(inode);
3006 struct buffer_head *bh = iloc->bh;
3007 + uid_t uid = XIDINO_UID(XID_TAG(inode), inode->i_uid, inode->i_xid);
3008 + gid_t gid = XIDINO_GID(XID_TAG(inode), inode->i_gid, inode->i_xid);
3009 int err = 0, rc, block;
3011 /* For fields not not tracking in the in-memory inode,
3012 @@ -2538,29 +2559,32 @@ static int ext3_do_update_inode(handle_t
3014 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3015 if(!(test_opt(inode->i_sb, NO_UID32))) {
3016 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3017 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3018 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3019 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3021 * Fix up interoperability with old kernels. Otherwise, old inodes get
3022 * re-used with the upper 16 bits of the uid/gid intact
3025 raw_inode->i_uid_high =
3026 - cpu_to_le16(high_16_bits(inode->i_uid));
3027 + cpu_to_le16(high_16_bits(uid));
3028 raw_inode->i_gid_high =
3029 - cpu_to_le16(high_16_bits(inode->i_gid));
3030 + cpu_to_le16(high_16_bits(gid));
3032 raw_inode->i_uid_high = 0;
3033 raw_inode->i_gid_high = 0;
3036 raw_inode->i_uid_low =
3037 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3038 + cpu_to_le16(fs_high2lowuid(uid));
3039 raw_inode->i_gid_low =
3040 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3041 + cpu_to_le16(fs_high2lowgid(gid));
3042 raw_inode->i_uid_high = 0;
3043 raw_inode->i_gid_high = 0;
3045 +#ifdef CONFIG_INOXID_INTERN
3046 + raw_inode->i_raw_xid = cpu_to_le16(inode->i_xid);
3048 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3049 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
3050 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
3051 @@ -2682,6 +2706,44 @@ int ext3_write_inode(struct inode *inode
3052 return ext3_force_commit(inode->i_sb);
3055 +int ext3_setattr_flags(struct inode *inode, unsigned int flags)
3057 + unsigned int oldflags, newflags;
3060 + oldflags = EXT3_I(inode)->i_flags;
3061 + newflags = oldflags &
3062 + ~(EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL | EXT3_BARRIER_FL);
3063 + if (flags & ATTR_FLAG_IMMUTABLE)
3064 + newflags |= EXT3_IMMUTABLE_FL;
3065 + if (flags & ATTR_FLAG_IUNLINK)
3066 + newflags |= EXT3_IUNLINK_FL;
3067 + if (flags & ATTR_FLAG_BARRIER)
3068 + newflags |= EXT3_BARRIER_FL;
3070 + if (oldflags ^ newflags) {
3072 + struct ext3_iloc iloc;
3074 + handle = ext3_journal_start(inode, 1);
3075 + if (IS_ERR(handle))
3076 + return PTR_ERR(handle);
3077 + if (IS_SYNC(inode))
3078 + handle->h_sync = 1;
3079 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3083 + EXT3_I(inode)->i_flags = newflags;
3084 + inode->i_ctime = CURRENT_TIME;
3086 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3088 + ext3_journal_stop(handle);
3096 @@ -2710,7 +2772,8 @@ int ext3_setattr(struct dentry *dentry,
3099 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3100 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3101 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3102 + (ia_valid & ATTR_XID && attr->ia_xid != inode->i_xid)) {
3105 /* (user+group)*(old+new) structure, inode write (sb,
3106 @@ -2731,6 +2794,10 @@ int ext3_setattr(struct dentry *dentry,
3107 inode->i_uid = attr->ia_uid;
3108 if (attr->ia_valid & ATTR_GID)
3109 inode->i_gid = attr->ia_gid;
3110 + if ((attr->ia_valid & ATTR_XID)
3112 + && (inode->i_sb->s_flags & MS_TAGXID))
3113 + inode->i_xid = attr->ia_xid;
3114 error = ext3_mark_inode_dirty(handle, inode);
3115 ext3_journal_stop(handle);
3117 @@ -2753,6 +2820,12 @@ int ext3_setattr(struct dentry *dentry,
3118 ext3_journal_stop(handle);
3121 + if (ia_valid & ATTR_ATTR_FLAG) {
3122 + rc = ext3_setattr_flags(inode, attr->ia_attr_flags);
3127 rc = inode_setattr(inode, attr);
3129 /* If inode_setattr's call to ext3_truncate failed to get a
3130 diff -NurpP --minimal linux-2.6.10/fs/ext3/ioctl.c linux-2.6.10-vs1.9.3.17/fs/ext3/ioctl.c
3131 --- linux-2.6.10/fs/ext3/ioctl.c 2004-12-25 01:55:20.000000000 +0100
3132 +++ linux-2.6.10-vs1.9.3.17/fs/ext3/ioctl.c 2004-12-26 19:40:36.000000000 +0100
3134 #include <linux/ext3_fs.h>
3135 #include <linux/ext3_jbd.h>
3136 #include <linux/time.h>
3137 +#include <linux/vserver/xid.h>
3138 #include <asm/uaccess.h>
3141 @@ -58,7 +59,9 @@ int ext3_ioctl (struct inode * inode, st
3143 * This test looks nicer. Thanks to Pauline Middelink
3145 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3146 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3147 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3148 + EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL))) {
3149 if (!capable(CAP_LINUX_IMMUTABLE))
3152 @@ -219,6 +222,38 @@ flags_err:
3156 +#if defined(CONFIG_VSERVER_LEGACY) && !defined(CONFIG_INOXID_NONE)
3157 + case EXT3_IOC_SETXID: {
3159 + struct ext3_iloc iloc;
3163 + /* fixme: if stealth, return -ENOTTY */
3164 + if (!capable(CAP_CONTEXT))
3166 + if (IS_RDONLY(inode))
3168 + if (!(inode->i_sb->s_flags & MS_TAGXID))
3170 + if (get_user(xid, (int *) arg))
3173 + handle = ext3_journal_start(inode, 1);
3174 + if (IS_ERR(handle))
3175 + return PTR_ERR(handle);
3176 + err = ext3_reserve_inode_write(handle, inode, &iloc);
3180 + inode->i_xid = (xid & 0xFFFF);
3181 + inode->i_ctime = CURRENT_TIME;
3183 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3184 + ext3_journal_stop(handle);
3191 diff -NurpP --minimal linux-2.6.10/fs/ext3/namei.c linux-2.6.10-vs1.9.3.17/fs/ext3/namei.c
3192 --- linux-2.6.10/fs/ext3/namei.c 2004-12-25 01:55:20.000000000 +0100
3193 +++ linux-2.6.10-vs1.9.3.17/fs/ext3/namei.c 2004-12-26 19:40:30.000000000 +0100
3195 #include <linux/quotaops.h>
3196 #include <linux/buffer_head.h>
3197 #include <linux/smp_lock.h>
3198 +#include <linux/vserver/xid.h>
3202 @@ -989,6 +990,7 @@ static struct dentry *ext3_lookup(struct
3205 return ERR_PTR(-EACCES);
3206 + vx_propagate_xid(nd, inode);
3209 return d_splice_alias(inode, dentry);
3210 diff -NurpP --minimal linux-2.6.10/fs/ext3/super.c linux-2.6.10-vs1.9.3.17/fs/ext3/super.c
3211 --- linux-2.6.10/fs/ext3/super.c 2004-12-25 01:55:20.000000000 +0100
3212 +++ linux-2.6.10-vs1.9.3.17/fs/ext3/super.c 2004-12-26 19:40:34.000000000 +0100
3213 @@ -584,7 +584,7 @@ enum {
3214 Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
3215 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3216 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0,
3217 - Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
3218 + Opt_tagxid, Opt_barrier, Opt_ignore, Opt_err, Opt_resize,
3221 static match_table_t tokens = {
3222 @@ -627,6 +627,7 @@ static match_table_t tokens = {
3223 {Opt_grpjquota, "grpjquota=%s"},
3224 {Opt_jqfmt_vfsold, "jqfmt=vfsold"},
3225 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
3226 + {Opt_tagxid, "tagxid"},
3227 {Opt_ignore, "grpquota"},
3228 {Opt_ignore, "noquota"},
3229 {Opt_ignore, "quota"},
3230 @@ -722,6 +723,16 @@ static int parse_options (char * options
3232 set_opt (sbi->s_mount_opt, NO_UID32);
3234 +#ifndef CONFIG_INOXID_NONE
3237 + printk(KERN_ERR "EXT3-fs: cannot specify "
3238 + "tagxid on remount\n");
3241 + set_opt (sbi->s_mount_opt, TAG_XID);
3245 #ifdef CONFIG_EXT3_CHECK
3246 set_opt (sbi->s_mount_opt, CHECK);
3247 @@ -1313,6 +1324,8 @@ static int ext3_fill_super (struct super
3248 if (!parse_options ((char *) data, sb, &journal_inum, NULL, 0))
3251 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAG_XID)
3252 + sb->s_flags |= MS_TAGXID;
3253 sb->s_flags |= MS_ONE_SECOND;
3254 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3255 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
3256 diff -NurpP --minimal linux-2.6.10/fs/ext3/xattr.c linux-2.6.10-vs1.9.3.17/fs/ext3/xattr.c
3257 --- linux-2.6.10/fs/ext3/xattr.c 2004-12-25 01:55:20.000000000 +0100
3258 +++ linux-2.6.10-vs1.9.3.17/fs/ext3/xattr.c 2004-12-26 19:40:35.000000000 +0100
3260 #include <linux/mbcache.h>
3261 #include <linux/quotaops.h>
3262 #include <linux/rwsem.h>
3263 +#include <linux/vs_dlimit.h>
3267 @@ -661,8 +662,12 @@ ext3_xattr_set_handle2(handle_t *handle,
3269 ea_bdebug(new_bh, "reusing block");
3272 + if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, 1))
3275 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
3276 + DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
3277 unlock_buffer(new_bh);
3278 journal_release_buffer(handle, new_bh,
3280 @@ -747,6 +752,7 @@ getblk_failed:
3281 /* Decrement the refcount only. */
3282 HDR(old_bh)->h_refcount = cpu_to_le32(
3283 le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
3284 + DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
3285 DQUOT_FREE_BLOCK(inode, 1);
3286 ext3_journal_dirty_metadata(handle, old_bh);
3287 ea_bdebug(old_bh, "refcount now=%d",
3288 @@ -838,6 +844,7 @@ ext3_xattr_delete_inode(handle_t *handle
3289 ext3_journal_dirty_metadata(handle, bh);
3292 + DLIMIT_FREE_BLOCK(inode->i_sb, inode->i_xid, 1);
3293 DQUOT_FREE_BLOCK(inode, 1);
3295 ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
3296 diff -NurpP --minimal linux-2.6.10/fs/fcntl.c linux-2.6.10-vs1.9.3.17/fs/fcntl.c
3297 --- linux-2.6.10/fs/fcntl.c 2004-12-25 01:55:20.000000000 +0100
3298 +++ linux-2.6.10-vs1.9.3.17/fs/fcntl.c 2004-12-26 19:40:35.000000000 +0100
3300 #include <linux/module.h>
3301 #include <linux/security.h>
3302 #include <linux/ptrace.h>
3303 +#include <linux/vs_limit.h>
3305 #include <asm/poll.h>
3306 #include <asm/siginfo.h>
3307 @@ -108,6 +109,8 @@ repeat:
3309 if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
3311 + if (!vx_files_avail(1))
3314 error = expand_files(files, newfd);
3316 @@ -140,6 +143,7 @@ static int dupfd(struct file *file, unsi
3317 FD_SET(fd, files->open_fds);
3318 FD_CLR(fd, files->close_on_exec);
3319 spin_unlock(&files->file_lock);
3320 + // vx_openfd_inc(fd);
3321 fd_install(fd, file);
3323 spin_unlock(&files->file_lock);
3324 @@ -187,6 +191,7 @@ asmlinkage long sys_dup2(unsigned int ol
3325 FD_SET(newfd, files->open_fds);
3326 FD_CLR(newfd, files->close_on_exec);
3327 spin_unlock(&files->file_lock);
3328 + // vx_openfd_inc(newfd);
3331 filp_close(tofree, files);
3332 @@ -489,7 +494,7 @@ void send_sigio(struct fown_struct *fown
3334 read_lock(&tasklist_lock);
3336 - p = find_task_by_pid(pid);
3337 + p = find_task_by_real_pid(pid);
3339 send_sigio_to_task(p, fown, fd, band);
3341 @@ -524,7 +529,7 @@ int send_sigurg(struct fown_struct *fown
3343 read_lock(&tasklist_lock);
3345 - p = find_task_by_pid(pid);
3346 + p = find_task_by_real_pid(pid);
3348 send_sigurg_to_task(p, fown);
3350 diff -NurpP --minimal linux-2.6.10/fs/file_table.c linux-2.6.10-vs1.9.3.17/fs/file_table.c
3351 --- linux-2.6.10/fs/file_table.c 2004-12-25 01:55:20.000000000 +0100
3352 +++ linux-2.6.10-vs1.9.3.17/fs/file_table.c 2004-12-26 19:40:35.000000000 +0100
3354 #include <linux/eventpoll.h>
3355 #include <linux/mount.h>
3356 #include <linux/cdev.h>
3357 +#include <linux/vs_limit.h>
3358 +#include <linux/vs_context.h>
3360 /* sysctl tunables... */
3361 struct files_stat_struct files_stat = {
3362 @@ -85,6 +87,9 @@ static int old_max;
3363 f->f_owner.lock = RW_LOCK_UNLOCKED;
3364 /* f->f_version: 0 */
3365 INIT_LIST_HEAD(&f->f_list);
3366 + // set_vx_info(&f->f_vx_info, current->vx_info);
3367 + f->f_xid = vx_current_xid();
3372 @@ -137,6 +142,8 @@ void fastcall __fput(struct file *file)
3373 fops_put(file->f_op);
3374 if (file->f_mode & FMODE_WRITE)
3375 put_write_access(inode);
3376 + vx_files_dec(file);
3379 file->f_dentry = NULL;
3380 file->f_vfsmnt = NULL;
3381 @@ -192,6 +199,8 @@ void put_filp(struct file *file)
3383 if (atomic_dec_and_test(&file->f_count)) {
3384 security_file_free(file);
3385 + vx_files_dec(file);
3390 diff -NurpP --minimal linux-2.6.10/fs/inode.c linux-2.6.10-vs1.9.3.17/fs/inode.c
3391 --- linux-2.6.10/fs/inode.c 2004-12-25 01:55:20.000000000 +0100
3392 +++ linux-2.6.10-vs1.9.3.17/fs/inode.c 2004-12-26 19:40:34.000000000 +0100
3393 @@ -115,6 +115,10 @@ static struct inode *alloc_inode(struct
3394 struct address_space * const mapping = &inode->i_data;
3397 + // inode->i_dqh = dqhget(sb->s_dqh);
3399 + /* essential because of inode slab reuse */
3401 inode->i_blkbits = sb->s_blocksize_bits;
3403 atomic_set(&inode->i_count, 1);
3404 diff -NurpP --minimal linux-2.6.10/fs/ioctl.c linux-2.6.10-vs1.9.3.17/fs/ioctl.c
3405 --- linux-2.6.10/fs/ioctl.c 2004-12-25 01:55:20.000000000 +0100
3406 +++ linux-2.6.10-vs1.9.3.17/fs/ioctl.c 2004-12-26 19:40:36.000000000 +0100
3408 #include <linux/fs.h>
3409 #include <linux/security.h>
3410 #include <linux/module.h>
3411 +#include <linux/proc_fs.h>
3412 +#include <linux/vserver/inode.h>
3413 +#include <linux/vserver/xid.h>
3415 #include <asm/uaccess.h>
3416 #include <asm/ioctls.h>
3418 +#ifdef CONFIG_VSERVER_LEGACY
3419 +extern int vx_proc_ioctl(struct inode *, struct file *,
3420 + unsigned int, unsigned long);
3423 static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)
3426 @@ -123,6 +131,48 @@ asmlinkage long sys_ioctl(unsigned int f
3430 +#ifdef CONFIG_VSERVER_LEGACY
3431 +#ifndef CONFIG_INOXID_NONE
3432 + case FIOC_GETXID: {
3433 + struct inode *inode = filp->f_dentry->d_inode;
3435 + /* fixme: if stealth, return -ENOTTY */
3437 + if (capable(CAP_CONTEXT))
3438 + error = put_user(inode->i_xid, (int *) arg);
3441 + case FIOC_SETXID: {
3442 + struct inode *inode = filp->f_dentry->d_inode;
3445 + /* fixme: if stealth, return -ENOTTY */
3447 + if (!capable(CAP_CONTEXT))
3450 + if (IS_RDONLY(inode))
3453 + if (!(inode->i_sb->s_flags & MS_TAGXID))
3456 + if (get_user(xid, (int *) arg))
3459 + inode->i_xid = (xid & 0xFFFF);
3460 + inode->i_ctime = CURRENT_TIME;
3461 + mark_inode_dirty(inode);
3465 + case FIOC_GETXFLG:
3466 + case FIOC_SETXFLG:
3468 + if (filp->f_dentry->d_inode->i_sb->s_magic == PROC_SUPER_MAGIC)
3469 + error = vx_proc_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
3474 if (S_ISREG(filp->f_dentry->d_inode->i_mode))
3475 diff -NurpP --minimal linux-2.6.10/fs/jfs/jfs_imap.c linux-2.6.10-vs1.9.3.17/fs/jfs/jfs_imap.c
3476 --- linux-2.6.10/fs/jfs/jfs_imap.c 2004-12-25 01:55:20.000000000 +0100
3477 +++ linux-2.6.10-vs1.9.3.17/fs/jfs/jfs_imap.c 2004-12-26 19:40:34.000000000 +0100
3479 #include <linux/buffer_head.h>
3480 #include <linux/pagemap.h>
3481 #include <linux/quotaops.h>
3482 +#include <linux/vserver/xid.h>
3484 #include "jfs_incore.h"
3485 #include "jfs_filsys.h"
3486 @@ -3092,14 +3093,21 @@ static void duplicateIXtree(struct super
3487 static int copy_from_dinode(struct dinode * dip, struct inode *ip)
3489 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3493 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3494 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3496 ip->i_mode = le32_to_cpu(dip->di_mode) & 0xffff;
3497 ip->i_nlink = le32_to_cpu(dip->di_nlink);
3498 - ip->i_uid = le32_to_cpu(dip->di_uid);
3499 - ip->i_gid = le32_to_cpu(dip->di_gid);
3501 + uid = le32_to_cpu(dip->di_uid);
3502 + gid = le32_to_cpu(dip->di_gid);
3503 + ip->i_uid = INOXID_UID(XID_TAG(ip), uid, gid);
3504 + ip->i_gid = INOXID_GID(XID_TAG(ip), uid, gid);
3505 + ip->i_xid = INOXID_XID(XID_TAG(ip), uid, gid, 0);
3507 ip->i_size = le64_to_cpu(dip->di_size);
3508 ip->i_atime.tv_sec = le32_to_cpu(dip->di_atime.tv_sec);
3509 ip->i_atime.tv_nsec = le32_to_cpu(dip->di_atime.tv_nsec);
3510 @@ -3150,6 +3158,8 @@ static int copy_from_dinode(struct dinod
3511 static void copy_to_dinode(struct dinode * dip, struct inode *ip)
3513 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3517 dip->di_fileset = cpu_to_le32(jfs_ip->fileset);
3518 dip->di_inostamp = cpu_to_le32(JFS_SBI(ip->i_sb)->inostamp);
3519 @@ -3158,8 +3168,11 @@ static void copy_to_dinode(struct dinode
3520 dip->di_size = cpu_to_le64(ip->i_size);
3521 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3522 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3523 - dip->di_uid = cpu_to_le32(ip->i_uid);
3524 - dip->di_gid = cpu_to_le32(ip->i_gid);
3526 + uid = XIDINO_UID(XID_TAG(ip), ip->i_uid, ip->i_xid);
3527 + gid = XIDINO_GID(XID_TAG(ip), ip->i_gid, ip->i_xid);
3528 + dip->di_uid = cpu_to_le32(uid);
3529 + dip->di_gid = cpu_to_le32(gid);
3531 * mode2 is only needed for storing the higher order bits.
3532 * Trust i_mode for the lower order ones
3533 diff -NurpP --minimal linux-2.6.10/fs/namei.c linux-2.6.10-vs1.9.3.17/fs/namei.c
3534 --- linux-2.6.10/fs/namei.c 2004-12-25 01:55:21.000000000 +0100
3535 +++ linux-2.6.10-vs1.9.3.17/fs/namei.c 2004-12-26 19:40:34.000000000 +0100
3537 #include <linux/syscalls.h>
3538 #include <linux/mount.h>
3539 #include <linux/audit.h>
3540 +#include <linux/proc_fs.h>
3541 +#include <linux/vserver/inode.h>
3542 +#include <linux/vserver/debug.h>
3544 #include <asm/namei.h>
3545 #include <asm/uaccess.h>
3547 @@ -224,6 +228,24 @@ int generic_permission(struct inode *ino
3551 +static inline int xid_permission(struct inode *inode, int mask, struct nameidata *nd)
3553 + if (IS_BARRIER(inode) && !vx_check(0, VX_ADMIN)) {
3554 + vxwprintk(1, "xid=%d did hit the barrier.",
3555 + vx_current_xid());
3558 + if (inode->i_xid == 0)
3560 + if (vx_check(inode->i_xid, VX_ADMIN|VX_WATCH|VX_IDENT))
3563 + vxwprintk(1, "xid=%d denied access to %p[#%d,%lu] »%s«.",
3564 + vx_current_xid(), inode, inode->i_xid, inode->i_ino,
3565 + vxd_path(nd->dentry, nd->mnt));
3569 int permission(struct inode * inode,int mask, struct nameidata *nd)
3572 @@ -232,6 +254,8 @@ int permission(struct inode * inode,int
3573 /* Ordinary permission routines do not understand MAY_APPEND. */
3574 submask = mask & ~MAY_APPEND;
3576 + if ((retval = xid_permission(inode, mask, nd)))
3578 if (inode->i_op && inode->i_op->permission)
3579 retval = inode->i_op->permission(inode, submask, nd);
3581 @@ -634,15 +658,33 @@ static int do_lookup(struct nameidata *n
3583 struct vfsmount *mnt = nd->mnt;
3584 struct dentry *dentry = __d_lookup(nd->dentry, name);
3585 + struct inode *inode;
3589 if (dentry->d_op && dentry->d_op->d_revalidate)
3590 goto need_revalidate;
3591 + inode = dentry->d_inode;
3594 + if (!vx_check(inode->i_xid, VX_WATCH|VX_HOSTID|VX_IDENT))
3596 + if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
3597 + struct proc_dir_entry *de = PDE(inode);
3599 + if (de && !vx_hide_check(0, de->vx_flags))
3604 path->dentry = dentry;
3607 + vxwprintk(1, "xid=%d did lookup hidden %p[#%d,%lu] »%s«.",
3608 + vx_current_xid(), inode, inode->i_xid, inode->i_ino,
3609 + vxd_path(dentry, mnt));
3614 dentry = real_lookup(nd->dentry, name, nd);
3615 @@ -1123,7 +1165,7 @@ static inline int may_delete(struct inod
3618 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
3619 - IS_IMMUTABLE(victim->d_inode))
3620 + IS_IXORUNLINK(victim->d_inode))
3623 if (!S_ISDIR(victim->d_inode->i_mode))
3624 @@ -1929,7 +1971,7 @@ int vfs_link(struct dentry *old_dentry,
3626 * A link to an append-only or immutable file cannot be created.
3628 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3629 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
3631 if (!dir->i_op || !dir->i_op->link)
3633 diff -NurpP --minimal linux-2.6.10/fs/namespace.c linux-2.6.10-vs1.9.3.17/fs/namespace.c
3634 --- linux-2.6.10/fs/namespace.c 2004-12-25 01:55:21.000000000 +0100
3635 +++ linux-2.6.10-vs1.9.3.17/fs/namespace.c 2004-12-26 19:40:34.000000000 +0100
3637 #include <linux/namei.h>
3638 #include <linux/security.h>
3639 #include <linux/mount.h>
3640 +#include <linux/vserver/namespace.h>
3641 +#include <linux/vserver/xid.h>
3643 #include <asm/uaccess.h>
3644 #include <asm/unistd.h>
3646 @@ -161,6 +164,7 @@ clone_mnt(struct vfsmount *old, struct d
3647 mnt->mnt_mountpoint = mnt->mnt_root;
3648 mnt->mnt_parent = mnt;
3649 mnt->mnt_namespace = old->mnt_namespace;
3650 + mnt->mnt_xid = old->mnt_xid;
3652 /* stick the duplicate mount on the same expiry list
3653 * as the original if that was on one */
3654 @@ -228,6 +232,7 @@ static int show_vfsmnt(struct seq_file *
3655 { MS_MANDLOCK, ",mand" },
3656 { MS_NOATIME, ",noatime" },
3657 { MS_NODIRATIME, ",nodiratime" },
3658 + { MS_TAGXID, ",tagxid" },
3661 static struct proc_fs_info mnt_info[] = {
3662 @@ -238,6 +243,11 @@ static int show_vfsmnt(struct seq_file *
3664 struct proc_fs_info *fs_infop;
3666 + if (vx_flags(VXF_HIDE_MOUNT, 0))
3668 + if (!vx_check_vfsmount(current->vx_info, mnt))
3671 mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
3673 seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
3674 @@ -252,6 +262,8 @@ static int show_vfsmnt(struct seq_file *
3675 if (mnt->mnt_flags & fs_infop->flag)
3676 seq_puts(m, fs_infop->str);
3678 + if (mnt->mnt_flags & MNT_XID)
3679 + seq_printf(m, ",xid=%d", mnt->mnt_xid);
3680 if (mnt->mnt_sb->s_op->show_options)
3681 err = mnt->mnt_sb->s_op->show_options(m, mnt);
3682 seq_puts(m, " 0 0\n");
3683 @@ -337,18 +349,12 @@ int may_umount(struct vfsmount *mnt)
3685 EXPORT_SYMBOL(may_umount);
3687 -void umount_tree(struct vfsmount *mnt)
3688 +static inline void __umount_list(struct list_head *kill)
3690 - struct vfsmount *p;
3693 - for (p = mnt; p; p = next_mnt(p, mnt)) {
3694 - list_del(&p->mnt_list);
3695 - list_add(&p->mnt_list, &kill);
3697 + struct vfsmount *mnt;
3699 - while (!list_empty(&kill)) {
3700 - mnt = list_entry(kill.next, struct vfsmount, mnt_list);
3701 + while (!list_empty(kill)) {
3702 + mnt = list_entry(kill->next, struct vfsmount, mnt_list);
3703 list_del_init(&mnt->mnt_list);
3704 list_del_init(&mnt->mnt_fslink);
3705 if (mnt->mnt_parent == mnt) {
3706 @@ -364,6 +370,32 @@ void umount_tree(struct vfsmount *mnt)
3710 +void umount_tree(struct vfsmount *mnt)
3712 + struct vfsmount *p;
3715 + for (p = mnt; p; p = next_mnt(p, mnt)) {
3716 + list_del(&p->mnt_list);
3717 + list_add(&p->mnt_list, &kill);
3719 + __umount_list(&kill);
3722 +void umount_unused(struct vfsmount *mnt, struct fs_struct *fs)
3724 + struct vfsmount *p;
3727 + for (p = mnt; p; p = next_mnt(p, mnt)) {
3728 + if (p == fs->rootmnt || p == fs->pwdmnt)
3730 + list_del(&p->mnt_list);
3731 + list_add(&p->mnt_list, &kill);
3733 + __umount_list(&kill);
3736 static int do_umount(struct vfsmount *mnt, int flags)
3738 struct super_block * sb = mnt->mnt_sb;
3739 @@ -480,7 +512,7 @@ asmlinkage long sys_umount(char __user *
3743 - if (!capable(CAP_SYS_ADMIN))
3744 + if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SECURE_MOUNT))
3747 retval = do_umount(nd.mnt, flags);
3748 @@ -507,6 +539,8 @@ static int mount_is_safe(struct nameidat
3750 if (capable(CAP_SYS_ADMIN))
3752 + if (vx_ccaps(VXC_SECURE_MOUNT))
3756 if (S_ISLNK(nd->dentry->d_inode->i_mode))
3757 @@ -618,11 +652,12 @@ out_unlock:
3759 * do loopback mount.
3761 -static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
3762 +static int do_loopback(struct nameidata *nd, char *old_name, xid_t xid, int flags)
3764 struct nameidata old_nd;
3765 struct vfsmount *mnt = NULL;
3766 int err = mount_is_safe(nd);
3767 + int recurse = flags & MS_REC;
3770 if (!old_name || !*old_name)
3771 @@ -647,6 +682,10 @@ static int do_loopback(struct nameidata
3772 list_del_init(&mnt->mnt_fslink);
3773 spin_unlock(&vfsmount_lock);
3775 + if (flags & MS_XID) {
3776 + mnt->mnt_xid = xid;
3777 + mnt->mnt_flags |= MNT_XID;
3779 err = graft_tree(mnt, nd);
3781 spin_lock(&vfsmount_lock);
3782 @@ -668,12 +707,12 @@ static int do_loopback(struct nameidata
3785 static int do_remount(struct nameidata *nd, int flags, int mnt_flags,
3787 + void *data, xid_t xid)
3790 struct super_block * sb = nd->mnt->mnt_sb;
3792 - if (!capable(CAP_SYS_ADMIN))
3793 + if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SECURE_REMOUNT))
3796 if (!check_mnt(nd->mnt))
3797 @@ -682,10 +721,15 @@ static int do_remount(struct nameidata *
3798 if (nd->dentry != nd->mnt->mnt_root)
3801 + if (vx_ccaps(VXC_SECURE_REMOUNT))
3802 + mnt_flags |= MNT_NODEV;
3803 down_write(&sb->s_umount);
3804 err = do_remount_sb(sb, flags, data, 0);
3807 nd->mnt->mnt_flags=mnt_flags;
3808 + if (flags & MS_XID)
3809 + nd->mnt->mnt_xid = xid;
3811 up_write(&sb->s_umount);
3813 security_sb_post_remount(nd->mnt, flags, data);
3814 @@ -697,7 +741,7 @@ static int do_move_mount(struct nameidat
3815 struct nameidata old_nd, parent_nd;
3818 - if (!capable(CAP_SYS_ADMIN))
3819 + if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SECURE_MOUNT))
3821 if (!old_name || !*old_name)
3823 @@ -769,7 +813,7 @@ static int do_new_mount(struct nameidata
3826 /* we need capabilities... */
3827 - if (!capable(CAP_SYS_ADMIN))
3828 + if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SECURE_MOUNT))
3831 mnt = do_kern_mount(type, flags, name, data);
3832 @@ -1011,6 +1055,7 @@ long do_mount(char * dev_name, char * di
3833 struct nameidata nd;
3839 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
3840 @@ -1026,6 +1071,14 @@ long do_mount(char * dev_name, char * di
3842 ((char *)data_page)[PAGE_SIZE - 1] = 0;
3844 + retval = vx_parse_xid(data_page, &xid, 1);
3846 + mnt_flags |= MNT_XID;
3847 + /* bind and re-mounts get xid flag */
3848 + if (flags & (MS_BIND|MS_REMOUNT))
3852 /* Separate the per-mountpoint flags */
3853 if (flags & MS_NOSUID)
3854 mnt_flags |= MNT_NOSUID;
3855 @@ -1035,6 +1088,9 @@ long do_mount(char * dev_name, char * di
3856 mnt_flags |= MNT_NOEXEC;
3857 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);
3859 + if (vx_ccaps(VXC_SECURE_MOUNT))
3860 + mnt_flags |= MNT_NODEV;
3862 /* ... and get the mountpoint */
3863 retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
3865 @@ -1046,9 +1102,9 @@ long do_mount(char * dev_name, char * di
3867 if (flags & MS_REMOUNT)
3868 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
3871 else if (flags & MS_BIND)
3872 - retval = do_loopback(&nd, dev_name, flags & MS_REC);
3873 + retval = do_loopback(&nd, dev_name, xid, flags);
3874 else if (flags & MS_MOVE)
3875 retval = do_move_mount(&nd, dev_name);
3877 @@ -1075,7 +1131,7 @@ int copy_namespace(int flags, struct tas
3878 if (!(flags & CLONE_NEWNS))
3881 - if (!capable(CAP_SYS_ADMIN)) {
3882 + if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SECURE_MOUNT)) {
3883 put_namespace(namespace);
3886 diff -NurpP --minimal linux-2.6.10/fs/nfs/dir.c linux-2.6.10-vs1.9.3.17/fs/nfs/dir.c
3887 --- linux-2.6.10/fs/nfs/dir.c 2004-12-25 01:55:21.000000000 +0100
3888 +++ linux-2.6.10-vs1.9.3.17/fs/nfs/dir.c 2004-12-26 19:40:34.000000000 +0100
3890 #include <linux/pagemap.h>
3891 #include <linux/smp_lock.h>
3892 #include <linux/namei.h>
3893 +#include <linux/vserver/xid.h>
3895 #include "delegation.h"
3897 @@ -759,6 +760,7 @@ static struct dentry *nfs_lookup(struct
3898 inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr);
3901 + vx_propagate_xid(nd, inode);
3904 d_add(dentry, inode);
3905 diff -NurpP --minimal linux-2.6.10/fs/nfs/inode.c linux-2.6.10-vs1.9.3.17/fs/nfs/inode.c
3906 --- linux-2.6.10/fs/nfs/inode.c 2004-10-23 05:06:17.000000000 +0200
3907 +++ linux-2.6.10-vs1.9.3.17/fs/nfs/inode.c 2004-12-26 19:40:34.000000000 +0100
3909 #include <linux/mount.h>
3910 #include <linux/nfs_idmap.h>
3911 #include <linux/vfs.h>
3912 +#include <linux/vserver/xid.h>
3914 #include <asm/system.h>
3915 #include <asm/uaccess.h>
3916 @@ -313,6 +314,9 @@ nfs_sb_init(struct super_block *sb, rpc_
3918 server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD;
3920 + if (server->flags & NFS_MOUNT_TAGXID)
3921 + sb->s_flags |= MS_TAGXID;
3923 sb->s_maxbytes = fsinfo.maxfilesize;
3924 if (sb->s_maxbytes > MAX_LFS_FILESIZE)
3925 sb->s_maxbytes = MAX_LFS_FILESIZE;
3926 @@ -367,6 +371,7 @@ nfs_create_client(struct nfs_server *ser
3927 clnt->cl_intr = (server->flags & NFS_MOUNT_INTR) ? 1 : 0;
3928 clnt->cl_softrtry = (server->flags & NFS_MOUNT_SOFT) ? 1 : 0;
3929 clnt->cl_droppriv = (server->flags & NFS_MOUNT_BROKEN_SUID) ? 1 : 0;
3930 + clnt->cl_tagxid = (server->flags & NFS_MOUNT_TAGXID) ? 1 : 0;
3931 clnt->cl_chatty = 1;
3934 @@ -524,6 +529,7 @@ static int nfs_show_options(struct seq_f
3935 { NFS_MOUNT_NOAC, ",noac", "" },
3936 { NFS_MOUNT_NONLM, ",nolock", ",lock" },
3937 { NFS_MOUNT_BROKEN_SUID, ",broken_suid", "" },
3938 + { NFS_MOUNT_TAGXID, ",tagxid", "" },
3941 struct proc_nfs_info *nfs_infop;
3942 @@ -688,8 +694,10 @@ nfs_fhget(struct super_block *sb, struct
3943 nfsi->change_attr = fattr->change_attr;
3944 inode->i_size = nfs_size_to_loff_t(fattr->size);
3945 inode->i_nlink = fattr->nlink;
3946 - inode->i_uid = fattr->uid;
3947 - inode->i_gid = fattr->gid;
3948 + inode->i_uid = INOXID_UID(XID_TAG(inode), fattr->uid, fattr->gid);
3949 + inode->i_gid = INOXID_GID(XID_TAG(inode), fattr->uid, fattr->gid);
3950 + inode->i_xid = INOXID_XID(XID_TAG(inode), fattr->uid, fattr->gid, 0);
3951 + /* maybe fattr->xid someday */
3952 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
3954 * report the blocks in 512byte units
3955 @@ -715,7 +723,12 @@ nfs_fhget(struct super_block *sb, struct
3962 + make_bad_inode(inode);
3967 printk("nfs_fhget: iget failed\n");
3969 @@ -761,6 +774,8 @@ nfs_setattr(struct dentry *dentry, struc
3970 inode->i_uid = attr->ia_uid;
3971 if ((attr->ia_valid & ATTR_GID) != 0)
3972 inode->i_gid = attr->ia_gid;
3973 + if ((attr->ia_valid & ATTR_XID) != 0)
3974 + inode->i_xid = attr->ia_xid;
3975 if ((attr->ia_valid & ATTR_SIZE) != 0) {
3976 inode->i_size = attr->ia_size;
3977 vmtruncate(inode, attr->ia_size);
3978 @@ -1114,6 +1129,9 @@ int nfs_refresh_inode(struct inode *inod
3979 struct nfs_inode *nfsi = NFS_I(inode);
3980 loff_t cur_size, new_isize;
3986 /* Do we hold a delegation? */
3987 if (nfs_have_delegation(inode, FMODE_READ))
3988 @@ -1157,10 +1175,15 @@ int nfs_refresh_inode(struct inode *inod
3989 } else if (S_ISREG(inode->i_mode) && new_isize > cur_size)
3990 nfsi->flags |= NFS_INO_INVALID_ATTR;
3992 + uid = INOXID_UID(XID_TAG(inode), fattr->uid, fattr->gid);
3993 + gid = INOXID_GID(XID_TAG(inode), fattr->uid, fattr->gid);
3994 + xid = INOXID_XID(XID_TAG(inode), fattr->uid, fattr->gid, 0);
3996 /* Have any file permissions changed? */
3997 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)
3998 - || inode->i_uid != fattr->uid
3999 - || inode->i_gid != fattr->gid)
4000 + || inode->i_uid != uid
4001 + || inode->i_gid != gid
4002 + || inode->i_xid != xid)
4003 nfsi->flags |= NFS_INO_INVALID_ATTR;
4005 /* Has the link count changed? */
4006 @@ -1194,6 +1217,9 @@ static int nfs_update_inode(struct inode
4007 unsigned int invalid = 0;
4014 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
4015 __FUNCTION__, inode->i_sb->s_id, inode->i_ino,
4016 @@ -1276,9 +1302,14 @@ static int nfs_update_inode(struct inode
4017 memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime));
4018 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
4020 + uid = INOXID_UID(XID_TAG(inode), fattr->uid, fattr->gid);
4021 + gid = INOXID_GID(XID_TAG(inode), fattr->uid, fattr->gid);
4022 + xid = INOXID_XID(XID_TAG(inode), fattr->uid, fattr->gid, 0);
4024 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) ||
4025 - inode->i_uid != fattr->uid ||
4026 - inode->i_gid != fattr->gid) {
4027 + inode->i_uid != uid ||
4028 + inode->i_gid != gid ||
4029 + inode->i_xid != xid) {
4030 struct rpc_cred **cred = &NFS_I(inode)->cache_access.cred;
4033 @@ -1289,8 +1320,9 @@ static int nfs_update_inode(struct inode
4035 inode->i_mode = fattr->mode;
4036 inode->i_nlink = fattr->nlink;
4037 - inode->i_uid = fattr->uid;
4038 - inode->i_gid = fattr->gid;
4039 + inode->i_uid = uid;
4040 + inode->i_gid = gid;
4041 + inode->i_xid = xid;
4043 if (fattr->valid & (NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4)) {
4045 diff -NurpP --minimal linux-2.6.10/fs/nfs/nfs3xdr.c linux-2.6.10-vs1.9.3.17/fs/nfs/nfs3xdr.c
4046 --- linux-2.6.10/fs/nfs/nfs3xdr.c 2004-10-23 05:06:17.000000000 +0200
4047 +++ linux-2.6.10-vs1.9.3.17/fs/nfs/nfs3xdr.c 2004-12-26 19:40:34.000000000 +0100
4049 #include <linux/nfs.h>
4050 #include <linux/nfs3.h>
4051 #include <linux/nfs_fs.h>
4052 +#include <linux/vserver/xid.h>
4054 #define NFSDBG_FACILITY NFSDBG_XDR
4056 @@ -173,7 +174,7 @@ xdr_decode_fattr(u32 *p, struct nfs_fatt
4060 -xdr_encode_sattr(u32 *p, struct iattr *attr)
4061 +xdr_encode_sattr(u32 *p, struct iattr *attr, int tagxid)
4063 if (attr->ia_valid & ATTR_MODE) {
4065 @@ -181,15 +182,17 @@ xdr_encode_sattr(u32 *p, struct iattr *a
4069 - if (attr->ia_valid & ATTR_UID) {
4070 + if (attr->ia_valid & ATTR_UID ||
4071 + (tagxid && (attr->ia_valid & ATTR_XID))) {
4073 - *p++ = htonl(attr->ia_uid);
4074 + *p++ = htonl(XIDINO_UID(tagxid, attr->ia_uid, attr->ia_xid));
4078 - if (attr->ia_valid & ATTR_GID) {
4079 + if (attr->ia_valid & ATTR_GID ||
4080 + (tagxid && (attr->ia_valid & ATTR_XID))) {
4082 - *p++ = htonl(attr->ia_gid);
4083 + *p++ = htonl(XIDINO_GID(tagxid, attr->ia_gid, attr->ia_xid));
4087 @@ -274,7 +277,8 @@ static int
4088 nfs3_xdr_sattrargs(struct rpc_rqst *req, u32 *p, struct nfs3_sattrargs *args)
4090 p = xdr_encode_fhandle(p, args->fh);
4091 - p = xdr_encode_sattr(p, args->sattr);
4092 + p = xdr_encode_sattr(p, args->sattr,
4093 + req->rq_task->tk_client->cl_tagxid);
4094 *p++ = htonl(args->guard);
4096 p = xdr_encode_time3(p, &args->guardtime);
4097 @@ -365,7 +369,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
4098 *p++ = args->verifier[0];
4099 *p++ = args->verifier[1];
4101 - p = xdr_encode_sattr(p, args->sattr);
4102 + p = xdr_encode_sattr(p, args->sattr,
4103 + req->rq_task->tk_client->cl_tagxid);
4105 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
4107 @@ -379,7 +384,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
4109 p = xdr_encode_fhandle(p, args->fh);
4110 p = xdr_encode_array(p, args->name, args->len);
4111 - p = xdr_encode_sattr(p, args->sattr);
4112 + p = xdr_encode_sattr(p, args->sattr,
4113 + req->rq_task->tk_client->cl_tagxid);
4114 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
4117 @@ -392,7 +398,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
4119 p = xdr_encode_fhandle(p, args->fromfh);
4120 p = xdr_encode_array(p, args->fromname, args->fromlen);
4121 - p = xdr_encode_sattr(p, args->sattr);
4122 + p = xdr_encode_sattr(p, args->sattr,
4123 + req->rq_task->tk_client->cl_tagxid);
4124 p = xdr_encode_array(p, args->topath, args->tolen);
4125 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
4127 @@ -407,7 +414,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
4128 p = xdr_encode_fhandle(p, args->fh);
4129 p = xdr_encode_array(p, args->name, args->len);
4130 *p++ = htonl(args->type);
4131 - p = xdr_encode_sattr(p, args->sattr);
4132 + p = xdr_encode_sattr(p, args->sattr,
4133 + req->rq_task->tk_client->cl_tagxid);
4134 if (args->type == NF3CHR || args->type == NF3BLK) {
4135 *p++ = htonl(MAJOR(args->rdev));
4136 *p++ = htonl(MINOR(args->rdev));
4137 diff -NurpP --minimal linux-2.6.10/fs/nfs/nfsroot.c linux-2.6.10-vs1.9.3.17/fs/nfs/nfsroot.c
4138 --- linux-2.6.10/fs/nfs/nfsroot.c 2004-08-14 12:55:48.000000000 +0200
4139 +++ linux-2.6.10-vs1.9.3.17/fs/nfs/nfsroot.c 2004-12-26 19:40:34.000000000 +0100
4141 #include <linux/root_dev.h>
4142 #include <net/ipconfig.h>
4143 #include <linux/parser.h>
4144 +#include <linux/vs_cvirt.h>
4146 /* Define this to allow debugging output */
4147 #undef NFSROOT_DEBUG
4148 @@ -124,7 +125,7 @@ enum {
4149 Opt_soft, Opt_hard, Opt_intr,
4150 Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac,
4151 Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
4153 + Opt_broken_suid, Opt_tagxid,
4157 @@ -160,6 +161,7 @@ static match_table_t __initdata tokens =
4158 {Opt_tcp, "proto=tcp"},
4160 {Opt_broken_suid, "broken_suid"},
4161 + {Opt_tagxid, "tagxid"},
4165 @@ -271,6 +273,9 @@ static int __init root_nfs_parse(char *n
4166 case Opt_broken_suid:
4167 nfs_data.flags |= NFS_MOUNT_BROKEN_SUID;
4170 + nfs_data.flags |= NFS_MOUNT_TAGXID;
4175 @@ -306,7 +311,7 @@ static int __init root_nfs_name(char *na
4176 /* Override them by options set on kernel command-line */
4177 root_nfs_parse(name, buf);
4179 - cp = system_utsname.nodename;
4180 + cp = vx_new_uts(nodename);
4181 if (strlen(buf) + strlen(cp) > NFS_MAXPATHLEN) {
4182 printk(KERN_ERR "Root-NFS: Pathname for remote directory too long.\n");
4184 diff -NurpP --minimal linux-2.6.10/fs/nfsd/auth.c linux-2.6.10-vs1.9.3.17/fs/nfsd/auth.c
4185 --- linux-2.6.10/fs/nfsd/auth.c 2004-08-14 12:56:14.000000000 +0200
4186 +++ linux-2.6.10-vs1.9.3.17/fs/nfsd/auth.c 2004-12-26 19:40:34.000000000 +0100
4188 #include <linux/sunrpc/svc.h>
4189 #include <linux/sunrpc/svcauth.h>
4190 #include <linux/nfsd/nfsd.h>
4191 +#include <linux/vserver/xid.h>
4193 #define CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
4195 @@ -42,18 +43,20 @@ int nfsd_setuser(struct svc_rqst *rqstp,
4198 if (cred->cr_uid != (uid_t) -1)
4199 - current->fsuid = cred->cr_uid;
4200 + current->fsuid = INOXID_UID(1, cred->cr_uid, cred->cr_gid);
4202 current->fsuid = exp->ex_anon_uid;
4203 if (cred->cr_gid != (gid_t) -1)
4204 - current->fsgid = cred->cr_gid;
4205 + current->fsgid = INOXID_GID(1, cred->cr_uid, cred->cr_gid);
4207 current->fsgid = exp->ex_anon_gid;
4209 + current->xid = INOXID_XID(1, cred->cr_uid, cred->cr_gid, 0);
4211 if (!cred->cr_group_info)
4213 ret = set_current_groups(cred->cr_group_info);
4214 - if ((cred->cr_uid)) {
4215 + if (INOXID_UID(1, cred->cr_uid, cred->cr_gid)) {
4216 cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
4218 cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
4219 diff -NurpP --minimal linux-2.6.10/fs/nfsd/nfs3xdr.c linux-2.6.10-vs1.9.3.17/fs/nfsd/nfs3xdr.c
4220 --- linux-2.6.10/fs/nfsd/nfs3xdr.c 2004-10-23 05:06:17.000000000 +0200
4221 +++ linux-2.6.10-vs1.9.3.17/fs/nfsd/nfs3xdr.c 2004-12-26 19:40:34.000000000 +0100
4223 #include <linux/sunrpc/svc.h>
4224 #include <linux/nfsd/nfsd.h>
4225 #include <linux/nfsd/xdr3.h>
4226 +#include <linux/vserver/xid.h>
4228 #define NFSDDBG_FACILITY NFSDDBG_XDR
4230 @@ -121,6 +122,8 @@ static inline u32 *
4231 decode_sattr3(u32 *p, struct iattr *iap)
4239 @@ -130,12 +133,15 @@ decode_sattr3(u32 *p, struct iattr *iap)
4242 iap->ia_valid |= ATTR_UID;
4243 - iap->ia_uid = ntohl(*p++);
4244 + uid = ntohl(*p++);
4247 iap->ia_valid |= ATTR_GID;
4248 - iap->ia_gid = ntohl(*p++);
4249 + gid = ntohl(*p++);
4251 + iap->ia_uid = INOXID_UID(1, uid, gid);
4252 + iap->ia_gid = INOXID_GID(1, uid, gid);
4253 + iap->ia_xid = INOXID_XID(1, uid, gid, 0);
4257 @@ -176,8 +182,10 @@ encode_fattr3(struct svc_rqst *rqstp, u3
4258 *p++ = htonl(nfs3_ftypes[(stat.mode & S_IFMT) >> 12]);
4259 *p++ = htonl((u32) stat.mode);
4260 *p++ = htonl((u32) stat.nlink);
4261 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat.uid));
4262 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat.gid));
4263 + *p++ = htonl((u32) nfsd_ruid(rqstp,
4264 + XIDINO_UID(XID_TAG(dentry->d_inode), stat.uid, stat.xid)));
4265 + *p++ = htonl((u32) nfsd_rgid(rqstp,
4266 + XIDINO_GID(XID_TAG(dentry->d_inode), stat.gid, stat.xid)));
4267 if (S_ISLNK(stat.mode) && stat.size > NFS3_MAXPATHLEN) {
4268 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
4270 diff -NurpP --minimal linux-2.6.10/fs/nfsd/nfs4xdr.c linux-2.6.10-vs1.9.3.17/fs/nfsd/nfs4xdr.c
4271 --- linux-2.6.10/fs/nfsd/nfs4xdr.c 2004-12-25 01:55:21.000000000 +0100
4272 +++ linux-2.6.10-vs1.9.3.17/fs/nfsd/nfs4xdr.c 2004-12-26 19:40:34.000000000 +0100
4274 #include <linux/nfsd_idmap.h>
4275 #include <linux/nfs4.h>
4276 #include <linux/nfs4_acl.h>
4277 +#include <linux/vserver/xid.h>
4279 #define NFSDDBG_FACILITY NFSDDBG_XDR
4281 @@ -1660,14 +1661,18 @@ out_acl:
4282 WRITE32(stat.nlink);
4284 if (bmval1 & FATTR4_WORD1_OWNER) {
4285 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
4286 + status = nfsd4_encode_user(rqstp,
4287 + XIDINO_UID(XID_TAG(dentry->d_inode),
4288 + stat.uid, stat.xid), &p, &buflen);
4289 if (status == nfserr_resource)
4294 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
4295 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
4296 + status = nfsd4_encode_group(rqstp,
4297 + XIDINO_GID(XID_TAG(dentry->d_inode),
4298 + stat.gid, stat.xid), &p, &buflen);
4299 if (status == nfserr_resource)
4302 diff -NurpP --minimal linux-2.6.10/fs/nfsd/nfsxdr.c linux-2.6.10-vs1.9.3.17/fs/nfsd/nfsxdr.c
4303 --- linux-2.6.10/fs/nfsd/nfsxdr.c 2004-08-14 12:54:47.000000000 +0200
4304 +++ linux-2.6.10-vs1.9.3.17/fs/nfsd/nfsxdr.c 2004-12-26 19:40:34.000000000 +0100
4306 #include <linux/nfsd/nfsd.h>
4307 #include <linux/nfsd/xdr.h>
4308 #include <linux/mm.h>
4309 +#include <linux/vserver/xid.h>
4311 #define NFSDDBG_FACILITY NFSDDBG_XDR
4313 @@ -96,6 +97,8 @@ static inline u32 *
4314 decode_sattr(u32 *p, struct iattr *iap)
4322 @@ -109,12 +112,15 @@ decode_sattr(u32 *p, struct iattr *iap)
4324 if ((tmp = ntohl(*p++)) != (u32)-1) {
4325 iap->ia_valid |= ATTR_UID;
4326 - iap->ia_uid = tmp;
4329 if ((tmp = ntohl(*p++)) != (u32)-1) {
4330 iap->ia_valid |= ATTR_GID;
4331 - iap->ia_gid = tmp;
4334 + iap->ia_uid = INOXID_UID(1, uid, gid);
4335 + iap->ia_gid = INOXID_GID(1, uid, gid);
4336 + iap->ia_xid = INOXID_XID(1, uid, gid, 0);
4337 if ((tmp = ntohl(*p++)) != (u32)-1) {
4338 iap->ia_valid |= ATTR_SIZE;
4340 @@ -160,8 +166,10 @@ encode_fattr(struct svc_rqst *rqstp, u32
4341 *p++ = htonl(nfs_ftypes[type >> 12]);
4342 *p++ = htonl((u32) stat.mode);
4343 *p++ = htonl((u32) stat.nlink);
4344 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat.uid));
4345 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat.gid));
4346 + *p++ = htonl((u32) nfsd_ruid(rqstp,
4347 + XIDINO_UID(XID_TAG(dentry->d_inode), stat.uid, stat.xid)));
4348 + *p++ = htonl((u32) nfsd_rgid(rqstp,
4349 + XIDINO_GID(XID_TAG(dentry->d_inode), stat.gid, stat.xid)));
4351 if (S_ISLNK(type) && stat.size > NFS_MAXPATHLEN) {
4352 *p++ = htonl(NFS_MAXPATHLEN);
4353 diff -NurpP --minimal linux-2.6.10/fs/open.c linux-2.6.10-vs1.9.3.17/fs/open.c
4354 --- linux-2.6.10/fs/open.c 2004-12-25 01:55:21.000000000 +0100
4355 +++ linux-2.6.10-vs1.9.3.17/fs/open.c 2004-12-26 19:40:35.000000000 +0100
4357 #include <linux/fs.h>
4358 #include <linux/pagemap.h>
4359 #include <linux/syscalls.h>
4360 +#include <linux/vs_limit.h>
4361 +#include <linux/vs_dlimit.h>
4362 +#include <linux/vserver/xid.h>
4364 #include <asm/unistd.h>
4366 @@ -41,6 +44,8 @@ int vfs_statfs(struct super_block *sb, s
4367 if (retval == 0 && buf->f_frsize == 0)
4368 buf->f_frsize = buf->f_bsize;
4370 + if (!vx_check(0, VX_ADMIN|VX_WATCH))
4371 + vx_vsi_statfs(sb, buf);
4375 @@ -679,14 +684,15 @@ static int chown_common(struct dentry *
4377 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
4380 newattrs.ia_valid = ATTR_CTIME;
4381 if (user != (uid_t) -1) {
4382 newattrs.ia_valid |= ATTR_UID;
4383 - newattrs.ia_uid = user;
4384 + newattrs.ia_uid = vx_map_uid(user);
4386 if (group != (gid_t) -1) {
4387 newattrs.ia_valid |= ATTR_GID;
4388 - newattrs.ia_gid = group;
4389 + newattrs.ia_gid = vx_map_gid(group);
4391 if (!S_ISDIR(inode->i_mode))
4392 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
4393 @@ -881,6 +887,7 @@ repeat:
4394 FD_SET(fd, files->open_fds);
4395 FD_CLR(fd, files->close_on_exec);
4396 files->next_fd = fd + 1;
4397 + // vx_openfd_inc(fd);
4400 if (files->fd[fd] != NULL) {
4401 @@ -902,6 +909,7 @@ static inline void __put_unused_fd(struc
4402 __FD_CLR(fd, files->open_fds);
4403 if (fd < files->next_fd)
4404 files->next_fd = fd;
4405 + // vx_openfd_dec(fd);
4408 void fastcall put_unused_fd(unsigned int fd)
4409 diff -NurpP --minimal linux-2.6.10/fs/proc/array.c linux-2.6.10-vs1.9.3.17/fs/proc/array.c
4410 --- linux-2.6.10/fs/proc/array.c 2004-12-25 01:55:21.000000000 +0100
4411 +++ linux-2.6.10-vs1.9.3.17/fs/proc/array.c 2004-12-26 19:40:36.000000000 +0100
4413 #include <linux/highmem.h>
4414 #include <linux/file.h>
4415 #include <linux/times.h>
4416 +#include <linux/vs_context.h>
4417 +#include <linux/vs_network.h>
4418 +#include <linux/vs_cvirt.h>
4420 #include <asm/uaccess.h>
4421 #include <asm/pgtable.h>
4422 @@ -132,7 +135,8 @@ static const char *task_state_array[] =
4423 "T (stopped)", /* 4 */
4424 "T (tracing stop)", /* 8 */
4425 "Z (zombie)", /* 16 */
4426 - "X (dead)" /* 32 */
4427 + "X (dead)", /* 32 */
4428 + "H (on hold)" /* 64 */
4431 static inline const char * get_task_state(struct task_struct *tsk)
4432 @@ -141,7 +145,8 @@ static inline const char * get_task_stat
4433 TASK_INTERRUPTIBLE |
4434 TASK_UNINTERRUPTIBLE |
4439 (tsk->exit_state & (EXIT_ZOMBIE |
4441 const char **p = &task_state_array[0];
4442 @@ -157,8 +162,13 @@ static inline char * task_state(struct t
4444 struct group_info *group_info;
4446 + pid_t pid, ptgid, tppid, tgid;
4448 read_lock(&tasklist_lock);
4449 + tgid = vx_map_tgid(p->tgid);
4450 + pid = vx_map_pid(p->pid);
4451 + ptgid = vx_map_pid(p->group_leader->real_parent->tgid);
4452 + tppid = vx_map_pid(p->parent->pid);
4453 buffer += sprintf(buffer,
4455 "SleepAVG:\t%lu%%\n"
4456 @@ -170,9 +180,8 @@ static inline char * task_state(struct t
4457 "Gid:\t%d\t%d\t%d\t%d\n",
4459 (p->sleep_avg/1024)*100/(1020000000/1024),
4461 - p->pid, pid_alive(p) ? p->group_leader->real_parent->tgid : 0,
4462 - pid_alive(p) && p->ptrace ? p->parent->pid : 0,
4463 + tgid, pid, (pid > 1) ? ptgid : 0,
4464 + pid_alive(p) && p->ptrace ? tppid : 0,
4465 p->uid, p->euid, p->suid, p->fsuid,
4466 p->gid, p->egid, p->sgid, p->fsgid);
4467 read_unlock(&tasklist_lock);
4468 @@ -283,6 +292,10 @@ static inline char *task_cap(struct task
4469 int proc_pid_status(struct task_struct *task, char * buffer)
4471 char * orig = buffer;
4472 +#ifdef CONFIG_VSERVER_LEGACY
4473 + struct vx_info *vxi;
4474 + struct nx_info *nxi;
4476 struct mm_struct *mm = get_task_mm(task);
4478 buffer = task_name(task, buffer);
4479 @@ -294,6 +307,39 @@ int proc_pid_status(struct task_struct *
4481 buffer = task_sig(task, buffer);
4482 buffer = task_cap(task, buffer);
4484 +#ifdef CONFIG_VSERVER_LEGACY
4485 + buffer += sprintf (buffer,"s_context: %d\n", vx_task_xid(task));
4486 + vxi = task_get_vx_info(task);
4488 + buffer += sprintf (buffer,"ctxflags: %08llx\n"
4489 + ,(unsigned long long)vxi->vx_flags);
4490 + buffer += sprintf (buffer,"initpid: %d\n"
4491 + ,vxi->vx_initpid);
4493 + buffer += sprintf (buffer,"ctxflags: none\n");
4494 + buffer += sprintf (buffer,"initpid: none\n");
4497 + nxi = task_get_nx_info(task);
4501 + buffer += sprintf (buffer,"ipv4root:");
4502 + for (i=0; i<nxi->nbipv4; i++){
4503 + buffer += sprintf (buffer," %08x/%08x"
4508 + buffer += sprintf (buffer,"ipv4root_bcast: %08x\n"
4511 + buffer += sprintf (buffer,"ipv4root: 0\n");
4512 + buffer += sprintf (buffer,"ipv4root_bcast: 0\n");
4516 #if defined(CONFIG_ARCH_S390)
4517 buffer = task_show_regs(task, buffer);
4519 @@ -308,7 +354,7 @@ static int do_task_stat(struct task_stru
4520 sigset_t sigign, sigcatch;
4523 - pid_t ppid, pgid = -1, sid = -1;
4524 + pid_t pid, ppid, pgid = -1, sid = -1;
4525 int num_threads = 0;
4526 struct mm_struct *mm;
4527 unsigned long long start_time;
4528 @@ -370,7 +416,11 @@ static int do_task_stat(struct task_stru
4529 stime += task->signal->stime;
4532 - ppid = pid_alive(task) ? task->group_leader->real_parent->tgid : 0;
4533 + pid = vx_info_map_pid(task->vx_info, pid_alive(task) ? task->pid : 0);
4534 + ppid = (!(pid > 1)) ? 0 : vx_info_map_tgid(task->vx_info,
4535 + task->group_leader->real_parent->tgid);
4536 + pgid = vx_info_map_pid(task->vx_info, pgid);
4538 read_unlock(&tasklist_lock);
4540 if (!whole || num_threads<2)
4541 @@ -391,13 +441,25 @@ static int do_task_stat(struct task_stru
4542 /* convert timespec -> nsec*/
4543 start_time = (unsigned long long)task->start_time.tv_sec * NSEC_PER_SEC
4544 + task->start_time.tv_nsec;
4546 /* convert nsec -> ticks */
4547 start_time = nsec_to_clock_t(start_time);
4549 + /* fixup start time for virt uptime */
4550 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
4551 + unsigned long long bias =
4552 + current->vx_info->cvirt.bias_clock;
4554 + if (start_time > bias)
4555 + start_time -= bias;
4560 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
4561 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d %ld %llu %lu %ld %lu %lu %lu %lu %lu \
4562 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu\n",
4568 diff -NurpP --minimal linux-2.6.10/fs/proc/base.c linux-2.6.10-vs1.9.3.17/fs/proc/base.c
4569 --- linux-2.6.10/fs/proc/base.c 2004-12-25 01:55:21.000000000 +0100
4570 +++ linux-2.6.10-vs1.9.3.17/fs/proc/base.c 2005-01-02 18:45:13.000000000 +0100
4572 #include <linux/mount.h>
4573 #include <linux/security.h>
4574 #include <linux/ptrace.h>
4575 +#include <linux/vs_network.h>
4578 * For hysterical raisins we keep the same inumbers as in the old procfs.
4579 @@ -70,6 +71,8 @@ enum pid_directory_inos {
4580 PROC_TGID_ATTR_EXEC,
4581 PROC_TGID_ATTR_FSCREATE,
4583 + PROC_TGID_VX_INFO,
4584 + PROC_TGID_IP_INFO,
4588 @@ -96,6 +99,8 @@ enum pid_directory_inos {
4590 PROC_TID_ATTR_FSCREATE,
4594 PROC_TID_FD_DIR = 0x8000, /* 0x8000-0xffff */
4597 @@ -132,6 +137,8 @@ static struct pid_entry tgid_base_stuff[
4598 #ifdef CONFIG_SCHEDSTATS
4599 E(PROC_TGID_SCHEDSTAT, "schedstat", S_IFREG|S_IRUGO),
4601 + E(PROC_TGID_VX_INFO, "vinfo", S_IFREG|S_IRUGO),
4602 + E(PROC_TGID_IP_INFO, "ninfo", S_IFREG|S_IRUGO),
4605 static struct pid_entry tid_base_stuff[] = {
4606 @@ -157,6 +164,8 @@ static struct pid_entry tid_base_stuff[]
4607 #ifdef CONFIG_SCHEDSTATS
4608 E(PROC_TID_SCHEDSTAT, "schedstat",S_IFREG|S_IRUGO),
4610 + E(PROC_TID_VX_INFO, "vinfo", S_IFREG|S_IRUGO),
4611 + E(PROC_TID_IP_INFO, "ninfo", S_IFREG|S_IRUGO),
4615 @@ -961,6 +970,7 @@ static struct inode *proc_pid_make_inode
4616 inode->i_uid = task->euid;
4617 inode->i_gid = task->egid;
4619 + inode->i_xid = vx_task_xid(task);
4620 security_task_to_inode(task, inode);
4623 @@ -986,6 +996,11 @@ static int pid_revalidate(struct dentry
4625 struct inode *inode = dentry->d_inode;
4626 struct task_struct *task = proc_task(inode);
4628 + if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
4630 + /* discard wrong fakeinit */
4632 if (pid_alive(task)) {
4633 if (proc_type(inode) == PROC_TGID_INO || proc_type(inode) == PROC_TID_INO || task_dumpable(task)) {
4634 inode->i_uid = task->euid;
4635 @@ -997,6 +1012,7 @@ static int pid_revalidate(struct dentry
4636 security_task_to_inode(task, inode);
4643 @@ -1231,6 +1247,9 @@ static struct file_operations proc_tgid_
4644 static struct inode_operations proc_tgid_attr_inode_operations;
4647 +extern int proc_pid_vx_info(struct task_struct *, char *);
4648 +extern int proc_pid_nx_info(struct task_struct *, char *);
4651 static struct dentry *proc_pident_lookup(struct inode *dir,
4652 struct dentry *dentry,
4653 @@ -1377,6 +1396,16 @@ static struct dentry *proc_pident_lookup
4654 ei->op.proc_read = proc_pid_schedstat;
4657 + case PROC_TID_VX_INFO:
4658 + case PROC_TGID_VX_INFO:
4659 + inode->i_fop = &proc_info_file_operations;
4660 + ei->op.proc_read = proc_pid_vx_info;
4662 + case PROC_TID_IP_INFO:
4663 + case PROC_TGID_IP_INFO:
4664 + inode->i_fop = &proc_info_file_operations;
4665 + ei->op.proc_read = proc_pid_nx_info;
4668 printk("procfs: impossible type (%d)",p->type);
4670 @@ -1469,14 +1498,14 @@ static int proc_self_readlink(struct den
4674 - sprintf(tmp, "%d", current->tgid);
4675 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
4676 return vfs_readlink(dentry,buffer,buflen,tmp);
4679 static int proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
4682 - sprintf(tmp, "%d", current->tgid);
4683 + sprintf(tmp, "%d", vx_map_tgid(current->tgid));
4684 return vfs_follow_link(nd,tmp);
4687 @@ -1571,13 +1600,13 @@ struct dentry *proc_pid_lookup(struct in
4691 - inode = proc_pid_make_inode(dir->i_sb, task, PROC_TGID_INO);
4692 + if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
4693 + goto out_drop_task;
4695 + inode = proc_pid_make_inode(dir->i_sb, task, PROC_TGID_INO);
4697 + goto out_drop_task;
4700 - put_task_struct(task);
4703 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
4704 inode->i_op = &proc_tgid_base_inode_operations;
4705 inode->i_fop = &proc_tgid_base_operations;
4706 @@ -1602,6 +1631,8 @@ struct dentry *proc_pid_lookup(struct in
4711 + put_task_struct(task);
4713 return ERR_PTR(-ENOENT);
4715 @@ -1617,6 +1648,8 @@ static struct dentry *proc_task_lookup(s
4716 tid = name_to_int(dentry);
4719 + if (vx_current_initpid(tid))
4722 read_lock(&tasklist_lock);
4723 task = find_task_by_pid(tid);
4724 @@ -1628,11 +1661,13 @@ static struct dentry *proc_task_lookup(s
4725 if (leader->tgid != task->tgid)
4728 - inode = proc_pid_make_inode(dir->i_sb, task, PROC_TID_INO);
4730 + if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
4731 + goto out_drop_task;
4733 + inode = proc_pid_make_inode(dir->i_sb, task, PROC_TID_INO);
4737 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
4738 inode->i_op = &proc_tid_base_inode_operations;
4739 inode->i_fop = &proc_tid_base_operations;
4740 @@ -1668,7 +1703,7 @@ static int get_tgid_list(int index, unsi
4741 read_lock(&tasklist_lock);
4744 - p = find_task_by_pid(version);
4745 + p = find_task_by_real_pid(version);
4746 if (p && !thread_group_leader(p))
4749 @@ -1680,11 +1715,14 @@ static int get_tgid_list(int index, unsi
4751 for ( ; p != &init_task; p = next_task(p)) {
4756 + if (!vx_check(vx_task_xid(p), VX_WATCH|VX_IDENT))
4760 - tgids[nr_tgids] = tgid;
4761 + tgids[nr_tgids] = vx_map_tgid(tgid);
4763 if (nr_tgids >= PROC_MAXPIDS)
4765 @@ -1714,9 +1752,11 @@ static int get_tid_list(int index, unsig
4766 if (pid_alive(task)) do {
4767 int tid = task->pid;
4769 + if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
4773 - tids[nr_tids] = tid;
4774 + tids[nr_tids] = vx_map_pid(tid);
4776 if (nr_tids >= PROC_MAXPIDS)
4778 @@ -1792,11 +1832,14 @@ static int proc_task_readdir(struct file
4779 unsigned int nr_tids, i;
4780 struct dentry *dentry = filp->f_dentry;
4781 struct inode *inode = dentry->d_inode;
4782 + struct task_struct *task = proc_task(inode);
4783 int retval = -ENOENT;
4785 unsigned long pos = filp->f_pos; /* avoiding "long long" filp->f_pos */
4787 - if (!pid_alive(proc_task(inode)))
4788 + if (!vx_check(vx_task_xid(task), VX_WATCH|VX_IDENT))
4790 + if (!pid_alive(task))
4794 diff -NurpP --minimal linux-2.6.10/fs/proc/generic.c linux-2.6.10-vs1.9.3.17/fs/proc/generic.c
4795 --- linux-2.6.10/fs/proc/generic.c 2004-12-25 01:55:21.000000000 +0100
4796 +++ linux-2.6.10-vs1.9.3.17/fs/proc/generic.c 2004-12-26 19:40:24.000000000 +0100
4798 #include <linux/idr.h>
4799 #include <linux/namei.h>
4800 #include <linux/bitops.h>
4801 +#include <linux/vserver/inode.h>
4802 #include <asm/uaccess.h>
4804 static ssize_t proc_file_read(struct file *file, char __user *buf,
4805 @@ -372,11 +373,15 @@ struct dentry *proc_lookup(struct inode
4806 for (de = de->subdir; de ; de = de->next) {
4807 if (de->namelen != dentry->d_name.len)
4809 + if (!vx_hide_check(0, de->vx_flags))
4811 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
4812 unsigned int ino = de->low_ino;
4815 inode = proc_get_inode(dir->i_sb, ino, de);
4816 + /* generic proc entries belong to the host */
4821 @@ -448,9 +453,12 @@ int proc_readdir(struct file * filp,
4825 + if (!vx_hide_check(0, de->vx_flags))
4827 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
4828 de->low_ino, de->mode >> 12) < 0)
4834 @@ -562,6 +570,7 @@ static struct proc_dir_entry *proc_creat
4838 + ent->vx_flags = IATTR_PROC_DEFAULT;
4842 @@ -582,7 +591,8 @@ struct proc_dir_entry *proc_symlink(cons
4848 + ent->vx_flags = IATTR_PROC_SYMLINK;
4852 diff -NurpP --minimal linux-2.6.10/fs/proc/inode.c linux-2.6.10-vs1.9.3.17/fs/proc/inode.c
4853 --- linux-2.6.10/fs/proc/inode.c 2004-10-23 05:06:17.000000000 +0200
4854 +++ linux-2.6.10-vs1.9.3.17/fs/proc/inode.c 2004-12-26 19:40:24.000000000 +0100
4855 @@ -211,6 +211,8 @@ struct inode *proc_get_inode(struct supe
4856 inode->i_uid = de->uid;
4857 inode->i_gid = de->gid;
4860 + PROC_I(inode)->vx_flags = de->vx_flags;
4862 inode->i_size = de->size;
4864 diff -NurpP --minimal linux-2.6.10/fs/proc/proc_misc.c linux-2.6.10-vs1.9.3.17/fs/proc/proc_misc.c
4865 --- linux-2.6.10/fs/proc/proc_misc.c 2004-12-25 01:55:21.000000000 +0100
4866 +++ linux-2.6.10-vs1.9.3.17/fs/proc/proc_misc.c 2004-12-26 19:40:30.000000000 +0100
4868 #include <asm/tlb.h>
4869 #include <asm/div64.h>
4871 +#include <linux/vs_cvirt.h>
4873 #define LOAD_INT(x) ((x) >> FSHIFT)
4874 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
4876 @@ -81,17 +83,32 @@ static int proc_calc_metrics(char *page,
4877 static int loadavg_read_proc(char *page, char **start, off_t off,
4878 int count, int *eof, void *data)
4880 + unsigned int running, threads;
4884 - a = avenrun[0] + (FIXED_1/200);
4885 - b = avenrun[1] + (FIXED_1/200);
4886 - c = avenrun[2] + (FIXED_1/200);
4887 - len = sprintf(page,"%d.%02d %d.%02d %d.%02d %ld/%d %d\n",
4888 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
4889 + struct vx_info *vxi = current->vx_info;
4891 + a = vxi->cvirt.load[0] + (FIXED_1/200);
4892 + b = vxi->cvirt.load[1] + (FIXED_1/200);
4893 + c = vxi->cvirt.load[2] + (FIXED_1/200);
4895 + running = atomic_read(&vxi->cvirt.nr_running);
4896 + threads = atomic_read(&vxi->cvirt.nr_threads);
4898 + a = avenrun[0] + (FIXED_1/200);
4899 + b = avenrun[1] + (FIXED_1/200);
4900 + c = avenrun[2] + (FIXED_1/200);
4902 + running = nr_running();
4903 + threads = nr_threads;
4905 + len = sprintf(page,"%d.%02d %d.%02d %d.%02d %d/%d %d\n",
4906 LOAD_INT(a), LOAD_FRAC(a),
4907 LOAD_INT(b), LOAD_FRAC(b),
4908 LOAD_INT(c), LOAD_FRAC(c),
4909 - nr_running(), nr_threads, last_pid);
4910 + running, threads, last_pid);
4911 return proc_calc_metrics(page, start, off, count, eof, len);
4914 @@ -140,6 +157,9 @@ static int uptime_read_proc(char *page,
4916 do_posix_clock_monotonic_gettime(&uptime);
4917 jiffies_to_timespec(idle_jiffies, &idle);
4918 + if (vx_flags(VXF_VIRT_UPTIME, 0))
4919 + vx_vsi_uptime(&uptime, &idle);
4921 len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
4922 (unsigned long) uptime.tv_sec,
4923 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
4924 diff -NurpP --minimal linux-2.6.10/fs/proc/root.c linux-2.6.10-vs1.9.3.17/fs/proc/root.c
4925 --- linux-2.6.10/fs/proc/root.c 2004-12-25 01:55:21.000000000 +0100
4926 +++ linux-2.6.10-vs1.9.3.17/fs/proc/root.c 2004-12-26 19:40:24.000000000 +0100
4927 @@ -23,6 +23,9 @@ struct proc_dir_entry *proc_net, *proc_n
4928 #ifdef CONFIG_SYSCTL
4929 struct proc_dir_entry *proc_sys_root;
4931 +struct proc_dir_entry *proc_virtual;
4933 +extern void proc_vx_init(void);
4935 static struct super_block *proc_get_sb(struct file_system_type *fs_type,
4936 int flags, const char *dev_name, void *data)
4937 @@ -77,6 +80,7 @@ void __init proc_root_init(void)
4938 proc_device_tree_init();
4940 proc_bus = proc_mkdir("bus", NULL);
4944 static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry, struct nameidata *nd)
4945 diff -NurpP --minimal linux-2.6.10/fs/reiserfs/inode.c linux-2.6.10-vs1.9.3.17/fs/reiserfs/inode.c
4946 --- linux-2.6.10/fs/reiserfs/inode.c 2004-12-25 01:55:21.000000000 +0100
4947 +++ linux-2.6.10-vs1.9.3.17/fs/reiserfs/inode.c 2004-12-26 19:40:34.000000000 +0100
4949 #include <linux/mpage.h>
4950 #include <linux/writeback.h>
4951 #include <linux/quotaops.h>
4952 +#include <linux/vserver/xid.h>
4954 extern int reiserfs_default_io_size; /* default io size devuned in super.c */
4956 @@ -1049,6 +1050,8 @@ static void init_inode (struct inode * i
4957 struct buffer_head * bh;
4958 struct item_head * ih;
4962 //int version = ITEM_VERSION_1;
4964 bh = PATH_PLAST_BUFFER (path);
4965 @@ -1072,12 +1075,13 @@ static void init_inode (struct inode * i
4966 struct stat_data_v1 * sd = (struct stat_data_v1 *)B_I_PITEM (bh, ih);
4967 unsigned long blocks;
4969 + uid = sd_v1_uid(sd);
4970 + gid = sd_v1_gid(sd);
4972 set_inode_item_key_version (inode, KEY_FORMAT_3_5);
4973 set_inode_sd_version (inode, STAT_DATA_V1);
4974 inode->i_mode = sd_v1_mode(sd);
4975 inode->i_nlink = sd_v1_nlink(sd);
4976 - inode->i_uid = sd_v1_uid(sd);
4977 - inode->i_gid = sd_v1_gid(sd);
4978 inode->i_size = sd_v1_size(sd);
4979 inode->i_atime.tv_sec = sd_v1_atime(sd);
4980 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
4981 @@ -1117,11 +1121,12 @@ static void init_inode (struct inode * i
4982 // (directories and symlinks)
4983 struct stat_data * sd = (struct stat_data *)B_I_PITEM (bh, ih);
4985 + uid = sd_v2_uid(sd);
4986 + gid = sd_v2_gid(sd);
4988 inode->i_mode = sd_v2_mode(sd);
4989 inode->i_nlink = sd_v2_nlink(sd);
4990 - inode->i_uid = sd_v2_uid(sd);
4991 inode->i_size = sd_v2_size(sd);
4992 - inode->i_gid = sd_v2_gid(sd);
4993 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
4994 inode->i_atime.tv_sec = sd_v2_atime(sd);
4995 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
4996 @@ -1148,6 +1153,9 @@ static void init_inode (struct inode * i
4997 REISERFS_I(inode)->i_attrs = sd_v2_attrs( sd );
4998 sd_attrs_to_i_attrs( sd_v2_attrs( sd ), inode );
5000 + inode->i_uid = INOXID_UID(XID_TAG(inode), uid, gid);
5001 + inode->i_gid = INOXID_GID(XID_TAG(inode), uid, gid);
5002 + inode->i_xid = INOXID_XID(XID_TAG(inode), uid, gid, 0);
5005 if (S_ISREG (inode->i_mode)) {
5006 @@ -1172,13 +1180,15 @@ static void init_inode (struct inode * i
5007 static void inode2sd (void * sd, struct inode * inode, loff_t size)
5009 struct stat_data * sd_v2 = (struct stat_data *)sd;
5010 + uid_t uid = XIDINO_UID(XID_TAG(inode), inode->i_uid, inode->i_xid);
5011 + gid_t gid = XIDINO_GID(XID_TAG(inode), inode->i_gid, inode->i_xid);
5014 + set_sd_v2_uid(sd_v2, uid );
5015 + set_sd_v2_gid(sd_v2, gid );
5016 set_sd_v2_mode(sd_v2, inode->i_mode );
5017 set_sd_v2_nlink(sd_v2, inode->i_nlink );
5018 - set_sd_v2_uid(sd_v2, inode->i_uid );
5019 set_sd_v2_size(sd_v2, size );
5020 - set_sd_v2_gid(sd_v2, inode->i_gid );
5021 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec );
5022 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec );
5023 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec );
5024 @@ -2554,6 +2564,14 @@ void sd_attrs_to_i_attrs( __u16 sd_attrs
5025 inode -> i_flags |= S_IMMUTABLE;
5027 inode -> i_flags &= ~S_IMMUTABLE;
5028 + if( sd_attrs & REISERFS_IUNLINK_FL )
5029 + inode -> i_flags |= S_IUNLINK;
5031 + inode -> i_flags &= ~S_IUNLINK;
5032 + if( sd_attrs & REISERFS_BARRIER_FL )
5033 + inode -> i_flags |= S_BARRIER;
5035 + inode -> i_flags &= ~S_BARRIER;
5036 if( sd_attrs & REISERFS_APPEND_FL )
5037 inode -> i_flags |= S_APPEND;
5039 @@ -2576,6 +2594,14 @@ void i_attrs_to_sd_attrs( struct inode *
5040 *sd_attrs |= REISERFS_IMMUTABLE_FL;
5042 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
5043 + if( inode -> i_flags & S_IUNLINK )
5044 + *sd_attrs |= REISERFS_IUNLINK_FL;
5046 + *sd_attrs &= ~REISERFS_IUNLINK_FL;
5047 + if( inode -> i_flags & S_BARRIER )
5048 + *sd_attrs |= REISERFS_BARRIER_FL;
5050 + *sd_attrs &= ~REISERFS_BARRIER_FL;
5051 if( inode -> i_flags & S_SYNC )
5052 *sd_attrs |= REISERFS_SYNC_FL;
5054 @@ -2748,6 +2774,27 @@ static ssize_t reiserfs_direct_IO(int rw
5055 offset, nr_segs, reiserfs_get_blocks_direct_io, NULL);
5058 +int reiserfs_setattr_flags(struct inode *inode, unsigned int flags)
5060 + unsigned int oldflags, newflags;
5062 + oldflags = REISERFS_I(inode)->i_flags;
5063 + newflags = oldflags & ~(REISERFS_IMMUTABLE_FL |
5064 + REISERFS_IUNLINK_FL | REISERFS_BARRIER_FL);
5065 + if (flags & ATTR_FLAG_IMMUTABLE)
5066 + newflags |= REISERFS_IMMUTABLE_FL;
5067 + if (flags & ATTR_FLAG_IUNLINK)
5068 + newflags |= REISERFS_IUNLINK_FL;
5069 + if (flags & ATTR_FLAG_BARRIER)
5070 + newflags |= REISERFS_BARRIER_FL;
5072 + if (oldflags ^ newflags) {
5073 + REISERFS_I(inode)->i_flags = newflags;
5074 + inode->i_ctime = CURRENT_TIME;
5079 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) {
5080 struct inode *inode = dentry->d_inode ;
5082 @@ -2791,6 +2838,10 @@ int reiserfs_setattr(struct dentry *dent
5085 error = inode_change_ok(inode, attr) ;
5087 + if (!error && attr->ia_valid & ATTR_ATTR_FLAG)
5088 + reiserfs_setattr_flags(inode, attr->ia_attr_flags);
5091 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
5092 (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
5093 diff -NurpP --minimal linux-2.6.10/fs/reiserfs/ioctl.c linux-2.6.10-vs1.9.3.17/fs/reiserfs/ioctl.c
5094 --- linux-2.6.10/fs/reiserfs/ioctl.c 2004-08-14 12:55:19.000000000 +0200
5095 +++ linux-2.6.10-vs1.9.3.17/fs/reiserfs/ioctl.c 2004-12-26 19:40:30.000000000 +0100
5097 int reiserfs_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
5100 - unsigned int flags;
5101 + unsigned int flags, oldflags;
5104 case REISERFS_IOC_UNPACK:
5105 @@ -36,6 +36,7 @@ int reiserfs_ioctl (struct inode * inode
5106 case REISERFS_IOC_GETFLAGS:
5107 flags = REISERFS_I(inode) -> i_attrs;
5108 i_attrs_to_sd_attrs( inode, ( __u16 * ) &flags );
5109 + flags &= REISERFS_FL_USER_VISIBLE;
5110 return put_user(flags, (int __user *) arg);
5111 case REISERFS_IOC_SETFLAGS: {
5112 if (IS_RDONLY(inode))
5113 @@ -47,8 +48,12 @@ int reiserfs_ioctl (struct inode * inode
5114 if (get_user(flags, (int __user *) arg))
5117 - if ( ( ( flags ^ REISERFS_I(inode) -> i_attrs) & ( REISERFS_IMMUTABLE_FL | REISERFS_APPEND_FL)) &&
5118 - !capable( CAP_LINUX_IMMUTABLE ) )
5119 + oldflags = REISERFS_I(inode) -> i_attrs;
5120 + if ( ( (oldflags & REISERFS_IMMUTABLE_FL) ||
5121 + ( (flags ^ oldflags) &
5122 + (REISERFS_IMMUTABLE_FL | REISERFS_IUNLINK_FL |
5123 + REISERFS_APPEND_FL) ) ) &&
5124 + !capable( CAP_LINUX_IMMUTABLE ) )
5127 if( ( flags & REISERFS_NOTAIL_FL ) &&
5128 @@ -59,6 +64,9 @@ int reiserfs_ioctl (struct inode * inode
5133 + flags = flags & REISERFS_FL_USER_MODIFYABLE;
5134 + flags |= oldflags & ~REISERFS_FL_USER_MODIFYABLE;
5135 sd_attrs_to_i_attrs( flags, inode );
5136 REISERFS_I(inode) -> i_attrs = flags;
5137 inode->i_ctime = CURRENT_TIME;
5138 diff -NurpP --minimal linux-2.6.10/fs/reiserfs/namei.c linux-2.6.10-vs1.9.3.17/fs/reiserfs/namei.c
5139 --- linux-2.6.10/fs/reiserfs/namei.c 2004-12-25 01:55:21.000000000 +0100
5140 +++ linux-2.6.10-vs1.9.3.17/fs/reiserfs/namei.c 2004-12-26 19:40:34.000000000 +0100
5142 #include <linux/reiserfs_xattr.h>
5143 #include <linux/smp_lock.h>
5144 #include <linux/quotaops.h>
5145 +#include <linux/vserver/xid.h>
5147 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { i->i_nlink++; if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
5148 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) i->i_nlink--;
5149 @@ -350,6 +351,7 @@ static struct dentry * reiserfs_lookup (
5150 reiserfs_write_unlock(dir->i_sb);
5151 return ERR_PTR(-EACCES);
5153 + vx_propagate_xid(nd, inode);
5155 /* Propogate the priv_object flag so we know we're in the priv tree */
5156 if (is_reiserfs_priv_object (dir))
5157 diff -NurpP --minimal linux-2.6.10/fs/reiserfs/super.c linux-2.6.10-vs1.9.3.17/fs/reiserfs/super.c
5158 --- linux-2.6.10/fs/reiserfs/super.c 2004-12-25 01:55:21.000000000 +0100
5159 +++ linux-2.6.10-vs1.9.3.17/fs/reiserfs/super.c 2004-12-26 19:40:34.000000000 +0100
5160 @@ -757,6 +757,7 @@ static int reiserfs_parse_options (struc
5161 {"user_xattr", .setmask = 1<<REISERFS_UNSUPPORTED_OPT},
5162 {"nouser_xattr",.clrmask = 1<<REISERFS_UNSUPPORTED_OPT},
5164 + {"tagxid", .setmask = 1<<REISERFS_TAGXID},
5165 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
5166 {"acl", .setmask = 1<<REISERFS_POSIXACL},
5167 {"noacl", .clrmask = 1<<REISERFS_POSIXACL},
5168 diff -NurpP --minimal linux-2.6.10/fs/stat.c linux-2.6.10-vs1.9.3.17/fs/stat.c
5169 --- linux-2.6.10/fs/stat.c 2004-12-25 01:55:21.000000000 +0100
5170 +++ linux-2.6.10-vs1.9.3.17/fs/stat.c 2004-12-26 19:40:34.000000000 +0100
5171 @@ -27,6 +27,7 @@ void generic_fillattr(struct inode *inod
5172 stat->nlink = inode->i_nlink;
5173 stat->uid = inode->i_uid;
5174 stat->gid = inode->i_gid;
5175 + stat->xid = inode->i_xid;
5176 stat->rdev = inode->i_rdev;
5177 stat->atime = inode->i_atime;
5178 stat->mtime = inode->i_mtime;
5179 diff -NurpP --minimal linux-2.6.10/fs/super.c linux-2.6.10-vs1.9.3.17/fs/super.c
5180 --- linux-2.6.10/fs/super.c 2004-12-25 01:55:21.000000000 +0100
5181 +++ linux-2.6.10-vs1.9.3.17/fs/super.c 2004-12-26 19:40:30.000000000 +0100
5183 #include <linux/writeback.h> /* for the emergency remount stuff */
5184 #include <linux/idr.h>
5185 #include <linux/kobject.h>
5186 +#include <linux/devpts_fs.h>
5187 +#include <linux/proc_fs.h>
5188 #include <asm/uaccess.h>
5191 @@ -824,6 +826,13 @@ do_kern_mount(const char *fstype, int fl
5192 sb = type->get_sb(type, flags, name, data);
5194 goto out_free_secdata;
5197 + if (!capable(CAP_SYS_ADMIN) && !sb->s_bdev &&
5198 + (sb->s_magic != PROC_SUPER_MAGIC) &&
5199 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
5202 error = security_sb_kern_mount(sb, secdata);
5205 diff -NurpP --minimal linux-2.6.10/fs/sysfs/mount.c linux-2.6.10-vs1.9.3.17/fs/sysfs/mount.c
5206 --- linux-2.6.10/fs/sysfs/mount.c 2004-12-25 01:55:21.000000000 +0100
5207 +++ linux-2.6.10-vs1.9.3.17/fs/sysfs/mount.c 2004-12-26 19:40:30.000000000 +0100
5212 -/* Random magic number */
5213 -#define SYSFS_MAGIC 0x62656572
5215 struct vfsmount *sysfs_mount;
5216 struct super_block * sysfs_sb = NULL;
5217 @@ -36,7 +34,7 @@ static int sysfs_fill_super(struct super
5219 sb->s_blocksize = PAGE_CACHE_SIZE;
5220 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
5221 - sb->s_magic = SYSFS_MAGIC;
5222 + sb->s_magic = SYSFS_SUPER_MAGIC;
5223 sb->s_op = &sysfs_ops;
5226 diff -NurpP --minimal linux-2.6.10/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.10-vs1.9.3.17/fs/xfs/linux-2.6/xfs_ioctl.c
5227 --- linux-2.6.10/fs/xfs/linux-2.6/xfs_ioctl.c 2004-12-25 01:55:22.000000000 +0100
5228 +++ linux-2.6.10-vs1.9.3.17/fs/xfs/linux-2.6/xfs_ioctl.c 2004-12-26 19:40:31.000000000 +0100
5229 @@ -1008,6 +1008,8 @@ xfs_ioc_fsgeometry(
5230 #define LINUX_XFLAG_APPEND 0x00000020 /* writes to file may only append */
5231 #define LINUX_XFLAG_NODUMP 0x00000040 /* do not dump file */
5232 #define LINUX_XFLAG_NOATIME 0x00000080 /* do not update atime */
5233 +#define LINUX_XFLAG_BARRIER 0x00004000 /* chroot() barrier */
5234 +#define LINUX_XFLAG_IUNLINK 0x00008000 /* immutable unlink */
5237 xfs_merge_ioc_xflags(
5238 @@ -1048,6 +1050,10 @@ xfs_di2lxflags(
5240 if (di_flags & XFS_DIFLAG_IMMUTABLE)
5241 flags |= LINUX_XFLAG_IMMUTABLE;
5242 + if (di_flags & XFS_DIFLAG_IUNLINK)
5243 + flags |= LINUX_XFLAG_IUNLINK;
5244 + if (di_flags & XFS_DIFLAG_BARRIER)
5245 + flags |= LINUX_XFLAG_BARRIER;
5246 if (di_flags & XFS_DIFLAG_APPEND)
5247 flags |= LINUX_XFLAG_APPEND;
5248 if (di_flags & XFS_DIFLAG_SYNC)
5249 diff -NurpP --minimal linux-2.6.10/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.10-vs1.9.3.17/fs/xfs/linux-2.6/xfs_iops.c
5250 --- linux-2.6.10/fs/xfs/linux-2.6/xfs_iops.c 2004-10-23 05:06:18.000000000 +0200
5251 +++ linux-2.6.10-vs1.9.3.17/fs/xfs/linux-2.6/xfs_iops.c 2004-12-26 19:40:31.000000000 +0100
5252 @@ -495,6 +495,28 @@ linvfs_getattr(
5256 +linvfs_setattr_flags(
5258 + unsigned int flags)
5260 + unsigned int oldflags, newflags;
5262 + oldflags = vap->va_xflags;
5263 + newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
5264 + XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
5265 + if (flags & ATTR_FLAG_IMMUTABLE)
5266 + newflags |= XFS_XFLAG_IMMUTABLE;
5267 + if (flags & ATTR_FLAG_IUNLINK)
5268 + newflags |= XFS_XFLAG_IUNLINK;
5269 + if (flags & ATTR_FLAG_BARRIER)
5270 + newflags |= XFS_XFLAG_BARRIER;
5272 + if (oldflags ^ newflags)
5273 + vap->va_xflags = newflags;
5279 struct dentry *dentry,
5281 @@ -545,6 +567,11 @@ linvfs_setattr(
5282 flags |= ATTR_NONBLOCK;
5285 + if (ia_valid & ATTR_ATTR_FLAG) {
5286 + vattr.va_mask |= XFS_AT_XFLAGS;
5287 + linvfs_setattr_flags(&vattr, attr->ia_attr_flags);
5290 VOP_SETATTR(vp, &vattr, flags, NULL, error);
5293 diff -NurpP --minimal linux-2.6.10/fs/xfs/linux-2.6/xfs_super.c linux-2.6.10-vs1.9.3.17/fs/xfs/linux-2.6/xfs_super.c
5294 --- linux-2.6.10/fs/xfs/linux-2.6/xfs_super.c 2004-12-25 01:55:22.000000000 +0100
5295 +++ linux-2.6.10-vs1.9.3.17/fs/xfs/linux-2.6/xfs_super.c 2004-12-26 19:40:31.000000000 +0100
5296 @@ -192,6 +192,14 @@ xfs_revalidate_inode(
5297 inode->i_flags |= S_IMMUTABLE;
5299 inode->i_flags &= ~S_IMMUTABLE;
5300 + if (ip->i_d.di_flags & XFS_DIFLAG_IUNLINK)
5301 + inode->i_flags |= S_IUNLINK;
5303 + inode->i_flags &= ~S_IUNLINK;
5304 + if (ip->i_d.di_flags & XFS_DIFLAG_BARRIER)
5305 + inode->i_flags |= S_BARRIER;
5307 + inode->i_flags &= ~S_BARRIER;
5308 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
5309 inode->i_flags |= S_APPEND;
5311 diff -NurpP --minimal linux-2.6.10/fs/xfs/linux-2.6/xfs_vnode.c linux-2.6.10-vs1.9.3.17/fs/xfs/linux-2.6/xfs_vnode.c
5312 --- linux-2.6.10/fs/xfs/linux-2.6/xfs_vnode.c 2004-10-23 05:06:18.000000000 +0200
5313 +++ linux-2.6.10-vs1.9.3.17/fs/xfs/linux-2.6/xfs_vnode.c 2004-12-26 19:40:31.000000000 +0100
5314 @@ -212,6 +212,14 @@ vn_revalidate_core(
5315 inode->i_flags |= S_IMMUTABLE;
5317 inode->i_flags &= ~S_IMMUTABLE;
5318 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
5319 + inode->i_flags |= S_IUNLINK;
5321 + inode->i_flags &= ~S_IUNLINK;
5322 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
5323 + inode->i_flags |= S_BARRIER;
5325 + inode->i_flags &= ~S_BARRIER;
5326 if (vap->va_xflags & XFS_XFLAG_APPEND)
5327 inode->i_flags |= S_APPEND;
5329 diff -NurpP --minimal linux-2.6.10/fs/xfs/xfs_dinode.h linux-2.6.10-vs1.9.3.17/fs/xfs/xfs_dinode.h
5330 --- linux-2.6.10/fs/xfs/xfs_dinode.h 2004-10-23 05:06:18.000000000 +0200
5331 +++ linux-2.6.10-vs1.9.3.17/fs/xfs/xfs_dinode.h 2004-12-26 19:40:31.000000000 +0100
5332 @@ -459,6 +459,9 @@ xfs_dinode_t *xfs_buf_to_dinode(struct x
5333 #define XFS_DIFLAG_RTINHERIT_BIT 8 /* create with realtime bit set */
5334 #define XFS_DIFLAG_PROJINHERIT_BIT 9 /* create with parents projid */
5335 #define XFS_DIFLAG_NOSYMLINKS_BIT 10 /* disallow symlink creation */
5336 +#define XFS_DIFLAG_BARRIER_BIT 12 /* chroot() barrier */
5337 +#define XFS_DIFLAG_IUNLINK_BIT 13 /* immutable unlink */
5339 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
5340 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
5341 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
5342 @@ -470,6 +473,9 @@ xfs_dinode_t *xfs_buf_to_dinode(struct x
5343 #define XFS_DIFLAG_RTINHERIT (1 << XFS_DIFLAG_RTINHERIT_BIT)
5344 #define XFS_DIFLAG_PROJINHERIT (1 << XFS_DIFLAG_PROJINHERIT_BIT)
5345 #define XFS_DIFLAG_NOSYMLINKS (1 << XFS_DIFLAG_NOSYMLINKS_BIT)
5346 +#define XFS_DIFLAG_BARRIER (1 << XFS_DIFLAG_BARRIER_BIT)
5347 +#define XFS_DIFLAG_IUNLINK (1 << XFS_DIFLAG_IUNLINK_BIT)
5350 #define XFS_DIFLAG_ANY \
5351 (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
5352 diff -NurpP --minimal linux-2.6.10/fs/xfs/xfs_fs.h linux-2.6.10-vs1.9.3.17/fs/xfs/xfs_fs.h
5353 --- linux-2.6.10/fs/xfs/xfs_fs.h 2004-10-23 05:06:18.000000000 +0200
5354 +++ linux-2.6.10-vs1.9.3.17/fs/xfs/xfs_fs.h 2004-12-26 19:40:31.000000000 +0100
5355 @@ -79,6 +79,8 @@ struct fsxattr {
5356 #define XFS_XFLAG_RTINHERIT 0x00000100 /* create with rt bit set */
5357 #define XFS_XFLAG_PROJINHERIT 0x00000200 /* create with parents projid */
5358 #define XFS_XFLAG_NOSYMLINKS 0x00000400 /* disallow symlink creation */
5359 +#define XFS_XFLAG_BARRIER 0x00004000 /* chroot() barrier */
5360 +#define XFS_XFLAG_IUNLINK 0x00008000 /* immutable unlink */
5361 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
5364 diff -NurpP --minimal linux-2.6.10/fs/xfs/xfs_vnodeops.c linux-2.6.10-vs1.9.3.17/fs/xfs/xfs_vnodeops.c
5365 --- linux-2.6.10/fs/xfs/xfs_vnodeops.c 2004-10-23 05:06:19.000000000 +0200
5366 +++ linux-2.6.10-vs1.9.3.17/fs/xfs/xfs_vnodeops.c 2004-12-26 19:40:31.000000000 +0100
5367 @@ -832,6 +832,10 @@ xfs_setattr(
5368 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
5369 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
5370 di_flags |= XFS_DIFLAG_IMMUTABLE;
5371 + if (vap->va_xflags & XFS_XFLAG_IUNLINK)
5372 + di_flags |= XFS_DIFLAG_IUNLINK;
5373 + if (vap->va_xflags & XFS_XFLAG_BARRIER)
5374 + di_flags |= XFS_DIFLAG_BARRIER;
5375 if (vap->va_xflags & XFS_XFLAG_APPEND)
5376 di_flags |= XFS_DIFLAG_APPEND;
5377 if (vap->va_xflags & XFS_XFLAG_SYNC)
5378 diff -NurpP --minimal linux-2.6.10/include/asm-alpha/unistd.h linux-2.6.10-vs1.9.3.17/include/asm-alpha/unistd.h
5379 --- linux-2.6.10/include/asm-alpha/unistd.h 2004-10-23 05:06:19.000000000 +0200
5380 +++ linux-2.6.10-vs1.9.3.17/include/asm-alpha/unistd.h 2004-12-26 19:40:24.000000000 +0100
5382 #define __NR_osf_memcntl 260 /* not implemented */
5383 #define __NR_osf_fdatasync 261 /* not implemented */
5385 +#define __NR_vserver 273
5388 * Linux-specific system calls begin at 300
5389 diff -NurpP --minimal linux-2.6.10/include/asm-arm/tlb.h linux-2.6.10-vs1.9.3.17/include/asm-arm/tlb.h
5390 --- linux-2.6.10/include/asm-arm/tlb.h 2004-08-14 12:54:47.000000000 +0200
5391 +++ linux-2.6.10-vs1.9.3.17/include/asm-arm/tlb.h 2004-12-26 19:40:35.000000000 +0100
5392 @@ -58,7 +58,8 @@ tlb_finish_mmu(struct mmu_gather *tlb, u
5396 - mm->rss = rss - freed;
5397 + // mm->rss = rss - freed;
5398 + vx_rsspages_sub(mm, freed);
5402 diff -NurpP --minimal linux-2.6.10/include/asm-arm26/tlb.h linux-2.6.10-vs1.9.3.17/include/asm-arm26/tlb.h
5403 --- linux-2.6.10/include/asm-arm26/tlb.h 2004-08-14 12:56:23.000000000 +0200
5404 +++ linux-2.6.10-vs1.9.3.17/include/asm-arm26/tlb.h 2004-12-26 19:40:35.000000000 +0100
5405 @@ -39,7 +39,8 @@ tlb_finish_mmu(struct mmu_gather *tlb, u
5409 - mm->rss = rss - freed;
5410 + // mm->rss = rss - freed;
5411 + vx_rsspages_sub(mm, freed);
5415 diff -NurpP --minimal linux-2.6.10/include/asm-generic/tlb.h linux-2.6.10-vs1.9.3.17/include/asm-generic/tlb.h
5416 --- linux-2.6.10/include/asm-generic/tlb.h 2004-08-14 12:54:46.000000000 +0200
5417 +++ linux-2.6.10-vs1.9.3.17/include/asm-generic/tlb.h 2004-12-26 19:40:35.000000000 +0100
5420 #include <linux/config.h>
5421 #include <linux/swap.h>
5422 +#include <linux/vs_memory.h>
5423 #include <asm/pgalloc.h>
5424 #include <asm/tlbflush.h>
5426 @@ -92,7 +93,8 @@ tlb_finish_mmu(struct mmu_gather *tlb, u
5430 - mm->rss = rss - freed;
5431 + // mm->rss = rss - freed;
5432 + vx_rsspages_sub(mm, freed);
5433 tlb_flush_mmu(tlb, start, end);
5435 /* keep the page table cache within bounds */
5436 diff -NurpP --minimal linux-2.6.10/include/asm-i386/elf.h linux-2.6.10-vs1.9.3.17/include/asm-i386/elf.h
5437 --- linux-2.6.10/include/asm-i386/elf.h 2004-10-23 05:06:20.000000000 +0200
5438 +++ linux-2.6.10-vs1.9.3.17/include/asm-i386/elf.h 2004-12-26 19:40:36.000000000 +0100
5439 @@ -70,7 +70,7 @@ typedef struct user_fxsr_struct elf_fpxr
5440 the loader. We need to make sure that it is out of the way of the program
5441 that it will "exec", and that there is sufficient room for the brk. */
5443 -#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5444 +#define ELF_ET_DYN_BASE ((TASK_UNMAPPED_BASE) * 2)
5446 /* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
5447 now struct_user_regs, they are different) */
5448 diff -NurpP --minimal linux-2.6.10/include/asm-i386/page.h linux-2.6.10-vs1.9.3.17/include/asm-i386/page.h
5449 --- linux-2.6.10/include/asm-i386/page.h 2004-12-25 01:55:23.000000000 +0100
5450 +++ linux-2.6.10-vs1.9.3.17/include/asm-i386/page.h 2004-12-26 19:40:36.000000000 +0100
5451 @@ -120,16 +120,23 @@ extern int sysctl_legacy_va_layout;
5453 #endif /* __ASSEMBLY__ */
5455 -#ifdef __ASSEMBLY__
5456 +#if defined(CONFIG_SPLIT_3GB)
5457 #define __PAGE_OFFSET (0xC0000000)
5459 -#define __PAGE_OFFSET (0xC0000000UL)
5460 +#elif defined(CONFIG_SPLIT_25GB)
5461 +#define __PAGE_OFFSET (0xA0000000)
5462 +#elif defined(CONFIG_SPLIT_2GB)
5463 +#define __PAGE_OFFSET (0x80000000)
5464 +#elif defined(CONFIG_SPLIT_15GB)
5465 +#define __PAGE_OFFSET (0x60000000)
5466 +#elif defined(CONFIG_SPLIT_1GB)
5467 +#define __PAGE_OFFSET (0x40000000)
5471 #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
5472 #define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
5473 -#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE)
5474 +#define __MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE)
5475 +#define MAXMEM ((unsigned long)(-PAGE_OFFSET-VMALLOC_RESERVE))
5477 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
5478 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
5479 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
5480 diff -NurpP --minimal linux-2.6.10/include/asm-i386/param.h linux-2.6.10-vs1.9.3.17/include/asm-i386/param.h
5481 --- linux-2.6.10/include/asm-i386/param.h 2004-08-14 12:54:51.000000000 +0200
5482 +++ linux-2.6.10-vs1.9.3.17/include/asm-i386/param.h 2004-12-26 19:40:36.000000000 +0100
5484 #ifndef _ASMi386_PARAM_H
5485 #define _ASMi386_PARAM_H
5487 +#include <linux/config.h>
5490 -# define HZ 1000 /* Internal kernel timer frequency */
5491 +# ifdef CONFIG_KERNEL_HZ
5492 +# define HZ CONFIG_KERNEL_HZ
5494 +# define HZ 1000 /* Internal kernel timer frequency */
5496 # define USER_HZ 100 /* .. some user interfaces are in "ticks" */
5497 # define CLOCKS_PER_SEC (USER_HZ) /* like times() */
5499 diff -NurpP --minimal linux-2.6.10/include/asm-i386/processor.h linux-2.6.10-vs1.9.3.17/include/asm-i386/processor.h
5500 --- linux-2.6.10/include/asm-i386/processor.h 2004-12-25 01:55:23.000000000 +0100
5501 +++ linux-2.6.10-vs1.9.3.17/include/asm-i386/processor.h 2004-12-26 19:40:36.000000000 +0100
5502 @@ -289,9 +289,10 @@ extern unsigned int BIOS_revision;
5503 extern unsigned int mca_pentium_flag;
5506 - * User space process size: 3GB (default).
5507 + * User space process size: (3GB default).
5509 -#define TASK_SIZE (PAGE_OFFSET)
5510 +#define __TASK_SIZE (__PAGE_OFFSET)
5511 +#define TASK_SIZE ((unsigned long)__TASK_SIZE)
5513 /* This decides where the kernel will search for a free chunk of vm
5514 * space during mmap's.
5515 diff -NurpP --minimal linux-2.6.10/include/asm-ia64/tlb.h linux-2.6.10-vs1.9.3.17/include/asm-ia64/tlb.h
5516 --- linux-2.6.10/include/asm-ia64/tlb.h 2004-10-23 05:06:20.000000000 +0200
5517 +++ linux-2.6.10-vs1.9.3.17/include/asm-ia64/tlb.h 2004-12-26 19:40:35.000000000 +0100
5519 #include <linux/mm.h>
5520 #include <linux/pagemap.h>
5521 #include <linux/swap.h>
5522 +#include <linux/vs_memory.h>
5524 #include <asm/pgalloc.h>
5525 #include <asm/processor.h>
5526 @@ -165,7 +166,8 @@ tlb_finish_mmu (struct mmu_gather *tlb,
5530 - mm->rss = rss - freed;
5531 + // mm->rss = rss - freed;
5532 + vx_rsspages_sub(mm, freed);
5534 * Note: tlb->nr may be 0 at this point, so we can't rely on tlb->start_addr and
5536 diff -NurpP --minimal linux-2.6.10/include/asm-parisc/unistd.h linux-2.6.10-vs1.9.3.17/include/asm-parisc/unistd.h
5537 --- linux-2.6.10/include/asm-parisc/unistd.h 2004-12-25 01:55:25.000000000 +0100
5538 +++ linux-2.6.10-vs1.9.3.17/include/asm-parisc/unistd.h 2004-12-26 19:40:24.000000000 +0100
5540 #define __NR_get_mempolicy (__NR_Linux + 261)
5541 #define __NR_set_mempolicy (__NR_Linux + 262)
5543 -#define __NR_Linux_syscalls 263
5544 +#define __NR_vserver (__NR_Linux + 273)
5546 +#define __NR_Linux_syscalls 273
5548 #define HPUX_GATEWAY_ADDR 0xC0000004
5549 #define LINUX_GATEWAY_ADDR 0x100
5550 diff -NurpP --minimal linux-2.6.10/include/asm-ppc/unistd.h linux-2.6.10-vs1.9.3.17/include/asm-ppc/unistd.h
5551 --- linux-2.6.10/include/asm-ppc/unistd.h 2004-12-25 01:55:25.000000000 +0100
5552 +++ linux-2.6.10-vs1.9.3.17/include/asm-ppc/unistd.h 2004-12-26 19:40:24.000000000 +0100
5554 #define __NR_fadvise64_64 254
5555 #define __NR_rtas 255
5556 /* Number 256 is reserved for sys_debug_setcontext */
5557 -/* Number 257 is reserved for vserver */
5558 +#define __NR_vserver 257
5559 /* Number 258 is reserved for new sys_remap_file_pages */
5560 /* Number 259 is reserved for new sys_mbind */
5561 /* Number 260 is reserved for new sys_get_mempolicy */
5562 diff -NurpP --minimal linux-2.6.10/include/asm-ppc64/unistd.h linux-2.6.10-vs1.9.3.17/include/asm-ppc64/unistd.h
5563 --- linux-2.6.10/include/asm-ppc64/unistd.h 2004-12-25 01:55:25.000000000 +0100
5564 +++ linux-2.6.10-vs1.9.3.17/include/asm-ppc64/unistd.h 2004-12-26 19:40:24.000000000 +0100
5566 /* #define __NR_fadvise64_64 254 32bit only */
5567 #define __NR_rtas 255
5568 /* Number 256 is reserved for sys_debug_setcontext */
5569 -/* Number 257 is reserved for vserver */
5570 +#define __NR_vserver 257
5571 /* Number 258 is reserved for new sys_remap_file_pages */
5572 #define __NR_mbind 259
5573 #define __NR_get_mempolicy 260
5574 diff -NurpP --minimal linux-2.6.10/include/asm-s390/unistd.h linux-2.6.10-vs1.9.3.17/include/asm-s390/unistd.h
5575 --- linux-2.6.10/include/asm-s390/unistd.h 2004-12-25 01:55:25.000000000 +0100
5576 +++ linux-2.6.10-vs1.9.3.17/include/asm-s390/unistd.h 2004-12-26 19:40:24.000000000 +0100
5578 #define __NR_clock_gettime (__NR_timer_create+6)
5579 #define __NR_clock_getres (__NR_timer_create+7)
5580 #define __NR_clock_nanosleep (__NR_timer_create+8)
5581 -/* Number 263 is reserved for vserver */
5582 +#define __NR_vserver 263
5583 #define __NR_fadvise64_64 264
5584 #define __NR_statfs64 265
5585 #define __NR_fstatfs64 266
5586 diff -NurpP --minimal linux-2.6.10/include/asm-sparc/unistd.h linux-2.6.10-vs1.9.3.17/include/asm-sparc/unistd.h
5587 --- linux-2.6.10/include/asm-sparc/unistd.h 2004-12-25 01:55:26.000000000 +0100
5588 +++ linux-2.6.10-vs1.9.3.17/include/asm-sparc/unistd.h 2004-12-26 19:40:24.000000000 +0100
5590 #define __NR_timer_getoverrun 264
5591 #define __NR_timer_delete 265
5592 #define __NR_timer_create 266
5593 -/* #define __NR_vserver 267 Reserved for VSERVER */
5594 +#define __NR_vserver 267
5595 #define __NR_io_setup 268
5596 #define __NR_io_destroy 269
5597 #define __NR_io_submit 270
5598 diff -NurpP --minimal linux-2.6.10/include/asm-sparc64/tlb.h linux-2.6.10-vs1.9.3.17/include/asm-sparc64/tlb.h
5599 --- linux-2.6.10/include/asm-sparc64/tlb.h 2004-08-14 12:55:48.000000000 +0200
5600 +++ linux-2.6.10-vs1.9.3.17/include/asm-sparc64/tlb.h 2004-12-26 19:40:35.000000000 +0100
5603 #include <linux/config.h>
5604 #include <linux/swap.h>
5605 +#include <linux/vs_memory.h>
5607 #include <asm/pgalloc.h>
5608 #include <asm/tlbflush.h>
5609 #include <asm/mmu_context.h>
5610 @@ -84,7 +86,8 @@ static inline void tlb_finish_mmu(struct
5614 - mm->rss = rss - freed;
5615 + // mm->rss = rss - freed;
5616 + vx_rsspages_sub(mm, freed);
5620 diff -NurpP --minimal linux-2.6.10/include/asm-sparc64/unistd.h linux-2.6.10-vs1.9.3.17/include/asm-sparc64/unistd.h
5621 --- linux-2.6.10/include/asm-sparc64/unistd.h 2004-12-25 01:55:26.000000000 +0100
5622 +++ linux-2.6.10-vs1.9.3.17/include/asm-sparc64/unistd.h 2004-12-26 19:40:24.000000000 +0100
5624 #define __NR_timer_getoverrun 264
5625 #define __NR_timer_delete 265
5626 #define __NR_timer_create 266
5627 -/* #define __NR_vserver 267 Reserved for VSERVER */
5628 +#define __NR_vserver 267
5629 #define __NR_io_setup 268
5630 #define __NR_io_destroy 269
5631 #define __NR_io_submit 270
5632 diff -NurpP --minimal linux-2.6.10/include/asm-x86_64/unistd.h linux-2.6.10-vs1.9.3.17/include/asm-x86_64/unistd.h
5633 --- linux-2.6.10/include/asm-x86_64/unistd.h 2004-10-23 05:06:22.000000000 +0200
5634 +++ linux-2.6.10-vs1.9.3.17/include/asm-x86_64/unistd.h 2004-12-26 19:40:24.000000000 +0100
5635 @@ -531,9 +531,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
5636 #define __NR_utimes 235
5637 __SYSCALL(__NR_utimes, sys_utimes)
5638 #define __NR_vserver 236
5639 -__SYSCALL(__NR_vserver, sys_ni_syscall)
5640 -#define __NR_vserver 236
5641 -__SYSCALL(__NR_vserver, sys_ni_syscall)
5642 +__SYSCALL(__NR_vserver, sys_vserver)
5643 #define __NR_mbind 237
5644 __SYSCALL(__NR_mbind, sys_mbind)
5645 #define __NR_set_mempolicy 238
5646 diff -NurpP --minimal linux-2.6.10/include/linux/capability.h linux-2.6.10-vs1.9.3.17/include/linux/capability.h
5647 --- linux-2.6.10/include/linux/capability.h 2004-08-14 12:55:09.000000000 +0200
5648 +++ linux-2.6.10-vs1.9.3.17/include/linux/capability.h 2004-12-26 19:40:23.000000000 +0100
5649 @@ -235,6 +235,7 @@ typedef __u32 kernel_cap_t;
5650 /* Allow enabling/disabling tagged queuing on SCSI controllers and sending
5651 arbitrary SCSI commands */
5652 /* Allow setting encryption key on loopback filesystem */
5653 +/* Allow the selection of a security context */
5655 #define CAP_SYS_ADMIN 21
5657 @@ -284,6 +285,11 @@ typedef __u32 kernel_cap_t;
5659 #define CAP_LEASE 28
5661 +/* Allow context manipulations */
5662 +/* Allow changing context info on files */
5664 +#define CAP_CONTEXT 29
5669 diff -NurpP --minimal linux-2.6.10/include/linux/cyclades.h linux-2.6.10-vs1.9.3.17/include/linux/cyclades.h
5670 --- linux-2.6.10/include/linux/cyclades.h 2004-10-23 05:06:22.000000000 +0200
5671 +++ linux-2.6.10-vs1.9.3.17/include/linux/cyclades.h 2004-12-26 19:40:36.000000000 +0100
5672 @@ -624,7 +624,11 @@ struct cyclades_port {
5673 #define Cy_EVENT_DELTA_WAKEUP 6
5674 #define Cy_EVENT_Z_RX_FULL 7
5677 #define CLOSING_WAIT_DELAY 30*HZ
5679 +#define CLOSING_WAIT_DELAY 65534
5681 #define CY_CLOSING_WAIT_NONE 65535
5682 #define CY_CLOSING_WAIT_INF 0
5684 diff -NurpP --minimal linux-2.6.10/include/linux/devpts_fs.h linux-2.6.10-vs1.9.3.17/include/linux/devpts_fs.h
5685 --- linux-2.6.10/include/linux/devpts_fs.h 2004-08-14 12:55:59.000000000 +0200
5686 +++ linux-2.6.10-vs1.9.3.17/include/linux/devpts_fs.h 2004-12-26 19:40:30.000000000 +0100
5687 @@ -30,5 +30,7 @@ static inline void devpts_pty_kill(int n
5691 +#define DEVPTS_SUPER_MAGIC 0x1cd1
5694 #endif /* _LINUX_DEVPTS_FS_H */
5695 diff -NurpP --minimal linux-2.6.10/include/linux/dtlk.h linux-2.6.10-vs1.9.3.17/include/linux/dtlk.h
5696 --- linux-2.6.10/include/linux/dtlk.h 2004-08-14 12:56:01.000000000 +0200
5697 +++ linux-2.6.10-vs1.9.3.17/include/linux/dtlk.h 2004-12-26 19:40:36.000000000 +0100
5700 #define DTLK_CLEAR 0x18 /* stops speech */
5702 -#define DTLK_MAX_RETRIES (loops_per_jiffy/(10000/HZ))
5703 +#define DTLK_MAX_RETRIES (HZ*(loops_per_jiffy >> 3)/1250)
5705 /* TTS Port Status Flags */
5706 #define TTS_READABLE 0x80 /* mask for bit which is nonzero if a
5707 diff -NurpP --minimal linux-2.6.10/include/linux/ext2_fs.h linux-2.6.10-vs1.9.3.17/include/linux/ext2_fs.h
5708 --- linux-2.6.10/include/linux/ext2_fs.h 2004-10-23 05:06:22.000000000 +0200
5709 +++ linux-2.6.10-vs1.9.3.17/include/linux/ext2_fs.h 2004-12-26 19:40:34.000000000 +0100
5710 @@ -192,10 +192,17 @@ struct ext2_group_desc
5711 #define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */
5712 #define EXT2_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
5713 #define EXT2_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
5714 +#define EXT2_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5715 +#define EXT2_IUNLINK_FL 0x08000000 /* Immutable unlink */
5716 #define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
5718 +#ifdef CONFIG_VSERVER_LEGACY
5719 +#define EXT2_FL_USER_VISIBLE 0x0803DFFF /* User visible flags */
5720 +#define EXT2_FL_USER_MODIFIABLE 0x080380FF /* User modifiable flags */
5722 #define EXT2_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
5723 #define EXT2_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
5728 @@ -240,7 +247,7 @@ struct ext2_inode {
5730 __u8 l_i_frag; /* Fragment number */
5731 __u8 l_i_fsize; /* Fragment size */
5733 + __u16 l_i_xid; /* LRU Context */
5734 __le16 l_i_uid_high; /* these 2 fields */
5735 __le16 l_i_gid_high; /* were reserved2[0] */
5736 __u32 l_i_reserved2;
5737 @@ -272,6 +279,7 @@ struct ext2_inode {
5738 #define i_gid_low i_gid
5739 #define i_uid_high osd2.linux2.l_i_uid_high
5740 #define i_gid_high osd2.linux2.l_i_gid_high
5741 +#define i_raw_xid osd2.linux2.l_i_xid
5742 #define i_reserved2 osd2.linux2.l_i_reserved2
5745 @@ -312,6 +320,7 @@ struct ext2_inode {
5746 #define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */
5747 #define EXT2_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
5748 #define EXT2_MOUNT_POSIX_ACL 0x8000 /* POSIX Access Control Lists */
5749 +#define EXT2_MOUNT_TAG_XID (1<<24) /* Enable Context Tags */
5751 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
5752 #define set_opt(o, opt) o |= EXT2_MOUNT_##opt
5753 diff -NurpP --minimal linux-2.6.10/include/linux/ext3_fs.h linux-2.6.10-vs1.9.3.17/include/linux/ext3_fs.h
5754 --- linux-2.6.10/include/linux/ext3_fs.h 2004-12-25 01:55:29.000000000 +0100
5755 +++ linux-2.6.10-vs1.9.3.17/include/linux/ext3_fs.h 2004-12-26 19:40:34.000000000 +0100
5756 @@ -185,10 +185,20 @@ struct ext3_group_desc
5757 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
5758 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
5759 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
5760 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5761 +#define EXT3_IUNLINK_FL 0x08000000 /* Immutable unlink */
5762 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
5764 +#ifdef CONFIG_VSERVER_LEGACY
5765 +#define EXT3_FL_USER_VISIBLE 0x0803DFFF /* User visible flags */
5766 +#define EXT3_FL_USER_MODIFIABLE 0x080380FF /* User modifiable flags */
5768 #define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
5769 #define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
5771 +#ifdef CONFIG_VSERVER_LEGACY
5772 +#define EXT3_IOC_SETXID FIOC_SETXIDJ
5776 * Inode dynamic state flags
5777 @@ -273,7 +283,7 @@ struct ext3_inode {
5779 __u8 l_i_frag; /* Fragment number */
5780 __u8 l_i_fsize; /* Fragment size */
5782 + __u16 l_i_xid; /* LRU Context */
5783 __le16 l_i_uid_high; /* these 2 fields */
5784 __le16 l_i_gid_high; /* were reserved2[0] */
5785 __u32 l_i_reserved2;
5786 @@ -305,6 +315,7 @@ struct ext3_inode {
5787 #define i_gid_low i_gid
5788 #define i_uid_high osd2.linux2.l_i_uid_high
5789 #define i_gid_high osd2.linux2.l_i_gid_high
5790 +#define i_raw_xid osd2.linux2.l_i_xid
5791 #define i_reserved2 osd2.linux2.l_i_reserved2
5793 #elif defined(__GNU__)
5794 @@ -355,6 +366,7 @@ struct ext3_inode {
5795 #define EXT3_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
5796 #define EXT3_MOUNT_RESERVATION 0x10000 /* Preallocation */
5797 #define EXT3_MOUNT_BARRIER 0x20000 /* Use block barriers */
5798 +#define EXT3_MOUNT_TAG_XID (1<<24) /* Enable Context Tags */
5800 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
5801 #ifndef _LINUX_EXT2_FS_H
5802 diff -NurpP --minimal linux-2.6.10/include/linux/fs.h linux-2.6.10-vs1.9.3.17/include/linux/fs.h
5803 --- linux-2.6.10/include/linux/fs.h 2004-12-25 01:55:29.000000000 +0100
5804 +++ linux-2.6.10-vs1.9.3.17/include/linux/fs.h 2004-12-26 19:40:34.000000000 +0100
5805 @@ -124,6 +124,8 @@ extern int dir_notify_enable;
5806 #define MS_VERBOSE 32768
5807 #define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
5808 #define MS_ONE_SECOND (1<<17) /* fs has 1 sec a/m/ctime resolution */
5809 +#define MS_TAGXID (1<<24) /* tag inodes with context information */
5810 +#define MS_XID (1<<25) /* use specific xid for this mount */
5811 #define MS_ACTIVE (1<<30)
5812 #define MS_NOUSER (1<<31)
5814 @@ -150,6 +152,8 @@ extern int dir_notify_enable;
5815 #define S_DIRSYNC 64 /* Directory modifications are synchronous */
5816 #define S_NOCMTIME 128 /* Do not update file c/mtime */
5817 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
5818 +#define S_BARRIER 1024 /* Barrier for chroot() */
5819 +#define S_IUNLINK 2048 /* Immutable unlink */
5822 * Note that nosuid etc flags are inode-specific: setting some file-system
5823 @@ -176,11 +180,14 @@ extern int dir_notify_enable;
5824 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
5825 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
5826 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
5827 +#define IS_IUNLINK(inode) ((inode)->i_flags & S_IUNLINK)
5828 +#define IS_IXORUNLINK(inode) ((IS_IUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
5829 #define IS_NOATIME(inode) (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
5830 #define IS_NODIRATIME(inode) __IS_FLG(inode, MS_NODIRATIME)
5831 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
5832 #define IS_ONE_SECOND(inode) __IS_FLG(inode, MS_ONE_SECOND)
5834 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_flags & S_BARRIER))
5835 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
5836 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
5837 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
5838 @@ -262,6 +269,7 @@ typedef void (dio_iodone_t)(struct inode
5839 #define ATTR_ATTR_FLAG 1024
5840 #define ATTR_KILL_SUID 2048
5841 #define ATTR_KILL_SGID 4096
5842 +#define ATTR_XID 8192
5845 * This is the Inode Attributes structure, used for notify_change(). It
5846 @@ -277,6 +285,7 @@ struct iattr {
5852 struct timespec ia_atime;
5853 struct timespec ia_mtime;
5854 @@ -293,6 +302,9 @@ struct iattr {
5855 #define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */
5856 #define ATTR_FLAG_NODIRATIME 16 /* Don't update atime for directory */
5858 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
5859 +#define ATTR_FLAG_IUNLINK 1024 /* Immutable unlink */
5862 * Includes for diskquotas.
5864 @@ -436,6 +448,7 @@ struct inode {
5865 unsigned int i_nlink;
5871 struct timespec i_atime;
5872 @@ -588,6 +601,8 @@ struct file {
5873 unsigned int f_uid, f_gid;
5874 struct file_ra_state f_ra;
5878 unsigned long f_version;
5881 --- linux-2.6.10/include/linux/init_task.h.orig 2005-01-06 11:59:13.000000000 +0100
5882 +++ linux-2.6.10/include/linux/init_task.h 2005-01-06 12:06:32.000000000 +0100
5883 @@ -114,6 +114,10 @@
5884 .journal_info = NULL, \
5885 .private_pages = LIST_HEAD_INIT(tsk.private_pages), \
5886 .private_pages_count = 0, \
5888 + .vx_info = NULL, \
5890 + .nx_info = NULL, \
5894 diff -NurpP --minimal linux-2.6.10/include/linux/ip.h linux-2.6.10-vs1.9.3.17/include/linux/ip.h
5895 --- linux-2.6.10/include/linux/ip.h 2004-08-14 12:55:09.000000000 +0200
5896 +++ linux-2.6.10-vs1.9.3.17/include/linux/ip.h 2004-12-26 19:40:29.000000000 +0100
5897 @@ -111,6 +111,7 @@ struct inet_opt {
5898 /* Socket demultiplex comparisons on incoming packets. */
5899 __u32 daddr; /* Foreign IPv4 addr */
5900 __u32 rcv_saddr; /* Bound local IPv4 addr */
5901 + __u32 rcv_saddr2; /* Second bound ipv4 addr, for ipv4root */
5902 __u16 dport; /* Destination port */
5903 __u16 num; /* Local port */
5904 __u32 saddr; /* Sending source */
5905 diff -NurpP --minimal linux-2.6.10/include/linux/ipc.h linux-2.6.10-vs1.9.3.17/include/linux/ipc.h
5906 --- linux-2.6.10/include/linux/ipc.h 2004-08-14 12:54:46.000000000 +0200
5907 +++ linux-2.6.10-vs1.9.3.17/include/linux/ipc.h 2004-12-26 19:40:29.000000000 +0100
5908 @@ -66,6 +66,7 @@ struct kern_ipc_perm
5915 #endif /* __KERNEL__ */
5916 diff -NurpP --minimal linux-2.6.10/include/linux/jiffies.h linux-2.6.10-vs1.9.3.17/include/linux/jiffies.h
5917 --- linux-2.6.10/include/linux/jiffies.h 2004-12-25 01:55:29.000000000 +0100
5918 +++ linux-2.6.10-vs1.9.3.17/include/linux/jiffies.h 2004-12-26 19:40:36.000000000 +0100
5921 #elif HZ >= 768 && HZ < 1536
5922 # define SHIFT_HZ 10
5923 +#elif HZ >= 1536 && HZ < 3072
5924 +# define SHIFT_HZ 11
5925 +#elif HZ >= 3072 && HZ < 6144
5926 +# define SHIFT_HZ 12
5927 +#elif HZ >= 6144 && HZ < 12288
5928 +# define SHIFT_HZ 13
5929 +#elif HZ >= 12288 && HZ < 24576
5930 +# define SHIFT_HZ 14
5934 diff -NurpP --minimal linux-2.6.10/include/linux/mount.h linux-2.6.10-vs1.9.3.17/include/linux/mount.h
5935 --- linux-2.6.10/include/linux/mount.h 2004-12-25 01:55:29.000000000 +0100
5936 +++ linux-2.6.10-vs1.9.3.17/include/linux/mount.h 2004-12-26 19:40:34.000000000 +0100
5938 #define MNT_NOSUID 1
5940 #define MNT_NOEXEC 4
5941 +#define MNT_XID 256
5945 @@ -36,6 +37,7 @@ struct vfsmount
5946 struct list_head mnt_list;
5947 struct list_head mnt_fslink; /* link in fs-specific expiry list */
5948 struct namespace *mnt_namespace; /* containing namespace */
5949 + xid_t mnt_xid; /* xid tagging used for vfsmount */
5952 static inline struct vfsmount *mntget(struct vfsmount *mnt)
5953 diff -NurpP --minimal linux-2.6.10/include/linux/namespace.h linux-2.6.10-vs1.9.3.17/include/linux/namespace.h
5954 --- linux-2.6.10/include/linux/namespace.h 2004-08-14 12:55:33.000000000 +0200
5955 +++ linux-2.6.10-vs1.9.3.17/include/linux/namespace.h 2004-12-26 19:40:29.000000000 +0100
5956 @@ -13,6 +13,7 @@ struct namespace {
5959 extern void umount_tree(struct vfsmount *);
5960 +extern void umount_unused(struct vfsmount *, struct fs_struct *);
5961 extern int copy_namespace(int, struct task_struct *);
5962 extern void __put_namespace(struct namespace *namespace);
5964 diff -NurpP --minimal linux-2.6.10/include/linux/net.h linux-2.6.10-vs1.9.3.17/include/linux/net.h
5965 --- linux-2.6.10/include/linux/net.h 2004-12-25 01:55:29.000000000 +0100
5966 +++ linux-2.6.10-vs1.9.3.17/include/linux/net.h 2004-12-26 19:40:29.000000000 +0100
5967 @@ -61,6 +61,8 @@ typedef enum {
5968 #define SOCK_ASYNC_NOSPACE 0
5969 #define SOCK_ASYNC_WAITDATA 1
5970 #define SOCK_NOSPACE 2
5971 +#define SOCK_PASS_CRED 16
5972 +#define SOCK_USER_SOCKET 17
5974 #ifndef ARCH_HAS_SOCKET_TYPES
5975 /** sock_type - Socket types
5976 @@ -111,7 +113,6 @@ struct socket {
5978 wait_queue_head_t wait;
5980 - unsigned char passcred;
5983 struct vm_area_struct;
5984 diff -NurpP --minimal linux-2.6.10/include/linux/nfs_mount.h linux-2.6.10-vs1.9.3.17/include/linux/nfs_mount.h
5985 --- linux-2.6.10/include/linux/nfs_mount.h 2004-08-14 12:54:47.000000000 +0200
5986 +++ linux-2.6.10-vs1.9.3.17/include/linux/nfs_mount.h 2004-12-26 19:40:34.000000000 +0100
5987 @@ -60,6 +60,7 @@ struct nfs_mount_data {
5988 #define NFS_MOUNT_BROKEN_SUID 0x0400 /* 4 */
5989 #define NFS_MOUNT_STRICTLOCK 0x1000 /* reserved for NFSv4 */
5990 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
5991 +#define NFS_MOUNT_TAGXID 0x8000 /* tagxid */
5992 #define NFS_MOUNT_FLAGMASK 0xFFFF
5995 diff -NurpP --minimal linux-2.6.10/include/linux/proc_fs.h linux-2.6.10-vs1.9.3.17/include/linux/proc_fs.h
5996 --- linux-2.6.10/include/linux/proc_fs.h 2004-12-25 01:55:29.000000000 +0100
5997 +++ linux-2.6.10-vs1.9.3.17/include/linux/proc_fs.h 2004-12-26 19:40:24.000000000 +0100
5998 @@ -55,6 +55,7 @@ struct proc_dir_entry {
6004 struct inode_operations * proc_iops;
6005 struct file_operations * proc_fops;
6006 @@ -243,9 +244,11 @@ extern struct kcore_list *kclist_del(voi
6008 struct task_struct *task;
6012 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
6013 int (*proc_read)(struct task_struct *task, char *page);
6014 + int (*proc_vid_read)(int vid, char *page);
6016 struct proc_dir_entry *pde;
6017 struct inode vfs_inode;
6018 diff -NurpP --minimal linux-2.6.10/include/linux/ptrace.h linux-2.6.10-vs1.9.3.17/include/linux/ptrace.h
6019 --- linux-2.6.10/include/linux/ptrace.h 2004-12-25 01:55:29.000000000 +0100
6020 +++ linux-2.6.10-vs1.9.3.17/include/linux/ptrace.h 2004-12-26 19:40:14.000000000 +0100
6023 #include <linux/compiler.h> /* For unlikely. */
6024 #include <linux/sched.h> /* For struct task_struct. */
6025 +#include <linux/vs_cvirt.h>
6026 +#include <linux/vs_context.h>
6028 extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);
6029 extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len);
6030 diff -NurpP --minimal linux-2.6.10/include/linux/reiserfs_fs.h linux-2.6.10-vs1.9.3.17/include/linux/reiserfs_fs.h
6031 --- linux-2.6.10/include/linux/reiserfs_fs.h 2004-12-25 01:55:29.000000000 +0100
6032 +++ linux-2.6.10-vs1.9.3.17/include/linux/reiserfs_fs.h 2004-12-26 19:40:31.000000000 +0100
6033 @@ -889,6 +889,18 @@ struct stat_data_v1
6034 #define REISERFS_COMPR_FL EXT2_COMPR_FL
6035 #define REISERFS_NOTAIL_FL EXT2_NOTAIL_FL
6037 +/* unfortunately reiserfs sdattr is only 16 bit */
6038 +#define REISERFS_BARRIER_FL (EXT2_BARRIER_FL >> 16)
6039 +#define REISERFS_IUNLINK_FL (EXT2_IUNLINK_FL >> 16)
6041 +#ifdef CONFIG_VSERVER_LEGACY
6042 +#define REISERFS_FL_USER_VISIBLE (REISERFS_IUNLINK_FL|0x80FF)
6043 +#define REISERFS_FL_USER_MODIFYABLE (REISERFS_IUNLINK_FL|0x80FF)
6045 +#define REISERFS_FL_USER_VISIBLE 0x80FF
6046 +#define REISERFS_FL_USER_MODIFYABLE 0x80FF
6049 /* persistent flags that file inherits from the parent directory */
6050 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
6051 REISERFS_SYNC_FL | \
6052 diff -NurpP --minimal linux-2.6.10/include/linux/reiserfs_fs_sb.h linux-2.6.10-vs1.9.3.17/include/linux/reiserfs_fs_sb.h
6053 --- linux-2.6.10/include/linux/reiserfs_fs_sb.h 2004-12-25 01:55:29.000000000 +0100
6054 +++ linux-2.6.10-vs1.9.3.17/include/linux/reiserfs_fs_sb.h 2004-12-26 19:40:34.000000000 +0100
6055 @@ -457,6 +457,7 @@ enum reiserfs_mount_options {
6057 REISERFS_BARRIER_NONE,
6058 REISERFS_BARRIER_FLUSH,
6061 /* Actions on error */
6062 REISERFS_ERROR_PANIC,
6063 diff -NurpP --minimal linux-2.6.10/include/linux/sched.h linux-2.6.10-vs1.9.3.17/include/linux/sched.h
6064 --- linux-2.6.10/include/linux/sched.h 2004-12-25 01:55:29.000000000 +0100
6065 +++ linux-2.6.10-vs1.9.3.17/include/linux/sched.h 2004-12-26 19:40:35.000000000 +0100
6067 #include <linux/pid.h>
6068 #include <linux/percpu.h>
6069 #include <linux/topology.h>
6070 +#include <linux/vs_base.h>
6074 @@ -110,6 +111,7 @@ extern unsigned long nr_iowait(void);
6075 #define TASK_TRACED 8
6076 #define EXIT_ZOMBIE 16
6077 #define EXIT_DEAD 32
6078 +#define TASK_ONHOLD 64
6080 #define __set_task_state(tsk, state_value) \
6081 do { (tsk)->state = (state_value); } while (0)
6082 @@ -236,6 +238,7 @@ struct mm_struct {
6084 /* Architecture-specific MM context */
6085 mm_context_t context;
6086 + struct vx_info *mm_vx_info;
6088 /* Token based thrashing protection. */
6089 unsigned long swap_token_time;
6090 @@ -365,9 +368,10 @@ struct user_struct {
6091 /* Hash table maintenance information */
6092 struct list_head uidhash_list;
6097 -extern struct user_struct *find_user(uid_t);
6098 +extern struct user_struct *find_user(xid_t, uid_t);
6100 extern struct user_struct root_user;
6101 #define INIT_USER (&root_user)
6102 @@ -630,6 +634,14 @@ struct task_struct {
6104 struct audit_context *audit_context;
6106 +/* vserver context data */
6108 + struct vx_info *vx_info;
6110 +/* vserver network data */
6112 + struct nx_info *nx_info;
6114 /* Thread group tracking */
6117 @@ -768,13 +780,19 @@ extern struct task_struct init_task;
6119 extern struct mm_struct init_mm;
6121 -#define find_task_by_pid(nr) find_task_by_pid_type(PIDTYPE_PID, nr)
6123 +#define find_task_by_real_pid(nr) \
6124 + find_task_by_pid_type(PIDTYPE_PID, nr)
6125 +#define find_task_by_pid(nr) \
6126 + find_task_by_pid_type(PIDTYPE_PID, \
6129 extern struct task_struct *find_task_by_pid_type(int type, int pid);
6130 extern void set_special_pids(pid_t session, pid_t pgrp);
6131 extern void __set_special_pids(pid_t session, pid_t pgrp);
6133 /* per-UID process charging. */
6134 -extern struct user_struct * alloc_uid(uid_t);
6135 +extern struct user_struct * alloc_uid(xid_t, uid_t);
6136 static inline struct user_struct *get_uid(struct user_struct *u)
6138 atomic_inc(&u->__count);
6139 @@ -867,15 +885,28 @@ static inline int sas_ss_flags(unsigned
6140 #ifdef CONFIG_SECURITY
6141 /* code is in security.c */
6142 extern int capable(int cap);
6143 +extern int vx_capable(int cap, int ccap);
6145 static inline int capable(int cap)
6147 + if (vx_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
6149 if (cap_raised(current->cap_effective, cap)) {
6150 current->flags |= PF_SUPERPRIV;
6156 +static inline int vx_capable(int cap, int ccap)
6158 + if (cap_raised(current->cap_effective, cap) &&
6160 + current->flags |= PF_SUPERPRIV;
6168 diff -NurpP --minimal linux-2.6.10/include/linux/shmem_fs.h linux-2.6.10-vs1.9.3.17/include/linux/shmem_fs.h
6169 --- linux-2.6.10/include/linux/shmem_fs.h 2004-10-23 05:06:23.000000000 +0200
6170 +++ linux-2.6.10-vs1.9.3.17/include/linux/shmem_fs.h 2004-12-26 19:40:30.000000000 +0100
6173 #define SHMEM_NR_DIRECT 16
6175 +#define TMPFS_SUPER_MAGIC 0x01021994
6178 struct shmem_inode_info {
6180 unsigned long flags;
6181 diff -NurpP --minimal linux-2.6.10/include/linux/stat.h linux-2.6.10-vs1.9.3.17/include/linux/stat.h
6182 --- linux-2.6.10/include/linux/stat.h 2004-08-14 12:55:10.000000000 +0200
6183 +++ linux-2.6.10-vs1.9.3.17/include/linux/stat.h 2004-12-26 19:40:34.000000000 +0100
6184 @@ -63,6 +63,7 @@ struct kstat {
6191 struct timespec atime;
6192 diff -NurpP --minimal linux-2.6.10/include/linux/sunrpc/auth.h linux-2.6.10-vs1.9.3.17/include/linux/sunrpc/auth.h
6193 --- linux-2.6.10/include/linux/sunrpc/auth.h 2004-08-14 12:55:33.000000000 +0200
6194 +++ linux-2.6.10-vs1.9.3.17/include/linux/sunrpc/auth.h 2004-12-26 19:40:34.000000000 +0100
6200 struct group_info *group_info;
6203 diff -NurpP --minimal linux-2.6.10/include/linux/sunrpc/clnt.h linux-2.6.10-vs1.9.3.17/include/linux/sunrpc/clnt.h
6204 --- linux-2.6.10/include/linux/sunrpc/clnt.h 2004-08-14 12:55:34.000000000 +0200
6205 +++ linux-2.6.10-vs1.9.3.17/include/linux/sunrpc/clnt.h 2004-12-26 19:40:34.000000000 +0100
6206 @@ -53,7 +53,8 @@ struct rpc_clnt {
6207 cl_autobind : 1,/* use getport() */
6208 cl_droppriv : 1,/* enable NFS suid hack */
6209 cl_oneshot : 1,/* dispose after use */
6210 - cl_dead : 1;/* abandoned */
6211 + cl_dead : 1,/* abandoned */
6212 + cl_tagxid : 1;/* do xid tagging */
6214 struct rpc_rtt * cl_rtt; /* RTO estimator data */
6215 struct rpc_portmap * cl_pmap; /* port mapping */
6216 --- linux-2.6.10/include/linux/sysctl.h.orig 2005-01-06 11:59:10.000000000 +0100
6217 +++ linux-2.6.10/include/linux/sysctl.h 2005-01-06 12:05:55.000000000 +0100
6219 KERN_HZ_TIMER=65, /* int: hz timer on or off */
6220 KERN_UNKNOWN_NMI_PANIC=66, /* int: unknown nmi panic flag */
6221 KERN_FBSPLASH=67, /* string: path to fbsplash helper */
6222 + KERN_VSHELPER=68, /* string: path to vshelper policy agent */
6226 diff -NurpP --minimal linux-2.6.10/include/linux/sysfs.h linux-2.6.10-vs1.9.3.17/include/linux/sysfs.h
6227 --- linux-2.6.10/include/linux/sysfs.h 2004-12-25 01:55:30.000000000 +0100
6228 +++ linux-2.6.10-vs1.9.3.17/include/linux/sysfs.h 2004-12-26 19:40:30.000000000 +0100
6231 #include <asm/atomic.h>
6233 +#define SYSFS_SUPER_MAGIC 0x62656572
6238 diff -NurpP --minimal linux-2.6.10/include/linux/types.h linux-2.6.10-vs1.9.3.17/include/linux/types.h
6239 --- linux-2.6.10/include/linux/types.h 2004-12-25 01:55:30.000000000 +0100
6240 +++ linux-2.6.10-vs1.9.3.17/include/linux/types.h 2004-12-26 19:40:23.000000000 +0100
6241 @@ -36,6 +36,8 @@ typedef __kernel_uid32_t uid_t;
6242 typedef __kernel_gid32_t gid_t;
6243 typedef __kernel_uid16_t uid16_t;
6244 typedef __kernel_gid16_t gid16_t;
6245 +typedef unsigned int xid_t;
6246 +typedef unsigned int nid_t;
6249 /* This is defined by include/asm-{arch}/posix_types.h */
6250 diff -NurpP --minimal linux-2.6.10/include/linux/vs_base.h linux-2.6.10-vs1.9.3.17/include/linux/vs_base.h
6251 --- linux-2.6.10/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
6252 +++ linux-2.6.10-vs1.9.3.17/include/linux/vs_base.h 2004-12-26 19:40:21.000000000 +0100
6254 +#ifndef _VX_VS_BASE_H
6255 +#define _VX_VS_BASE_H
6258 +#include "vserver/context.h"
6261 +#define vx_task_xid(t) ((t)->xid)
6263 +#define vx_current_xid() vx_task_xid(current)
6265 +#define vx_check(c,m) __vx_check(vx_current_xid(),c,m)
6267 +#define vx_weak_check(c,m) ((m) ? vx_check(c,m) : 1)
6271 + * check current context for ADMIN/WATCH and
6272 + * optionally agains supplied argument
6274 +static inline int __vx_check(xid_t cid, xid_t id, unsigned int mode)
6276 + if (mode & VX_ARG_MASK) {
6277 + if ((mode & VX_IDENT) &&
6281 + if (mode & VX_ATR_MASK) {
6282 + if ((mode & VX_DYNAMIC) &&
6283 + (id >= MIN_D_CONTEXT) &&
6284 + (id <= MAX_S_CONTEXT))
6286 + if ((mode & VX_STATIC) &&
6287 + (id > 1) && (id < MIN_D_CONTEXT))
6290 + return (((mode & VX_ADMIN) && (cid == 0)) ||
6291 + ((mode & VX_WATCH) && (cid == 1)) ||
6292 + ((mode & VX_HOSTID) && (id == 0)));
6296 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
6298 +#define vx_info_state(v,m) (__vx_state(v) & (m))
6301 +/* generic flag merging */
6303 +#define vx_check_flags(v,m,f) (((v) & (m)) ^ (f))
6305 +#define vx_mask_flags(v,f,m) (((v) & ~(m)) | ((f) & (m)))
6307 +#define vx_mask_mask(v,f,m) (((v) & ~(m)) | ((v) & (f) & (m)))
6309 +#define vx_check_bit(v,n) ((v) & (1LL << (n)))
6312 +/* context flags */
6314 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
6316 +#define vx_current_flags() __vx_flags(current->vx_info)
6318 +#define vx_info_flags(v,m,f) \
6319 + vx_check_flags(__vx_flags(v),(m),(f))
6321 +#define task_vx_flags(t,m,f) \
6322 + ((t) && vx_info_flags((t)->vx_info, (m), (f)))
6324 +#define vx_flags(m,f) vx_info_flags(current->vx_info,(m),(f))
6329 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
6331 +#define vx_current_ccaps() __vx_ccaps(current->vx_info)
6333 +#define vx_info_ccaps(v,c) (__vx_ccaps(v) & (c))
6335 +#define vx_ccaps(c) vx_info_ccaps(current->vx_info,(c))
6338 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
6340 +#define vx_info_mcaps(v,c) (__vx_mcaps(v) & (c))
6342 +#define vx_mcaps(c) vx_info_mcaps(current->vx_info,(c))
6345 +#define vx_current_bcaps() \
6346 + (((current->vx_info) && !vx_flags(VXF_STATE_SETUP, 0)) ? \
6347 + current->vx_info->vx_bcaps : cap_bset)
6350 +#define vx_current_initpid(n) \
6351 + (current->vx_info && \
6352 + (current->vx_info->vx_initpid == (n)))
6356 +#warning duplicate inclusion
6358 diff -NurpP --minimal linux-2.6.10/include/linux/vs_context.h linux-2.6.10-vs1.9.3.17/include/linux/vs_context.h
6359 --- linux-2.6.10/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
6360 +++ linux-2.6.10-vs1.9.3.17/include/linux/vs_context.h 2005-01-03 01:34:47.000000000 +0100
6362 +#ifndef _VX_VS_CONTEXT_H
6363 +#define _VX_VS_CONTEXT_H
6366 +#include <linux/kernel.h>
6367 +#include "vserver/debug.h"
6370 +#define get_vx_info(i) __get_vx_info(i,__FILE__,__LINE__)
6372 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
6373 + const char *_file, int _line)
6378 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
6379 + vxi, vxi?vxi->vx_id:0, vxi?atomic_read(&vxi->vx_usecnt):0,
6381 + vxh_get_vx_info(vxi);
6383 + atomic_inc(&vxi->vx_usecnt);
6387 +#define put_vx_info(i) __put_vx_info(i,__FILE__,__LINE__)
6389 +static inline void __put_vx_info(struct vx_info *vxi, const char *_file, int _line)
6394 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
6395 + vxi, vxi?vxi->vx_id:0, vxi?atomic_read(&vxi->vx_usecnt):0,
6397 + vxh_put_vx_info(vxi);
6399 + if (atomic_dec_and_test(&vxi->vx_usecnt))
6400 + free_vx_info(vxi);
6403 +#define set_vx_info(p,i) __set_vx_info(p,i,__FILE__,__LINE__)
6405 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
6406 + const char *_file, int _line)
6408 + struct vx_info *vxo;
6413 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d.%d])",
6414 + vxi, vxi?vxi->vx_id:0,
6415 + vxi?atomic_read(&vxi->vx_usecnt):0,
6416 + vxi?atomic_read(&vxi->vx_refcnt):0,
6418 + vxh_set_vx_info(vxi, vxp);
6420 + atomic_inc(&vxi->vx_refcnt);
6421 + vxo = xchg(vxp, __get_vx_info(vxi, _file, _line));
6425 +#define clr_vx_info(p) __clr_vx_info(p,__FILE__,__LINE__)
6427 +static inline void __clr_vx_info(struct vx_info **vxp,
6428 + const char *_file, int _line)
6430 + struct vx_info *vxo;
6432 + vxo = xchg(vxp, NULL);
6436 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d.%d])",
6437 + vxo, vxo?vxo->vx_id:0,
6438 + vxo?atomic_read(&vxo->vx_usecnt):0,
6439 + vxo?atomic_read(&vxo->vx_refcnt):0,
6441 + vxh_clr_vx_info(vxo, vxp);
6443 + if (atomic_dec_and_test(&vxo->vx_refcnt))
6444 + unhash_vx_info(vxo);
6445 + __put_vx_info(vxo, _file, _line);
6449 +#define task_get_vx_info(p) __task_get_vx_info(p,__FILE__,__LINE__)
6451 +static __inline__ struct vx_info *__task_get_vx_info(struct task_struct *p,
6452 + const char *_file, int _line)
6454 + struct vx_info *vxi;
6457 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
6459 + vxi = __get_vx_info(p->vx_info, _file, _line);
6465 +#define vx_verify_info(p,i) \
6466 + __vx_verify_info((p)->vx_info,i,__FILE__,__LINE__)
6468 +static __inline__ void __vx_verify_info(
6469 + struct vx_info *vxa, struct vx_info *vxb,
6470 + const char *_file, int _line)
6474 + printk(KERN_ERR "vx bad assumption (%p==%p) at %s:%d\n",
6475 + vxa, vxb, _file, _line);
6480 +#warning duplicate inclusion
6482 diff -NurpP --minimal linux-2.6.10/include/linux/vs_cvirt.h linux-2.6.10-vs1.9.3.17/include/linux/vs_cvirt.h
6483 --- linux-2.6.10/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
6484 +++ linux-2.6.10-vs1.9.3.17/include/linux/vs_cvirt.h 2004-12-26 19:40:21.000000000 +0100
6486 +#ifndef _VX_VS_CVIRT_H
6487 +#define _VX_VS_CVIRT_H
6490 +#include "vserver/cvirt.h"
6491 +#include "vserver/debug.h"
6494 +/* utsname virtualization */
6496 +static inline struct new_utsname *vx_new_utsname(void)
6498 + if (current->vx_info)
6499 + return ¤t->vx_info->cvirt.utsname;
6500 + return &system_utsname;
6503 +#define vx_new_uts(x) ((vx_new_utsname())->x)
6506 +/* pid faking stuff */
6509 +#define vx_info_map_pid(v,p) \
6510 + __vx_info_map_pid((v), (p), __FUNC__, __FILE__, __LINE__)
6511 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
6512 +#define vx_map_pid(p) vx_info_map_pid(current->vx_info, p)
6513 +#define vx_map_tgid(p) vx_map_pid(p)
6515 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
6516 + const char *func, const char *file, int line)
6518 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
6519 + vxfprintk(VXD_CBIT(cvirt, 2),
6520 + "vx_map_tgid: %p/%llx: %d -> %d",
6521 + vxi, (long long)vxi->vx_flags, pid,
6522 + (pid && pid == vxi->vx_initpid)?1:pid,
6523 + func, file, line);
6526 + if (pid == vxi->vx_initpid)
6532 +#define vx_info_rmap_pid(v,p) \
6533 + __vx_info_rmap_pid((v), (p), __FUNC__, __FILE__, __LINE__)
6534 +#define vx_rmap_pid(p) vx_info_rmap_pid(current->vx_info, p)
6535 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
6537 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
6538 + const char *func, const char *file, int line)
6540 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
6541 + vxfprintk(VXD_CBIT(cvirt, 2),
6542 + "vx_rmap_tgid: %p/%llx: %d -> %d",
6543 + vxi, (long long)vxi->vx_flags, pid,
6544 + (pid == 1)?vxi->vx_initpid:pid,
6545 + func, file, line);
6546 + if ((pid == 1) && vxi->vx_initpid)
6547 + return vxi->vx_initpid;
6548 + if (pid == vxi->vx_initpid)
6555 +static inline void vx_activate_task(struct task_struct *p)
6557 + struct vx_info *vxi;
6559 + if ((vxi = p->vx_info)) {
6560 + vx_update_load(vxi);
6561 + atomic_inc(&vxi->cvirt.nr_running);
6565 +static inline void vx_deactivate_task(struct task_struct *p)
6567 + struct vx_info *vxi;
6569 + if ((vxi = p->vx_info)) {
6570 + vx_update_load(vxi);
6571 + atomic_dec(&vxi->cvirt.nr_running);
6575 +static inline void vx_uninterruptible_inc(struct task_struct *p)
6577 + struct vx_info *vxi;
6579 + if ((vxi = p->vx_info))
6580 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
6583 +static inline void vx_uninterruptible_dec(struct task_struct *p)
6585 + struct vx_info *vxi;
6587 + if ((vxi = p->vx_info))
6588 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
6593 +#warning duplicate inclusion
6595 diff -NurpP --minimal linux-2.6.10/include/linux/vs_dlimit.h linux-2.6.10-vs1.9.3.17/include/linux/vs_dlimit.h
6596 --- linux-2.6.10/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
6597 +++ linux-2.6.10-vs1.9.3.17/include/linux/vs_dlimit.h 2004-12-26 19:40:21.000000000 +0100
6599 +#ifndef _VX_VS_DLIMIT_H
6600 +#define _VX_VS_DLIMIT_H
6603 +#include "vserver/dlimit.h"
6604 +#include "vserver/debug.h"
6607 +#define get_dl_info(i) __get_dl_info(i,__FILE__,__LINE__)
6609 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
6610 + const char *_file, int _line)
6614 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
6615 + dli, dli?dli->dl_xid:0, dli?atomic_read(&dli->dl_usecnt):0,
6617 + atomic_inc(&dli->dl_usecnt);
6622 +#define free_dl_info(i) \
6623 + call_rcu(&i->dl_rcu, rcu_free_dl_info);
6625 +#define put_dl_info(i) __put_dl_info(i,__FILE__,__LINE__)
6627 +static inline void __put_dl_info(struct dl_info *dli,
6628 + const char *_file, int _line)
6632 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
6633 + dli, dli?dli->dl_xid:0, dli?atomic_read(&dli->dl_usecnt):0,
6635 + if (atomic_dec_and_test(&dli->dl_usecnt))
6636 + free_dl_info(dli);
6640 +#define __dlimit_char(d) ((d)?'*':' ')
6642 +static inline int __dl_alloc_space(struct super_block *sb,
6643 + xid_t xid, dlsize_t nr, const char *file, int line)
6645 + struct dl_info *dli = NULL;
6650 + dli = locate_dl_info(sb, xid);
6654 + spin_lock(&dli->dl_lock);
6655 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
6657 + dli->dl_space_used += nr;
6658 + spin_unlock(&dli->dl_lock);
6661 + vxlprintk(VXD_CBIT(dlim, 1),
6662 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
6663 + sb, xid, __dlimit_char(dli), (long long)nr,
6668 +static inline void __dl_free_space(struct super_block *sb,
6669 + xid_t xid, dlsize_t nr, const char *_file, int _line)
6671 + struct dl_info *dli = NULL;
6675 + dli = locate_dl_info(sb, xid);
6679 + spin_lock(&dli->dl_lock);
6680 + if (dli->dl_space_used > nr)
6681 + dli->dl_space_used -= nr;
6683 + dli->dl_space_used = 0;
6684 + spin_unlock(&dli->dl_lock);
6687 + vxlprintk(VXD_CBIT(dlim, 1),
6688 + "FREE (%p,#%d)%c %lld bytes",
6689 + sb, xid, __dlimit_char(dli), (long long)nr,
6693 +static inline int __dl_alloc_inode(struct super_block *sb,
6694 + xid_t xid, const char *_file, int _line)
6696 + struct dl_info *dli;
6699 + dli = locate_dl_info(sb, xid);
6703 + spin_lock(&dli->dl_lock);
6704 + ret = (dli->dl_inodes_used >= dli->dl_inodes_total);
6706 + dli->dl_inodes_used++;
6709 + vxwprintk("DLIMIT hit (%p,#%d), inode %d>=%d @ %s:%d",
6711 + dli->dl_inodes_used, dli->dl_inodes_total,
6714 + spin_unlock(&dli->dl_lock);
6717 + vxlprintk(VXD_CBIT(dlim, 0),
6718 + "ALLOC (%p,#%d)%c inode (%d)",
6719 + sb, xid, __dlimit_char(dli), ret, _file, _line);
6723 +static inline void __dl_free_inode(struct super_block *sb,
6724 + xid_t xid, const char *_file, int _line)
6726 + struct dl_info *dli;
6728 + dli = locate_dl_info(sb, xid);
6732 + spin_lock(&dli->dl_lock);
6733 + if (dli->dl_inodes_used > 1)
6734 + dli->dl_inodes_used--;
6736 + dli->dl_inodes_used = 0;
6737 + spin_unlock(&dli->dl_lock);
6740 + vxlprintk(VXD_CBIT(dlim, 0),
6741 + "FREE (%p,#%d)%c inode",
6742 + sb, xid, __dlimit_char(dli), _file, _line);
6745 +static inline void __dl_adjust_block(struct super_block *sb, xid_t xid,
6746 + unsigned int *free_blocks, unsigned int *root_blocks,
6747 + const char *_file, int _line)
6749 + struct dl_info *dli;
6750 + uint64_t broot, bfree;
6752 + dli = locate_dl_info(sb, xid);
6756 + spin_lock(&dli->dl_lock);
6757 + broot = (dli->dl_space_total -
6758 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
6759 + >> sb->s_blocksize_bits;
6760 + bfree = (dli->dl_space_total - dli->dl_space_used)
6761 + >> sb->s_blocksize_bits;
6762 + spin_unlock(&dli->dl_lock);
6764 + vxlprintk(VXD_CBIT(dlim, 2),
6765 + "ADJUST: %lld,%lld on %d,%d [mult=%d]",
6766 + (long long)bfree, (long long)broot,
6767 + *free_blocks, *root_blocks, dli->dl_nrlmult,
6769 + if (free_blocks) {
6770 + if (*free_blocks > bfree)
6771 + *free_blocks = bfree;
6773 + if (root_blocks) {
6774 + if (*root_blocks > broot)
6775 + *root_blocks = broot;
6781 +#define DLIMIT_ALLOC_BLOCK(sb, xid, nr) \
6782 + __dl_alloc_space(sb, xid, \
6783 + ((dlsize_t)(nr)) << (sb)->s_blocksize_bits, \
6784 + __FILE__, __LINE__ )
6786 +#define DLIMIT_FREE_BLOCK(sb, xid, nr) \
6787 + __dl_free_space(sb, xid, \
6788 + ((dlsize_t)(nr)) << (sb)->s_blocksize_bits, \
6789 + __FILE__, __LINE__ )
6791 +#define DLIMIT_ALLOC_INODE(sb, xid) \
6792 + __dl_alloc_inode(sb, xid, __FILE__, __LINE__ )
6794 +#define DLIMIT_FREE_INODE(sb, xid) \
6795 + __dl_free_inode(sb, xid, __FILE__, __LINE__ )
6798 +#define DLIMIT_ADJUST_BLOCK(sb, xid, fb, rb) \
6799 + __dl_adjust_block(sb, xid, fb, rb, __FILE__, __LINE__ )
6803 +#warning duplicate inclusion
6805 diff -NurpP --minimal linux-2.6.10/include/linux/vs_limit.h linux-2.6.10-vs1.9.3.17/include/linux/vs_limit.h
6806 --- linux-2.6.10/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
6807 +++ linux-2.6.10-vs1.9.3.17/include/linux/vs_limit.h 2004-12-26 19:40:21.000000000 +0100
6809 +#ifndef _VX_VS_LIMIT_H
6810 +#define _VX_VS_LIMIT_H
6813 +#include "vserver/limit.h"
6814 +#include "vserver/debug.h"
6820 +static inline void __vx_acc_cres(struct vx_info *vxi,
6821 + int res, int dir, void *_data, char *_file, int _line)
6823 + if (VXD_RLIMIT(res, RLIMIT_NOFILE) ||
6824 + VXD_RLIMIT(res, RLIMIT_NPROC) ||
6825 + VXD_RLIMIT(res, VLIMIT_NSOCK))
6826 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5d%s (%p)",
6827 + (vxi?vxi->vx_id:-1), vlimit_name[res], res,
6828 + (vxi?atomic_read(&vxi->limit.rcur[res]):0),
6829 + (dir>0)?"++":"--", _data, _file, _line);
6832 + atomic_inc(&vxi->limit.rcur[res]);
6834 + atomic_dec(&vxi->limit.rcur[res]);
6838 +#define vx_acc_cres(v,d,p,r) \
6839 + __vx_acc_cres((v), (r), (d), (p), __FILE__, __LINE__)
6841 +#define vx_acc_cres_cond(x,d,p,r) \
6842 + __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0,\
6843 + (r), (d), (p), __FILE__, __LINE__)
6845 +#define vx_nproc_inc(p) \
6846 + vx_acc_cres((p)->vx_info, 1, (p), RLIMIT_NPROC)
6848 +#define vx_nproc_dec(p) \
6849 + vx_acc_cres((p)->vx_info,-1, (p), RLIMIT_NPROC)
6851 +#define vx_files_inc(f) \
6852 + vx_acc_cres_cond((f)->f_xid, 1, (f), RLIMIT_NOFILE)
6854 +#define vx_files_dec(f) \
6855 + vx_acc_cres_cond((f)->f_xid,-1, (f), RLIMIT_NOFILE)
6858 +#define vx_cres_avail(v,n,r) \
6859 + __vx_cres_avail((v), (r), (n), __FILE__, __LINE__)
6861 +static inline int __vx_cres_avail(struct vx_info *vxi,
6862 + int res, int num, char *_file, int _line)
6864 + unsigned long value;
6866 + if (VXD_RLIMIT(res, RLIMIT_NOFILE) ||
6867 + VXD_RLIMIT(res, RLIMIT_NPROC) ||
6868 + VXD_RLIMIT(res, VLIMIT_NSOCK))
6869 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d",
6870 + (vxi?vxi->vx_id:-1), vlimit_name[res], res,
6871 + (vxi?vxi->limit.rlim[res]:1),
6872 + (vxi?atomic_read(&vxi->limit.rcur[res]):0),
6873 + num, _file, _line);
6876 + value = atomic_read(&vxi->limit.rcur[res]);
6877 + if (value > vxi->limit.rmax[res])
6878 + vxi->limit.rmax[res] = value;
6879 + if (vxi->limit.rlim[res] == RLIM_INFINITY)
6881 + if (value + num <= vxi->limit.rlim[res])
6883 + atomic_inc(&vxi->limit.lhit[res]);
6887 +#define vx_nproc_avail(n) \
6888 + vx_cres_avail(current->vx_info, (n), RLIMIT_NPROC)
6890 +#define vx_files_avail(n) \
6891 + vx_cres_avail(current->vx_info, (n), RLIMIT_NOFILE)
6894 +/* socket limits */
6896 +#define vx_sock_inc(s) \
6897 + vx_acc_cres((s)->sk_vx_info, 1, (s), VLIMIT_NSOCK)
6898 +#define vx_sock_dec(s) \
6899 + vx_acc_cres((s)->sk_vx_info,-1, (s), VLIMIT_NSOCK)
6901 +#define vx_sock_avail(n) \
6902 + vx_cres_avail(current->vx_info, (n), VLIMIT_NSOCK)
6905 +#warning duplicate inclusion
6907 diff -NurpP --minimal linux-2.6.10/include/linux/vs_memory.h linux-2.6.10-vs1.9.3.17/include/linux/vs_memory.h
6908 --- linux-2.6.10/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
6909 +++ linux-2.6.10-vs1.9.3.17/include/linux/vs_memory.h 2004-12-26 19:40:21.000000000 +0100
6911 +#ifndef _VX_VS_MEMORY_H
6912 +#define _VX_VS_MEMORY_H
6915 +#include "vserver/limit.h"
6916 +#include "vserver/debug.h"
6919 +#define vx_acc_page(m, d, v, r) \
6920 + __vx_acc_page(&(m->v), m->mm_vx_info, r, d, __FILE__, __LINE__)
6922 +static inline void __vx_acc_page(unsigned long *v, struct vx_info *vxi,
6923 + int res, int dir, char *file, int line)
6925 + if (VXD_RLIMIT(res, RLIMIT_RSS) ||
6926 + VXD_RLIMIT(res, RLIMIT_AS) ||
6927 + VXD_RLIMIT(res, RLIMIT_MEMLOCK))
6928 + vxlprintk(1, "vx_acc_page[%5d,%s,%2d]: %5d%s",
6929 + (vxi?vxi->vx_id:-1), vlimit_name[res], res,
6930 + (vxi?atomic_read(&vxi->limit.rcur[res]):0),
6931 + (dir?"++":"--"), file, line);
6940 + atomic_inc(&vxi->limit.rcur[res]);
6942 + atomic_dec(&vxi->limit.rcur[res]);
6947 +#define vx_acc_pages(m, p, v, r) \
6948 + __vx_acc_pages(&(m->v), m->mm_vx_info, r, p, __FILE__, __LINE__)
6950 +static inline void __vx_acc_pages(unsigned long *v, struct vx_info *vxi,
6951 + int res, int pages, char *_file, int _line)
6953 + if (VXD_RLIMIT(res, RLIMIT_RSS) ||
6954 + VXD_RLIMIT(res, RLIMIT_AS) ||
6955 + VXD_RLIMIT(res, RLIMIT_MEMLOCK))
6956 + vxlprintk(1, "vx_acc_pages[%5d,%s,%2d]: %5d += %5d",
6957 + (vxi?vxi->vx_id:-1), vlimit_name[res], res,
6958 + (vxi?atomic_read(&vxi->limit.rcur[res]):0),
6959 + pages, _file, _line);
6965 + atomic_add(pages, &vxi->limit.rcur[res]);
6970 +#define vx_acc_vmpage(m,d) vx_acc_page(m, d, total_vm, RLIMIT_AS)
6971 +#define vx_acc_vmlpage(m,d) vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
6972 +#define vx_acc_rsspage(m,d) vx_acc_page(m, d, rss, RLIMIT_RSS)
6974 +#define vx_acc_vmpages(m,p) vx_acc_pages(m, p, total_vm, RLIMIT_AS)
6975 +#define vx_acc_vmlpages(m,p) vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
6976 +#define vx_acc_rsspages(m,p) vx_acc_pages(m, p, rss, RLIMIT_RSS)
6978 +#define vx_pages_add(s,r,p) __vx_acc_pages(0, s, r, p, __FILE__, __LINE__)
6979 +#define vx_pages_sub(s,r,p) vx_pages_add(s, r, -(p))
6981 +#define vx_vmpages_inc(m) vx_acc_vmpage(m, 1)
6982 +#define vx_vmpages_dec(m) vx_acc_vmpage(m,-1)
6983 +#define vx_vmpages_add(m,p) vx_acc_vmpages(m, p)
6984 +#define vx_vmpages_sub(m,p) vx_acc_vmpages(m,-(p))
6986 +#define vx_vmlocked_inc(m) vx_acc_vmlpage(m, 1)
6987 +#define vx_vmlocked_dec(m) vx_acc_vmlpage(m,-1)
6988 +#define vx_vmlocked_add(m,p) vx_acc_vmlpages(m, p)
6989 +#define vx_vmlocked_sub(m,p) vx_acc_vmlpages(m,-(p))
6991 +#define vx_rsspages_inc(m) vx_acc_rsspage(m, 1)
6992 +#define vx_rsspages_dec(m) vx_acc_rsspage(m,-1)
6993 +#define vx_rsspages_add(m,p) vx_acc_rsspages(m, p)
6994 +#define vx_rsspages_sub(m,p) vx_acc_rsspages(m,-(p))
6998 +#define vx_pages_avail(m, p, r) \
6999 + __vx_pages_avail((m)->mm_vx_info, (r), (p), __FILE__, __LINE__)
7001 +static inline int __vx_pages_avail(struct vx_info *vxi,
7002 + int res, int pages, char *_file, int _line)
7004 + unsigned long value;
7006 + if (VXD_RLIMIT(res, RLIMIT_RSS) ||
7007 + VXD_RLIMIT(res, RLIMIT_AS) ||
7008 + VXD_RLIMIT(res, RLIMIT_MEMLOCK))
7009 + vxlprintk(1, "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d",
7010 + (vxi?vxi->vx_id:-1), vlimit_name[res], res,
7011 + (vxi?vxi->limit.rlim[res]:1),
7012 + (vxi?atomic_read(&vxi->limit.rcur[res]):0),
7013 + pages, _file, _line);
7016 + value = atomic_read(&vxi->limit.rcur[res]);
7017 + if (value > vxi->limit.rmax[res])
7018 + vxi->limit.rmax[res] = value;
7019 + if (vxi->limit.rlim[res] == RLIM_INFINITY)
7021 + if (value + pages <= vxi->limit.rlim[res])
7023 + atomic_inc(&vxi->limit.lhit[res]);
7027 +#define vx_vmpages_avail(m,p) vx_pages_avail(m, p, RLIMIT_AS)
7028 +#define vx_vmlocked_avail(m,p) vx_pages_avail(m, p, RLIMIT_MEMLOCK)
7029 +#define vx_rsspages_avail(m,p) vx_pages_avail(m, p, RLIMIT_RSS)
7032 +#warning duplicate inclusion
7034 diff -NurpP --minimal linux-2.6.10/include/linux/vs_network.h linux-2.6.10-vs1.9.3.17/include/linux/vs_network.h
7035 --- linux-2.6.10/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
7036 +++ linux-2.6.10-vs1.9.3.17/include/linux/vs_network.h 2005-01-03 01:24:39.000000000 +0100
7038 +#ifndef _NX_VS_NETWORK_H
7039 +#define _NX_VS_NETWORK_H
7042 +#include "vserver/network.h"
7043 +#include "vserver/debug.h"
7046 +#define get_nx_info(i) __get_nx_info(i,__FILE__,__LINE__)
7048 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
7049 + const char *_file, int _line)
7053 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
7054 + nxi, nxi?nxi->nx_id:0, nxi?atomic_read(&nxi->nx_usecnt):0,
7056 + atomic_inc(&nxi->nx_usecnt);
7060 +#define put_nx_info(i) __put_nx_info(i,__FILE__,__LINE__)
7062 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
7066 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
7067 + nxi, nxi?nxi->nx_id:0, nxi?atomic_read(&nxi->nx_usecnt):0,
7069 + if (atomic_dec_and_test(&nxi->nx_usecnt))
7070 + free_nx_info(nxi);
7073 +#define set_nx_info(p,i) __set_nx_info(p,i,__FILE__,__LINE__)
7075 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
7076 + const char *_file, int _line)
7078 + struct nx_info *nxo;
7083 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d.%d])",
7084 + nxi, nxi?nxi->nx_id:0,
7085 + nxi?atomic_read(&nxi->nx_usecnt):0,
7086 + nxi?atomic_read(&nxi->nx_refcnt):0,
7089 + atomic_inc(&nxi->nx_refcnt);
7090 + nxo = xchg(nxp, __get_nx_info(nxi, _file, _line));
7094 +#define clr_nx_info(p) __clr_nx_info(p,__FILE__,__LINE__)
7096 +static inline void __clr_nx_info(struct nx_info **nxp,
7097 + const char *_file, int _line)
7099 + struct nx_info *nxo;
7101 + nxo = xchg(nxp, NULL);
7105 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d.%d])",
7106 + nxo, nxo?nxo->nx_id:0,
7107 + nxo?atomic_read(&nxo->nx_usecnt):0,
7108 + nxo?atomic_read(&nxo->nx_refcnt):0,
7111 + if (atomic_dec_and_test(&nxo->nx_refcnt))
7112 + unhash_nx_info(nxo);
7113 + __put_nx_info(nxo, _file, _line);
7117 +#define task_get_nx_info(i) __task_get_nx_info(i,__FILE__,__LINE__)
7119 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
7120 + const char *_file, int _line)
7122 + struct nx_info *nxi;
7125 + nxi = __get_nx_info(p->nx_info, _file, _line);
7126 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
7132 +#define nx_verify_info(p,i) \
7133 + __nx_verify_info((p)->nx_info,i,__FILE__,__LINE__)
7135 +static __inline__ void __nx_verify_info(
7136 + struct nx_info *ipa, struct nx_info *ipb,
7137 + const char *_file, int _line)
7141 + printk(KERN_ERR "ip bad assumption (%p==%p) at %s:%d\n",
7142 + ipa, ipb, _file, _line);
7146 +#define nx_task_nid(t) ((t)->nid)
7148 +#define nx_current_nid() nx_task_nid(current)
7150 +#define nx_check(c,m) __nx_check(nx_current_nid(),c,m)
7152 +#define nx_weak_check(c,m) ((m) ? nx_check(c,m) : 1)
7155 +#define __nx_flags(v,m,f) (((v) & (m)) ^ (f))
7157 +#define __nx_task_flags(t,m,f) \
7158 + (((t) && ((t)->nx_info)) ? \
7159 + __nx_flags((t)->nx_info->nx_flags,(m),(f)) : 0)
7161 +#define nx_current_flags() \
7162 + ((current->nx_info) ? current->nx_info->nx_flags : 0)
7164 +#define nx_flags(m,f) __nx_flags(nx_current_flags(),(m),(f))
7167 +#define nx_current_ncaps() \
7168 + ((current->nx_info) ? current->nx_info->nx_ncaps : 0)
7170 +#define nx_ncaps(c) (nx_current_ncaps() & (c))
7173 +static inline int addr_in_nx_info(struct nx_info *nxi, uint32_t addr)
7181 + for (i=0; i<n; i++) {
7182 + if (nxi->ipv4[i] == addr)
7190 +#warning duplicate inclusion
7192 diff -NurpP --minimal linux-2.6.10/include/linux/vs_sched.h linux-2.6.10-vs1.9.3.17/include/linux/vs_sched.h
7193 --- linux-2.6.10/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
7194 +++ linux-2.6.10-vs1.9.3.17/include/linux/vs_sched.h 2004-12-26 19:40:21.000000000 +0100
7196 +#ifndef _VX_VS_SCHED_H
7197 +#define _VX_VS_SCHED_H
7200 +#include "vserver/sched.h"
7203 +#define VAVAVOOM_RATIO 50
7205 +#define MAX_PRIO_BIAS 20
7206 +#define MIN_PRIO_BIAS -20
7209 +static inline int vx_tokens_avail(struct vx_info *vxi)
7211 + return atomic_read(&vxi->sched.tokens);
7214 +static inline void vx_consume_token(struct vx_info *vxi)
7216 + atomic_dec(&vxi->sched.tokens);
7219 +static inline int vx_need_resched(struct task_struct *p)
7221 +#ifdef CONFIG_VSERVER_HARDCPU
7222 + struct vx_info *vxi = p->vx_info;
7224 + int slice = --p->time_slice;
7226 +#ifdef CONFIG_VSERVER_HARDCPU
7230 + if ((tokens = vx_tokens_avail(vxi)) > 0)
7231 + vx_consume_token(vxi);
7232 + /* for tokens > 0, one token was consumed */
7237 + return (slice == 0);
7241 +static inline void vx_onhold_inc(struct vx_info *vxi)
7243 + int onhold = atomic_read(&vxi->cvirt.nr_onhold);
7245 + atomic_inc(&vxi->cvirt.nr_onhold);
7247 + vxi->cvirt.onhold_last = jiffies;
7250 +static inline void __vx_onhold_update(struct vx_info *vxi)
7252 + int cpu = smp_processor_id();
7253 + uint32_t now = jiffies;
7254 + uint32_t delta = now - vxi->cvirt.onhold_last;
7256 + vxi->cvirt.onhold_last = now;
7257 + vxi->sched.cpu[cpu].hold_ticks += delta;
7260 +static inline void vx_onhold_dec(struct vx_info *vxi)
7262 + if (atomic_dec_and_test(&vxi->cvirt.nr_onhold))
7263 + __vx_onhold_update(vxi);
7267 +#warning duplicate inclusion
7269 diff -NurpP --minimal linux-2.6.10/include/linux/vs_socket.h linux-2.6.10-vs1.9.3.17/include/linux/vs_socket.h
7270 --- linux-2.6.10/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
7271 +++ linux-2.6.10-vs1.9.3.17/include/linux/vs_socket.h 2004-12-26 19:40:21.000000000 +0100
7273 +#ifndef _VX_VS_SOCKET_H
7274 +#define _VX_VS_SOCKET_H
7277 +#include "vserver/debug.h"
7280 +/* socket accounting */
7282 +#include <linux/socket.h>
7284 +static inline int vx_sock_type(int family)
7288 + if (family > 0 && family < 3)
7290 + else if (family == PF_INET6)
7295 +#define vx_acc_sock(v,f,p,s) \
7296 + __vx_acc_sock((v), (f), (p), (s), __FILE__, __LINE__)
7298 +static inline void __vx_acc_sock(struct vx_info *vxi,
7299 + int family, int pos, int size, char *file, int line)
7302 + int type = vx_sock_type(family);
7304 + atomic_inc(&vxi->cacct.sock[type][pos].count);
7305 + atomic_add(size, &vxi->cacct.sock[type][pos].total);
7309 +#define vx_sock_recv(sk,s) \
7310 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, (s))
7311 +#define vx_sock_send(sk,s) \
7312 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, (s))
7313 +#define vx_sock_fail(sk,s) \
7314 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, (s))
7317 +#define sock_vx_init(s) do { \
7318 + (s)->sk_xid = 0; \
7319 + (s)->sk_vx_info = NULL; \
7322 +#define sock_nx_init(s) do { \
7323 + (s)->sk_nid = 0; \
7324 + (s)->sk_nx_info = NULL; \
7329 +#warning duplicate inclusion
7331 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/context.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/context.h
7332 --- linux-2.6.10/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
7333 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/context.h 2005-01-02 18:30:16.000000000 +0100
7335 +#ifndef _VX_CONTEXT_H
7336 +#define _VX_CONTEXT_H
7338 +#include <linux/types.h>
7341 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
7342 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
7344 +#define VX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
7346 +/* context flags */
7348 +#define VXF_INFO_LOCK 0x00000001
7349 +#define VXF_INFO_SCHED 0x00000002
7350 +#define VXF_INFO_NPROC 0x00000004
7351 +#define VXF_INFO_PRIVATE 0x00000008
7353 +#define VXF_INFO_INIT 0x00000010
7354 +#define VXF_INFO_HIDE 0x00000020
7355 +#define VXF_INFO_ULIMIT 0x00000040
7356 +#define VXF_INFO_NSPACE 0x00000080
7358 +#define VXF_SCHED_HARD 0x00000100
7359 +#define VXF_SCHED_PRIO 0x00000200
7360 +#define VXF_SCHED_PAUSE 0x00000400
7362 +#define VXF_VIRT_MEM 0x00010000
7363 +#define VXF_VIRT_UPTIME 0x00020000
7364 +#define VXF_VIRT_CPU 0x00040000
7365 +#define VXF_VIRT_LOAD 0x00080000
7367 +#define VXF_HIDE_MOUNT 0x01000000
7368 +#define VXF_HIDE_NETIF 0x02000000
7370 +#define VXF_STATE_SETUP (1ULL<<32)
7371 +#define VXF_STATE_INIT (1ULL<<33)
7373 +#define VXF_FORK_RSS (1ULL<<48)
7374 +#define VXF_PROLIFIC (1ULL<<49)
7376 +#define VXF_IGNEG_NICE (1ULL<<52)
7378 +#define VXF_ONE_TIME (0x0003ULL<<32)
7383 +#define VXC_CAP_MASK 0x00000000
7385 +#define VXC_SET_UTSNAME 0x00000001
7386 +#define VXC_SET_RLIMIT 0x00000002
7388 +#define VXC_RAW_ICMP 0x00000100
7390 +#define VXC_SECURE_MOUNT 0x00010000
7391 +#define VXC_SECURE_REMOUNT 0x00020000
7394 +/* vshelper sync commands */
7396 +#define VS_CONTEXT_CREATED 1
7397 +#define VS_CONTEXT_DESTROY 2
7402 +#include <linux/list.h>
7403 +#include <linux/spinlock.h>
7404 +#include <linux/rcupdate.h>
7406 +#include "limit_def.h"
7407 +#include "sched_def.h"
7408 +#include "cvirt_def.h"
7411 + struct hlist_node vx_hlist; /* linked list of contexts */
7412 + struct rcu_head vx_rcu; /* the rcu head */
7413 + xid_t vx_id; /* context id */
7414 + atomic_t vx_usecnt; /* usage count */
7415 + atomic_t vx_refcnt; /* reference count */
7416 + struct vx_info *vx_parent; /* parent context */
7417 + int vx_state; /* context state */
7419 + struct namespace *vx_namespace; /* private namespace */
7420 + struct fs_struct *vx_fs; /* private namespace fs */
7421 + uint64_t vx_flags; /* context flags */
7422 + uint64_t vx_bcaps; /* bounding caps (system) */
7423 + uint64_t vx_ccaps; /* context caps (vserver) */
7425 + pid_t vx_initpid; /* PID of fake init process */
7427 + spinlock_t vx_lock;
7428 + wait_queue_head_t vx_exit; /* context exit waitqueue */
7430 + struct _vx_limit limit; /* vserver limits */
7431 + struct _vx_sched sched; /* vserver scheduler */
7432 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
7433 + struct _vx_cacct cacct; /* context accounting */
7435 + char vx_name[65]; /* vserver name */
7441 +#define VXS_HASHED 0x0001
7442 +#define VXS_PAUSED 0x0010
7443 +#define VXS_ONHOLD 0x0020
7444 +#define VXS_SHUTDOWN 0x0100
7445 +#define VXS_DEFUNCT 0x1000
7446 +#define VXS_RELEASED 0x8000
7448 +/* check conditions */
7450 +#define VX_ADMIN 0x0001
7451 +#define VX_WATCH 0x0002
7452 +#define VX_HIDE 0x0004
7453 +#define VX_HOSTID 0x0008
7455 +#define VX_IDENT 0x0010
7456 +#define VX_EQUIV 0x0020
7457 +#define VX_PARENT 0x0040
7458 +#define VX_CHILD 0x0080
7460 +#define VX_ARG_MASK 0x00F0
7462 +#define VX_DYNAMIC 0x0100
7463 +#define VX_STATIC 0x0200
7465 +#define VX_ATR_MASK 0x0F00
7470 +extern void unhash_vx_info(struct vx_info *);
7472 +extern void free_vx_info(struct vx_info *);
7474 +extern struct vx_info *locate_vx_info(int);
7475 +extern struct vx_info *locate_or_create_vx_info(int);
7477 +extern int get_xid_list(int, unsigned int *, int);
7478 +extern int vx_info_is_hashed(xid_t);
7480 +extern int vx_migrate_task(struct task_struct *, struct vx_info *);
7482 +// extern int proc_pid_vx_info(struct task_struct *, char *);
7484 +extern long vs_context_state(unsigned int);
7486 +#endif /* __KERNEL__ */
7487 +#else /* _VX_CONTEXT_H */
7488 +#warning duplicate inclusion
7489 +#endif /* _VX_CONTEXT_H */
7490 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/context_cmd.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/context_cmd.h
7491 --- linux-2.6.10/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
7492 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/context_cmd.h 2004-12-26 19:40:36.000000000 +0100
7494 +#ifndef _VX_CONTEXT_CMD_H
7495 +#define _VX_CONTEXT_CMD_H
7498 +/* vinfo commands */
7500 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
7503 +extern int vc_task_xid(uint32_t, void __user *);
7505 +#endif /* __KERNEL__ */
7507 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
7509 +struct vcmd_vx_info_v0 {
7512 + /* more to come */
7516 +extern int vc_vx_info(uint32_t, void __user *);
7518 +#endif /* __KERNEL__ */
7521 +/* context commands */
7523 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 0)
7524 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 0)
7527 +extern int vc_ctx_create(uint32_t, void __user *);
7528 +extern int vc_ctx_migrate(uint32_t, void __user *);
7530 +#endif /* __KERNEL__ */
7533 +/* flag commands */
7535 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
7536 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
7538 +struct vcmd_ctx_flags_v0 {
7539 + uint64_t flagword;
7544 +extern int vc_get_cflags(uint32_t, void __user *);
7545 +extern int vc_set_cflags(uint32_t, void __user *);
7547 +#endif /* __KERNEL__ */
7550 +/* context caps commands */
7552 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 0)
7553 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 0)
7555 +struct vcmd_ctx_caps_v0 {
7562 +extern int vc_get_ccaps(uint32_t, void __user *);
7563 +extern int vc_set_ccaps(uint32_t, void __user *);
7565 +#endif /* __KERNEL__ */
7566 +#endif /* _VX_CONTEXT_CMD_H */
7567 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/cvirt.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/cvirt.h
7568 --- linux-2.6.10/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
7569 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/cvirt.h 2004-12-26 19:40:30.000000000 +0100
7571 +#ifndef _VX_CVIRT_H
7572 +#define _VX_CVIRT_H
7578 +void vx_vsi_uptime(struct timespec *, struct timespec *);
7583 +void vx_update_load(struct vx_info *);
7585 +#endif /* __KERNEL__ */
7586 +#else /* _VX_CVIRT_H */
7587 +#warning duplicate inclusion
7588 +#endif /* _VX_CVIRT_H */
7589 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/cvirt_cmd.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/cvirt_cmd.h
7590 --- linux-2.6.10/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
7591 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/cvirt_cmd.h 2004-12-26 19:40:36.000000000 +0100
7593 +#ifndef _VX_CVIRT_CMD_H
7594 +#define _VX_CVIRT_CMD_H
7596 +/* cvirt vserver commands */
7599 +#endif /* _VX_CVIRT_CMD_H */
7600 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/cvirt_def.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/cvirt_def.h
7601 --- linux-2.6.10/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
7602 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/cvirt_def.h 2004-12-26 19:40:36.000000000 +0100
7604 +#ifndef _VX_CVIRT_DEF_H
7605 +#define _VX_CVIRT_DEF_H
7607 +#include <linux/jiffies.h>
7608 +#include <linux/utsname.h>
7609 +#include <linux/spinlock.h>
7610 +#include <linux/time.h>
7611 +#include <asm/atomic.h>
7614 +struct _vx_usage_stat {
7624 +/* context sub struct */
7627 + int max_threads; /* maximum allowed threads */
7628 + atomic_t nr_threads; /* number of current threads */
7629 + atomic_t nr_running; /* number of running threads */
7630 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
7632 + atomic_t nr_onhold; /* processes on hold */
7633 + uint32_t onhold_last; /* jiffies when put on hold */
7635 + struct timespec bias_idle;
7636 + struct timespec bias_uptime; /* context creation point */
7637 + uint64_t bias_clock; /* offset in clock_t */
7639 + struct new_utsname utsname;
7641 + spinlock_t load_lock; /* lock for the load averages */
7642 + atomic_t load_updates; /* nr of load updates done so far */
7643 + uint32_t load_last; /* last time load was cacled */
7644 + uint32_t load[3]; /* load averages 1,5,15 */
7646 + struct _vx_usage_stat cpustat[NR_CPUS];
7649 +struct _vx_sock_acc {
7654 +/* context sub struct */
7657 + unsigned long total_forks;
7659 + struct _vx_sock_acc sock[5][3];
7662 +#endif /* _VX_CVIRT_DEF_H */
7663 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/debug.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/debug.h
7664 --- linux-2.6.10/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
7665 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/debug.h 2005-01-02 09:44:49.000000000 +0100
7667 +#ifndef _VX_DEBUG_H
7668 +#define _VX_DEBUG_H
7671 +#define VXD_CBIT(n,m) (vx_debug_ ## n & (1 << (m)))
7672 +#define VXD_CMIN(n,m) (vx_debug_ ## n > (m))
7673 +#define VXD_MASK(n,m) (vx_debug_ ## n & (m))
7675 +#define VXD_QPOS(v,p) (((uint32_t)(v) >> ((p)*8)) & 0xFF)
7676 +#define VXD_QUAD(v) VXD_QPOS(v,0), VXD_QPOS(v,1), \
7677 + VXD_QPOS(v,2), VXD_QPOS(v,3)
7679 +#define __FUNC__ __func__
7682 +#ifdef CONFIG_VSERVER_DEBUG
7684 +extern unsigned int vx_debug_switch;
7685 +extern unsigned int vx_debug_xid;
7686 +extern unsigned int vx_debug_nid;
7687 +extern unsigned int vx_debug_net;
7688 +extern unsigned int vx_debug_limit;
7689 +extern unsigned int vx_debug_dlim;
7690 +extern unsigned int vx_debug_cvirt;
7693 +#define VX_LOGLEVEL "vxD: "
7694 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
7696 +#define vxdprintk(c,f,x...) \
7699 + printk(VX_LOGLEVEL f "\n" , ##x); \
7702 +#define vxlprintk(c,f,x...) \
7705 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
7708 +#define vxfprintk(c,f,x...) \
7711 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
7715 +#define vxwprintk(c,f,x...) \
7718 + printk(VX_WARNLEVEL f "\n" , ##x); \
7722 +#define vxd_path(d,m) \
7723 + ({ static char _buffer[PATH_MAX]; \
7724 + d_path((d), (m), _buffer, sizeof(_buffer)); })
7726 +#else /* CONFIG_VSERVER_DEBUG */
7728 +#define vx_debug_switch 0
7729 +#define vx_debug_xid 0
7730 +#define vx_debug_nid 0
7731 +#define vx_debug_net 0
7732 +#define vx_debug_limit 0
7733 +#define vx_debug_dlim 0
7734 +#define vx_debug_cvirt 0
7736 +#define vxdprintk(x...) do { } while (0)
7737 +#define vxlprintk(x...) do { } while (0)
7738 +#define vxfprintk(x...) do { } while (0)
7739 +#define vxwprintk(x...) do { } while (0)
7741 +#define vxd_path "<none>"
7743 +#endif /* CONFIG_VSERVER_DEBUG */
7746 +/* history stuff */
7748 +#ifdef CONFIG_VSERVER_HISTORY
7751 +extern unsigned volatile int vxh_active;
7754 + struct vx_info *ptr;
7760 +struct _vxhe_set_clr {
7764 +struct _vxhe_loc_lookup {
7776 + VXH_ALLOC_VX_INFO,
7777 + VXH_DEALLOC_VX_INFO,
7779 + VXH_UNHASH_VX_INFO,
7781 + VXH_LOOKUP_VX_INFO,
7784 +struct _vx_hist_entry {
7786 + unsigned short seq;
7787 + unsigned short type;
7788 + struct _vxhe_vxi vxi;
7790 + struct _vxhe_set_clr sc;
7791 + struct _vxhe_loc_lookup ll;
7795 +struct _vx_hist_entry *vxh_advance(void *loc);
7797 +#define VXH_HERE() \
7798 + ({ __label__ here; \
7804 +static inline void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
7806 + entry->vxi.ptr = vxi;
7808 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
7809 + entry->vxi.refcnt = atomic_read(&vxi->vx_refcnt);
7810 + entry->vxi.xid = vxi->vx_id;
7814 +static inline void vxh_throw_oops(void)
7816 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7818 + entry->type = VXH_THROW_OOPS;
7820 + /* prevent further acquisition */
7824 +static inline void vxh_get_vx_info(struct vx_info *vxi)
7826 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7828 + __vxh_copy_vxi(entry, vxi);
7829 + entry->type = VXH_GET_VX_INFO;
7832 +static inline void vxh_put_vx_info(struct vx_info *vxi)
7834 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7836 + __vxh_copy_vxi(entry, vxi);
7837 + entry->type = VXH_PUT_VX_INFO;
7840 +static inline void vxh_set_vx_info(struct vx_info *vxi, void *data)
7842 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7844 + __vxh_copy_vxi(entry, vxi);
7845 + entry->sc.data = data;
7846 + entry->type = VXH_SET_VX_INFO;
7849 +static inline void vxh_clr_vx_info(struct vx_info *vxi, void *data)
7851 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7853 + __vxh_copy_vxi(entry, vxi);
7854 + entry->sc.data = data;
7855 + entry->type = VXH_CLR_VX_INFO;
7858 +static inline void vxh_alloc_vx_info(struct vx_info *vxi)
7860 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7862 + __vxh_copy_vxi(entry, vxi);
7863 + entry->type = VXH_ALLOC_VX_INFO;
7866 +static inline void vxh_dealloc_vx_info(struct vx_info *vxi)
7868 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7870 + __vxh_copy_vxi(entry, vxi);
7871 + entry->type = VXH_DEALLOC_VX_INFO;
7874 +static inline void vxh_hash_vx_info(struct vx_info *vxi)
7876 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7878 + __vxh_copy_vxi(entry, vxi);
7879 + entry->type = VXH_HASH_VX_INFO;
7882 +static inline void vxh_unhash_vx_info(struct vx_info *vxi)
7884 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7886 + __vxh_copy_vxi(entry, vxi);
7887 + entry->type = VXH_UNHASH_VX_INFO;
7890 +static inline void vxh_loc_vx_info(unsigned arg, struct vx_info *vxi)
7892 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7894 + __vxh_copy_vxi(entry, vxi);
7895 + entry->ll.arg = arg;
7896 + entry->type = VXH_LOC_VX_INFO;
7899 +static inline void vxh_lookup_vx_info(unsigned arg, struct vx_info *vxi)
7901 + struct _vx_hist_entry *entry = vxh_advance(VXH_HERE());
7903 + __vxh_copy_vxi(entry, vxi);
7904 + entry->ll.arg = arg;
7905 + entry->type = VXH_LOOKUP_VX_INFO;
7908 +extern void vxh_dump_history(void);
7910 +#else /* CONFIG_VSERVER_HISTORY */
7912 +#define vxh_throw_oops() do { } while (0)
7914 +#define vxh_get_vx_info(v) do { } while (0)
7915 +#define vxh_put_vx_info(v) do { } while (0)
7917 +#define vxh_set_vx_info(v,d) do { } while (0)
7918 +#define vxh_clr_vx_info(v,d) do { } while (0)
7920 +#define vxh_alloc_vx_info(v) do { } while (0)
7921 +#define vxh_dealloc_vx_info(v) do { } while (0)
7923 +#define vxh_hash_vx_info(v) do { } while (0)
7924 +#define vxh_unhash_vx_info(v) do { } while (0)
7926 +#define vxh_loc_vx_info(a,v) do { } while (0)
7927 +#define vxh_lookup_vx_info(a,v) do { } while (0)
7929 +#define vxh_dump_history() do { } while (0)
7932 +#endif /* CONFIG_VSERVER_HISTORY */
7934 +#endif /* _VX_DEBUG_H */
7935 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/debug_cmd.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/debug_cmd.h
7936 --- linux-2.6.10/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
7937 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/debug_cmd.h 2005-01-02 09:44:49.000000000 +0100
7939 +#ifndef _VX_DEBUG_CMD_H
7940 +#define _VX_DEBUG_CMD_H
7943 +/* debug commands */
7945 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
7949 +extern int vc_dump_history(uint32_t);
7951 +#endif /* __KERNEL__ */
7952 +#endif /* _VX_DEBUG_CMD_H */
7953 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/dlimit.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/dlimit.h
7954 --- linux-2.6.10/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
7955 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/dlimit.h 2004-12-26 19:40:35.000000000 +0100
7957 +#ifndef _VX_DLIMIT_H
7958 +#define _VX_DLIMIT_H
7960 +#include "switch.h"
7961 +#include <linux/spinlock.h>
7963 +/* inode vserver commands */
7965 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
7966 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
7968 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
7969 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
7972 +struct vcmd_ctx_dlimit_base_v0 {
7973 + const char __user *name;
7977 +struct vcmd_ctx_dlimit_v0 {
7978 + const char __user *name;
7979 + uint32_t space_used; /* used space in kbytes */
7980 + uint32_t space_total; /* maximum space in kbytes */
7981 + uint32_t inodes_used; /* used inodes */
7982 + uint32_t inodes_total; /* maximum inodes */
7983 + uint32_t reserved; /* reserved for root in % */
7987 +#define CDLIM_UNSET (0ULL)
7988 +#define CDLIM_INFINITY (~0ULL)
7989 +#define CDLIM_KEEP (~1ULL)
7994 +struct super_block;
7997 + struct hlist_node dl_hlist; /* linked list of contexts */
7998 + struct rcu_head dl_rcu; /* the rcu head */
7999 + xid_t dl_xid; /* context id */
8000 + atomic_t dl_usecnt; /* usage count */
8001 + atomic_t dl_refcnt; /* reference count */
8003 + struct super_block *dl_sb; /* associated superblock */
8005 +// struct rw_semaphore dl_sem; /* protect the values */
8006 + spinlock_t dl_lock; /* protect the values */
8008 + uint64_t dl_space_used; /* used space in bytes */
8009 + uint64_t dl_space_total; /* maximum space in bytes */
8010 + uint32_t dl_inodes_used; /* used inodes */
8011 + uint32_t dl_inodes_total; /* maximum inodes */
8013 + unsigned int dl_nrlmult; /* non root limit mult */
8018 +extern void rcu_free_dl_info(struct rcu_head *);
8019 +extern void unhash_dl_info(struct dl_info *);
8021 +extern struct dl_info *locate_dl_info(struct super_block *, xid_t);
8026 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
8029 +extern int vc_add_dlimit(uint32_t, void __user *);
8030 +extern int vc_rem_dlimit(uint32_t, void __user *);
8032 +extern int vc_set_dlimit(uint32_t, void __user *);
8033 +extern int vc_get_dlimit(uint32_t, void __user *);
8036 +typedef uint64_t dlsize_t;
8038 +#endif /* __KERNEL__ */
8039 +#else /* _VX_DLIMIT_H */
8040 +#warning duplicate inclusion
8041 +#endif /* _VX_DLIMIT_H */
8042 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/inode.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/inode.h
8043 --- linux-2.6.10/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
8044 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/inode.h 2004-12-26 19:40:30.000000000 +0100
8046 +#ifndef _VX_INODE_H
8047 +#define _VX_INODE_H
8049 +#include "switch.h"
8051 +/* inode vserver commands */
8053 +#define VCMD_get_iattr_v0 VC_CMD(INODE, 1, 0)
8054 +#define VCMD_set_iattr_v0 VC_CMD(INODE, 2, 0)
8056 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
8057 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
8059 +struct vcmd_ctx_iattr_v0 {
8060 + /* device handle in id */
8067 +struct vcmd_ctx_iattr_v1 {
8068 + const char __user *name;
8075 +#define IATTR_XID 0x01000000
8077 +#define IATTR_ADMIN 0x00000001
8078 +#define IATTR_WATCH 0x00000002
8079 +#define IATTR_HIDE 0x00000004
8080 +#define IATTR_FLAGS 0x00000007
8082 +#define IATTR_BARRIER 0x00010000
8083 +#define IATTR_IUNLINK 0x00020000
8084 +#define IATTR_IMMUTABLE 0x00040000
8087 +#ifdef CONFIG_VSERVER_PROC_SECURE
8088 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
8089 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
8091 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
8092 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
8097 +#define vx_hide_check(c,m) (((m) & IATTR_HIDE) ? vx_check(c,m) : 1)
8099 +extern int vc_get_iattr_v0(uint32_t, void __user *);
8100 +extern int vc_set_iattr_v0(uint32_t, void __user *);
8102 +extern int vc_get_iattr(uint32_t, void __user *);
8103 +extern int vc_set_iattr(uint32_t, void __user *);
8105 +#endif /* __KERNEL__ */
8109 +#define FIOC_GETXFLG _IOR('x', 5, long)
8110 +#define FIOC_SETXFLG _IOW('x', 6, long)
8112 +#else /* _VX_INODE_H */
8113 +#warning duplicate inclusion
8114 +#endif /* _VX_INODE_H */
8115 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/legacy.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/legacy.h
8116 --- linux-2.6.10/include/linux/vserver/legacy.h 1970-01-01 01:00:00.000000000 +0100
8117 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/legacy.h 2004-12-26 19:40:36.000000000 +0100
8119 +#ifndef _VX_LEGACY_H
8120 +#define _VX_LEGACY_H
8122 +#include "switch.h"
8124 +/* compatibiliy vserver commands */
8126 +#define VCMD_new_s_context VC_CMD(COMPAT, 1, 1)
8127 +#define VCMD_set_ipv4root VC_CMD(COMPAT, 2, 3)
8129 +#define VCMD_create_context VC_CMD(VSETUP, 1, 0)
8131 +/* compatibiliy vserver arguments */
8133 +struct vcmd_new_s_context_v1 {
8134 + uint32_t remove_cap;
8138 +struct vcmd_set_ipv4root_v3 {
8139 + /* number of pairs in id */
8140 + uint32_t broadcast;
8144 + } nx_mask_pair[NB_IPV4ROOT];
8148 +#define VX_INFO_LOCK 1 /* Can't request a new vx_id */
8149 +#define VX_INFO_NPROC 4 /* Limit number of processes in a context */
8150 +#define VX_INFO_PRIVATE 8 /* Noone can join this security context */
8151 +#define VX_INFO_INIT 16 /* This process wants to become the */
8152 + /* logical process 1 of the security */
8154 +#define VX_INFO_HIDEINFO 32 /* Hide some information in /proc */
8155 +#define VX_INFO_ULIMIT 64 /* Use ulimit of the current process */
8156 + /* to become the global limits */
8157 + /* of the context */
8158 +#define VX_INFO_NAMESPACE 128 /* save private namespace */
8161 +#define NB_S_CONTEXT 16
8163 +#define NB_IPV4ROOT 16
8167 +extern int vc_new_s_context(uint32_t, void __user *);
8168 +extern int vc_set_ipv4root(uint32_t, void __user *);
8170 +#endif /* __KERNEL__ */
8171 +#endif /* _VX_LEGACY_H */
8172 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/limit.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/limit.h
8173 --- linux-2.6.10/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
8174 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/limit.h 2004-12-26 19:40:35.000000000 +0100
8176 +#ifndef _VX_LIMIT_H
8177 +#define _VX_LIMIT_H
8183 +void vx_vsi_meminfo(struct sysinfo *);
8184 +void vx_vsi_swapinfo(struct sysinfo *);
8186 +#define VXD_RLIMIT(r,l) (VXD_CBIT(limit, (l)) && ((r) == (l)))
8188 +#define NUM_LIMITS 20
8190 +#define VLIMIT_NSOCK 16
8192 +extern const char *vlimit_name[NUM_LIMITS];
8194 +#endif /* __KERNEL__ */
8195 +#endif /* _VX_LIMIT_H */
8196 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/limit_cmd.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/limit_cmd.h
8197 --- linux-2.6.10/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
8198 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/limit_cmd.h 2004-12-26 19:40:36.000000000 +0100
8200 +#ifndef _VX_LIMIT_CMD_H
8201 +#define _VX_LIMIT_CMD_H
8203 +/* rlimit vserver commands */
8205 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
8206 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
8207 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
8209 +struct vcmd_ctx_rlimit_v0 {
8212 + uint64_t softlimit;
8216 +struct vcmd_ctx_rlimit_mask_v0 {
8218 + uint32_t softlimit;
8222 +#define CRLIM_UNSET (0ULL)
8223 +#define CRLIM_INFINITY (~0ULL)
8224 +#define CRLIM_KEEP (~1ULL)
8228 +#include <linux/compiler.h>
8230 +extern int vc_get_rlimit(uint32_t, void __user *);
8231 +extern int vc_set_rlimit(uint32_t, void __user *);
8232 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
8234 +#endif /* __KERNEL__ */
8235 +#endif /* _VX_LIMIT_CMD_H */
8236 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/limit_def.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/limit_def.h
8237 --- linux-2.6.10/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
8238 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/limit_def.h 2004-12-26 19:40:36.000000000 +0100
8240 +#ifndef _VX_LIMIT_DEF_H
8241 +#define _VX_LIMIT_DEF_H
8243 +#include <asm/atomic.h>
8244 +#include <asm/resource.h>
8248 +/* context sub struct */
8253 + unsigned long rlim[NUM_LIMITS]; /* Context limit */
8254 + unsigned long rmax[NUM_LIMITS]; /* Context maximum */
8255 + atomic_t rcur[NUM_LIMITS]; /* Current value */
8256 + atomic_t lhit[NUM_LIMITS]; /* Limit hits */
8260 +#endif /* _VX_LIMIT_DEF_H */
8261 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/namespace.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/namespace.h
8262 --- linux-2.6.10/include/linux/vserver/namespace.h 1970-01-01 01:00:00.000000000 +0100
8263 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/namespace.h 2004-12-26 19:40:29.000000000 +0100
8265 +#ifndef _VX_NAMESPACE_H
8266 +#define _VX_NAMESPACE_H
8268 +#include <linux/types.h>
8271 +/* virtual host info names */
8273 +#define VCMD_vx_set_vhi_name VC_CMD(VHOST, 1, 0)
8274 +#define VCMD_vx_get_vhi_name VC_CMD(VHOST, 2, 0)
8276 +struct vcmd_vx_vhi_name_v0 {
8282 +enum vx_vhi_name_field {
8295 +#include <linux/compiler.h>
8297 +extern int vc_set_vhi_name(uint32_t, void __user *);
8298 +extern int vc_get_vhi_name(uint32_t, void __user *);
8300 +#endif /* __KERNEL__ */
8302 +#define VCMD_enter_namespace VC_CMD(PROCALT, 1, 0)
8303 +#define VCMD_cleanup_namespace VC_CMD(PROCALT, 2, 0)
8304 +#define VCMD_set_namespace VC_CMD(PROCALT, 3, 0)
8313 +extern int vx_check_vfsmount(struct vx_info *, struct vfsmount *);
8315 +extern int vx_set_namespace(struct vx_info *, struct namespace *, struct fs_struct *);
8317 +extern int vc_enter_namespace(uint32_t, void __user *);
8318 +extern int vc_cleanup_namespace(uint32_t, void __user *);
8319 +extern int vc_set_namespace(uint32_t, void __user *);
8321 +#endif /* __KERNEL__ */
8322 +#else /* _VX_NAMESPACE_H */
8323 +#warning duplicate inclusion
8324 +#endif /* _VX_NAMESPACE_H */
8325 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/network.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/network.h
8326 --- linux-2.6.10/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
8327 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/network.h 2005-01-02 18:34:28.000000000 +0100
8329 +#ifndef _VX_NETWORK_H
8330 +#define _VX_NETWORK_H
8332 +#include <linux/types.h>
8335 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
8337 +#define NX_DYNAMIC_ID ((uint32_t)-1) /* id for dynamic context */
8339 +#define NB_IPV4ROOT 16
8344 +#include <linux/list.h>
8345 +#include <linux/spinlock.h>
8346 +#include <linux/rcupdate.h>
8347 +#include <asm/atomic.h>
8351 + struct hlist_node nx_hlist; /* linked list of nxinfos */
8352 + struct rcu_head nx_rcu; /* the rcu head */
8353 + nid_t nx_id; /* vnet id */
8354 + atomic_t nx_usecnt; /* usage count */
8355 + atomic_t nx_refcnt; /* reference count */
8357 + uint64_t nx_flags; /* network flag word */
8358 + uint64_t nx_ncaps; /* network capabilities */
8361 + __u32 ipv4[NB_IPV4ROOT]; /* Process can only bind to these IPs */
8362 + /* The first one is used to connect */
8363 + /* and for bind any service */
8364 + /* The other must be used explicity */
8365 + __u32 mask[NB_IPV4ROOT]; /* Netmask for each ipv4 */
8366 + /* Used to select the proper source */
8367 + /* address for sockets */
8368 + __u32 v4_bcast; /* Broadcast address to receive UDP */
8370 + char nx_name[65]; /* network context name */
8376 +extern void unhash_nx_info(struct nx_info *);
8378 +extern void free_nx_info(struct nx_info *);
8380 +extern struct nx_info *locate_nx_info(int);
8381 +extern struct nx_info *locate_or_create_nx_info(int);
8383 +extern int get_nid_list(int, unsigned int *, int);
8384 +extern int nx_info_is_hashed(nid_t);
8386 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
8391 +int ifa_in_nx_info(struct in_ifaddr *, struct nx_info *);
8392 +int dev_in_nx_info(struct net_device *, struct nx_info *);
8396 +int nx_addr_conflict(struct nx_info *, uint32_t, struct sock *);
8398 +#endif /* __KERNEL__ */
8399 +#else /* _VX_NETWORK_H */
8400 +#warning duplicate inclusion
8401 +#endif /* _VX_NETWORK_H */
8402 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/network_cmd.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/network_cmd.h
8403 --- linux-2.6.10/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
8404 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/network_cmd.h 2004-12-26 19:40:36.000000000 +0100
8406 +#ifndef _VX_NETWORK_CMD_H
8407 +#define _VX_NETWORK_CMD_H
8410 +/* vinfo commands */
8412 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
8415 +extern int vc_task_nid(uint32_t, void __user *);
8417 +#endif /* __KERNEL__ */
8419 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
8421 +struct vcmd_nx_info_v0 {
8423 + /* more to come */
8427 +extern int vc_nx_info(uint32_t, void __user *);
8429 +#endif /* __KERNEL__ */
8431 +#define VCMD_net_create VC_CMD(VNET, 1, 0)
8432 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
8434 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
8435 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
8437 +struct vcmd_net_nx_v0 {
8442 + /* more to come */
8449 +extern int vc_net_create(uint32_t, void __user *);
8450 +extern int vc_net_migrate(uint32_t, void __user *);
8452 +#endif /* __KERNEL__ */
8454 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
8455 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
8457 +struct vcmd_net_flags_v0 {
8458 + uint64_t flagword;
8463 +extern int vc_get_nflags(uint32_t, void __user *);
8464 +extern int vc_set_nflags(uint32_t, void __user *);
8466 +#endif /* __KERNEL__ */
8468 +#define IPF_STATE_SETUP (1ULL<<32)
8471 +#define IPF_ONE_TIME (0x0001ULL<<32)
8473 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
8474 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
8476 +struct vcmd_net_caps_v0 {
8482 +extern int vc_get_ncaps(uint32_t, void __user *);
8483 +extern int vc_set_ncaps(uint32_t, void __user *);
8485 +#endif /* __KERNEL__ */
8486 +#endif /* _VX_CONTEXT_CMD_H */
8487 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/sched.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/sched.h
8488 --- linux-2.6.10/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
8489 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/sched.h 2004-12-26 19:40:30.000000000 +0100
8491 +#ifndef _VX_SCHED_H
8492 +#define _VX_SCHED_H
8498 +void vx_vsi_uptime(struct timespec *, struct timespec *);
8503 +void vx_update_load(struct vx_info *);
8506 +struct task_struct;
8508 +int effective_vavavoom(struct task_struct *, int);
8510 +int vx_tokens_recalc(struct vx_info *);
8512 +#endif /* __KERNEL__ */
8513 +#else /* _VX_SCHED_H */
8514 +#warning duplicate inclusion
8515 +#endif /* _VX_SCHED_H */
8516 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/sched_cmd.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/sched_cmd.h
8517 --- linux-2.6.10/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
8518 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/sched_cmd.h 2004-12-26 19:40:36.000000000 +0100
8520 +#ifndef _VX_SCHED_CMD_H
8521 +#define _VX_SCHED_CMD_H
8523 +/* sched vserver commands */
8525 +#define VCMD_set_sched_v2 VC_CMD(SCHED, 1, 2)
8526 +#define VCMD_set_sched VC_CMD(SCHED, 1, 3)
8528 +struct vcmd_set_sched_v2 {
8529 + int32_t fill_rate;
8532 + int32_t tokens_min;
8533 + int32_t tokens_max;
8534 + uint64_t cpu_mask;
8537 +struct vcmd_set_sched_v3 {
8538 + uint32_t set_mask;
8539 + int32_t fill_rate;
8542 + int32_t tokens_min;
8543 + int32_t tokens_max;
8544 + int32_t priority_bias;
8548 +#define VXSM_FILL_RATE 0x0001
8549 +#define VXSM_INTERVAL 0x0002
8550 +#define VXSM_TOKENS 0x0010
8551 +#define VXSM_TOKENS_MIN 0x0020
8552 +#define VXSM_TOKENS_MAX 0x0040
8553 +#define VXSM_PRIO_BIAS 0x0100
8555 +#define SCHED_KEEP (-2)
8559 +#include <linux/compiler.h>
8561 +extern int vc_set_sched_v1(uint32_t, void __user *);
8562 +extern int vc_set_sched_v2(uint32_t, void __user *);
8563 +extern int vc_set_sched(uint32_t, void __user *);
8565 +#endif /* __KERNEL__ */
8566 +#endif /* _VX_SCHED_CMD_H */
8567 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/sched_def.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/sched_def.h
8568 --- linux-2.6.10/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
8569 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/sched_def.h 2004-12-26 19:40:36.000000000 +0100
8571 +#ifndef _VX_SCHED_DEF_H
8572 +#define _VX_SCHED_DEF_H
8574 +#include <linux/spinlock.h>
8575 +#include <linux/jiffies.h>
8576 +#include <linux/cpumask.h>
8577 +#include <asm/atomic.h>
8578 +#include <asm/param.h>
8582 + uint64_t user_ticks; /* token tick events */
8583 + uint64_t sys_ticks; /* token tick events */
8584 + uint64_t hold_ticks; /* token ticks paused */
8585 + uint64_t unused[5]; /* cacheline ? */
8588 +/* context sub struct */
8591 + atomic_t tokens; /* number of CPU tokens */
8592 + spinlock_t tokens_lock; /* lock for token bucket */
8594 + int fill_rate; /* Fill rate: add X tokens... */
8595 + int interval; /* Divisor: per Y jiffies */
8596 + int tokens_min; /* Limit: minimum for unhold */
8597 + int tokens_max; /* Limit: no more than N tokens */
8598 + uint32_t jiffies; /* last time accounted */
8600 + int priority_bias; /* bias offset for priority */
8601 + cpumask_t cpus_allowed; /* cpu mask for context */
8603 + struct _vx_ticks cpu[NR_CPUS];
8606 +#endif /* _VX_SCHED_DEF_H */
8607 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/signal.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/signal.h
8608 --- linux-2.6.10/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
8609 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/signal.h 2004-12-26 19:40:30.000000000 +0100
8611 +#ifndef _VX_SIGNAL_H
8612 +#define _VX_SIGNAL_H
8614 +#include "switch.h"
8616 +/* context signalling */
8618 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
8619 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
8621 +struct vcmd_ctx_kill_v0 {
8626 +struct vcmd_wait_exit_v0 {
8633 +extern int vc_ctx_kill(uint32_t, void __user *);
8634 +extern int vc_wait_exit(uint32_t, void __user *);
8636 +#endif /* __KERNEL__ */
8637 +#endif /* _VX_SIGNAL_H */
8638 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/switch.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/switch.h
8639 --- linux-2.6.10/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
8640 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/switch.h 2005-01-02 09:44:49.000000000 +0100
8642 +#ifndef _VX_SWITCH_H
8643 +#define _VX_SWITCH_H
8645 +#include <linux/types.h>
8647 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
8648 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
8649 +#define VC_VERSION(c) ((c) & 0xFFF)
8651 +#define VC_CMD(c,i,v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
8652 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
8656 + Syscall Matrix V2.8
8658 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
8659 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
8660 + |INFO |SETUP | |MOVE | | | | | |
8661 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
8662 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICES| |
8663 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
8664 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
8665 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
8666 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
8667 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
8668 + MEMORY | | | | | | | |SWAP | |
8669 + | 16| 17| 18| 19| 20| 21| | 22| 23|
8670 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
8671 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
8672 + | 24| 25| 26| 27| 28| 29| | 30| 31|
8673 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
8674 + DISK | | | | |DLIMIT | | |INODE | |
8675 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
8676 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
8677 + OTHER | | | | | | | |VINFO | |
8678 + | 40| 41| 42| 43| 44| 45| | 46| 47|
8679 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
8680 + SPECIAL|EVENT | | | |FLAGS | | | | |
8681 + | 48| 49| 50| 51| 52| 53| | 54| 55|
8682 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
8683 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
8684 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
8685 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
8689 +#define VC_CAT_VERSION 0
8691 +#define VC_CAT_VSETUP 1
8692 +#define VC_CAT_VHOST 2
8694 +#define VC_CAT_VPROC 9
8695 +#define VC_CAT_PROCALT 10
8696 +#define VC_CAT_PROCMIG 11
8697 +#define VC_CAT_PROCTRL 12
8699 +#define VC_CAT_SCHED 14
8701 +#define VC_CAT_VNET 25
8702 +#define VC_CAT_NETALT 26
8703 +#define VC_CAT_NETMIG 27
8704 +#define VC_CAT_NETCTRL 28
8706 +#define VC_CAT_DLIMIT 36
8707 +#define VC_CAT_INODE 38
8709 +#define VC_CAT_VINFO 46
8710 +#define VC_CAT_EVENT 48
8712 +#define VC_CAT_FLAGS 52
8713 +#define VC_CAT_DEBUG 56
8714 +#define VC_CAT_RLIMIT 60
8716 +#define VC_CAT_SYSTEST 61
8717 +#define VC_CAT_COMPAT 63
8719 +/* interface version */
8721 +#define VCI_VERSION 0x00010025
8724 +/* query version */
8726 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
8731 +#include <linux/errno.h>
8734 +#else /* __KERNEL__ */
8736 +#endif /* __KERNEL__ */
8738 +#endif /* _VX_SWITCH_H */
8739 diff -NurpP --minimal linux-2.6.10/include/linux/vserver/xid.h linux-2.6.10-vs1.9.3.17/include/linux/vserver/xid.h
8740 --- linux-2.6.10/include/linux/vserver/xid.h 1970-01-01 01:00:00.000000000 +0100
8741 +++ linux-2.6.10-vs1.9.3.17/include/linux/vserver/xid.h 2004-12-26 19:40:34.000000000 +0100
8747 +#define XID_TAG(in) (!(in) || \
8748 + (((struct inode *)in)->i_sb && \
8749 + (((struct inode *)in)->i_sb->s_flags & MS_TAGXID)))
8752 +#ifdef CONFIG_INOXID_NONE
8754 +#define MAX_UID 0xFFFFFFFF
8755 +#define MAX_GID 0xFFFFFFFF
8757 +#define INOXID_XID(tag, uid, gid, xid) (0)
8759 +#define XIDINO_UID(tag, uid, xid) (uid)
8760 +#define XIDINO_GID(tag, gid, xid) (gid)
8765 +#ifdef CONFIG_INOXID_GID16
8767 +#define MAX_UID 0xFFFFFFFF
8768 +#define MAX_GID 0x0000FFFF
8770 +#define INOXID_XID(tag, uid, gid, xid) \
8771 + ((tag) ? (((gid) >> 16) & 0xFFFF) : 0)
8773 +#define XIDINO_UID(tag, uid, xid) (uid)
8774 +#define XIDINO_GID(tag, gid, xid) \
8775 + ((tag) ? (((gid) & 0xFFFF) | ((xid) << 16)) : (gid))
8780 +#ifdef CONFIG_INOXID_UGID24
8782 +#define MAX_UID 0x00FFFFFF
8783 +#define MAX_GID 0x00FFFFFF
8785 +#define INOXID_XID(tag, uid, gid, xid) \
8786 + ((tag) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
8788 +#define XIDINO_UID(tag, uid, xid) \
8789 + ((tag) ? (((uid) & 0xFFFFFF) | (((xid) & 0xFF00) << 16)) : (uid))
8790 +#define XIDINO_GID(tag, gid, xid) \
8791 + ((tag) ? (((gid) & 0xFFFFFF) | (((xid) & 0x00FF) << 24)) : (gid))
8796 +#ifdef CONFIG_INOXID_UID16
8798 +#define MAX_UID 0x0000FFFF
8799 +#define MAX_GID 0xFFFFFFFF
8801 +#define INOXID_XID(tag, uid, gid, xid) \
8802 + ((tag) ? ((uid) >> 16) & 0xFFFF) : 0)
8804 +#define XIDINO_UID(tag, uid, xid) \
8805 + ((tag) ? (((uid) & 0xFFFF) | ((xid) << 16)) : (uid))
8806 +#define XIDINO_GID(tag, gid, xid) (gid)
8811 +#ifdef CONFIG_INOXID_INTERN
8813 +#define MAX_UID 0xFFFFFFFF
8814 +#define MAX_GID 0xFFFFFFFF
8816 +#define INOXID_XID(tag, uid, gid, xid) \
8817 + ((tag) ? (xid) : 0)
8819 +#define XIDINO_UID(tag, uid, xid) (uid)
8820 +#define XIDINO_GID(tag, gid, xid) (gid)
8825 +#ifdef CONFIG_INOXID_RUNTIME
8827 +#define MAX_UID 0xFFFFFFFF
8828 +#define MAX_GID 0xFFFFFFFF
8830 +#define INOXID_XID(tag, uid, gid, xid) (0)
8832 +#define XIDINO_UID(tag, uid, xid) (uid)
8833 +#define XIDINO_GID(tag, gid, xid) (gid)
8838 +#define INOXID_UID(tag, uid, gid) \
8839 + ((tag) ? ((uid) & MAX_UID) : (uid))
8840 +#define INOXID_GID(tag, uid, gid) \
8841 + ((tag) ? ((gid) & MAX_GID) : (gid))
8844 +static inline uid_t vx_map_uid(uid_t uid)
8846 + if ((uid > MAX_UID) && (uid != -1))
8848 + return (uid & MAX_UID);
8851 +static inline gid_t vx_map_gid(gid_t gid)
8853 + if ((gid > MAX_GID) && (gid != -1))
8855 + return (gid & MAX_GID);
8859 +#ifdef CONFIG_VSERVER_LEGACY
8860 +#define FIOC_GETXID _IOR('x', 1, long)
8861 +#define FIOC_SETXID _IOW('x', 2, long)
8862 +#define FIOC_SETXIDJ _IOW('x', 3, long)
8865 +int vx_parse_xid(char *string, xid_t *xid, int remove);
8866 +void vx_propagate_xid(struct nameidata *nd, struct inode *inode);
8868 +#endif /* _VX_XID_H */
8869 diff -NurpP --minimal linux-2.6.10/include/net/af_unix.h linux-2.6.10-vs1.9.3.17/include/net/af_unix.h
8870 --- linux-2.6.10/include/net/af_unix.h 2004-10-23 05:06:24.000000000 +0200
8871 +++ linux-2.6.10-vs1.9.3.17/include/net/af_unix.h 2004-12-26 19:40:29.000000000 +0100
8872 @@ -11,9 +11,9 @@ extern rwlock_t unix_table_lock;
8874 extern atomic_t unix_tot_inflight;
8876 -static inline struct sock *first_unix_socket(int *i)
8877 +static inline struct sock *next_unix_socket_table(int *i)
8879 - for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
8880 + for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
8881 if (!hlist_empty(&unix_socket_table[*i]))
8882 return __sk_head(&unix_socket_table[*i]);
8884 @@ -22,16 +22,19 @@ static inline struct sock *first_unix_so
8886 static inline struct sock *next_unix_socket(int *i, struct sock *s)
8888 - struct sock *next = sk_next(s);
8889 - /* More in this chain? */
8892 - /* Look for next non-empty chain. */
8893 - for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
8894 - if (!hlist_empty(&unix_socket_table[*i]))
8895 - return __sk_head(&unix_socket_table[*i]);
8902 + s = next_unix_socket_table(i);
8903 + } while (s && !vx_check(s->sk_xid, VX_IDENT|VX_WATCH));
8907 +static inline struct sock *first_unix_socket(int *i)
8910 + return next_unix_socket(i, NULL);
8913 #define forall_unix_sockets(i, s) \
8914 diff -NurpP --minimal linux-2.6.10/include/net/lapb.h linux-2.6.10-vs1.9.3.17/include/net/lapb.h
8915 --- linux-2.6.10/include/net/lapb.h 2004-08-14 12:56:22.000000000 +0200
8916 +++ linux-2.6.10-vs1.9.3.17/include/net/lapb.h 2004-12-26 19:40:36.000000000 +0100
8917 @@ -57,7 +57,11 @@ enum {
8919 #define LAPB_DEFAULT_MODE (LAPB_STANDARD | LAPB_SLP | LAPB_DTE)
8920 #define LAPB_DEFAULT_WINDOW 7 /* Window=7 */
8922 #define LAPB_DEFAULT_T1 (5 * HZ) /* T1=5s */
8924 +#define LAPB_DEFAULT_T1 (65534) /* T1=max */
8926 #define LAPB_DEFAULT_T2 (1 * HZ) /* T2=1s */
8927 #define LAPB_DEFAULT_N2 20 /* N2=20 */
8929 diff -NurpP --minimal linux-2.6.10/include/net/route.h linux-2.6.10-vs1.9.3.17/include/net/route.h
8930 --- linux-2.6.10/include/net/route.h 2004-10-23 05:06:24.000000000 +0200
8931 +++ linux-2.6.10-vs1.9.3.17/include/net/route.h 2004-12-26 19:40:29.000000000 +0100
8933 #include <linux/route.h>
8934 #include <linux/ip.h>
8935 #include <linux/cache.h>
8936 +#include <linux/vs_context.h>
8937 +#include <linux/vs_network.h>
8940 #warning This file is not supposed to be used outside of kernel.
8941 @@ -143,6 +145,59 @@ static inline char rt_tos2priority(u8 to
8942 return ip_tos2prio[IPTOS_TOS(tos)>>1];
8945 +#define IPI_LOOPBACK 0x0100007f
8947 +static inline int ip_find_src(struct nx_info *nxi, struct rtable **rp, struct flowi *fl)
8950 + int i, n = nxi->nbipv4;
8951 + u32 ipv4root = nxi->ipv4[0];
8953 + if (ipv4root == 0)
8956 + if (fl->fl4_src == 0) {
8960 + err = __ip_route_output_key(rp, fl);
8962 + fl->fl4_src = ipv4root;
8963 + err = __ip_route_output_key(rp, fl);
8968 + foundsrc = (*rp)->rt_src;
8971 + for (i=0; i<n; i++){
8972 + u32 mask = nxi->mask[i];
8973 + u32 ipv4 = nxi->ipv4[i];
8974 + u32 net4 = ipv4 & mask;
8976 + if (foundsrc == ipv4) {
8977 + fl->fl4_src = ipv4;
8980 + if (!fl->fl4_src && (foundsrc & mask) == net4)
8981 + fl->fl4_src = ipv4;
8984 + if (fl->fl4_src == 0)
8985 + fl->fl4_src = (fl->fl4_dst == IPI_LOOPBACK)
8986 + ? IPI_LOOPBACK : ipv4root;
8988 + for (i=0; i<n; i++) {
8989 + if (nxi->ipv4[i] == fl->fl4_src)
8998 static inline int ip_route_connect(struct rtable **rp, u32 dst,
8999 u32 src, u32 tos, int oif, u8 protocol,
9000 u16 sport, u16 dport, struct sock *sk)
9001 @@ -157,7 +212,23 @@ static inline int ip_route_connect(struc
9002 .dport = dport } } };
9005 - if (!dst || !src) {
9006 + struct nx_info *nx_info = current->nx_info;
9009 + nx_info = sk->sk_nx_info;
9010 + vxdprintk(VXD_CBIT(net, 4),
9011 + "ip_route_connect(%p) %p,%p;%lx",
9012 + sk, nx_info, sk->sk_socket,
9013 + (sk->sk_socket?sk->sk_socket->flags:0));
9016 + err = ip_find_src(nx_info, rp, &fl);
9019 + if (fl.fl4_dst == IPI_LOOPBACK && !vx_check(0, VX_ADMIN))
9020 + fl.fl4_dst = nx_info->ipv4[0];
9022 + if (!fl.fl4_dst || !fl.fl4_src) {
9023 err = __ip_route_output_key(rp, &fl);
9026 diff -NurpP --minimal linux-2.6.10/include/net/scm.h linux-2.6.10-vs1.9.3.17/include/net/scm.h
9027 --- linux-2.6.10/include/net/scm.h 2004-08-14 12:55:32.000000000 +0200
9028 +++ linux-2.6.10-vs1.9.3.17/include/net/scm.h 2004-12-26 19:40:29.000000000 +0100
9029 @@ -51,13 +51,13 @@ static __inline__ void scm_recv(struct s
9031 if (!msg->msg_control)
9033 - if (sock->passcred || scm->fp)
9034 + if (test_bit(SOCK_PASS_CRED, &sock->flags) || scm->fp)
9035 msg->msg_flags |= MSG_CTRUNC;
9040 - if (sock->passcred)
9041 + if (test_bit(SOCK_PASS_CRED, &sock->flags))
9042 put_cmsg(msg, SOL_SOCKET, SCM_CREDENTIALS, sizeof(scm->creds), &scm->creds);
9045 diff -NurpP --minimal linux-2.6.10/include/net/sock.h linux-2.6.10-vs1.9.3.17/include/net/sock.h
9046 --- linux-2.6.10/include/net/sock.h 2004-12-25 01:55:30.000000000 +0100
9047 +++ linux-2.6.10-vs1.9.3.17/include/net/sock.h 2004-12-26 19:40:29.000000000 +0100
9048 @@ -110,6 +110,10 @@ struct sock_common {
9049 struct hlist_node skc_node;
9050 struct hlist_node skc_bind_node;
9051 atomic_t skc_refcnt;
9053 + struct vx_info *skc_vx_info;
9055 + struct nx_info *skc_nx_info;
9059 @@ -191,6 +195,10 @@ struct sock {
9060 #define sk_node __sk_common.skc_node
9061 #define sk_bind_node __sk_common.skc_bind_node
9062 #define sk_refcnt __sk_common.skc_refcnt
9063 +#define sk_xid __sk_common.skc_xid
9064 +#define sk_vx_info __sk_common.skc_vx_info
9065 +#define sk_nid __sk_common.skc_nid
9066 +#define sk_nx_info __sk_common.skc_nx_info
9067 volatile unsigned char sk_zapped;
9068 unsigned char sk_shutdown;
9069 unsigned char sk_use_write_queue;
9070 diff -NurpP --minimal linux-2.6.10/include/net/tcp.h linux-2.6.10-vs1.9.3.17/include/net/tcp.h
9071 --- linux-2.6.10/include/net/tcp.h 2004-12-25 01:55:30.000000000 +0100
9072 +++ linux-2.6.10-vs1.9.3.17/include/net/tcp.h 2004-12-26 19:40:36.000000000 +0100
9073 @@ -192,6 +192,10 @@ struct tcp_tw_bucket {
9074 #define tw_node __tw_common.skc_node
9075 #define tw_bind_node __tw_common.skc_bind_node
9076 #define tw_refcnt __tw_common.skc_refcnt
9077 +#define tw_xid __tw_common.skc_xid
9078 +#define tw_vx_info __tw_common.skc_vx_info
9079 +#define tw_nid __tw_common.skc_nid
9080 +#define tw_nx_info __tw_common.skc_nx_info
9081 volatile unsigned char tw_substate;
9082 unsigned char tw_rcv_wscale;
9084 @@ -486,8 +490,8 @@ static __inline__ int tcp_sk_listen_hash
9085 so that we select tick to get range about 4 seconds.
9088 -#if HZ <= 16 || HZ > 4096
9089 -# error Unsupported: HZ <= 16 or HZ > 4096
9090 +#if HZ <= 16 || HZ > 32768
9091 +# error Unsupported: HZ <= 16 or HZ > 32768
9093 # define TCP_TW_RECYCLE_TICK (5+2-TCP_TW_RECYCLE_SLOTS_LOG)
9095 @@ -502,8 +506,14 @@ static __inline__ int tcp_sk_listen_hash
9096 # define TCP_TW_RECYCLE_TICK (10+2-TCP_TW_RECYCLE_SLOTS_LOG)
9098 # define TCP_TW_RECYCLE_TICK (11+2-TCP_TW_RECYCLE_SLOTS_LOG)
9101 # define TCP_TW_RECYCLE_TICK (12+2-TCP_TW_RECYCLE_SLOTS_LOG)
9103 +# define TCP_TW_RECYCLE_TICK (13+2-TCP_TW_RECYCLE_SLOTS_LOG)
9105 +# define TCP_TW_RECYCLE_TICK (14+2-TCP_TW_RECYCLE_SLOTS_LOG)
9107 +# define TCP_TW_RECYCLE_TICK (15+2-TCP_TW_RECYCLE_SLOTS_LOG)
9110 #define BICTCP_1_OVER_BETA 8 /*
9111 diff -NurpP --minimal linux-2.6.10/init/main.c linux-2.6.10-vs1.9.3.17/init/main.c
9112 --- linux-2.6.10/init/main.c 2004-12-25 01:55:30.000000000 +0100
9113 +++ linux-2.6.10-vs1.9.3.17/init/main.c 2004-12-26 19:40:36.000000000 +0100
9114 @@ -216,8 +216,8 @@ void __devinit calibrate_delay(void)
9115 loops_per_jiffy = preset_lpj;
9116 printk("Calibrating delay loop (skipped)... "
9117 "%lu.%02lu BogoMIPS preset\n",
9118 - loops_per_jiffy/(500000/HZ),
9119 - (loops_per_jiffy/(5000/HZ)) % 100);
9120 + HZ*(loops_per_jiffy >> 3)/62500,
9121 + (HZ*(loops_per_jiffy >> 3)/625) % 100);
9123 loops_per_jiffy = (1<<12);
9125 @@ -254,8 +254,8 @@ void __devinit calibrate_delay(void)
9127 /* Round the value and print it */
9128 printk("%lu.%02lu BogoMIPS (lpj=%lu)\n",
9129 - loops_per_jiffy/(500000/HZ),
9130 - (loops_per_jiffy/(5000/HZ)) % 100,
9131 + HZ*(loops_per_jiffy >> 3)/62500,
9132 + (HZ*(loops_per_jiffy >> 3)/625) % 100,
9136 diff -NurpP --minimal linux-2.6.10/ipc/msg.c linux-2.6.10-vs1.9.3.17/ipc/msg.c
9137 --- linux-2.6.10/ipc/msg.c 2004-12-25 01:55:30.000000000 +0100
9138 +++ linux-2.6.10-vs1.9.3.17/ipc/msg.c 2004-12-26 19:40:29.000000000 +0100
9139 @@ -97,6 +97,7 @@ static int newque (key_t key, int msgflg
9141 msq->q_perm.mode = (msgflg & S_IRWXUGO);
9142 msq->q_perm.key = key;
9143 + msq->q_perm.xid = vx_current_xid();
9145 msq->q_perm.security = NULL;
9146 retval = security_msg_queue_alloc(msq);
9147 @@ -817,7 +818,11 @@ static int sysvipc_msg_read_proc(char *b
9148 for(i = 0; i <= msg_ids.max_id; i++) {
9149 struct msg_queue * msq;
9153 + if (!vx_check(msq->q_perm.xid, VX_IDENT)) {
9157 len += sprintf(buffer + len, "%10d %10d %4o %10lu %10lu %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu\n",
9159 msg_buildid(i,msq->q_perm.seq),
9160 diff -NurpP --minimal linux-2.6.10/ipc/sem.c linux-2.6.10-vs1.9.3.17/ipc/sem.c
9161 --- linux-2.6.10/ipc/sem.c 2004-12-25 01:55:30.000000000 +0100
9162 +++ linux-2.6.10-vs1.9.3.17/ipc/sem.c 2004-12-26 19:40:29.000000000 +0100
9163 @@ -176,6 +176,7 @@ static int newary (key_t key, int nsems,
9165 sma->sem_perm.mode = (semflg & S_IRWXUGO);
9166 sma->sem_perm.key = key;
9167 + sma->sem_perm.xid = vx_current_xid();
9169 sma->sem_perm.security = NULL;
9170 retval = security_sem_alloc(sma);
9171 @@ -1329,7 +1330,11 @@ static int sysvipc_sem_read_proc(char *b
9172 for(i = 0; i <= sem_ids.max_id; i++) {
9173 struct sem_array *sma;
9177 + if (!vx_check(sma->sem_perm.xid, VX_IDENT)) {
9181 len += sprintf(buffer + len, "%10d %10d %4o %10lu %5u %5u %5u %5u %10lu %10lu\n",
9183 sem_buildid(i,sma->sem_perm.seq),
9184 diff -NurpP --minimal linux-2.6.10/ipc/shm.c linux-2.6.10-vs1.9.3.17/ipc/shm.c
9185 --- linux-2.6.10/ipc/shm.c 2004-12-25 01:55:30.000000000 +0100
9186 +++ linux-2.6.10-vs1.9.3.17/ipc/shm.c 2004-12-26 19:40:29.000000000 +0100
9187 @@ -193,6 +193,7 @@ static int newseg (key_t key, int shmflg
9190 shp->shm_perm.key = key;
9191 + shp->shm_perm.xid = vx_current_xid();
9192 shp->shm_flags = (shmflg & S_IRWXUGO);
9193 shp->mlock_user = NULL;
9195 @@ -865,11 +866,15 @@ static int sysvipc_shm_read_proc(char *b
9196 struct shmid_kernel* shp;
9201 #define SMALL_STRING "%10d %10d %4o %10u %5u %5u %5d %5u %5u %5u %5u %10lu %10lu %10lu\n"
9202 #define BIG_STRING "%10d %10d %4o %21u %5u %5u %5d %5u %5u %5u %5u %10lu %10lu %10lu\n"
9205 + if (!vx_check(shp->shm_perm.xid, VX_IDENT)) {
9209 if (sizeof(size_t) <= sizeof(int))
9210 format = SMALL_STRING;
9212 diff -NurpP --minimal linux-2.6.10/ipc/util.c linux-2.6.10-vs1.9.3.17/ipc/util.c
9213 --- linux-2.6.10/ipc/util.c 2004-12-25 01:55:30.000000000 +0100
9214 +++ linux-2.6.10-vs1.9.3.17/ipc/util.c 2004-12-26 19:40:29.000000000 +0100
9215 @@ -107,7 +107,9 @@ int ipc_findkey(struct ipc_ids* ids, key
9217 for (id = 0; id <= max_id; id++) {
9218 p = ids->entries->p[id];
9222 + if (!vx_check(p->xid, VX_IDENT))
9226 @@ -420,6 +422,8 @@ int ipcperms (struct kern_ipc_perm *ipcp
9227 { /* flag will most probably be 0 or S_...UGO from <linux/stat.h> */
9228 int requested_mode, granted_mode;
9230 + if (!vx_check(ipcp->xid, VX_ADMIN|VX_IDENT)) /* maybe just VX_IDENT? */
9232 requested_mode = (flag >> 6) | (flag >> 3) | flag;
9233 granted_mode = ipcp->mode;
9234 if (current->euid == ipcp->cuid || current->euid == ipcp->uid)
9235 diff -NurpP --minimal linux-2.6.10/kernel/Makefile linux-2.6.10-vs1.9.3.17/kernel/Makefile
9236 --- linux-2.6.10/kernel/Makefile 2004-12-25 01:55:30.000000000 +0100
9237 +++ linux-2.6.10-vs1.9.3.17/kernel/Makefile 2004-12-26 19:40:23.000000000 +0100
9238 @@ -9,6 +9,9 @@ obj-y = sched.o fork.o exec_domain.o
9239 rcupdate.o intermodule.o extable.o params.o posix-timers.o \
9240 kthread.o wait.o kfifo.o sys_ni.o
9242 +subdir-y += vserver
9243 +obj-y += vserver/vserver.o
9245 obj-$(CONFIG_FUTEX) += futex.o
9246 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
9247 obj-$(CONFIG_SMP) += cpu.o spinlock.o
9248 diff -NurpP --minimal linux-2.6.10/kernel/capability.c linux-2.6.10-vs1.9.3.17/kernel/capability.c
9249 --- linux-2.6.10/kernel/capability.c 2004-12-25 01:55:30.000000000 +0100
9250 +++ linux-2.6.10-vs1.9.3.17/kernel/capability.c 2004-12-26 19:40:14.000000000 +0100
9252 #include <linux/module.h>
9253 #include <linux/security.h>
9254 #include <linux/syscalls.h>
9255 +#include <linux/vs_cvirt.h>
9257 #include <asm/uaccess.h>
9259 unsigned securebits = SECUREBITS_DEFAULT; /* systemwide security settings */
9260 diff -NurpP --minimal linux-2.6.10/kernel/exit.c linux-2.6.10-vs1.9.3.17/kernel/exit.c
9261 --- linux-2.6.10/kernel/exit.c 2004-12-25 01:55:30.000000000 +0100
9262 +++ linux-2.6.10-vs1.9.3.17/kernel/exit.c 2004-12-26 19:40:35.000000000 +0100
9264 #include <linux/proc_fs.h>
9265 #include <linux/mempolicy.h>
9266 #include <linux/syscalls.h>
9267 +#include <linux/vs_limit.h>
9269 #include <asm/uaccess.h>
9270 #include <asm/unistd.h>
9271 @@ -40,6 +41,11 @@ int getrusage(struct task_struct *, int,
9272 static void __unhash_process(struct task_struct *p)
9275 + /* tasklist_lock is held, is this sufficient? */
9277 + atomic_dec(&p->vx_info->cvirt.nr_threads);
9280 detach_pid(p, PIDTYPE_PID);
9281 detach_pid(p, PIDTYPE_TGID);
9282 if (thread_group_leader(p)) {
9283 @@ -226,6 +232,7 @@ void reparent_to_init(void)
9284 ptrace_unlink(current);
9285 /* Reparent to init */
9286 REMOVE_LINKS(current);
9287 + /* FIXME handle vchild_reaper/initpid */
9288 current->parent = child_reaper;
9289 current->real_parent = child_reaper;
9291 @@ -370,6 +377,7 @@ static inline void close_files(struct fi
9292 struct file * file = xchg(&files->fd[i], NULL);
9294 filp_close(file, files);
9295 + // vx_openfd_dec(i);
9299 @@ -593,6 +601,7 @@ static inline void forget_original_paren
9300 struct task_struct *p, *reaper = father;
9301 struct list_head *_p, *_n;
9303 + /* FIXME handle vchild_reaper/initpid */
9305 reaper = next_thread(reaper);
9306 if (reaper == father) {
9307 diff -NurpP --minimal linux-2.6.10/kernel/fork.c linux-2.6.10-vs1.9.3.17/kernel/fork.c
9308 --- linux-2.6.10/kernel/fork.c 2004-12-25 01:55:30.000000000 +0100
9309 +++ linux-2.6.10-vs1.9.3.17/kernel/fork.c 2005-01-03 01:23:16.000000000 +0100
9311 #include <linux/audit.h>
9312 #include <linux/profile.h>
9313 #include <linux/rmap.h>
9314 +#include <linux/vs_network.h>
9315 +#include <linux/vs_limit.h>
9316 +#include <linux/vs_memory.h>
9318 #include <asm/pgtable.h>
9319 #include <asm/pgalloc.h>
9320 @@ -81,6 +84,8 @@ static kmem_cache_t *task_struct_cachep;
9321 void free_task(struct task_struct *tsk)
9323 free_thread_info(tsk->thread_info);
9324 + clr_vx_info(&tsk->vx_info);
9325 + clr_nx_info(&tsk->nx_info);
9326 free_task_struct(tsk);
9328 EXPORT_SYMBOL(free_task);
9329 @@ -302,6 +307,7 @@ static struct mm_struct * mm_init(struct
9331 if (likely(!mm_alloc_pgd(mm))) {
9333 + set_vx_info(&mm->mm_vx_info, current->vx_info);
9337 @@ -333,6 +339,7 @@ void fastcall __mmdrop(struct mm_struct
9338 BUG_ON(mm == &init_mm);
9340 destroy_context(mm);
9341 + clr_vx_info(&mm->mm_vx_info);
9345 @@ -459,6 +466,7 @@ static int copy_mm(unsigned long clone_f
9347 /* Copy the current MM stuff.. */
9348 memcpy(mm, oldmm, sizeof(*mm));
9349 + mm->mm_vx_info = NULL;
9353 @@ -791,6 +799,7 @@ static task_t *copy_process(unsigned lon
9356 struct task_struct *p = NULL;
9357 + struct vx_info *vxi;
9359 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
9360 return ERR_PTR(-EINVAL);
9361 @@ -819,12 +828,32 @@ static task_t *copy_process(unsigned lon
9365 + p->vx_info = NULL;
9366 + set_vx_info(&p->vx_info, current->vx_info);
9367 + p->nx_info = NULL;
9368 + set_nx_info(&p->nx_info, current->nx_info);
9370 + /* check vserver memory */
9371 + if (p->mm && !(clone_flags & CLONE_VM)) {
9372 + if (vx_vmpages_avail(p->mm, p->mm->total_vm))
9373 + vx_pages_add(p->mm->mm_vx_info, RLIMIT_AS, p->mm->total_vm);
9375 + goto bad_fork_free;
9377 + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
9378 + if (!vx_rsspages_avail(p->mm, p->mm->rss))
9379 + goto bad_fork_cleanup_vm;
9383 + if (!vx_nproc_avail(1))
9384 + goto bad_fork_cleanup_vm;
9386 if (atomic_read(&p->user->processes) >=
9387 p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
9388 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
9389 p->user != &root_user)
9390 - goto bad_fork_free;
9391 + goto bad_fork_cleanup_vm;
9394 atomic_inc(&p->user->__count);
9395 @@ -1020,6 +1049,12 @@ static task_t *copy_process(unsigned lon
9399 + /* p is copy of current */
9402 + atomic_inc(&vxi->cvirt.nr_threads);
9405 write_unlock_irq(&tasklist_lock);
9408 @@ -1062,6 +1097,9 @@ bad_fork_cleanup_count:
9409 put_group_info(p->group_info);
9410 atomic_dec(&p->user->processes);
9412 +bad_fork_cleanup_vm:
9413 + if (p->mm && !(clone_flags & CLONE_VM))
9414 + vx_pages_sub(p->mm->mm_vx_info, RLIMIT_AS, p->mm->total_vm);
9418 diff -NurpP --minimal linux-2.6.10/kernel/kthread.c linux-2.6.10-vs1.9.3.17/kernel/kthread.c
9419 --- linux-2.6.10/kernel/kthread.c 2004-08-14 12:56:22.000000000 +0200
9420 +++ linux-2.6.10-vs1.9.3.17/kernel/kthread.c 2004-12-26 19:40:30.000000000 +0100
9421 @@ -108,7 +108,7 @@ static void keventd_create_kthread(void
9422 create->result = ERR_PTR(pid);
9424 wait_for_completion(&create->started);
9425 - create->result = find_task_by_pid(pid);
9426 + create->result = find_task_by_real_pid(pid);
9428 complete(&create->done);
9430 diff -NurpP --minimal linux-2.6.10/kernel/posix-timers.c linux-2.6.10-vs1.9.3.17/kernel/posix-timers.c
9431 --- linux-2.6.10/kernel/posix-timers.c 2004-12-25 01:55:30.000000000 +0100
9432 +++ linux-2.6.10-vs1.9.3.17/kernel/posix-timers.c 2004-12-26 19:40:30.000000000 +0100
9434 #include <linux/syscalls.h>
9435 #include <linux/wait.h>
9436 #include <linux/workqueue.h>
9437 +#include <linux/vs_cvirt.h>
9439 #ifndef div_long_long_rem
9440 #include <asm/div64.h>
9441 @@ -469,7 +470,7 @@ static inline struct task_struct * good_
9442 struct task_struct *rtn = current->group_leader;
9444 if ((event->sigev_notify & SIGEV_THREAD_ID ) &&
9445 - (!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) ||
9446 + (!(rtn = find_task_by_real_pid(event->sigev_notify_thread_id)) ||
9447 rtn->tgid != current->tgid ||
9448 (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))
9450 diff -NurpP --minimal linux-2.6.10/kernel/printk.c linux-2.6.10-vs1.9.3.17/kernel/printk.c
9451 --- linux-2.6.10/kernel/printk.c 2004-12-25 01:55:30.000000000 +0100
9452 +++ linux-2.6.10-vs1.9.3.17/kernel/printk.c 2004-12-26 19:40:36.000000000 +0100
9453 @@ -251,7 +251,10 @@ int do_syslog(int type, char __user * bu
9454 unsigned long i, j, limit, count;
9458 + int error = -EPERM;
9460 + if (!vx_check(0, VX_ADMIN|VX_WATCH))
9463 error = security_syslog(type);
9465 @@ -521,6 +524,8 @@ asmlinkage int printk(const char *fmt, .
9469 +static volatile int printk_cpu = -1;
9471 asmlinkage int vprintk(const char *fmt, va_list args)
9473 unsigned long flags;
9474 @@ -529,11 +534,12 @@ asmlinkage int vprintk(const char *fmt,
9475 static char printk_buf[1024];
9476 static int log_level_unknown = 1;
9478 - if (unlikely(oops_in_progress))
9479 + if (unlikely(oops_in_progress && printk_cpu == smp_processor_id()))
9482 /* This stops the holder of console_sem just where we want him */
9483 spin_lock_irqsave(&logbuf_lock, flags);
9484 + printk_cpu = smp_processor_id();
9486 /* Emit the output into the temporary buffer */
9487 printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args);
9488 diff -NurpP --minimal linux-2.6.10/kernel/sched.c linux-2.6.10-vs1.9.3.17/kernel/sched.c
9489 --- linux-2.6.10/kernel/sched.c 2004-12-25 01:55:30.000000000 +0100
9490 +++ linux-2.6.10-vs1.9.3.17/kernel/sched.c 2004-12-26 19:40:30.000000000 +0100
9492 #include <asm/tlb.h>
9494 #include <asm/unistd.h>
9495 +#include <linux/vs_context.h>
9496 +#include <linux/vs_cvirt.h>
9497 +#include <linux/vs_sched.h>
9500 #define cpu_to_node_mask(cpu) node_to_cpumask(cpu_to_node(cpu))
9501 @@ -244,6 +247,10 @@ struct runqueue {
9502 task_t *migration_thread;
9503 struct list_head migration_queue;
9505 +#ifdef CONFIG_VSERVER_HARDCPU
9506 + struct list_head hold_queue;
9510 #ifdef CONFIG_SCHEDSTATS
9512 @@ -617,6 +624,9 @@ static int effective_prio(task_t *p)
9513 bonus = CURRENT_BONUS(p) - MAX_BONUS / 2;
9515 prio = p->static_prio - bonus;
9516 + if (task_vx_flags(p, VXF_SCHED_PRIO, 0))
9517 + prio += effective_vavavoom(p, MAX_USER_PRIO);
9519 if (prio < MAX_RT_PRIO)
9521 if (prio > MAX_PRIO-1)
9522 @@ -762,19 +772,27 @@ static void activate_task(task_t *p, run
9526 + vx_activate_task(p);
9527 __activate_task(p, rq);
9531 * deactivate_task - remove a task from the runqueue.
9533 -static void deactivate_task(struct task_struct *p, runqueue_t *rq)
9534 +static void __deactivate_task(struct task_struct *p, runqueue_t *rq)
9537 dequeue_task(p, p->array);
9542 +void deactivate_task(struct task_struct *p, runqueue_t *rq)
9544 + vx_deactivate_task(p);
9545 + __deactivate_task(p, rq);
9549 * resched_task - mark a task 'to be rescheduled now'.
9551 @@ -1109,6 +1127,9 @@ out_activate:
9552 * to be considered on this CPU.)
9554 activate_task(p, rq, cpu == this_cpu);
9555 + /* this is to get the accounting behind the load update */
9556 + if (old_state == TASK_UNINTERRUPTIBLE)
9557 + vx_uninterruptible_dec(p);
9558 if (!sync || cpu != this_cpu) {
9559 if (TASK_PREEMPTS_CURR(p, rq))
9560 resched_task(rq->curr);
9561 @@ -1231,6 +1252,7 @@ void fastcall wake_up_new_task(task_t *
9563 p->prio = effective_prio(p);
9565 + vx_activate_task(p);
9566 if (likely(cpu == this_cpu)) {
9567 if (!(clone_flags & CLONE_VM)) {
9569 @@ -2287,12 +2309,18 @@ void scheduler_tick(int user_ticks, int
9570 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
9571 runqueue_t *rq = this_rq();
9572 task_t *p = current;
9573 + struct vx_info *vxi = p->vx_info;
9575 rq->timestamp_last_tick = sched_clock();
9577 if (rcu_pending(cpu))
9578 rcu_check_callbacks(cpu, user_ticks);
9581 + vxi->sched.cpu[cpu].user_ticks += user_ticks;
9582 + vxi->sched.cpu[cpu].sys_ticks += sys_ticks;
9585 /* note: this timer irq context must be accounted for as well */
9586 if (hardirq_count() - HARDIRQ_OFFSET) {
9587 cpustat->irq += sys_ticks;
9588 @@ -2305,10 +2333,18 @@ void scheduler_tick(int user_ticks, int
9589 if (p == rq->idle) {
9590 if (atomic_read(&rq->nr_iowait) > 0)
9591 cpustat->iowait += sys_ticks;
9592 + // vx_cpustat_acc(vxi, iowait, cpu, cpustat, sys_ticks);
9594 cpustat->idle += sys_ticks;
9595 + // vx_cpustat_acc(vxi, idle, cpu, cpustat, sys_ticks);
9597 if (wake_priority_sleeper(rq))
9600 +#ifdef CONFIG_VSERVER_HARDCPU_IDLE
9601 + if (!--rq->idle_tokens && !list_empty(&rq->hold_queue))
9602 + set_need_resched();
9604 rebalance_tick(cpu, rq, SCHED_IDLE);
9607 @@ -2347,7 +2383,7 @@ void scheduler_tick(int user_ticks, int
9611 - if (!--p->time_slice) {
9612 + if (vx_need_resched(p)) {
9613 dequeue_task(p, rq->active);
9614 set_tsk_need_resched(p);
9615 p->prio = effective_prio(p);
9616 @@ -2533,6 +2569,10 @@ asmlinkage void __sched schedule(void)
9617 struct list_head *queue;
9618 unsigned long long now;
9619 unsigned long run_time;
9620 +#ifdef CONFIG_VSERVER_HARDCPU
9621 + struct vx_info *vxi;
9622 + int maxidle = -HZ;
9627 @@ -2596,12 +2636,53 @@ need_resched_nonpreemptible:
9628 unlikely(signal_pending(prev))))
9629 prev->state = TASK_RUNNING;
9631 - if (prev->state == TASK_UNINTERRUPTIBLE)
9632 + if (prev->state == TASK_UNINTERRUPTIBLE) {
9633 rq->nr_uninterruptible++;
9634 + vx_uninterruptible_inc(prev);
9636 deactivate_task(prev, rq);
9640 +#ifdef CONFIG_VSERVER_HARDCPU
9641 + if (!list_empty(&rq->hold_queue)) {
9642 + struct list_head *l, *n;
9646 + list_for_each_safe(l, n, &rq->hold_queue) {
9647 + next = list_entry(l, task_t, run_list);
9648 + if (vxi == next->vx_info)
9651 + vxi = next->vx_info;
9652 + ret = vx_tokens_recalc(vxi);
9653 + // tokens = vx_tokens_avail(next);
9656 + list_del(&next->run_list);
9657 + next->state &= ~TASK_ONHOLD;
9658 + // one less waiting
9659 + vx_onhold_dec(vxi);
9660 + array = rq->expired;
9661 + next->prio = MAX_PRIO-1;
9662 + enqueue_task(next, array);
9664 + if (next->static_prio < rq->best_expired_prio)
9665 + rq->best_expired_prio = next->static_prio;
9667 + // printk("··· %8lu unhold %p [%d]\n", jiffies, next, next->prio);
9670 + if ((ret < 0) && (maxidle < ret))
9674 + rq->idle_tokens = -maxidle;
9679 cpu = smp_processor_id();
9680 if (unlikely(!rq->nr_running)) {
9682 @@ -2650,6 +2731,26 @@ go_idle:
9683 queue = array->queue + idx;
9684 next = list_entry(queue->next, task_t, run_list);
9686 +#ifdef CONFIG_VSERVER_HARDCPU
9687 + vxi = next->vx_info;
9688 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE|VXF_SCHED_HARD, 0)) {
9689 + int ret = vx_tokens_recalc(vxi);
9691 + if (unlikely(ret <= 0)) {
9692 + if (ret && (rq->idle_tokens > -ret))
9693 + rq->idle_tokens = -ret;
9694 + __deactivate_task(next, rq);
9695 + recalc_task_prio(next, now);
9696 + // a new one on hold
9697 + vx_onhold_inc(vxi);
9698 + next->state |= TASK_ONHOLD;
9699 + list_add_tail(&next->run_list, &rq->hold_queue);
9700 + //printk("··· %8lu hold %p [%d]\n", jiffies, next, next->prio);
9706 if (!rt_task(next) && next->activated > 0) {
9707 unsigned long long delta = now - next->timestamp;
9709 @@ -3009,6 +3110,8 @@ asmlinkage long sys_nice(int increment)
9710 * and we have a single winner.
9712 if (increment < 0) {
9713 + if (vx_flags(VXF_IGNEG_NICE, 0))
9715 if (!capable(CAP_SYS_NICE))
9717 if (increment < -40)
9718 @@ -3166,6 +3269,7 @@ recheck:
9720 __setscheduler(p, policy, lp.sched_priority);
9722 + vx_activate_task(p);
9723 __activate_task(p, task_rq(p));
9725 * Reschedule if we are currently running on this runqueue and
9726 @@ -4596,6 +4700,9 @@ void __init sched_init(void)
9727 rq->migration_thread = NULL;
9728 INIT_LIST_HEAD(&rq->migration_queue);
9730 +#ifdef CONFIG_VSERVER_HARDCPU
9731 + INIT_LIST_HEAD(&rq->hold_queue);
9733 atomic_set(&rq->nr_iowait, 0);
9735 for (j = 0; j < 2; j++) {
9736 diff -NurpP --minimal linux-2.6.10/kernel/signal.c linux-2.6.10-vs1.9.3.17/kernel/signal.c
9737 --- linux-2.6.10/kernel/signal.c 2004-12-25 01:55:30.000000000 +0100
9738 +++ linux-2.6.10-vs1.9.3.17/kernel/signal.c 2004-12-26 19:40:30.000000000 +0100
9739 @@ -621,17 +621,26 @@ static int check_kill_permission(int sig
9740 struct task_struct *t)
9742 int error = -EINVAL;
9745 if (sig < 0 || sig > _NSIG)
9748 + user = (!info || ((unsigned long)info != 1 &&
9749 + (unsigned long)info != 2 && SI_FROMUSER(info)));
9752 - if ((!info || ((unsigned long)info != 1 &&
9753 - (unsigned long)info != 2 && SI_FROMUSER(info)))
9754 - && ((sig != SIGCONT) ||
9755 + if (user && ((sig != SIGCONT) ||
9756 (current->signal->session != t->signal->session))
9757 && (current->euid ^ t->suid) && (current->euid ^ t->uid)
9758 && (current->uid ^ t->suid) && (current->uid ^ t->uid)
9759 && !capable(CAP_KILL))
9763 + if (user && !vx_check(vx_task_xid(t), VX_ADMIN|VX_IDENT))
9766 return security_task_kill(t, info, sig);
9769 diff -NurpP --minimal linux-2.6.10/kernel/sys.c linux-2.6.10-vs1.9.3.17/kernel/sys.c
9770 --- linux-2.6.10/kernel/sys.c 2004-12-25 01:55:30.000000000 +0100
9771 +++ linux-2.6.10-vs1.9.3.17/kernel/sys.c 2004-12-26 19:40:35.000000000 +0100
9773 #include <linux/mman.h>
9774 #include <linux/smp_lock.h>
9775 #include <linux/notifier.h>
9776 +#include <linux/kmod.h>
9777 #include <linux/reboot.h>
9778 #include <linux/prctl.h>
9779 #include <linux/init.h>
9781 #include <linux/security.h>
9782 #include <linux/dcookies.h>
9783 #include <linux/suspend.h>
9784 +#include <linux/vs_cvirt.h>
9786 #include <linux/compat.h>
9787 #include <linux/syscalls.h>
9788 @@ -225,7 +227,10 @@ static int set_one_prio(struct task_stru
9791 if (niceval < task_nice(p) && !capable(CAP_SYS_NICE)) {
9793 + if (vx_flags(VXF_IGNEG_NICE, 0))
9799 no_nice = security_task_setnice(p, niceval);
9800 @@ -277,7 +282,8 @@ asmlinkage long sys_setpriority(int whic
9804 - if ((who != current->uid) && !(user = find_user(who)))
9805 + if ((who != current->uid) &&
9806 + !(user = find_user(vx_current_xid(), who)))
9807 goto out_unlock; /* No processes for this user */
9809 do_each_thread(g, p)
9810 @@ -335,7 +341,8 @@ asmlinkage long sys_getpriority(int whic
9814 - if ((who != current->uid) && !(user = find_user(who)))
9815 + if ((who != current->uid) &&
9816 + !(user = find_user(vx_current_xid(), who)))
9817 goto out_unlock; /* No processes for this user */
9819 do_each_thread(g, p)
9820 @@ -355,6 +362,7 @@ out_unlock:
9824 +long vs_reboot(unsigned int, void *);
9827 * Reboot system call: for obvious reasons only root may call it,
9828 @@ -380,6 +388,9 @@ asmlinkage long sys_reboot(int magic1, i
9829 magic2 != LINUX_REBOOT_MAGIC2C))
9832 + if (!vx_check(0, VX_ADMIN|VX_WATCH))
9833 + return vs_reboot(cmd, arg);
9837 case LINUX_REBOOT_CMD_RESTART:
9838 @@ -577,7 +588,7 @@ static int set_user(uid_t new_ruid, int
9840 struct user_struct *new_user;
9842 - new_user = alloc_uid(new_ruid);
9843 + new_user = alloc_uid(vx_current_xid(), new_ruid);
9847 @@ -946,14 +957,17 @@ asmlinkage long sys_setpgid(pid_t pid, p
9849 struct task_struct *p;
9854 - pid = current->pid;
9855 + pid = vx_map_pid(current->pid);
9861 + rpgid = vx_rmap_pid(pgid);
9863 /* From this point forward we keep holding onto the tasklist lock
9864 * so that our parent does not change from under us. -DaveM
9866 @@ -988,22 +1002,22 @@ asmlinkage long sys_setpgid(pid_t pid, p
9868 struct task_struct *p;
9870 - do_each_task_pid(pgid, PIDTYPE_PGID, p) {
9871 + do_each_task_pid(rpgid, PIDTYPE_PGID, p) {
9872 if (p->signal->session == current->signal->session)
9874 - } while_each_task_pid(pgid, PIDTYPE_PGID, p);
9875 + } while_each_task_pid(rpgid, PIDTYPE_PGID, p);
9880 - err = security_task_setpgid(p, pgid);
9881 + err = security_task_setpgid(p, rpgid);
9885 - if (process_group(p) != pgid) {
9886 + if (process_group(p) != rpgid) {
9887 detach_pid(p, PIDTYPE_PGID);
9888 - p->signal->pgrp = pgid;
9889 - attach_pid(p, PIDTYPE_PGID, pgid);
9890 + p->signal->pgrp = rpgid;
9891 + attach_pid(p, PIDTYPE_PGID, rpgid);
9895 @@ -1016,7 +1030,7 @@ out:
9896 asmlinkage long sys_getpgid(pid_t pid)
9899 - return process_group(current);
9900 + return vx_rmap_pid(process_group(current));
9903 struct task_struct *p;
9904 @@ -1028,7 +1042,7 @@ asmlinkage long sys_getpgid(pid_t pid)
9906 retval = security_task_getpgid(p);
9908 - retval = process_group(p);
9909 + retval = vx_rmap_pid(process_group(p));
9911 read_unlock(&tasklist_lock);
9913 @@ -1364,7 +1378,7 @@ asmlinkage long sys_newuname(struct new_
9916 down_read(&uts_sem);
9917 - if (copy_to_user(name,&system_utsname,sizeof *name))
9918 + if (copy_to_user(name, vx_new_utsname(), sizeof *name))
9922 @@ -1375,15 +1389,17 @@ asmlinkage long sys_sethostname(char __u
9924 char tmp[__NEW_UTS_LEN];
9926 - if (!capable(CAP_SYS_ADMIN))
9927 + if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SET_UTSNAME))
9929 if (len < 0 || len > __NEW_UTS_LEN)
9931 down_write(&uts_sem);
9933 if (!copy_from_user(tmp, name, len)) {
9934 - memcpy(system_utsname.nodename, tmp, len);
9935 - system_utsname.nodename[len] = 0;
9936 + char *ptr = vx_new_uts(nodename);
9938 + memcpy(ptr, tmp, len);
9943 @@ -1395,15 +1411,17 @@ asmlinkage long sys_sethostname(char __u
9944 asmlinkage long sys_gethostname(char __user *name, int len)
9951 down_read(&uts_sem);
9952 - i = 1 + strlen(system_utsname.nodename);
9953 + ptr = vx_new_uts(nodename);
9954 + i = 1 + strlen(ptr);
9958 - if (copy_to_user(name, system_utsname.nodename, i))
9959 + if (copy_to_user(name, ptr, i))
9963 @@ -1420,7 +1438,7 @@ asmlinkage long sys_setdomainname(char _
9965 char tmp[__NEW_UTS_LEN];
9967 - if (!capable(CAP_SYS_ADMIN))
9968 + if (!capable(CAP_SYS_ADMIN) && !vx_ccaps(VXC_SET_UTSNAME))
9970 if (len < 0 || len > __NEW_UTS_LEN)
9972 @@ -1428,8 +1446,10 @@ asmlinkage long sys_setdomainname(char _
9973 down_write(&uts_sem);
9975 if (!copy_from_user(tmp, name, len)) {
9976 - memcpy(system_utsname.domainname, tmp, len);
9977 - system_utsname.domainname[len] = 0;
9978 + char *ptr = vx_new_uts(domainname);
9980 + memcpy(ptr, tmp, len);
9985 @@ -1486,7 +1506,7 @@ asmlinkage long sys_setrlimit(unsigned i
9987 old_rlim = current->signal->rlim + resource;
9988 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
9989 - !capable(CAP_SYS_RESOURCE))
9990 + !capable(CAP_SYS_RESOURCE) && !vx_ccaps(VXC_SET_RLIMIT))
9992 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
9994 diff -NurpP --minimal linux-2.6.10/kernel/sysctl.c linux-2.6.10-vs1.9.3.17/kernel/sysctl.c
9995 --- linux-2.6.10/kernel/sysctl.c 2004-12-25 01:55:30.000000000 +0100
9996 +++ linux-2.6.10-vs1.9.3.17/kernel/sysctl.c 2004-12-26 19:40:34.000000000 +0100
9997 @@ -86,6 +86,7 @@ extern char modprobe_path[];
9998 #ifdef CONFIG_HOTPLUG
9999 extern char hotplug_path[];
10001 +extern char vshelper_path[];
10002 #ifdef CONFIG_CHR_DEV_SG
10003 extern int sg_big_buff;
10005 @@ -400,6 +401,15 @@ static ctl_table kern_table[] = {
10006 .strategy = &sysctl_string,
10010 + .ctl_name = KERN_VSHELPER,
10011 + .procname = "vshelper",
10012 + .data = &vshelper_path,
10015 + .proc_handler = &proc_dostring,
10016 + .strategy = &sysctl_string,
10018 #ifdef CONFIG_CHR_DEV_SG
10020 .ctl_name = KERN_SG_BIG_BUFF,
10021 diff -NurpP --minimal linux-2.6.10/kernel/timer.c linux-2.6.10-vs1.9.3.17/kernel/timer.c
10022 --- linux-2.6.10/kernel/timer.c 2004-12-25 01:55:30.000000000 +0100
10023 +++ linux-2.6.10-vs1.9.3.17/kernel/timer.c 2004-12-26 19:40:36.000000000 +0100
10025 #include <linux/jiffies.h>
10026 #include <linux/cpu.h>
10027 #include <linux/syscalls.h>
10028 +#include <linux/vs_cvirt.h>
10029 +#include <linux/vserver/sched.h>
10031 #include <asm/uaccess.h>
10032 #include <asm/unistd.h>
10033 @@ -677,7 +679,11 @@ static void second_overflow(void)
10034 if (ltemp > (MAXPHASE / MINSEC) << SHIFT_UPDATE)
10035 ltemp = (MAXPHASE / MINSEC) << SHIFT_UPDATE;
10036 time_offset += ltemp;
10037 + #if SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE > 0
10038 time_adj = -ltemp << (SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE);
10040 + time_adj = -ltemp >> (SHIFT_HZ + SHIFT_UPDATE - SHIFT_SCALE);
10043 ltemp = time_offset;
10044 if (!(time_status & STA_FLL))
10045 @@ -685,7 +691,11 @@ static void second_overflow(void)
10046 if (ltemp > (MAXPHASE / MINSEC) << SHIFT_UPDATE)
10047 ltemp = (MAXPHASE / MINSEC) << SHIFT_UPDATE;
10048 time_offset -= ltemp;
10049 + #if SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE > 0
10050 time_adj = ltemp << (SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE);
10052 + time_adj = ltemp >> (SHIFT_HZ + SHIFT_UPDATE - SHIFT_SCALE);
10057 @@ -1006,7 +1016,7 @@ asmlinkage unsigned long sys_alarm(unsig
10059 asmlinkage long sys_getpid(void)
10061 - return current->tgid;
10062 + return vx_map_tgid(current->tgid);
10066 @@ -1050,7 +1060,7 @@ asmlinkage long sys_getppid(void)
10071 + return vx_map_pid(pid);
10074 asmlinkage long sys_getuid(void)
10075 @@ -1258,6 +1268,8 @@ asmlinkage long sys_sysinfo(struct sysin
10076 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
10079 + if (vx_flags(VXF_VIRT_UPTIME, 0))
10080 + vx_vsi_uptime(&tp, NULL);
10081 val.uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
10083 val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
10084 @@ -1267,6 +1279,9 @@ asmlinkage long sys_sysinfo(struct sysin
10085 val.procs = nr_threads;
10086 } while (read_seqretry(&xtime_lock, seq));
10088 +/* if (vx_flags(VXF_VIRT_CPU, 0))
10094 diff -NurpP --minimal linux-2.6.10/kernel/user.c linux-2.6.10-vs1.9.3.17/kernel/user.c
10095 --- linux-2.6.10/kernel/user.c 2004-12-25 01:55:30.000000000 +0100
10096 +++ linux-2.6.10-vs1.9.3.17/kernel/user.c 2004-12-26 19:40:29.000000000 +0100
10098 #define UIDHASH_BITS 8
10099 #define UIDHASH_SZ (1 << UIDHASH_BITS)
10100 #define UIDHASH_MASK (UIDHASH_SZ - 1)
10101 -#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
10102 -#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid)))
10103 +#define __uidhashfn(xid,uid) ((((uid) >> UIDHASH_BITS) + ((uid)^(xid))) & UIDHASH_MASK)
10104 +#define uidhashentry(xid,uid) (uidhash_table + __uidhashfn((xid),(uid)))
10106 static kmem_cache_t *uid_cachep;
10107 static struct list_head uidhash_table[UIDHASH_SZ];
10108 @@ -54,7 +54,7 @@ static inline void uid_hash_remove(struc
10109 list_del(&up->uidhash_list);
10112 -static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
10113 +static inline struct user_struct *uid_hash_find(xid_t xid, uid_t uid, struct list_head *hashent)
10115 struct list_head *up;
10117 @@ -63,7 +63,7 @@ static inline struct user_struct *uid_ha
10119 user = list_entry(up, struct user_struct, uidhash_list);
10121 - if(user->uid == uid) {
10122 + if(user->uid == uid && user->xid == xid) {
10123 atomic_inc(&user->__count);
10126 @@ -78,12 +78,12 @@ static inline struct user_struct *uid_ha
10128 * If the user_struct could not be found, return NULL.
10130 -struct user_struct *find_user(uid_t uid)
10131 +struct user_struct *find_user(xid_t xid, uid_t uid)
10133 struct user_struct *ret;
10135 spin_lock(&uidhash_lock);
10136 - ret = uid_hash_find(uid, uidhashentry(uid));
10137 + ret = uid_hash_find(xid, uid, uidhashentry(xid, uid));
10138 spin_unlock(&uidhash_lock);
10141 @@ -99,13 +99,13 @@ void free_uid(struct user_struct *up)
10145 -struct user_struct * alloc_uid(uid_t uid)
10146 +struct user_struct * alloc_uid(xid_t xid, uid_t uid)
10148 - struct list_head *hashent = uidhashentry(uid);
10149 + struct list_head *hashent = uidhashentry(xid, uid);
10150 struct user_struct *up;
10152 spin_lock(&uidhash_lock);
10153 - up = uid_hash_find(uid, hashent);
10154 + up = uid_hash_find(xid, uid, hashent);
10155 spin_unlock(&uidhash_lock);
10158 @@ -115,6 +115,7 @@ struct user_struct * alloc_uid(uid_t uid
10163 atomic_set(&new->__count, 1);
10164 atomic_set(&new->processes, 0);
10165 atomic_set(&new->files, 0);
10166 @@ -133,7 +134,7 @@ struct user_struct * alloc_uid(uid_t uid
10167 * on adding the same user already..
10169 spin_lock(&uidhash_lock);
10170 - up = uid_hash_find(uid, hashent);
10171 + up = uid_hash_find(xid, uid, hashent);
10173 key_put(new->uid_keyring);
10174 key_put(new->session_keyring);
10175 @@ -179,7 +180,7 @@ static int __init uid_cache_init(void)
10177 /* Insert the root user immediately (init already runs as root) */
10178 spin_lock(&uidhash_lock);
10179 - uid_hash_insert(&root_user, uidhashentry(0));
10180 + uid_hash_insert(&root_user, uidhashentry(0,0));
10181 spin_unlock(&uidhash_lock);
10184 diff -NurpP --minimal linux-2.6.10/kernel/vserver/Kconfig linux-2.6.10-vs1.9.3.17/kernel/vserver/Kconfig
10185 --- linux-2.6.10/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
10186 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/Kconfig 2005-01-02 09:44:49.000000000 +0100
10189 +# Linux VServer configuration
10192 +menu "Linux VServer"
10194 +config VSERVER_LEGACY
10195 + bool "Enable Legacy Kernel API"
10198 + This enables the legacy API used in vs1.xx, which allows
10199 + to use older tools (for migration purposes).
10201 +config VSERVER_PROC_SECURE
10202 + bool "Enable Proc Security"
10203 + depends on PROC_FS
10206 + Hide proc entries by default for xid>1
10208 +config VSERVER_HARDCPU
10209 + bool "Enable Hard CPU Limits"
10210 + depends on EXPERIMENTAL
10213 + Activate the Hard CPU Limits
10215 +config VSERVER_HARDCPU_IDLE
10216 + bool "Limit the IDLE task"
10217 + depends on VSERVER_HARDCPU
10220 + Limit the idle slices, so the the next context
10221 + will be scheduled as soon as possible.
10222 + might improve interactivity/latency but
10223 + increases scheduling overhead.
10226 + prompt "Persistent Inode Context Tagging"
10227 + default INOXID_UGID24
10229 + This adds persistent context information to filesystems
10230 + mounted with the tagxid option. Tagging is a requirement
10231 + for per context disk limits and per context quota.
10234 +config INOXID_NONE
10237 + no context information is store for inodes
10239 +config INOXID_UID16
10240 + bool "UID16/GID32"
10242 + reduces UID to 16 bit, but leaves GID at 32 bit.
10244 +config INOXID_GID16
10245 + bool "UID32/GID16"
10247 + reduces GID to 16 bit, but leaves UID at 32 bit.
10249 +config INOXID_UGID24
10250 + bool "UID24/GID24"
10252 + uses the upper 8bit from UID and GID for XID tagging
10253 + which leaves 24bit for UID/GID each, which should be
10254 + more than sufficient for normal use.
10256 +config INOXID_INTERN
10257 + bool "UID32/GID32"
10259 + this uses otherwise reserved inode fields in the on
10260 + disk representation, which limits the use to a few
10261 + filesystems (currently ext2 and ext3)
10263 +config INOXID_RUNTIME
10265 + depends on EXPERIMENTAL
10267 + inodes are tagged when first accessed, this doesn't
10268 + require any persistant information, but might give
10269 + funny results for mixed access.
10273 +config VSERVER_DEBUG
10274 + bool "Compile Debugging Code"
10277 + Set this to yes if you want to be able to activate
10278 + debugging output at runtime. It adds a probably small
10279 + overhead (~ ??%) to all vserver related functions and
10280 + increases the kernel size by about 20k.
10282 +config VSERVER_HISTORY
10283 + bool "Compile History Tracing"
10284 + depends on VSERVER_DEBUG
10287 + Set this to yes if you want to record the history of
10288 + linux-vserver activities, so they can be replayed on
10289 + a kernel panic (oops)
10291 +config VSERVER_HISTORY_SIZE
10292 + int "Per CPU History Size (32-65536)"
10293 + depends on VSERVER_HISTORY
10297 + This allows you to specify the number of entries in
10298 + the per CPU history buffer.
10302 diff -NurpP --minimal linux-2.6.10/kernel/vserver/Makefile linux-2.6.10-vs1.9.3.17/kernel/vserver/Makefile
10303 --- linux-2.6.10/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
10304 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/Makefile 2005-01-02 09:44:49.000000000 +0100
10307 +# Makefile for the Linux vserver routines.
10311 +obj-y += vserver.o
10313 +vserver-y := switch.o context.o namespace.o sched.o network.o inode.o \
10314 + limit.o cvirt.o signal.o proc.o helper.o init.o dlimit.o
10316 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o
10317 +vserver-$(CONFIG_VSERVER_LEGACY) += legacy.o
10318 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
10320 diff -NurpP --minimal linux-2.6.10/kernel/vserver/context.c linux-2.6.10-vs1.9.3.17/kernel/vserver/context.c
10321 --- linux-2.6.10/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
10322 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/context.c 2005-01-05 15:51:26.000000000 +0100
10325 + * linux/kernel/vserver/context.c
10327 + * Virtual Server: Context Support
10329 + * Copyright (C) 2003-2005 Herbert Pötzl
10331 + * V0.01 context helper
10332 + * V0.02 vx_ctx_kill syscall command
10333 + * V0.03 replaced context_info calls
10334 + * V0.04 redesign of struct (de)alloc
10335 + * V0.05 rlimit basic implementation
10336 + * V0.06 task_xid and info commands
10337 + * V0.07 context flags and caps
10338 + * V0.08 switch to RCU based hash
10339 + * V0.09 revert to non RCU for now
10340 + * V0.10 and back to working RCU hash
10344 +#include <linux/config.h>
10345 +#include <linux/slab.h>
10346 +#include <linux/types.h>
10347 +#include <linux/namespace.h>
10349 +#include <linux/sched.h>
10350 +#include <linux/vserver/network.h>
10351 +#include <linux/vserver/legacy.h>
10352 +#include <linux/vserver/limit.h>
10353 +#include <linux/vserver/debug.h>
10355 +#include <linux/vs_context.h>
10356 +#include <linux/vserver/context_cmd.h>
10358 +#include <asm/errno.h>
10360 +#include "cvirt_init.h"
10361 +#include "limit_init.h"
10362 +#include "sched_init.h"
10365 +/* __alloc_vx_info()
10367 + * allocate an initialized vx_info struct
10368 + * doesn't make it visible (hash) */
10370 +static struct vx_info *__alloc_vx_info(xid_t xid)
10372 + struct vx_info *new = NULL;
10374 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
10376 + /* would this benefit from a slab cache? */
10377 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
10381 + memset (new, 0, sizeof(struct vx_info));
10382 + new->vx_id = xid;
10383 + INIT_RCU_HEAD(&new->vx_rcu);
10384 + INIT_HLIST_NODE(&new->vx_hlist);
10385 + atomic_set(&new->vx_refcnt, 0);
10386 + atomic_set(&new->vx_usecnt, 0);
10387 + new->vx_parent = NULL;
10388 + new->vx_state = 0;
10389 + new->vx_lock = SPIN_LOCK_UNLOCKED;
10390 + init_waitqueue_head(&new->vx_exit);
10392 + /* rest of init goes here */
10393 + vx_info_init_limit(&new->limit);
10394 + vx_info_init_sched(&new->sched);
10395 + vx_info_init_cvirt(&new->cvirt);
10396 + vx_info_init_cacct(&new->cacct);
10399 + new->vx_flags = VXF_STATE_SETUP|VXF_STATE_INIT;
10400 + new->vx_bcaps = CAP_INIT_EFF_SET;
10401 + new->vx_ccaps = 0;
10403 + vxdprintk(VXD_CBIT(xid, 0),
10404 + "alloc_vx_info(%d) = %p", xid, new);
10405 + vxh_alloc_vx_info(new);
10409 +/* __dealloc_vx_info()
10411 + * final disposal of vx_info */
10413 +static void __dealloc_vx_info(struct vx_info *vxi)
10415 + vxdprintk(VXD_CBIT(xid, 0),
10416 + "dealloc_vx_info(%p)", vxi);
10417 + vxh_dealloc_vx_info(vxi);
10419 + vxi->vx_hlist.next = LIST_POISON1;
10422 + vx_info_exit_limit(&vxi->limit);
10423 + vx_info_exit_sched(&vxi->sched);
10424 + vx_info_exit_cvirt(&vxi->cvirt);
10425 + vx_info_exit_cacct(&vxi->cacct);
10428 + BUG_ON(atomic_read(&vxi->vx_usecnt));
10429 + BUG_ON(atomic_read(&vxi->vx_refcnt));
10431 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
10432 + // BUG_ON(!vx_state(vxi, VXS_DEFUNCT));
10434 + vxi->vx_state |= VXS_RELEASED;
10438 +static inline int __free_vx_info(struct vx_info *vxi)
10440 + int usecnt, refcnt;
10444 + usecnt = atomic_read(&vxi->vx_usecnt);
10445 + BUG_ON(usecnt < 0);
10447 + refcnt = atomic_read(&vxi->vx_refcnt);
10448 + BUG_ON(refcnt < 0);
10451 + __dealloc_vx_info(vxi);
10455 +static void __rcu_put_vx_info(struct rcu_head *head)
10457 + struct vx_info *vxi = container_of(head, struct vx_info, vx_rcu);
10459 + vxdprintk(VXD_CBIT(xid, 3),
10460 + "__rcu_put_vx_info(%p[#%d]): %d,%d",
10462 + atomic_read(&vxi->vx_usecnt),
10463 + atomic_read(&vxi->vx_refcnt));
10464 + put_vx_info(vxi);
10467 +void __shutdown_vx_info(struct vx_info *vxi)
10469 + struct namespace *namespace;
10470 + struct fs_struct *fs;
10474 + namespace = xchg(&vxi->vx_namespace, NULL);
10476 + put_namespace(namespace);
10478 + fs = xchg(&vxi->vx_fs, NULL);
10480 + put_fs_struct(fs);
10483 +/* exported stuff */
10485 +void free_vx_info(struct vx_info *vxi)
10487 + /* context shutdown is mandatory */
10488 + // BUG_ON(vxi->vx_state != VXS_SHUTDOWN);
10490 + BUG_ON(vxi->vx_state & VXS_HASHED);
10492 + BUG_ON(vxi->vx_namespace);
10493 + BUG_ON(vxi->vx_fs);
10495 + BUG_ON(__free_vx_info(vxi));
10499 +/* hash table for vx_info hash */
10501 +#define VX_HASH_SIZE 13
10503 +struct hlist_head vx_info_hash[VX_HASH_SIZE];
10505 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
10508 +static inline unsigned int __hashval(xid_t xid)
10510 + return (xid % VX_HASH_SIZE);
10515 +/* __hash_vx_info()
10517 + * add the vxi to the global hash table
10518 + * requires the hash_lock to be held */
10520 +static inline void __hash_vx_info(struct vx_info *vxi)
10522 + struct hlist_head *head;
10524 + vxdprintk(VXD_CBIT(xid, 4),
10525 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
10526 + vxh_hash_vx_info(vxi);
10528 + get_vx_info(vxi);
10529 + vxi->vx_state |= VXS_HASHED;
10530 + head = &vx_info_hash[__hashval(vxi->vx_id)];
10531 + hlist_add_head_rcu(&vxi->vx_hlist, head);
10534 +/* __unhash_vx_info()
10536 + * remove the vxi from the global hash table
10537 + * requires the hash_lock to be held */
10539 +static inline void __unhash_vx_info(struct vx_info *vxi)
10541 + vxdprintk(VXD_CBIT(xid, 4),
10542 + "__unhash_vx_info: %p[#%d]", vxi, vxi->vx_id);
10543 + vxh_unhash_vx_info(vxi);
10545 + vxi->vx_state &= ~VXS_HASHED;
10546 + hlist_del_rcu(&vxi->vx_hlist);
10548 + call_rcu(&vxi->vx_rcu, __rcu_put_vx_info);
10552 +/* __lookup_vx_info()
10554 + * requires the rcu_read_lock()
10555 + * doesn't increment the vx_refcnt */
10557 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
10559 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
10560 + struct hlist_node *pos;
10561 + struct vx_info *vxi;
10563 + hlist_for_each_rcu(pos, head) {
10564 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
10566 + if ((vxi->vx_id == xid) &&
10567 + vx_info_state(vxi, VXS_HASHED))
10572 + vxdprintk(VXD_CBIT(xid, 0),
10573 + "__lookup_vx_info(#%u): %p[#%u]",
10574 + xid, vxi, vxi?vxi->vx_id:0);
10575 + vxh_lookup_vx_info(xid, vxi);
10580 +/* __vx_dynamic_id()
10582 + * find unused dynamic xid
10583 + * requires the rcu_read_lock()
10584 + * requires the hash_lock to be held */
10586 +static inline xid_t __vx_dynamic_id(void)
10588 + static xid_t seq = MAX_S_CONTEXT;
10589 + xid_t barrier = seq;
10592 + if (++seq > MAX_S_CONTEXT)
10593 + seq = MIN_D_CONTEXT;
10594 + if (!__lookup_vx_info(seq)) {
10595 + vxdprintk(VXD_CBIT(xid, 4),
10596 + "__vx_dynamic_id: [#%d]", seq);
10599 + } while (barrier != seq);
10603 +/* __loc_vx_info()
10605 + * locate or create the requested context
10606 + * get() it and if new hash it */
10608 +static struct vx_info * __loc_vx_info(int id, int *err)
10610 + struct vx_info *new, *vxi = NULL;
10612 + vxdprintk(VXD_CBIT(xid, 1), "loc_vx_info(%d)*", id);
10614 + if (!(new = __alloc_vx_info(id))) {
10619 + /* FIXME is this required at all ? */
10621 + /* required to make dynamic xids unique */
10622 + spin_lock(&vx_info_hash_lock);
10624 + /* dynamic context requested */
10625 + if (id == VX_DYNAMIC_ID) {
10626 + id = __vx_dynamic_id();
10628 + printk(KERN_ERR "no dynamic context available.\n");
10633 + /* existing context requested */
10634 + else if ((vxi = __lookup_vx_info(id))) {
10635 + /* context in setup is not available */
10636 + if (vxi->vx_flags & VXF_STATE_SETUP) {
10637 + vxdprintk(VXD_CBIT(xid, 0),
10638 + "loc_vx_info(%d) = %p (not available)", id, vxi);
10642 + vxdprintk(VXD_CBIT(xid, 0),
10643 + "loc_vx_info(%d) = %p (found)", id, vxi);
10644 + get_vx_info(vxi);
10650 + /* new context requested */
10651 + vxdprintk(VXD_CBIT(xid, 0),
10652 + "loc_vx_info(%d) = %p (new)", id, new);
10653 + __hash_vx_info(get_vx_info(new));
10654 + vxi = new, new = NULL;
10658 + spin_unlock(&vx_info_hash_lock);
10659 + rcu_read_unlock();
10660 + vxh_loc_vx_info(id, vxi);
10662 + __dealloc_vx_info(new);
10668 +/* exported stuff */
10671 +void unhash_vx_info(struct vx_info *vxi)
10673 + __shutdown_vx_info(vxi);
10674 + spin_lock(&vx_info_hash_lock);
10675 + __unhash_vx_info(vxi);
10676 + spin_unlock(&vx_info_hash_lock);
10679 +/* locate_vx_info()
10681 + * search for a vx_info and get() it
10682 + * negative id means current */
10684 +struct vx_info *locate_vx_info(int id)
10686 + struct vx_info *vxi;
10689 + vxi = get_vx_info(current->vx_info);
10692 + vxi = get_vx_info(__lookup_vx_info(id));
10693 + rcu_read_unlock();
10698 +/* vx_info_is_hashed()
10700 + * verify that xid is still hashed */
10702 +int vx_info_is_hashed(xid_t xid)
10707 + hashed = (__lookup_vx_info(xid) != NULL);
10708 + rcu_read_unlock();
10712 +#ifdef CONFIG_VSERVER_LEGACY
10715 +struct vx_info *alloc_vx_info(xid_t xid)
10717 + return __alloc_vx_info(xid);
10721 +struct vx_info *locate_or_create_vx_info(int id)
10725 + return __loc_vx_info(id, &err);
10730 +#ifdef CONFIG_PROC_FS
10732 +int get_xid_list(int index, unsigned int *xids, int size)
10734 + int hindex, nr_xids = 0;
10737 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
10738 + struct hlist_head *head = &vx_info_hash[hindex];
10739 + struct hlist_node *pos;
10741 + hlist_for_each_rcu(pos, head) {
10742 + struct vx_info *vxi;
10747 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
10748 + xids[nr_xids] = vxi->vx_id;
10749 + if (++nr_xids >= size)
10754 + rcu_read_unlock();
10759 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
10761 + struct user_struct *new_user, *old_user;
10765 + new_user = alloc_uid(vxi->vx_id, p->uid);
10769 + old_user = p->user;
10770 + if (new_user != old_user) {
10771 + atomic_inc(&new_user->processes);
10772 + atomic_dec(&old_user->processes);
10773 + p->user = new_user;
10775 + free_uid(old_user);
10779 +void vx_mask_bcaps(struct task_struct *p)
10781 + struct vx_info *vxi = p->vx_info;
10783 + p->cap_effective &= vxi->vx_bcaps;
10784 + p->cap_inheritable &= vxi->vx_bcaps;
10785 + p->cap_permitted &= vxi->vx_bcaps;
10789 +#include <linux/file.h>
10791 +static inline int vx_nofiles_task(struct task_struct *tsk)
10793 + struct files_struct *files = tsk->files;
10794 + unsigned long *obptr;
10795 + int count, total;
10797 + spin_lock(&files->file_lock);
10798 + obptr = files->open_fds->fds_bits;
10799 + count = files->max_fds / (sizeof(unsigned long) * 8);
10800 + for (total = 0; count > 0; count--) {
10802 + total += hweight_long(*obptr);
10805 + spin_unlock(&files->file_lock);
10811 +static inline int vx_openfd_task(struct task_struct *tsk)
10813 + struct files_struct *files = tsk->files;
10814 + const unsigned long *bptr;
10815 + int count, total;
10817 + spin_lock(&files->file_lock);
10818 + bptr = files->open_fds->fds_bits;
10819 + count = files->max_fds / (sizeof(unsigned long) * 8);
10820 + for (total = 0; count > 0; count--) {
10822 + total += hweight_long(*bptr);
10825 + spin_unlock(&files->file_lock);
10832 + * migrate task to new context
10833 + * gets vxi, puts old_vxi on change
10836 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi)
10838 + struct vx_info *old_vxi;
10844 + old_vxi = task_get_vx_info(p);
10845 + if (old_vxi == vxi)
10848 + vxdprintk(VXD_CBIT(xid, 5),
10849 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
10850 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
10852 + if (!(ret = vx_migrate_user(p, vxi))) {
10856 + // openfd = vx_openfd_task(p);
10857 + nofiles = vx_nofiles_task(p);
10860 + atomic_dec(&old_vxi->cvirt.nr_threads);
10861 + atomic_dec(&old_vxi->cvirt.nr_running);
10862 + atomic_dec(&old_vxi->limit.rcur[RLIMIT_NPROC]);
10863 + /* FIXME: what about the struct files here? */
10864 + // atomic_sub(nofiles, &old_vxi->limit.rcur[RLIMIT_NOFILE]);
10865 + // atomic_sub(openfd, &old_vxi->limit.rcur[RLIMIT_OPENFD]);
10867 + atomic_inc(&vxi->cvirt.nr_threads);
10868 + atomic_inc(&vxi->cvirt.nr_running);
10869 + atomic_inc(&vxi->limit.rcur[RLIMIT_NPROC]);
10870 + /* FIXME: what about the struct files here? */
10871 + // atomic_add(nofiles, &vxi->limit.rcur[RLIMIT_NOFILE]);
10872 + // atomic_add(openfd, &vxi->limit.rcur[RLIMIT_OPENFD]);
10874 + vxdprintk(VXD_CBIT(xid, 5),
10875 + "moved task %p into vxi:%p[#%d]",
10876 + p, vxi, vxi->vx_id);
10878 + /* should be handled in set_vx_info !! */
10880 + clr_vx_info(&p->vx_info);
10881 + set_vx_info(&p->vx_info, vxi);
10882 + p->xid = vxi->vx_id;
10883 + vx_mask_bcaps(p);
10886 + /* obsoleted by clr/set */
10887 + // put_vx_info(old_vxi);
10890 + put_vx_info(old_vxi);
10894 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
10898 + if (vxi->vx_initpid)
10901 + vxdprintk(VXD_CBIT(xid, 6),
10902 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
10903 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
10905 + vxi->vx_initpid = p->tgid;
10910 +/* vserver syscall commands below here */
10912 +/* taks xid and vx_info functions */
10914 +#include <asm/uaccess.h>
10917 +int vc_task_xid(uint32_t id, void __user *data)
10922 + struct task_struct *tsk;
10924 + if (!vx_check(0, VX_ADMIN|VX_WATCH))
10927 + read_lock(&tasklist_lock);
10928 + tsk = find_task_by_real_pid(id);
10929 + xid = (tsk) ? tsk->xid : -ESRCH;
10930 + read_unlock(&tasklist_lock);
10933 + xid = vx_current_xid();
10938 +int vc_vx_info(uint32_t id, void __user *data)
10940 + struct vx_info *vxi;
10941 + struct vcmd_vx_info_v0 vc_data;
10943 + if (!vx_check(0, VX_ADMIN))
10945 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RESOURCE))
10948 + vxi = locate_vx_info(id);
10952 + vc_data.xid = vxi->vx_id;
10953 + vc_data.initpid = vxi->vx_initpid;
10954 + put_vx_info(vxi);
10956 + if (copy_to_user (data, &vc_data, sizeof(vc_data)))
10962 +/* context functions */
10964 +int vc_ctx_create(uint32_t xid, void __user *data)
10966 + struct vx_info *new_vxi;
10969 + if (!capable(CAP_SYS_ADMIN))
10972 + if ((xid >= MIN_D_CONTEXT) && (xid != VX_DYNAMIC_ID))
10978 + new_vxi = __loc_vx_info(xid, &ret);
10981 + if (!(new_vxi->vx_flags & VXF_STATE_SETUP)) {
10986 + ret = new_vxi->vx_id;
10987 + vx_migrate_task(current, new_vxi);
10988 + /* if this fails, we might end up with a hashed vx_info */
10990 + put_vx_info(new_vxi);
10995 +int vc_ctx_migrate(uint32_t id, void __user *data)
10997 + struct vx_info *vxi;
10999 + if (!capable(CAP_SYS_ADMIN))
11002 + /* dirty hack until Spectator becomes a cap */
11004 + current->xid = 1;
11008 + vxi = locate_vx_info(id);
11011 + vx_migrate_task(current, vxi);
11012 + put_vx_info(vxi);
11017 +int vc_get_cflags(uint32_t id, void __user *data)
11019 + struct vx_info *vxi;
11020 + struct vcmd_ctx_flags_v0 vc_data;
11022 + if (!capable(CAP_SYS_ADMIN))
11025 + vxi = locate_vx_info(id);
11029 + vc_data.flagword = vxi->vx_flags;
11031 + /* special STATE flag handling */
11032 + vc_data.mask = vx_mask_flags(~0UL, vxi->vx_flags, VXF_ONE_TIME);
11034 + put_vx_info(vxi);
11036 + if (copy_to_user (data, &vc_data, sizeof(vc_data)))
11041 +int vc_set_cflags(uint32_t id, void __user *data)
11043 + struct vx_info *vxi;
11044 + struct vcmd_ctx_flags_v0 vc_data;
11045 + uint64_t mask, trigger;
11047 + if (!capable(CAP_SYS_ADMIN))
11049 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
11052 + vxi = locate_vx_info(id);
11056 + /* special STATE flag handling */
11057 + mask = vx_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
11058 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
11060 + if (trigger & VXF_STATE_SETUP)
11061 + vx_mask_bcaps(current);
11062 + if (trigger & VXF_STATE_INIT)
11063 + if (vxi == current->vx_info)
11064 + vx_set_init(vxi, current);
11066 + vxi->vx_flags = vx_mask_flags(vxi->vx_flags,
11067 + vc_data.flagword, mask);
11068 + put_vx_info(vxi);
11072 +int vc_get_ccaps(uint32_t id, void __user *data)
11074 + struct vx_info *vxi;
11075 + struct vcmd_ctx_caps_v0 vc_data;
11077 + if (!capable(CAP_SYS_ADMIN))
11080 + vxi = locate_vx_info(id);
11084 + vc_data.bcaps = vxi->vx_bcaps;
11085 + vc_data.ccaps = vxi->vx_ccaps;
11086 + vc_data.cmask = ~0UL;
11087 + put_vx_info(vxi);
11089 + if (copy_to_user (data, &vc_data, sizeof(vc_data)))
11094 +int vc_set_ccaps(uint32_t id, void __user *data)
11096 + struct vx_info *vxi;
11097 + struct vcmd_ctx_caps_v0 vc_data;
11099 + if (!capable(CAP_SYS_ADMIN))
11101 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
11104 + vxi = locate_vx_info(id);
11108 + vxi->vx_bcaps &= vc_data.bcaps;
11109 + vxi->vx_ccaps = vx_mask_flags(vxi->vx_ccaps,
11110 + vc_data.ccaps, vc_data.cmask);
11111 + put_vx_info(vxi);
11115 +#include <linux/module.h>
11117 +EXPORT_SYMBOL_GPL(free_vx_info);
11118 +EXPORT_SYMBOL_GPL(unhash_vx_info);
11120 diff -NurpP --minimal linux-2.6.10/kernel/vserver/cvirt.c linux-2.6.10-vs1.9.3.17/kernel/vserver/cvirt.c
11121 --- linux-2.6.10/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
11122 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/cvirt.c 2004-12-26 19:40:30.000000000 +0100
11125 + * linux/kernel/vserver/cvirt.c
11127 + * Virtual Server: Context Virtualization
11129 + * Copyright (C) 2004 Herbert Pötzl
11131 + * V0.01 broken out from limit.c
11135 +#include <linux/config.h>
11136 +#include <linux/sched.h>
11137 +#include <linux/types.h>
11138 +#include <linux/vs_context.h>
11139 +#include <linux/vs_cvirt.h>
11140 +#include <linux/vserver/switch.h>
11142 +#include <asm/errno.h>
11143 +#include <asm/uaccess.h>
11146 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
11148 + struct vx_info *vxi = current->vx_info;
11150 + set_normalized_timespec(uptime,
11151 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
11152 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
11155 + set_normalized_timespec(idle,
11156 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
11157 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
11161 +uint64_t vx_idle_jiffies(void)
11163 + return init_task.utime + init_task.stime;
11168 +static inline uint32_t __update_loadavg(uint32_t load,
11169 + int wsize, int delta, int n)
11171 + unsigned long long calc, prev;
11173 + /* just set it to n */
11174 + if (unlikely(delta >= wsize))
11175 + return (n << FSHIFT);
11177 + calc = delta * n;
11179 + prev = (wsize - delta);
11182 + do_div(calc, wsize);
11187 +void vx_update_load(struct vx_info *vxi)
11189 + uint32_t now, last, delta;
11190 + unsigned int nr_running, nr_uninterruptible;
11191 + unsigned int total;
11193 + spin_lock(&vxi->cvirt.load_lock);
11196 + last = vxi->cvirt.load_last;
11197 + delta = now - last;
11199 + if (delta < 5*HZ)
11202 + nr_running = atomic_read(&vxi->cvirt.nr_running);
11203 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
11204 + total = nr_running + nr_uninterruptible;
11206 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
11207 + 60*HZ, delta, total);
11208 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
11209 + 5*60*HZ, delta, total);
11210 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
11211 + 15*60*HZ, delta, total);
11213 + vxi->cvirt.load_last = now;
11215 + atomic_inc(&vxi->cvirt.load_updates);
11216 + spin_unlock(&vxi->cvirt.load_lock);
11221 diff -NurpP --minimal linux-2.6.10/kernel/vserver/cvirt_init.h linux-2.6.10-vs1.9.3.17/kernel/vserver/cvirt_init.h
11222 --- linux-2.6.10/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
11223 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/cvirt_init.h 2004-12-26 19:40:36.000000000 +0100
11226 +extern uint64_t vx_idle_jiffies(void);
11228 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
11230 + uint64_t idle_jiffies = vx_idle_jiffies();
11231 + uint64_t nsuptime;
11233 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
11234 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
11235 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
11236 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
11238 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
11239 + atomic_set(&cvirt->nr_threads, 0);
11240 + atomic_set(&cvirt->nr_running, 0);
11241 + atomic_set(&cvirt->nr_uninterruptible, 0);
11242 + atomic_set(&cvirt->nr_onhold, 0);
11244 + down_read(&uts_sem);
11245 + cvirt->utsname = system_utsname;
11246 + up_read(&uts_sem);
11248 + spin_lock_init(&cvirt->load_lock);
11249 + cvirt->load_last = jiffies;
11250 + atomic_set(&cvirt->load_updates, 0);
11251 + cvirt->load[0] = 0;
11252 + cvirt->load[1] = 0;
11253 + cvirt->load[2] = 0;
11256 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
11258 +#ifdef CONFIG_VSERVER_DEBUG
11261 + vxwprintk((value = atomic_read(&cvirt->nr_threads)),
11262 + "!!! cvirt: %p[nr_threads] = %d on exit.",
11264 + vxwprintk((value = atomic_read(&cvirt->nr_running)),
11265 + "!!! cvirt: %p[nr_running] = %d on exit.",
11267 + vxwprintk((value = atomic_read(&cvirt->nr_uninterruptible)),
11268 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
11274 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
11278 + for (i=0; i<5; i++) {
11279 + for (j=0; j<3; j++) {
11280 + atomic_set(&cacct->sock[i][j].count, 0);
11281 + atomic_set(&cacct->sock[i][j].total, 0);
11286 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
11291 diff -NurpP --minimal linux-2.6.10/kernel/vserver/cvirt_proc.h linux-2.6.10-vs1.9.3.17/kernel/vserver/cvirt_proc.h
11292 --- linux-2.6.10/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
11293 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/cvirt_proc.h 2004-12-26 19:40:36.000000000 +0100
11295 +#ifndef _VX_CVIRT_PROC_H
11296 +#define _VX_CVIRT_PROC_H
11298 +#include <linux/sched.h>
11301 +#define LOAD_INT(x) ((x) >> FSHIFT)
11302 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
11304 +static inline int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
11309 + length += sprintf(buffer + length,
11310 + "BiasUptime:\t%lu.%02lu\n",
11311 + (unsigned long)cvirt->bias_uptime.tv_sec,
11312 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
11313 + length += sprintf(buffer + length,
11314 + "SysName:\t%.*s\n"
11315 + "NodeName:\t%.*s\n"
11316 + "Release:\t%.*s\n"
11317 + "Version:\t%.*s\n"
11318 + "Machine:\t%.*s\n"
11319 + "DomainName:\t%.*s\n"
11320 + ,__NEW_UTS_LEN, cvirt->utsname.sysname
11321 + ,__NEW_UTS_LEN, cvirt->utsname.nodename
11322 + ,__NEW_UTS_LEN, cvirt->utsname.release
11323 + ,__NEW_UTS_LEN, cvirt->utsname.version
11324 + ,__NEW_UTS_LEN, cvirt->utsname.machine
11325 + ,__NEW_UTS_LEN, cvirt->utsname.domainname
11328 + a = cvirt->load[0] + (FIXED_1/200);
11329 + b = cvirt->load[1] + (FIXED_1/200);
11330 + c = cvirt->load[2] + (FIXED_1/200);
11331 + length += sprintf(buffer + length,
11332 + "nr_threads:\t%d\n"
11333 + "nr_running:\t%d\n"
11334 + "nr_unintr:\t%d\n"
11335 + "nr_onhold:\t%d\n"
11336 + "load_updates:\t%d\n"
11337 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
11338 + ,atomic_read(&cvirt->nr_threads)
11339 + ,atomic_read(&cvirt->nr_running)
11340 + ,atomic_read(&cvirt->nr_uninterruptible)
11341 + ,atomic_read(&cvirt->nr_onhold)
11342 + ,atomic_read(&cvirt->load_updates)
11343 + ,LOAD_INT(a), LOAD_FRAC(a)
11344 + ,LOAD_INT(b), LOAD_FRAC(b)
11345 + ,LOAD_INT(c), LOAD_FRAC(c)
11351 +static inline long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11353 + return atomic_read(&cacct->sock[type][pos].count);
11357 +static inline long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11359 + return atomic_read(&cacct->sock[type][pos].total);
11362 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
11364 + int i,j, length = 0;
11365 + static char *type[] = { "UNSPEC", "UNIX", "INET", "INET6", "OTHER" };
11367 + for (i=0; i<5; i++) {
11368 + length += sprintf(buffer + length,
11370 + for (j=0; j<3; j++) {
11371 + length += sprintf(buffer + length,
11373 + ,vx_sock_count(cacct, i, j)
11374 + ,vx_sock_total(cacct, i, j)
11377 + buffer[length++] = '\n';
11379 + length += sprintf(buffer + length,
11380 + "forks:\t%lu\n", cacct->total_forks);
11384 +#endif /* _VX_CVIRT_PROC_H */
11385 diff -NurpP --minimal linux-2.6.10/kernel/vserver/dlimit.c linux-2.6.10-vs1.9.3.17/kernel/vserver/dlimit.c
11386 --- linux-2.6.10/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
11387 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/dlimit.c 2004-12-26 19:40:35.000000000 +0100
11390 + * linux/kernel/vserver/dlimit.c
11392 + * Virtual Server: Context Disk Limits
11394 + * Copyright (C) 2004 Herbert Pötzl
11396 + * V0.01 initial version
11400 +#include <linux/config.h>
11401 +#include <linux/fs.h>
11402 +#include <linux/namespace.h>
11403 +#include <linux/namei.h>
11404 +#include <linux/statfs.h>
11405 +#include <linux/vserver/switch.h>
11406 +#include <linux/vs_context.h>
11407 +#include <linux/vs_dlimit.h>
11409 +#include <asm/errno.h>
11410 +#include <asm/uaccess.h>
11412 +/* __alloc_dl_info()
11414 + * allocate an initialized dl_info struct
11415 + * doesn't make it visible (hash) */
11417 +static struct dl_info *__alloc_dl_info(struct super_block *sb, xid_t xid)
11419 + struct dl_info *new = NULL;
11421 + vxdprintk(VXD_CBIT(dlim, 5),
11422 + "alloc_dl_info(%p,%d)*", sb, xid);
11424 + /* would this benefit from a slab cache? */
11425 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
11429 + memset (new, 0, sizeof(struct dl_info));
11430 + new->dl_xid = xid;
11432 + INIT_RCU_HEAD(&new->dl_rcu);
11433 + INIT_HLIST_NODE(&new->dl_hlist);
11434 + spin_lock_init(&new->dl_lock);
11435 + atomic_set(&new->dl_refcnt, 0);
11436 + atomic_set(&new->dl_usecnt, 0);
11438 + /* rest of init goes here */
11440 + vxdprintk(VXD_CBIT(dlim, 4),
11441 + "alloc_dl_info(%p,%d) = %p", sb, xid, new);
11445 +/* __dealloc_dl_info()
11447 + * final disposal of dl_info */
11449 +static void __dealloc_dl_info(struct dl_info *dli)
11451 + vxdprintk(VXD_CBIT(dlim, 4),
11452 + "dealloc_dl_info(%p)", dli);
11454 + dli->dl_hlist.next = LIST_POISON1;
11455 + dli->dl_xid = -1;
11458 + BUG_ON(atomic_read(&dli->dl_usecnt));
11459 + BUG_ON(atomic_read(&dli->dl_refcnt));
11465 +/* hash table for dl_info hash */
11467 +#define DL_HASH_SIZE 13
11469 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
11471 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
11474 +static inline unsigned int __hashval(struct super_block *sb, xid_t xid)
11476 + return ((xid ^ (unsigned long)sb) % DL_HASH_SIZE);
11481 +/* __hash_dl_info()
11483 + * add the dli to the global hash table
11484 + * requires the hash_lock to be held */
11486 +static inline void __hash_dl_info(struct dl_info *dli)
11488 + struct hlist_head *head;
11490 + vxdprintk(VXD_CBIT(dlim, 6),
11491 + "__hash_dl_info: %p[#%d]", dli, dli->dl_xid);
11492 + get_dl_info(dli);
11493 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_xid)];
11494 + hlist_add_head_rcu(&dli->dl_hlist, head);
11497 +/* __unhash_dl_info()
11499 + * remove the dli from the global hash table
11500 + * requires the hash_lock to be held */
11502 +static inline void __unhash_dl_info(struct dl_info *dli)
11504 + vxdprintk(VXD_CBIT(dlim, 6),
11505 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_xid);
11506 + hlist_del_rcu(&dli->dl_hlist);
11507 + put_dl_info(dli);
11511 +/* __lookup_dl_info()
11513 + * requires the rcu_read_lock()
11514 + * doesn't increment the dl_refcnt */
11516 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, xid_t xid)
11518 + struct hlist_head *head = &dl_info_hash[__hashval(sb, xid)];
11519 + struct hlist_node *pos;
11521 + hlist_for_each_rcu(pos, head) {
11522 + struct dl_info *dli =
11523 + hlist_entry(pos, struct dl_info, dl_hlist);
11525 + if (dli->dl_xid == xid && dli->dl_sb == sb) {
11533 +struct dl_info *locate_dl_info(struct super_block *sb, xid_t xid)
11535 + struct dl_info *dli;
11538 + dli = get_dl_info(__lookup_dl_info(sb, xid));
11539 + vxdprintk(VXD_CBIT(dlim, 7),
11540 + "locate_dl_info(%p,#%d) = %p", sb, xid, dli);
11541 + rcu_read_unlock();
11545 +void rcu_free_dl_info(struct rcu_head *head)
11547 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
11548 + int usecnt, refcnt;
11550 + BUG_ON(!dli || !head);
11552 + usecnt = atomic_read(&dli->dl_usecnt);
11553 + BUG_ON(usecnt < 0);
11555 + refcnt = atomic_read(&dli->dl_refcnt);
11556 + BUG_ON(refcnt < 0);
11558 + vxdprintk(VXD_CBIT(dlim, 3),
11559 + "rcu_free_dl_info(%p)", dli);
11561 + __dealloc_dl_info(dli);
11563 + printk("!!! rcu didn't free\n");
11569 +int vc_add_dlimit(uint32_t id, void __user *data)
11571 + struct nameidata nd;
11572 + struct vcmd_ctx_dlimit_base_v0 vc_data;
11575 + if (!vx_check(0, VX_ADMIN))
11577 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
11580 + ret = user_path_walk_link(vc_data.name, &nd);
11582 + struct super_block *sb;
11583 + struct dl_info *dli;
11586 + if (!nd.dentry->d_inode)
11587 + goto out_release;
11588 + if (!(sb = nd.dentry->d_inode->i_sb))
11589 + goto out_release;
11591 + dli = __alloc_dl_info(sb, id);
11592 + spin_lock(&dl_info_hash_lock);
11595 + if (__lookup_dl_info(sb, id))
11597 + __hash_dl_info(dli);
11602 + spin_unlock(&dl_info_hash_lock);
11604 + __dealloc_dl_info(dli);
11606 + path_release(&nd);
11612 +int vc_rem_dlimit(uint32_t id, void __user *data)
11614 + struct nameidata nd;
11615 + struct vcmd_ctx_dlimit_base_v0 vc_data;
11618 + if (!vx_check(0, VX_ADMIN))
11620 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
11623 + ret = user_path_walk_link(vc_data.name, &nd);
11625 + struct super_block *sb;
11626 + struct dl_info *dli;
11629 + if (!nd.dentry->d_inode)
11630 + goto out_release;
11631 + if (!(sb = nd.dentry->d_inode->i_sb))
11632 + goto out_release;
11634 + spin_lock(&dl_info_hash_lock);
11635 + dli = __lookup_dl_info(sb, id);
11641 + __unhash_dl_info(dli);
11645 + spin_unlock(&dl_info_hash_lock);
11647 + path_release(&nd);
11653 +int vc_set_dlimit(uint32_t id, void __user *data)
11655 + struct nameidata nd;
11656 + struct vcmd_ctx_dlimit_v0 vc_data;
11659 + if (!vx_check(0, VX_ADMIN))
11661 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
11664 + ret = user_path_walk_link(vc_data.name, &nd);
11666 + struct super_block *sb;
11667 + struct dl_info *dli;
11670 + if (!nd.dentry->d_inode)
11671 + goto out_release;
11672 + if (!(sb = nd.dentry->d_inode->i_sb))
11673 + goto out_release;
11674 + if ((vc_data.reserved != (uint32_t)CDLIM_KEEP &&
11675 + vc_data.reserved > 100) ||
11676 + (vc_data.inodes_used != (uint32_t)CDLIM_KEEP &&
11677 + vc_data.inodes_used > vc_data.inodes_total) ||
11678 + (vc_data.space_used != (uint32_t)CDLIM_KEEP &&
11679 + vc_data.space_used > vc_data.space_total))
11680 + goto out_release;
11683 + dli = locate_dl_info(sb, id);
11685 + goto out_release;
11687 + spin_lock(&dli->dl_lock);
11689 + if (vc_data.inodes_used != (uint32_t)CDLIM_KEEP)
11690 + dli->dl_inodes_used = vc_data.inodes_used;
11691 + if (vc_data.inodes_total != (uint32_t)CDLIM_KEEP)
11692 + dli->dl_inodes_total = vc_data.inodes_total;
11693 + if (vc_data.space_used != (uint32_t)CDLIM_KEEP) {
11694 + dli->dl_space_used = vc_data.space_used;
11695 + dli->dl_space_used <<= 10;
11697 + if (vc_data.space_total == (uint32_t)CDLIM_INFINITY)
11698 + dli->dl_space_total = (uint64_t)CDLIM_INFINITY;
11699 + else if (vc_data.space_total != (uint32_t)CDLIM_KEEP) {
11700 + dli->dl_space_total = vc_data.space_total;
11701 + dli->dl_space_total <<= 10;
11703 + if (vc_data.reserved != (uint32_t)CDLIM_KEEP)
11704 + dli->dl_nrlmult = (1 << 10) * (100 - vc_data.reserved) / 100;
11706 + spin_unlock(&dli->dl_lock);
11708 + put_dl_info(dli);
11712 + path_release(&nd);
11717 +int vc_get_dlimit(uint32_t id, void __user *data)
11719 + struct nameidata nd;
11720 + struct vcmd_ctx_dlimit_v0 vc_data;
11723 + if (!vx_check(0, VX_ADMIN))
11725 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
11728 + ret = user_path_walk_link(vc_data.name, &nd);
11730 + struct super_block *sb;
11731 + struct dl_info *dli;
11734 + if (!nd.dentry->d_inode)
11735 + goto out_release;
11736 + if (!(sb = nd.dentry->d_inode->i_sb))
11737 + goto out_release;
11738 + if (vc_data.reserved > 100 ||
11739 + vc_data.inodes_used > vc_data.inodes_total ||
11740 + vc_data.space_used > vc_data.space_total)
11741 + goto out_release;
11744 + dli = locate_dl_info(sb, id);
11746 + goto out_release;
11748 + spin_lock(&dli->dl_lock);
11749 + vc_data.inodes_used = dli->dl_inodes_used;
11750 + vc_data.inodes_total = dli->dl_inodes_total;
11751 + vc_data.space_used = dli->dl_space_used >> 10;
11752 + if (dli->dl_space_total == (uint64_t)CDLIM_INFINITY)
11753 + vc_data.space_total = (uint32_t)CDLIM_INFINITY;
11755 + vc_data.space_total = dli->dl_space_total >> 10;
11757 + vc_data.reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
11758 + spin_unlock(&dli->dl_lock);
11760 + put_dl_info(dli);
11762 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
11763 + goto out_release;
11767 + path_release(&nd);
11773 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
11775 + struct dl_info *dli;
11776 + __u64 blimit, bfree, bavail;
11779 + dli = locate_dl_info(sb, vx_current_xid());
11783 + spin_lock(&dli->dl_lock);
11784 + if (dli->dl_inodes_total == (uint32_t)CDLIM_INFINITY)
11787 + /* reduce max inodes available to limit */
11788 + if (buf->f_files > dli->dl_inodes_total)
11789 + buf->f_files = dli->dl_inodes_total;
11791 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
11792 + /* reduce free inodes to min */
11793 + if (ifree < buf->f_ffree)
11794 + buf->f_ffree = ifree;
11797 + if (dli->dl_space_total == (uint64_t)CDLIM_INFINITY)
11800 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
11802 + if (dli->dl_space_total < dli->dl_space_used)
11805 + bfree = (dli->dl_space_total - dli->dl_space_used)
11806 + >> sb->s_blocksize_bits;
11808 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
11809 + if (bavail < dli->dl_space_used)
11812 + bavail = (bavail - dli->dl_space_used)
11813 + >> sb->s_blocksize_bits;
11815 + /* reduce max space available to limit */
11816 + if (buf->f_blocks > blimit)
11817 + buf->f_blocks = blimit;
11819 + /* reduce free space to min */
11820 + if (bfree < buf->f_bfree)
11821 + buf->f_bfree = bfree;
11823 + /* reduce avail space to min */
11824 + if (bavail < buf->f_bavail)
11825 + buf->f_bavail = bavail;
11828 + spin_unlock(&dli->dl_lock);
11829 + put_dl_info(dli);
11834 +#include <linux/module.h>
11836 +EXPORT_SYMBOL_GPL(locate_dl_info);
11837 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
11839 diff -NurpP --minimal linux-2.6.10/kernel/vserver/helper.c linux-2.6.10-vs1.9.3.17/kernel/vserver/helper.c
11840 --- linux-2.6.10/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
11841 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/helper.c 2004-12-26 19:40:34.000000000 +0100
11844 + * linux/kernel/vserver/helper.c
11846 + * Virtual Context Support
11848 + * Copyright (C) 2004 Herbert Pötzl
11850 + * V0.01 basic helper
11854 +#include <linux/config.h>
11855 +#include <linux/errno.h>
11856 +#include <linux/reboot.h>
11857 +#include <linux/kmod.h>
11858 +#include <linux/sched.h>
11859 +#include <linux/vs_context.h>
11861 +#include <asm/uaccess.h>
11862 +#include <asm/unistd.h>
11865 +char vshelper_path[255] = "/sbin/vshelper";
11869 + * vshelper path is set via /proc/sys
11870 + * invoked by vserver sys_reboot(), with
11871 + * the following arguments
11873 + * argv [0] = vshelper_path;
11874 + * argv [1] = action: "restart", "halt", "poweroff", ...
11875 + * argv [2] = context identifier
11876 + * argv [3] = additional argument (restart2)
11878 + * envp [*] = type-specific parameters
11881 +long vs_reboot(unsigned int cmd, void * arg)
11883 + char id_buf[8], cmd_buf[32];
11884 + char uid_buf[32], pid_buf[32];
11885 + char buffer[256];
11887 + char *argv[] = {vshelper_path, NULL, id_buf, NULL, 0};
11888 + char *envp[] = {"HOME=/", "TERM=linux",
11889 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
11890 + uid_buf, pid_buf, cmd_buf, 0};
11892 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vx_current_xid());
11894 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
11895 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid);
11896 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
11899 + case LINUX_REBOOT_CMD_RESTART:
11900 + argv[1] = "restart";
11903 + case LINUX_REBOOT_CMD_HALT:
11904 + argv[1] = "halt";
11907 + case LINUX_REBOOT_CMD_POWER_OFF:
11908 + argv[1] = "poweroff";
11911 + case LINUX_REBOOT_CMD_SW_SUSPEND:
11912 + argv[1] = "swsusp";
11915 + case LINUX_REBOOT_CMD_RESTART2:
11916 + if (strncpy_from_user(&buffer[0], (char *)arg, sizeof(buffer) - 1) < 0)
11918 + argv[3] = buffer;
11920 + argv[1] = "restart2";
11924 + /* maybe we should wait ? */
11925 + if (call_usermodehelper(*argv, argv, envp, 0)) {
11926 + printk( KERN_WARNING
11927 + "vs_reboot(): failed to exec (%s %s %s %s)\n",
11928 + vshelper_path, argv[1], argv[2], argv[3]);
11934 +long vs_context_state(unsigned int cmd)
11936 + char id_buf[8], cmd_buf[32];
11938 + char *argv[] = {vshelper_path, NULL, id_buf, NULL, 0};
11939 + char *envp[] = {"HOME=/", "TERM=linux",
11940 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
11942 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vx_current_xid());
11943 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
11946 + case VS_CONTEXT_CREATED:
11947 + argv[1] = "startup";
11949 + case VS_CONTEXT_DESTROY:
11950 + argv[1] = "shutdown";
11956 + if (call_usermodehelper(*argv, argv, envp, 1)) {
11957 + printk( KERN_WARNING
11958 + "vs_context_state(): failed to exec (%s %s %s %s)\n",
11959 + vshelper_path, argv[1], argv[2], argv[3]);
11965 diff -NurpP --minimal linux-2.6.10/kernel/vserver/history.c linux-2.6.10-vs1.9.3.17/kernel/vserver/history.c
11966 --- linux-2.6.10/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
11967 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/history.c 2005-01-04 17:56:33.000000000 +0100
11970 + * kernel/vserver/history.c
11972 + * Virtual Context History Backtrace
11974 + * Copyright (C) 2004-2005 Herbert Pötzl
11976 + * V0.01 basic structure
11977 + * V0.02 hash/unhash and trace
11981 +#include <linux/config.h>
11982 +#include <linux/errno.h>
11983 +#include <linux/module.h>
11984 +#include <linux/types.h>
11985 +#include <linux/ctype.h>
11987 +#include <asm/uaccess.h>
11988 +#include <asm/atomic.h>
11989 +#include <asm/unistd.h>
11991 +#include <linux/vserver/debug.h>
11994 +#ifdef CONFIG_VSERVER_HISTORY
11995 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
11997 +#define VXH_SIZE 64
12000 +struct _vx_history {
12001 + unsigned int counter;
12003 + struct _vx_hist_entry entry[VXH_SIZE+1];
12007 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
12009 +unsigned volatile int vxh_active = 1;
12011 +static atomic_t sequence = ATOMIC_INIT(0);
12014 +struct _vx_hist_entry *vxh_advance(void *loc)
12016 + unsigned int cpu = smp_processor_id();
12017 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
12018 + struct _vx_hist_entry *entry;
12019 + unsigned int index;
12021 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
12022 + entry = &hist->entry[index];
12024 + entry->seq = atomic_inc_return(&sequence);
12025 + entry->loc = loc;
12030 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
12032 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
12035 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
12037 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
12038 + (e)->vxi.ptr?(e)->vxi.xid:0, \
12039 + (e)->vxi.ptr?(e)->vxi.usecnt:0, \
12040 + (e)->vxi.ptr?(e)->vxi.refcnt:0
12042 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
12044 + switch (e->type) {
12045 + case VXH_THROW_OOPS:
12046 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
12049 + case VXH_GET_VX_INFO:
12050 + case VXH_PUT_VX_INFO:
12051 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
12053 + (e->type==VXH_GET_VX_INFO)?"get":"put",
12054 + VXH_VXI_ARGS(e));
12057 + case VXH_SET_VX_INFO:
12058 + case VXH_CLR_VX_INFO:
12059 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
12061 + (e->type==VXH_SET_VX_INFO)?"set":"clr",
12062 + VXH_VXI_ARGS(e), e->sc.data);
12065 + case VXH_ALLOC_VX_INFO:
12066 + case VXH_DEALLOC_VX_INFO:
12067 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
12069 + (e->type==VXH_ALLOC_VX_INFO)?"alloc":"dealloc",
12070 + VXH_VXI_ARGS(e));
12073 + case VXH_HASH_VX_INFO:
12074 + case VXH_UNHASH_VX_INFO:
12075 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
12077 + (e->type==VXH_HASH_VX_INFO)?"hash":"unhash",
12078 + VXH_VXI_ARGS(e));
12081 + case VXH_LOC_VX_INFO:
12082 + case VXH_LOOKUP_VX_INFO:
12083 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
12085 + (e->type==VXH_LOC_VX_INFO)?"loc":"lookup",
12086 + e->ll.arg, VXH_VXI_ARGS(e));
12091 +static void __vxh_dump_history(void)
12093 + unsigned int i,j;
12095 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
12096 + atomic_read(&sequence), NR_CPUS);
12098 + for (i=0; i < VXH_SIZE; i++) {
12099 + for (j=0; j < NR_CPUS; j++) {
12100 + struct _vx_history *hist =
12101 + &per_cpu(vx_history_buffer, j);
12102 + unsigned int index = (hist->counter-i) % VXH_SIZE;
12103 + struct _vx_hist_entry *entry = &hist->entry[index];
12105 + vxh_dump_entry(entry, j);
12110 +void vxh_dump_history(void)
12114 + local_irq_enable();
12116 + local_irq_disable();
12118 + __vxh_dump_history();
12122 +/* vserver syscall commands below here */
12125 +int vc_dump_history(uint32_t id)
12128 + __vxh_dump_history();
12134 +EXPORT_SYMBOL_GPL(vxh_advance);
12136 diff -NurpP --minimal linux-2.6.10/kernel/vserver/init.c linux-2.6.10-vs1.9.3.17/kernel/vserver/init.c
12137 --- linux-2.6.10/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
12138 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/init.c 2004-12-26 19:40:23.000000000 +0100
12141 + * linux/kernel/init.c
12143 + * Virtual Server Init
12145 + * Copyright (C) 2004 Herbert Pötzl
12147 + * V0.01 basic structure
12151 +#include <linux/config.h>
12152 +#include <linux/errno.h>
12153 +#include <linux/init.h>
12154 +#include <linux/module.h>
12156 +int vserver_register_sysctl(void);
12157 +void vserver_unregister_sysctl(void);
12160 +static int __init init_vserver(void)
12164 +#ifdef CONFIG_VSERVER_DEBUG
12165 + vserver_register_sysctl();
12171 +static void __exit exit_vserver(void)
12174 +#ifdef CONFIG_VSERVER_DEBUG
12175 + vserver_unregister_sysctl();
12181 +module_init(init_vserver);
12182 +module_exit(exit_vserver);
12184 diff -NurpP --minimal linux-2.6.10/kernel/vserver/inode.c linux-2.6.10-vs1.9.3.17/kernel/vserver/inode.c
12185 --- linux-2.6.10/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
12186 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/inode.c 2004-12-26 19:40:30.000000000 +0100
12189 + * linux/kernel/vserver/inode.c
12191 + * Virtual Server: File System Support
12193 + * Copyright (C) 2004 Herbert Pötzl
12195 + * V0.01 separated from vcontext V0.05
12199 +#include <linux/config.h>
12200 +#include <linux/sched.h>
12201 +#include <linux/vs_context.h>
12202 +#include <linux/proc_fs.h>
12203 +#include <linux/devpts_fs.h>
12204 +#include <linux/namei.h>
12205 +#include <linux/mount.h>
12206 +#include <linux/parser.h>
12207 +#include <linux/vserver/inode.h>
12208 +#include <linux/vserver/xid.h>
12210 +#include <asm/errno.h>
12211 +#include <asm/uaccess.h>
12214 +static int __vc_get_iattr(struct inode *in, uint32_t *xid, uint32_t *flags, uint32_t *mask)
12216 + struct proc_dir_entry *entry;
12218 + if (!in || !in->i_sb)
12221 + *flags = IATTR_XID
12222 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
12223 + | (IS_IUNLINK(in) ? IATTR_IUNLINK : 0)
12224 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0);
12225 + *mask = IATTR_IUNLINK | IATTR_IMMUTABLE;
12227 + if (S_ISDIR(in->i_mode))
12228 + *mask |= IATTR_BARRIER;
12230 + if (in->i_sb->s_flags & MS_TAGXID) {
12231 + *xid = in->i_xid;
12232 + *mask |= IATTR_XID;
12235 + switch (in->i_sb->s_magic) {
12236 + case PROC_SUPER_MAGIC:
12237 + entry = PROC_I(in)->pde;
12239 + // check for specific inodes ?
12241 + *mask |= IATTR_FLAGS;
12243 + *flags |= (entry->vx_flags & IATTR_FLAGS);
12245 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
12248 + case DEVPTS_SUPER_MAGIC:
12249 + *xid = in->i_xid;
12250 + *mask |= IATTR_XID;
12259 +int vc_get_iattr(uint32_t id, void __user *data)
12261 + struct nameidata nd;
12262 + struct vcmd_ctx_iattr_v1 vc_data = { .xid = -1 };
12265 + if (!vx_check(0, VX_ADMIN))
12267 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
12270 + ret = user_path_walk_link(vc_data.name, &nd);
12272 + ret = __vc_get_iattr(nd.dentry->d_inode,
12273 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
12274 + path_release(&nd);
12277 + if (copy_to_user (data, &vc_data, sizeof(vc_data)))
12282 +static int __vc_set_iattr(struct dentry *de, uint32_t *xid, uint32_t *flags, uint32_t *mask)
12284 + struct inode *in = de->d_inode;
12285 + int error = 0, is_proc = 0, has_xid = 0;
12287 + if (!in || !in->i_sb)
12290 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
12291 + if ((*mask & IATTR_FLAGS) && !is_proc)
12294 + has_xid = (in->i_sb->s_flags & MS_TAGXID) ||
12295 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
12296 + if ((*mask & IATTR_XID) && !has_xid)
12299 + down(&in->i_sem);
12300 + if (*mask & IATTR_XID)
12301 + in->i_xid = *xid;
12303 + if (*mask & IATTR_FLAGS) {
12304 + struct proc_dir_entry *entry = PROC_I(in)->pde;
12305 + unsigned int iflags = PROC_I(in)->vx_flags;
12307 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
12308 + | (*flags & IATTR_FLAGS);
12309 + PROC_I(in)->vx_flags = iflags;
12311 + entry->vx_flags = iflags;
12314 + if (*mask & (IATTR_BARRIER | IATTR_IUNLINK | IATTR_IMMUTABLE)) {
12315 + struct iattr attr;
12317 + attr.ia_valid = ATTR_ATTR_FLAG;
12318 + attr.ia_attr_flags =
12319 + (IS_IMMUTABLE(in) ? ATTR_FLAG_IMMUTABLE : 0) |
12320 + (IS_IUNLINK(in) ? ATTR_FLAG_IUNLINK : 0) |
12321 + (IS_BARRIER(in) ? ATTR_FLAG_BARRIER : 0);
12323 + if (*mask & IATTR_IMMUTABLE) {
12324 + if (*flags & IATTR_IMMUTABLE)
12325 + attr.ia_attr_flags |= ATTR_FLAG_IMMUTABLE;
12327 + attr.ia_attr_flags &= ~ATTR_FLAG_IMMUTABLE;
12329 + if (*mask & IATTR_IUNLINK) {
12330 + if (*flags & IATTR_IUNLINK)
12331 + attr.ia_attr_flags |= ATTR_FLAG_IUNLINK;
12333 + attr.ia_attr_flags &= ~ATTR_FLAG_IUNLINK;
12335 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
12336 + if (*flags & IATTR_BARRIER)
12337 + attr.ia_attr_flags |= ATTR_FLAG_BARRIER;
12339 + attr.ia_attr_flags &= ~ATTR_FLAG_BARRIER;
12341 + if (in->i_op && in->i_op->setattr)
12342 + error = in->i_op->setattr(de, &attr);
12344 + error = inode_change_ok(in, &attr);
12346 + error = inode_setattr(in, &attr);
12350 + mark_inode_dirty(in);
12355 +int vc_set_iattr(uint32_t id, void __user *data)
12357 + struct nameidata nd;
12358 + struct vcmd_ctx_iattr_v1 vc_data;
12361 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_LINUX_IMMUTABLE))
12363 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
12366 + ret = user_path_walk_link(vc_data.name, &nd);
12368 + ret = __vc_set_iattr(nd.dentry,
12369 + &vc_data.xid, &vc_data.flags, &vc_data.mask);
12370 + path_release(&nd);
12373 + if (copy_to_user (data, &vc_data, sizeof(vc_data)))
12379 +#ifdef CONFIG_VSERVER_LEGACY
12381 +#define PROC_DYNAMIC_FIRST 0xF0000000UL
12383 +int vx_proc_ioctl(struct inode * inode, struct file * filp,
12384 + unsigned int cmd, unsigned long arg)
12386 + struct proc_dir_entry *entry;
12390 + if (inode->i_ino < PROC_DYNAMIC_FIRST)
12393 + entry = PROC_I(inode)->pde;
12398 + case FIOC_GETXFLG: {
12399 + /* fixme: if stealth, return -ENOTTY */
12401 + flags = entry->vx_flags;
12402 + if (capable(CAP_CONTEXT))
12403 + error = put_user(flags, (int *) arg);
12406 + case FIOC_SETXFLG: {
12407 + /* fixme: if stealth, return -ENOTTY */
12409 + if (!capable(CAP_CONTEXT))
12412 + if (IS_RDONLY(inode))
12415 + if (get_user(flags, (int *) arg))
12418 + entry->vx_flags = flags;
12429 +int vx_parse_xid(char *string, xid_t *xid, int remove)
12431 + static match_table_t tokens = {
12435 + substring_t args[MAX_OPT_ARGS];
12436 + int token, option = 0;
12441 + token = match_token(string, tokens, args);
12442 + if (token && xid && !match_int(args, &option))
12445 + vxdprintk(VXD_CBIT(xid, 7),
12446 + "vx_parse_xid(»%s«): %d:#%d",
12447 + string, token, option);
12449 + if (token && remove) {
12450 + char *p = strstr(string, "xid=");
12454 + while (*q != '\0' && *q != ',')
12465 +void vx_propagate_xid(struct nameidata *nd, struct inode *inode)
12467 + xid_t new_xid = 0;
12468 + struct vfsmount *mnt;
12477 + propagate = (mnt->mnt_flags & MNT_XID);
12479 + new_xid = mnt->mnt_xid;
12481 + vxdprintk(VXD_CBIT(xid, 7),
12482 + "vx_propagate_xid(%p[#%lu.%d]): %d,%d",
12483 + inode, inode->i_ino, inode->i_xid,
12484 + new_xid, (propagate)?1:0);
12487 + inode->i_xid = new_xid;
12490 +#include <linux/module.h>
12492 +EXPORT_SYMBOL_GPL(vx_propagate_xid);
12494 diff -NurpP --minimal linux-2.6.10/kernel/vserver/legacy.c linux-2.6.10-vs1.9.3.17/kernel/vserver/legacy.c
12495 --- linux-2.6.10/kernel/vserver/legacy.c 1970-01-01 01:00:00.000000000 +0100
12496 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/legacy.c 2004-12-26 19:40:36.000000000 +0100
12499 + * linux/kernel/vserver/legacy.c
12501 + * Virtual Server: Legacy Funtions
12503 + * Copyright (C) 2001-2003 Jacques Gelinas
12504 + * Copyright (C) 2003-2004 Herbert Pötzl
12506 + * V0.01 broken out from vcontext.c V0.05
12510 +#include <linux/config.h>
12511 +#include <linux/sched.h>
12512 +#include <linux/vs_context.h>
12513 +#include <linux/vs_network.h>
12514 +#include <linux/vserver/legacy.h>
12515 +#include <linux/vserver/namespace.h>
12516 +#include <linux/namespace.h>
12518 +#include <asm/errno.h>
12519 +#include <asm/uaccess.h>
12523 +static int vx_set_initpid(struct vx_info *vxi, int pid)
12525 + if (vxi->vx_initpid)
12528 + vxi->vx_initpid = pid;
12532 +int vc_new_s_context(uint32_t ctx, void __user *data)
12534 + int ret = -ENOMEM;
12535 + struct vcmd_new_s_context_v1 vc_data;
12536 + struct vx_info *new_vxi;
12538 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
12541 + /* legacy hack, will be removed soon */
12543 + /* assign flags and initpid */
12544 + if (!current->vx_info)
12547 + if (vc_data.flags & VX_INFO_INIT)
12548 + ret = vx_set_initpid(current->vx_info, current->tgid);
12550 + /* We keep the same vx_id, but lower the capabilities */
12551 + current->vx_info->vx_bcaps &= (~vc_data.remove_cap);
12552 + // current->cap_bset &= (~vc_data.remove_cap);
12553 + ret = vx_current_xid();
12554 + current->vx_info->vx_flags |= vc_data.flags;
12559 + if (!vx_check(0, VX_ADMIN) || !capable(CAP_SYS_ADMIN)
12560 + /* might make sense in the future, or not ... */
12561 + || vx_flags(VX_INFO_LOCK, 0))
12564 + /* ugly hack for Spectator */
12566 + current->xid = 1;
12570 + if (((ctx > MAX_S_CONTEXT) && (ctx != VX_DYNAMIC_ID)) ||
12574 + if ((ctx == VX_DYNAMIC_ID) || (ctx < MIN_D_CONTEXT))
12575 + new_vxi = locate_or_create_vx_info(ctx);
12577 + new_vxi = locate_vx_info(ctx);
12583 + if (!vx_info_flags(new_vxi, VXF_STATE_SETUP, 0) &&
12584 + vx_info_flags(new_vxi, VX_INFO_PRIVATE, 0))
12587 + new_vxi->vx_flags &= ~(VXF_STATE_SETUP|VXF_STATE_INIT);
12589 + ret = vx_migrate_task(current, new_vxi);
12591 + current->vx_info->vx_bcaps &= (~vc_data.remove_cap);
12592 + // current->cap_bset &= (~vc_data.remove_cap);
12593 + new_vxi->vx_flags |= vc_data.flags;
12594 + if (vc_data.flags & VX_INFO_INIT)
12595 + vx_set_initpid(new_vxi, current->tgid);
12596 + if (vc_data.flags & VX_INFO_NAMESPACE)
12597 + vx_set_namespace(new_vxi,
12598 + current->namespace, current->fs);
12599 + if (vc_data.flags & VX_INFO_NPROC)
12600 + new_vxi->limit.rlim[RLIMIT_NPROC] =
12601 + current->signal->rlim[RLIMIT_NPROC].rlim_max;
12602 + ret = new_vxi->vx_id;
12605 + put_vx_info(new_vxi);
12610 +extern struct nx_info *create_nx_info(void);
12612 +/* set ipv4 root (syscall) */
12614 +int vc_set_ipv4root(uint32_t nbip, void __user *data)
12616 + int i, err = -EPERM;
12617 + struct vcmd_set_ipv4root_v3 vc_data;
12618 + struct nx_info *new_nxi, *nxi = current->nx_info;
12620 + if (nbip < 0 || nbip > NB_IPV4ROOT)
12622 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
12625 + if (!nxi || nxi->ipv4[0] == 0 || capable(CAP_NET_ADMIN))
12626 + // We are allowed to change everything
12631 + // We are allowed to select a subset of the currently
12632 + // installed IP numbers. No new one allowed
12633 + // We can't change the broadcast address though
12634 + for (i=0; i<nbip; i++) {
12636 + __u32 nxip = vc_data.nx_mask_pair[i].ip;
12637 + for (j=0; j<nxi->nbipv4; j++) {
12638 + if (nxip == nxi->ipv4[j]) {
12644 + if ((found == nbip) &&
12645 + (vc_data.broadcast == nxi->v4_bcast))
12651 + new_nxi = create_nx_info();
12655 + new_nxi->nbipv4 = nbip;
12656 + for (i=0; i<nbip; i++) {
12657 + new_nxi->ipv4[i] = vc_data.nx_mask_pair[i].ip;
12658 + new_nxi->mask[i] = vc_data.nx_mask_pair[i].mask;
12660 + new_nxi->v4_bcast = vc_data.broadcast;
12661 + // current->nx_info = new_nxi;
12663 + printk("!!! switching nx_info %p->%p\n", nxi, new_nxi);
12664 + clr_nx_info(¤t->nx_info);
12666 + nx_migrate_task(current, new_nxi);
12667 + // set_nx_info(¤t->nx_info, new_nxi);
12668 + // current->nid = new_nxi->nx_id;
12669 + put_nx_info(new_nxi);
12674 diff -NurpP --minimal linux-2.6.10/kernel/vserver/limit.c linux-2.6.10-vs1.9.3.17/kernel/vserver/limit.c
12675 --- linux-2.6.10/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
12676 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/limit.c 2004-12-26 19:40:35.000000000 +0100
12679 + * linux/kernel/vserver/limit.c
12681 + * Virtual Server: Context Limits
12683 + * Copyright (C) 2004 Herbert Pötzl
12685 + * V0.01 broken out from vcontext V0.05
12689 +#include <linux/config.h>
12690 +#include <linux/module.h>
12691 +#include <linux/vs_context.h>
12692 +#include <linux/vs_limit.h>
12693 +#include <linux/vserver/limit.h>
12694 +#include <linux/vserver/switch.h>
12695 +#include <linux/vserver/limit_cmd.h>
12697 +#include <asm/errno.h>
12698 +#include <asm/uaccess.h>
12701 +const char *vlimit_name[NUM_LIMITS] = {
12702 + [RLIMIT_CPU] = "CPU",
12703 + [RLIMIT_RSS] = "RSS",
12704 + [RLIMIT_NPROC] = "NPROC",
12705 + [RLIMIT_NOFILE] = "NOFILE",
12706 + [RLIMIT_MEMLOCK] = "VML",
12707 + [RLIMIT_AS] = "VM",
12708 + [RLIMIT_LOCKS] = "LOCKS",
12709 + [RLIMIT_MSGQUEUE] = "MSGQ",
12710 + [VLIMIT_NSOCK] = "NSOCK",
12713 +EXPORT_SYMBOL_GPL(vlimit_name);
12716 +static int is_valid_rlimit(int id)
12721 + case RLIMIT_NPROC:
12724 + case RLIMIT_MEMLOCK:
12725 + case RLIMIT_NOFILE:
12732 +static inline uint64_t vc_get_rlim(struct vx_info *vxi, int id)
12734 + unsigned long limit;
12736 + limit = vxi->limit.rlim[id];
12737 + if (limit == RLIM_INFINITY)
12738 + return CRLIM_INFINITY;
12742 +int vc_get_rlimit(uint32_t id, void __user *data)
12744 + struct vx_info *vxi;
12745 + struct vcmd_ctx_rlimit_v0 vc_data;
12747 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
12749 + if (!is_valid_rlimit(vc_data.id))
12750 + return -ENOTSUPP;
12752 + vxi = locate_vx_info(id);
12756 + vc_data.maximum = vc_get_rlim(vxi, vc_data.id);
12757 + vc_data.minimum = CRLIM_UNSET;
12758 + vc_data.softlimit = CRLIM_UNSET;
12759 + put_vx_info(vxi);
12761 + if (copy_to_user (data, &vc_data, sizeof(vc_data)))
12766 +int vc_set_rlimit(uint32_t id, void __user *data)
12768 + struct vx_info *vxi;
12769 + struct vcmd_ctx_rlimit_v0 vc_data;
12771 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RESOURCE))
12773 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
12775 + if (!is_valid_rlimit(vc_data.id))
12776 + return -ENOTSUPP;
12778 + vxi = locate_vx_info(id);
12782 + if (vc_data.maximum != CRLIM_KEEP)
12783 + vxi->limit.rlim[vc_data.id] = vc_data.maximum;
12784 + put_vx_info(vxi);
12789 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
12791 + static struct vcmd_ctx_rlimit_mask_v0 mask = {
12794 + , /* softlimit */
12797 + (1 << RLIMIT_NPROC) |
12798 + (1 << RLIMIT_NOFILE) |
12799 + (1 << RLIMIT_MEMLOCK) |
12800 + (1 << RLIMIT_AS) |
12801 + (1 << RLIMIT_RSS)
12804 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RESOURCE))
12806 + if (copy_to_user(data, &mask, sizeof(mask)))
12812 +void vx_vsi_meminfo(struct sysinfo *val)
12814 + struct vx_info *vxi = current->vx_info;
12817 + v = vxi->limit.rlim[RLIMIT_RSS];
12818 + if (v != RLIM_INFINITY)
12819 + val->totalram = min(val->totalram, v);
12820 + v = atomic_read(&vxi->limit.rcur[RLIMIT_RSS]);
12821 + val->freeram = (v < val->totalram) ? val->totalram - v : 0;
12822 + val->bufferram = 0;
12823 + val->totalhigh = 0;
12824 + val->freehigh = 0;
12828 +void vx_vsi_swapinfo(struct sysinfo *val)
12830 + struct vx_info *vxi = current->vx_info;
12831 + unsigned long v, w;
12833 + v = vxi->limit.rlim[RLIMIT_RSS];
12834 + w = vxi->limit.rlim[RLIMIT_AS];
12835 + if (w != RLIM_INFINITY)
12836 + val->totalswap = min(val->totalswap, w -
12837 + ((v != RLIM_INFINITY) ? v : 0));
12838 + w = atomic_read(&vxi->limit.rcur[RLIMIT_AS]);
12839 + val->freeswap = (w < val->totalswap) ? val->totalswap - w : 0;
12843 diff -NurpP --minimal linux-2.6.10/kernel/vserver/limit_init.h linux-2.6.10-vs1.9.3.17/kernel/vserver/limit_init.h
12844 --- linux-2.6.10/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
12845 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/limit_init.h 2004-12-26 19:40:36.000000000 +0100
12848 +static inline void vx_info_init_limit(struct _vx_limit *limit)
12852 + for (lim=0; lim<NUM_LIMITS; lim++) {
12853 + limit->rlim[lim] = RLIM_INFINITY;
12854 + limit->rmax[lim] = 0;
12855 + atomic_set(&limit->rcur[lim], 0);
12856 + atomic_set(&limit->lhit[lim], 0);
12860 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
12862 +#ifdef CONFIG_VSERVER_DEBUG
12863 + unsigned long value;
12864 + unsigned int lim;
12866 + for (lim=0; lim<NUM_LIMITS; lim++) {
12867 + value = atomic_read(&limit->rcur[lim]);
12869 + "!!! limit: %p[%s,%d] = %ld on exit.",
12870 + limit, vlimit_name[lim], lim, value);
12875 diff -NurpP --minimal linux-2.6.10/kernel/vserver/limit_proc.h linux-2.6.10-vs1.9.3.17/kernel/vserver/limit_proc.h
12876 --- linux-2.6.10/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
12877 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/limit_proc.h 2004-12-26 19:40:36.000000000 +0100
12879 +#ifndef _VX_LIMIT_PROC_H
12880 +#define _VX_LIMIT_PROC_H
12883 +static inline void vx_limit_fixup(struct _vx_limit *limit)
12885 + unsigned long value;
12886 + unsigned int lim;
12888 + for (lim=0; lim<NUM_LIMITS; lim++) {
12889 + value = atomic_read(&limit->rcur[lim]);
12890 + if (value > limit->rmax[lim])
12891 + limit->rmax[lim] = value;
12892 + if (limit->rmax[lim] > limit->rlim[lim])
12893 + limit->rmax[lim] = limit->rlim[lim];
12897 +#define VX_LIMIT_FMT ":\t%10d\t%10ld\t%10ld\t%6d\n"
12899 +#define VX_LIMIT_ARG(r) \
12900 + ,atomic_read(&limit->rcur[r]) \
12901 + ,limit->rmax[r] \
12902 + ,limit->rlim[r] \
12903 + ,atomic_read(&limit->lhit[r])
12905 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
12907 + vx_limit_fixup(limit);
12908 + return sprintf(buffer,
12909 + "PROC" VX_LIMIT_FMT
12910 + "VM" VX_LIMIT_FMT
12911 + "VML" VX_LIMIT_FMT
12912 + "RSS" VX_LIMIT_FMT
12913 + "FILES" VX_LIMIT_FMT
12914 + "SOCK" VX_LIMIT_FMT
12915 + VX_LIMIT_ARG(RLIMIT_NPROC)
12916 + VX_LIMIT_ARG(RLIMIT_AS)
12917 + VX_LIMIT_ARG(RLIMIT_MEMLOCK)
12918 + VX_LIMIT_ARG(RLIMIT_RSS)
12919 + VX_LIMIT_ARG(RLIMIT_NOFILE)
12920 + VX_LIMIT_ARG(VLIMIT_NSOCK)
12924 +#endif /* _VX_LIMIT_PROC_H */
12927 diff -NurpP --minimal linux-2.6.10/kernel/vserver/namespace.c linux-2.6.10-vs1.9.3.17/kernel/vserver/namespace.c
12928 --- linux-2.6.10/kernel/vserver/namespace.c 1970-01-01 01:00:00.000000000 +0100
12929 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/namespace.c 2004-12-26 19:40:29.000000000 +0100
12932 + * linux/kernel/vserver/namespace.c
12934 + * Virtual Server: Context Namespace Support
12936 + * Copyright (C) 2003-2004 Herbert Pötzl
12938 + * V0.01 broken out from context.c 0.07
12939 + * V0.02 added task locking for namespace
12943 +#include <linux/config.h>
12944 +#include <linux/utsname.h>
12945 +#include <linux/sched.h>
12946 +#include <linux/vs_context.h>
12947 +#include <linux/vserver/namespace.h>
12948 +#include <linux/dcache.h>
12949 +#include <linux/mount.h>
12950 +#include <linux/fs.h>
12952 +#include <asm/errno.h>
12953 +#include <asm/uaccess.h>
12956 +int vx_check_vfsmount(struct vx_info *vxi, struct vfsmount *mnt)
12958 + struct vfsmount *root_mnt, *altroot_mnt;
12959 + struct dentry *root, *altroot, *point;
12960 + int r1, r2, s1, s2, ret = 0;
12962 + if (!vxi || !mnt)
12965 + spin_lock(&dcache_lock);
12966 + altroot_mnt = current->fs->rootmnt;
12967 + altroot = current->fs->root;
12970 + if (vxi->vx_fs) {
12971 + root_mnt = vxi->vx_fs->rootmnt;
12972 + root = vxi->vx_fs->root;
12974 + root_mnt = altroot_mnt;
12977 + /* printk("··· %p:%p/%p:%p ",
12978 + root_mnt, root, altroot_mnt, altroot); */
12980 + while ((mnt != mnt->mnt_parent) &&
12981 + (mnt != root_mnt) && (mnt != altroot_mnt)) {
12982 + point = mnt->mnt_mountpoint;
12983 + mnt = mnt->mnt_parent;
12986 + r1 = (mnt == root_mnt);
12987 + s1 = is_subdir(point, root);
12988 + r2 = (mnt == altroot_mnt);
12989 + s2 = is_subdir(point, altroot);
12991 + ret = (((mnt == root_mnt) && is_subdir(point, root)) ||
12992 + ((mnt == altroot_mnt) && is_subdir(point, altroot)));
12993 + /* printk("··· for %p:%p -> %d:%d/%d:%d = %d\n",
12994 + mnt, point, r1, s1, r2, s2, ret); */
12995 + spin_unlock(&dcache_lock);
12997 + return (r2 && s2);
13001 +/* virtual host info names */
13003 +static char * vx_vhi_name(struct vx_info *vxi, int id)
13006 + case VHIN_CONTEXT:
13007 + return vxi->vx_name;
13008 + case VHIN_SYSNAME:
13009 + return vxi->cvirt.utsname.sysname;
13010 + case VHIN_NODENAME:
13011 + return vxi->cvirt.utsname.nodename;
13012 + case VHIN_RELEASE:
13013 + return vxi->cvirt.utsname.release;
13014 + case VHIN_VERSION:
13015 + return vxi->cvirt.utsname.version;
13016 + case VHIN_MACHINE:
13017 + return vxi->cvirt.utsname.machine;
13018 + case VHIN_DOMAINNAME:
13019 + return vxi->cvirt.utsname.domainname;
13026 +int vc_set_vhi_name(uint32_t id, void __user *data)
13028 + struct vx_info *vxi;
13029 + struct vcmd_vx_vhi_name_v0 vc_data;
13032 + if (!capable(CAP_SYS_ADMIN))
13034 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
13037 + vxi = locate_vx_info(id);
13041 + name = vx_vhi_name(vxi, vc_data.field);
13043 + memcpy(name, vc_data.name, 65);
13044 + put_vx_info(vxi);
13045 + return (name ? 0 : -EFAULT);
13048 +int vc_get_vhi_name(uint32_t id, void __user *data)
13050 + struct vx_info *vxi;
13051 + struct vcmd_vx_vhi_name_v0 vc_data;
13054 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
13057 + vxi = locate_vx_info(id);
13061 + name = vx_vhi_name(vxi, vc_data.field);
13065 + memcpy(vc_data.name, name, 65);
13066 + if (copy_to_user (data, &vc_data, sizeof(vc_data)))
13069 + put_vx_info(vxi);
13070 + return (name ? 0 : -EFAULT);
13073 +/* namespace functions */
13075 +#include <linux/namespace.h>
13077 +int vx_set_namespace(struct vx_info *vxi, struct namespace *ns, struct fs_struct *fs)
13079 + struct fs_struct *fs_copy;
13081 + if (vxi->vx_namespace)
13086 + fs_copy = copy_fs_struct(fs);
13090 + get_namespace(ns);
13091 + vxi->vx_namespace = ns;
13092 + vxi->vx_fs = fs_copy;
13096 +int vc_enter_namespace(uint32_t id, void *data)
13098 + struct vx_info *vxi;
13099 + struct fs_struct *old_fs, *fs;
13100 + struct namespace *old_ns;
13103 + if (!vx_check(0, VX_ADMIN))
13106 + vxi = locate_vx_info(id);
13111 + if (!vxi->vx_namespace)
13115 + fs = copy_fs_struct(vxi->vx_fs);
13120 + task_lock(current);
13121 + old_ns = current->namespace;
13122 + old_fs = current->fs;
13123 + get_namespace(vxi->vx_namespace);
13124 + current->namespace = vxi->vx_namespace;
13125 + current->fs = fs;
13126 + task_unlock(current);
13128 + put_namespace(old_ns);
13129 + put_fs_struct(old_fs);
13131 + put_vx_info(vxi);
13135 +int vc_cleanup_namespace(uint32_t id, void *data)
13137 + down_write(¤t->namespace->sem);
13138 + spin_lock(&vfsmount_lock);
13139 + umount_unused(current->namespace->root, current->fs);
13140 + spin_unlock(&vfsmount_lock);
13141 + up_write(¤t->namespace->sem);
13145 +int vc_set_namespace(uint32_t id, void __user *data)
13147 + struct fs_struct *fs;
13148 + struct namespace *ns;
13149 + struct vx_info *vxi;
13152 + if (vx_check(0, VX_ADMIN|VX_WATCH))
13155 + task_lock(current);
13156 + vxi = get_vx_info(current->vx_info);
13157 + fs = current->fs;
13158 + atomic_inc(&fs->count);
13159 + ns = current->namespace;
13160 + get_namespace(current->namespace);
13161 + task_unlock(current);
13163 + ret = vx_set_namespace(vxi, ns, fs);
13165 + put_namespace(ns);
13166 + put_fs_struct(fs);
13167 + put_vx_info(vxi);
13171 diff -NurpP --minimal linux-2.6.10/kernel/vserver/network.c linux-2.6.10-vs1.9.3.17/kernel/vserver/network.c
13172 --- linux-2.6.10/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
13173 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/network.c 2005-01-04 14:22:07.000000000 +0100
13176 + * linux/kernel/vserver/network.c
13178 + * Virtual Server: Network Support
13180 + * Copyright (C) 2003-2004 Herbert Pötzl
13182 + * V0.01 broken out from vcontext V0.05
13183 + * V0.02 cleaned up implementation
13184 + * V0.03 added equiv nx commands
13185 + * V0.04 switch to RCU based hash
13189 +#include <linux/config.h>
13190 +#include <linux/slab.h>
13191 +#include <linux/vserver/network_cmd.h>
13192 +#include <linux/rcupdate.h>
13193 +#include <net/tcp.h>
13195 +#include <asm/errno.h>
13198 +/* __alloc_nx_info()
13200 + * allocate an initialized nx_info struct
13201 + * doesn't make it visible (hash) */
13203 +static struct nx_info *__alloc_nx_info(nid_t nid)
13205 + struct nx_info *new = NULL;
13207 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
13209 + /* would this benefit from a slab cache? */
13210 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
13214 + memset (new, 0, sizeof(struct nx_info));
13215 + new->nx_id = nid;
13216 + INIT_RCU_HEAD(&new->nx_rcu);
13217 + INIT_HLIST_NODE(&new->nx_hlist);
13218 + atomic_set(&new->nx_refcnt, 0);
13219 + atomic_set(&new->nx_usecnt, 0);
13221 + /* rest of init goes here */
13223 + vxdprintk(VXD_CBIT(nid, 0),
13224 + "alloc_nx_info() = %p", new);
13228 +/* __dealloc_nx_info()
13230 + * final disposal of nx_info */
13232 +static void __dealloc_nx_info(struct nx_info *nxi)
13234 + vxdprintk(VXD_CBIT(nid, 0),
13235 + "dealloc_nx_info(%p)", nxi);
13237 + nxi->nx_hlist.next = LIST_POISON1;
13240 + BUG_ON(atomic_read(&nxi->nx_usecnt));
13241 + BUG_ON(atomic_read(&nxi->nx_refcnt));
13246 +static inline int __free_nx_info(struct nx_info *nxi)
13248 + int usecnt, refcnt;
13252 + usecnt = atomic_read(&nxi->nx_usecnt);
13253 + BUG_ON(usecnt < 0);
13255 + refcnt = atomic_read(&nxi->nx_refcnt);
13256 + BUG_ON(refcnt < 0);
13259 + __dealloc_nx_info(nxi);
13263 +static void __rcu_put_nx_info(struct rcu_head *head)
13265 + struct nx_info *nxi = container_of(head, struct nx_info, nx_rcu);
13267 + vxdprintk(VXD_CBIT(nid, 3),
13268 + "__rcu_put_nx_info(%p[#%d]): %d,%d",
13270 + atomic_read(&nxi->nx_usecnt),
13271 + atomic_read(&nxi->nx_refcnt));
13272 + put_nx_info(nxi);
13276 +/* hash table for nx_info hash */
13278 +#define NX_HASH_SIZE 13
13280 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
13282 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
13285 +static inline unsigned int __hashval(nid_t nid)
13287 + return (nid % NX_HASH_SIZE);
13292 +/* __hash_nx_info()
13294 + * add the nxi to the global hash table
13295 + * requires the hash_lock to be held */
13297 +static inline void __hash_nx_info(struct nx_info *nxi)
13299 + struct hlist_head *head;
13301 + vxdprintk(VXD_CBIT(nid, 4),
13302 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
13303 + get_nx_info(nxi);
13304 + head = &nx_info_hash[__hashval(nxi->nx_id)];
13305 + hlist_add_head_rcu(&nxi->nx_hlist, head);
13308 +/* __unhash_nx_info()
13310 + * remove the nxi from the global hash table
13311 + * requires the hash_lock to be held */
13313 +static inline void __unhash_nx_info(struct nx_info *nxi)
13315 + vxdprintk(VXD_CBIT(nid, 4),
13316 + "__unhash_nx_info: %p[#%d]", nxi, nxi->nx_id);
13317 + hlist_del_rcu(&nxi->nx_hlist);
13318 + call_rcu(&nxi->nx_rcu, __rcu_put_nx_info);
13322 +/* __lookup_nx_info()
13324 + * requires the rcu_read_lock()
13325 + * doesn't increment the nx_refcnt */
13327 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
13329 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
13330 + struct hlist_node *pos;
13332 + hlist_for_each_rcu(pos, head) {
13333 + struct nx_info *nxi =
13334 + hlist_entry(pos, struct nx_info, nx_hlist);
13336 + if (nxi->nx_id == nid) {
13344 +/* __nx_dynamic_id()
13346 + * find unused dynamic nid
13347 + * requires the rcu_read_lock()
13348 + * requires the hash_lock to be held */
13350 +static inline nid_t __nx_dynamic_id(void)
13352 + static nid_t seq = MAX_N_CONTEXT;
13353 + nid_t barrier = seq;
13356 + if (++seq > MAX_N_CONTEXT)
13357 + seq = MIN_D_CONTEXT;
13358 + if (!__lookup_nx_info(seq)) {
13359 + vxdprintk(VXD_CBIT(nid, 4),
13360 + "__nx_dynamic_id: [#%d]", seq);
13363 + } while (barrier != seq);
13367 +/* __loc_nx_info()
13369 + * locate or create the requested context
13370 + * get() it and if new hash it */
13372 +static struct nx_info * __loc_nx_info(int id, int *err)
13374 + struct nx_info *new, *nxi = NULL;
13376 + vxdprintk(VXD_CBIT(nid, 1), "loc_nx_info(%d)*", id);
13378 + if (!(new = __alloc_nx_info(id))) {
13383 + /* FIXME is this required at all ? */
13385 + /* required to make dynamic xids unique */
13386 + spin_lock(&nx_info_hash_lock);
13388 + /* dynamic context requested */
13389 + if (id == NX_DYNAMIC_ID) {
13390 + id = __nx_dynamic_id();
13392 + printk(KERN_ERR "no dynamic context available.\n");
13397 + /* existing context requested */
13398 + else if ((nxi = __lookup_nx_info(id))) {
13399 + /* context in setup is not available */
13400 + if (nxi->nx_flags & VXF_STATE_SETUP) {
13401 + vxdprintk(VXD_CBIT(nid, 0),
13402 + "loc_nx_info(%d) = %p (not available)", id, nxi);
13406 + vxdprintk(VXD_CBIT(nid, 0),
13407 + "loc_nx_info(%d) = %p (found)", id, nxi);
13408 + get_nx_info(nxi);
13414 + /* new context requested */
13415 + vxdprintk(VXD_CBIT(nid, 0),
13416 + "loc_nx_info(%d) = %p (new)", id, new);
13417 + __hash_nx_info(get_nx_info(new));
13418 + nxi = new, new = NULL;
13422 + spin_unlock(&nx_info_hash_lock);
13423 + rcu_read_unlock();
13425 + __dealloc_nx_info(new);
13431 +/* exported stuff */
13433 +void free_nx_info(struct nx_info *nxi)
13435 + BUG_ON(__free_nx_info(nxi));
13438 +void unhash_nx_info(struct nx_info *nxi)
13440 + spin_lock(&nx_info_hash_lock);
13441 + __unhash_nx_info(nxi);
13442 + spin_unlock(&nx_info_hash_lock);
13445 +/* locate_nx_info()
13447 + * search for a nx_info and get() it
13448 + * negative id means current */
13450 +struct nx_info *locate_nx_info(int id)
13452 + struct nx_info *nxi;
13455 + nxi = get_nx_info(current->nx_info);
13458 + nxi = get_nx_info(__lookup_nx_info(id));
13459 + rcu_read_unlock();
13464 +/* nx_info_is_hashed()
13466 + * verify that nid is still hashed */
13468 +int nx_info_is_hashed(nid_t nid)
13473 + hashed = (__lookup_nx_info(nid) != NULL);
13474 + rcu_read_unlock();
13478 +#ifdef CONFIG_VSERVER_LEGACY
13480 +struct nx_info *locate_or_create_nx_info(int id)
13484 + return __loc_nx_info(id, &err);
13487 +struct nx_info *create_nx_info(void)
13489 + struct nx_info *new;
13492 + vxdprintk(VXD_CBIT(nid, 5), "create_nx_info(%s)", "void");
13493 + if (!(new = __loc_nx_info(NX_DYNAMIC_ID, &err)))
13501 +#ifdef CONFIG_PROC_FS
13503 +int get_nid_list(int index, unsigned int *nids, int size)
13505 + int hindex, nr_nids = 0;
13508 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
13509 + struct hlist_head *head = &nx_info_hash[hindex];
13510 + struct hlist_node *pos;
13512 + hlist_for_each_rcu(pos, head) {
13513 + struct nx_info *nxi;
13518 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
13519 + nids[nr_nids] = nxi->nx_id;
13520 + if (++nr_nids >= size)
13525 + rcu_read_unlock();
13532 + * migrate task to new network
13535 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
13537 + struct nx_info *old_nxi;
13543 + vxdprintk(VXD_CBIT(nid, 5),
13544 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
13545 + p, nxi, nxi->nx_id,
13546 + atomic_read(&nxi->nx_usecnt),
13547 + atomic_read(&nxi->nx_refcnt));
13549 + old_nxi = task_get_nx_info(p);
13550 + if (old_nxi == nxi)
13554 + /* should be handled in set_nx_info !! */
13556 + clr_nx_info(&p->nx_info);
13557 + set_nx_info(&p->nx_info, nxi);
13558 + p->nid = nxi->nx_id;
13561 + /* obsoleted by clr/set */
13562 + // put_nx_info(old_nxi);
13564 + put_nx_info(old_nxi);
13569 +#include <linux/netdevice.h>
13570 +#include <linux/inetdevice.h>
13573 +int ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
13579 + return addr_in_nx_info(nxi, ifa->ifa_address);
13582 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
13584 + struct in_device *in_dev = __in_dev_get(dev);
13585 + struct in_ifaddr **ifap = NULL;
13586 + struct in_ifaddr *ifa = NULL;
13593 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
13594 + ifap = &ifa->ifa_next) {
13595 + if (addr_in_nx_info(nxi, ifa->ifa_address))
13602 + * check if address is covered by socket
13604 + * sk: the socket to check against
13605 + * addr: the address in question (must be != 0)
13607 +static inline int __addr_in_socket(struct sock *sk, uint32_t addr)
13609 + struct nx_info *nxi = sk->sk_nx_info;
13610 + uint32_t saddr = tcp_v4_rcv_saddr(sk);
13612 + vxdprintk(VXD_CBIT(net, 5),
13613 + "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx",
13614 + sk, VXD_QUAD(addr), nxi, VXD_QUAD(saddr), sk->sk_socket,
13615 + (sk->sk_socket?sk->sk_socket->flags:0));
13618 + /* direct address match */
13619 + return (saddr == addr);
13620 + } else if (nxi) {
13621 + /* match against nx_info */
13622 + return addr_in_nx_info(nxi, addr);
13624 + /* unrestricted any socket */
13630 +int nx_addr_conflict(struct nx_info *nxi, uint32_t addr, struct sock *sk)
13632 + vxdprintk(VXD_CBIT(net, 2),
13633 + "nx_addr_conflict(%p,%p) %d.%d,%d.%d",
13634 + nxi, sk, VXD_QUAD(addr));
13637 + /* check real address */
13638 + return __addr_in_socket(sk, addr);
13639 + } else if (nxi) {
13640 + /* check against nx_info */
13641 + int i, n = nxi->nbipv4;
13643 + for (i=0; i<n; i++)
13644 + if (__addr_in_socket(sk, nxi->ipv4[i]))
13648 + /* check against any */
13654 +/* vserver syscall commands below here */
13656 +/* taks nid and nx_info functions */
13658 +#include <asm/uaccess.h>
13661 +int vc_task_nid(uint32_t id, void __user *data)
13666 + struct task_struct *tsk;
13668 + if (!vx_check(0, VX_ADMIN|VX_WATCH))
13671 + read_lock(&tasklist_lock);
13672 + tsk = find_task_by_real_pid(id);
13673 + nid = (tsk) ? tsk->nid : -ESRCH;
13674 + read_unlock(&tasklist_lock);
13677 + nid = current->nid;
13682 +int vc_nx_info(uint32_t id, void __user *data)
13684 + struct nx_info *nxi;
13685 + struct vcmd_nx_info_v0 vc_data;
13687 + if (!vx_check(0, VX_ADMIN))
13689 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RESOURCE))
13692 + nxi = locate_nx_info(id);
13696 + vc_data.nid = nxi->nx_id;
13697 + put_nx_info(nxi);
13699 + if (copy_to_user (data, &vc_data, sizeof(vc_data)))
13705 +/* network functions */
13707 +int vc_net_create(uint32_t nid, void __user *data)
13709 + // int ret = -ENOMEM;
13710 + struct nx_info *new_nxi;
13713 + if (!capable(CAP_SYS_ADMIN))
13716 + if ((nid >= MIN_D_CONTEXT) && (nid != VX_DYNAMIC_ID))
13722 + new_nxi = __loc_nx_info(nid, &ret);
13725 + if (!(new_nxi->nx_flags & VXF_STATE_SETUP)) {
13730 + ret = new_nxi->nx_id;
13731 + nx_migrate_task(current, new_nxi);
13733 + put_nx_info(new_nxi);
13738 +int vc_net_migrate(uint32_t id, void __user *data)
13740 + struct nx_info *nxi;
13742 + if (!capable(CAP_SYS_ADMIN))
13745 + nxi = locate_nx_info(id);
13748 + nx_migrate_task(current, nxi);
13749 + put_nx_info(nxi);
13753 +int vc_net_add(uint32_t id, void __user *data)
13755 + struct nx_info *nxi;
13756 + struct vcmd_net_nx_v0 vc_data;
13758 + if (!capable(CAP_SYS_ADMIN))
13760 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
13763 + nxi = locate_nx_info(id);
13767 + // add ip to net context here
13768 + put_nx_info(nxi);
13772 +int vc_net_remove(uint32_t id, void __user *data)
13774 + struct nx_info *nxi;
13775 + struct vcmd_net_nx_v0 vc_data;
13777 + if (!capable(CAP_SYS_ADMIN))
13779 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
13782 + nxi = locate_nx_info(id);
13786 + // rem ip from net context here
13787 + put_nx_info(nxi);
13793 +int vc_get_nflags(uint32_t id, void __user *data)
13795 + struct nx_info *nxi;
13796 + struct vcmd_net_flags_v0 vc_data;
13798 + if (!capable(CAP_SYS_ADMIN))
13801 + nxi = locate_nx_info(id);
13805 + vc_data.flagword = nxi->nx_flags;
13807 + /* special STATE flag handling */
13808 + vc_data.mask = vx_mask_flags(~0UL, nxi->nx_flags, IPF_ONE_TIME);
13810 + put_nx_info(nxi);
13812 + if (copy_to_user (data, &vc_data, sizeof(vc_data)))
13817 +int vc_set_nflags(uint32_t id, void __user *data)
13819 + struct nx_info *nxi;
13820 + struct vcmd_net_flags_v0 vc_data;
13821 + uint64_t mask, trigger;
13823 + if (!capable(CAP_SYS_ADMIN))
13825 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
13828 + nxi = locate_nx_info(id);
13832 + /* special STATE flag handling */
13833 + mask = vx_mask_mask(vc_data.mask, nxi->nx_flags, IPF_ONE_TIME);
13834 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
13835 + // if (trigger & IPF_STATE_SETUP)
13837 + nxi->nx_flags = vx_mask_flags(nxi->nx_flags,
13838 + vc_data.flagword, mask);
13839 + put_nx_info(nxi);
13843 +int vc_get_ncaps(uint32_t id, void __user *data)
13845 + struct nx_info *nxi;
13846 + struct vcmd_net_caps_v0 vc_data;
13848 + if (!capable(CAP_SYS_ADMIN))
13851 + nxi = locate_nx_info(id);
13855 + vc_data.ncaps = nxi->nx_ncaps;
13856 + vc_data.cmask = ~0UL;
13857 + put_nx_info(nxi);
13859 + if (copy_to_user (data, &vc_data, sizeof(vc_data)))
13864 +int vc_set_ncaps(uint32_t id, void __user *data)
13866 + struct nx_info *nxi;
13867 + struct vcmd_net_caps_v0 vc_data;
13869 + if (!capable(CAP_SYS_ADMIN))
13871 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
13874 + nxi = locate_nx_info(id);
13878 + nxi->nx_ncaps = vx_mask_flags(nxi->nx_ncaps,
13879 + vc_data.ncaps, vc_data.cmask);
13880 + put_nx_info(nxi);
13885 +#include <linux/module.h>
13887 +EXPORT_SYMBOL_GPL(free_nx_info);
13888 +EXPORT_SYMBOL_GPL(unhash_nx_info);
13890 diff -NurpP --minimal linux-2.6.10/kernel/vserver/proc.c linux-2.6.10-vs1.9.3.17/kernel/vserver/proc.c
13891 --- linux-2.6.10/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
13892 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/proc.c 2004-12-26 19:40:24.000000000 +0100
13895 + * linux/kernel/vserver/proc.c
13897 + * Virtual Context Support
13899 + * Copyright (C) 2003-2004 Herbert Pötzl
13901 + * V0.01 basic structure
13902 + * V0.02 adaptation vs1.3.0
13903 + * V0.03 proc permissions
13904 + * V0.04 locking/generic
13905 + * V0.05 next generation procfs
13906 + * V0.06 inode validation
13907 + * V0.07 generic rewrite vid
13911 +#include <linux/config.h>
13912 +#include <linux/errno.h>
13913 +#include <linux/proc_fs.h>
13914 +#include <linux/sched.h>
13915 +#include <linux/vs_context.h>
13916 +#include <linux/vs_network.h>
13917 +#include <linux/vs_cvirt.h>
13919 +#include <linux/vserver/switch.h>
13921 +#include <asm/uaccess.h>
13922 +#include <asm/unistd.h>
13924 +#include "cvirt_proc.h"
13925 +#include "limit_proc.h"
13926 +#include "sched_proc.h"
13928 +static struct proc_dir_entry *proc_virtual;
13930 +static struct proc_dir_entry *proc_vnet;
13933 +enum vid_directory_inos {
13934 + PROC_XID_INO = 32,
13942 + PROC_NID_INO = 64,
13947 +#define PROC_VID_MASK 0x60
13950 +/* first the actual feeds */
13953 +static int proc_virtual_info(int vid, char *buffer)
13955 + return sprintf(buffer,
13956 + "VCIVersion:\t%04x:%04x\n"
13957 + "VCISyscall:\t%d\n"
13958 + ,VCI_VERSION >> 16
13959 + ,VCI_VERSION & 0xFFFF
13965 +int proc_xid_info (int vid, char *buffer)
13967 + struct vx_info *vxi;
13970 + vxi = locate_vx_info(vid);
13973 + length = sprintf(buffer,
13981 + put_vx_info(vxi);
13985 +int proc_xid_status (int vid, char *buffer)
13987 + struct vx_info *vxi;
13990 + vxi = locate_vx_info(vid);
13993 + length = sprintf(buffer,
13996 + "Flags:\t%016llx\n"
13997 + "BCaps:\t%016llx\n"
13998 + "CCaps:\t%016llx\n"
14000 + ,atomic_read(&vxi->vx_usecnt)
14001 + ,atomic_read(&vxi->vx_refcnt)
14002 + ,(unsigned long long)vxi->vx_flags
14003 + ,(unsigned long long)vxi->vx_bcaps
14004 + ,(unsigned long long)vxi->vx_ccaps
14005 + ,atomic_read(&vxi->limit.ticks)
14007 + put_vx_info(vxi);
14011 +int proc_xid_limit (int vid, char *buffer)
14013 + struct vx_info *vxi;
14016 + vxi = locate_vx_info(vid);
14019 + length = vx_info_proc_limit(&vxi->limit, buffer);
14020 + put_vx_info(vxi);
14024 +int proc_xid_sched (int vid, char *buffer)
14026 + struct vx_info *vxi;
14029 + vxi = locate_vx_info(vid);
14032 + length = vx_info_proc_sched(&vxi->sched, buffer);
14033 + put_vx_info(vxi);
14037 +int proc_xid_cvirt (int vid, char *buffer)
14039 + struct vx_info *vxi;
14042 + vxi = locate_vx_info(vid);
14045 + vx_update_load(vxi);
14046 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
14047 + put_vx_info(vxi);
14051 +int proc_xid_cacct (int vid, char *buffer)
14053 + struct vx_info *vxi;
14056 + vxi = locate_vx_info(vid);
14059 + length = vx_info_proc_cacct(&vxi->cacct, buffer);
14060 + put_vx_info(vxi);
14065 +static int proc_vnet_info(int vid, char *buffer)
14067 + return sprintf(buffer,
14068 + "VCIVersion:\t%04x:%04x\n"
14069 + "VCISyscall:\t%d\n"
14070 + ,VCI_VERSION >> 16
14071 + ,VCI_VERSION & 0xFFFF
14076 +#define atoquad(a) \
14077 + (((a)>>0) & 0xff), (((a)>>8) & 0xff), \
14078 + (((a)>>16) & 0xff), (((a)>>24) & 0xff)
14080 +int proc_nid_info (int vid, char *buffer)
14082 + struct nx_info *nxi;
14085 + nxi = locate_nx_info(vid);
14088 + length = sprintf(buffer,
14094 + for (i=0; i<nxi->nbipv4; i++) {
14095 + length += sprintf(buffer + length,
14096 + "%d:\t%d.%d.%d.%d/%d.%d.%d.%d\n", i,
14097 + atoquad(nxi->ipv4[i]),
14098 + atoquad(nxi->mask[i]));
14100 + put_nx_info(nxi);
14104 +int proc_nid_status (int vid, char *buffer)
14106 + struct nx_info *nxi;
14109 + nxi = locate_nx_info(vid);
14112 + length = sprintf(buffer,
14115 + ,atomic_read(&nxi->nx_usecnt)
14116 + ,atomic_read(&nxi->nx_refcnt)
14118 + put_nx_info(nxi);
14122 +/* here the inode helpers */
14125 +#define fake_ino(id,nr) (((nr) & 0xFFFF) | \
14126 + (((id) & 0xFFFF) << 16))
14128 +#define inode_vid(i) (((i)->i_ino >> 16) & 0xFFFF)
14129 +#define inode_type(i) ((i)->i_ino & 0xFFFF)
14131 +#define MAX_MULBY10 ((~0U-9)/10)
14134 +static struct inode *proc_vid_make_inode(struct super_block * sb,
14135 + int vid, int ino)
14137 + struct inode *inode = new_inode(sb);
14142 + inode->i_mtime = inode->i_atime =
14143 + inode->i_ctime = CURRENT_TIME;
14144 + inode->i_ino = fake_ino(vid, ino);
14146 + inode->i_uid = 0;
14147 + inode->i_gid = 0;
14148 + // inode->i_xid = xid;
14153 +static int proc_vid_revalidate(struct dentry * dentry, struct nameidata *nd)
14155 + struct inode * inode = dentry->d_inode;
14156 + int vid, hashed=0;
14158 + vid = inode_vid(inode);
14159 + switch (inode_type(inode) & PROC_VID_MASK) {
14160 + case PROC_XID_INO:
14161 + hashed = vx_info_is_hashed(vid);
14163 + case PROC_NID_INO:
14164 + hashed = nx_info_is_hashed(vid);
14174 +static int proc_vid_delete_dentry(struct dentry * dentry)
14181 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
14183 +static ssize_t proc_vid_info_read(struct file * file, char * buf,
14184 + size_t count, loff_t *ppos)
14186 + struct inode * inode = file->f_dentry->d_inode;
14187 + unsigned long page;
14192 + if (count > PROC_BLOCK_SIZE)
14193 + count = PROC_BLOCK_SIZE;
14194 + if (!(page = __get_free_page(GFP_KERNEL)))
14197 + vid = inode_vid(inode);
14198 + length = PROC_I(inode)->op.proc_vid_read(vid, (char*)page);
14200 + if (length < 0) {
14204 + /* Static 4kB (or whatever) block capacity */
14205 + if (*ppos >= length) {
14209 + if (count + *ppos > length)
14210 + count = length - *ppos;
14211 + end = count + *ppos;
14212 + copy_to_user(buf, (char *) page + *ppos, count);
14222 +/* here comes the lower level (vid) */
14224 +static struct file_operations proc_vid_info_file_operations = {
14225 + read: proc_vid_info_read,
14228 +static struct dentry_operations proc_vid_dentry_operations = {
14229 + d_revalidate: proc_vid_revalidate,
14230 +// d_delete: proc_vid_delete_dentry,
14234 +struct vid_entry {
14241 +#define E(type,name,mode) {(type),sizeof(name)-1,(name),(mode)}
14243 +static struct vid_entry vx_base_stuff[] = {
14244 + E(PROC_XID_INFO, "info", S_IFREG|S_IRUGO),
14245 + E(PROC_XID_STATUS, "status", S_IFREG|S_IRUGO),
14246 + E(PROC_XID_LIMIT, "limit", S_IFREG|S_IRUGO),
14247 + E(PROC_XID_SCHED, "sched", S_IFREG|S_IRUGO),
14248 + E(PROC_XID_CVIRT, "cvirt", S_IFREG|S_IRUGO),
14249 + E(PROC_XID_CACCT, "cacct", S_IFREG|S_IRUGO),
14253 +static struct vid_entry vn_base_stuff[] = {
14254 + E(PROC_NID_INFO, "info", S_IFREG|S_IRUGO),
14255 + E(PROC_NID_STATUS, "status", S_IFREG|S_IRUGO),
14261 +static struct dentry *proc_vid_lookup(struct inode *dir,
14262 + struct dentry *dentry, struct nameidata *nd)
14264 + struct inode *inode;
14265 + struct vid_entry *p;
14271 + switch (inode_type(dir)) {
14272 + case PROC_XID_INO:
14273 + p = vx_base_stuff;
14275 + case PROC_NID_INO:
14276 + p = vn_base_stuff;
14282 + for (; p->name; p++) {
14283 + if (p->len != dentry->d_name.len)
14285 + if (!memcmp(dentry->d_name.name, p->name, p->len))
14292 + inode = proc_vid_make_inode(dir->i_sb, inode_vid(dir), p->type);
14296 + switch(p->type) {
14297 + case PROC_XID_INFO:
14298 + PROC_I(inode)->op.proc_vid_read = proc_xid_info;
14300 + case PROC_XID_STATUS:
14301 + PROC_I(inode)->op.proc_vid_read = proc_xid_status;
14303 + case PROC_XID_LIMIT:
14304 + PROC_I(inode)->op.proc_vid_read = proc_xid_limit;
14306 + case PROC_XID_SCHED:
14307 + PROC_I(inode)->op.proc_vid_read = proc_xid_sched;
14309 + case PROC_XID_CVIRT:
14310 + PROC_I(inode)->op.proc_vid_read = proc_xid_cvirt;
14312 + case PROC_XID_CACCT:
14313 + PROC_I(inode)->op.proc_vid_read = proc_xid_cacct;
14316 + case PROC_NID_INFO:
14317 + PROC_I(inode)->op.proc_vid_read = proc_nid_info;
14319 + case PROC_NID_STATUS:
14320 + PROC_I(inode)->op.proc_vid_read = proc_nid_status;
14324 + printk("procfs: impossible type (%d)",p->type);
14326 + return ERR_PTR(-EINVAL);
14328 + inode->i_mode = p->mode;
14329 +// inode->i_op = &proc_vid_info_inode_operations;
14330 + inode->i_fop = &proc_vid_info_file_operations;
14331 + inode->i_nlink = 1;
14332 + inode->i_flags|=S_IMMUTABLE;
14334 + dentry->d_op = &proc_vid_dentry_operations;
14335 + d_add(dentry, inode);
14338 + return ERR_PTR(error);
14342 +static int proc_vid_readdir(struct file * filp,
14343 + void * dirent, filldir_t filldir)
14346 + struct inode *inode = filp->f_dentry->d_inode;
14347 + struct vid_entry *p;
14352 + if (filldir(dirent, ".", 1, i,
14353 + inode->i_ino, DT_DIR) < 0)
14357 + /* fall through */
14359 + if (filldir(dirent, "..", 2, i,
14360 + PROC_ROOT_INO, DT_DIR) < 0)
14364 + /* fall through */
14367 + switch (inode_type(inode)) {
14368 + case PROC_XID_INO:
14369 + size = sizeof(vx_base_stuff);
14370 + p = vx_base_stuff + i;
14372 + case PROC_NID_INO:
14373 + size = sizeof(vn_base_stuff);
14374 + p = vn_base_stuff + i;
14379 + if (i >= size/sizeof(struct vid_entry))
14381 + while (p->name) {
14382 + if (filldir(dirent, p->name, p->len,
14383 + filp->f_pos, fake_ino(inode_vid(inode),
14384 + p->type), p->mode >> 12) < 0)
14396 +/* now the upper level (virtual) */
14398 +static struct file_operations proc_vid_file_operations = {
14399 + read: generic_read_dir,
14400 + readdir: proc_vid_readdir,
14403 +static struct inode_operations proc_vid_inode_operations = {
14404 + lookup: proc_vid_lookup,
14409 +static __inline__ int atovid(const char *str, int len)
14414 + while (len-- > 0) {
14419 + if (vid >= MAX_MULBY10)
14430 +struct dentry *proc_virtual_lookup(struct inode *dir,
14431 + struct dentry * dentry, struct nameidata *nd)
14433 + int xid, len, ret;
14434 + struct vx_info *vxi;
14435 + const char *name;
14436 + struct inode *inode;
14438 + name = dentry->d_name.name;
14439 + len = dentry->d_name.len;
14442 + if (len == 7 && !memcmp(name, "current", 7)) {
14443 + inode = new_inode(dir->i_sb);
14446 + inode->i_mtime = inode->i_atime =
14447 + inode->i_ctime = CURRENT_TIME;
14448 + inode->i_ino = fake_ino(1, PROC_XID_INO);
14449 + inode->i_mode = S_IFLNK|S_IRWXUGO;
14450 + inode->i_uid = inode->i_gid = 0;
14451 + inode->i_size = 64;
14452 +// inode->i_op = &proc_current_inode_operations;
14453 + d_add(dentry, inode);
14456 + if (len == 4 && !memcmp(name, "info", 4)) {
14457 + inode = proc_vid_make_inode(dir->i_sb, 0, PROC_XID_INFO);
14460 + inode->i_fop = &proc_vid_info_file_operations;
14461 + PROC_I(inode)->op.proc_vid_read = proc_virtual_info;
14462 + inode->i_mode = S_IFREG|S_IRUGO;
14463 +// inode->i_size = 64;
14464 +// inode->i_op = &proc_current_inode_operations;
14465 + d_add(dentry, inode);
14470 + xid = atovid(name, len);
14473 + vxi = locate_vx_info(xid);
14478 + if (vx_check(xid, VX_ADMIN|VX_WATCH|VX_IDENT))
14479 + inode = proc_vid_make_inode(dir->i_sb,
14480 + vxi->vx_id, PROC_XID_INO);
14482 + goto out_release;
14484 + inode->i_mode = S_IFDIR|S_IRUGO;
14485 + inode->i_op = &proc_vid_inode_operations;
14486 + inode->i_fop = &proc_vid_file_operations;
14487 + inode->i_nlink = 2;
14488 + inode->i_flags|=S_IMMUTABLE;
14490 + dentry->d_op = &proc_vid_dentry_operations;
14491 + d_add(dentry, inode);
14495 + put_vx_info(vxi);
14497 + return ERR_PTR(ret);
14501 +struct dentry *proc_vnet_lookup(struct inode *dir,
14502 + struct dentry * dentry, struct nameidata *nd)
14504 + int nid, len, ret;
14505 + struct nx_info *nxi;
14506 + const char *name;
14507 + struct inode *inode;
14509 + name = dentry->d_name.name;
14510 + len = dentry->d_name.len;
14512 + if (len == 7 && !memcmp(name, "current", 7)) {
14513 + inode = new_inode(dir->i_sb);
14516 + inode->i_mtime = inode->i_atime =
14517 + inode->i_ctime = CURRENT_TIME;
14518 + inode->i_ino = fake_ino(1, PROC_NID_INO);
14519 + inode->i_mode = S_IFLNK|S_IRWXUGO;
14520 + inode->i_uid = inode->i_gid = 0;
14521 + inode->i_size = 64;
14522 +// inode->i_op = &proc_current_inode_operations;
14523 + d_add(dentry, inode);
14526 + if (len == 4 && !memcmp(name, "info", 4)) {
14527 + inode = proc_vid_make_inode(dir->i_sb, 0, PROC_NID_INFO);
14530 + inode->i_fop = &proc_vid_info_file_operations;
14531 + PROC_I(inode)->op.proc_vid_read = proc_vnet_info;
14532 + inode->i_mode = S_IFREG|S_IRUGO;
14533 +// inode->i_size = 64;
14534 +// inode->i_op = &proc_current_inode_operations;
14535 + d_add(dentry, inode);
14540 + nid = atovid(name, len);
14543 + nxi = locate_nx_info(nid);
14549 + inode = proc_vid_make_inode(dir->i_sb,
14550 + nxi->nx_id, PROC_NID_INO);
14552 + goto out_release;
14554 + inode->i_mode = S_IFDIR|S_IRUGO;
14555 + inode->i_op = &proc_vid_inode_operations;
14556 + inode->i_fop = &proc_vid_file_operations;
14557 + inode->i_nlink = 2;
14558 + inode->i_flags|=S_IMMUTABLE;
14560 + dentry->d_op = &proc_vid_dentry_operations;
14561 + d_add(dentry, inode);
14565 + put_nx_info(nxi);
14567 + return ERR_PTR(ret);
14573 +#define PROC_NUMBUF 10
14574 +#define PROC_MAXVIDS 32
14576 +int proc_virtual_readdir(struct file * filp,
14577 + void * dirent, filldir_t filldir)
14579 + unsigned int xid_array[PROC_MAXVIDS];
14580 + char buf[PROC_NUMBUF];
14581 + unsigned int nr = filp->f_pos-3;
14582 + unsigned int nr_xids, i;
14585 + switch ((long)filp->f_pos) {
14587 + ino = fake_ino(0, PROC_XID_INO);
14588 + if (filldir(dirent, ".", 1,
14589 + filp->f_pos, ino, DT_DIR) < 0)
14592 + /* fall through */
14594 + ino = filp->f_dentry->d_parent->d_inode->i_ino;
14595 + if (filldir(dirent, "..", 2,
14596 + filp->f_pos, ino, DT_DIR) < 0)
14599 + /* fall through */
14601 + ino = fake_ino(0, PROC_XID_INFO);
14602 + if (filldir(dirent, "info", 4,
14603 + filp->f_pos, ino, DT_LNK) < 0)
14606 + /* fall through */
14608 + if (vx_current_xid() > 1) {
14609 + ino = fake_ino(1, PROC_XID_INO);
14610 + if (filldir(dirent, "current", 7,
14611 + filp->f_pos, ino, DT_LNK) < 0)
14617 + nr_xids = get_xid_list(nr, xid_array, PROC_MAXVIDS);
14618 + for (i = 0; i < nr_xids; i++) {
14619 + int xid = xid_array[i];
14620 + ino_t ino = fake_ino(xid, PROC_XID_INO);
14621 + unsigned int j = PROC_NUMBUF;
14623 + do buf[--j] = '0' + (xid % 10); while (xid/=10);
14625 + if (filldir(dirent, buf+j, PROC_NUMBUF-j,
14626 + filp->f_pos, ino, DT_DIR) < 0)
14634 +static struct file_operations proc_virtual_dir_operations = {
14635 + read: generic_read_dir,
14636 + readdir: proc_virtual_readdir,
14639 +static struct inode_operations proc_virtual_dir_inode_operations = {
14640 + lookup: proc_virtual_lookup,
14644 +int proc_vnet_readdir(struct file * filp,
14645 + void * dirent, filldir_t filldir)
14647 + unsigned int nid_array[PROC_MAXVIDS];
14648 + char buf[PROC_NUMBUF];
14649 + unsigned int nr = filp->f_pos-3;
14650 + unsigned int nr_nids, i;
14653 + switch ((long)filp->f_pos) {
14655 + ino = fake_ino(0, PROC_NID_INO);
14656 + if (filldir(dirent, ".", 1,
14657 + filp->f_pos, ino, DT_DIR) < 0)
14660 + /* fall through */
14662 + ino = filp->f_dentry->d_parent->d_inode->i_ino;
14663 + if (filldir(dirent, "..", 2,
14664 + filp->f_pos, ino, DT_DIR) < 0)
14667 + /* fall through */
14669 + ino = fake_ino(0, PROC_NID_INFO);
14670 + if (filldir(dirent, "info", 4,
14671 + filp->f_pos, ino, DT_LNK) < 0)
14674 + /* fall through */
14676 + if (vx_current_xid() > 1) {
14677 + ino = fake_ino(1, PROC_NID_INO);
14678 + if (filldir(dirent, "current", 7,
14679 + filp->f_pos, ino, DT_LNK) < 0)
14685 + nr_nids = get_nid_list(nr, nid_array, PROC_MAXVIDS);
14686 + for (i = 0; i < nr_nids; i++) {
14687 + int nid = nid_array[i];
14688 + ino_t ino = fake_ino(nid, PROC_NID_INO);
14689 + unsigned long j = PROC_NUMBUF;
14691 + do buf[--j] = '0' + (nid % 10); while (nid/=10);
14693 + if (filldir(dirent, buf+j, PROC_NUMBUF-j,
14694 + filp->f_pos, ino, DT_DIR) < 0)
14702 +static struct file_operations proc_vnet_dir_operations = {
14703 + read: generic_read_dir,
14704 + readdir: proc_vnet_readdir,
14707 +static struct inode_operations proc_vnet_dir_inode_operations = {
14708 + lookup: proc_vnet_lookup,
14713 +void proc_vx_init(void)
14715 + struct proc_dir_entry *ent;
14717 + ent = proc_mkdir("virtual", 0);
14719 + ent->proc_fops = &proc_virtual_dir_operations;
14720 + ent->proc_iops = &proc_virtual_dir_inode_operations;
14722 + proc_virtual = ent;
14724 + ent = proc_mkdir("virtnet", 0);
14726 + ent->proc_fops = &proc_vnet_dir_operations;
14727 + ent->proc_iops = &proc_vnet_dir_inode_operations;
14735 +/* per pid info */
14738 +char *task_vx_info(struct task_struct *p, char *buffer)
14740 + struct vx_info *vxi;
14742 + buffer += sprintf (buffer,"XID:\t%d\n", vx_task_xid(p));
14743 + vxi = task_get_vx_info(p);
14744 + if (vxi && !vx_flags(VXF_INFO_HIDE, 0)) {
14745 + buffer += sprintf (buffer,"BCaps:\t%016llx\n"
14746 + ,(unsigned long long)vxi->vx_bcaps);
14747 + buffer += sprintf (buffer,"CCaps:\t%016llx\n"
14748 + ,(unsigned long long)vxi->vx_ccaps);
14749 + buffer += sprintf (buffer,"CFlags:\t%016llx\n"
14750 + ,(unsigned long long)vxi->vx_flags);
14751 + buffer += sprintf (buffer,"CIPid:\t%d\n"
14752 + ,vxi->vx_initpid);
14754 + put_vx_info(vxi);
14758 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
14760 + char * orig = buffer;
14762 + buffer = task_vx_info(p, buffer);
14763 + return buffer - orig;
14766 +char *task_nx_info(struct task_struct *p, char *buffer)
14768 + struct nx_info *nxi;
14770 + buffer += sprintf (buffer,"NID:\t%d\n", nx_task_nid(p));
14771 + nxi = task_get_nx_info(p);
14772 + if (nxi && !vx_flags(VXF_INFO_HIDE, 0)) {
14775 + for (i=0; i<nxi->nbipv4; i++){
14776 + buffer += sprintf (buffer,
14777 + "V4Root[%d]:\t%d.%d.%d.%d/%d.%d.%d.%d\n", i
14778 + ,NIPQUAD(nxi->ipv4[i])
14779 + ,NIPQUAD(nxi->mask[i]));
14781 + buffer += sprintf (buffer,
14782 + "V4Root[bcast]:\t%d.%d.%d.%d\n"
14783 + ,NIPQUAD(nxi->v4_bcast));
14785 + put_nx_info(nxi);
14789 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
14791 + char * orig = buffer;
14793 + buffer = task_nx_info(p, buffer);
14794 + return buffer - orig;
14797 diff -NurpP --minimal linux-2.6.10/kernel/vserver/sched.c linux-2.6.10-vs1.9.3.17/kernel/vserver/sched.c
14798 --- linux-2.6.10/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
14799 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/sched.c 2004-12-26 19:40:30.000000000 +0100
14802 + * linux/kernel/vserver/sched.c
14804 + * Virtual Server: Scheduler Support
14806 + * Copyright (C) 2004 Herbert Pötzl
14808 + * V0.01 adapted Sam Vilains version to 2.6.3
14809 + * V0.02 removed legacy interface
14813 +#include <linux/config.h>
14814 +#include <linux/sched.h>
14815 +// #include <linux/vs_base.h>
14816 +#include <linux/vs_context.h>
14817 +#include <linux/vs_sched.h>
14818 +#include <linux/vserver/sched_cmd.h>
14820 +#include <asm/errno.h>
14821 +#include <asm/uaccess.h>
14825 + * recalculate the context's scheduling tokens
14827 + * ret > 0 : number of tokens available
14828 + * ret = 0 : context is paused
14829 + * ret < 0 : number of jiffies until new tokens arrive
14832 +int vx_tokens_recalc(struct vx_info *vxi)
14834 + long delta, tokens = 0;
14836 + if (vx_info_flags(vxi, VXF_SCHED_PAUSE, 0))
14837 + /* we are paused */
14840 + delta = jiffies - vxi->sched.jiffies;
14842 + if (delta >= vxi->sched.interval) {
14843 + /* lockdown scheduler info */
14844 + spin_lock(&vxi->sched.tokens_lock);
14846 + /* calc integral token part */
14847 + delta = jiffies - vxi->sched.jiffies;
14848 + tokens = delta / vxi->sched.interval;
14849 + delta = tokens * vxi->sched.interval;
14850 + tokens *= vxi->sched.fill_rate;
14852 + atomic_add(tokens, &vxi->sched.tokens);
14853 + vxi->sched.jiffies += delta;
14854 + tokens = atomic_read(&vxi->sched.tokens);
14856 + if (tokens > vxi->sched.tokens_max) {
14857 + tokens = vxi->sched.tokens_max;
14858 + atomic_set(&vxi->sched.tokens, tokens);
14860 + spin_unlock(&vxi->sched.tokens_lock);
14862 + /* no new tokens */
14863 + tokens = vx_tokens_avail(vxi);
14865 + vxi->vx_state |= VXS_ONHOLD;
14866 + if (tokens < vxi->sched.tokens_min) {
14867 + /* enough tokens will be available in */
14868 + if (vxi->sched.tokens_min == 0)
14869 + return delta - vxi->sched.interval;
14870 + return delta - vxi->sched.interval *
14871 + vxi->sched.tokens_min / vxi->sched.fill_rate;
14875 + /* we have some tokens left */
14876 + if (vx_info_state(vxi, VXS_ONHOLD) &&
14877 + (tokens >= vxi->sched.tokens_min))
14878 + vxi->vx_state &= ~VXS_ONHOLD;
14879 + if (vx_info_state(vxi, VXS_ONHOLD))
14880 + tokens -= vxi->sched.tokens_min;
14886 + * effective_prio - return the priority that is based on the static
14887 + * priority but is modified by bonuses/penalties.
14889 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
14890 + * into a -4 ... 0 ... +4 bonus/penalty range.
14892 + * Additionally, we scale another amount based on the number of
14893 + * CPU tokens currently held by the context, if the process is
14894 + * part of a context (and the appropriate SCHED flag is set).
14895 + * This ranges from -5 ... 0 ... +15, quadratically.
14897 + * So, the total bonus is -9 .. 0 .. +19
14898 + * We use ~50% of the full 0...39 priority range so that:
14900 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
14901 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
14902 + * unless that context is far exceeding its CPU allocation.
14904 + * Both properties are important to certain workloads.
14906 +int effective_vavavoom(task_t *p, int max_prio)
14908 + struct vx_info *vxi = p->vx_info;
14909 + int vavavoom, max;
14911 + /* lots of tokens = lots of vavavoom
14912 + * no tokens = no vavavoom */
14913 + if ((vavavoom = atomic_read(&vxi->sched.tokens)) >= 0) {
14914 + max = vxi->sched.tokens_max;
14915 + vavavoom = max - vavavoom;
14917 + vavavoom = max_prio * VAVAVOOM_RATIO / 100
14918 + * (vavavoom*vavavoom - (max >> 2)) / max;
14919 + /* alternative, geometric mapping
14920 + vavavoom = -( MAX_USER_PRIO*VAVAVOOM_RATIO/100 * vavavoom
14921 + / vxi->sched.tokens_max -
14922 + MAX_USER_PRIO*VAVAVOOM_RATIO/100/2); */
14925 + /* vavavoom = ( MAX_USER_PRIO*VAVAVOOM_RATIO/100*tokens_left(p) -
14926 + MAX_USER_PRIO*VAVAVOOM_RATIO/100/2); */
14932 +int vc_set_sched_v2(uint32_t xid, void __user *data)
14934 + struct vcmd_set_sched_v2 vc_data;
14935 + struct vx_info *vxi;
14937 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
14940 + vxi = locate_vx_info(xid);
14944 + spin_lock(&vxi->sched.tokens_lock);
14946 + if (vc_data.interval != SCHED_KEEP)
14947 + vxi->sched.interval = vc_data.interval;
14948 + if (vc_data.fill_rate != SCHED_KEEP)
14949 + vxi->sched.fill_rate = vc_data.fill_rate;
14950 + if (vc_data.tokens_min != SCHED_KEEP)
14951 + vxi->sched.tokens_min = vc_data.tokens_min;
14952 + if (vc_data.tokens_max != SCHED_KEEP)
14953 + vxi->sched.tokens_max = vc_data.tokens_max;
14954 + if (vc_data.tokens != SCHED_KEEP)
14955 + atomic_set(&vxi->sched.tokens, vc_data.tokens);
14957 + /* Sanity check the resultant values */
14958 + if (vxi->sched.fill_rate <= 0)
14959 + vxi->sched.fill_rate = 1;
14960 + if (vxi->sched.interval <= 0)
14961 + vxi->sched.interval = HZ;
14962 + if (vxi->sched.tokens_max == 0)
14963 + vxi->sched.tokens_max = 1;
14964 + if (atomic_read(&vxi->sched.tokens) > vxi->sched.tokens_max)
14965 + atomic_set(&vxi->sched.tokens, vxi->sched.tokens_max);
14966 + if (vxi->sched.tokens_min > vxi->sched.tokens_max)
14967 + vxi->sched.tokens_min = vxi->sched.tokens_max;
14969 + spin_unlock(&vxi->sched.tokens_lock);
14970 + put_vx_info(vxi);
14975 +int vc_set_sched(uint32_t xid, void __user *data)
14977 + struct vcmd_set_sched_v3 vc_data;
14978 + struct vx_info *vxi;
14979 + unsigned int set_mask;
14981 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
14984 + vxi = locate_vx_info(xid);
14988 + set_mask = vc_data.set_mask;
14990 + spin_lock(&vxi->sched.tokens_lock);
14992 + if (set_mask & VXSM_FILL_RATE)
14993 + vxi->sched.fill_rate = vc_data.fill_rate;
14994 + if (set_mask & VXSM_INTERVAL)
14995 + vxi->sched.interval = vc_data.interval;
14996 + if (set_mask & VXSM_TOKENS)
14997 + atomic_set(&vxi->sched.tokens, vc_data.tokens);
14998 + if (set_mask & VXSM_TOKENS_MIN)
14999 + vxi->sched.tokens_min = vc_data.tokens_min;
15000 + if (set_mask & VXSM_TOKENS_MAX)
15001 + vxi->sched.tokens_max = vc_data.tokens_max;
15002 + if (set_mask & VXSM_PRIO_BIAS)
15003 + vxi->sched.priority_bias = vc_data.priority_bias;
15005 + /* Sanity check the resultant values */
15006 + if (vxi->sched.fill_rate <= 0)
15007 + vxi->sched.fill_rate = 1;
15008 + if (vxi->sched.interval <= 0)
15009 + vxi->sched.interval = HZ;
15010 + if (vxi->sched.tokens_max == 0)
15011 + vxi->sched.tokens_max = 1;
15012 + if (atomic_read(&vxi->sched.tokens) > vxi->sched.tokens_max)
15013 + atomic_set(&vxi->sched.tokens, vxi->sched.tokens_max);
15014 + if (vxi->sched.tokens_min > vxi->sched.tokens_max)
15015 + vxi->sched.tokens_min = vxi->sched.tokens_max;
15016 + if (vxi->sched.priority_bias > MAX_PRIO_BIAS)
15017 + vxi->sched.priority_bias = MAX_PRIO_BIAS;
15018 + if (vxi->sched.priority_bias < MIN_PRIO_BIAS)
15019 + vxi->sched.priority_bias = MIN_PRIO_BIAS;
15021 + spin_unlock(&vxi->sched.tokens_lock);
15022 + put_vx_info(vxi);
15026 diff -NurpP --minimal linux-2.6.10/kernel/vserver/sched_init.h linux-2.6.10-vs1.9.3.17/kernel/vserver/sched_init.h
15027 --- linux-2.6.10/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
15028 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/sched_init.h 2004-12-26 19:40:36.000000000 +0100
15031 +static inline void vx_info_init_sched(struct _vx_sched *sched)
15035 + /* scheduling; hard code starting values as constants */
15036 + sched->fill_rate = 1;
15037 + sched->interval = 4;
15038 + sched->tokens_min = HZ >> 4;
15039 + sched->tokens_max = HZ >> 1;
15040 + sched->jiffies = jiffies;
15041 + sched->tokens_lock = SPIN_LOCK_UNLOCKED;
15043 + atomic_set(&sched->tokens, HZ >> 2);
15044 + sched->cpus_allowed = CPU_MASK_ALL;
15045 + sched->priority_bias = 0;
15047 + for_each_cpu(i) {
15048 + sched->cpu[i].user_ticks = 0;
15049 + sched->cpu[i].sys_ticks = 0;
15050 + sched->cpu[i].hold_ticks = 0;
15054 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
15059 diff -NurpP --minimal linux-2.6.10/kernel/vserver/sched_proc.h linux-2.6.10-vs1.9.3.17/kernel/vserver/sched_proc.h
15060 --- linux-2.6.10/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
15061 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/sched_proc.h 2004-12-26 19:40:36.000000000 +0100
15063 +#ifndef _VX_SCHED_PROC_H
15064 +#define _VX_SCHED_PROC_H
15067 +static inline int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
15072 + length += sprintf(buffer,
15073 + "Token:\t\t%8d\n"
15074 + "FillRate:\t%8d\n"
15075 + "Interval:\t%8d\n"
15076 + "TokensMin:\t%8d\n"
15077 + "TokensMax:\t%8d\n"
15078 + "PrioBias:\t%8d\n"
15079 + ,atomic_read(&sched->tokens)
15080 + ,sched->fill_rate
15082 + ,sched->tokens_min
15083 + ,sched->tokens_max
15084 + ,sched->priority_bias
15087 + for_each_online_cpu(i) {
15088 + length += sprintf(buffer + length,
15089 + "cpu %d: %lld %lld %lld\n"
15091 + ,(long long)sched->cpu[i].user_ticks
15092 + ,(long long)sched->cpu[i].sys_ticks
15093 + ,(long long)sched->cpu[i].hold_ticks
15100 +#endif /* _VX_SCHED_PROC_H */
15101 diff -NurpP --minimal linux-2.6.10/kernel/vserver/signal.c linux-2.6.10-vs1.9.3.17/kernel/vserver/signal.c
15102 --- linux-2.6.10/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
15103 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/signal.c 2004-12-26 19:40:30.000000000 +0100
15106 + * linux/kernel/vserver/signal.c
15108 + * Virtual Server: Signal Support
15110 + * Copyright (C) 2003-2004 Herbert Pötzl
15112 + * V0.01 broken out from vcontext V0.05
15116 +#include <linux/config.h>
15117 +#include <linux/sched.h>
15119 +#include <asm/errno.h>
15120 +#include <asm/uaccess.h>
15122 +#include <linux/vs_context.h>
15123 +#include <linux/vserver/signal.h>
15126 +int vc_ctx_kill(uint32_t id, void __user *data)
15128 + int retval, count=0;
15129 + struct vcmd_ctx_kill_v0 vc_data;
15130 + struct siginfo info;
15131 + struct task_struct *p;
15132 + struct vx_info *vxi;
15134 + if (!vx_check(0, VX_ADMIN))
15136 + if (copy_from_user (&vc_data, data, sizeof(vc_data)))
15139 + info.si_signo = vc_data.sig;
15140 + info.si_errno = 0;
15141 + info.si_code = SI_USER;
15142 + info.si_pid = current->pid;
15143 + info.si_uid = current->uid;
15145 + vxi = locate_vx_info(id);
15150 + read_lock(&tasklist_lock);
15151 + switch (vc_data.pid) {
15154 + for_each_process(p) {
15157 + if (vx_task_xid(p) != id || p->pid <= 1 ||
15158 + (vc_data.pid && vxi->vx_initpid == p->pid) ||
15159 + !thread_group_leader(p))
15162 + err = send_sig_info(vc_data.sig, &info, p);
15164 + if (err != -EPERM)
15170 + p = find_task_by_real_pid(vc_data.pid);
15172 + if (!thread_group_leader(p)) {
15173 + struct task_struct *tg;
15175 + tg = find_task_by_real_pid(p->tgid);
15179 + if ((id == -1) || (vx_task_xid(p) == id))
15180 + retval = send_sig_info(vc_data.sig, &info, p);
15184 + read_unlock(&tasklist_lock);
15185 + put_vx_info(vxi);
15190 +static int __wait_exit(struct vx_info *vxi)
15192 + DECLARE_WAITQUEUE(wait, current);
15195 + add_wait_queue(&vxi->vx_exit, &wait);
15196 + set_current_state(TASK_INTERRUPTIBLE);
15199 + if (vx_info_state(vxi, VXS_DEFUNCT))
15201 + if (signal_pending(current)) {
15202 + ret = -ERESTARTSYS;
15209 + set_current_state(TASK_RUNNING);
15210 + remove_wait_queue(&vxi->vx_exit, &wait);
15216 +int vc_wait_exit(uint32_t id, void __user *data)
15218 +// struct vcmd_wait_exit_v0 vc_data;
15219 + struct vx_info *vxi;
15222 + vxi = locate_vx_info(id);
15226 + ret = __wait_exit(vxi);
15227 + put_vx_info(vxi);
15231 diff -NurpP --minimal linux-2.6.10/kernel/vserver/switch.c linux-2.6.10-vs1.9.3.17/kernel/vserver/switch.c
15232 --- linux-2.6.10/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
15233 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/switch.c 2005-01-02 10:40:56.000000000 +0100
15236 + * linux/kernel/vserver/switch.c
15238 + * Virtual Server: Syscall Switch
15240 + * Copyright (C) 2003-2005 Herbert Pötzl
15242 + * V0.01 syscall switch
15243 + * V0.02 added signal to context
15244 + * V0.03 added rlimit functions
15245 + * V0.04 added iattr, task/xid functions
15246 + * V0.05 added debug/history stuff
15250 +#include <linux/config.h>
15251 +#include <linux/linkage.h>
15252 +#include <linux/sched.h>
15253 +#include <asm/errno.h>
15255 +#include <linux/vserver/network.h>
15256 +#include <linux/vserver/switch.h>
15257 +#include <linux/vserver/debug.h>
15261 +vc_get_version(uint32_t id)
15263 + return VCI_VERSION;
15266 +#include <linux/vserver/context_cmd.h>
15267 +#include <linux/vserver/cvirt_cmd.h>
15268 +#include <linux/vserver/limit_cmd.h>
15269 +#include <linux/vserver/network_cmd.h>
15270 +#include <linux/vserver/sched_cmd.h>
15271 +#include <linux/vserver/debug_cmd.h>
15273 +#include <linux/vserver/legacy.h>
15274 +#include <linux/vserver/namespace.h>
15275 +#include <linux/vserver/inode.h>
15276 +#include <linux/vserver/signal.h>
15277 +#include <linux/vserver/dlimit.h>
15280 +extern asmlinkage long
15281 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
15283 + vxdprintk(VXD_CBIT(switch, 0),
15284 + "vc: VCMD_%02d_%d[%d], %d",
15285 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
15286 + VC_VERSION(cmd), id);
15288 +#ifdef CONFIG_VSERVER_LEGACY
15289 + if (!capable(CAP_CONTEXT) &&
15290 + /* dirty hack for capremove */
15291 + !(cmd==VCMD_new_s_context && id==-2))
15294 + if (!capable(CAP_CONTEXT))
15299 + case VCMD_get_version:
15300 + return vc_get_version(id);
15302 + case VCMD_dump_history:
15303 +#ifdef CONFIG_VSERVER_HISTORY
15304 + return vc_dump_history(id);
15309 +#ifdef CONFIG_VSERVER_LEGACY
15310 + case VCMD_new_s_context:
15311 + return vc_new_s_context(id, data);
15312 + case VCMD_set_ipv4root:
15313 + return vc_set_ipv4root(id, data);
15316 + case VCMD_task_xid:
15317 + return vc_task_xid(id, data);
15318 + case VCMD_vx_info:
15319 + return vc_vx_info(id, data);
15321 + case VCMD_task_nid:
15322 + return vc_task_nid(id, data);
15323 + case VCMD_nx_info:
15324 + return vc_nx_info(id, data);
15326 + case VCMD_set_namespace:
15327 + return vc_set_namespace(id, data);
15328 + case VCMD_cleanup_namespace:
15329 + return vc_cleanup_namespace(id, data);
15332 + /* those are allowed while in setup too */
15333 + if (!vx_check(0, VX_ADMIN|VX_WATCH) &&
15334 + !vx_flags(VXF_STATE_SETUP,0))
15337 +#ifdef CONFIG_VSERVER_LEGACY
15339 + case VCMD_set_cflags:
15340 + case VCMD_set_ccaps:
15341 + if (vx_check(0, VX_WATCH))
15347 + case VCMD_get_rlimit:
15348 + return vc_get_rlimit(id, data);
15349 + case VCMD_set_rlimit:
15350 + return vc_set_rlimit(id, data);
15351 + case VCMD_get_rlimit_mask:
15352 + return vc_get_rlimit_mask(id, data);
15354 + case VCMD_vx_get_vhi_name:
15355 + return vc_get_vhi_name(id, data);
15356 + case VCMD_vx_set_vhi_name:
15357 + return vc_set_vhi_name(id, data);
15359 + case VCMD_set_cflags:
15360 + return vc_set_cflags(id, data);
15361 + case VCMD_get_cflags:
15362 + return vc_get_cflags(id, data);
15364 + case VCMD_set_ccaps:
15365 + return vc_set_ccaps(id, data);
15366 + case VCMD_get_ccaps:
15367 + return vc_get_ccaps(id, data);
15369 + case VCMD_set_nflags:
15370 + return vc_set_nflags(id, data);
15371 + case VCMD_get_nflags:
15372 + return vc_get_nflags(id, data);
15374 + case VCMD_set_ncaps:
15375 + return vc_set_ncaps(id, data);
15376 + case VCMD_get_ncaps:
15377 + return vc_get_ncaps(id, data);
15379 + case VCMD_set_sched_v2:
15380 + return vc_set_sched_v2(id, data);
15381 + /* this is version 3 */
15382 + case VCMD_set_sched:
15383 + return vc_set_sched(id, data);
15385 + case VCMD_add_dlimit:
15386 + return vc_add_dlimit(id, data);
15387 + case VCMD_rem_dlimit:
15388 + return vc_rem_dlimit(id, data);
15389 + case VCMD_set_dlimit:
15390 + return vc_set_dlimit(id, data);
15391 + case VCMD_get_dlimit:
15392 + return vc_get_dlimit(id, data);
15395 + /* below here only with VX_ADMIN */
15396 + if (!vx_check(0, VX_ADMIN|VX_WATCH))
15400 + case VCMD_ctx_kill:
15401 + return vc_ctx_kill(id, data);
15403 + case VCMD_wait_exit:
15404 + return vc_wait_exit(id, data);
15406 + case VCMD_create_context:
15407 +#ifdef CONFIG_VSERVER_LEGACY
15408 + return vc_ctx_create(id, data);
15413 + case VCMD_get_iattr:
15414 + return vc_get_iattr(id, data);
15415 + case VCMD_set_iattr:
15416 + return vc_set_iattr(id, data);
15418 + case VCMD_enter_namespace:
15419 + return vc_enter_namespace(id, data);
15421 + case VCMD_ctx_create:
15422 +#ifdef CONFIG_VSERVER_LEGACY
15424 + current->xid = 1;
15428 + return vc_ctx_create(id, data);
15429 + case VCMD_ctx_migrate:
15430 + return vc_ctx_migrate(id, data);
15432 + case VCMD_net_create:
15433 + return vc_net_create(id, data);
15434 + case VCMD_net_migrate:
15435 + return vc_net_migrate(id, data);
15441 diff -NurpP --minimal linux-2.6.10/kernel/vserver/sysctl.c linux-2.6.10-vs1.9.3.17/kernel/vserver/sysctl.c
15442 --- linux-2.6.10/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
15443 +++ linux-2.6.10-vs1.9.3.17/kernel/vserver/sysctl.c 2004-12-26 19:40:35.000000000 +0100
15446 + * linux/kernel/sysctl.c
15448 + * Virtual Context Support
15450 + * Copyright (C) 2004 Herbert Pötzl
15452 + * V0.01 basic structure
15456 +#include <linux/config.h>
15457 +#include <linux/errno.h>
15458 +#include <linux/module.h>
15459 +#include <linux/types.h>
15460 +#include <linux/ctype.h>
15461 +#include <linux/sysctl.h>
15462 +#include <linux/fs.h>
15464 +#include <asm/uaccess.h>
15465 +#include <asm/unistd.h>
15468 +#define CTL_VSERVER 4242 /* unused? */
15471 + CTL_DEBUG_SWITCH = 1,
15481 +unsigned int vx_debug_switch = 0;
15482 +unsigned int vx_debug_xid = 0;
15483 +unsigned int vx_debug_nid = 0;
15484 +unsigned int vx_debug_net = 0;
15485 +unsigned int vx_debug_limit = 0;
15486 +unsigned int vx_debug_dlim = 0;
15487 +unsigned int vx_debug_cvirt = 0;
15490 +static struct ctl_table_header *vserver_table_header;
15491 +static ctl_table vserver_table[];
15494 +void vserver_register_sysctl(void)
15496 + if (!vserver_table_header) {
15497 + vserver_table_header = register_sysctl_table(vserver_table, 1);
15502 +void vserver_unregister_sysctl(void)
15504 + if (vserver_table_header) {
15505 + unregister_sysctl_table(vserver_table_header);
15506 + vserver_table_header = NULL;
15511 +static int proc_dodebug(ctl_table *table, int write,
15512 + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
15514 + char tmpbuf[20], *p, c;
15515 + unsigned int value;
15516 + size_t left, len;
15518 + if ((*ppos && !write) || !*lenp) {
15526 + if (!access_ok(VERIFY_READ, buffer, left))
15528 + p = (char *) buffer;
15529 + while (left && __get_user(c, p) >= 0 && isspace(c))
15534 + if (left > sizeof(tmpbuf) - 1)
15536 + if (copy_from_user(tmpbuf, p, left))
15538 + tmpbuf[left] = '\0';
15540 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
15541 + value = 10 * value + (*p - '0');
15542 + if (*p && !isspace(*p))
15544 + while (left && isspace(*p))
15546 + *(unsigned int *) table->data = value;
15548 + if (!access_ok(VERIFY_WRITE, buffer, left))
15550 + len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data);
15553 + if (__copy_to_user(buffer, tmpbuf, len))
15555 + if ((left -= len) > 0) {
15556 + if (put_user('\n', (char *)buffer + len))
15570 +static ctl_table debug_table[] = {
15572 + .ctl_name = CTL_DEBUG_SWITCH,
15573 + .procname = "debug_switch",
15574 + .data = &vx_debug_switch,
15575 + .maxlen = sizeof(int),
15577 + .proc_handler = &proc_dodebug
15580 + .ctl_name = CTL_DEBUG_XID,
15581 + .procname = "debug_xid",
15582 + .data = &vx_debug_xid,
15583 + .maxlen = sizeof(int),
15585 + .proc_handler = &proc_dodebug
15588 + .ctl_name = CTL_DEBUG_NID,
15589 + .procname = "debug_nid",
15590 + .data = &vx_debug_nid,
15591 + .maxlen = sizeof(int),
15593 + .proc_handler = &proc_dodebug
15596 + .ctl_name = CTL_DEBUG_NET,
15597 + .procname = "debug_net",
15598 + .data = &vx_debug_net,
15599 + .maxlen = sizeof(int),
15601 + .proc_handler = &proc_dodebug
15604 + .ctl_name = CTL_DEBUG_LIMIT,
15605 + .procname = "debug_limit",
15606 + .data = &vx_debug_limit,
15607 + .maxlen = sizeof(int),
15609 + .proc_handler = &proc_dodebug
15612 + .ctl_name = CTL_DEBUG_DLIM,
15613 + .procname = "debug_dlim",
15614 + .data = &vx_debug_dlim,
15615 + .maxlen = sizeof(int),
15617 + .proc_handler = &proc_dodebug
15620 + .ctl_name = CTL_DEBUG_CVIRT,
15621 + .procname = "debug_cvirt",
15622 + .data = &vx_debug_cvirt,
15623 + .maxlen = sizeof(int),
15625 + .proc_handler = &proc_dodebug
15627 + { .ctl_name = 0 }
15630 +static ctl_table vserver_table[] = {
15632 + .ctl_name = CTL_VSERVER,
15633 + .procname = "vserver",
15635 + .child = debug_table
15637 + { .ctl_name = 0 }
15641 +EXPORT_SYMBOL_GPL(vx_debug_switch);
15642 +EXPORT_SYMBOL_GPL(vx_debug_xid);
15643 +EXPORT_SYMBOL_GPL(vx_debug_nid);
15644 +EXPORT_SYMBOL_GPL(vx_debug_net);
15645 +EXPORT_SYMBOL_GPL(vx_debug_limit);
15646 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
15647 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
15649 diff -NurpP --minimal linux-2.6.10/mm/fremap.c linux-2.6.10-vs1.9.3.17/mm/fremap.c
15650 --- linux-2.6.10/mm/fremap.c 2004-12-25 01:55:31.000000000 +0100
15651 +++ linux-2.6.10-vs1.9.3.17/mm/fremap.c 2004-12-26 19:40:35.000000000 +0100
15653 #include <linux/rmap.h>
15654 #include <linux/module.h>
15655 #include <linux/syscalls.h>
15656 +#include <linux/vs_memory.h>
15658 #include <asm/mmu_context.h>
15659 #include <asm/cacheflush.h>
15660 @@ -39,7 +40,8 @@ static inline void zap_pte(struct mm_str
15661 set_page_dirty(page);
15662 page_remove_rmap(page);
15663 page_cache_release(page);
15666 + vx_rsspages_dec(mm);
15670 @@ -67,6 +69,9 @@ int install_page(struct mm_struct *mm, s
15671 pgd = pgd_offset(mm, addr);
15672 spin_lock(&mm->page_table_lock);
15674 + if (!vx_rsspages_avail(mm, 1))
15677 pmd = pmd_alloc(mm, pgd, addr);
15680 @@ -87,7 +92,8 @@ int install_page(struct mm_struct *mm, s
15682 zap_pte(mm, vma, addr, pte);
15686 + vx_rsspages_inc(mm);
15687 flush_icache_page(vma, page);
15688 set_pte(pte, mk_pte(page, prot));
15689 page_add_file_rmap(page);
15690 diff -NurpP --minimal linux-2.6.10/mm/memory.c linux-2.6.10-vs1.9.3.17/mm/memory.c
15691 --- linux-2.6.10/mm/memory.c 2004-12-25 01:55:31.000000000 +0100
15692 +++ linux-2.6.10-vs1.9.3.17/mm/memory.c 2004-12-26 19:40:35.000000000 +0100
15693 @@ -283,6 +283,10 @@ skip_copy_pte_range:
15697 + if (!vx_rsspages_avail(dst, 1)) {
15698 + spin_unlock(&src->page_table_lock);
15704 @@ -333,7 +337,8 @@ skip_copy_pte_range:
15705 pte = pte_mkclean(pte);
15706 pte = pte_mkold(pte);
15710 + vx_rsspages_inc(dst);
15711 if (PageAnon(page))
15713 set_pte(dst_pte, pte);
15714 @@ -1112,7 +1117,8 @@ static int do_wp_page(struct mm_struct *
15715 if (PageAnon(old_page))
15717 if (PageReserved(old_page))
15720 + vx_rsspages_inc(mm);
15722 page_remove_rmap(old_page);
15723 break_cow(vma, new_page, address, page_table);
15724 @@ -1370,6 +1376,10 @@ static int do_swap_page(struct mm_struct
15728 + if (!vx_rsspages_avail(mm, 1)) {
15729 + ret = VM_FAULT_OOM;
15732 mark_page_accessed(page);
15735 @@ -1394,7 +1404,8 @@ static int do_swap_page(struct mm_struct
15736 if (vm_swap_full())
15737 remove_exclusive_swap_page(page);
15741 + vx_rsspages_inc(mm);
15742 pte = mk_pte(page, vma->vm_page_prot);
15743 if (write_access && can_share_swap_page(page)) {
15744 pte = maybe_mkwrite(pte_mkdirty(pte), vma);
15745 @@ -1445,6 +1456,9 @@ do_anonymous_page(struct mm_struct *mm,
15747 if (unlikely(anon_vma_prepare(vma)))
15749 + if (!vx_rsspages_avail(mm, 1))
15752 page = alloc_page_vma(GFP_HIGHUSER, vma, addr);
15755 @@ -1459,7 +1473,8 @@ do_anonymous_page(struct mm_struct *mm,
15756 spin_unlock(&mm->page_table_lock);
15761 + vx_rsspages_inc(mm);
15762 entry = maybe_mkwrite(pte_mkdirty(mk_pte(page,
15763 vma->vm_page_prot)),
15765 @@ -1522,6 +1537,8 @@ retry:
15766 return VM_FAULT_SIGBUS;
15767 if (new_page == NOPAGE_OOM)
15768 return VM_FAULT_OOM;
15769 + if (!vx_rsspages_avail(mm, 1))
15770 + return VM_FAULT_OOM;
15773 * Should we do an early C-O-W break?
15774 @@ -1568,7 +1585,8 @@ retry:
15775 /* Only go through if we didn't race with anybody else... */
15776 if (pte_none(*page_table)) {
15777 if (!PageReserved(new_page))
15780 + vx_rsspages_inc(mm);
15781 flush_icache_page(vma, new_page);
15782 entry = mk_pte(new_page, vma->vm_page_prot);
15784 diff -NurpP --minimal linux-2.6.10/mm/mlock.c linux-2.6.10-vs1.9.3.17/mm/mlock.c
15785 --- linux-2.6.10/mm/mlock.c 2004-12-25 01:55:31.000000000 +0100
15786 +++ linux-2.6.10-vs1.9.3.17/mm/mlock.c 2004-12-26 19:40:35.000000000 +0100
15788 #include <linux/mman.h>
15789 #include <linux/mm.h>
15790 #include <linux/syscalls.h>
15791 +#include <linux/vs_memory.h>
15794 static int mlock_fixup(struct vm_area_struct * vma,
15795 @@ -51,7 +52,8 @@ static int mlock_fixup(struct vm_area_st
15796 ret = make_pages_present(start, end);
15799 - vma->vm_mm->locked_vm -= pages;
15800 + // vma->vm_mm->locked_vm -= pages;
15801 + vx_vmlocked_sub(vma->vm_mm, pages);
15805 @@ -103,7 +105,7 @@ static int do_mlock(unsigned long start,
15807 asmlinkage long sys_mlock(unsigned long start, size_t len)
15809 - unsigned long locked;
15810 + unsigned long locked, grow;
15811 unsigned long lock_limit;
15812 int error = -ENOMEM;
15814 @@ -114,8 +116,10 @@ asmlinkage long sys_mlock(unsigned long
15815 len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
15816 start &= PAGE_MASK;
15818 - locked = len >> PAGE_SHIFT;
15819 - locked += current->mm->locked_vm;
15820 + grow = len >> PAGE_SHIFT;
15821 + if (!vx_vmlocked_avail(current->mm, grow))
15823 + locked = current->mm->locked_vm + grow;
15825 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
15826 lock_limit >>= PAGE_SHIFT;
15827 @@ -123,6 +127,7 @@ asmlinkage long sys_mlock(unsigned long
15828 /* check against resource limits */
15829 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
15830 error = do_mlock(start, len, 1);
15832 up_write(¤t->mm->mmap_sem);
15835 @@ -182,6 +187,8 @@ asmlinkage long sys_mlockall(int flags)
15836 lock_limit >>= PAGE_SHIFT;
15839 + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
15841 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
15842 capable(CAP_IPC_LOCK))
15843 ret = do_mlockall(flags);
15844 diff -NurpP --minimal linux-2.6.10/mm/mmap.c linux-2.6.10-vs1.9.3.17/mm/mmap.c
15845 --- linux-2.6.10/mm/mmap.c 2004-12-25 01:55:31.000000000 +0100
15846 +++ linux-2.6.10-vs1.9.3.17/mm/mmap.c 2004-12-26 19:40:35.000000000 +0100
15847 @@ -908,6 +908,10 @@ munmap_back:
15848 > current->signal->rlim[RLIMIT_AS].rlim_cur)
15851 + /* check context space, maybe only Private writable mapping? */
15852 + if (!vx_vmpages_avail(mm, len >> PAGE_SHIFT))
15855 if (accountable && (!(flags & MAP_NORESERVE) ||
15856 sysctl_overcommit_memory == OVERCOMMIT_NEVER)) {
15857 if (vm_flags & VM_SHARED) {
15858 @@ -1007,10 +1011,12 @@ munmap_back:
15859 kmem_cache_free(vm_area_cachep, vma);
15862 - mm->total_vm += len >> PAGE_SHIFT;
15863 + // mm->total_vm += len >> PAGE_SHIFT;
15864 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
15865 __vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
15866 if (vm_flags & VM_LOCKED) {
15867 - mm->locked_vm += len >> PAGE_SHIFT;
15868 + // mm->locked_vm += len >> PAGE_SHIFT;
15869 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
15870 make_pages_present(addr, addr + len);
15872 if (flags & MAP_POPULATE) {
15873 @@ -1347,8 +1353,9 @@ int expand_stack(struct vm_area_struct *
15874 address &= PAGE_MASK;
15875 grow = (address - vma->vm_end) >> PAGE_SHIFT;
15877 - /* Overcommit.. */
15878 - if (security_vm_enough_memory(grow)) {
15879 + /* Overcommit.. vx check first to avoid vm_unacct_memory() */
15880 + if (!vx_vmpages_avail(vma->vm_mm, grow) ||
15881 + security_vm_enough_memory(grow)) {
15882 anon_vma_unlock(vma);
15885 @@ -1361,9 +1368,11 @@ int expand_stack(struct vm_area_struct *
15888 vma->vm_end = address;
15889 - vma->vm_mm->total_vm += grow;
15890 + // vma->vm_mm->total_vm += grow;
15891 + vx_vmpages_add(vma->vm_mm, grow);
15892 if (vma->vm_flags & VM_LOCKED)
15893 - vma->vm_mm->locked_vm += grow;
15894 + // vma->vm_mm->locked_vm += grow;
15895 + vx_vmlocked_add(vma->vm_mm, grow);
15896 __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, grow);
15897 anon_vma_unlock(vma);
15899 @@ -1409,8 +1418,9 @@ int expand_stack(struct vm_area_struct *
15900 address &= PAGE_MASK;
15901 grow = (vma->vm_start - address) >> PAGE_SHIFT;
15903 - /* Overcommit.. */
15904 - if (security_vm_enough_memory(grow)) {
15905 + /* Overcommit.. vx check first to avoid vm_unacct_memory() */
15906 + if (!vx_vmpages_avail(vma->vm_mm, grow) ||
15907 + security_vm_enough_memory(grow)) {
15908 anon_vma_unlock(vma);
15911 @@ -1424,9 +1434,11 @@ int expand_stack(struct vm_area_struct *
15913 vma->vm_start = address;
15914 vma->vm_pgoff -= grow;
15915 - vma->vm_mm->total_vm += grow;
15916 + // vma->vm_mm->total_vm += grow;
15917 + vx_vmpages_add(vma->vm_mm, grow);
15918 if (vma->vm_flags & VM_LOCKED)
15919 - vma->vm_mm->locked_vm += grow;
15920 + // vma->vm_mm->locked_vm += grow;
15921 + vx_vmlocked_add(vma->vm_mm, grow);
15922 __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, grow);
15923 anon_vma_unlock(vma);
15925 @@ -1530,9 +1542,12 @@ static void unmap_vma(struct mm_struct *
15927 size_t len = area->vm_end - area->vm_start;
15929 - area->vm_mm->total_vm -= len >> PAGE_SHIFT;
15930 + // area->vm_mm->total_vm -= len >> PAGE_SHIFT;
15931 + vx_vmpages_sub(area->vm_mm, len >> PAGE_SHIFT);
15933 if (area->vm_flags & VM_LOCKED)
15934 - area->vm_mm->locked_vm -= len >> PAGE_SHIFT;
15935 + // area->vm_mm->locked_vm -= len >> PAGE_SHIFT;
15936 + vx_vmlocked_sub(area->vm_mm, len >> PAGE_SHIFT);
15937 vm_stat_unaccount(area);
15938 area->vm_mm->unmap_area(area);
15939 remove_vm_struct(area);
15940 @@ -1767,6 +1782,8 @@ unsigned long do_brk(unsigned long addr,
15942 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
15944 + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
15949 @@ -1788,7 +1805,8 @@ unsigned long do_brk(unsigned long addr,
15950 if (mm->map_count > sysctl_max_map_count)
15953 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
15954 + if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
15955 + !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
15958 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
15959 @@ -1816,9 +1834,11 @@ unsigned long do_brk(unsigned long addr,
15960 vma->vm_page_prot = protection_map[flags & 0x0f];
15961 vma_link(mm, vma, prev, rb_link, rb_parent);
15963 - mm->total_vm += len >> PAGE_SHIFT;
15964 + // mm->total_vm += len >> PAGE_SHIFT;
15965 + vx_vmpages_add(mm, len >> PAGE_SHIFT);
15966 if (flags & VM_LOCKED) {
15967 - mm->locked_vm += len >> PAGE_SHIFT;
15968 + // mm->locked_vm += len >> PAGE_SHIFT;
15969 + vx_vmlocked_add(mm, len >> PAGE_SHIFT);
15970 make_pages_present(addr, addr + len);
15973 @@ -1850,9 +1870,12 @@ void exit_mmap(struct mm_struct *mm)
15975 mm->mmap = mm->mmap_cache = NULL;
15976 mm->mm_rb = RB_ROOT;
15978 - mm->total_vm = 0;
15979 - mm->locked_vm = 0;
15981 + vx_rsspages_sub(mm, mm->rss);
15982 + // mm->total_vm = 0;
15983 + vx_vmpages_sub(mm, mm->total_vm);
15984 + // mm->locked_vm = 0;
15985 + vx_vmlocked_sub(mm, mm->locked_vm);
15987 spin_unlock(&mm->page_table_lock);
15989 diff -NurpP --minimal linux-2.6.10/mm/mremap.c linux-2.6.10-vs1.9.3.17/mm/mremap.c
15990 --- linux-2.6.10/mm/mremap.c 2004-12-25 01:55:31.000000000 +0100
15991 +++ linux-2.6.10-vs1.9.3.17/mm/mremap.c 2004-12-26 19:40:35.000000000 +0100
15993 #include <linux/highmem.h>
15994 #include <linux/security.h>
15995 #include <linux/syscalls.h>
15996 +#include <linux/vs_memory.h>
15998 #include <asm/uaccess.h>
15999 #include <asm/cacheflush.h>
16000 @@ -224,10 +225,12 @@ static unsigned long move_vma(struct vm_
16001 vma->vm_next->vm_flags |= VM_ACCOUNT;
16004 - mm->total_vm += new_len >> PAGE_SHIFT;
16005 + // mm->total_vm += new_len >> PAGE_SHIFT;
16006 + vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
16007 __vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
16008 if (vm_flags & VM_LOCKED) {
16009 - mm->locked_vm += new_len >> PAGE_SHIFT;
16010 + // mm->locked_vm += new_len >> PAGE_SHIFT;
16011 + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
16012 if (new_len > old_len)
16013 make_pages_present(new_addr + old_len,
16014 new_addr + new_len);
16015 @@ -333,11 +336,18 @@ unsigned long do_mremap(unsigned long ad
16017 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
16020 + if (!vx_vmlocked_avail(current->mm,
16021 + (new_len - old_len) >> PAGE_SHIFT))
16025 if ((current->mm->total_vm << PAGE_SHIFT) + (new_len - old_len)
16026 > current->signal->rlim[RLIMIT_AS].rlim_cur)
16028 + /* check context space, maybe only Private writable mapping? */
16029 + if (!vx_vmpages_avail(current->mm, (new_len - old_len) >> PAGE_SHIFT))
16032 if (vma->vm_flags & VM_ACCOUNT) {
16033 charged = (new_len - old_len) >> PAGE_SHIFT;
16034 @@ -361,11 +371,13 @@ unsigned long do_mremap(unsigned long ad
16035 vma_adjust(vma, vma->vm_start,
16036 addr + new_len, vma->vm_pgoff, NULL);
16038 - current->mm->total_vm += pages;
16039 + // current->mm->total_vm += pages;
16040 + vx_vmpages_add(current->mm, pages);
16041 __vm_stat_account(vma->vm_mm, vma->vm_flags,
16042 vma->vm_file, pages);
16043 if (vma->vm_flags & VM_LOCKED) {
16044 - current->mm->locked_vm += pages;
16045 + // current->mm->locked_vm += pages;
16046 + vx_vmlocked_add(vma->vm_mm, pages);
16047 make_pages_present(addr + old_len,
16050 diff -NurpP --minimal linux-2.6.10/mm/nommu.c linux-2.6.10-vs1.9.3.17/mm/nommu.c
16051 --- linux-2.6.10/mm/nommu.c 2004-12-25 01:55:31.000000000 +0100
16052 +++ linux-2.6.10-vs1.9.3.17/mm/nommu.c 2004-12-26 19:40:35.000000000 +0100
16053 @@ -440,7 +440,8 @@ unsigned long do_mmap_pgoff(
16055 tblock->next = current->mm->context.tblock.next;
16056 current->mm->context.tblock.next = tblock;
16057 - current->mm->total_vm += len >> PAGE_SHIFT;
16058 + // current->mm->total_vm += len >> PAGE_SHIFT;
16059 + vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
16062 printk("do_mmap:\n");
16063 @@ -494,7 +495,8 @@ int do_munmap(struct mm_struct * mm, uns
16064 realalloc -= kobjsize(tblock);
16065 askedalloc -= sizeof(struct mm_tblock_struct);
16067 - mm->total_vm -= len >> PAGE_SHIFT;
16068 + // mm->total_vm -= len >> PAGE_SHIFT;
16069 + vx_vmpages_sub(mm, len >> PAGE_SHIFT);
16072 show_process_blocks();
16073 @@ -507,7 +509,8 @@ int do_munmap(struct mm_struct * mm, uns
16074 void exit_mmap(struct mm_struct * mm)
16076 struct mm_tblock_struct *tmp;
16077 - mm->total_vm = 0;
16078 + // mm->total_vm = 0;
16079 + vx_vmpages_sub(mm, mm->total_vm);
16083 diff -NurpP --minimal linux-2.6.10/mm/oom_kill.c linux-2.6.10-vs1.9.3.17/mm/oom_kill.c
16084 --- linux-2.6.10/mm/oom_kill.c 2004-10-23 05:06:25.000000000 +0200
16085 +++ linux-2.6.10-vs1.9.3.17/mm/oom_kill.c 2004-12-26 19:40:35.000000000 +0100
16086 @@ -55,6 +55,7 @@ static unsigned long badness(struct task
16087 * The memory size of the process is the basis for the badness.
16089 points = p->mm->total_vm;
16090 + /* FIXME add vserver badness ;) */
16093 * CPU time is in tens of seconds and run time is in thousands
16094 diff -NurpP --minimal linux-2.6.10/mm/page_alloc.c linux-2.6.10-vs1.9.3.17/mm/page_alloc.c
16095 --- linux-2.6.10/mm/page_alloc.c 2004-12-25 01:55:31.000000000 +0100
16096 +++ linux-2.6.10-vs1.9.3.17/mm/page_alloc.c 2004-12-26 19:40:30.000000000 +0100
16098 #include <linux/sysctl.h>
16099 #include <linux/cpu.h>
16100 #include <linux/nodemask.h>
16101 +#include <linux/vs_limit.h>
16103 #include <asm/tlbflush.h>
16105 @@ -1011,6 +1012,8 @@ void si_meminfo(struct sysinfo *val)
16108 val->mem_unit = PAGE_SIZE;
16109 + if (vx_flags(VXF_VIRT_MEM, 0))
16110 + vx_vsi_meminfo(val);
16113 EXPORT_SYMBOL(si_meminfo);
16114 diff -NurpP --minimal linux-2.6.10/mm/rmap.c linux-2.6.10-vs1.9.3.17/mm/rmap.c
16115 --- linux-2.6.10/mm/rmap.c 2004-12-25 01:55:31.000000000 +0100
16116 +++ linux-2.6.10-vs1.9.3.17/mm/rmap.c 2004-12-26 19:40:35.000000000 +0100
16118 #include <linux/init.h>
16119 #include <linux/rmap.h>
16120 #include <linux/rcupdate.h>
16121 +#include <linux/vs_memory.h>
16123 #include <asm/tlbflush.h>
16125 @@ -595,7 +596,8 @@ static int try_to_unmap_one(struct page
16131 + vx_rsspages_dec(mm);
16132 page_remove_rmap(page);
16133 page_cache_release(page);
16135 @@ -695,7 +697,8 @@ static void try_to_unmap_cluster(unsigne
16137 page_remove_rmap(page);
16138 page_cache_release(page);
16141 + vx_rsspages_dec(mm);
16145 diff -NurpP --minimal linux-2.6.10/mm/shmem.c linux-2.6.10-vs1.9.3.17/mm/shmem.c
16146 --- linux-2.6.10/mm/shmem.c 2004-12-25 01:55:31.000000000 +0100
16147 +++ linux-2.6.10-vs1.9.3.17/mm/shmem.c 2004-12-26 19:40:30.000000000 +0100
16149 #include <asm/pgtable.h>
16151 /* This magic number is used in glibc for posix shared memory */
16152 -#define TMPFS_MAGIC 0x01021994
16154 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
16155 #define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
16156 @@ -1604,7 +1603,7 @@ static int shmem_statfs(struct super_blo
16158 struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
16160 - buf->f_type = TMPFS_MAGIC;
16161 + buf->f_type = TMPFS_SUPER_MAGIC;
16162 buf->f_bsize = PAGE_CACHE_SIZE;
16163 buf->f_namelen = NAME_MAX;
16165 @@ -2002,7 +2001,7 @@ static int shmem_fill_super(struct super
16166 sb->s_maxbytes = SHMEM_MAX_BYTES;
16167 sb->s_blocksize = PAGE_CACHE_SIZE;
16168 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
16169 - sb->s_magic = TMPFS_MAGIC;
16170 + sb->s_magic = TMPFS_SUPER_MAGIC;
16171 sb->s_op = &shmem_ops;
16172 inode = shmem_get_inode(sb, S_IFDIR | mode, 0);
16174 diff -NurpP --minimal linux-2.6.10/mm/swapfile.c linux-2.6.10-vs1.9.3.17/mm/swapfile.c
16175 --- linux-2.6.10/mm/swapfile.c 2004-12-25 01:55:31.000000000 +0100
16176 +++ linux-2.6.10-vs1.9.3.17/mm/swapfile.c 2004-12-26 19:40:35.000000000 +0100
16178 #include <asm/pgtable.h>
16179 #include <asm/tlbflush.h>
16180 #include <linux/swapops.h>
16181 +#include <linux/vs_memory.h>
16183 spinlock_t swaplock = SPIN_LOCK_UNLOCKED;
16184 unsigned int nr_swapfiles;
16185 @@ -431,7 +432,8 @@ static void
16186 unuse_pte(struct vm_area_struct *vma, unsigned long address, pte_t *dir,
16187 swp_entry_t entry, struct page *page)
16189 - vma->vm_mm->rss++;
16190 + // vma->vm_mm->rss++;
16191 + vx_rsspages_inc(vma->vm_mm);
16193 set_pte(dir, pte_mkold(mk_pte(page, vma->vm_page_prot)));
16194 page_add_anon_rmap(page, vma, address);
16195 @@ -1626,6 +1628,8 @@ void si_swapinfo(struct sysinfo *val)
16196 val->freeswap = nr_swap_pages + nr_to_be_unused;
16197 val->totalswap = total_swap_pages + nr_to_be_unused;
16198 swap_list_unlock();
16199 + if (vx_flags(VXF_VIRT_MEM, 0))
16200 + vx_vsi_swapinfo(val);
16204 diff -NurpP --minimal linux-2.6.10/mm/vmscan.c linux-2.6.10-vs1.9.3.17/mm/vmscan.c
16205 --- linux-2.6.10/mm/vmscan.c 2004-12-25 01:55:31.000000000 +0100
16206 +++ linux-2.6.10-vs1.9.3.17/mm/vmscan.c 2004-12-26 19:40:30.000000000 +0100
16207 @@ -1238,7 +1238,7 @@ static int __init kswapd_init(void)
16209 for_each_pgdat(pgdat)
16211 - = find_task_by_pid(kernel_thread(kswapd, pgdat, CLONE_KERNEL));
16212 + = find_task_by_real_pid(kernel_thread(kswapd, pgdat, CLONE_KERNEL));
16213 total_memory = nr_free_pagecache_pages();
16214 hotcpu_notifier(cpu_callback, 0);
16216 diff -NurpP --minimal linux-2.6.10/net/core/dev.c linux-2.6.10-vs1.9.3.17/net/core/dev.c
16217 --- linux-2.6.10/net/core/dev.c 2004-12-25 01:55:31.000000000 +0100
16218 +++ linux-2.6.10-vs1.9.3.17/net/core/dev.c 2004-12-26 19:40:29.000000000 +0100
16219 @@ -112,6 +112,7 @@
16220 #include <linux/wireless.h> /* Note : will define WIRELESS_EXT */
16221 #include <net/iw_handler.h>
16222 #endif /* CONFIG_NET_RADIO */
16223 +#include <linux/vs_network.h>
16224 #include <asm/current.h>
16226 /* This define, if set, will randomly drop a packet when congestion
16227 @@ -1893,6 +1894,9 @@ static int dev_ifconf(char __user *arg)
16230 for (dev = dev_base; dev; dev = dev->next) {
16231 + if (vx_flags(VXF_HIDE_NETIF, 0) &&
16232 + !dev_in_nx_info(dev, current->nx_info))
16234 for (i = 0; i < NPROTO; i++) {
16235 if (gifconf_list[i]) {
16237 @@ -1953,6 +1957,10 @@ void dev_seq_stop(struct seq_file *seq,
16239 static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
16241 + struct nx_info *nxi = current->nx_info;
16243 + if (vx_flags(VXF_HIDE_NETIF, 0) && !dev_in_nx_info(dev, nxi))
16245 if (dev->get_stats) {
16246 struct net_device_stats *stats = dev->get_stats(dev);
16248 diff -NurpP --minimal linux-2.6.10/net/core/rtnetlink.c linux-2.6.10-vs1.9.3.17/net/core/rtnetlink.c
16249 --- linux-2.6.10/net/core/rtnetlink.c 2004-10-23 05:06:25.000000000 +0200
16250 +++ linux-2.6.10-vs1.9.3.17/net/core/rtnetlink.c 2004-12-26 19:40:29.000000000 +0100
16251 @@ -251,6 +251,9 @@ int rtnetlink_dump_ifinfo(struct sk_buff
16252 for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
16255 + if (vx_info_flags(skb->sk->sk_vx_info, VXF_HIDE_NETIF, 0) &&
16256 + !dev_in_nx_info(dev, skb->sk->sk_nx_info))
16258 if (rtnetlink_fill_ifinfo(skb, dev, RTM_NEWLINK, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, 0) <= 0)
16261 @@ -416,6 +419,9 @@ void rtmsg_ifinfo(int type, struct net_d
16262 sizeof(struct rtnl_link_ifmap) +
16263 sizeof(struct rtnl_link_stats) + 128);
16265 + if (vx_flags(VXF_HIDE_NETIF, 0) &&
16266 + !dev_in_nx_info(dev, current->nx_info))
16268 skb = alloc_skb(size, GFP_KERNEL);
16271 diff -NurpP --minimal linux-2.6.10/net/core/sock.c linux-2.6.10-vs1.9.3.17/net/core/sock.c
16272 --- linux-2.6.10/net/core/sock.c 2004-12-25 01:55:31.000000000 +0100
16273 +++ linux-2.6.10-vs1.9.3.17/net/core/sock.c 2004-12-26 19:40:29.000000000 +0100
16274 @@ -122,6 +122,7 @@
16275 #include <linux/ipsec.h>
16277 #include <linux/filter.h>
16278 +#include <linux/vs_socket.h>
16281 #include <net/tcp.h>
16282 @@ -333,7 +334,10 @@ int sock_setsockopt(struct socket *sock,
16286 - sock->passcred = valbool;
16288 + set_bit(SOCK_PASS_CRED, &sock->flags);
16290 + clear_bit(SOCK_PASS_CRED, &sock->flags);
16294 @@ -557,7 +561,7 @@ int sock_getsockopt(struct socket *sock,
16298 - v.val = sock->passcred;
16299 + v.val = test_bit(SOCK_PASS_CRED, &sock->flags)?1:0;
16303 @@ -632,6 +636,8 @@ struct sock *sk_alloc(int family, int pr
16304 sock_lock_init(sk);
16306 sk->sk_slab = slab;
16307 + sock_vx_init(sk);
16308 + sock_nx_init(sk);
16310 if (security_sk_alloc(sk, family, priority)) {
16311 kmem_cache_free(slab, sk);
16312 @@ -662,6 +668,8 @@ void sk_free(struct sock *sk)
16313 __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
16315 security_sk_free(sk);
16316 + BUG_ON(sk->sk_vx_info);
16317 + BUG_ON(sk->sk_nx_info);
16318 kmem_cache_free(sk->sk_slab, sk);
16321 @@ -1199,6 +1207,11 @@ void sock_init_data(struct socket *sock,
16322 sk->sk_stamp.tv_sec = -1L;
16323 sk->sk_stamp.tv_usec = -1L;
16325 + sk->sk_vx_info = NULL;
16327 + sk->sk_nx_info = NULL;
16330 atomic_set(&sk->sk_refcnt, 1);
16333 diff -NurpP --minimal linux-2.6.10/net/ipv4/af_inet.c linux-2.6.10-vs1.9.3.17/net/ipv4/af_inet.c
16334 --- linux-2.6.10/net/ipv4/af_inet.c 2004-12-25 01:55:31.000000000 +0100
16335 +++ linux-2.6.10-vs1.9.3.17/net/ipv4/af_inet.c 2004-12-26 19:40:29.000000000 +0100
16336 @@ -112,6 +112,7 @@
16337 #ifdef CONFIG_IP_MROUTE
16338 #include <linux/mroute.h>
16340 +#include <linux/vs_limit.h>
16342 DEFINE_SNMP_STAT(struct linux_mib, net_statistics);
16344 @@ -153,6 +154,13 @@ void inet_sock_destruct(struct sock *sk)
16350 + clr_vx_info(&sk->sk_vx_info);
16352 + clr_nx_info(&sk->sk_nx_info);
16355 dst_release(sk->sk_dst_cache);
16356 #ifdef INET_REFCNT_DEBUG
16357 atomic_dec(&inet_sock_nr);
16358 @@ -266,8 +274,11 @@ static int inet_create(struct socket *so
16360 goto out_rcu_unlock;
16362 + if ((protocol == IPPROTO_ICMP) && vx_ccaps(VXC_RAW_ICMP))
16364 if (answer->capability > 0 && !capable(answer->capability))
16365 goto out_rcu_unlock;
16367 err = -EPROTONOSUPPORT;
16369 goto out_rcu_unlock;
16370 @@ -316,6 +327,12 @@ static int inet_create(struct socket *so
16371 sk->sk_protocol = protocol;
16372 sk->sk_backlog_rcv = sk->sk_prot->backlog_rcv;
16374 + set_vx_info(&sk->sk_vx_info, current->vx_info);
16375 + sk->sk_xid = vx_current_xid();
16377 + set_nx_info(&sk->sk_nx_info, current->nx_info);
16378 + sk->sk_nid = nx_current_nid();
16383 @@ -377,6 +394,11 @@ int inet_release(struct socket *sock)
16384 !(current->flags & PF_EXITING))
16385 timeout = sk->sk_lingertime;
16388 + clr_vx_info(&sk->sk_vx_info);
16390 + clr_nx_info(&sk->sk_nx_info);
16392 sk->sk_prot->close(sk, timeout);
16395 @@ -393,6 +415,10 @@ int inet_bind(struct socket *sock, struc
16396 unsigned short snum;
16399 + __u32 s_addr; /* Address used for validation */
16400 + __u32 s_addr1; /* Address used for socket */
16401 + __u32 s_addr2; /* Broadcast address for the socket */
16402 + struct nx_info *nxi = sk->sk_nx_info;
16404 /* If the socket has its own bind function then use it. (RAW) */
16405 if (sk->sk_prot->bind) {
16406 @@ -403,7 +429,40 @@ int inet_bind(struct socket *sock, struc
16407 if (addr_len < sizeof(struct sockaddr_in))
16410 - chk_addr_ret = inet_addr_type(addr->sin_addr.s_addr);
16411 + s_addr = addr->sin_addr.s_addr;
16412 + s_addr1 = s_addr;
16413 + s_addr2 = 0xffffffffl;
16415 + vxdprintk(VXD_CBIT(net, 3),
16416 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d",
16417 + sk, sk->sk_nx_info, sk->sk_socket,
16418 + (sk->sk_socket?sk->sk_socket->flags:0),
16419 + VXD_QUAD(s_addr));
16421 + __u32 v4_bcast = nxi->v4_bcast;
16422 + __u32 ipv4root = nxi->ipv4[0];
16423 + int nbipv4 = nxi->nbipv4;
16425 + if (s_addr == 0) {
16426 + /* bind to any for 1-n */
16427 + s_addr = ipv4root;
16428 + s_addr1 = (nbipv4 > 1) ? 0 : s_addr;
16429 + s_addr2 = v4_bcast;
16430 + } else if (s_addr == 0x0100007f) {
16431 + /* rewrite localhost to ipv4root */
16432 + s_addr = ipv4root;
16433 + s_addr1 = ipv4root;
16434 + } else if (s_addr != v4_bcast) {
16435 + /* normal address bind */
16436 + if (!addr_in_nx_info(nxi, s_addr))
16437 + return -EADDRNOTAVAIL;
16440 + chk_addr_ret = inet_addr_type(s_addr);
16442 + vxdprintk(VXD_CBIT(net, 3),
16443 + "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d",
16444 + sk, VXD_QUAD(s_addr), VXD_QUAD(s_addr1), VXD_QUAD(s_addr2));
16446 /* Not specified by any standard per-se, however it breaks too
16447 * many applications when removed. It is unfortunate since
16448 @@ -415,7 +474,7 @@ int inet_bind(struct socket *sock, struc
16449 err = -EADDRNOTAVAIL;
16450 if (!sysctl_ip_nonlocal_bind &&
16452 - addr->sin_addr.s_addr != INADDR_ANY &&
16453 + s_addr != INADDR_ANY &&
16454 chk_addr_ret != RTN_LOCAL &&
16455 chk_addr_ret != RTN_MULTICAST &&
16456 chk_addr_ret != RTN_BROADCAST)
16457 @@ -440,7 +499,8 @@ int inet_bind(struct socket *sock, struc
16458 if (sk->sk_state != TCP_CLOSE || inet->num)
16459 goto out_release_sock;
16461 - inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
16462 + inet->rcv_saddr = inet->saddr = s_addr1;
16463 + inet->rcv_saddr2 = s_addr2;
16464 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
16465 inet->saddr = 0; /* Use device */
16467 diff -NurpP --minimal linux-2.6.10/net/ipv4/devinet.c linux-2.6.10-vs1.9.3.17/net/ipv4/devinet.c
16468 --- linux-2.6.10/net/ipv4/devinet.c 2004-12-25 01:55:31.000000000 +0100
16469 +++ linux-2.6.10-vs1.9.3.17/net/ipv4/devinet.c 2004-12-26 19:40:29.000000000 +0100
16470 @@ -489,6 +489,33 @@ static __inline__ int inet_abc_len(u32 a
16475 + Check that a device is not member of the ipv4root assigned to the process
16476 + Return true if this is the case
16478 + If the process is not bound to specific IP, then it returns 0 (all
16479 + interface are fine).
16481 +static inline int devinet_notiproot (struct in_ifaddr *ifa)
16484 + struct nx_info *nxi;
16486 + if ((nxi = current->nx_info)) {
16488 + int nbip = nxi->nbipv4;
16489 + __u32 addr = ifa->ifa_local;
16491 + for (i=0; i<nbip; i++) {
16492 + if(nxi->ipv4[i] == addr) {
16502 int devinet_ioctl(unsigned int cmd, void __user *arg)
16504 @@ -596,6 +623,9 @@ int devinet_ioctl(unsigned int cmd, void
16505 ret = -EADDRNOTAVAIL;
16506 if (!ifa && cmd != SIOCSIFADDR && cmd != SIOCSIFFLAGS)
16508 + if (vx_flags(VXF_HIDE_NETIF, 0) &&
16509 + !ifa_in_nx_info(ifa, current->nx_info))
16513 case SIOCGIFADDR: /* Get interface address */
16514 @@ -739,6 +769,9 @@ static int inet_gifconf(struct net_devic
16517 for (; ifa; ifa = ifa->ifa_next) {
16518 + if (vx_flags(VXF_HIDE_NETIF, 0) &&
16519 + !ifa_in_nx_info(ifa, current->nx_info))
16522 done += sizeof(ifr);
16524 @@ -1045,6 +1078,7 @@ static int inet_dump_ifaddr(struct sk_bu
16525 struct net_device *dev;
16526 struct in_device *in_dev;
16527 struct in_ifaddr *ifa;
16528 + struct sock *sk = skb->sk;
16529 int s_ip_idx, s_idx = cb->args[0];
16531 s_ip_idx = ip_idx = cb->args[1];
16532 @@ -1062,6 +1096,9 @@ static int inet_dump_ifaddr(struct sk_bu
16534 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
16535 ifa = ifa->ifa_next, ip_idx++) {
16536 + if (sk && vx_info_flags(sk->sk_vx_info, VXF_HIDE_NETIF, 0) &&
16537 + !ifa_in_nx_info(ifa, sk->sk_nx_info))
16539 if (ip_idx < s_ip_idx)
16541 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
16542 diff -NurpP --minimal linux-2.6.10/net/ipv4/fib_hash.c linux-2.6.10-vs1.9.3.17/net/ipv4/fib_hash.c
16543 --- linux-2.6.10/net/ipv4/fib_hash.c 2004-12-25 01:55:31.000000000 +0100
16544 +++ linux-2.6.10-vs1.9.3.17/net/ipv4/fib_hash.c 2004-12-26 19:40:29.000000000 +0100
16545 @@ -1022,6 +1022,8 @@ static unsigned fib_flag_trans(int type,
16549 +extern int dev_in_nx_info(struct net_device *, struct nx_info *);
16552 * This outputs /proc/net/route.
16554 @@ -1052,7 +1054,8 @@ static int fib_seq_show(struct seq_file
16555 prefix = f->fn_key;
16556 mask = FZ_MASK(iter->zone);
16557 flags = fib_flag_trans(fa->fa_type, mask, fi);
16559 + if (fi && (!vx_flags(VXF_HIDE_NETIF, 0) ||
16560 + dev_in_nx_info(fi->fib_dev, current->nx_info)))
16561 snprintf(bf, sizeof(bf),
16562 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
16563 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
16564 diff -NurpP --minimal linux-2.6.10/net/ipv4/netfilter/ip_conntrack_proto_sctp.c linux-2.6.10-vs1.9.3.17/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
16565 --- linux-2.6.10/net/ipv4/netfilter/ip_conntrack_proto_sctp.c 2004-10-23 05:06:26.000000000 +0200
16566 +++ linux-2.6.10-vs1.9.3.17/net/ipv4/netfilter/ip_conntrack_proto_sctp.c 2004-12-26 19:40:36.000000000 +0100
16567 @@ -61,7 +61,11 @@ static const char *sctp_conntrack_names[
16568 unsigned long ip_ct_sctp_timeout_closed = 10 SECS;
16569 unsigned long ip_ct_sctp_timeout_cookie_wait = 3 SECS;
16570 unsigned long ip_ct_sctp_timeout_cookie_echoed = 3 SECS;
16571 -unsigned long ip_ct_sctp_timeout_established = 5 DAYS;
16573 +unsigned long ip_ct_sctp_timeout_established = 5U DAYS;
16575 +unsigned long ip_ct_sctp_timeout_established = 2U DAYS;
16577 unsigned long ip_ct_sctp_timeout_shutdown_sent = 300 SECS / 1000;
16578 unsigned long ip_ct_sctp_timeout_shutdown_recd = 300 SECS / 1000;
16579 unsigned long ip_ct_sctp_timeout_shutdown_ack_sent = 3 SECS;
16580 diff -NurpP --minimal linux-2.6.10/net/ipv4/netfilter/ip_conntrack_proto_tcp.c linux-2.6.10-vs1.9.3.17/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
16581 --- linux-2.6.10/net/ipv4/netfilter/ip_conntrack_proto_tcp.c 2004-12-25 01:55:31.000000000 +0100
16582 +++ linux-2.6.10-vs1.9.3.17/net/ipv4/netfilter/ip_conntrack_proto_tcp.c 2004-12-26 19:40:36.000000000 +0100
16583 @@ -88,7 +88,11 @@ static const char *tcp_conntrack_names[]
16585 unsigned long ip_ct_tcp_timeout_syn_sent = 2 MINS;
16586 unsigned long ip_ct_tcp_timeout_syn_recv = 60 SECS;
16587 -unsigned long ip_ct_tcp_timeout_established = 5 DAYS;
16589 +unsigned long ip_ct_tcp_timeout_established = 5U DAYS;
16591 +unsigned long ip_ct_tcp_timeout_established = 2U DAYS;
16593 unsigned long ip_ct_tcp_timeout_fin_wait = 2 MINS;
16594 unsigned long ip_ct_tcp_timeout_close_wait = 60 SECS;
16595 unsigned long ip_ct_tcp_timeout_last_ack = 30 SECS;
16596 diff -NurpP --minimal linux-2.6.10/net/ipv4/netfilter/ipt_owner.c linux-2.6.10-vs1.9.3.17/net/ipv4/netfilter/ipt_owner.c
16597 --- linux-2.6.10/net/ipv4/netfilter/ipt_owner.c 2004-08-14 12:56:22.000000000 +0200
16598 +++ linux-2.6.10-vs1.9.3.17/net/ipv4/netfilter/ipt_owner.c 2004-12-26 19:40:30.000000000 +0100
16599 @@ -61,7 +61,7 @@ match_pid(const struct sk_buff *skb, pid
16602 read_lock(&tasklist_lock);
16603 - p = find_task_by_pid(pid);
16604 + p = find_task_by_real_pid(pid);
16608 diff -NurpP --minimal linux-2.6.10/net/ipv4/raw.c linux-2.6.10-vs1.9.3.17/net/ipv4/raw.c
16609 --- linux-2.6.10/net/ipv4/raw.c 2004-12-25 01:55:31.000000000 +0100
16610 +++ linux-2.6.10-vs1.9.3.17/net/ipv4/raw.c 2004-12-26 19:40:29.000000000 +0100
16611 @@ -102,6 +102,27 @@ static void raw_v4_unhash(struct sock *s
16612 write_unlock_bh(&raw_v4_lock);
16617 + * Check if a given address matches for a socket
16619 + * nxi: the socket's nx_info if any
16620 + * addr: to be verified address
16621 + * saddr/baddr: socket addresses
16623 +static inline int raw_addr_match (
16624 + struct nx_info *nxi,
16629 + if (addr && (saddr == addr || baddr == addr))
16632 + return addr_in_nx_info(nxi, addr);
16636 struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
16637 unsigned long raddr, unsigned long laddr,
16639 @@ -113,7 +134,8 @@ struct sock *__raw_v4_lookup(struct sock
16641 if (inet->num == num &&
16642 !(inet->daddr && inet->daddr != raddr) &&
16643 - !(inet->rcv_saddr && inet->rcv_saddr != laddr) &&
16644 + raw_addr_match(sk->sk_nx_info, laddr,
16645 + inet->rcv_saddr, inet->rcv_saddr2) &&
16646 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
16647 goto found; /* gotcha */
16649 @@ -308,6 +330,10 @@ static int raw_send_hdrinc(struct sock *
16651 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
16654 + if (!vx_check(0, VX_ADMIN) && !capable(CAP_NET_RAW)
16655 + && (!addr_in_nx_info(sk->sk_nx_info, iph->saddr)))
16658 err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
16660 @@ -480,6 +506,12 @@ static int raw_sendmsg(struct kiocb *ioc
16661 if (!inet->hdrincl)
16662 raw_probe_proto_opt(&fl, msg);
16664 + if (sk->sk_nx_info) {
16665 + err = ip_find_src(sk->sk_nx_info, &rt, &fl);
16670 err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
16673 @@ -742,7 +774,8 @@ static struct sock *raw_get_first(struct
16674 struct hlist_node *node;
16676 sk_for_each(sk, node, &raw_v4_htable[state->bucket])
16677 - if (sk->sk_family == PF_INET)
16678 + if (sk->sk_family == PF_INET &&
16679 + vx_check(sk->sk_xid, VX_WATCH|VX_IDENT))
16683 @@ -758,7 +791,8 @@ static struct sock *raw_get_next(struct
16687 - } while (sk && sk->sk_family != PF_INET);
16688 + } while (sk && (sk->sk_family != PF_INET ||
16689 + !vx_check(sk->sk_xid, VX_WATCH|VX_IDENT)));
16691 if (!sk && ++state->bucket < RAWV4_HTABLE_SIZE) {
16692 sk = sk_head(&raw_v4_htable[state->bucket]);
16693 diff -NurpP --minimal linux-2.6.10/net/ipv4/tcp_ipv4.c linux-2.6.10-vs1.9.3.17/net/ipv4/tcp_ipv4.c
16694 --- linux-2.6.10/net/ipv4/tcp_ipv4.c 2004-12-25 01:55:31.000000000 +0100
16695 +++ linux-2.6.10-vs1.9.3.17/net/ipv4/tcp_ipv4.c 2004-12-26 19:40:29.000000000 +0100
16697 #include <linux/stddef.h>
16698 #include <linux/proc_fs.h>
16699 #include <linux/seq_file.h>
16700 +#include <linux/vserver/debug.h>
16702 extern int sysctl_ip_dynaddr;
16703 int sysctl_tcp_tw_reuse;
16704 @@ -181,7 +182,6 @@ void tcp_bind_hash(struct sock *sk, stru
16706 static inline int tcp_bind_conflict(struct sock *sk, struct tcp_bind_bucket *tb)
16708 - const u32 sk_rcv_saddr = tcp_v4_rcv_saddr(sk);
16710 struct hlist_node *node;
16711 int reuse = sk->sk_reuse;
16712 @@ -194,9 +194,8 @@ static inline int tcp_bind_conflict(stru
16713 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
16714 if (!reuse || !sk2->sk_reuse ||
16715 sk2->sk_state == TCP_LISTEN) {
16716 - const u32 sk2_rcv_saddr = tcp_v4_rcv_saddr(sk2);
16717 - if (!sk2_rcv_saddr || !sk_rcv_saddr ||
16718 - sk2_rcv_saddr == sk_rcv_saddr)
16719 + if (nx_addr_conflict(sk->sk_nx_info,
16720 + tcp_v4_rcv_saddr(sk), sk2))
16724 @@ -405,6 +404,26 @@ void tcp_unhash(struct sock *sk)
16725 wake_up(&tcp_lhash_wait);
16730 + * Check if a given address matches for a tcp socket
16732 + * nxi: the socket's nx_info if any
16733 + * addr: to be verified address
16734 + * saddr: socket addresses
16736 +static inline int tcp_addr_match (
16737 + struct nx_info *nxi,
16741 + if (addr && (saddr == addr))
16744 + return addr_in_nx_info(nxi, addr);
16748 /* Don't inline this cruft. Here are some nice properties to
16749 * exploit here. The BSD API does not allow a listening TCP
16750 * to specify the remote port nor the remote address for the
16751 @@ -426,11 +445,10 @@ static struct sock *__tcp_v4_lookup_list
16752 __u32 rcv_saddr = inet->rcv_saddr;
16754 score = (sk->sk_family == PF_INET ? 1 : 0);
16756 - if (rcv_saddr != daddr)
16758 + if (tcp_addr_match(sk->sk_nx_info, daddr, rcv_saddr))
16763 if (sk->sk_bound_dev_if) {
16764 if (sk->sk_bound_dev_if != dif)
16766 @@ -460,8 +478,8 @@ static inline struct sock *tcp_v4_lookup
16767 struct inet_opt *inet = inet_sk((sk = __sk_head(head)));
16769 if (inet->num == hnum && !sk->sk_node.next &&
16770 - (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
16771 (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
16772 + tcp_addr_match(sk->sk_nx_info, daddr, inet->rcv_saddr) &&
16773 !sk->sk_bound_dev_if)
16775 sk = __tcp_v4_lookup_listener(head, daddr, hnum, dif);
16776 @@ -2163,6 +2181,12 @@ static void *listening_get_next(struct s
16777 req = req->dl_next;
16780 + vxdprintk(VXD_CBIT(net, 6),
16781 + "sk,req: %p [#%d] (from %d)", req->sk,
16782 + (req->sk)?req->sk->sk_xid:0, vx_current_xid());
16784 + !vx_check(req->sk->sk_xid, VX_IDENT|VX_WATCH))
16786 if (req->class->family == st->family) {
16789 @@ -2187,6 +2211,10 @@ get_req:
16792 sk_for_each_from(sk, node) {
16793 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
16794 + sk, sk->sk_xid, vx_current_xid());
16795 + if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
16797 if (sk->sk_family == st->family) {
16800 @@ -2235,18 +2263,26 @@ static void *established_get_first(struc
16802 read_lock(&tcp_ehash[st->bucket].lock);
16803 sk_for_each(sk, node, &tcp_ehash[st->bucket].chain) {
16804 - if (sk->sk_family != st->family) {
16805 + vxdprintk(VXD_CBIT(net, 6),
16806 + "sk,egf: %p [#%d] (from %d)",
16807 + sk, sk->sk_xid, vx_current_xid());
16808 + if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
16810 + if (sk->sk_family != st->family)
16816 st->state = TCP_SEQ_STATE_TIME_WAIT;
16817 tw_for_each(tw, node,
16818 &tcp_ehash[st->bucket + tcp_ehash_size].chain) {
16819 - if (tw->tw_family != st->family) {
16820 + vxdprintk(VXD_CBIT(net, 6),
16821 + "tw: %p [#%d] (from %d)",
16822 + tw, tw->tw_xid, vx_current_xid());
16823 + if (!vx_check(tw->tw_xid, VX_IDENT|VX_WATCH))
16825 + if (tw->tw_family != st->family)
16831 @@ -2270,7 +2306,8 @@ static void *established_get_next(struct
16835 - while (tw && tw->tw_family != st->family) {
16836 + while (tw && (tw->tw_family != st->family ||
16837 + !vx_check(tw->tw_xid, VX_IDENT|VX_WATCH))) {
16841 @@ -2290,6 +2327,11 @@ get_tw:
16844 sk_for_each_from(sk, node) {
16845 + vxdprintk(VXD_CBIT(net, 6),
16846 + "sk,egn: %p [#%d] (from %d)",
16847 + sk, sk->sk_xid, vx_current_xid());
16848 + if (!vx_check(sk->sk_xid, VX_IDENT|VX_WATCH))
16850 if (sk->sk_family == st->family)
16853 diff -NurpP --minimal linux-2.6.10/net/ipv4/tcp_minisocks.c linux-2.6.10-vs1.9.3.17/net/ipv4/tcp_minisocks.c
16854 --- linux-2.6.10/net/ipv4/tcp_minisocks.c 2004-12-25 01:55:31.000000000 +0100
16855 +++ linux-2.6.10-vs1.9.3.17/net/ipv4/tcp_minisocks.c 2004-12-26 19:40:29.000000000 +0100
16857 #include <net/inet_common.h>
16858 #include <net/xfrm.h>
16860 +#include <linux/vs_limit.h>
16861 +#include <linux/vs_socket.h>
16863 #ifdef CONFIG_SYSCTL
16864 #define SYNC_INIT 0 /* let the user enable it */
16866 @@ -362,6 +365,11 @@ void tcp_time_wait(struct sock *sk, int
16867 tw->tw_ts_recent_stamp = tp->ts_recent_stamp;
16868 tw_dead_node_init(tw);
16870 + tw->tw_xid = sk->sk_xid;
16871 + tw->tw_vx_info = NULL;
16872 + tw->tw_nid = sk->sk_nid;
16873 + tw->tw_nx_info = NULL;
16875 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
16876 if (tw->tw_family == PF_INET6) {
16877 struct ipv6_pinfo *np = inet6_sk(sk);
16878 @@ -697,6 +705,8 @@ struct sock *tcp_create_openreq_child(st
16879 newsk->sk_state = TCP_SYN_RECV;
16882 + sock_vx_init(newsk);
16883 + sock_nx_init(newsk);
16884 sk_node_init(&newsk->sk_node);
16885 tcp_sk(newsk)->bind_hash = NULL;
16887 @@ -795,6 +805,12 @@ struct sock *tcp_create_openreq_child(st
16889 newsk->sk_priority = 0;
16890 atomic_set(&newsk->sk_refcnt, 2);
16892 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
16893 + newsk->sk_xid = sk->sk_xid;
16894 + vx_sock_inc(newsk);
16895 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
16896 + newsk->sk_nid = sk->sk_nid;
16897 #ifdef INET_REFCNT_DEBUG
16898 atomic_inc(&inet_sock_nr);
16900 diff -NurpP --minimal linux-2.6.10/net/ipv4/udp.c linux-2.6.10-vs1.9.3.17/net/ipv4/udp.c
16901 --- linux-2.6.10/net/ipv4/udp.c 2004-12-25 01:55:31.000000000 +0100
16902 +++ linux-2.6.10-vs1.9.3.17/net/ipv4/udp.c 2004-12-26 19:40:29.000000000 +0100
16903 @@ -174,14 +174,12 @@ gotit:
16904 struct inet_opt *inet2 = inet_sk(sk2);
16906 if (inet2->num == snum &&
16908 - !ipv6_only_sock(sk2) &&
16909 + sk2 != sk && !ipv6_only_sock(sk2) &&
16910 (!sk2->sk_bound_dev_if ||
16911 !sk->sk_bound_dev_if ||
16912 sk2->sk_bound_dev_if == sk->sk_bound_dev_if) &&
16913 - (!inet2->rcv_saddr ||
16914 - !inet->rcv_saddr ||
16915 - inet2->rcv_saddr == inet->rcv_saddr) &&
16916 + nx_addr_conflict(sk->sk_nx_info,
16917 + tcp_v4_rcv_saddr(sk), sk2) &&
16918 (!sk2->sk_reuse || !sk->sk_reuse))
16921 @@ -216,6 +214,17 @@ static void udp_v4_unhash(struct sock *s
16922 write_unlock_bh(&udp_hash_lock);
16925 +static inline int udp_in_list(struct nx_info *nx_info, u32 addr)
16927 + int n = nx_info->nbipv4;
16930 + for (i=0; i<n; i++)
16931 + if (nx_info->ipv4[i] == addr)
16936 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
16937 * harder than this. -DaveM
16939 @@ -235,6 +244,11 @@ struct sock *udp_v4_lookup_longway(u32 s
16940 if (inet->rcv_saddr != daddr)
16943 + } else if (sk->sk_nx_info) {
16944 + if (udp_in_list(sk->sk_nx_info, daddr))
16950 if (inet->daddr != saddr)
16951 @@ -290,7 +304,8 @@ static inline struct sock *udp_v4_mcast_
16952 if (inet->num != hnum ||
16953 (inet->daddr && inet->daddr != rmt_addr) ||
16954 (inet->dport != rmt_port && inet->dport) ||
16955 - (inet->rcv_saddr && inet->rcv_saddr != loc_addr) ||
16956 + (inet->rcv_saddr && inet->rcv_saddr != loc_addr &&
16957 + inet->rcv_saddr2 && inet->rcv_saddr2 != loc_addr) ||
16958 ipv6_only_sock(s) ||
16959 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
16961 @@ -599,6 +614,15 @@ int udp_sendmsg(struct kiocb *iocb, stru
16962 .uli_u = { .ports =
16963 { .sport = inet->sport,
16964 .dport = dport } } };
16965 + struct nx_info *nxi = sk->sk_nx_info;
16968 + err = ip_find_src(nxi, &rt, &fl);
16971 + if (daddr == IPI_LOOPBACK && !vx_check(0, VX_ADMIN))
16972 + daddr = fl.fl4_dst = nxi->ipv4[0];
16974 err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
16977 @@ -1380,8 +1404,10 @@ static struct sock *udp_get_first(struct
16979 for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
16980 struct hlist_node *node;
16982 sk_for_each(sk, node, &udp_hash[state->bucket]) {
16983 - if (sk->sk_family == state->family)
16984 + if (sk->sk_family == state->family &&
16985 + vx_check(sk->sk_xid, VX_WATCH|VX_IDENT))
16989 @@ -1398,7 +1424,8 @@ static struct sock *udp_get_next(struct
16993 - } while (sk && sk->sk_family != state->family);
16994 + } while (sk && (sk->sk_family != state->family ||
16995 + !vx_check(sk->sk_xid, VX_WATCH|VX_IDENT)));
16997 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
16998 sk = sk_head(&udp_hash[state->bucket]);
16999 diff -NurpP --minimal linux-2.6.10/net/ipv6/addrconf.c linux-2.6.10-vs1.9.3.17/net/ipv6/addrconf.c
17000 --- linux-2.6.10/net/ipv6/addrconf.c 2004-12-25 01:55:31.000000000 +0100
17001 +++ linux-2.6.10-vs1.9.3.17/net/ipv6/addrconf.c 2004-12-26 19:40:29.000000000 +0100
17002 @@ -2659,6 +2659,10 @@ static int inet6_dump_addr(struct sk_buf
17003 struct ifmcaddr6 *ifmca;
17004 struct ifacaddr6 *ifaca;
17006 + /* no ipv6 inside a vserver for now */
17007 + if (skb->sk && skb->sk->sk_vx_info)
17010 s_idx = cb->args[0];
17011 s_ip_idx = ip_idx = cb->args[1];
17012 read_lock(&dev_base_lock);
17013 @@ -2878,6 +2882,10 @@ static int inet6_dump_ifinfo(struct sk_b
17014 struct net_device *dev;
17015 struct inet6_dev *idev;
17017 + /* no ipv6 inside a vserver for now */
17018 + if (skb->sk && skb->sk->sk_vx_info)
17021 read_lock(&dev_base_lock);
17022 for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
17024 diff -NurpP --minimal linux-2.6.10/net/ipv6/netfilter/ip6t_owner.c linux-2.6.10-vs1.9.3.17/net/ipv6/netfilter/ip6t_owner.c
17025 --- linux-2.6.10/net/ipv6/netfilter/ip6t_owner.c 2004-12-25 01:55:32.000000000 +0100
17026 +++ linux-2.6.10-vs1.9.3.17/net/ipv6/netfilter/ip6t_owner.c 2004-12-26 19:40:30.000000000 +0100
17027 @@ -28,7 +28,7 @@ match_pid(const struct sk_buff *skb, pid
17030 read_lock(&tasklist_lock);
17031 - p = find_task_by_pid(pid);
17032 + p = find_task_by_real_pid(pid);
17036 diff -NurpP --minimal linux-2.6.10/net/netlink/af_netlink.c linux-2.6.10-vs1.9.3.17/net/netlink/af_netlink.c
17037 --- linux-2.6.10/net/netlink/af_netlink.c 2004-12-25 01:55:32.000000000 +0100
17038 +++ linux-2.6.10-vs1.9.3.17/net/netlink/af_netlink.c 2004-12-26 19:40:29.000000000 +0100
17040 #include <linux/bitops.h>
17041 #include <linux/mm.h>
17042 #include <linux/types.h>
17043 +#include <linux/vs_context.h>
17044 +#include <linux/vs_network.h>
17045 +#include <linux/vs_limit.h>
17046 #include <net/sock.h>
17047 #include <net/scm.h>
17049 @@ -361,6 +364,12 @@ static int netlink_create(struct socket
17050 init_waitqueue_head(&nlk->wait);
17051 sk->sk_destruct = netlink_sock_destruct;
17053 + set_vx_info(&sk->sk_vx_info, current->vx_info);
17054 + sk->sk_xid = vx_current_xid();
17056 + set_nx_info(&sk->sk_nx_info, current->nx_info);
17057 + sk->sk_nid = nx_current_nid();
17059 sk->sk_protocol = protocol;
17062 @@ -402,6 +411,12 @@ static int netlink_release(struct socket
17063 notifier_call_chain(&netlink_chain, NETLINK_URELEASE, &n);
17067 + clr_vx_info(&sk->sk_vx_info);
17069 + clr_nx_info(&sk->sk_nx_info);
17075 diff -NurpP --minimal linux-2.6.10/net/socket.c linux-2.6.10-vs1.9.3.17/net/socket.c
17076 --- linux-2.6.10/net/socket.c 2004-12-25 01:55:32.000000000 +0100
17077 +++ linux-2.6.10-vs1.9.3.17/net/socket.c 2004-12-26 19:40:29.000000000 +0100
17080 #include <net/sock.h>
17081 #include <linux/netfilter.h>
17082 +#include <linux/vs_socket.h>
17084 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
17085 static ssize_t sock_aio_read(struct kiocb *iocb, char __user *buf,
17086 @@ -287,7 +288,7 @@ static struct inode *sock_alloc_inode(st
17087 ei->socket.ops = NULL;
17088 ei->socket.sk = NULL;
17089 ei->socket.file = NULL;
17090 - ei->socket.passcred = 0;
17091 + ei->socket.flags = 0;
17093 return &ei->vfs_inode;
17095 @@ -531,7 +532,7 @@ static inline int __sock_sendmsg(struct
17096 struct msghdr *msg, size_t size)
17098 struct sock_iocb *si = kiocb_to_siocb(iocb);
17104 @@ -542,7 +543,21 @@ static inline int __sock_sendmsg(struct
17108 - return sock->ops->sendmsg(iocb, sock, msg, size);
17109 + len = sock->ops->sendmsg(iocb, sock, msg, size);
17112 + vx_sock_send(sock->sk, size);
17114 + vx_sock_fail(sock->sk, size);
17116 + vxdprintk(VXD_CBIT(net, 7),
17117 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d",
17119 + (sock->sk)?sock->sk->sk_nx_info:0,
17120 + (sock->sk)?sock->sk->sk_vx_info:0,
17121 + (sock->sk)?sock->sk->sk_xid:0,
17122 + (unsigned int)size, len);
17126 int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
17127 @@ -580,7 +595,7 @@ int kernel_sendmsg(struct socket *sock,
17128 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
17129 struct msghdr *msg, size_t size, int flags)
17133 struct sock_iocb *si = kiocb_to_siocb(iocb);
17136 @@ -593,7 +608,17 @@ static inline int __sock_recvmsg(struct
17140 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
17141 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
17142 + if ((len >= 0) && sock->sk)
17143 + vx_sock_recv(sock->sk, len);
17144 + vxdprintk(VXD_CBIT(net, 7),
17145 + "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d",
17147 + (sock->sk)?sock->sk->sk_nx_info:0,
17148 + (sock->sk)?sock->sk->sk_vx_info:0,
17149 + (sock->sk)?sock->sk->sk_xid:0,
17150 + (unsigned int)size, len);
17154 int sock_recvmsg(struct socket *sock, struct msghdr *msg,
17155 @@ -1085,6 +1110,10 @@ static int __sock_create(int family, int
17156 if (type < 0 || type >= SOCK_MAX)
17159 + /* disable IPv6 inside vservers for now */
17160 + if (family == PF_INET6 && !vx_check(0, VX_ADMIN))
17161 + return -EAFNOSUPPORT;
17165 This uglymoron is moved from INET layer to here to avoid
17166 @@ -1193,6 +1222,7 @@ asmlinkage long sys_socket(int family, i
17170 + set_bit(SOCK_USER_SOCKET, &sock->flags);
17171 retval = sock_map_fd(sock);
17174 @@ -1223,10 +1253,12 @@ asmlinkage long sys_socketpair(int famil
17175 err = sock_create(family, type, protocol, &sock1);
17178 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
17180 err = sock_create(family, type, protocol, &sock2);
17182 goto out_release_1;
17183 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
17185 err = sock1->ops->socketpair(sock1, sock2);
17187 diff -NurpP --minimal linux-2.6.10/net/sunrpc/auth.c linux-2.6.10-vs1.9.3.17/net/sunrpc/auth.c
17188 --- linux-2.6.10/net/sunrpc/auth.c 2004-08-14 12:55:32.000000000 +0200
17189 +++ linux-2.6.10-vs1.9.3.17/net/sunrpc/auth.c 2004-12-26 19:40:34.000000000 +0100
17191 #include <linux/socket.h>
17192 #include <linux/sunrpc/clnt.h>
17193 #include <linux/spinlock.h>
17194 +#include <linux/vserver/xid.h>
17197 # define RPCDBG_FACILITY RPCDBG_AUTH
17198 @@ -261,6 +262,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
17199 get_group_info(current->group_info);
17200 acred.uid = current->fsuid;
17201 acred.gid = current->fsgid;
17202 + acred.xid = vx_current_xid();
17203 acred.group_info = current->group_info;
17205 dprintk("RPC: looking up %s cred\n",
17206 @@ -280,6 +282,7 @@ rpcauth_bindcred(struct rpc_task *task)
17207 get_group_info(current->group_info);
17208 acred.uid = current->fsuid;
17209 acred.gid = current->fsgid;
17210 + acred.xid = vx_current_xid();
17211 acred.group_info = current->group_info;
17213 dprintk("RPC: %4d looking up %s cred\n",
17214 diff -NurpP --minimal linux-2.6.10/net/sunrpc/auth_unix.c linux-2.6.10-vs1.9.3.17/net/sunrpc/auth_unix.c
17215 --- linux-2.6.10/net/sunrpc/auth_unix.c 2004-08-14 12:55:33.000000000 +0200
17216 +++ linux-2.6.10-vs1.9.3.17/net/sunrpc/auth_unix.c 2004-12-26 19:40:34.000000000 +0100
17217 @@ -13,14 +13,17 @@
17218 #include <linux/in.h>
17219 #include <linux/sunrpc/clnt.h>
17220 #include <linux/sunrpc/auth.h>
17221 +#include <linux/vserver/xid.h>
17223 #define NFS_NGROUPS 16
17226 struct rpc_cred uc_base;
17229 uid_t uc_puid; /* process uid */
17230 gid_t uc_pgid; /* process gid */
17231 + xid_t uc_pxid; /* process xid */
17232 gid_t uc_gids[NFS_NGROUPS];
17234 #define uc_uid uc_base.cr_uid
17235 @@ -80,6 +83,7 @@ unx_create_cred(struct rpc_auth *auth, s
17236 if (flags & RPC_TASK_ROOTCREDS) {
17237 cred->uc_uid = cred->uc_puid = 0;
17238 cred->uc_gid = cred->uc_pgid = 0;
17239 + cred->uc_xid = cred->uc_pxid = vx_current_xid();
17240 cred->uc_gids[0] = NOGROUP;
17242 int groups = acred->group_info->ngroups;
17243 @@ -88,8 +92,10 @@ unx_create_cred(struct rpc_auth *auth, s
17245 cred->uc_uid = acred->uid;
17246 cred->uc_gid = acred->gid;
17247 + cred->uc_xid = acred->xid;
17248 cred->uc_puid = current->uid;
17249 cred->uc_pgid = current->gid;
17250 + cred->uc_pxid = vx_current_xid();
17251 for (i = 0; i < groups; i++)
17252 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
17253 if (i < NFS_NGROUPS)
17254 @@ -122,8 +128,10 @@ unx_match(struct auth_cred *acred, struc
17256 if (cred->uc_uid != acred->uid
17257 || cred->uc_gid != acred->gid
17258 + || cred->uc_xid != acred->xid
17259 || cred->uc_puid != current->uid
17260 - || cred->uc_pgid != current->gid)
17261 + || cred->uc_pgid != current->gid
17262 + || cred->uc_pxid != vx_current_xid())
17265 groups = acred->group_info->ngroups;
17266 @@ -149,7 +157,7 @@ unx_marshal(struct rpc_task *task, u32 *
17267 struct rpc_clnt *clnt = task->tk_client;
17268 struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred;
17273 *p++ = htonl(RPC_AUTH_UNIX);
17275 @@ -159,14 +167,19 @@ unx_marshal(struct rpc_task *task, u32 *
17276 * Copy the UTS nodename captured when the client was created.
17278 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
17279 + tagxid = task->tk_client->cl_tagxid;
17281 /* Note: we don't use real uid if it involves raising privilege */
17282 if (ruid && cred->uc_puid != 0 && cred->uc_pgid != 0) {
17283 - *p++ = htonl((u32) cred->uc_puid);
17284 - *p++ = htonl((u32) cred->uc_pgid);
17285 + *p++ = htonl((u32) XIDINO_UID(tagxid,
17286 + cred->uc_puid, cred->uc_pxid));
17287 + *p++ = htonl((u32) XIDINO_GID(tagxid,
17288 + cred->uc_pgid, cred->uc_pxid));
17290 - *p++ = htonl((u32) cred->uc_uid);
17291 - *p++ = htonl((u32) cred->uc_gid);
17292 + *p++ = htonl((u32) XIDINO_UID(tagxid,
17293 + cred->uc_uid, cred->uc_xid));
17294 + *p++ = htonl((u32) XIDINO_GID(tagxid,
17295 + cred->uc_gid, cred->uc_xid));
17298 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
17299 diff -NurpP --minimal linux-2.6.10/net/unix/af_unix.c linux-2.6.10-vs1.9.3.17/net/unix/af_unix.c
17300 --- linux-2.6.10/net/unix/af_unix.c 2004-12-25 01:55:32.000000000 +0100
17301 +++ linux-2.6.10-vs1.9.3.17/net/unix/af_unix.c 2004-12-26 19:40:29.000000000 +0100
17302 @@ -118,6 +118,9 @@
17303 #include <linux/mount.h>
17304 #include <net/checksum.h>
17305 #include <linux/security.h>
17306 +#include <linux/vs_context.h>
17307 +#include <linux/vs_network.h>
17308 +#include <linux/vs_limit.h>
17310 int sysctl_unix_max_dgram_qlen = 10;
17312 @@ -394,6 +397,9 @@ static int unix_release_sock (struct soc
17317 + clr_vx_info(&sk->sk_vx_info);
17318 + clr_nx_info(&sk->sk_nx_info);
17321 /* ---- Socket is dead now and most probably destroyed ---- */
17322 @@ -550,6 +556,11 @@ static struct sock * unix_create1(struct
17323 sock_init_data(sock,sk);
17324 sk_set_owner(sk, THIS_MODULE);
17326 + set_vx_info(&sk->sk_vx_info, current->vx_info);
17327 + sk->sk_xid = vx_current_xid();
17329 + set_nx_info(&sk->sk_nx_info, current->nx_info);
17331 sk->sk_write_space = unix_write_space;
17332 sk->sk_max_ack_backlog = sysctl_unix_max_dgram_qlen;
17333 sk->sk_destruct = unix_sock_destructor;
17334 @@ -861,7 +872,7 @@ static int unix_dgram_connect(struct soc
17338 - if (sock->passcred && !unix_sk(sk)->addr &&
17339 + if (test_bit(SOCK_PASS_CRED, &sock->flags) && !unix_sk(sk)->addr &&
17340 (err = unix_autobind(sock)) != 0)
17343 @@ -952,7 +963,8 @@ static int unix_stream_connect(struct so
17347 - if (sock->passcred && !u->addr && (err = unix_autobind(sock)) != 0)
17348 + if (test_bit(SOCK_PASS_CRED, &sock->flags)
17349 + && !u->addr && (err = unix_autobind(sock)) != 0)
17352 timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
17353 @@ -1286,7 +1298,8 @@ static int unix_dgram_sendmsg(struct kio
17357 - if (sock->passcred && !u->addr && (err = unix_autobind(sock)) != 0)
17358 + if (test_bit(SOCK_PASS_CRED, &sock->flags)
17359 + && !u->addr && (err = unix_autobind(sock)) != 0)
17363 diff -NurpP --minimal linux-2.6.10/security/commoncap.c linux-2.6.10-vs1.9.3.17/security/commoncap.c
17364 --- linux-2.6.10/security/commoncap.c 2004-12-25 01:55:32.000000000 +0100
17365 +++ linux-2.6.10-vs1.9.3.17/security/commoncap.c 2004-12-26 19:40:23.000000000 +0100
17366 @@ -142,7 +142,7 @@ void cap_bprm_apply_creds (struct linux_
17367 /* Derived from fs/exec.c:compute_creds. */
17368 kernel_cap_t new_permitted, working;
17370 - new_permitted = cap_intersect (bprm->cap_permitted, cap_bset);
17371 + new_permitted = cap_intersect (bprm->cap_permitted, vx_current_bcaps());
17372 working = cap_intersect (bprm->cap_inheritable,
17373 current->cap_inheritable);
17374 new_permitted = cap_combine (new_permitted, working);
17375 diff -NurpP --minimal linux-2.6.10/security/security.c linux-2.6.10-vs1.9.3.17/security/security.c
17376 --- linux-2.6.10/security/security.c 2004-12-25 01:55:33.000000000 +0100
17377 +++ linux-2.6.10-vs1.9.3.17/security/security.c 2004-12-26 19:40:23.000000000 +0100
17378 @@ -185,6 +185,8 @@ int mod_unreg_security(const char *name,
17380 int capable(int cap)
17382 + if (vx_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
17384 if (security_ops->capable(current, cap)) {
17385 /* capability denied */
17387 @@ -195,9 +197,24 @@ int capable(int cap)
17391 +int vx_capable(int cap, int ccap)
17393 + if (security_ops->capable(current, cap)) {
17394 + /* capability denied */
17397 + if (!vx_ccaps(ccap))
17400 + /* capability granted */
17401 + current->flags |= PF_SUPERPRIV;
17405 EXPORT_SYMBOL_GPL(register_security);
17406 EXPORT_SYMBOL_GPL(unregister_security);
17407 EXPORT_SYMBOL_GPL(mod_reg_security);
17408 EXPORT_SYMBOL_GPL(mod_unreg_security);
17409 EXPORT_SYMBOL(capable);
17410 +EXPORT_SYMBOL(vx_capable);
17411 EXPORT_SYMBOL(security_ops);