]> git.pld-linux.org Git - packages/kernel.git/blame - linux-2.6-vs.patch
- obsolete
[packages/kernel.git] / linux-2.6-vs.patch
CommitLineData
061e4d09
JB
1diff -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
4@@ -0,0 +1,171 @@
5+
6+debug_switch:
7+
8+ 0 1
9+
10+ 1 2
11+
12+ 2 4
13+
14+ 3 8
15+
16+ 4 16
17+
18+ 5 32
19+
20+ 6 64
21+
22+ 7 128
23+
24+
25+debug_xid:
26+
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)"
32+
33+ 1 2 "alloc_vx_info(%d)*"
34+ "loc_vx_info(%d)*"
35+ "locate_vx_info(%d)"
36+
37+ 2 4 "get_vx_info(%p[#%d.%d])"
38+ "put_vx_info(%p[#%d.%d])"
39+
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"
43+
44+ 4 16 "__hash_vx_info: %p[#%d]"
45+ "__unhash_vx_info: %p[#%d]"
46+ "__vx_dynamic_id: [#%d]"
47+
48+ 5 32 "vx_migrate_task(%p,%p[#%d.%d])"
49+ "task_get_vx_info(%p)"
50+
51+ 6 64 "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
52+
53+ 7 128 "vx_propagate_xid(%p[#%d.%d]): %d"
54+
55+
56+debug_nid:
57+
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)"
63+
64+ 1 2 "alloc_nx_info(%d)*"
65+ "loc_nx_info(%d)*"
66+
67+ 2 4 "get_nx_info(%p[#%d.%d])"
68+ "put_nx_info(%p[#%d.%d])"
69+
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"
73+
74+ 4 16 "__hash_nx_info: %p[#%d]"
75+ "__unhash_nx_info: %p[#%d]"
76+ "__nx_dynamic_id: [#%d]"
77+
78+ 5 32 "nx_migrate_task(%p,%p[#%d.%d])"
79+ "task_get_nx_info(%p)"
80+ "create_nx_info()"
81+
82+ 6 64
83+
84+ 7 128
85+
86+
87+debug_dlim:
88+
89+ 0 1 "alloc_dl_info(%p,%d) = %p"
90+ "dealloc_dl_info(%p)"
91+ "locate_dl_info(%p,#%d) = %p"
92+
93+ 1 2 "alloc_dl_info(%p,%d)*"
94+
95+ 2 4 "get_dl_info(%p[#%d.%d])"
96+ "put_dl_info(%p[#%d.%d])"
97+
98+ 3 8 "rcu_free_dl_info(%p)"
99+ "__hash_dl_info: %p[#%d]"
100+ "__unhash_dl_info: %p[#%d]"
101+
102+
103+ 4 16 "ALLOC (%p,#%d)%c inode (%d)"
104+ "FREE (%p,#%d)%c inode"
105+
106+ 5 32 "ALLOC (%p,#%d)%c %lld bytes (%d)"
107+ "FREE (%p,#%d)%c %lld bytes"
108+
109+ 6 64 "ADJUST: %lld,%lld on %d,%d [mult=%d]"
110+
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"
113+
114+
115+
116+debug_cvirt:
117+
118+
119+ 0 1
120+
121+ 1 2
122+
123+ 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
124+ "vx_rmap_tgid: %p/%llx: %d -> %d"
125+
126+ 3 8
127+
128+ 4 16
129+
130+ 5 32
131+
132+ 6 64
133+
134+ 7 128
135+
136+
137+
138+debug_net:
139+
140+
141+ 0 1
142+
143+ 1 2
144+
145+ 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
146+
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"
149+
150+ 4 16 "ip_route_connect(%p) %p,%p;%lx"
151+
152+ 5 32 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
153+
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)"
159+
160+ 7 128 "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
161+ "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
162+
163+
164+
165+
166+debug_limit:
167+
168+ n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
169+ "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
170+
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"
174+
175+
176diff -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
179@@ -1,7 +1,7 @@
180 VERSION = 2
181 PATCHLEVEL = 6
182 SUBLEVEL = 10
183-EXTRAVERSION =
184+EXTRAVERSION = -vs1.9.3.17
185 NAME=Woozy Numbat
186
187 # *DOCUMENTATION*
188diff -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"
192
193 source "arch/alpha/Kconfig.debug"
194
195+source "kernel/vserver/Kconfig"
196+
197 source "security/Kconfig"
198
199 source "crypto/Kconfig"
200diff -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);
205 if (!child)
206 goto out_notsk;
207+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
208+ goto out;
209
210 if (request == PTRACE_ATTACH) {
211 ret = ptrace_attach(child);
212diff -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
224diff -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"
228
229 source "arch/arm/Kconfig.debug"
230
231+source "kernel/vserver/Kconfig"
232+
233 source "security/Kconfig"
234
235 source "crypto/Kconfig"
236diff -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);
241 if (!child)
242 goto out;
243+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
244+ goto out_tsk;
245
246 ret = -EPERM;
247 if (pid == 1) /* you may not mess with init */
248diff -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"
252
253 source "arch/arm26/Kconfig.debug"
254
255+source "kernel/vserver/Kconfig"
256+
257 source "security/Kconfig"
258
259 source "crypto/Kconfig"
260diff -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);
265 if (!child)
266 goto out;
267+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
268+ goto out_tsk;
269
270 ret = -EPERM;
271 if (pid == 1) /* you may not mess with init */
272diff -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"
276
277 source "arch/cris/Kconfig.debug"
278
279+source "kernel/vserver/Kconfig"
280+
281 source "security/Kconfig"
282
283 source "crypto/Kconfig"
284diff -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"
288
289 source "arch/h8300/Kconfig.debug"
290
291+source "kernel/vserver/Kconfig"
292+
293 source "security/Kconfig"
294
295 source "crypto/Kconfig"
296diff -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);
301 if (!child)
302 goto out;
303+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
304+ goto out_tsk;
305
306 ret = -EPERM;
307 if (pid == 1) /* you may not mess with init */
308diff -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
313 default y
314
315+config KERNEL_HZ
316+ int "Timer Frequency (100-20000)"
317+ range 100 20000
318+ default "1000"
319+ help
320+ This allows you to specify the frequency at which the
321+ kernel timer interrupt will occur.
322+
323 config X86_TSC
324 bool
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
327
328 endchoice
329
330+choice
331+ prompt "Memory Split User Space"
332+ default SPLIT_3GB
333+ help
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.
337+
338+config SPLIT_3GB
339+ bool "3.0GB/1.0GB Kernel (Default)"
340+ help
341+ This is the default split of 3GB userspace to 1GB kernel
342+ space, which will result in about 860MB of lowmem.
343+
344+config SPLIT_25GB
345+ bool "2.5GB/1.5GB Kernel"
346+ help
347+ This split provides 2.5GB userspace and 1.5GB kernel
348+ space, which will result in about 1370MB of lowmem.
349+
350+config SPLIT_2GB
351+ bool "2.0GB/2.0GB Kernel"
352+ help
353+ This split provides 2GB userspace and 2GB kernel
354+ space, which will result in about 1880MB of lowmem.
355+
356+config SPLIT_15GB
357+ bool "1.5GB/2.5GB Kernel"
358+ help
359+ This split provides 1.5GB userspace and 2.5GB kernel
360+ space, which will result in about 2390MB of lowmem.
361+
362+config SPLIT_1GB
363+ bool "1.0GB/3.0GB Kernel"
364+ help
365+ This split provides 1GB userspace and 3GB kernel
366+ space, which will result in about 2900MB of lowmem.
367+
368+endchoice
369+
370 config HIGHMEM
371 bool
372 depends on HIGHMEM64G || HIGHMEM4G
373@@ -1194,6 +1242,8 @@ source "arch/i386/oprofile/Kconfig"
374
375 source "arch/i386/Kconfig.debug"
376
377+source "kernel/vserver/Kconfig"
378+
379 source "security/Kconfig"
380
381 source "crypto/Kconfig"
382diff -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)
388 {
389- unsigned int curr_count, prev_count=~0;
390- int delta;
391+ unsigned int curr_count, prev_count;
392
393 curr_count = get_8254_timer_count();
394-
395 do {
396 prev_count = curr_count;
397 curr_count = get_8254_timer_count();
398- delta = curr_count-prev_count;
399
400- /*
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.
404- */
405+ /* workaround for broken Mercury/Neptune */
406+ if (prev_count >= curr_count + 0x100)
407+ curr_count = get_8254_timer_count();
408
409- } while (delta < 300);
410+ } while (prev_count >= curr_count);
411 }
412
413 /*
414diff -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]);
419
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);
425 return 0;
426 }
427
428diff -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 */
433 .long sys_utimes
434 .long sys_fadvise64_64
435- .long sys_ni_syscall /* sys_vserver */
436+ .long sys_vserver
437 .long sys_mbind
438 .long sys_get_mempolicy
439 .long sys_set_mempolicy
440diff -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)
444
445 local_irq_enable();
446 /* Let ten ticks pass... */
447- mdelay((10 * 1000) / HZ);
448+ mdelay((10 * 1000) / HZ + 1);
449
450 /*
451 * Expect a few ticks at least, to be sure some possible
452diff -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);
457 if (!child)
458 goto out;
459+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
460+ goto out_tsk;
461
462 ret = -EPERM;
463 if (pid == 1) /* you may not mess with init */
464diff -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
468 printk(KERN_INFO
469 "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
470 cpucount+1,
471- bogosum/(500000/HZ),
472- (bogosum/(5000/HZ))%100);
473+ HZ*(bogosum >> 3)/62500,
474+ (HZ*(bogosum >> 3)/625) % 100);
475
476 Dprintk("Before bogocount - setting activated=1.\n");
477
478diff -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
481@@ -19,6 +19,7 @@
482 #include <linux/mman.h>
483 #include <linux/file.h>
484 #include <linux/utsname.h>
485+#include <linux/vs_cvirt.h>
486
487 #include <asm/uaccess.h>
488 #include <asm/ipc.h>
489@@ -217,7 +218,7 @@ asmlinkage int sys_uname(struct old_utsn
490 if (!name)
491 return -EFAULT;
492 down_read(&uts_sem);
493- err=copy_to_user(name, &system_utsname, sizeof (*name));
494+ err=copy_to_user(name, vx_new_utsname(), sizeof (*name));
495 up_read(&uts_sem);
496 return err?-EFAULT:0;
497 }
498@@ -225,6 +226,7 @@ asmlinkage int sys_uname(struct old_utsn
499 asmlinkage int sys_olduname(struct oldold_utsname __user * name)
500 {
501 int error;
502+ struct new_utsname *ptr;
503
504 if (!name)
505 return -EFAULT;
506@@ -233,15 +235,16 @@ asmlinkage int sys_olduname(struct oldol
507
508 down_read(&uts_sem);
509
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);
526
527 up_read(&uts_sem);
528diff -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
531@@ -53,6 +53,7 @@
532
533 #include <linux/irq.h>
534 #include <linux/module.h>
535+#include <linux/vserver/debug.h>
536
537 #include "mach_traps.h"
538
539@@ -306,6 +307,7 @@ void die(const char * str, struct pt_reg
540 };
541 static int die_counter;
542
543+ vxh_throw_oops();
544 if (die.lock_owner != smp_processor_id()) {
545 console_verbose();
546 spin_lock_irq(&die.lock);
547@@ -340,6 +342,7 @@ void die(const char * str, struct pt_reg
548 bust_spinlocks(0);
549 die.lock_owner = -1;
550 spin_unlock_irq(&die.lock);
551+ vxh_dump_history();
552 if (in_interrupt())
553 panic("Fatal exception in interrupt");
554
555diff -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
559 {
560 pte_t entry;
561
562- mm->rss += (HPAGE_SIZE / PAGE_SIZE);
563+ // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
564+ vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
565 if (write_access) {
566 entry =
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);
570 get_page(ptepage);
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);
575 addr += HPAGE_SIZE;
576 }
577 return 0;
578@@ -218,7 +220,8 @@ void unmap_hugepage_range(struct vm_area
579 page = pte_page(pte);
580 put_page(page);
581 }
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);
586 }
587
588diff -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"
592
593 source "arch/ia64/Kconfig.debug"
594
595+source "kernel/vserver/Kconfig"
596+
597 source "security/Kconfig"
598
599 source "crypto/Kconfig"
600diff -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)
604 int
605 ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
606 {
607- unsigned long stack_base;
608+ unsigned long stack_base, grow;
609 struct vm_area_struct *mpnt;
610 struct mm_struct *mm = current->mm;
611 int i, ret;
612@@ -216,8 +216,10 @@ ia32_setup_arg_pages (struct linux_binpr
613 if (!mpnt)
614 return -ENOMEM;
615
616- if (security_vm_enough_memory((IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
617- >> PAGE_SHIFT)) {
618+ grow = (IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
619+ >> PAGE_SHIFT;
620+ if (security_vm_enough_memory(grow) ||
621+ !vx_vmpages_avail(mm, grow)) {
622 kmem_cache_free(vm_area_cachep, mpnt);
623 return -ENOMEM;
624 }
625@@ -242,7 +244,9 @@ ia32_setup_arg_pages (struct linux_binpr
626 kmem_cache_free(vm_area_cachep, mpnt);
627 return ret;
628 }
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;
633 }
634
635 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
636diff -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:
640 data8 sys_mq_notify
641 data8 sys_mq_getsetattr
642 data8 sys_ni_syscall // reserved for kexec_load
643- data8 sys_ni_syscall // reserved for vserver
644+ data8 sys_vserver
645 data8 sys_waitid // 1270
646 data8 sys_add_key
647 data8 sys_request_key
648diff -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
651@@ -39,6 +39,8 @@
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>
657
658 #include <asm/errno.h>
659 #include <asm/intrinsics.h>
660@@ -2341,7 +2343,8 @@ pfm_smpl_buffer_alloc(struct task_struct
661 */
662 insert_vm_struct(mm, vma);
663
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);
669
670diff -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);
675 if (!child)
676 goto out;
677+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
678+ goto out_tsk;
679+
680 ret = -EPERM;
681 if (pid == 1) /* no messing around with init! */
682 goto out_tsk;
683diff -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
686@@ -9,6 +9,7 @@
687 #include <linux/mm.h>
688 #include <linux/smp_lock.h>
689 #include <linux/interrupt.h>
690+#include <linux/vs_memory.h>
691
692 #include <asm/pgtable.h>
693 #include <asm/processor.h>
694@@ -33,12 +34,19 @@ expand_backing_store (struct vm_area_str
695
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))
701+ return -ENOMEM;
702+ if (!vx_vmpages_avail(vma->vm_mm, grow) ||
703+ ((vma->vm_flags & VM_LOCKED) &&
704+ !vx_vmlocked_avail(vma->vm_mm, grow)))
705 return -ENOMEM;
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);
715 return 0;
716 }
717diff -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
721 {
722 pte_t entry;
723
724- mm->rss += (HPAGE_SIZE / PAGE_SIZE);
725+ // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
726+ vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
727 if (write_access) {
728 entry =
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);
732 get_page(ptepage);
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);
737 addr += HPAGE_SIZE;
738 }
739 return 0;
740@@ -249,7 +251,8 @@ void unmap_hugepage_range(struct vm_area
741 put_page(page);
742 pte_clear(pte);
743 }
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);
748 }
749
750diff -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"
754
755 source "arch/m68k/Kconfig.debug"
756
757+source "kernel/vserver/Kconfig"
758+
759 source "security/Kconfig"
760
761 source "crypto/Kconfig"
762diff -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)));
767 swap_free(entry);
768 get_page(page);
769- ++vma->vm_mm->rss;
770+ // ++vma->vm_mm->rss;
771+ vx_rsspages_inc(vma->vm_mm);
772 }
773
774 static inline void unswap_pmd(struct vm_area_struct * vma, pmd_t *dir,
775diff -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);
780 if (!child)
781 goto out;
782+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
783+ goto out_tsk;
784
785 ret = -EPERM;
786 if (pid == 1) /* you may not mess with init */
787diff -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"
791
792 source "arch/m68knommu/Kconfig.debug"
793
794+source "kernel/vserver/Kconfig"
795+
796 source "security/Kconfig"
797
798 source "crypto/Kconfig"
799diff -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);
804 if (!child)
805 goto out;
806+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
807+ goto out_tsk;
808
809 ret = -EPERM;
810 if (pid == 1) /* you may not mess with init */
811diff -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"
815
816 source "arch/mips/Kconfig.debug"
817
818+source "kernel/vserver/Kconfig"
819+
820 source "security/Kconfig"
821
822 source "crypto/Kconfig"
823diff -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.
829 */
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;
835
836diff -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
840 int ret = 0;
841
842 down_read(&uts_sem);
843- if (copy_to_user(name,&system_utsname,sizeof *name))
844+ if (copy_to_user(name, vx_new_utsname(), sizeof *name))
845 ret = -EFAULT;
846 up_read(&uts_sem);
847
848diff -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);
853 if (!child)
854 goto out;
855+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
856+ goto out_tsk;
857
858 ret = -EPERM;
859 if (pid == 1) /* you may not mess with init */
860diff -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
863@@ -25,6 +25,7 @@
864 #include <linux/msg.h>
865 #include <linux/shm.h>
866 #include <linux/compiler.h>
867+#include <linux/vs_cvirt.h>
868
869 #include <asm/branch.h>
870 #include <asm/cachectl.h>
871@@ -212,7 +213,7 @@ out:
872 */
873 asmlinkage int sys_uname(struct old_utsname * name)
874 {
875- if (name && !copy_to_user(name, &system_utsname, sizeof (*name)))
876+ if (name && !copy_to_user(name, vx_new_utsname(), sizeof (*name)))
877 return 0;
878 return -EFAULT;
879 }
880@@ -223,21 +224,23 @@ asmlinkage int sys_uname(struct old_utsn
881 asmlinkage int sys_olduname(struct oldold_utsname * name)
882 {
883 int error;
884+ struct new_utsname *ptr;
885
886 if (!name)
887 return -EFAULT;
888 if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
889 return -EFAULT;
890
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;
908
909@@ -263,10 +266,10 @@ asmlinkage int _sys_sysmips(int cmd, lon
910 return -EFAULT;
911
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)));
920 up_write(&uts_sem);
921 return 0;
922 }
923diff -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
926@@ -30,6 +30,7 @@
927 #include <linux/socket.h>
928 #include <linux/security.h>
929 #include <linux/syscalls.h>
930+#include <linux/vs_cvirt.h>
931
932 #include <asm/ptrace.h>
933 #include <asm/page.h>
934@@ -582,7 +583,8 @@ asmlinkage int irix_brk(unsigned long br
935 /*
936 * Check if we have enough memory..
937 */
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)) {
941 ret = -ENOMEM;
942 goto out;
943 }
944diff -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"
948
949 source "arch/parisc/Kconfig.debug"
950
951+source "kernel/vserver/Kconfig"
952+
953 source "security/Kconfig"
954
955 source "crypto/Kconfig"
956diff -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);
961 if (!child)
962 goto out;
963+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
964+ goto out_tsk;
965+
966 ret = -EPERM;
967 if (pid == 1) /* no messing around with init! */
968 goto out_tsk;
969diff -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
973
974 do {
975 seq = read_seqbegin(&xtime_lock);
976+ /* requires vx virtualization */
977 val.uptime = jiffies / HZ;
978
979 val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
980diff -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"
984
985 source "arch/ppc/Kconfig.debug"
986
987+source "kernel/vserver/Kconfig"
988+
989 source "security/Kconfig"
990
991 source "crypto/Kconfig"
992diff -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 */
1000+ .long sys_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 */
1004diff -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);
1009 if (!child)
1010 goto out;
1011+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1012+ goto out_tsk;
1013
1014 ret = -EPERM;
1015 if (pid == 1) /* you may not mess with init */
1016diff -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
1019@@ -36,6 +36,7 @@
1020 #include <linux/utsname.h>
1021 #include <linux/file.h>
1022 #include <linux/unistd.h>
1023+#include <linux/vs_cvirt.h>
1024
1025 #include <asm/uaccess.h>
1026 #include <asm/ipc.h>
1027@@ -229,7 +230,7 @@ int sys_uname(struct old_utsname __user
1028 int err = -EFAULT;
1029
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)))
1033 err = 0;
1034 up_read(&uts_sem);
1035 return err;
1036@@ -238,6 +239,7 @@ int sys_uname(struct old_utsname __user
1037 int sys_olduname(struct oldold_utsname __user * name)
1038 {
1039 int error;
1040+ struct new_utsname *ptr;
1041
1042 if (!name)
1043 return -EFAULT;
1044@@ -245,15 +247,16 @@ int sys_olduname(struct oldold_utsname _
1045 return -EFAULT;
1046
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);
1064 up_read(&uts_sem);
1065
1066diff -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"
1070
1071 source "arch/ppc64/Kconfig.debug"
1072
1073+source "kernel/vserver/Kconfig"
1074+
1075 source "security/Kconfig"
1076
1077 config KEYS_COMPAT
1078diff -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 */
1090diff -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);
1095 if (!child)
1096 goto out;
1097+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1098+ goto out_tsk;
1099
1100 ret = -EPERM;
1101 if (pid == 1) /* you may not mess with init */
1102diff -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
1105@@ -60,6 +60,7 @@
1106 #include <linux/ptrace.h>
1107 #include <linux/aio_abi.h>
1108 #include <linux/elf.h>
1109+#include <linux/vs_cvirt.h>
1110
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)
1115 {
1116 int error;
1117+ struct new_utsname *ptr;
1118
1119 if (!name)
1120 return -EFAULT;
1121@@ -1180,15 +1182,16 @@ asmlinkage int sys32_olduname(struct old
1122 return -EFAULT;
1123
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);
1141 up_read(&uts_sem);
1142
1143diff -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
1147 {
1148 pte_t entry;
1149
1150- mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1151+ // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1152+ vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
1153 if (write_access) {
1154 entry =
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
1157
1158 ptepage = pte_page(entry);
1159 get_page(ptepage);
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);
1164
1165 addr += HPAGE_SIZE;
1166@@ -421,7 +423,8 @@ void unmap_hugepage_range(struct vm_area
1167
1168 put_page(page);
1169 }
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();
1174 }
1175
1176diff -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"
1180
1181 source "arch/s390/Kconfig.debug"
1182
1183+source "kernel/vserver/Kconfig"
1184+
1185 source "security/Kconfig"
1186
1187 source "crypto/Kconfig"
1188diff -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
1191@@ -36,7 +36,7 @@
1192
1193 int setup_arg_pages32(struct linux_binprm *bprm, int executable_stack)
1194 {
1195- unsigned long stack_base;
1196+ unsigned long stack_base, grow;
1197 struct vm_area_struct *mpnt;
1198 struct mm_struct *mm = current->mm;
1199 int i, ret;
1200@@ -53,7 +53,10 @@ int setup_arg_pages32(struct linux_binpr
1201 if (!mpnt)
1202 return -ENOMEM;
1203
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))
1206+ >> PAGE_SHIFT;
1207+ if (security_vm_enough_memory(grow) ||
1208+ !vx_vmpages_avail(mm, grow)) {
1209 kmem_cache_free(vm_area_cachep, mpnt);
1210 return -ENOMEM;
1211 }
1212@@ -73,7 +76,9 @@ int setup_arg_pages32(struct linux_binpr
1213 kmem_cache_free(vm_area_cachep, mpnt);
1214 return ret;
1215 }
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;
1220 }
1221
1222 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
1223diff -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);
1228 if (!child)
1229 goto out;
1230+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1231+ goto out_tsk;
1232
1233 ret = do_ptrace(child, request, addr, data);
1234-
1235+out_tsk:
1236 put_task_struct(child);
1237 out:
1238 unlock_kernel();
1239diff -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)
1251diff -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"
1255
1256 source "arch/sh/Kconfig.debug"
1257
1258+source "kernel/vserver/Kconfig"
1259+
1260 source "security/Kconfig"
1261
1262 source "crypto/Kconfig"
1263diff -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;
1268
1269 /* First check via PID */
1270- thread = find_task_by_pid(pid);
1271+ thread = find_task_by_real_pid(pid);
1272
1273 if (thread)
1274 return thread;
1275diff -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);
1280 if (!child)
1281 goto out;
1282+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1283+ goto out_tsk;
1284
1285 ret = -EPERM;
1286 if (pid == 1) /* you may not mess with init */
1287diff -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
1291 unsigned long i;
1292 pte_t entry;
1293
1294- mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1295+ // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1296+ vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
1297
1298 if (write_access)
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;
1302 dst_pte++;
1303 }
1304- dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1305+ // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1306+ vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
1307 addr += HPAGE_SIZE;
1308 }
1309 return 0;
1310@@ -206,7 +208,8 @@ void unmap_hugepage_range(struct vm_area
1311 pte++;
1312 }
1313 }
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);
1318 }
1319
1320diff -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
1324 unsigned long i;
1325 pte_t entry;
1326
1327- mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1328-
1329+ // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1330+ vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
1331 if (write_access)
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;
1336 dst_pte++;
1337 }
1338- dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1339+ // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1340+ vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
1341 addr += HPAGE_SIZE;
1342 }
1343 return 0;
1344@@ -206,7 +207,8 @@ void unmap_hugepage_range(struct vm_area
1345 pte++;
1346 }
1347 }
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);
1352 }
1353
1354diff -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"
1358
1359 source "arch/sparc/Kconfig.debug"
1360
1361+source "kernel/vserver/Kconfig"
1362+
1363 source "security/Kconfig"
1364
1365 source "crypto/Kconfig"
1366diff -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);
1371 goto out;
1372 }
1373+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) {
1374+ pt_error_return(regs, ESRCH);
1375+ goto out_tsk;
1376+ }
1377
1378 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1379 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1380diff -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
1383@@ -21,6 +21,7 @@
1384 #include <linux/utsname.h>
1385 #include <linux/smp.h>
1386 #include <linux/smp_lock.h>
1387+#include <linux/vs_cvirt.h>
1388
1389 #include <asm/uaccess.h>
1390 #include <asm/ipc.h>
1391@@ -471,13 +472,13 @@ asmlinkage int sys_getdomainname(char __
1392
1393 down_read(&uts_sem);
1394
1395- nlen = strlen(system_utsname.domainname) + 1;
1396+ nlen = strlen(vx_new_uts(domainname)) + 1;
1397
1398 if (nlen < len)
1399 len = nlen;
1400 if (len > __NEW_UTS_LEN)
1401 goto done;
1402- if (copy_to_user(name, system_utsname.domainname, len))
1403+ if (copy_to_user(name, vx_new_uts(domainname), len))
1404 goto done;
1405 err = 0;
1406 done:
1407diff -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
1419diff -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"
1423
1424 source "arch/sparc64/Kconfig.debug"
1425
1426+source "kernel/vserver/Kconfig"
1427+
1428 source "security/Kconfig"
1429
1430 source "crypto/Kconfig"
1431diff -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
1434@@ -27,6 +27,7 @@
1435 #include <linux/binfmts.h>
1436 #include <linux/personality.h>
1437 #include <linux/init.h>
1438+#include <linux/vs_memory.h>
1439
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));
1445
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;
1452diff -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);
1457 goto out;
1458 }
1459+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) {
1460+ pt_error_return(regs, ESRCH);
1461+ goto out_tsk;
1462+ }
1463
1464 if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
1465 || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
1466diff -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
1469@@ -25,6 +25,7 @@
1470 #include <linux/syscalls.h>
1471 #include <linux/ipc.h>
1472 #include <linux/personality.h>
1473+#include <linux/vs_cvirt.h>
1474
1475 #include <asm/uaccess.h>
1476 #include <asm/ipc.h>
1477@@ -465,13 +466,13 @@ asmlinkage long sys_getdomainname(char _
1478
1479 down_read(&uts_sem);
1480
1481- nlen = strlen(system_utsname.domainname) + 1;
1482+ nlen = strlen(vx_new_uts(domainname)) + 1;
1483
1484 if (nlen < len)
1485 len = nlen;
1486 if (len > __NEW_UTS_LEN)
1487 goto done;
1488- if (copy_to_user(name, system_utsname.domainname, len))
1489+ if (copy_to_user(name, vx_new_uts(domainname), len))
1490 goto done;
1491 err = 0;
1492 done:
1493diff -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
1514diff -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
1518 unsigned long i;
1519 pte_t entry;
1520
1521- mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1522+ // mm->rss += (HPAGE_SIZE / PAGE_SIZE);
1523+ vx_rsspages_add(mm, HPAGE_SIZE / PAGE_SIZE);
1524
1525 if (write_access)
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;
1529 dst_pte++;
1530 }
1531- dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1532+ // dst->rss += (HPAGE_SIZE / PAGE_SIZE);
1533+ vx_rsspages_add(dst, HPAGE_SIZE / PAGE_SIZE);
1534 addr += HPAGE_SIZE;
1535 }
1536 return 0;
1537@@ -203,7 +205,8 @@ void unmap_hugepage_range(struct vm_area
1538 pte++;
1539 }
1540 }
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);
1545 }
1546
1547diff -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"
1551
1552 source "fs/Kconfig"
1553
1554+source "kernel/vserver/Kconfig"
1555+
1556 source "security/Kconfig"
1557
1558 source "crypto/Kconfig"
1559diff -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
1562@@ -21,6 +21,8 @@
1563 #include "linux/spinlock.h"
1564 #include "linux/proc_fs.h"
1565 #include "linux/ptrace.h"
1566+#include "linux/vs_cvirt.h"
1567+
1568 #include "asm/unistd.h"
1569 #include "asm/mman.h"
1570 #include "asm/segment.h"
1571diff -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);
1576 if (!child)
1577 goto out;
1578+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1579+ goto out_tsk;
1580
1581 ret = -EPERM;
1582 if (pid == 1) /* you may not mess with init */
1583diff -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;
1591
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,
1600
1601 ARCH_SYSCALLS
1602 [ LAST_SYSCALL + 1 ... NR_syscalls ] =
1603diff -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
1606@@ -15,6 +15,8 @@
1607 #include "linux/unistd.h"
1608 #include "linux/slab.h"
1609 #include "linux/utime.h"
1610+#include <linux/vs_cvirt.h>
1611+
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
1616 if (!name)
1617 return -EFAULT;
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));
1621 up_read(&uts_sem);
1622 return err?-EFAULT:0;
1623 }
1624@@ -232,6 +234,7 @@ long sys_uname(struct old_utsname * name
1625 long sys_olduname(struct oldold_utsname * name)
1626 {
1627 long error;
1628+ struct new_utsname *ptr;
1629
1630 if (!name)
1631 return -EFAULT;
1632@@ -240,19 +243,20 @@ long sys_olduname(struct oldold_utsname
1633
1634 down_read(&uts_sem);
1635
1636- error = __copy_to_user(&name->sysname,&system_utsname.sysname,
1637+ ptr = vx_new_utsname();
1638+ error = __copy_to_user(&name->sysname,ptr->sysname,
1639 __OLD_UTS_LEN);
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,
1643 __OLD_UTS_LEN);
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,
1647 __OLD_UTS_LEN);
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,
1651 __OLD_UTS_LEN);
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,
1655 __OLD_UTS_LEN);
1656 error |= __put_user(0,name->machine+__OLD_UTS_LEN);
1657
1658diff -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"
1662
1663 source "arch/v850/Kconfig.debug"
1664
1665+source "kernel/vserver/Kconfig"
1666+
1667 source "security/Kconfig"
1668
1669 source "crypto/Kconfig"
1670diff -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);
1675 if (!child)
1676 goto out;
1677+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1678+ goto out_tsk;
1679
1680 rval = -EPERM;
1681 if (pid == 1) /* you may not mess with init */
1682diff -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"
1686
1687 source "arch/x86_64/Kconfig.debug"
1688
1689+source "kernel/vserver/Kconfig"
1690+
1691 source "security/Kconfig"
1692
1693 source "crypto/Kconfig"
1694diff -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
1697@@ -25,6 +25,7 @@
1698 #include <linux/binfmts.h>
1699 #include <linux/personality.h>
1700 #include <linux/init.h>
1701+#include <linux/vs_memory.h>
1702
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;
1708
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;
1715diff -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
1719
1720 int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
1721 {
1722- unsigned long stack_base;
1723+ unsigned long stack_base, grow;
1724 struct vm_area_struct *mpnt;
1725 struct mm_struct *mm = current->mm;
1726 int i, ret;
1727@@ -348,7 +348,10 @@ int setup_arg_pages(struct linux_binprm
1728 if (!mpnt)
1729 return -ENOMEM;
1730
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))
1733+ >> PAGE_SHIFT;
1734+ if (security_vm_enough_memory(grow) ||
1735+ !vx_vmpages_avail(mm, grow)) {
1736 kmem_cache_free(vm_area_cachep, mpnt);
1737 return -ENOMEM;
1738 }
1739@@ -373,7 +376,9 @@ int setup_arg_pages(struct linux_binprm
1740 kmem_cache_free(vm_area_cachep, mpnt);
1741 return ret;
1742 }
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;
1747 }
1748
1749 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
1750diff -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 */
1758+ .quad sys_vserver
1759 .quad sys_mbind
1760 .quad compat_sys_get_mempolicy /* 275 */
1761 .quad sys_set_mempolicy
1762diff -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)
1767 {
1768 int error;
1769+ struct new_utsname *ptr;
1770
1771 if (!name)
1772 return -EFAULT;
1773@@ -932,13 +933,14 @@ asmlinkage long sys32_olduname(struct ol
1774
1775 down_read(&uts_sem);
1776
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);
1790 {
1791 char *arch = "x86_64";
1792@@ -961,7 +963,7 @@ long sys32_uname(struct old_utsname __us
1793 if (!name)
1794 return -EFAULT;
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));
1798 up_read(&uts_sem);
1799 if (personality(current->personality) == PER_LINUX32)
1800 err |= copy_to_user(&name->machine, "i686", 5);
1801diff -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);
1806 if (!child)
1807 goto out;
1808+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
1809+ goto out_tsk;
1810
1811 ret = -EPERM;
1812 if (pid == 1) /* you may not mess with init */
1813diff -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
1816@@ -16,6 +16,7 @@
1817 #include <linux/file.h>
1818 #include <linux/utsname.h>
1819 #include <linux/personality.h>
1820+#include <linux/vs_cvirt.h>
1821
1822 #include <asm/uaccess.h>
1823 #include <asm/ipc.h>
1824@@ -146,7 +147,7 @@ asmlinkage long sys_uname(struct new_uts
1825 {
1826 int err;
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));
1830 up_read(&uts_sem);
1831 if (personality(current->personality) == PER_LINUX32)
1832 err |= copy_to_user(&name->machine, "i686", 5);
1833diff -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?
1838 {
1839 int i = 0;
1840- static const int quantum_ms = 1000/HZ;
1841+ static const int quantum_ms = (HZ>1000)?1:(1000/HZ);
1842
1843 ret = down_trylock(sem);
1844 for (i = timeout; (i > 0 && ret < 0); i -= quantum_ms) {
1845diff -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])
1851
1852+#if HZ < 12800
1853 #define SEL_DLY (2*HZ/100)
1854+#else
1855+#define SEL_DLY (255)
1856+#endif
1857
1858 /*
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;
1862 } else {
1863 default_drive_params[i].params.select_delay =
1864- 2 * HZ / 100;
1865+ SEL_DLY;
1866 default_drive_params[i].params.flags &=
1867 ~FD_SILENT_DCL_CLEAR;
1868 }
1869diff -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
1874 go nonzero. */
1875 for (retries = 0;
1876- retries < loops_per_jiffy / (4000/HZ);
1877+ retries < HZ*(loops_per_jiffy >> 3)/500;
1878 retries++)
1879 if (inb_p(dtlk_port_tts) &
1880 TTS_WRITABLE)
1881@@ -445,7 +445,7 @@ for (i = 0; i < 10; i++) \
1882 LOOK
1883 dtlk_write_bytes("\0012I\r", 4);
1884 buffer[b++] = 0;
1885- __delay(50 * loops_per_jiffy / (1000/HZ));
1886+ __delay(50 * (loops_per_jiffy >> 3) * HZ / 125);
1887 outb_p(0xff, dtlk_port_lpc);
1888 buffer[b++] = 0;
1889 LOOK
1890diff -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;
1897+ #if HZ < 2185
1898 info->closing_wait = 30*HZ;
1899+ #else
1900+ info->closing_wait = 65534;
1901+ #endif
1902 init_waitqueue_head(&info->open_wait);
1903 init_waitqueue_head(&info->close_wait);
1904 init_waitqueue_head(&info->status_event_wait_q);
1905diff -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;
1912+ #if HZ < 2185
1913 info->closing_wait = 30*HZ;
1914+ #else
1915+ info->closing_wait = 65534;
1916+ #endif
1917 init_waitqueue_head(&info->open_wait);
1918 init_waitqueue_head(&info->close_wait);
1919 init_waitqueue_head(&info->status_event_wait_q);
1920diff -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;
1927+ #if HZ < 2185
1928 info->closing_wait = 30*HZ;
1929+ #else
1930+ info->closing_wait = 65534;
1931+ #endif
1932 init_waitqueue_head(&info->open_wait);
1933 init_waitqueue_head(&info->close_wait);
1934 init_waitqueue_head(&info->status_event_wait_q);
1935diff -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
1938@@ -102,6 +102,7 @@
1939 #include <linux/vt_kern.h>
1940 #include <linux/selection.h>
1941 #include <linux/devfs_fs_kernel.h>
1942+#include <linux/vs_cvirt.h>
1943
1944 #include <linux/kmod.h>
1945
1946@@ -2092,13 +2093,16 @@ static int tiocsctty(struct tty_struct *
1947
1948 static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
1949 {
1950+ pid_t pgrp;
1951 /*
1952 * (tty == real_tty) is a cheap way of
1953 * testing if the tty is NOT a master pty.
1954 */
1955 if (tty == real_tty && current->signal->tty != real_tty)
1956 return -ENOTTY;
1957- return put_user(real_tty->pgrp, p);
1958+
1959+ pgrp = vx_map_pid(real_tty->pgrp);
1960+ return put_user(pgrp, p);
1961 }
1962
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 *
1965 return -ENOTTY;
1966 if (get_user(pgrp, p))
1967 return -EFAULT;
1968+
1969+ pgrp = vx_rmap_pid(pgrp);
1970 if (pgrp < 0)
1971 return -EINVAL;
1972 if (session_of_pgrp(pgrp) != current->signal->session)
1973diff -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;
1980+ #if HZ < 2185
1981 tmp.close_delay = 5*HZ;
1982 tmp.closing_wait = 30*HZ;
1983+ #else
1984+ tmp.close_delay = 2*HZ;
1985+ tmp.closing_wait = 65534;
1986+ #endif
1987 // tmp.custom_divisor = state->custom_divisor;
1988 // tmp.hub6 = state->hub6;
1989 // tmp.io_type = state->io_type;
1990diff -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
1993@@ -14,6 +14,9 @@
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>
2000
2001 /* Taken over from the old code... */
2002
2003@@ -55,6 +58,28 @@ int inode_change_ok(struct inode *inode,
2004 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
2005 goto error;
2006 }
2007+
2008+ /* Check for evil vserver activity */
2009+ if (vx_check(0, VX_ADMIN))
2010+ goto fine;
2011+
2012+ if (IS_BARRIER(inode)) {
2013+ vxwprintk(1, "xid=%d messing with the barrier.",
2014+ vx_current_xid());
2015+ goto error;
2016+ }
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());
2021+ goto error;
2022+ case DEVPTS_SUPER_MAGIC:
2023+ if (vx_check(inode->i_xid, VX_IDENT))
2024+ goto fine;
2025+ vxwprintk(1, "xid=%d messing with the devpts.",
2026+ vx_current_xid());
2027+ goto error;
2028+ }
2029 fine:
2030 retval = 0;
2031 error:
2032@@ -63,6 +88,24 @@ error:
2033
2034 EXPORT_SYMBOL(inode_change_ok);
2035
2036+int inode_setattr_flags(struct inode *inode, unsigned int flags)
2037+{
2038+ unsigned int oldflags, newflags;
2039+
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;
2048+
2049+ if (oldflags ^ newflags)
2050+ inode->i_flags = newflags;
2051+ return 0;
2052+}
2053+
2054 int inode_setattr(struct inode * inode, struct iattr * attr)
2055 {
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,
2067 mode &= ~S_ISGID;
2068 inode->i_mode = mode;
2069 }
2070+ if (ia_valid & ATTR_ATTR_FLAG)
2071+ inode_setattr_flags(inode, attr->ia_attr_flags);
2072 mark_inode_dirty(inode);
2073 out:
2074 return error;
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);
2086 if (!error) {
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;
2092 if (!error)
2093 error = inode_setattr(inode, attr);
2094diff -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
2097@@ -24,6 +24,7 @@
2098 #include <linux/binfmts.h>
2099 #include <linux/personality.h>
2100 #include <linux/init.h>
2101+#include <linux/vs_memory.h>
2102
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;
2108
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;
2115diff -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
2118@@ -37,6 +37,7 @@
2119 #include <linux/pagemap.h>
2120 #include <linux/security.h>
2121 #include <linux/syscalls.h>
2122+#include <linux/vs_memory.h>
2123
2124 #include <asm/uaccess.h>
2125 #include <asm/param.h>
2126@@ -734,7 +735,8 @@ static int load_elf_binary(struct linux_
2127
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);
2135 if (retval < 0) {
2136diff -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
2139@@ -36,6 +36,7 @@
2140 #include <linux/personality.h>
2141 #include <linux/init.h>
2142 #include <linux/flat.h>
2143+#include <linux/vs_memory.h>
2144
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);
2154 }
2155
2156 if (flags & FLAT_FLAG_KTRACE)
2157diff -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
2160@@ -28,6 +28,7 @@
2161 #include <linux/shm.h>
2162 #include <linux/personality.h>
2163 #include <linux/init.h>
2164+#include <linux/vs_memory.h>
2165
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);
2170
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);
2175
2176 #if 0
2177 printk("(start_brk) %08lx\n" , (unsigned long) current->mm->start_brk);
2178diff -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
2182 NULL
2183 };
2184
2185+static int devpts_permission(struct inode *inode, int mask, struct nameidata *nd)
2186+{
2187+ int ret = -EACCES;
2188+
2189+ if (vx_check(inode->i_xid, VX_IDENT))
2190+ ret = generic_permission(inode, mask, NULL);
2191+ return ret;
2192+}
2193+
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,
2200 #endif
2201+ .permission = devpts_permission,
2202 };
2203
2204 static struct vfsmount *devpts_mnt;
2205@@ -88,6 +98,68 @@ static int devpts_remount(struct super_b
2206 return 0;
2207 }
2208
2209+static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2210+{
2211+ struct dentry *dentry = filp->f_dentry;
2212+ struct dentry *cursor = filp->private_data;
2213+ struct list_head *p, *q = &cursor->d_child;
2214+ ino_t ino;
2215+ int i = filp->f_pos;
2216+
2217+ switch (i) {
2218+ case 0:
2219+ ino = dentry->d_inode->i_ino;
2220+ if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
2221+ break;
2222+ filp->f_pos++;
2223+ i++;
2224+ /* fallthrough */
2225+ case 1:
2226+ ino = parent_ino(dentry);
2227+ if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0)
2228+ break;
2229+ filp->f_pos++;
2230+ i++;
2231+ /* fallthrough */
2232+ default:
2233+ spin_lock(&dcache_lock);
2234+ if (filp->f_pos == 2) {
2235+ list_del(q);
2236+ list_add(q, &dentry->d_subdirs);
2237+ }
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)
2242+ continue;
2243+ if (!vx_check(next->d_inode->i_xid, VX_IDENT))
2244+ continue;
2245+
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)
2250+ return 0;
2251+ spin_lock(&dcache_lock);
2252+ /* next is still alive */
2253+ list_del(q);
2254+ list_add(q, p);
2255+ p = q;
2256+ filp->f_pos++;
2257+ }
2258+ spin_unlock(&dcache_lock);
2259+ }
2260+ return 0;
2261+}
2262+
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,
2269+};
2270+
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;
2280 inode->i_nlink = 2;
2281+ inode->i_xid = vx_current_xid();
2282
2283 devpts_root = s->s_root = d_alloc_root(inode);
2284 if (s->s_root)
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;
2292
2293diff -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
2296@@ -47,6 +47,7 @@
2297 #include <linux/security.h>
2298 #include <linux/syscalls.h>
2299 #include <linux/rmap.h>
2300+#include <linux/vs_memory.h>
2301
2302 #include <asm/uaccess.h>
2303 #include <asm/mmu_context.h>
2304@@ -320,7 +321,8 @@ void install_arg_page(struct vm_area_str
2305 pte_unmap(pte);
2306 goto out;
2307 }
2308- mm->rss++;
2309+ // mm->rss++;
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
2315 if (!mpnt)
2316 return -ENOMEM;
2317
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);
2322 return -ENOMEM;
2323 }
2324@@ -438,7 +441,9 @@ int setup_arg_pages(struct linux_binprm
2325 kmem_cache_free(vm_area_cachep, mpnt);
2326 return ret;
2327 }
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;
2332 }
2333
2334 for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
2335diff -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
2338@@ -16,6 +16,7 @@
2339 #include <linux/quotaops.h>
2340 #include <linux/sched.h>
2341 #include <linux/buffer_head.h>
2342+#include <linux/vs_dlimit.h>
2343
2344 /*
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);
2349
2350+ DLIMIT_ADJUST_BLOCK(sb, vx_current_xid(), &free_blocks, &root_blocks);
2351+
2352 if (free_blocks < count)
2353 count = free_blocks;
2354
2355@@ -258,6 +261,7 @@ do_more:
2356 }
2357 error_return:
2358 brelse(bitmap_bh);
2359+ DLIMIT_FREE_BLOCK(sb, inode->i_xid, freed);
2360 release_blocks(sb, freed);
2361 DQUOT_FREE_BLOCK(inode, freed);
2362 }
2363@@ -361,6 +365,10 @@ int ext2_new_block(struct inode *inode,
2364 *err = -ENOSPC;
2365 goto out_dquot;
2366 }
2367+ if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, es_alloc)) {
2368+ *err = -ENOSPC;
2369+ goto out_dlimit;
2370+ }
2371
2372 ext2_debug ("goal=%lu.\n", goal);
2373
2374@@ -508,6 +516,8 @@ got_block:
2375 *err = 0;
2376 out_release:
2377 group_release_blocks(sb, group_no, desc, gdp_bh, group_alloc);
2378+ DLIMIT_FREE_BLOCK(sb, inode->i_xid, es_alloc);
2379+out_dlimit:
2380 release_blocks(sb, es_alloc);
2381 out_dquot:
2382 DQUOT_FREE_BLOCK(inode, dq_alloc);
2383diff -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
2386@@ -18,6 +18,8 @@
2387 #include <linux/backing-dev.h>
2388 #include <linux/buffer_head.h>
2389 #include <linux/random.h>
2390+#include <linux/vs_dlimit.h>
2391+
2392 #include "ext2.h"
2393 #include "xattr.h"
2394 #include "acl.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);
2401 DQUOT_DROP(inode);
2402 }
2403@@ -465,6 +468,15 @@ struct inode *ext2_new_inode(struct inod
2404 if (!inode)
2405 return ERR_PTR(-ENOMEM);
2406
2407+ if (sb->s_flags & MS_TAGXID)
2408+ inode->i_xid = vx_current_xid();
2409+ else
2410+ inode->i_xid = 0;
2411+
2412+ if (DLIMIT_ALLOC_INODE(sb, inode->i_xid)) {
2413+ err = -ENOSPC;
2414+ goto fail_dlim;
2415+ }
2416 ei = EXT2_I(inode);
2417 sbi = EXT2_SB(sb);
2418 es = sbi->s_es;
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);
2426 if (S_ISLNK(mode))
2427 ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
2428 /* dirsync is only applied to directories */
2429@@ -620,12 +633,15 @@ got:
2430 return inode;
2431
2432 fail2:
2433+ DLIMIT_FREE_INODE(sb, inode->i_xid);
2434 inode->i_flags |= S_NOQUOTA;
2435 inode->i_nlink = 0;
2436 iput(inode);
2437 return ERR_PTR(err);
2438
2439 fail:
2440+ DLIMIT_FREE_INODE(sb, inode->i_xid);
2441+fail_dlim:
2442 make_bad_inode(inode);
2443 iput(inode);
2444 return ERR_PTR(err);
2445diff -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
2448@@ -31,6 +31,7 @@
2449 #include <linux/writeback.h>
2450 #include <linux/buffer_head.h>
2451 #include <linux/mpage.h>
2452+#include <linux/vserver/xid.h>
2453 #include "ext2.h"
2454 #include "acl.h"
2455
2456@@ -52,6 +53,8 @@ static inline int ext2_inode_is_fast_sym
2457 inode->i_blocks - ea_blocks == 0);
2458 }
2459
2460+static void ext2_truncate_nocheck (struct inode * inode);
2461+
2462 /*
2463 * Called at the last iput() if i_nlink is zero.
2464 */
2465@@ -65,7 +68,7 @@ void ext2_delete_inode (struct inode * i
2466
2467 inode->i_size = 0;
2468 if (inode->i_blocks)
2469- ext2_truncate (inode);
2470+ ext2_truncate_nocheck(inode);
2471 ext2_free_inode (inode);
2472
2473 return;
2474@@ -865,7 +868,7 @@ static void ext2_free_branches(struct in
2475 ext2_free_data(inode, p, q);
2476 }
2477
2478-void ext2_truncate (struct inode * inode)
2479+static void ext2_truncate_nocheck(struct inode * inode)
2480 {
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
2484 return;
2485 if (ext2_inode_is_fast_symlink(inode))
2486 return;
2487- if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2488- return;
2489
2490 ext2_discard_prealloc(inode);
2491
2492@@ -1005,17 +1006,28 @@ Egdp:
2493 return ERR_PTR(-EIO);
2494 }
2495
2496+void ext2_truncate (struct inode * inode)
2497+{
2498+ if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2499+ return;
2500+ ext2_truncate_nocheck(inode);
2501+}
2502+
2503 void ext2_set_inode_flags(struct inode *inode)
2504 {
2505 unsigned int flags = EXT2_I(inode)->i_flags;
2506
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);
2526+ uid_t uid;
2527+ gid_t gid;
2528 int n;
2529
2530 #ifdef CONFIG_EXT2_FS_POSIX_ACL
2531@@ -1038,12 +1052,17 @@ void ext2_read_inode (struct inode * ino
2532 goto bad_inode;
2533
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;
2544 }
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));
2549+
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);
2563 int n;
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;
2567 }
2568+#ifdef CONFIG_INOXID_INTERN
2569+ raw_inode->i_raw_xid = cpu_to_le16(inode->i_xid);
2570+#endif
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);
2576 }
2577
2578+int ext2_setattr_flags(struct inode *inode, unsigned int flags)
2579+{
2580+ unsigned int oldflags, newflags;
2581+
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;
2591+
2592+ if (oldflags ^ newflags) {
2593+ EXT2_I(inode)->i_flags = newflags;
2594+ inode->i_ctime = CURRENT_TIME;
2595+ }
2596+ return 0;
2597+}
2598+
2599 int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
2600 {
2601 struct inode *inode = dentry->d_inode;
2602@@ -1258,11 +1301,15 @@ int ext2_setattr(struct dentry *dentry,
2603 if (error)
2604 return error;
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;
2610 if (error)
2611 return error;
2612 }
2613+ if (iattr->ia_valid & ATTR_ATTR_FLAG)
2614+ ext2_setattr_flags(inode, iattr->ia_attr_flags);
2615+
2616 error = inode_setattr(inode, iattr);
2617 if (!error && (iattr->ia_valid & ATTR_MODE))
2618 error = ext2_acl_chmod(inode);
2619diff -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
2623 *
2624 * This test looks nicer. Thanks to Pauline Middelink
2625 */
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))
2631 return -EPERM;
2632 }
2633diff -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
2636@@ -31,6 +31,7 @@
2637 */
2638
2639 #include <linux/pagemap.h>
2640+#include <linux/vserver/xid.h>
2641 #include "ext2.h"
2642 #include "xattr.h"
2643 #include "acl.h"
2644@@ -81,6 +82,7 @@ static struct dentry *ext2_lookup(struct
2645 inode = iget(dir->i_sb, ino);
2646 if (!inode)
2647 return ERR_PTR(-EACCES);
2648+ vx_propagate_xid(nd, inode);
2649 }
2650 if (inode)
2651 return d_splice_alias(inode, dentry);
2652diff -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,
2662 };
2663
2664@@ -279,6 +279,7 @@ static match_table_t tokens = {
2665 {Opt_nouser_xattr, "nouser_xattr"},
2666 {Opt_acl, "acl"},
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
2673 case Opt_nouid32:
2674 set_opt (sbi->s_mount_opt, NO_UID32);
2675 break;
2676+#ifndef CONFIG_INOXID_NONE
2677+ case Opt_tagxid:
2678+ set_opt (sbi->s_mount_opt, TAG_XID);
2679+ break;
2680+#endif
2681 case Opt_check:
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))
2686 goto failed_mount;
2687
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) ?
2692 MS_POSIXACL : 0);
2693diff -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
2696@@ -60,6 +60,7 @@
2697 #include <linux/mbcache.h>
2698 #include <linux/quotaops.h>
2699 #include <linux/rwsem.h>
2700+#include <linux/vs_dlimit.h>
2701 #include "ext2.h"
2702 #include "xattr.h"
2703 #include "acl.h"
2704@@ -643,8 +644,12 @@ ext2_xattr_set2(struct inode *inode, str
2705 the inode. */
2706 ea_bdebug(new_bh, "reusing block");
2707
2708+ error = -ENOSPC;
2709+ if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, 1))
2710+ goto cleanup;
2711 error = -EDQUOT;
2712 if (DQUOT_ALLOC_BLOCK(inode, 1)) {
2713+ DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
2714 unlock_buffer(new_bh);
2715 goto cleanup;
2716 }
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);
2727 if (IS_SYNC(inode))
2728 sync_dirty_buffer(bh);
2729+ DLIMIT_FREE_BLOCK(inode->i_sb, inode->i_xid, 1);
2730 DQUOT_FREE_BLOCK(inode, 1);
2731 }
2732 ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
2733diff -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
2736@@ -19,6 +19,7 @@
2737 #include <linux/ext3_jbd.h>
2738 #include <linux/quotaops.h>
2739 #include <linux/buffer_head.h>
2740+#include <linux/vs_dlimit.h>
2741
2742 /*
2743 * balloc.c contains the blocks allocation and deallocation routines
2744@@ -462,8 +463,10 @@ void ext3_free_blocks(handle_t *handle,
2745 return;
2746 }
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);
2752+ }
2753 return;
2754 }
2755
2756@@ -1091,18 +1094,32 @@ out:
2757 return ret;
2758 }
2759
2760-static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
2761+static int ext3_has_free_blocks(struct super_block *sb)
2762 {
2763- int free_blocks, root_blocks;
2764+ struct ext3_sb_info *sbi = EXT3_SB(sb);
2765+ int free_blocks, root_blocks, cond;
2766
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) &&
2770+
2771+ vxdprintk(VXD_CBIT(dlim, 3),
2772+ "ext3_has_free_blocks(%p): free=%u, root=%u",
2773+ sb, free_blocks, root_blocks);
2774+
2775+ DLIMIT_ADJUST_BLOCK(sb, vx_current_xid(), &free_blocks, &root_blocks);
2776+
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))) {
2781- return 0;
2782- }
2783- return 1;
2784+ (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)));
2785+
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);
2791+
2792+ return (cond ? 0 : 1);
2793 }
2794
2795 /*
2796@@ -1113,7 +1130,7 @@ static int ext3_has_free_blocks(struct e
2797 */
2798 int ext3_should_retry_alloc(struct super_block *sb, int *retries)
2799 {
2800- if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3)
2801+ if (!ext3_has_free_blocks(sb) || (*retries)++ > 3)
2802 return 0;
2803
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
2806 *errp = -EDQUOT;
2807 return 0;
2808 }
2809+ if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, 1))
2810+ goto out_dlimit;
2811
2812 sbi = EXT3_SB(sb);
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))
2817 my_rsv = rsv;
2818- if (!ext3_has_free_blocks(sbi)) {
2819+ if (!ext3_has_free_blocks(sb)) {
2820 *errp = -ENOSPC;
2821 goto out;
2822 }
2823@@ -1360,6 +1379,9 @@ allocated:
2824 io_error:
2825 *errp = -EIO;
2826 out:
2827+ if (!performed_allocation)
2828+ DLIMIT_FREE_BLOCK(sb, inode->i_xid, 1);
2829+out_dlimit:
2830 if (fatal) {
2831 *errp = fatal;
2832 ext3_std_error(sb, fatal);
2833diff -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
2836@@ -23,6 +23,7 @@
2837 #include <linux/buffer_head.h>
2838 #include <linux/random.h>
2839 #include <linux/bitops.h>
2840+#include <linux/vs_dlimit.h>
2841
2842 #include <asm/byteorder.h>
2843
2844@@ -125,6 +126,7 @@ void ext3_free_inode (handle_t *handle,
2845 */
2846 DQUOT_INIT(inode);
2847 ext3_xattr_delete_inode(handle, inode);
2848+ DLIMIT_FREE_INODE(sb, inode->i_xid);
2849 DQUOT_FREE_INODE(inode);
2850 DQUOT_DROP(inode);
2851
2852@@ -443,6 +445,16 @@ struct inode *ext3_new_inode(handle_t *h
2853 inode = new_inode(sb);
2854 if (!inode)
2855 return ERR_PTR(-ENOMEM);
2856+
2857+ if (sb->s_flags & MS_TAGXID)
2858+ inode->i_xid = vx_current_xid();
2859+ else
2860+ inode->i_xid = 0;
2861+
2862+ if (DLIMIT_ALLOC_INODE(sb, inode->i_xid)) {
2863+ err = -ENOSPC;
2864+ goto out;
2865+ }
2866 ei = EXT3_I(inode);
2867
2868 sbi = EXT3_SB(sb);
2869@@ -566,7 +578,8 @@ got:
2870 ei->i_dir_start_lookup = 0;
2871 ei->i_disksize = 0;
2872
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);
2876 if (S_ISLNK(mode))
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);
2881 goto really_out;
2882 fail:
2883+ DLIMIT_FREE_INODE(sb, inode->i_xid);
2884 ext3_std_error(sb, err);
2885 out:
2886 iput(inode);
2887@@ -627,6 +641,7 @@ really_out:
2888 return ret;
2889
2890 fail2:
2891+ DLIMIT_FREE_INODE(sb, inode->i_xid);
2892 inode->i_flags |= S_NOQUOTA;
2893 inode->i_nlink = 0;
2894 iput(inode);
2895diff -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
2898@@ -36,6 +36,7 @@
2899 #include <linux/writeback.h>
2900 #include <linux/mpage.h>
2901 #include <linux/uio.h>
2902+#include <linux/vserver/xid.h>
2903 #include "xattr.h"
2904 #include "acl.h"
2905
2906@@ -178,6 +179,8 @@ static int ext3_journal_test_restart(han
2907 return ext3_journal_restart(handle, blocks_for_truncate(inode));
2908 }
2909
2910+static void ext3_truncate_nocheck (struct inode *inode);
2911+
2912 /*
2913 * Called at the last iput() if i_nlink is zero.
2914 */
2915@@ -201,7 +204,7 @@ void ext3_delete_inode (struct inode * i
2916 handle->h_sync = 1;
2917 inode->i_size = 0;
2918 if (inode->i_blocks)
2919- ext3_truncate(inode);
2920+ ext3_truncate_nocheck(inode);
2921 /*
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.
2926 */
2927
2928-void ext3_truncate(struct inode * inode)
2929+void ext3_truncate_nocheck(struct inode * inode)
2930 {
2931 handle_t *handle;
2932 struct ext3_inode_info *ei = EXT3_I(inode);
2933@@ -2069,8 +2072,6 @@ void ext3_truncate(struct inode * inode)
2934 return;
2935 if (ext3_inode_is_fast_symlink(inode))
2936 return;
2937- if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2938- return;
2939
2940 ext3_discard_reservation(inode);
2941
2942@@ -2380,17 +2381,28 @@ has_buffer:
2943 return 0;
2944 }
2945
2946+void ext3_truncate(struct inode * inode)
2947+{
2948+ if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2949+ return;
2950+ ext3_truncate_nocheck(inode);
2951+}
2952+
2953 void ext3_set_inode_flags(struct inode *inode)
2954 {
2955 unsigned int flags = EXT3_I(inode)->i_flags;
2956
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;
2975 int block;
2976+ uid_t uid;
2977+ gid_t gid;
2978
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
2982 bh = iloc.bh;
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;
2994 }
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));
2999+
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;
3010
3011 /* For fields not not tracking in the in-memory inode,
3012@@ -2538,29 +2559,32 @@ static int ext3_do_update_inode(handle_t
3013
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));
3020 /*
3021 * Fix up interoperability with old kernels. Otherwise, old inodes get
3022 * re-used with the upper 16 bits of the uid/gid intact
3023 */
3024 if(!ei->i_dtime) {
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));
3031 } else {
3032 raw_inode->i_uid_high = 0;
3033 raw_inode->i_gid_high = 0;
3034 }
3035 } else {
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;
3044 }
3045+#ifdef CONFIG_INOXID_INTERN
3046+ raw_inode->i_raw_xid = cpu_to_le16(inode->i_xid);
3047+#endif
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);
3053 }
3054
3055+int ext3_setattr_flags(struct inode *inode, unsigned int flags)
3056+{
3057+ unsigned int oldflags, newflags;
3058+ int err = 0;
3059+
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;
3069+
3070+ if (oldflags ^ newflags) {
3071+ handle_t *handle;
3072+ struct ext3_iloc iloc;
3073+
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);
3080+ if (err)
3081+ goto flags_err;
3082+
3083+ EXT3_I(inode)->i_flags = newflags;
3084+ inode->i_ctime = CURRENT_TIME;
3085+
3086+ err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3087+ flags_err:
3088+ ext3_journal_stop(handle);
3089+ }
3090+ return err;
3091+}
3092+
3093 /*
3094 * ext3_setattr()
3095 *
3096@@ -2710,7 +2772,8 @@ int ext3_setattr(struct dentry *dentry,
3097 return error;
3098
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)) {
3103 handle_t *handle;
3104
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)
3111+ && inode->i_sb
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);
3116 }
3117@@ -2753,6 +2820,12 @@ int ext3_setattr(struct dentry *dentry,
3118 ext3_journal_stop(handle);
3119 }
3120
3121+ if (ia_valid & ATTR_ATTR_FLAG) {
3122+ rc = ext3_setattr_flags(inode, attr->ia_attr_flags);
3123+ if (!error)
3124+ error = rc;
3125+ }
3126+
3127 rc = inode_setattr(inode, attr);
3128
3129 /* If inode_setattr's call to ext3_truncate failed to get a
3130diff -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
3133@@ -12,6 +12,7 @@
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>
3139
3140
3141@@ -58,7 +59,9 @@ int ext3_ioctl (struct inode * inode, st
3142 *
3143 * This test looks nicer. Thanks to Pauline Middelink
3144 */
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))
3150 return -EPERM;
3151 }
3152@@ -219,6 +222,38 @@ flags_err:
3153 return err;
3154 }
3155
3156+#if defined(CONFIG_VSERVER_LEGACY) && !defined(CONFIG_INOXID_NONE)
3157+ case EXT3_IOC_SETXID: {
3158+ handle_t *handle;
3159+ struct ext3_iloc iloc;
3160+ int xid;
3161+ int err;
3162+
3163+ /* fixme: if stealth, return -ENOTTY */
3164+ if (!capable(CAP_CONTEXT))
3165+ return -EPERM;
3166+ if (IS_RDONLY(inode))
3167+ return -EROFS;
3168+ if (!(inode->i_sb->s_flags & MS_TAGXID))
3169+ return -ENOSYS;
3170+ if (get_user(xid, (int *) arg))
3171+ return -EFAULT;
3172+
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);
3177+ if (err)
3178+ return err;
3179+
3180+ inode->i_xid = (xid & 0xFFFF);
3181+ inode->i_ctime = CURRENT_TIME;
3182+
3183+ err = ext3_mark_iloc_dirty(handle, inode, &iloc);
3184+ ext3_journal_stop(handle);
3185+ return err;
3186+ }
3187+#endif
3188
3189 default:
3190 return -ENOTTY;
3191diff -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
3194@@ -36,6 +36,7 @@
3195 #include <linux/quotaops.h>
3196 #include <linux/buffer_head.h>
3197 #include <linux/smp_lock.h>
3198+#include <linux/vserver/xid.h>
3199 #include "xattr.h"
3200 #include "acl.h"
3201
3202@@ -989,6 +990,7 @@ static struct dentry *ext3_lookup(struct
3203
3204 if (!inode)
3205 return ERR_PTR(-EACCES);
3206+ vx_propagate_xid(nd, inode);
3207 }
3208 if (inode)
3209 return d_splice_alias(inode, dentry);
3210diff -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,
3219 };
3220
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
3231 case Opt_nouid32:
3232 set_opt (sbi->s_mount_opt, NO_UID32);
3233 break;
3234+#ifndef CONFIG_INOXID_NONE
3235+ case Opt_tagxid:
3236+ if (is_remount) {
3237+ printk(KERN_ERR "EXT3-fs: cannot specify "
3238+ "tagxid on remount\n");
3239+ return 0;
3240+ }
3241+ set_opt (sbi->s_mount_opt, TAG_XID);
3242+ break;
3243+#endif
3244 case Opt_check:
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))
3249 goto failed_mount;
3250
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);
3256diff -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
3259@@ -61,6 +61,7 @@
3260 #include <linux/mbcache.h>
3261 #include <linux/quotaops.h>
3262 #include <linux/rwsem.h>
3263+#include <linux/vs_dlimit.h>
3264 #include "xattr.h"
3265 #include "acl.h"
3266
3267@@ -661,8 +662,12 @@ ext3_xattr_set_handle2(handle_t *handle,
3268 the inode. */
3269 ea_bdebug(new_bh, "reusing block");
3270
3271+ error = -ENOSPC;
3272+ if (DLIMIT_ALLOC_BLOCK(sb, inode->i_xid, 1))
3273+ goto cleanup;
3274 error = -EDQUOT;
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,
3279 credits);
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);
3290 if (IS_SYNC(inode))
3291 handle->h_sync = 1;
3292+ DLIMIT_FREE_BLOCK(inode->i_sb, inode->i_xid, 1);
3293 DQUOT_FREE_BLOCK(inode, 1);
3294 }
3295 ea_bdebug(bh, "refcount now=%d", le32_to_cpu(HDR(bh)->h_refcount) - 1);
3296diff -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
3299@@ -15,6 +15,7 @@
3300 #include <linux/module.h>
3301 #include <linux/security.h>
3302 #include <linux/ptrace.h>
3303+#include <linux/vs_limit.h>
3304
3305 #include <asm/poll.h>
3306 #include <asm/siginfo.h>
3307@@ -108,6 +109,8 @@ repeat:
3308 error = -EMFILE;
3309 if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
3310 goto out;
3311+ if (!vx_files_avail(1))
3312+ goto out;
3313
3314 error = expand_files(files, newfd);
3315 if (error < 0)
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);
3322 } else {
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);
3329
3330 if (tofree)
3331 filp_close(tofree, files);
3332@@ -489,7 +494,7 @@ void send_sigio(struct fown_struct *fown
3333
3334 read_lock(&tasklist_lock);
3335 if (pid > 0) {
3336- p = find_task_by_pid(pid);
3337+ p = find_task_by_real_pid(pid);
3338 if (p) {
3339 send_sigio_to_task(p, fown, fd, band);
3340 }
3341@@ -524,7 +529,7 @@ int send_sigurg(struct fown_struct *fown
3342
3343 read_lock(&tasklist_lock);
3344 if (pid > 0) {
3345- p = find_task_by_pid(pid);
3346+ p = find_task_by_real_pid(pid);
3347 if (p) {
3348 send_sigurg_to_task(p, fown);
3349 }
3350diff -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
3353@@ -16,6 +16,8 @@
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>
3359
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();
3368+ vx_files_inc(f);
3369 return f;
3370 }
3371 }
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);
3377+ file->f_xid = 0;
3378 file_kill(file);
3379 file->f_dentry = NULL;
3380 file->f_vfsmnt = NULL;
3381@@ -192,6 +199,8 @@ void put_filp(struct file *file)
3382 {
3383 if (atomic_dec_and_test(&file->f_count)) {
3384 security_file_free(file);
3385+ vx_files_dec(file);
3386+ file->f_xid = 0;
3387 file_kill(file);
3388 file_free(file);
3389 }
3390diff -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;
3395
3396 inode->i_sb = sb;
3397+ // inode->i_dqh = dqhget(sb->s_dqh);
3398+
3399+ /* essential because of inode slab reuse */
3400+ inode->i_xid = 0;
3401 inode->i_blkbits = sb->s_blocksize_bits;
3402 inode->i_flags = 0;
3403 atomic_set(&inode->i_count, 1);
3404diff -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
3407@@ -12,10 +12,18 @@
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>
3414
3415 #include <asm/uaccess.h>
3416 #include <asm/ioctls.h>
3417
3418+#ifdef CONFIG_VSERVER_LEGACY
3419+extern int vx_proc_ioctl(struct inode *, struct file *,
3420+ unsigned int, unsigned long);
3421+#endif
3422+
3423 static int file_ioctl(struct file *filp,unsigned int cmd,unsigned long arg)
3424 {
3425 int error;
3426@@ -123,6 +131,48 @@ asmlinkage long sys_ioctl(unsigned int f
3427 else
3428 error = -ENOTTY;
3429 break;
3430+#ifdef CONFIG_VSERVER_LEGACY
3431+#ifndef CONFIG_INOXID_NONE
3432+ case FIOC_GETXID: {
3433+ struct inode *inode = filp->f_dentry->d_inode;
3434+
3435+ /* fixme: if stealth, return -ENOTTY */
3436+ error = -EPERM;
3437+ if (capable(CAP_CONTEXT))
3438+ error = put_user(inode->i_xid, (int *) arg);
3439+ break;
3440+ }
3441+ case FIOC_SETXID: {
3442+ struct inode *inode = filp->f_dentry->d_inode;
3443+ int xid;
3444+
3445+ /* fixme: if stealth, return -ENOTTY */
3446+ error = -EPERM;
3447+ if (!capable(CAP_CONTEXT))
3448+ break;
3449+ error = -EROFS;
3450+ if (IS_RDONLY(inode))
3451+ break;
3452+ error = -ENOSYS;
3453+ if (!(inode->i_sb->s_flags & MS_TAGXID))
3454+ break;
3455+ error = -EFAULT;
3456+ if (get_user(xid, (int *) arg))
3457+ break;
3458+ error = 0;
3459+ inode->i_xid = (xid & 0xFFFF);
3460+ inode->i_ctime = CURRENT_TIME;
3461+ mark_inode_dirty(inode);
3462+ break;
3463+ }
3464+#endif
3465+ case FIOC_GETXFLG:
3466+ case FIOC_SETXFLG:
3467+ error = -ENOTTY;
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);
3470+ break;
3471+#endif
3472 default:
3473 error = -ENOTTY;
3474 if (S_ISREG(filp->f_dentry->d_inode->i_mode))
3475diff -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
3478@@ -45,6 +45,7 @@
3479 #include <linux/buffer_head.h>
3480 #include <linux/pagemap.h>
3481 #include <linux/quotaops.h>
3482+#include <linux/vserver/xid.h>
3483
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)
3488 {
3489 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3490+ uid_t uid;
3491+ gid_t gid;
3492
3493 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3494 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3495
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);
3500+
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);
3506+
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)
3512 {
3513 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3514+ uid_t uid;
3515+ gid_t gid;
3516
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);
3525+
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);
3530 /*
3531 * mode2 is only needed for storing the higher order bits.
3532 * Trust i_mode for the lower order ones
3533diff -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
3536@@ -28,6 +28,10 @@
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>
3543+
3544 #include <asm/namei.h>
3545 #include <asm/uaccess.h>
3546
3547@@ -224,6 +228,24 @@ int generic_permission(struct inode *ino
3548 return -EACCES;
3549 }
3550
3551+static inline int xid_permission(struct inode *inode, int mask, struct nameidata *nd)
3552+{
3553+ if (IS_BARRIER(inode) && !vx_check(0, VX_ADMIN)) {
3554+ vxwprintk(1, "xid=%d did hit the barrier.",
3555+ vx_current_xid());
3556+ return -EACCES;
3557+ }
3558+ if (inode->i_xid == 0)
3559+ return 0;
3560+ if (vx_check(inode->i_xid, VX_ADMIN|VX_WATCH|VX_IDENT))
3561+ return 0;
3562+
3563