]> git.pld-linux.org Git - packages/kernel.git/blob - kernel-vserver-2.3.patch
04a364ca397b2b2eeea740a217c36c5e6f1ee774
[packages/kernel.git] / kernel-vserver-2.3.patch
1 diff -NurpP --minimal linux-2.6.35/arch/alpha/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/alpha/Kconfig
2 --- linux-2.6.35/arch/alpha/Kconfig     2010-08-02 16:51:53.000000000 +0200
3 +++ linux-2.6.35-vs2.3.0.36.31/arch/alpha/Kconfig       2010-08-02 17:05:05.000000000 +0200
4 @@ -681,6 +681,8 @@ config DUMMY_CONSOLE
5         depends on VGA_HOSE
6         default y
7  
8 +source "kernel/vserver/Kconfig"
9 +
10  source "security/Kconfig"
11  
12  source "crypto/Kconfig"
13 diff -NurpP --minimal linux-2.6.35/arch/alpha/kernel/entry.S linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/entry.S
14 --- linux-2.6.35/arch/alpha/kernel/entry.S      2009-06-11 17:11:46.000000000 +0200
15 +++ linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/entry.S        2010-08-02 17:05:05.000000000 +0200
16 @@ -874,24 +874,15 @@ sys_getxgid:
17         .globl  sys_getxpid
18         .ent    sys_getxpid
19  sys_getxpid:
20 +       lda     $sp, -16($sp)
21 +       stq     $26, 0($sp)
22         .prologue 0
23 -       ldq     $2, TI_TASK($8)
24  
25 -       /* See linux/kernel/timer.c sys_getppid for discussion
26 -          about this loop.  */
27 -       ldq     $3, TASK_GROUP_LEADER($2)
28 -       ldq     $4, TASK_REAL_PARENT($3)
29 -       ldl     $0, TASK_TGID($2)
30 -1:     ldl     $1, TASK_TGID($4)
31 -#ifdef CONFIG_SMP
32 -       mov     $4, $5
33 -       mb
34 -       ldq     $3, TASK_GROUP_LEADER($2)
35 -       ldq     $4, TASK_REAL_PARENT($3)
36 -       cmpeq   $4, $5, $5
37 -       beq     $5, 1b
38 -#endif
39 -       stq     $1, 80($sp)
40 +       lda     $16, 96($sp)
41 +       jsr     $26, do_getxpid
42 +       ldq     $26, 0($sp)
43 +
44 +       lda     $sp, 16($sp)
45         ret
46  .end sys_getxpid
47  
48 diff -NurpP --minimal linux-2.6.35/arch/alpha/kernel/osf_sys.c linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.35/arch/alpha/kernel/osf_sys.c    2010-07-07 18:30:51.000000000 +0200
50 +++ linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/osf_sys.c      2010-08-02 17:05:05.000000000 +0200
51 @@ -866,7 +866,7 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct
52  {
53         if (tv) {
54                 struct timeval ktv;
55 -               do_gettimeofday(&ktv);
56 +               vx_gettimeofday(&ktv);
57                 if (put_tv32(tv, &ktv))
58                         return -EFAULT;
59         }
60 diff -NurpP --minimal linux-2.6.35/arch/alpha/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.35/arch/alpha/kernel/ptrace.c     2010-07-07 18:30:51.000000000 +0200
62 +++ linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/ptrace.c       2010-08-02 17:05:05.000000000 +0200
63 @@ -13,6 +13,7 @@
64  #include <linux/user.h>
65  #include <linux/security.h>
66  #include <linux/signal.h>
67 +#include <linux/vs_base.h>
68  
69  #include <asm/uaccess.h>
70  #include <asm/pgtable.h>
71 diff -NurpP --minimal linux-2.6.35/arch/alpha/kernel/systbls.S linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/systbls.S
72 --- linux-2.6.35/arch/alpha/kernel/systbls.S    2010-02-25 11:51:19.000000000 +0100
73 +++ linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/systbls.S      2010-08-02 17:05:05.000000000 +0200
74 @@ -446,7 +446,7 @@ sys_call_table:
75         .quad sys_stat64                        /* 425 */
76         .quad sys_lstat64
77         .quad sys_fstat64
78 -       .quad sys_ni_syscall                    /* sys_vserver */
79 +       .quad sys_vserver                       /* sys_vserver */
80         .quad sys_ni_syscall                    /* sys_mbind */
81         .quad sys_ni_syscall                    /* sys_get_mempolicy */
82         .quad sys_ni_syscall                    /* sys_set_mempolicy */
83 diff -NurpP --minimal linux-2.6.35/arch/alpha/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/traps.c
84 --- linux-2.6.35/arch/alpha/kernel/traps.c      2010-07-07 18:30:51.000000000 +0200
85 +++ linux-2.6.35-vs2.3.0.36.31/arch/alpha/kernel/traps.c        2010-08-02 17:05:05.000000000 +0200
86 @@ -184,7 +184,8 @@ die_if_kernel(char * str, struct pt_regs
87  #ifdef CONFIG_SMP
88         printk("CPU %d ", hard_smp_processor_id());
89  #endif
90 -       printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
91 +       printk("%s(%d[#%u]): %s %ld\n", current->comm,
92 +               task_pid_nr(current), current->xid, str, err);
93         dik_show_regs(regs, r9_15);
94         add_taint(TAINT_DIE);
95         dik_show_trace((unsigned long *)(regs+1));
96 diff -NurpP --minimal linux-2.6.35/arch/arm/include/asm/tlb.h linux-2.6.35-vs2.3.0.36.31/arch/arm/include/asm/tlb.h
97 --- linux-2.6.35/arch/arm/include/asm/tlb.h     2009-09-10 15:25:15.000000000 +0200
98 +++ linux-2.6.35-vs2.3.0.36.31/arch/arm/include/asm/tlb.h       2010-08-02 17:05:05.000000000 +0200
99 @@ -27,6 +27,7 @@
100  
101  #else /* !CONFIG_MMU */
102  
103 +#include <linux/vs_memory.h>
104  #include <asm/pgalloc.h>
105  
106  /*
107 diff -NurpP --minimal linux-2.6.35/arch/arm/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/arm/Kconfig
108 --- linux-2.6.35/arch/arm/Kconfig       2010-08-02 16:51:53.000000000 +0200
109 +++ linux-2.6.35-vs2.3.0.36.31/arch/arm/Kconfig 2010-08-02 17:05:05.000000000 +0200
110 @@ -1673,6 +1673,8 @@ source "fs/Kconfig"
111  
112  source "arch/arm/Kconfig.debug"
113  
114 +source "kernel/vserver/Kconfig"
115 +
116  source "security/Kconfig"
117  
118  source "crypto/Kconfig"
119 diff -NurpP --minimal linux-2.6.35/arch/arm/kernel/calls.S linux-2.6.35-vs2.3.0.36.31/arch/arm/kernel/calls.S
120 --- linux-2.6.35/arch/arm/kernel/calls.S        2010-07-07 18:30:52.000000000 +0200
121 +++ linux-2.6.35-vs2.3.0.36.31/arch/arm/kernel/calls.S  2010-08-02 17:05:05.000000000 +0200
122 @@ -322,7 +322,7 @@
123  /* 310 */      CALL(sys_request_key)
124                 CALL(sys_keyctl)
125                 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
126 -/* vserver */  CALL(sys_ni_syscall)
127 +               CALL(sys_vserver)
128                 CALL(sys_ioprio_set)
129  /* 315 */      CALL(sys_ioprio_get)
130                 CALL(sys_inotify_init)
131 diff -NurpP --minimal linux-2.6.35/arch/arm/kernel/process.c linux-2.6.35-vs2.3.0.36.31/arch/arm/kernel/process.c
132 --- linux-2.6.35/arch/arm/kernel/process.c      2010-08-02 16:51:55.000000000 +0200
133 +++ linux-2.6.35-vs2.3.0.36.31/arch/arm/kernel/process.c        2010-08-02 17:05:05.000000000 +0200
134 @@ -269,7 +269,8 @@ void __show_regs(struct pt_regs *regs)
135  void show_regs(struct pt_regs * regs)
136  {
137         printk("\n");
138 -       printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
139 +       printk("Pid: %d[#%u], comm: %20s\n",
140 +               task_pid_nr(current), current->xid, current->comm);
141         __show_regs(regs);
142         __backtrace();
143  }
144 diff -NurpP --minimal linux-2.6.35/arch/arm/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/arm/kernel/traps.c
145 --- linux-2.6.35/arch/arm/kernel/traps.c        2010-07-07 18:30:52.000000000 +0200
146 +++ linux-2.6.35-vs2.3.0.36.31/arch/arm/kernel/traps.c  2010-08-02 17:05:05.000000000 +0200
147 @@ -243,8 +243,8 @@ static int __die(const char *str, int er
148  
149         print_modules();
150         __show_regs(regs);
151 -       printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
152 -               TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
153 +       printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
154 +               TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
155  
156         if (!user_mode(regs) || in_interrupt()) {
157                 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
158 diff -NurpP --minimal linux-2.6.35/arch/avr32/mm/fault.c linux-2.6.35-vs2.3.0.36.31/arch/avr32/mm/fault.c
159 --- linux-2.6.35/arch/avr32/mm/fault.c  2009-09-10 15:25:20.000000000 +0200
160 +++ linux-2.6.35-vs2.3.0.36.31/arch/avr32/mm/fault.c    2010-08-02 17:05:05.000000000 +0200
161 @@ -216,7 +216,8 @@ out_of_memory:
162                 down_read(&mm->mmap_sem);
163                 goto survive;
164         }
165 -       printk("VM: Killing process %s\n", tsk->comm);
166 +       printk("VM: Killing process %s(%d:#%u)\n",
167 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
168         if (user_mode(regs))
169                 do_group_exit(SIGKILL);
170         goto no_context;
171 diff -NurpP --minimal linux-2.6.35/arch/cris/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/cris/Kconfig
172 --- linux-2.6.35/arch/cris/Kconfig      2010-08-02 16:52:03.000000000 +0200
173 +++ linux-2.6.35-vs2.3.0.36.31/arch/cris/Kconfig        2010-08-02 17:05:05.000000000 +0200
174 @@ -694,6 +694,8 @@ source "drivers/staging/Kconfig"
175  
176  source "arch/cris/Kconfig.debug"
177  
178 +source "kernel/vserver/Kconfig"
179 +
180  source "security/Kconfig"
181  
182  source "crypto/Kconfig"
183 diff -NurpP --minimal linux-2.6.35/arch/cris/mm/fault.c linux-2.6.35-vs2.3.0.36.31/arch/cris/mm/fault.c
184 --- linux-2.6.35/arch/cris/mm/fault.c   2010-02-25 11:51:26.000000000 +0100
185 +++ linux-2.6.35-vs2.3.0.36.31/arch/cris/mm/fault.c     2010-08-02 17:05:05.000000000 +0200
186 @@ -245,7 +245,8 @@ do_page_fault(unsigned long address, str
187  
188   out_of_memory:
189         up_read(&mm->mmap_sem);
190 -       printk("VM: killing process %s\n", tsk->comm);
191 +       printk("VM: killing process %s(%d:#%u)\n",
192 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
193         if (user_mode(regs))
194                 do_exit(SIGKILL);
195         goto no_context;
196 diff -NurpP --minimal linux-2.6.35/arch/frv/kernel/kernel_thread.S linux-2.6.35-vs2.3.0.36.31/arch/frv/kernel/kernel_thread.S
197 --- linux-2.6.35/arch/frv/kernel/kernel_thread.S        2008-12-25 00:26:37.000000000 +0100
198 +++ linux-2.6.35-vs2.3.0.36.31/arch/frv/kernel/kernel_thread.S  2010-08-02 17:05:05.000000000 +0200
199 @@ -37,7 +37,7 @@ kernel_thread:
200  
201         # start by forking the current process, but with shared VM
202         setlos.p        #__NR_clone,gr7         ; syscall number
203 -       ori             gr10,#CLONE_VM,gr8      ; first syscall arg     [clone_flags]
204 +       ori             gr10,#CLONE_KT,gr8      ; first syscall arg     [clone_flags]
205         sethi.p         #0xe4e4,gr9             ; second syscall arg    [newsp]
206         setlo           #0xe4e4,gr9
207         setlos.p        #0,gr10                 ; third syscall arg     [parent_tidptr]
208 diff -NurpP --minimal linux-2.6.35/arch/h8300/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/h8300/Kconfig
209 --- linux-2.6.35/arch/h8300/Kconfig     2010-02-25 11:51:26.000000000 +0100
210 +++ linux-2.6.35-vs2.3.0.36.31/arch/h8300/Kconfig       2010-08-02 17:05:05.000000000 +0200
211 @@ -230,6 +230,8 @@ source "fs/Kconfig"
212  
213  source "arch/h8300/Kconfig.debug"
214  
215 +source "kernel/vserver/Kconfig"
216 +
217  source "security/Kconfig"
218  
219  source "crypto/Kconfig"
220 diff -NurpP --minimal linux-2.6.35/arch/ia64/include/asm/tlb.h linux-2.6.35-vs2.3.0.36.31/arch/ia64/include/asm/tlb.h
221 --- linux-2.6.35/arch/ia64/include/asm/tlb.h    2010-02-25 11:51:26.000000000 +0100
222 +++ linux-2.6.35-vs2.3.0.36.31/arch/ia64/include/asm/tlb.h      2010-08-02 17:05:05.000000000 +0200
223 @@ -40,6 +40,7 @@
224  #include <linux/mm.h>
225  #include <linux/pagemap.h>
226  #include <linux/swap.h>
227 +#include <linux/vs_memory.h>
228  
229  #include <asm/pgalloc.h>
230  #include <asm/processor.h>
231 diff -NurpP --minimal linux-2.6.35/arch/ia64/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/ia64/Kconfig
232 --- linux-2.6.35/arch/ia64/Kconfig      2010-08-02 16:52:03.000000000 +0200
233 +++ linux-2.6.35-vs2.3.0.36.31/arch/ia64/Kconfig        2010-08-02 17:05:05.000000000 +0200
234 @@ -676,6 +676,8 @@ source "fs/Kconfig"
235  
236  source "arch/ia64/Kconfig.debug"
237  
238 +source "kernel/vserver/Kconfig"
239 +
240  source "security/Kconfig"
241  
242  source "crypto/Kconfig"
243 diff -NurpP --minimal linux-2.6.35/arch/ia64/kernel/entry.S linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/entry.S
244 --- linux-2.6.35/arch/ia64/kernel/entry.S       2010-07-07 18:31:01.000000000 +0200
245 +++ linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/entry.S 2010-08-02 17:05:05.000000000 +0200
246 @@ -1714,7 +1714,7 @@ sys_call_table:
247         data8 sys_mq_notify
248         data8 sys_mq_getsetattr
249         data8 sys_kexec_load
250 -       data8 sys_ni_syscall                    // reserved for vserver
251 +       data8 sys_vserver
252         data8 sys_waitid                        // 1270
253         data8 sys_add_key
254         data8 sys_request_key
255 diff -NurpP --minimal linux-2.6.35/arch/ia64/kernel/perfmon.c linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/perfmon.c
256 --- linux-2.6.35/arch/ia64/kernel/perfmon.c     2010-07-07 18:31:01.000000000 +0200
257 +++ linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/perfmon.c       2010-08-02 17:05:05.000000000 +0200
258 @@ -42,6 +42,7 @@
259  #include <linux/completion.h>
260  #include <linux/tracehook.h>
261  #include <linux/slab.h>
262 +#include <linux/vs_memory.h>
263  
264  #include <asm/errno.h>
265  #include <asm/intrinsics.h>
266 diff -NurpP --minimal linux-2.6.35/arch/ia64/kernel/process.c linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/process.c
267 --- linux-2.6.35/arch/ia64/kernel/process.c     2010-07-07 18:31:01.000000000 +0200
268 +++ linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/process.c       2010-08-02 17:05:05.000000000 +0200
269 @@ -113,8 +113,8 @@ show_regs (struct pt_regs *regs)
270         unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
271  
272         print_modules();
273 -       printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
274 -                       smp_processor_id(), current->comm);
275 +       printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
276 +                       current->xid, smp_processor_id(), current->comm);
277         printk("psr : %016lx ifs : %016lx ip  : [<%016lx>]    %s (%s)\n",
278                regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
279                init_utsname()->release);
280 diff -NurpP --minimal linux-2.6.35/arch/ia64/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/ptrace.c
281 --- linux-2.6.35/arch/ia64/kernel/ptrace.c      2010-08-02 16:52:04.000000000 +0200
282 +++ linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/ptrace.c        2010-08-02 17:05:05.000000000 +0200
283 @@ -21,6 +21,7 @@
284  #include <linux/regset.h>
285  #include <linux/elf.h>
286  #include <linux/tracehook.h>
287 +#include <linux/vs_base.h>
288  
289  #include <asm/pgtable.h>
290  #include <asm/processor.h>
291 diff -NurpP --minimal linux-2.6.35/arch/ia64/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/traps.c
292 --- linux-2.6.35/arch/ia64/kernel/traps.c       2010-07-07 18:31:01.000000000 +0200
293 +++ linux-2.6.35-vs2.3.0.36.31/arch/ia64/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
294 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
295         put_cpu();
296  
297         if (++die.lock_owner_depth < 3) {
298 -               printk("%s[%d]: %s %ld [%d]\n",
299 -               current->comm, task_pid_nr(current), str, err, ++die_counter);
300 +               printk("%s[%d[#%u]]: %s %ld [%d]\n",
301 +                       current->comm, task_pid_nr(current), current->xid,
302 +                       str, err, ++die_counter);
303                 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
304                     != NOTIFY_STOP)
305                         show_regs(regs);
306 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
307                         if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
308                                 last.time = current_jiffies + 5 * HZ;
309                                 printk(KERN_WARNING
310 -                                       "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
311 -                                       current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
312 +                                       "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
313 +                                       current->comm, task_pid_nr(current), current->xid,
314 +                                       regs->cr_iip + ia64_psr(regs)->ri, isr);
315                         }
316                 }
317         }
318 diff -NurpP --minimal linux-2.6.35/arch/ia64/mm/fault.c linux-2.6.35-vs2.3.0.36.31/arch/ia64/mm/fault.c
319 --- linux-2.6.35/arch/ia64/mm/fault.c   2010-08-02 16:52:04.000000000 +0200
320 +++ linux-2.6.35-vs2.3.0.36.31/arch/ia64/mm/fault.c     2010-08-02 17:05:05.000000000 +0200
321 @@ -10,6 +10,7 @@
322  #include <linux/interrupt.h>
323  #include <linux/kprobes.h>
324  #include <linux/kdebug.h>
325 +#include <linux/vs_memory.h>
326  
327  #include <asm/pgtable.h>
328  #include <asm/processor.h>
329 diff -NurpP --minimal linux-2.6.35/arch/m32r/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/m32r/kernel/traps.c
330 --- linux-2.6.35/arch/m32r/kernel/traps.c       2009-12-03 20:01:57.000000000 +0100
331 +++ linux-2.6.35-vs2.3.0.36.31/arch/m32r/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
332 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
333         } else {
334                 printk("SPI: %08lx\n", sp);
335         }
336 -       printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
337 -               current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
338 +       printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
339 +               current->comm, task_pid_nr(current), current->xid,
340 +               0xffff & i, 4096+(unsigned long)current);
341  
342         /*
343          * When in-kernel, we also print out the stack and code at the
344 diff -NurpP --minimal linux-2.6.35/arch/m68k/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/m68k/Kconfig
345 --- linux-2.6.35/arch/m68k/Kconfig      2010-08-02 16:52:04.000000000 +0200
346 +++ linux-2.6.35-vs2.3.0.36.31/arch/m68k/Kconfig        2010-08-02 17:05:05.000000000 +0200
347 @@ -619,6 +619,8 @@ source "fs/Kconfig"
348  
349  source "arch/m68k/Kconfig.debug"
350  
351 +source "kernel/vserver/Kconfig"
352 +
353  source "security/Kconfig"
354  
355  source "crypto/Kconfig"
356 diff -NurpP --minimal linux-2.6.35/arch/m68k/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/arch/m68k/kernel/ptrace.c
357 --- linux-2.6.35/arch/m68k/kernel/ptrace.c      2010-07-07 18:31:02.000000000 +0200
358 +++ linux-2.6.35-vs2.3.0.36.31/arch/m68k/kernel/ptrace.c        2010-08-02 17:05:05.000000000 +0200
359 @@ -18,6 +18,7 @@
360  #include <linux/ptrace.h>
361  #include <linux/user.h>
362  #include <linux/signal.h>
363 +#include <linux/vs_base.h>
364  
365  #include <asm/uaccess.h>
366  #include <asm/page.h>
367 @@ -254,6 +255,8 @@ long arch_ptrace(struct task_struct *chi
368                 ret = ptrace_request(child, request, addr, data);
369                 break;
370         }
371 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
372 +               goto out_tsk;
373  
374         return ret;
375  out_eio:
376 diff -NurpP --minimal linux-2.6.35/arch/m68k/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/m68k/kernel/traps.c
377 --- linux-2.6.35/arch/m68k/kernel/traps.c       2010-08-02 16:52:04.000000000 +0200
378 +++ linux-2.6.35-vs2.3.0.36.31/arch/m68k/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
379 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
380         printk("d4: %08lx    d5: %08lx    a0: %08lx    a1: %08lx\n",
381                regs->d4, regs->d5, regs->a0, regs->a1);
382  
383 -       printk("Process %s (pid: %d, task=%p)\n",
384 -               current->comm, task_pid_nr(current), current);
385 +       printk("Process %s (pid: %d[#%u], task=%p)\n",
386 +               current->comm, task_pid_nr(current), current->xid, current);
387         addr = (unsigned long)&fp->un;
388         printk("Frame format=%X ", regs->format);
389         switch (regs->format) {
390 diff -NurpP --minimal linux-2.6.35/arch/m68knommu/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/m68knommu/Kconfig
391 --- linux-2.6.35/arch/m68knommu/Kconfig 2010-08-02 16:52:04.000000000 +0200
392 +++ linux-2.6.35-vs2.3.0.36.31/arch/m68knommu/Kconfig   2010-08-02 17:05:05.000000000 +0200
393 @@ -734,6 +734,8 @@ source "fs/Kconfig"
394  
395  source "arch/m68knommu/Kconfig.debug"
396  
397 +source "kernel/vserver/Kconfig"
398 +
399  source "security/Kconfig"
400  
401  source "crypto/Kconfig"
402 diff -NurpP --minimal linux-2.6.35/arch/m68knommu/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/m68knommu/kernel/traps.c
403 --- linux-2.6.35/arch/m68knommu/kernel/traps.c  2009-09-10 15:25:23.000000000 +0200
404 +++ linux-2.6.35-vs2.3.0.36.31/arch/m68knommu/kernel/traps.c    2010-08-02 17:05:05.000000000 +0200
405 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
406         printk(KERN_EMERG "d4: %08lx    d5: %08lx    a0: %08lx    a1: %08lx\n",
407                fp->d4, fp->d5, fp->a0, fp->a1);
408  
409 -       printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
410 -               current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
411 +       printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
412 +               current->comm, task_pid_nr(current), current->xid,
413 +               PAGE_SIZE+(unsigned long)current);
414         show_stack(NULL, (unsigned long *)(fp + 1));
415         add_taint(TAINT_DIE);
416         do_exit(SIGSEGV);
417 diff -NurpP --minimal linux-2.6.35/arch/mips/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/mips/Kconfig
418 --- linux-2.6.35/arch/mips/Kconfig      2010-08-02 16:52:05.000000000 +0200
419 +++ linux-2.6.35-vs2.3.0.36.31/arch/mips/Kconfig        2010-08-02 17:05:05.000000000 +0200
420 @@ -2253,6 +2253,8 @@ source "fs/Kconfig"
421  
422  source "arch/mips/Kconfig.debug"
423  
424 +source "kernel/vserver/Kconfig"
425 +
426  source "security/Kconfig"
427  
428  source "crypto/Kconfig"
429 diff -NurpP --minimal linux-2.6.35/arch/mips/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/ptrace.c
430 --- linux-2.6.35/arch/mips/kernel/ptrace.c      2010-07-07 18:31:04.000000000 +0200
431 +++ linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/ptrace.c        2010-08-02 17:05:05.000000000 +0200
432 @@ -25,6 +25,7 @@
433  #include <linux/security.h>
434  #include <linux/audit.h>
435  #include <linux/seccomp.h>
436 +#include <linux/vs_base.h>
437  
438  #include <asm/byteorder.h>
439  #include <asm/cpu.h>
440 @@ -259,6 +260,9 @@ long arch_ptrace(struct task_struct *chi
441  {
442         int ret;
443  
444 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
445 +               goto out;
446 +
447         switch (request) {
448         /* when I and D space are separate, these will need to be fixed. */
449         case PTRACE_PEEKTEXT: /* read word at location addr. */
450 diff -NurpP --minimal linux-2.6.35/arch/mips/kernel/scall32-o32.S linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall32-o32.S
451 --- linux-2.6.35/arch/mips/kernel/scall32-o32.S 2010-02-25 11:51:28.000000000 +0100
452 +++ linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall32-o32.S   2010-08-02 17:05:05.000000000 +0200
453 @@ -525,7 +525,7 @@ einval:     li      v0, -ENOSYS
454         sys     sys_mq_timedreceive     5
455         sys     sys_mq_notify           2       /* 4275 */
456         sys     sys_mq_getsetattr       3
457 -       sys     sys_ni_syscall          0       /* sys_vserver */
458 +       sys     sys_vserver             3
459         sys     sys_waitid              5
460         sys     sys_ni_syscall          0       /* available, was setaltroot */
461         sys     sys_add_key             5       /* 4280 */
462 diff -NurpP --minimal linux-2.6.35/arch/mips/kernel/scall64-64.S linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall64-64.S
463 --- linux-2.6.35/arch/mips/kernel/scall64-64.S  2010-02-25 11:51:28.000000000 +0100
464 +++ linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall64-64.S    2010-08-02 17:05:05.000000000 +0200
465 @@ -362,7 +362,7 @@ sys_call_table:
466         PTR     sys_mq_timedreceive
467         PTR     sys_mq_notify
468         PTR     sys_mq_getsetattr               /* 5235 */
469 -       PTR     sys_ni_syscall                  /* sys_vserver */
470 +       PTR     sys_vserver
471         PTR     sys_waitid
472         PTR     sys_ni_syscall                  /* available, was setaltroot */
473         PTR     sys_add_key
474 diff -NurpP --minimal linux-2.6.35/arch/mips/kernel/scall64-n32.S linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall64-n32.S
475 --- linux-2.6.35/arch/mips/kernel/scall64-n32.S 2010-08-02 16:52:05.000000000 +0200
476 +++ linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall64-n32.S   2010-08-02 17:05:05.000000000 +0200
477 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
478         PTR     compat_sys_mq_timedreceive
479         PTR     compat_sys_mq_notify
480         PTR     compat_sys_mq_getsetattr
481 -       PTR     sys_ni_syscall                  /* 6240, sys_vserver */
482 +       PTR     sys32_vserver                   /* 6240 */
483         PTR     compat_sys_waitid
484         PTR     sys_ni_syscall                  /* available, was setaltroot */
485         PTR     sys_add_key
486 diff -NurpP --minimal linux-2.6.35/arch/mips/kernel/scall64-o32.S linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall64-o32.S
487 --- linux-2.6.35/arch/mips/kernel/scall64-o32.S 2010-07-07 18:31:04.000000000 +0200
488 +++ linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/scall64-o32.S   2010-08-02 17:05:05.000000000 +0200
489 @@ -480,7 +480,7 @@ sys_call_table:
490         PTR     compat_sys_mq_timedreceive
491         PTR     compat_sys_mq_notify            /* 4275 */
492         PTR     compat_sys_mq_getsetattr
493 -       PTR     sys_ni_syscall                  /* sys_vserver */
494 +       PTR     sys32_vserver
495         PTR     sys_32_waitid
496         PTR     sys_ni_syscall                  /* available, was setaltroot */
497         PTR     sys_add_key                     /* 4280 */
498 diff -NurpP --minimal linux-2.6.35/arch/mips/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/traps.c
499 --- linux-2.6.35/arch/mips/kernel/traps.c       2010-08-02 16:52:05.000000000 +0200
500 +++ linux-2.6.35-vs2.3.0.36.31/arch/mips/kernel/traps.c 2010-08-02 17:05:05.000000000 +0200
501 @@ -340,9 +340,10 @@ void show_registers(const struct pt_regs
502  
503         __show_regs(regs);
504         print_modules();
505 -       printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
506 -              current->comm, current->pid, current_thread_info(), current,
507 -             field, current_thread_info()->tp_value);
508 +       printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
509 +               current->comm, task_pid_nr(current), current->xid,
510 +               current_thread_info(), current,
511 +               field, current_thread_info()->tp_value);
512         if (cpu_has_userlocal) {
513                 unsigned long tls;
514  
515 diff -NurpP --minimal linux-2.6.35/arch/parisc/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/parisc/Kconfig
516 --- linux-2.6.35/arch/parisc/Kconfig    2010-08-02 16:52:06.000000000 +0200
517 +++ linux-2.6.35-vs2.3.0.36.31/arch/parisc/Kconfig      2010-08-02 17:05:05.000000000 +0200
518 @@ -299,6 +299,8 @@ source "fs/Kconfig"
519  
520  source "arch/parisc/Kconfig.debug"
521  
522 +source "kernel/vserver/Kconfig"
523 +
524  source "security/Kconfig"
525  
526  source "crypto/Kconfig"
527 diff -NurpP --minimal linux-2.6.35/arch/parisc/kernel/syscall_table.S linux-2.6.35-vs2.3.0.36.31/arch/parisc/kernel/syscall_table.S
528 --- linux-2.6.35/arch/parisc/kernel/syscall_table.S     2010-07-07 18:31:04.000000000 +0200
529 +++ linux-2.6.35-vs2.3.0.36.31/arch/parisc/kernel/syscall_table.S       2010-08-02 17:05:05.000000000 +0200
530 @@ -361,7 +361,7 @@
531         ENTRY_COMP(mbind)               /* 260 */
532         ENTRY_COMP(get_mempolicy)
533         ENTRY_COMP(set_mempolicy)
534 -       ENTRY_SAME(ni_syscall)  /* 263: reserved for vserver */
535 +       ENTRY_DIFF(vserver)
536         ENTRY_SAME(add_key)
537         ENTRY_SAME(request_key)         /* 265 */
538         ENTRY_SAME(keyctl)
539 diff -NurpP --minimal linux-2.6.35/arch/parisc/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/parisc/kernel/traps.c
540 --- linux-2.6.35/arch/parisc/kernel/traps.c     2009-09-10 15:25:40.000000000 +0200
541 +++ linux-2.6.35-vs2.3.0.36.31/arch/parisc/kernel/traps.c       2010-08-02 17:05:05.000000000 +0200
542 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
543                 if (err == 0)
544                         return; /* STFU */
545  
546 -               printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
547 -                       current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
548 +               printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
549 +                       current->comm, task_pid_nr(current), current->xid,
550 +                       str, err, regs->iaoq[0]);
551  #ifdef PRINT_USER_FAULTS
552                 /* XXX for debugging only */
553                 show_regs(regs);
554 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
555                 pdc_console_restart();
556         
557         if (err)
558 -               printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
559 -                       current->comm, task_pid_nr(current), str, err);
560 +               printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
561 +                       current->comm, task_pid_nr(current), current->xid, str, err);
562  
563         /* Wot's wrong wif bein' racy? */
564         if (current->thread.flags & PARISC_KERNEL_DEATH) {
565 diff -NurpP --minimal linux-2.6.35/arch/parisc/mm/fault.c linux-2.6.35-vs2.3.0.36.31/arch/parisc/mm/fault.c
566 --- linux-2.6.35/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
567 +++ linux-2.6.35-vs2.3.0.36.31/arch/parisc/mm/fault.c   2010-08-02 17:05:05.000000000 +0200
568 @@ -237,8 +237,9 @@ bad_area:
569  
570  #ifdef PRINT_USER_FAULTS
571                 printk(KERN_DEBUG "\n");
572 -               printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
573 -                   task_pid_nr(tsk), tsk->comm, code, address);
574 +               printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
575 +                   "command='%s' type=%lu address=0x%08lx\n",
576 +                   task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
577                 if (vma) {
578                         printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
579                                         vma->vm_start, vma->vm_end);
580 diff -NurpP --minimal linux-2.6.35/arch/powerpc/include/asm/unistd.h linux-2.6.35-vs2.3.0.36.31/arch/powerpc/include/asm/unistd.h
581 --- linux-2.6.35/arch/powerpc/include/asm/unistd.h      2010-07-07 18:31:05.000000000 +0200
582 +++ linux-2.6.35-vs2.3.0.36.31/arch/powerpc/include/asm/unistd.h        2010-08-02 17:05:05.000000000 +0200
583 @@ -275,7 +275,7 @@
584  #endif
585  #define __NR_rtas              255
586  #define __NR_sys_debug_setcontext 256
587 -/* Number 257 is reserved for vserver */
588 +#define __NR_vserver           257
589  #define __NR_migrate_pages     258
590  #define __NR_mbind             259
591  #define __NR_get_mempolicy     260
592 diff -NurpP --minimal linux-2.6.35/arch/powerpc/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/powerpc/Kconfig
593 --- linux-2.6.35/arch/powerpc/Kconfig   2010-08-02 16:52:06.000000000 +0200
594 +++ linux-2.6.35-vs2.3.0.36.31/arch/powerpc/Kconfig     2010-08-02 17:05:05.000000000 +0200
595 @@ -990,6 +990,8 @@ source "lib/Kconfig"
596  
597  source "arch/powerpc/Kconfig.debug"
598  
599 +source "kernel/vserver/Kconfig"
600 +
601  source "security/Kconfig"
602  
603  config KEYS_COMPAT
604 diff -NurpP --minimal linux-2.6.35/arch/powerpc/kernel/process.c linux-2.6.35-vs2.3.0.36.31/arch/powerpc/kernel/process.c
605 --- linux-2.6.35/arch/powerpc/kernel/process.c  2010-08-02 16:52:07.000000000 +0200
606 +++ linux-2.6.35-vs2.3.0.36.31/arch/powerpc/kernel/process.c    2010-08-02 17:05:05.000000000 +0200
607 @@ -605,8 +605,9 @@ void show_regs(struct pt_regs * regs)
608  #else
609                 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
610  #endif
611 -       printk("TASK = %p[%d] '%s' THREAD: %p",
612 -              current, task_pid_nr(current), current->comm, task_thread_info(current));
613 +       printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
614 +              current, task_pid_nr(current), current->xid,
615 +              current->comm, task_thread_info(current));
616  
617  #ifdef CONFIG_SMP
618         printk(" CPU: %d", raw_smp_processor_id());
619 diff -NurpP --minimal linux-2.6.35/arch/powerpc/kernel/traps.c linux-2.6.35-vs2.3.0.36.31/arch/powerpc/kernel/traps.c
620 --- linux-2.6.35/arch/powerpc/kernel/traps.c    2010-08-02 16:52:07.000000000 +0200
621 +++ linux-2.6.35-vs2.3.0.36.31/arch/powerpc/kernel/traps.c      2010-08-02 17:05:05.000000000 +0200
622 @@ -1053,8 +1053,9 @@ void nonrecoverable_exception(struct pt_
623  
624  void trace_syscall(struct pt_regs *regs)
625  {
626 -       printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld    %s\n",
627 -              current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
628 +       printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld    %s\n",
629 +              current, task_pid_nr(current), current->xid,
630 +              regs->nip, regs->link, regs->gpr[0],
631                regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
632  }
633  
634 diff -NurpP --minimal linux-2.6.35/arch/powerpc/kernel/vdso.c linux-2.6.35-vs2.3.0.36.31/arch/powerpc/kernel/vdso.c
635 --- linux-2.6.35/arch/powerpc/kernel/vdso.c     2010-08-02 16:52:07.000000000 +0200
636 +++ linux-2.6.35-vs2.3.0.36.31/arch/powerpc/kernel/vdso.c       2010-08-02 17:43:41.000000000 +0200
637 @@ -23,6 +23,7 @@
638  #include <linux/security.h>
639  #include <linux/bootmem.h>
640  #include <linux/memblock.h>
641 +#include <linux/vs_memory.h>
642  
643  #include <asm/pgtable.h>
644  #include <asm/system.h>
645 diff -NurpP --minimal linux-2.6.35/arch/s390/include/asm/tlb.h linux-2.6.35-vs2.3.0.36.31/arch/s390/include/asm/tlb.h
646 --- linux-2.6.35/arch/s390/include/asm/tlb.h    2009-09-10 15:25:43.000000000 +0200
647 +++ linux-2.6.35-vs2.3.0.36.31/arch/s390/include/asm/tlb.h      2010-08-02 17:05:05.000000000 +0200
648 @@ -23,6 +23,8 @@
649  
650  #include <linux/mm.h>
651  #include <linux/swap.h>
652 +#include <linux/vs_memory.h>
653 +
654  #include <asm/processor.h>
655  #include <asm/pgalloc.h>
656  #include <asm/smp.h>
657 diff -NurpP --minimal linux-2.6.35/arch/s390/include/asm/unistd.h linux-2.6.35-vs2.3.0.36.31/arch/s390/include/asm/unistd.h
658 --- linux-2.6.35/arch/s390/include/asm/unistd.h 2010-07-07 18:31:06.000000000 +0200
659 +++ linux-2.6.35-vs2.3.0.36.31/arch/s390/include/asm/unistd.h   2010-08-02 17:05:05.000000000 +0200
660 @@ -202,7 +202,7 @@
661  #define __NR_clock_gettime     (__NR_timer_create+6)
662  #define __NR_clock_getres      (__NR_timer_create+7)
663  #define __NR_clock_nanosleep   (__NR_timer_create+8)
664 -/* Number 263 is reserved for vserver */
665 +#define __NR_vserver           263
666  #define __NR_statfs64          265
667  #define __NR_fstatfs64         266
668  #define __NR_remap_file_pages  267
669 diff -NurpP --minimal linux-2.6.35/arch/s390/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/s390/Kconfig
670 --- linux-2.6.35/arch/s390/Kconfig      2010-08-02 16:52:08.000000000 +0200
671 +++ linux-2.6.35-vs2.3.0.36.31/arch/s390/Kconfig        2010-08-02 17:05:05.000000000 +0200
672 @@ -623,6 +623,8 @@ source "fs/Kconfig"
673  
674  source "arch/s390/Kconfig.debug"
675  
676 +source "kernel/vserver/Kconfig"
677 +
678  source "security/Kconfig"
679  
680  source "crypto/Kconfig"
681 diff -NurpP --minimal linux-2.6.35/arch/s390/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/arch/s390/kernel/ptrace.c
682 --- linux-2.6.35/arch/s390/kernel/ptrace.c      2010-08-02 16:52:09.000000000 +0200
683 +++ linux-2.6.35-vs2.3.0.36.31/arch/s390/kernel/ptrace.c        2010-08-02 17:05:05.000000000 +0200
684 @@ -36,6 +36,7 @@
685  #include <linux/regset.h>
686  #include <linux/tracehook.h>
687  #include <linux/seccomp.h>
688 +#include <linux/vs_base.h>
689  #include <trace/syscall.h>
690  #include <asm/compat.h>
691  #include <asm/segment.h>
692 diff -NurpP --minimal linux-2.6.35/arch/s390/kernel/syscalls.S linux-2.6.35-vs2.3.0.36.31/arch/s390/kernel/syscalls.S
693 --- linux-2.6.35/arch/s390/kernel/syscalls.S    2010-07-07 18:31:07.000000000 +0200
694 +++ linux-2.6.35-vs2.3.0.36.31/arch/s390/kernel/syscalls.S      2010-08-02 17:05:05.000000000 +0200
695 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
696  SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper)       /* 260 */
697  SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
698  SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
699 -NI_SYSCALL                                                     /* reserved for vserver */
700 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
701  SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
702  SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
703  SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
704 diff -NurpP --minimal linux-2.6.35/arch/sh/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/sh/Kconfig
705 --- linux-2.6.35/arch/sh/Kconfig        2010-08-02 16:52:09.000000000 +0200
706 +++ linux-2.6.35-vs2.3.0.36.31/arch/sh/Kconfig  2010-08-02 17:05:05.000000000 +0200
707 @@ -881,6 +881,8 @@ source "fs/Kconfig"
708  
709  source "arch/sh/Kconfig.debug"
710  
711 +source "kernel/vserver/Kconfig"
712 +
713  source "security/Kconfig"
714  
715  source "crypto/Kconfig"
716 diff -NurpP --minimal linux-2.6.35/arch/sh/kernel/irq.c linux-2.6.35-vs2.3.0.36.31/arch/sh/kernel/irq.c
717 --- linux-2.6.35/arch/sh/kernel/irq.c   2010-08-02 16:52:10.000000000 +0200
718 +++ linux-2.6.35-vs2.3.0.36.31/arch/sh/kernel/irq.c     2010-08-02 17:41:50.000000000 +0200
719 @@ -13,6 +13,7 @@
720  #include <linux/seq_file.h>
721  #include <linux/ftrace.h>
722  #include <linux/delay.h>
723 +// #include <linux/vs_context.h>
724  #include <asm/processor.h>
725  #include <asm/machvec.h>
726  #include <asm/uaccess.h>
727 diff -NurpP --minimal linux-2.6.35/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.35-vs2.3.0.36.31/arch/sh/kernel/vsyscall/vsyscall.c
728 --- linux-2.6.35/arch/sh/kernel/vsyscall/vsyscall.c     2010-07-07 18:31:10.000000000 +0200
729 +++ linux-2.6.35-vs2.3.0.36.31/arch/sh/kernel/vsyscall/vsyscall.c       2010-08-02 17:05:05.000000000 +0200
730 @@ -18,6 +18,7 @@
731  #include <linux/elf.h>
732  #include <linux/sched.h>
733  #include <linux/err.h>
734 +#include <linux/vs_memory.h>
735  
736  /*
737   * Should the kernel map a VDSO page into processes and pass its
738 diff -NurpP --minimal linux-2.6.35/arch/sparc/include/asm/tlb_64.h linux-2.6.35-vs2.3.0.36.31/arch/sparc/include/asm/tlb_64.h
739 --- linux-2.6.35/arch/sparc/include/asm/tlb_64.h        2009-09-10 15:25:45.000000000 +0200
740 +++ linux-2.6.35-vs2.3.0.36.31/arch/sparc/include/asm/tlb_64.h  2010-08-02 17:05:05.000000000 +0200
741 @@ -3,6 +3,7 @@
742  
743  #include <linux/swap.h>
744  #include <linux/pagemap.h>
745 +#include <linux/vs_memory.h>
746  #include <asm/pgalloc.h>
747  #include <asm/tlbflush.h>
748  #include <asm/mmu_context.h>
749 diff -NurpP --minimal linux-2.6.35/arch/sparc/include/asm/unistd.h linux-2.6.35-vs2.3.0.36.31/arch/sparc/include/asm/unistd.h
750 --- linux-2.6.35/arch/sparc/include/asm/unistd.h        2010-07-07 18:31:10.000000000 +0200
751 +++ linux-2.6.35-vs2.3.0.36.31/arch/sparc/include/asm/unistd.h  2010-08-02 17:05:05.000000000 +0200
752 @@ -335,7 +335,7 @@
753  #define __NR_timer_getoverrun  264
754  #define __NR_timer_delete      265
755  #define __NR_timer_create      266
756 -/* #define __NR_vserver                267 Reserved for VSERVER */
757 +#define __NR_vserver           267
758  #define __NR_io_setup          268
759  #define __NR_io_destroy                269
760  #define __NR_io_submit         270
761 diff -NurpP --minimal linux-2.6.35/arch/sparc/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/sparc/Kconfig
762 --- linux-2.6.35/arch/sparc/Kconfig     2010-08-02 16:52:10.000000000 +0200
763 +++ linux-2.6.35-vs2.3.0.36.31/arch/sparc/Kconfig       2010-08-02 17:05:05.000000000 +0200
764 @@ -570,6 +570,8 @@ source "fs/Kconfig"
765  
766  source "arch/sparc/Kconfig.debug"
767  
768 +source "kernel/vserver/Kconfig"
769 +
770  source "security/Kconfig"
771  
772  source "crypto/Kconfig"
773 diff -NurpP --minimal linux-2.6.35/arch/sparc/kernel/systbls_32.S linux-2.6.35-vs2.3.0.36.31/arch/sparc/kernel/systbls_32.S
774 --- linux-2.6.35/arch/sparc/kernel/systbls_32.S 2010-02-25 11:51:34.000000000 +0100
775 +++ linux-2.6.35-vs2.3.0.36.31/arch/sparc/kernel/systbls_32.S   2010-08-02 17:05:05.000000000 +0200
776 @@ -70,7 +70,7 @@ sys_call_table:
777  /*250*/        .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
778  /*255*/        .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
779  /*260*/        .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
780 -/*265*/        .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
781 +/*265*/        .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
782  /*270*/        .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
783  /*275*/        .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
784  /*280*/        .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
785 diff -NurpP --minimal linux-2.6.35/arch/sparc/kernel/systbls_64.S linux-2.6.35-vs2.3.0.36.31/arch/sparc/kernel/systbls_64.S
786 --- linux-2.6.35/arch/sparc/kernel/systbls_64.S 2010-07-07 18:31:10.000000000 +0200
787 +++ linux-2.6.35-vs2.3.0.36.31/arch/sparc/kernel/systbls_64.S   2010-08-02 17:05:05.000000000 +0200
788 @@ -71,7 +71,7 @@ sys_call_table32:
789  /*250*/        .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
790         .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
791  /*260*/        .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
792 -       .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
793 +       .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
794  /*270*/        .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
795         .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
796  /*280*/        .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
797 @@ -146,7 +146,7 @@ sys_call_table:
798  /*250*/        .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
799         .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
800  /*260*/        .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
801 -       .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
802 +       .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
803  /*270*/        .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
804         .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
805  /*280*/        .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
806 diff -NurpP --minimal linux-2.6.35/arch/um/include/asm/tlb.h linux-2.6.35-vs2.3.0.36.31/arch/um/include/asm/tlb.h
807 --- linux-2.6.35/arch/um/include/asm/tlb.h      2009-09-10 15:25:46.000000000 +0200
808 +++ linux-2.6.35-vs2.3.0.36.31/arch/um/include/asm/tlb.h        2010-08-02 17:05:05.000000000 +0200
809 @@ -3,6 +3,7 @@
810  
811  #include <linux/pagemap.h>
812  #include <linux/swap.h>
813 +#include <linux/vs_memory.h>
814  #include <asm/percpu.h>
815  #include <asm/pgalloc.h>
816  #include <asm/tlbflush.h>
817 diff -NurpP --minimal linux-2.6.35/arch/um/include/shared/kern_constants.h linux-2.6.35-vs2.3.0.36.31/arch/um/include/shared/kern_constants.h
818 --- linux-2.6.35/arch/um/include/shared/kern_constants.h        1970-01-01 01:00:00.000000000 +0100
819 +++ linux-2.6.35-vs2.3.0.36.31/arch/um/include/shared/kern_constants.h  2010-08-02 17:05:05.000000000 +0200
820 @@ -0,0 +1 @@
821 +#include "../../../../include/generated/asm-offsets.h"
822 diff -NurpP --minimal linux-2.6.35/arch/um/include/shared/user_constants.h linux-2.6.35-vs2.3.0.36.31/arch/um/include/shared/user_constants.h
823 --- linux-2.6.35/arch/um/include/shared/user_constants.h        1970-01-01 01:00:00.000000000 +0100
824 +++ linux-2.6.35-vs2.3.0.36.31/arch/um/include/shared/user_constants.h  2010-08-02 17:05:05.000000000 +0200
825 @@ -0,0 +1,40 @@
826 +/*
827 + * DO NOT MODIFY.
828 + *
829 + * This file was generated by arch/um/Makefile
830 + *
831 + */
832 +
833 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2)    # */
834 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err)    # */
835 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno)      # */
836 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long)     # */
837 +#define HOST_RBX 5 /* RBX      # */
838 +#define HOST_RCX 11 /* RCX     # */
839 +#define HOST_RDI 14 /* RDI     # */
840 +#define HOST_RSI 13 /* RSI     # */
841 +#define HOST_RDX 12 /* RDX     # */
842 +#define HOST_RBP 4 /* RBP      # */
843 +#define HOST_RAX 10 /* RAX     # */
844 +#define HOST_R8 9 /* R8        # */
845 +#define HOST_R9 8 /* R9        # */
846 +#define HOST_R10 7 /* R10      # */
847 +#define HOST_R11 6 /* R11      # */
848 +#define HOST_R12 3 /* R12      # */
849 +#define HOST_R13 2 /* R13      # */
850 +#define HOST_R14 1 /* R14      # */
851 +#define HOST_R15 0 /* R15      # */
852 +#define HOST_ORIG_RAX 15 /* ORIG_RAX   # */
853 +#define HOST_CS 17 /* CS       # */
854 +#define HOST_SS 20 /* SS       # */
855 +#define HOST_EFLAGS 18 /* EFLAGS       # */
856 +#define HOST_IP 16 /* RIP      # */
857 +#define HOST_SP 19 /* RSP      # */
858 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct)   # */
859 +#define UM_POLLIN 1 /* POLLIN  # */
860 +#define UM_POLLPRI 2 /* POLLPRI        # */
861 +#define UM_POLLOUT 4 /* POLLOUT        # */
862 +#define UM_PROT_READ 1 /* PROT_READ    # */
863 +#define UM_PROT_WRITE 2 /* PROT_WRITE  # */
864 +#define UM_PROT_EXEC 4 /* PROT_EXEC    # */
865 +
866 diff -NurpP --minimal linux-2.6.35/arch/um/Kconfig.rest linux-2.6.35-vs2.3.0.36.31/arch/um/Kconfig.rest
867 --- linux-2.6.35/arch/um/Kconfig.rest   2009-06-11 17:12:19.000000000 +0200
868 +++ linux-2.6.35-vs2.3.0.36.31/arch/um/Kconfig.rest     2010-08-02 17:05:05.000000000 +0200
869 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
870  
871  source "fs/Kconfig"
872  
873 +source "kernel/vserver/Kconfig"
874 +
875  source "security/Kconfig"
876  
877  source "crypto/Kconfig"
878 diff -NurpP --minimal linux-2.6.35/arch/um/kernel/config.c linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/config.c
879 --- linux-2.6.35/arch/um/kernel/config.c        1970-01-01 01:00:00.000000000 +0100
880 +++ linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/config.c  2010-08-02 17:05:05.000000000 +0200
881 @@ -0,0 +1,417 @@
882 +/*
883 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
884 + * Licensed under the GPL
885 + */
886 +
887 +#include <stdio.h>
888 +#include <stdlib.h>
889 +#include "init.h"
890 +
891 +static __initdata const char *config[] = {
892 +
893 +"#\n",
894 +"# Automatically generated make config: don't edit\n",
895 +"# Linux kernel version: 2.6.33-vs2.3.0.36.29.1\n",
896 +"# Wed Mar 10 20:29:46 2010\n",
897 +"#\n",
898 +"CONFIG_DEFCONFIG_LIST=\"arch/$ARCH/defconfig\"\n",
899 +"CONFIG_GENERIC_HARDIRQS=y\n",
900 +"CONFIG_UML=y\n",
901 +"CONFIG_MMU=y\n",
902 +"CONFIG_NO_IOMEM=y\n",
903 +"# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set\n",
904 +"CONFIG_LOCKDEP_SUPPORT=y\n",
905 +"# CONFIG_STACKTRACE_SUPPORT is not set\n",
906 +"CONFIG_GENERIC_CALIBRATE_DELAY=y\n",
907 +"CONFIG_GENERIC_BUG=y\n",
908 +"CONFIG_GENERIC_TIME=y\n",
909 +"CONFIG_GENERIC_CLOCKEVENTS=y\n",
910 +"CONFIG_IRQ_RELEASE_METHOD=y\n",
911 +"CONFIG_HZ=100\n",
912 +"\n",
913 +"#\n",
914 +"# UML-specific options\n",
915 +"#\n",
916 +"\n",
917 +"#\n",
918 +"# Host processor type and features\n",
919 +"#\n",
920 +"# CONFIG_M386 is not set\n",
921 +"# CONFIG_M486 is not set\n",
922 +"# CONFIG_M586 is not set\n",
923 +"# CONFIG_M586TSC is not set\n",
924 +"# CONFIG_M586MMX is not set\n",
925 +"# CONFIG_M686 is not set\n",
926 +"# CONFIG_MPENTIUMII is not set\n",
927 +"# CONFIG_MPENTIUMIII is not set\n",
928 +"# CONFIG_MPENTIUMM is not set\n",
929 +"# CONFIG_MPENTIUM4 is not set\n",
930 +"# CONFIG_MK6 is not set\n",
931 +"# CONFIG_MK7 is not set\n",
932 +"CONFIG_MK8=y\n",
933 +"# CONFIG_MCRUSOE is not set\n",
934 +"# CONFIG_MEFFICEON is not set\n",
935 +"# CONFIG_MWINCHIPC6 is not set\n",
936 +"# CONFIG_MWINCHIP3D is not set\n",
937 +"# CONFIG_MGEODEGX1 is not set\n",
938 +"# CONFIG_MGEODE_LX is not set\n",
939 +"# CONFIG_MCYRIXIII is not set\n",
940 +"# CONFIG_MVIAC3_2 is not set\n",
941 +"# CONFIG_MVIAC7 is not set\n",
942 +"# CONFIG_MPSC is not set\n",
943 +"# CONFIG_MCORE2 is not set\n",
944 +"# CONFIG_MATOM is not set\n",
945 +"# CONFIG_GENERIC_CPU is not set\n",
946 +"CONFIG_X86_CPU=y\n",
947 +"CONFIG_X86_INTERNODE_CACHE_SHIFT=6\n",
948 +"# CONFIG_X86_CMPXCHG is not set\n",
949 +"CONFIG_X86_L1_CACHE_SHIFT=6\n",
950 +"CONFIG_X86_WP_WORKS_OK=y\n",
951 +"CONFIG_X86_INTEL_USERCOPY=y\n",
952 +"CONFIG_X86_USE_PPRO_CHECKSUM=y\n",
953 +"CONFIG_X86_TSC=y\n",
954 +"CONFIG_X86_CMOV=y\n",
955 +"CONFIG_X86_MINIMUM_CPU_FAMILY=3\n",
956 +"CONFIG_CPU_SUP_INTEL=y\n",
957 +"CONFIG_CPU_SUP_AMD=y\n",
958 +"CONFIG_CPU_SUP_CENTAUR=y\n",
959 +"CONFIG_UML_X86=y\n",
960 +"CONFIG_64BIT=y\n",
961 +"# CONFIG_X86_32 is not set\n",
962 +"# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set\n",
963 +"CONFIG_RWSEM_GENERIC_SPINLOCK=y\n",
964 +"# CONFIG_ARCH_HAS_SC_SIGNALS is not set\n",
965 +"# CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA is not set\n",
966 +"CONFIG_SMP_BROKEN=y\n",
967 +"CONFIG_GENERIC_HWEIGHT=y\n",
968 +"# CONFIG_STATIC_LINK is not set\n",
969 +"CONFIG_FLATMEM=y\n",
970 +"CONFIG_FLAT_NODE_MEM_MAP=y\n",
971 +"CONFIG_PAGEFLAGS_EXTENDED=y\n",
972 +"CONFIG_SPLIT_PTLOCK_CPUS=4\n",
973 +"CONFIG_PHYS_ADDR_T_64BIT=y\n",
974 +"CONFIG_ZONE_DMA_FLAG=0\n",
975 +"CONFIG_VIRT_TO_BUS=y\n",
976 +"# CONFIG_KSM is not set\n",
977 +"CONFIG_DEFAULT_MMAP_MIN_ADDR=4096\n",
978 +"# CONFIG_NO_HZ is not set\n",
979 +"# CONFIG_HIGH_RES_TIMERS is not set\n",
980 +"CONFIG_GENERIC_CLOCKEVENTS_BUILD=y\n",
981 +"CONFIG_LD_SCRIPT_DYN=y\n",
982 +"# CONFIG_BINFMT_ELF is not set\n",
983 +"# CONFIG_HAVE_AOUT is not set\n",
984 +"# CONFIG_BINFMT_MISC is not set\n",
985 +"# CONFIG_HOSTFS is not set\n",
986 +"# CONFIG_MCONSOLE is not set\n",
987 +"CONFIG_KERNEL_STACK_ORDER=1\n",
988 +"\n",
989 +"#\n",
990 +"# General setup\n",
991 +"#\n",
992 +"# CONFIG_EXPERIMENTAL is not set\n",
993 +"CONFIG_BROKEN_ON_SMP=y\n",
994 +"CONFIG_INIT_ENV_ARG_LIMIT=128\n",
995 +"CONFIG_LOCALVERSION=\"\"\n",
996 +"# CONFIG_LOCALVERSION_AUTO is not set\n",
997 +"# CONFIG_SWAP is not set\n",
998 +"CONFIG_SYSVIPC=y\n",
999 +"CONFIG_SYSVIPC_SYSCTL=y\n",
1000 +"# CONFIG_BSD_PROCESS_ACCT is not set\n",
1001 +"\n",
1002 +"#\n",
1003 +"# RCU Subsystem\n",
1004 +"#\n",
1005 +"CONFIG_TREE_RCU=y\n",
1006 +"# CONFIG_TREE_PREEMPT_RCU is not set\n",
1007 +"# CONFIG_TINY_RCU is not set\n",
1008 +"# CONFIG_RCU_TRACE is not set\n",
1009 +"CONFIG_RCU_FANOUT=64\n",
1010 +"# CONFIG_RCU_FANOUT_EXACT is not set\n",
1011 +"# CONFIG_TREE_RCU_TRACE is not set\n",
1012 +"# CONFIG_IKCONFIG is not set\n",
1013 +"CONFIG_LOG_BUF_SHIFT=17\n",
1014 +"# CONFIG_CGROUPS is not set\n",
1015 +"# CONFIG_SYSFS_DEPRECATED_V2 is not set\n",
1016 +"# CONFIG_RELAY is not set\n",
1017 +"CONFIG_NAMESPACES=y\n",
1018 +"CONFIG_UTS_NS=y\n",
1019 +"CONFIG_IPC_NS=y\n",
1020 +"CONFIG_USER_NS=y\n",
1021 +"# CONFIG_BLK_DEV_INITRD is not set\n",
1022 +"# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set\n",
1023 +"CONFIG_SYSCTL=y\n",
1024 +"CONFIG_ANON_INODES=y\n",
1025 +"# CONFIG_EMBEDDED is not set\n",
1026 +"CONFIG_UID16=y\n",
1027 +"CONFIG_SYSCTL_SYSCALL=y\n",
1028 +"CONFIG_KALLSYMS=y\n",
1029 +"# CONFIG_KALLSYMS_EXTRA_PASS is not set\n",
1030 +"CONFIG_HOTPLUG=y\n",
1031 +"CONFIG_PRINTK=y\n",
1032 +"CONFIG_BUG=y\n",
1033 +"CONFIG_ELF_CORE=y\n",
1034 +"CONFIG_BASE_FULL=y\n",
1035 +"CONFIG_FUTEX=y\n",
1036 +"CONFIG_EPOLL=y\n",
1037 +"CONFIG_SIGNALFD=y\n",
1038 +"CONFIG_TIMERFD=y\n",
1039 +"CONFIG_EVENTFD=y\n",
1040 +"CONFIG_SHMEM=y\n",
1041 +"CONFIG_AIO=y\n",
1042 +"\n",
1043 +"#\n",
1044 +"# Kernel Performance Events And Counters\n",
1045 +"#\n",
1046 +"CONFIG_VM_EVENT_COUNTERS=y\n",
1047 +"CONFIG_SLUB_DEBUG=y\n",
1048 +"# CONFIG_COMPAT_BRK is not set\n",
1049 +"# CONFIG_SLAB is not set\n",
1050 +"CONFIG_SLUB=y\n",
1051 +"# CONFIG_SLOB is not set\n",
1052 +"# CONFIG_PROFILING is not set\n",
1053 +"\n",
1054 +"#\n",
1055 +"# GCOV-based kernel profiling\n",
1056 +"#\n",
1057 +"# CONFIG_SLOW_WORK is not set\n",
1058 +"# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set\n",
1059 +"CONFIG_SLABINFO=y\n",
1060 +"CONFIG_RT_MUTEXES=y\n",
1061 +"CONFIG_BASE_SMALL=0\n",
1062 +"# CONFIG_MODULES is not set\n",
1063 +"CONFIG_BLOCK=y\n",
1064 +"# CONFIG_BLK_DEV_BSG is not set\n",
1065 +"# CONFIG_BLK_DEV_INTEGRITY is not set\n",
1066 +"\n",
1067 +"#\n",
1068 +"# IO Schedulers\n",
1069 +"#\n",
1070 +"CONFIG_IOSCHED_NOOP=y\n",
1071 +"# CONFIG_IOSCHED_DEADLINE is not set\n",
1072 +"# CONFIG_IOSCHED_CFQ is not set\n",
1073 +"# CONFIG_DEFAULT_DEADLINE is not set\n",
1074 +"# CONFIG_DEFAULT_CFQ is not set\n",
1075 +"CONFIG_DEFAULT_NOOP=y\n",
1076 +"CONFIG_DEFAULT_IOSCHED=\"noop\"\n",
1077 +"# CONFIG_INLINE_SPIN_TRYLOCK is not set\n",
1078 +"# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set\n",
1079 +"# CONFIG_INLINE_SPIN_LOCK is not set\n",
1080 +"# CONFIG_INLINE_SPIN_LOCK_BH is not set\n",
1081 +"# CONFIG_INLINE_SPIN_LOCK_IRQ is not set\n",
1082 +"# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set\n",
1083 +"CONFIG_INLINE_SPIN_UNLOCK=y\n",
1084 +"# CONFIG_INLINE_SPIN_UNLOCK_BH is not set\n",
1085 +"CONFIG_INLINE_SPIN_UNLOCK_IRQ=y\n",
1086 +"# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set\n",
1087 +"# CONFIG_INLINE_READ_TRYLOCK is not set\n",
1088 +"# CONFIG_INLINE_READ_LOCK is not set\n",
1089 +"# CONFIG_INLINE_READ_LOCK_BH is not set\n",
1090 +"# CONFIG_INLINE_READ_LOCK_IRQ is not set\n",
1091 +"# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set\n",
1092 +"CONFIG_INLINE_READ_UNLOCK=y\n",
1093 +"# CONFIG_INLINE_READ_UNLOCK_BH is not set\n",
1094 +"CONFIG_INLINE_READ_UNLOCK_IRQ=y\n",
1095 +"# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set\n",
1096 +"# CONFIG_INLINE_WRITE_TRYLOCK is not set\n",
1097 +"# CONFIG_INLINE_WRITE_LOCK is not set\n",
1098 +"# CONFIG_INLINE_WRITE_LOCK_BH is not set\n",
1099 +"# CONFIG_INLINE_WRITE_LOCK_IRQ is not set\n",
1100 +"# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set\n",
1101 +"CONFIG_INLINE_WRITE_UNLOCK=y\n",
1102 +"# CONFIG_INLINE_WRITE_UNLOCK_BH is not set\n",
1103 +"CONFIG_INLINE_WRITE_UNLOCK_IRQ=y\n",
1104 +"# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set\n",
1105 +"# CONFIG_MUTEX_SPIN_ON_OWNER is not set\n",
1106 +"# CONFIG_FREEZER is not set\n",
1107 +"# CONFIG_BLK_DEV is not set\n",
1108 +"\n",
1109 +"#\n",
1110 +"# Character Devices\n",
1111 +"#\n",
1112 +"# CONFIG_STDERR_CONSOLE is not set\n",
1113 +"CONFIG_STDIO_CONSOLE=y\n",
1114 +"# CONFIG_SSL is not set\n",
1115 +"# CONFIG_NULL_CHAN is not set\n",
1116 +"# CONFIG_PORT_CHAN is not set\n",
1117 +"# CONFIG_PTY_CHAN is not set\n",
1118 +"# CONFIG_TTY_CHAN is not set\n",
1119 +"# CONFIG_XTERM_CHAN is not set\n",
1120 +"CONFIG_NOCONFIG_CHAN=y\n",
1121 +"CONFIG_CON_ZERO_CHAN=\"fd:0,fd:1\"\n",
1122 +"CONFIG_CON_CHAN=\"xterm\"\n",
1123 +"CONFIG_SSL_CHAN=\"pty\"\n",
1124 +"# CONFIG_UNIX98_PTYS is not set\n",
1125 +"# CONFIG_LEGACY_PTYS is not set\n",
1126 +"# CONFIG_RAW_DRIVER is not set\n",
1127 +"# CONFIG_WATCHDOG is not set\n",
1128 +"# CONFIG_UML_SOUND is not set\n",
1129 +"# CONFIG_SOUND is not set\n",
1130 +"# CONFIG_SOUND_OSS_CORE is not set\n",
1131 +"# CONFIG_HOSTAUDIO is not set\n",
1132 +"# CONFIG_HW_RANDOM is not set\n",
1133 +"# CONFIG_UML_RANDOM is not set\n",
1134 +"# CONFIG_MMAPPER is not set\n",
1135 +"\n",
1136 +"#\n",
1137 +"# Generic Driver Options\n",
1138 +"#\n",
1139 +"CONFIG_UEVENT_HELPER_PATH=\"/sbin/hotplug\"\n",
1140 +"CONFIG_STANDALONE=y\n",
1141 +"# CONFIG_PREVENT_FIRMWARE_BUILD is not set\n",
1142 +"CONFIG_FW_LOADER=y\n",
1143 +"# CONFIG_FIRMWARE_IN_KERNEL is not set\n",
1144 +"CONFIG_EXTRA_FIRMWARE=\"\"\n",
1145 +"# CONFIG_SYS_HYPERVISOR is not set\n",
1146 +"# CONFIG_NET is not set\n",
1147 +"\n",
1148 +"#\n",
1149 +"# File systems\n",
1150 +"#\n",
1151 +"# CONFIG_EXT2_FS is not set\n",
1152 +"# CONFIG_EXT3_FS is not set\n",
1153 +"# CONFIG_EXT4_FS is not set\n",
1154 +"# CONFIG_REISERFS_FS is not set\n",
1155 +"# CONFIG_JFS_FS is not set\n",
1156 +"# CONFIG_FS_POSIX_ACL is not set\n",
1157 +"# CONFIG_XFS_FS is not set\n",
1158 +"CONFIG_FILE_LOCKING=y\n",
1159 +"# CONFIG_FSNOTIFY is not set\n",
1160 +"# CONFIG_DNOTIFY is not set\n",
1161 +"# CONFIG_INOTIFY is not set\n",
1162 +"# CONFIG_INOTIFY_USER is not set\n",
1163 +"# CONFIG_QUOTA is not set\n",
1164 +"# CONFIG_AUTOFS_FS is not set\n",
1165 +"# CONFIG_AUTOFS4_FS is not set\n",
1166 +"# CONFIG_FUSE_FS is not set\n",
1167 +"\n",
1168 +"#\n",
1169 +"# Caches\n",
1170 +"#\n",
1171 +"\n",
1172 +"#\n",
1173 +"# CD-ROM/DVD Filesystems\n",
1174 +"#\n",
1175 +"# CONFIG_ISO9660_FS is not set\n",
1176 +"# CONFIG_UDF_FS is not set\n",
1177 +"\n",
1178 +"#\n",
1179 +"# DOS/FAT/NT Filesystems\n",
1180 +"#\n",
1181 +"# CONFIG_MSDOS_FS is not set\n",
1182 +"# CONFIG_VFAT_FS is not set\n",
1183 +"# CONFIG_NTFS_FS is not set\n",
1184 +"\n",
1185 +"#\n",
1186 +"# Pseudo filesystems\n",
1187 +"#\n",
1188 +"CONFIG_PROC_FS=y\n",
1189 +"# CONFIG_PROC_KCORE is not set\n",
1190 +"CONFIG_PROC_SYSCTL=y\n",
1191 +"CONFIG_PROC_PAGE_MONITOR=y\n",
1192 +"CONFIG_SYSFS=y\n",
1193 +"# CONFIG_TMPFS is not set\n",
1194 +"# CONFIG_HUGETLB_PAGE is not set\n",
1195 +"# CONFIG_CONFIGFS_FS is not set\n",
1196 +"# CONFIG_MISC_FILESYSTEMS is not set\n",
1197 +"\n",
1198 +"#\n",
1199 +"# Partition Types\n",
1200 +"#\n",
1201 +"# CONFIG_PARTITION_ADVANCED is not set\n",
1202 +"CONFIG_MSDOS_PARTITION=y\n",
1203 +"# CONFIG_NLS is not set\n",
1204 +"\n",
1205 +"#\n",
1206 +"# Linux VServer\n",
1207 +"#\n",
1208 +"# CONFIG_VSERVER_AUTO_LBACK is not set\n",
1209 +"# CONFIG_VSERVER_COWBL is not set\n",
1210 +"# CONFIG_VSERVER_PROC_SECURE is not set\n",
1211 +"# CONFIG_VSERVER_HARDCPU is not set\n",
1212 +"# CONFIG_TAGGING_NONE is not set\n",
1213 +"# CONFIG_TAGGING_UID16 is not set\n",
1214 +"# CONFIG_TAGGING_GID16 is not set\n",
1215 +"CONFIG_TAGGING_ID24=y\n",
1216 +"# CONFIG_TAGGING_INTERN is not set\n",
1217 +"# CONFIG_TAG_NFSD is not set\n",
1218 +"# CONFIG_VSERVER_PRIVACY is not set\n",
1219 +"CONFIG_VSERVER_CONTEXTS=768\n",
1220 +"# CONFIG_VSERVER_WARN is not set\n",
1221 +"# CONFIG_VSERVER_DEBUG is not set\n",
1222 +"CONFIG_VSERVER=y\n",
1223 +"\n",
1224 +"#\n",
1225 +"# Security options\n",
1226 +"#\n",
1227 +"# CONFIG_KEYS is not set\n",
1228 +"# CONFIG_SECURITY is not set\n",
1229 +"# CONFIG_SECURITYFS is not set\n",
1230 +"# CONFIG_DEFAULT_SECURITY_SELINUX is not set\n",
1231 +"# CONFIG_DEFAULT_SECURITY_SMACK is not set\n",
1232 +"# CONFIG_DEFAULT_SECURITY_TOMOYO is not set\n",
1233 +"CONFIG_DEFAULT_SECURITY_DAC=y\n",
1234 +"CONFIG_DEFAULT_SECURITY=\"\"\n",
1235 +"# CONFIG_CRYPTO is not set\n",
1236 +"# CONFIG_BINARY_PRINTF is not set\n",
1237 +"\n",
1238 +"#\n",
1239 +"# Library routines\n",
1240 +"#\n",
1241 +"CONFIG_GENERIC_FIND_FIRST_BIT=y\n",
1242 +"CONFIG_GENERIC_FIND_NEXT_BIT=y\n",
1243 +"CONFIG_GENERIC_FIND_LAST_BIT=y\n",
1244 +"# CONFIG_CRC_CCITT is not set\n",
1245 +"# CONFIG_CRC16 is not set\n",
1246 +"# CONFIG_CRC_T10DIF is not set\n",
1247 +"# CONFIG_CRC_ITU_T is not set\n",
1248 +"# CONFIG_CRC32 is not set\n",
1249 +"# CONFIG_CRC7 is not set\n",
1250 +"# CONFIG_LIBCRC32C is not set\n",
1251 +"CONFIG_HAS_DMA=y\n",
1252 +"\n",
1253 +"#\n",
1254 +"# SCSI device support\n",
1255 +"#\n",
1256 +"# CONFIG_RAID_ATTRS is not set\n",
1257 +"# CONFIG_SCSI is not set\n",
1258 +"# CONFIG_SCSI_DMA is not set\n",
1259 +"# CONFIG_SCSI_NETLINK is not set\n",
1260 +"# CONFIG_MD is not set\n",
1261 +"# CONFIG_NEW_LEDS is not set\n",
1262 +"# CONFIG_INPUT is not set\n",
1263 +"\n",
1264 +"#\n",
1265 +"# Kernel hacking\n",
1266 +"#\n",
1267 +"# CONFIG_PRINTK_TIME is not set\n",
1268 +"# CONFIG_ENABLE_WARN_DEPRECATED is not set\n",
1269 +"# CONFIG_ENABLE_MUST_CHECK is not set\n",
1270 +"CONFIG_FRAME_WARN=2048\n",
1271 +"# CONFIG_STRIP_ASM_SYMS is not set\n",
1272 +"# CONFIG_UNUSED_SYMBOLS is not set\n",
1273 +"# CONFIG_DEBUG_FS is not set\n",
1274 +"# CONFIG_DEBUG_KERNEL is not set\n",
1275 +"# CONFIG_SLUB_DEBUG_ON is not set\n",
1276 +"# CONFIG_SLUB_STATS is not set\n",
1277 +"CONFIG_DEBUG_BUGVERBOSE=y\n",
1278 +"CONFIG_DEBUG_MEMORY_INIT=y\n",
1279 +"# CONFIG_RCU_CPU_STALL_DETECTOR is not set\n",
1280 +"# CONFIG_SYSCTL_SYSCALL_CHECK is not set\n",
1281 +"# CONFIG_SAMPLES is not set\n",
1282 +"# CONFIG_DEBUG_STACK_USAGE is not set\n",
1283 +""
1284 +};
1285 +
1286 +static int __init print_config(char *line, int *add)
1287 +{
1288 +       int i;
1289 +       for (i = 0; i < sizeof(config)/sizeof(config[0]); i++)
1290 +               printf("%s", config[i]);
1291 +       exit(0);
1292 +}
1293 +
1294 +__uml_setup("--showconfig", print_config,
1295 +"--showconfig\n"
1296 +"    Prints the config file that this UML binary was generated from.\n\n"
1297 +);
1298 +
1299 diff -NurpP --minimal linux-2.6.35/arch/um/kernel/config.tmp linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/config.tmp
1300 --- linux-2.6.35/arch/um/kernel/config.tmp      1970-01-01 01:00:00.000000000 +0100
1301 +++ linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/config.tmp        2010-08-02 17:05:05.000000000 +0200
1302 @@ -0,0 +1,390 @@
1303 +"#\n",
1304 +"# Automatically generated make config: don't edit\n",
1305 +"# Linux kernel version: 2.6.33-vs2.3.0.36.29.1\n",
1306 +"# Wed Mar 10 20:29:46 2010\n",
1307 +"#\n",
1308 +"CONFIG_DEFCONFIG_LIST=\"arch/$ARCH/defconfig\"\n",
1309 +"CONFIG_GENERIC_HARDIRQS=y\n",
1310 +"CONFIG_UML=y\n",
1311 +"CONFIG_MMU=y\n",
1312 +"CONFIG_NO_IOMEM=y\n",
1313 +"# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set\n",
1314 +"CONFIG_LOCKDEP_SUPPORT=y\n",
1315 +"# CONFIG_STACKTRACE_SUPPORT is not set\n",
1316 +"CONFIG_GENERIC_CALIBRATE_DELAY=y\n",
1317 +"CONFIG_GENERIC_BUG=y\n",
1318 +"CONFIG_GENERIC_TIME=y\n",
1319 +"CONFIG_GENERIC_CLOCKEVENTS=y\n",
1320 +"CONFIG_IRQ_RELEASE_METHOD=y\n",
1321 +"CONFIG_HZ=100\n",
1322 +"\n",
1323 +"#\n",
1324 +"# UML-specific options\n",
1325 +"#\n",
1326 +"\n",
1327 +"#\n",
1328 +"# Host processor type and features\n",
1329 +"#\n",
1330 +"# CONFIG_M386 is not set\n",
1331 +"# CONFIG_M486 is not set\n",
1332 +"# CONFIG_M586 is not set\n",
1333 +"# CONFIG_M586TSC is not set\n",
1334 +"# CONFIG_M586MMX is not set\n",
1335 +"# CONFIG_M686 is not set\n",
1336 +"# CONFIG_MPENTIUMII is not set\n",
1337 +"# CONFIG_MPENTIUMIII is not set\n",
1338 +"# CONFIG_MPENTIUMM is not set\n",
1339 +"# CONFIG_MPENTIUM4 is not set\n",
1340 +"# CONFIG_MK6 is not set\n",
1341 +"# CONFIG_MK7 is not set\n",
1342 +"CONFIG_MK8=y\n",
1343 +"# CONFIG_MCRUSOE is not set\n",
1344 +"# CONFIG_MEFFICEON is not set\n",
1345 +"# CONFIG_MWINCHIPC6 is not set\n",
1346 +"# CONFIG_MWINCHIP3D is not set\n",
1347 +"# CONFIG_MGEODEGX1 is not set\n",
1348 +"# CONFIG_MGEODE_LX is not set\n",
1349 +"# CONFIG_MCYRIXIII is not set\n",
1350 +"# CONFIG_MVIAC3_2 is not set\n",
1351 +"# CONFIG_MVIAC7 is not set\n",
1352 +"# CONFIG_MPSC is not set\n",
1353 +"# CONFIG_MCORE2 is not set\n",
1354 +"# CONFIG_MATOM is not set\n",
1355 +"# CONFIG_GENERIC_CPU is not set\n",
1356 +"CONFIG_X86_CPU=y\n",
1357 +"CONFIG_X86_INTERNODE_CACHE_SHIFT=6\n",
1358 +"# CONFIG_X86_CMPXCHG is not set\n",
1359 +"CONFIG_X86_L1_CACHE_SHIFT=6\n",
1360 +"CONFIG_X86_WP_WORKS_OK=y\n",
1361 +"CONFIG_X86_INTEL_USERCOPY=y\n",
1362 +"CONFIG_X86_USE_PPRO_CHECKSUM=y\n",
1363 +"CONFIG_X86_TSC=y\n",
1364 +"CONFIG_X86_CMOV=y\n",
1365 +"CONFIG_X86_MINIMUM_CPU_FAMILY=3\n",
1366 +"CONFIG_CPU_SUP_INTEL=y\n",
1367 +"CONFIG_CPU_SUP_AMD=y\n",
1368 +"CONFIG_CPU_SUP_CENTAUR=y\n",
1369 +"CONFIG_UML_X86=y\n",
1370 +"CONFIG_64BIT=y\n",
1371 +"# CONFIG_X86_32 is not set\n",
1372 +"# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set\n",
1373 +"CONFIG_RWSEM_GENERIC_SPINLOCK=y\n",
1374 +"# CONFIG_ARCH_HAS_SC_SIGNALS is not set\n",
1375 +"# CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA is not set\n",
1376 +"CONFIG_SMP_BROKEN=y\n",
1377 +"CONFIG_GENERIC_HWEIGHT=y\n",
1378 +"# CONFIG_STATIC_LINK is not set\n",
1379 +"CONFIG_FLATMEM=y\n",
1380 +"CONFIG_FLAT_NODE_MEM_MAP=y\n",
1381 +"CONFIG_PAGEFLAGS_EXTENDED=y\n",
1382 +"CONFIG_SPLIT_PTLOCK_CPUS=4\n",
1383 +"CONFIG_PHYS_ADDR_T_64BIT=y\n",
1384 +"CONFIG_ZONE_DMA_FLAG=0\n",
1385 +"CONFIG_VIRT_TO_BUS=y\n",
1386 +"# CONFIG_KSM is not set\n",
1387 +"CONFIG_DEFAULT_MMAP_MIN_ADDR=4096\n",
1388 +"# CONFIG_NO_HZ is not set\n",
1389 +"# CONFIG_HIGH_RES_TIMERS is not set\n",
1390 +"CONFIG_GENERIC_CLOCKEVENTS_BUILD=y\n",
1391 +"CONFIG_LD_SCRIPT_DYN=y\n",
1392 +"# CONFIG_BINFMT_ELF is not set\n",
1393 +"# CONFIG_HAVE_AOUT is not set\n",
1394 +"# CONFIG_BINFMT_MISC is not set\n",
1395 +"# CONFIG_HOSTFS is not set\n",
1396 +"# CONFIG_MCONSOLE is not set\n",
1397 +"CONFIG_KERNEL_STACK_ORDER=1\n",
1398 +"\n",
1399 +"#\n",
1400 +"# General setup\n",
1401 +"#\n",
1402 +"# CONFIG_EXPERIMENTAL is not set\n",
1403 +"CONFIG_BROKEN_ON_SMP=y\n",
1404 +"CONFIG_INIT_ENV_ARG_LIMIT=128\n",
1405 +"CONFIG_LOCALVERSION=\"\"\n",
1406 +"# CONFIG_LOCALVERSION_AUTO is not set\n",
1407 +"# CONFIG_SWAP is not set\n",
1408 +"CONFIG_SYSVIPC=y\n",
1409 +"CONFIG_SYSVIPC_SYSCTL=y\n",
1410 +"# CONFIG_BSD_PROCESS_ACCT is not set\n",
1411 +"\n",
1412 +"#\n",
1413 +"# RCU Subsystem\n",
1414 +"#\n",
1415 +"CONFIG_TREE_RCU=y\n",
1416 +"# CONFIG_TREE_PREEMPT_RCU is not set\n",
1417 +"# CONFIG_TINY_RCU is not set\n",
1418 +"# CONFIG_RCU_TRACE is not set\n",
1419 +"CONFIG_RCU_FANOUT=64\n",
1420 +"# CONFIG_RCU_FANOUT_EXACT is not set\n",
1421 +"# CONFIG_TREE_RCU_TRACE is not set\n",
1422 +"# CONFIG_IKCONFIG is not set\n",
1423 +"CONFIG_LOG_BUF_SHIFT=17\n",
1424 +"# CONFIG_CGROUPS is not set\n",
1425 +"# CONFIG_SYSFS_DEPRECATED_V2 is not set\n",
1426 +"# CONFIG_RELAY is not set\n",
1427 +"CONFIG_NAMESPACES=y\n",
1428 +"CONFIG_UTS_NS=y\n",
1429 +"CONFIG_IPC_NS=y\n",
1430 +"CONFIG_USER_NS=y\n",
1431 +"# CONFIG_BLK_DEV_INITRD is not set\n",
1432 +"# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set\n",
1433 +"CONFIG_SYSCTL=y\n",
1434 +"CONFIG_ANON_INODES=y\n",
1435 +"# CONFIG_EMBEDDED is not set\n",
1436 +"CONFIG_UID16=y\n",
1437 +"CONFIG_SYSCTL_SYSCALL=y\n",
1438 +"CONFIG_KALLSYMS=y\n",
1439 +"# CONFIG_KALLSYMS_EXTRA_PASS is not set\n",
1440 +"CONFIG_HOTPLUG=y\n",
1441 +"CONFIG_PRINTK=y\n",
1442 +"CONFIG_BUG=y\n",
1443 +"CONFIG_ELF_CORE=y\n",
1444 +"CONFIG_BASE_FULL=y\n",
1445 +"CONFIG_FUTEX=y\n",
1446 +"CONFIG_EPOLL=y\n",
1447 +"CONFIG_SIGNALFD=y\n",
1448 +"CONFIG_TIMERFD=y\n",
1449 +"CONFIG_EVENTFD=y\n",
1450 +"CONFIG_SHMEM=y\n",
1451 +"CONFIG_AIO=y\n",
1452 +"\n",
1453 +"#\n",
1454 +"# Kernel Performance Events And Counters\n",
1455 +"#\n",
1456 +"CONFIG_VM_EVENT_COUNTERS=y\n",
1457 +"CONFIG_SLUB_DEBUG=y\n",
1458 +"# CONFIG_COMPAT_BRK is not set\n",
1459 +"# CONFIG_SLAB is not set\n",
1460 +"CONFIG_SLUB=y\n",
1461 +"# CONFIG_SLOB is not set\n",
1462 +"# CONFIG_PROFILING is not set\n",
1463 +"\n",
1464 +"#\n",
1465 +"# GCOV-based kernel profiling\n",
1466 +"#\n",
1467 +"# CONFIG_SLOW_WORK is not set\n",
1468 +"# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set\n",
1469 +"CONFIG_SLABINFO=y\n",
1470 +"CONFIG_RT_MUTEXES=y\n",
1471 +"CONFIG_BASE_SMALL=0\n",
1472 +"# CONFIG_MODULES is not set\n",
1473 +"CONFIG_BLOCK=y\n",
1474 +"# CONFIG_BLK_DEV_BSG is not set\n",
1475 +"# CONFIG_BLK_DEV_INTEGRITY is not set\n",
1476 +"\n",
1477 +"#\n",
1478 +"# IO Schedulers\n",
1479 +"#\n",
1480 +"CONFIG_IOSCHED_NOOP=y\n",
1481 +"# CONFIG_IOSCHED_DEADLINE is not set\n",
1482 +"# CONFIG_IOSCHED_CFQ is not set\n",
1483 +"# CONFIG_DEFAULT_DEADLINE is not set\n",
1484 +"# CONFIG_DEFAULT_CFQ is not set\n",
1485 +"CONFIG_DEFAULT_NOOP=y\n",
1486 +"CONFIG_DEFAULT_IOSCHED=\"noop\"\n",
1487 +"# CONFIG_INLINE_SPIN_TRYLOCK is not set\n",
1488 +"# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set\n",
1489 +"# CONFIG_INLINE_SPIN_LOCK is not set\n",
1490 +"# CONFIG_INLINE_SPIN_LOCK_BH is not set\n",
1491 +"# CONFIG_INLINE_SPIN_LOCK_IRQ is not set\n",
1492 +"# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set\n",
1493 +"CONFIG_INLINE_SPIN_UNLOCK=y\n",
1494 +"# CONFIG_INLINE_SPIN_UNLOCK_BH is not set\n",
1495 +"CONFIG_INLINE_SPIN_UNLOCK_IRQ=y\n",
1496 +"# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set\n",
1497 +"# CONFIG_INLINE_READ_TRYLOCK is not set\n",
1498 +"# CONFIG_INLINE_READ_LOCK is not set\n",
1499 +"# CONFIG_INLINE_READ_LOCK_BH is not set\n",
1500 +"# CONFIG_INLINE_READ_LOCK_IRQ is not set\n",
1501 +"# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set\n",
1502 +"CONFIG_INLINE_READ_UNLOCK=y\n",
1503 +"# CONFIG_INLINE_READ_UNLOCK_BH is not set\n",
1504 +"CONFIG_INLINE_READ_UNLOCK_IRQ=y\n",
1505 +"# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set\n",
1506 +"# CONFIG_INLINE_WRITE_TRYLOCK is not set\n",
1507 +"# CONFIG_INLINE_WRITE_LOCK is not set\n",
1508 +"# CONFIG_INLINE_WRITE_LOCK_BH is not set\n",
1509 +"# CONFIG_INLINE_WRITE_LOCK_IRQ is not set\n",
1510 +"# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set\n",
1511 +"CONFIG_INLINE_WRITE_UNLOCK=y\n",
1512 +"# CONFIG_INLINE_WRITE_UNLOCK_BH is not set\n",
1513 +"CONFIG_INLINE_WRITE_UNLOCK_IRQ=y\n",
1514 +"# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set\n",
1515 +"# CONFIG_MUTEX_SPIN_ON_OWNER is not set\n",
1516 +"# CONFIG_FREEZER is not set\n",
1517 +"# CONFIG_BLK_DEV is not set\n",
1518 +"\n",
1519 +"#\n",
1520 +"# Character Devices\n",
1521 +"#\n",
1522 +"# CONFIG_STDERR_CONSOLE is not set\n",
1523 +"CONFIG_STDIO_CONSOLE=y\n",
1524 +"# CONFIG_SSL is not set\n",
1525 +"# CONFIG_NULL_CHAN is not set\n",
1526 +"# CONFIG_PORT_CHAN is not set\n",
1527 +"# CONFIG_PTY_CHAN is not set\n",
1528 +"# CONFIG_TTY_CHAN is not set\n",
1529 +"# CONFIG_XTERM_CHAN is not set\n",
1530 +"CONFIG_NOCONFIG_CHAN=y\n",
1531 +"CONFIG_CON_ZERO_CHAN=\"fd:0,fd:1\"\n",
1532 +"CONFIG_CON_CHAN=\"xterm\"\n",
1533 +"CONFIG_SSL_CHAN=\"pty\"\n",
1534 +"# CONFIG_UNIX98_PTYS is not set\n",
1535 +"# CONFIG_LEGACY_PTYS is not set\n",
1536 +"# CONFIG_RAW_DRIVER is not set\n",
1537 +"# CONFIG_WATCHDOG is not set\n",
1538 +"# CONFIG_UML_SOUND is not set\n",
1539 +"# CONFIG_SOUND is not set\n",
1540 +"# CONFIG_SOUND_OSS_CORE is not set\n",
1541 +"# CONFIG_HOSTAUDIO is not set\n",
1542 +"# CONFIG_HW_RANDOM is not set\n",
1543 +"# CONFIG_UML_RANDOM is not set\n",
1544 +"# CONFIG_MMAPPER is not set\n",
1545 +"\n",
1546 +"#\n",
1547 +"# Generic Driver Options\n",
1548 +"#\n",
1549 +"CONFIG_UEVENT_HELPER_PATH=\"/sbin/hotplug\"\n",
1550 +"CONFIG_STANDALONE=y\n",
1551 +"# CONFIG_PREVENT_FIRMWARE_BUILD is not set\n",
1552 +"CONFIG_FW_LOADER=y\n",
1553 +"# CONFIG_FIRMWARE_IN_KERNEL is not set\n",
1554 +"CONFIG_EXTRA_FIRMWARE=\"\"\n",
1555 +"# CONFIG_SYS_HYPERVISOR is not set\n",
1556 +"# CONFIG_NET is not set\n",
1557 +"\n",
1558 +"#\n",
1559 +"# File systems\n",
1560 +"#\n",
1561 +"# CONFIG_EXT2_FS is not set\n",
1562 +"# CONFIG_EXT3_FS is not set\n",
1563 +"# CONFIG_EXT4_FS is not set\n",
1564 +"# CONFIG_REISERFS_FS is not set\n",
1565 +"# CONFIG_JFS_FS is not set\n",
1566 +"# CONFIG_FS_POSIX_ACL is not set\n",
1567 +"# CONFIG_XFS_FS is not set\n",
1568 +"CONFIG_FILE_LOCKING=y\n",
1569 +"# CONFIG_FSNOTIFY is not set\n",
1570 +"# CONFIG_DNOTIFY is not set\n",
1571 +"# CONFIG_INOTIFY is not set\n",
1572 +"# CONFIG_INOTIFY_USER is not set\n",
1573 +"# CONFIG_QUOTA is not set\n",
1574 +"# CONFIG_AUTOFS_FS is not set\n",
1575 +"# CONFIG_AUTOFS4_FS is not set\n",
1576 +"# CONFIG_FUSE_FS is not set\n",
1577 +"\n",
1578 +"#\n",
1579 +"# Caches\n",
1580 +"#\n",
1581 +"\n",
1582 +"#\n",
1583 +"# CD-ROM/DVD Filesystems\n",
1584 +"#\n",
1585 +"# CONFIG_ISO9660_FS is not set\n",
1586 +"# CONFIG_UDF_FS is not set\n",
1587 +"\n",
1588 +"#\n",
1589 +"# DOS/FAT/NT Filesystems\n",
1590 +"#\n",
1591 +"# CONFIG_MSDOS_FS is not set\n",
1592 +"# CONFIG_VFAT_FS is not set\n",
1593 +"# CONFIG_NTFS_FS is not set\n",
1594 +"\n",
1595 +"#\n",
1596 +"# Pseudo filesystems\n",
1597 +"#\n",
1598 +"CONFIG_PROC_FS=y\n",
1599 +"# CONFIG_PROC_KCORE is not set\n",
1600 +"CONFIG_PROC_SYSCTL=y\n",
1601 +"CONFIG_PROC_PAGE_MONITOR=y\n",
1602 +"CONFIG_SYSFS=y\n",
1603 +"# CONFIG_TMPFS is not set\n",
1604 +"# CONFIG_HUGETLB_PAGE is not set\n",
1605 +"# CONFIG_CONFIGFS_FS is not set\n",
1606 +"# CONFIG_MISC_FILESYSTEMS is not set\n",
1607 +"\n",
1608 +"#\n",
1609 +"# Partition Types\n",
1610 +"#\n",
1611 +"# CONFIG_PARTITION_ADVANCED is not set\n",
1612 +"CONFIG_MSDOS_PARTITION=y\n",
1613 +"# CONFIG_NLS is not set\n",
1614 +"\n",
1615 +"#\n",
1616 +"# Linux VServer\n",
1617 +"#\n",
1618 +"# CONFIG_VSERVER_AUTO_LBACK is not set\n",
1619 +"# CONFIG_VSERVER_COWBL is not set\n",
1620 +"# CONFIG_VSERVER_PROC_SECURE is not set\n",
1621 +"# CONFIG_VSERVER_HARDCPU is not set\n",
1622 +"# CONFIG_TAGGING_NONE is not set\n",
1623 +"# CONFIG_TAGGING_UID16 is not set\n",
1624 +"# CONFIG_TAGGING_GID16 is not set\n",
1625 +"CONFIG_TAGGING_ID24=y\n",
1626 +"# CONFIG_TAGGING_INTERN is not set\n",
1627 +"# CONFIG_TAG_NFSD is not set\n",
1628 +"# CONFIG_VSERVER_PRIVACY is not set\n",
1629 +"CONFIG_VSERVER_CONTEXTS=768\n",
1630 +"# CONFIG_VSERVER_WARN is not set\n",
1631 +"# CONFIG_VSERVER_DEBUG is not set\n",
1632 +"CONFIG_VSERVER=y\n",
1633 +"\n",
1634 +"#\n",
1635 +"# Security options\n",
1636 +"#\n",
1637 +"# CONFIG_KEYS is not set\n",
1638 +"# CONFIG_SECURITY is not set\n",
1639 +"# CONFIG_SECURITYFS is not set\n",
1640 +"# CONFIG_DEFAULT_SECURITY_SELINUX is not set\n",
1641 +"# CONFIG_DEFAULT_SECURITY_SMACK is not set\n",
1642 +"# CONFIG_DEFAULT_SECURITY_TOMOYO is not set\n",
1643 +"CONFIG_DEFAULT_SECURITY_DAC=y\n",
1644 +"CONFIG_DEFAULT_SECURITY=\"\"\n",
1645 +"# CONFIG_CRYPTO is not set\n",
1646 +"# CONFIG_BINARY_PRINTF is not set\n",
1647 +"\n",
1648 +"#\n",
1649 +"# Library routines\n",
1650 +"#\n",
1651 +"CONFIG_GENERIC_FIND_FIRST_BIT=y\n",
1652 +"CONFIG_GENERIC_FIND_NEXT_BIT=y\n",
1653 +"CONFIG_GENERIC_FIND_LAST_BIT=y\n",
1654 +"# CONFIG_CRC_CCITT is not set\n",
1655 +"# CONFIG_CRC16 is not set\n",
1656 +"# CONFIG_CRC_T10DIF is not set\n",
1657 +"# CONFIG_CRC_ITU_T is not set\n",
1658 +"# CONFIG_CRC32 is not set\n",
1659 +"# CONFIG_CRC7 is not set\n",
1660 +"# CONFIG_LIBCRC32C is not set\n",
1661 +"CONFIG_HAS_DMA=y\n",
1662 +"\n",
1663 +"#\n",
1664 +"# SCSI device support\n",
1665 +"#\n",
1666 +"# CONFIG_RAID_ATTRS is not set\n",
1667 +"# CONFIG_SCSI is not set\n",
1668 +"# CONFIG_SCSI_DMA is not set\n",
1669 +"# CONFIG_SCSI_NETLINK is not set\n",
1670 +"# CONFIG_MD is not set\n",
1671 +"# CONFIG_NEW_LEDS is not set\n",
1672 +"# CONFIG_INPUT is not set\n",
1673 +"\n",
1674 +"#\n",
1675 +"# Kernel hacking\n",
1676 +"#\n",
1677 +"# CONFIG_PRINTK_TIME is not set\n",
1678 +"# CONFIG_ENABLE_WARN_DEPRECATED is not set\n",
1679 +"# CONFIG_ENABLE_MUST_CHECK is not set\n",
1680 +"CONFIG_FRAME_WARN=2048\n",
1681 +"# CONFIG_STRIP_ASM_SYMS is not set\n",
1682 +"# CONFIG_UNUSED_SYMBOLS is not set\n",
1683 +"# CONFIG_DEBUG_FS is not set\n",
1684 +"# CONFIG_DEBUG_KERNEL is not set\n",
1685 +"# CONFIG_SLUB_DEBUG_ON is not set\n",
1686 +"# CONFIG_SLUB_STATS is not set\n",
1687 +"CONFIG_DEBUG_BUGVERBOSE=y\n",
1688 +"CONFIG_DEBUG_MEMORY_INIT=y\n",
1689 +"# CONFIG_RCU_CPU_STALL_DETECTOR is not set\n",
1690 +"# CONFIG_SYSCTL_SYSCALL_CHECK is not set\n",
1691 +"# CONFIG_SAMPLES is not set\n",
1692 +"# CONFIG_DEBUG_STACK_USAGE is not set\n",
1693 diff -NurpP --minimal linux-2.6.35/arch/um/kernel/vmlinux.lds linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/vmlinux.lds
1694 --- linux-2.6.35/arch/um/kernel/vmlinux.lds     1970-01-01 01:00:00.000000000 +0100
1695 +++ linux-2.6.35-vs2.3.0.36.31/arch/um/kernel/vmlinux.lds       2010-08-02 17:05:05.000000000 +0200
1696 @@ -0,0 +1,547 @@
1697 +
1698 +
1699 +/*
1700 + * Automatically generated C config: don't edit
1701 + * Linux kernel version: 2.6.33-vs2.3.0.36.29.1
1702 + * Wed Mar 10 20:12:10 2010
1703 + */
1704 +KERNEL_STACK_SIZE = 4096 * (1 << 1);
1705 +/*
1706 + * Helper macros to support writing architecture specific
1707 + * linker scripts.
1708 + *
1709 + * A minimal linker scripts has following content:
1710 + * [This is a sample, architectures may have special requiriements]
1711 + *
1712 + * OUTPUT_FORMAT(...)
1713 + * OUTPUT_ARCH(...)
1714 + * ENTRY(...)
1715 + * SECTIONS
1716 + * {
1717 + *     . = START;
1718 + *     __init_begin = .;
1719 + *     HEAD_TEXT_SECTION
1720 + *     INIT_TEXT_SECTION(PAGE_SIZE)
1721 + *     INIT_DATA_SECTION(...)
1722 + *     PERCPU(PAGE_SIZE)
1723 + *     __init_end = .;
1724 + *
1725 + *     _stext = .;
1726 + *     TEXT_SECTION = 0
1727 + *     _etext = .;
1728 + *
1729 + *      _sdata = .;
1730 + *     RO_DATA_SECTION(PAGE_SIZE)
1731 + *     RW_DATA_SECTION(...)
1732 + *     _edata = .;
1733 + *
1734 + *     EXCEPTION_TABLE(...)
1735 + *     NOTES
1736 + *
1737 + *     BSS_SECTION(0, 0, 0)
1738 + *     _end = .;
1739 + *
1740 + *     STABS_DEBUG
1741 + *     DWARF_DEBUG
1742 + *
1743 + *     DISCARDS                // must be the last
1744 + * }
1745 + *
1746 + * [__init_begin, __init_end] is the init section that may be freed after init
1747 + * [_stext, _etext] is the text section
1748 + * [_sdata, _edata] is the data section
1749 + *
1750 + * Some of the included output section have their own set of constants.
1751 + * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
1752 + *               [__nosave_begin, __nosave_end] for the nosave data
1753 + */
1754 +
1755 +
1756 +
1757 +
1758 +
1759 +
1760 +
1761 +/* Align . to a 8 byte boundary equals to maximum function alignment. */
1762 +
1763 +
1764 +/* The actual configuration determine if the init/exit sections
1765 + * are handled as text/data or they can be discarded (which
1766 + * often happens at runtime)
1767 + */
1768 +/* .data section */
1769 +/*
1770 + * Data section helpers
1771 + */
1772 +/*
1773 + * Read only Data
1774 + */
1775 +/* RODATA & RO_DATA provided for backward compatibility.
1776 + * All archs are supposed to use RO_DATA() */
1777 +/* .text section. Map to function alignment to avoid address changes
1778 + * during second ld run in second ld pass when generating System.map */
1779 +/* sched.text is aling to function alignment to secure we have same
1780 + * address even at second ld pass when generating System.map */
1781 +/* spinlock.text is aling to function alignment to secure we have same
1782 + * address even at second ld pass when generating System.map */
1783 +/* Section used for early init (in .S files) */
1784 +/*
1785 + * Exception table
1786 + */
1787 +/*
1788 + * Init task
1789 + */
1790 +/* init and exit section handling */
1791 +/*
1792 + * bss (Block Started by Symbol) - uninitialized data
1793 + * zeroed during startup
1794 + */
1795 +/*
1796 + * DWARF debug sections.
1797 + * Symbols in the DWARF debugging sections are relative to
1798 + * the beginning of the section so we begin them at 0.
1799 + */
1800 +  /* Stabs debugging sections.  */
1801 +/*
1802 + * Default discarded sections.
1803 + *
1804 + * Some archs want to discard exit text/data at runtime rather than
1805 + * link time due to cross-section references such as alt instructions,
1806 + * bug table, eh_frame, etc.  DISCARDS must be the last of output
1807 + * section definitions so that such archs put those in earlier section
1808 + * definitions.
1809 + */
1810 +/**
1811 + * PERCPU_VADDR - define output section for percpu area
1812 + * @vaddr: explicit base address (optional)
1813 + * @phdr: destination PHDR (optional)
1814 + *
1815 + * Macro which expands to output section for percpu area.  If @vaddr
1816 + * is not blank, it specifies explicit base address and all percpu
1817 + * symbols will be offset from the given address.  If blank, @vaddr
1818 + * always equals @laddr + LOAD_OFFSET.
1819 + *
1820 + * @phdr defines the output PHDR to use if not blank.  Be warned that
1821 + * output PHDR is sticky.  If @phdr is specified, the next output
1822 + * section in the linker script will go there too.  @phdr should have
1823 + * a leading colon.
1824 + *
1825 + * Note that this macros defines __per_cpu_load as an absolute symbol.
1826 + * If there is no need to put the percpu section at a predetermined
1827 + * address, use PERCPU().
1828 + */
1829 +/**
1830 + * PERCPU - define output section for percpu area, simple version
1831 + * @align: required alignment
1832 + *
1833 + * Align to @align and outputs output section for percpu area.  This
1834 + * macro doesn't maniuplate @vaddr or @phdr and __per_cpu_load and
1835 + * __per_cpu_start will be identical.
1836 + *
1837 + * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except
1838 + * that __per_cpu_load is defined as a relative symbol against
1839 + * .data.percpu which is required for relocatable x86_32
1840 + * configuration.
1841 + */
1842 +/*
1843 + * Definition of the high level *_SECTION macros
1844 + * They will fit only a subset of the architectures
1845 + */
1846 +/*
1847 + * Writeable data.
1848 + * All sections are combined in a single .data section.
1849 + * The sections following CONSTRUCTORS are arranged so their
1850 + * typical alignment matches.
1851 + * A cacheline is typical/always less than a PAGE_SIZE so
1852 + * the sections that has this restriction (or similar)
1853 + * is located before the ones requiring PAGE_SIZE alignment.
1854 + * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
1855 + * matches the requirment of PAGE_ALIGNED_DATA.
1856 + *
1857 + * use 0 as page_align if page_aligned data is not used */
1858 +/*
1859 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
1860 + * Copyright 2003 PathScale, Inc.
1861 + * Licensed under the GPL
1862 + */
1863 +/* const.h: Macros for dealing with constants.  */
1864 +/* Some constant macros are used in both assembler and
1865 + * C code.  Therefore we cannot annotate them always with
1866 + * 'UL' and other type specifiers unilaterally.  We
1867 + * use the following macros to deal with this.
1868 + *
1869 + * Similarly, _AT() will cast an expression with a type in C, but
1870 + * leave it unchanged in asm.
1871 + */
1872 +/* PAGE_SHIFT determines the page size */
1873 +OUTPUT_FORMAT(elf64-x86-64)
1874 +OUTPUT_ARCH(i386:x86-64)
1875 +ENTRY(_start)
1876 +jiffies = jiffies_64;
1877 +SECTIONS
1878 +{
1879 +  PROVIDE (__executable_start = 0x60000000);
1880 +  . = 0x60000000 + SIZEOF_HEADERS;
1881 +  .interp : { *(.interp) }
1882 +  __binary_start = .;
1883 +  . = ALIGN(4096); /* Init code and data */
1884 +  _text = .;
1885 +  _stext = .;
1886 +  __init_begin = .;
1887 +  . = ALIGN((1 << 12)); .init.text : AT(ADDR(.init.text) - 0) { _sinittext = .; *(.init.text) *(.cpuinit.text) *(.meminit.text) _einittext = .; }
1888 +  . = ALIGN((1 << 12));
1889 +  /* Read-only sections, merged into text segment: */
1890 +  .hash : { *(.hash) }
1891 +  .gnu.hash : { *(.gnu.hash) }
1892 +  .dynsym : { *(.dynsym) }
1893 +  .dynstr : { *(.dynstr) }
1894 +  .gnu.version : { *(.gnu.version) }
1895 +  .gnu.version_d : { *(.gnu.version_d) }
1896 +  .gnu.version_r : { *(.gnu.version_r) }
1897 +  .rel.init : { *(.rel.init) }
1898 +  .rela.init : { *(.rela.init) }
1899 +  .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
1900 +  .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
1901 +  .rel.fini : { *(.rel.fini) }
1902 +  .rela.fini : { *(.rela.fini) }
1903 +  .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
1904 +  .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
1905 +  .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
1906 +  .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
1907 +  .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
1908 +  .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
1909 +  .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
1910 +  .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
1911 +  .rel.ctors : { *(.rel.ctors) }
1912 +  .rela.ctors : { *(.rela.ctors) }
1913 +  .rel.dtors : { *(.rel.dtors) }
1914 +  .rela.dtors : { *(.rela.dtors) }
1915 +  .rel.got : { *(.rel.got) }
1916 +  .rela.got : { *(.rela.got) }
1917 +  .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
1918 +  .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
1919 +  .rel.plt : { *(.rel.plt) }
1920 +  .rela.plt : { *(.rela.plt) }
1921 +  .init : {
1922 +    KEEP (*(.init))
1923 +  } =0x90909090
1924 +  .plt : { *(.plt) }
1925 +  .text : {
1926 +    . = ALIGN(8); *(.text.hot) *(.text) *(.ref.text) *(.devinit.text) *(.devexit.text) *(.text.unlikely)
1927 +    . = ALIGN(8); __sched_text_start = .; *(.sched.text) __sched_text_end = .;
1928 +    . = ALIGN(8); __lock_text_start = .; *(.spinlock.text) __lock_text_end = .;
1929 +    *(.fixup)
1930 +    *(.stub .text.* .gnu.linkonce.t.*)
1931 +    /* .gnu.warning sections are handled specially by elf32.em.  */
1932 +    *(.gnu.warning)
1933 +    . = ALIGN((1 << 12));
1934 +  } =0x90909090
1935 +  . = ALIGN((1 << 12));
1936 +  .syscall_stub : {
1937 + __syscall_stub_start = .;
1938 + *(.__syscall_stub*)
1939 + __syscall_stub_end = .;
1940 +  }
1941 +  .fini : {
1942 +    KEEP (*(.fini))
1943 +  } =0x90909090
1944 +  .kstrtab : { *(.kstrtab) }
1945 +/*
1946 + * Helper macros to support writing architecture specific
1947 + * linker scripts.
1948 + *
1949 + * A minimal linker scripts has following content:
1950 + * [This is a sample, architectures may have special requiriements]
1951 + *
1952 + * OUTPUT_FORMAT(...)
1953 + * OUTPUT_ARCH(...)
1954 + * ENTRY(...)
1955 + * SECTIONS
1956 + * {
1957 + *     . = START;
1958 + *     __init_begin = .;
1959 + *     HEAD_TEXT_SECTION
1960 + *     INIT_TEXT_SECTION(PAGE_SIZE)
1961 + *     INIT_DATA_SECTION(...)
1962 + *     PERCPU(PAGE_SIZE)
1963 + *     __init_end = .;
1964 + *
1965 + *     _stext = .;
1966 + *     TEXT_SECTION = 0
1967 + *     _etext = .;
1968 + *
1969 + *      _sdata = .;
1970 + *     RO_DATA_SECTION(PAGE_SIZE)
1971 + *     RW_DATA_SECTION(...)
1972 + *     _edata = .;
1973 + *
1974 + *     EXCEPTION_TABLE(...)
1975 + *     NOTES
1976 + *
1977 + *     BSS_SECTION(0, 0, 0)
1978 + *     _end = .;
1979 + *
1980 + *     STABS_DEBUG
1981 + *     DWARF_DEBUG
1982 + *
1983 + *     DISCARDS                // must be the last
1984 + * }
1985 + *
1986 + * [__init_begin, __init_end] is the init section that may be freed after init
1987 + * [_stext, _etext] is the text section
1988 + * [_sdata, _edata] is the data section
1989 + *
1990 + * Some of the included output section have their own set of constants.
1991 + * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
1992 + *               [__nosave_begin, __nosave_end] for the nosave data
1993 + */
1994 +/* Align . to a 8 byte boundary equals to maximum function alignment. */
1995 +/* The actual configuration determine if the init/exit sections
1996 + * are handled as text/data or they can be discarded (which
1997 + * often happens at runtime)
1998 + */
1999 +/* .data section */
2000 +/*
2001 + * Data section helpers
2002 + */
2003 +/*
2004 + * Read only Data
2005 + */
2006 +/* RODATA & RO_DATA provided for backward compatibility.
2007 + * All archs are supposed to use RO_DATA() */
2008 +/* .text section. Map to function alignment to avoid address changes
2009 + * during second ld run in second ld pass when generating System.map */
2010 +/* sched.text is aling to function alignment to secure we have same
2011 + * address even at second ld pass when generating System.map */
2012 +/* spinlock.text is aling to function alignment to secure we have same
2013 + * address even at second ld pass when generating System.map */
2014 +/* Section used for early init (in .S files) */
2015 +/*
2016 + * Exception table
2017 + */
2018 +/*
2019 + * Init task
2020 + */
2021 +/* init and exit section handling */
2022 +/*
2023 + * bss (Block Started by Symbol) - uninitialized data
2024 + * zeroed during startup
2025 + */
2026 +/*
2027 + * DWARF debug sections.
2028 + * Symbols in the DWARF debugging sections are relative to
2029 + * the beginning of the section so we begin them at 0.
2030 + */
2031 +  /* Stabs debugging sections.  */
2032 +/*
2033 + * Default discarded sections.
2034 + *
2035 + * Some archs want to discard exit text/data at runtime rather than
2036 + * link time due to cross-section references such as alt instructions,
2037 + * bug table, eh_frame, etc.  DISCARDS must be the last of output
2038 + * section definitions so that such archs put those in earlier section
2039 + * definitions.
2040 + */
2041 +/**
2042 + * PERCPU_VADDR - define output section for percpu area
2043 + * @vaddr: explicit base address (optional)
2044 + * @phdr: destination PHDR (optional)
2045 + *
2046 + * Macro which expands to output section for percpu area.  If @vaddr
2047 + * is not blank, it specifies explicit base address and all percpu
2048 + * symbols will be offset from the given address.  If blank, @vaddr
2049 + * always equals @laddr + LOAD_OFFSET.
2050 + *
2051 + * @phdr defines the output PHDR to use if not blank.  Be warned that
2052 + * output PHDR is sticky.  If @phdr is specified, the next output
2053 + * section in the linker script will go there too.  @phdr should have
2054 + * a leading colon.
2055 + *
2056 + * Note that this macros defines __per_cpu_load as an absolute symbol.
2057 + * If there is no need to put the percpu section at a predetermined
2058 + * address, use PERCPU().
2059 + */
2060 +/**
2061 + * PERCPU - define output section for percpu area, simple version
2062 + * @align: required alignment
2063 + *
2064 + * Align to @align and outputs output section for percpu area.  This
2065 + * macro doesn't maniuplate @vaddr or @phdr and __per_cpu_load and
2066 + * __per_cpu_start will be identical.
2067 + *
2068 + * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except
2069 + * that __per_cpu_load is defined as a relative symbol against
2070 + * .data.percpu which is required for relocatable x86_32
2071 + * configuration.
2072 + */
2073 +/*
2074 + * Definition of the high level *_SECTION macros
2075 + * They will fit only a subset of the architectures
2076 + */
2077 +/*
2078 + * Writeable data.
2079 + * All sections are combined in a single .data section.
2080 + * The sections following CONSTRUCTORS are arranged so their
2081 + * typical alignment matches.
2082 + * A cacheline is typical/always less than a PAGE_SIZE so
2083 + * the sections that has this restriction (or similar)
2084 + * is located before the ones requiring PAGE_SIZE alignment.
2085 + * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
2086 + * matches the requirment of PAGE_ALIGNED_DATA.
2087 + *
2088 + * use 0 as page_align if page_aligned data is not used */
2089 +  .fini : { *(.fini) } =0x9090
2090 +  _etext = .;
2091 +  PROVIDE (etext = .);
2092 +  . = ALIGN(4096);
2093 +  _sdata = .;
2094 +  PROVIDE (sdata = .);
2095 +  . = ALIGN((4096)); .rodata : AT(ADDR(.rodata) - 0) { __start_rodata = .; *(.rodata) *(.rodata.*) *(__vermagic) *(__markers_strings) *(__tracepoints_strings) } .rodata1 : AT(ADDR(.rodata1) - 0) { *(.rodata1) } . = ALIGN(8); __bug_table : AT(ADDR(__bug_table) - 0) { __start___bug_table = .; *(__bug_table) __stop___bug_table = .; } .pci_fixup : AT(ADDR(.pci_fixup) - 0) { __start_pci_fixups_early = .; *(.pci_fixup_early) __end_pci_fixups_early = .; __start_pci_fixups_header = .; *(.pci_fixup_header) __end_pci_fixups_header = .; __start_pci_fixups_final = .; *(.pci_fixup_final) __end_pci_fixups_final = .; __start_pci_fixups_enable = .; *(.pci_fixup_enable) __end_pci_fixups_enable = .; __start_pci_fixups_resume = .; *(.pci_fixup_resume) __end_pci_fixups_resume = .; __start_pci_fixups_resume_early = .; *(.pci_fixup_resume_early) __end_pci_fixups_resume_early = .; __start_pci_fixups_suspend = .; *(.pci_fixup_suspend) __end_pci_fixups_suspend = .; } .builtin_fw : AT(ADDR(.builtin_fw) - 0) { __start_builtin_fw = .; *(.builtin_fw) __end_builtin_fw = .; } .rio_route : AT(ADDR(.rio_route) - 0) { __start_rio_route_ops = .; *(.rio_route_ops) __end_rio_route_ops = .; } __ksymtab : AT(ADDR(__ksymtab) - 0) { __start___ksymtab = .; *(__ksymtab) __stop___ksymtab = .; } __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - 0) { __start___ksymtab_gpl = .; *(__ksymtab_gpl) __stop___ksymtab_gpl = .; } __ksymtab_unused : AT(ADDR(__ksymtab_unused) - 0) { __start___ksymtab_unused = .; *(__ksymtab_unused) __stop___ksymtab_unused = .; } __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - 0) { __start___ksymtab_unused_gpl = .; *(__ksymtab_unused_gpl) __stop___ksymtab_unused_gpl = .; } __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - 0) { __start___ksymtab_gpl_future = .; *(__ksymtab_gpl_future) __stop___ksymtab_gpl_future = .; } __kcrctab : AT(ADDR(__kcrctab) - 0) { __start___kcrctab = .; *(__kcrctab) __stop___kcrctab = .; } __kcrctab_gpl : AT(ADDR(__kcrctab_gpl) - 0) { __start___kcrctab_gpl = .; *(__kcrctab_gpl) __stop___kcrctab_gpl = .; } __kcrctab_unused : AT(ADDR(__kcrctab_unused) - 0) { __start___kcrctab_unused = .; *(__kcrctab_unused) __stop___kcrctab_unused = .; } __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - 0) { __start___kcrctab_unused_gpl = .; *(__kcrctab_unused_gpl) __stop___kcrctab_unused_gpl = .; } __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - 0) { __start___kcrctab_gpl_future = .; *(__kcrctab_gpl_future) __stop___kcrctab_gpl_future = .; } __ksymtab_strings : AT(ADDR(__ksymtab_strings) - 0) { *(__ksymtab_strings) } __init_rodata : AT(ADDR(__init_rodata) - 0) { *(.ref.rodata) *(.devinit.rodata) *(.devexit.rodata) } __param : AT(ADDR(__param) - 0) { __start___param = .; *(__param) __stop___param = .; . = ALIGN((4096)); __end_rodata = .; } . = ALIGN((4096));
2096 +  .unprotected : { *(.unprotected) }
2097 +  . = ALIGN(4096);
2098 +  PROVIDE (_unprotected_end = .);
2099 +  . = ALIGN(4096);
2100 +  .note : { *(.note.*) }
2101 +  . = ALIGN(0); __ex_table : AT(ADDR(__ex_table) - 0) { __start___ex_table = .; *(__ex_table) __stop___ex_table = .; }
2102 +  . = ALIGN(8); __bug_table : AT(ADDR(__bug_table) - 0) { __start___bug_table = .; *(__bug_table) __stop___bug_table = .; }
2103 +  .uml.setup.init : {
2104 + __uml_setup_start = .;
2105 + *(.uml.setup.init)
2106 + __uml_setup_end = .;
2107 +  }
2108 +  .uml.help.init : {
2109 + __uml_help_start = .;
2110 + *(.uml.help.init)
2111 + __uml_help_end = .;
2112 +  }
2113 +  .uml.postsetup.init : {
2114 + __uml_postsetup_start = .;
2115 + *(.uml.postsetup.init)
2116 + __uml_postsetup_end = .;
2117 +  }
2118 +  .init.setup : {
2119 + . = ALIGN(0); __setup_start = .; *(.init.setup) __setup_end = .;
2120 +  }
2121 +  . = ALIGN(32); .data.percpu : AT(ADDR(.data.percpu) - 0) { __per_cpu_load = .; __per_cpu_start = .; *(.data.percpu.first) *(.data.percpu.page_aligned) *(.data.percpu) *(.data.percpu.shared_aligned) __per_cpu_end = .; }
2122 +  .initcall.init : {
2123 + __initcall_start = .; *(.initcallearly.init) __early_initcall_end = .; *(.initcall0.init) *(.initcall0s.init) *(.initcall1.init) *(.initcall1s.init) *(.initcall2.init) *(.initcall2s.init) *(.initcall3.init) *(.initcall3s.init) *(.initcall4.init) *(.initcall4s.init) *(.initcall5.init) *(.initcall5s.init) *(.initcallrootfs.init) *(.initcall6.init) *(.initcall6s.init) *(.initcall7.init) *(.initcall7s.init) __initcall_end = .;
2124 +  }
2125 +  .con_initcall.init : {
2126 + __con_initcall_start = .; *(.con_initcall.init) __con_initcall_end = .;
2127 +  }
2128 +  .uml.initcall.init : {
2129 + __uml_initcall_start = .;
2130 + *(.uml.initcall.init)
2131 + __uml_initcall_end = .;
2132 +  }
2133 +  __init_end = .;
2134 +  .security_initcall.init : AT(ADDR(.security_initcall.init) - 0) { __security_initcall_start = .; *(.security_initcall.init) __security_initcall_end = .; }
2135 +  .exitcall : {
2136 + __exitcall_begin = .;
2137 + *(.exitcall.exit)
2138 + __exitcall_end = .;
2139 +  }
2140 +  .uml.exitcall : {
2141 + __uml_exitcall_begin = .;
2142 + *(.uml.exitcall.exit)
2143 + __uml_exitcall_end = .;
2144 +  }
2145 +  . = ALIGN(4);
2146 +  .altinstructions : {
2147 + __alt_instructions = .;
2148 + *(.altinstructions)
2149 + __alt_instructions_end = .;
2150 +  }
2151 +  .altinstr_replacement : { *(.altinstr_replacement) }
2152 +  /* .exit.text is discard at runtime, not link time, to deal with references
2153 +     from .altinstructions and .eh_frame */
2154 +  .exit.text : { *(.exit.text) }
2155 +  .exit.data : { *(.exit.data) }
2156 +  .preinit_array : {
2157 + __preinit_array_start = .;
2158 + *(.preinit_array)
2159 + __preinit_array_end = .;
2160 +  }
2161 +  .init_array : {
2162 + __init_array_start = .;
2163 + *(.init_array)
2164 + __init_array_end = .;
2165 +  }
2166 +  .fini_array : {
2167 + __fini_array_start = .;
2168 + *(.fini_array)
2169 + __fini_array_end = .;
2170 +  }
2171 +   . = ALIGN(4096);
2172 +  .init.ramfs : {
2173 +
2174 +  }
2175 +  init.data : { *(.init.data) *(.cpuinit.data) *(.meminit.data) *(.init.rodata) *(.cpuinit.rodata) *(.meminit.rodata) }
2176 +  /* Ensure the __preinit_array_start label is properly aligned.  We
2177 +     could instead move the label definition inside the section, but
2178 +     the linker would then create the section even if it turns out to
2179 +     be empty, which isn't pretty.  */
2180 +  . = ALIGN(32 / 8);
2181 +  .preinit_array : { *(.preinit_array) }
2182 +  .init_array : { *(.init_array) }
2183 +  .fini_array : { *(.fini_array) }
2184 +  .data : {
2185 +    . = ALIGN(KERNEL_STACK_SIZE); *(.data.init_task)
2186 +    . = ALIGN(KERNEL_STACK_SIZE);
2187 +    *(.data.init_irqstack)
2188 +    *(.data) *(.ref.data) *(.devinit.data) *(.devexit.data) . = ALIGN(8); __start___markers = .; *(__markers) __stop___markers = .; . = ALIGN(32); __start___tracepoints = .; *(__tracepoints) __stop___tracepoints = .; . = ALIGN(8); __start___verbose = .; *(__verbose) __stop___verbose = .;
2189 +    *(.data.* .gnu.linkonce.d.*)
2190 +    SORT(CONSTRUCTORS)
2191 +  }
2192 +  .data1 : { *(.data1) }
2193 +  .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
2194 +  .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
2195 +  .eh_frame : { KEEP (*(.eh_frame)) }
2196 +  .gcc_except_table : { *(.gcc_except_table) }
2197 +  .dynamic : { *(.dynamic) }
2198 +  .ctors : {
2199 +    /* gcc uses crtbegin.o to find the start of
2200 +       the constructors, so we make sure it is
2201 +       first.  Because this is a wildcard, it
2202 +       doesn't matter if the user does not
2203 +       actually link against crtbegin.o; the
2204 +       linker won't look for a file to match a
2205 +       wildcard.  The wildcard also means that it
2206 +       doesn't matter which directory crtbegin.o
2207 +       is in.  */
2208 +    KEEP (*crtbegin.o(.ctors))
2209 +    /* We don't want to include the .ctor section from
2210 +       from the crtend.o file until after the sorted ctors.
2211 +       The .ctor section from the crtend file contains the
2212 +       end of ctors marker and it must be last */
2213 +    KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
2214 +    KEEP (*(SORT(.ctors.*)))
2215 +    KEEP (*(.ctors))
2216 +  }
2217 +  .dtors : {
2218 +    KEEP (*crtbegin.o(.dtors))
2219 +    KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
2220 +    KEEP (*(SORT(.dtors.*)))
2221 +    KEEP (*(.dtors))
2222 +  }
2223 +  .jcr : { KEEP (*(.jcr)) }
2224 +  .got : { *(.got.plt) *(.got) }
2225 +  _edata = .;
2226 +  PROVIDE (edata = .);
2227 +  .bss : {
2228 +   __bss_start = .;
2229 +   *(.dynbss)
2230 +   *(.bss .bss.* .gnu.linkonce.b.*)
2231 +   *(COMMON)
2232 +   /* Align here to ensure that the .bss section occupies space up to
2233 +      _end.  Align after .bss to ensure correct alignment even if the
2234 +      .bss section disappears because there are no input sections.  */
2235 +   . = ALIGN(32 / 8);
2236 +  . = ALIGN(32 / 8);
2237 +  }
2238 +  _end = .;
2239 +  PROVIDE (end = .);
2240 +  .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } .stab.excl 0 : { *(.stab.excl) } .stab.exclstr 0 : { *(.stab.exclstr) } .stab.index 0 : { *(.stab.index) } .stab.indexstr 0 : { *(.stab.indexstr) } .comment 0 : { *(.comment) }
2241 +  .debug 0 : { *(.debug) } .line 0 : { *(.line) } .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) }
2242 +  /DISCARD/ : { *(.exit.text) *(.cpuexit.text) *(.memexit.text) *(.exit.data) *(.cpuexit.data) *(.cpuexit.rodata) *(.memexit.data) *(.memexit.rodata) *(.exitcall.exit) *(.discard) }
2243 +}
2244 diff -NurpP --minimal linux-2.6.35/arch/x86/ia32/ia32entry.S linux-2.6.35-vs2.3.0.36.31/arch/x86/ia32/ia32entry.S
2245 --- linux-2.6.35/arch/x86/ia32/ia32entry.S      2010-07-07 18:31:11.000000000 +0200
2246 +++ linux-2.6.35-vs2.3.0.36.31/arch/x86/ia32/ia32entry.S        2010-08-02 17:05:05.000000000 +0200
2247 @@ -777,7 +777,7 @@ ia32_sys_call_table:
2248         .quad sys_tgkill                /* 270 */
2249         .quad compat_sys_utimes
2250         .quad sys32_fadvise64_64
2251 -       .quad quiet_ni_syscall  /* sys_vserver */
2252 +       .quad sys32_vserver
2253         .quad sys_mbind
2254         .quad compat_sys_get_mempolicy  /* 275 */
2255         .quad sys_set_mempolicy
2256 diff -NurpP --minimal linux-2.6.35/arch/x86/include/asm/unistd_64.h linux-2.6.35-vs2.3.0.36.31/arch/x86/include/asm/unistd_64.h
2257 --- linux-2.6.35/arch/x86/include/asm/unistd_64.h       2010-07-07 18:31:11.000000000 +0200
2258 +++ linux-2.6.35-vs2.3.0.36.31/arch/x86/include/asm/unistd_64.h 2010-08-02 17:05:05.000000000 +0200
2259 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
2260  #define __NR_utimes                            235
2261  __SYSCALL(__NR_utimes, sys_utimes)
2262  #define __NR_vserver                           236
2263 -__SYSCALL(__NR_vserver, sys_ni_syscall)
2264 +__SYSCALL(__NR_vserver, sys_vserver)
2265  #define __NR_mbind                             237
2266  __SYSCALL(__NR_mbind, sys_mbind)
2267  #define __NR_set_mempolicy                     238
2268 diff -NurpP --minimal linux-2.6.35/arch/x86/Kconfig linux-2.6.35-vs2.3.0.36.31/arch/x86/Kconfig
2269 --- linux-2.6.35/arch/x86/Kconfig       2010-08-02 16:52:11.000000000 +0200
2270 +++ linux-2.6.35-vs2.3.0.36.31/arch/x86/Kconfig 2010-08-02 17:05:05.000000000 +0200
2271 @@ -2123,6 +2123,8 @@ source "fs/Kconfig"
2272  
2273  source "arch/x86/Kconfig.debug"
2274  
2275 +source "kernel/vserver/Kconfig"
2276 +
2277  source "security/Kconfig"
2278  
2279  source "crypto/Kconfig"
2280 diff -NurpP --minimal linux-2.6.35/arch/x86/kernel/syscall_table_32.S linux-2.6.35-vs2.3.0.36.31/arch/x86/kernel/syscall_table_32.S
2281 --- linux-2.6.35/arch/x86/kernel/syscall_table_32.S     2010-07-07 18:31:12.000000000 +0200
2282 +++ linux-2.6.35-vs2.3.0.36.31/arch/x86/kernel/syscall_table_32.S       2010-08-02 17:05:05.000000000 +0200
2283 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
2284         .long sys_tgkill        /* 270 */
2285         .long sys_utimes
2286         .long sys_fadvise64_64
2287 -       .long sys_ni_syscall    /* sys_vserver */
2288 +       .long sys_vserver
2289         .long sys_mbind
2290         .long sys_get_mempolicy
2291         .long sys_set_mempolicy
2292 diff -NurpP --minimal linux-2.6.35/Documentation/vserver/debug.txt linux-2.6.35-vs2.3.0.36.31/Documentation/vserver/debug.txt
2293 --- linux-2.6.35/Documentation/vserver/debug.txt        1970-01-01 01:00:00.000000000 +0100
2294 +++ linux-2.6.35-vs2.3.0.36.31/Documentation/vserver/debug.txt  2010-08-02 17:05:05.000000000 +0200
2295 @@ -0,0 +1,154 @@
2296 +
2297 +debug_cvirt:
2298 +
2299 + 2   4 "vx_map_tgid: %p/%llx: %d -> %d"
2300 +       "vx_rmap_tgid: %p/%llx: %d -> %d"
2301 +
2302 +debug_dlim:
2303 +
2304 + 0   1 "ALLOC (%p,#%d)%c inode (%d)"
2305 +       "FREE  (%p,#%d)%c inode"
2306 + 1   2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
2307 +       "FREE  (%p,#%d)%c %lld bytes"
2308 + 2   4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
2309 + 3   8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
2310 +       "ext3_has_free_blocks(%p): free=%lu, root=%lu"
2311 +       "rcu_free_dl_info(%p)"
2312 + 4  10 "alloc_dl_info(%p,%d) = %p"
2313 +       "dealloc_dl_info(%p)"
2314 +       "get_dl_info(%p[#%d.%d])"
2315 +       "put_dl_info(%p[#%d.%d])"
2316 + 5  20 "alloc_dl_info(%p,%d)*"
2317 + 6  40 "__hash_dl_info: %p[#%d]"
2318 +       "__unhash_dl_info: %p[#%d]"
2319 + 7  80 "locate_dl_info(%p,#%d) = %p"
2320 +
2321 +debug_misc:
2322 +
2323 + 0   1 "destroy_dqhash: %p [#0x%08x] c=%d"
2324 +       "new_dqhash: %p [#0x%08x]"
2325 +       "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
2326 +       "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
2327 +       "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
2328 +       "vroot_get_real_bdev not set"
2329 + 1   2 "cow_break_link(»%s«)"
2330 +       "temp copy Â»%s«"
2331 + 2   4 "dentry_open(new): %p"
2332 +       "dentry_open(old): %p"
2333 +       "lookup_create(new): %p"
2334 +       "old path Â»%s«"
2335 +       "path_lookup(old): %d"
2336 +       "vfs_create(new): %d"
2337 +       "vfs_rename: %d"
2338 +       "vfs_sendfile: %d"
2339 + 3   8 "fput(new_file=%p[#%d])"
2340 +       "fput(old_file=%p[#%d])"
2341 + 4  10 "vx_info_kill(%p[#%d],%d,%d) = %d"
2342 +       "vx_info_kill(%p[#%d],%d,%d)*"
2343 + 5  20 "vs_reboot(%p[#%d],%d)"
2344 + 6  40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
2345 +
2346 +debug_net:
2347 +
2348 + 2   4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
2349 + 3   8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
2350 +       "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
2351 + 4  10 "ip_route_connect(%p) %p,%p;%lx"
2352 + 5  20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
2353 + 6  40 "sk,egf: %p [#%d] (from %d)"
2354 +       "sk,egn: %p [#%d] (from %d)"
2355 +       "sk,req: %p [#%d] (from %d)"
2356 +       "sk: %p [#%d] (from %d)"
2357 +       "tw: %p [#%d] (from %d)"
2358 + 7  80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
2359 +       "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
2360 +
2361 +debug_nid:
2362 +
2363 + 0   1 "__lookup_nx_info(#%u): %p[#%u]"
2364 +       "alloc_nx_info(%d) = %p"
2365 +       "create_nx_info(%d) (dynamic rejected)"
2366 +       "create_nx_info(%d) = %p (already there)"
2367 +       "create_nx_info(%d) = %p (new)"
2368 +       "dealloc_nx_info(%p)"
2369 + 1   2 "alloc_nx_info(%d)*"
2370 +       "create_nx_info(%d)*"
2371 + 2   4 "get_nx_info(%p[#%d.%d])"
2372 +       "put_nx_info(%p[#%d.%d])"
2373 + 3   8 "claim_nx_info(%p[#%d.%d.%d]) %p"
2374 +       "clr_nx_info(%p[#%d.%d])"
2375 +       "init_nx_info(%p[#%d.%d])"
2376 +       "release_nx_info(%p[#%d.%d.%d]) %p"
2377 +       "set_nx_info(%p[#%d.%d])"
2378 + 4  10 "__hash_nx_info: %p[#%d]"
2379 +       "__nx_dynamic_id: [#%d]"
2380 +       "__unhash_nx_info: %p[#%d.%d.%d]"
2381 + 5  20 "moved task %p into nxi:%p[#%d]"
2382 +       "nx_migrate_task(%p,%p[#%d.%d.%d])"
2383 +       "task_get_nx_info(%p)"
2384 + 6  40 "nx_clear_persistent(%p[#%d])"
2385 +
2386 +debug_quota:
2387 +
2388 + 0   1 "quota_sync_dqh(%p,%d) discard inode %p"
2389 + 1   2 "quota_sync_dqh(%p,%d)"
2390 +       "sync_dquots(%p,%d)"
2391 +       "sync_dquots_dqh(%p,%d)"
2392 + 3   8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
2393 +
2394 +debug_switch:
2395 +
2396 + 0   1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
2397 + 1   2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
2398 + 4  10 "%s: (%s %s) returned %s with %d"
2399 +
2400 +debug_tag:
2401 +
2402 + 7  80 "dx_parse_tag(»%s«): %d:#%d"
2403 +       "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
2404 +
2405 +debug_xid:
2406 +
2407 + 0   1 "__lookup_vx_info(#%u): %p[#%u]"
2408 +       "alloc_vx_info(%d) = %p"
2409 +       "alloc_vx_info(%d)*"
2410 +       "create_vx_info(%d) (dynamic rejected)"
2411 +       "create_vx_info(%d) = %p (already there)"
2412 +       "create_vx_info(%d) = %p (new)"
2413 +       "dealloc_vx_info(%p)"
2414 +       "loc_vx_info(%d) = %p (found)"
2415 +       "loc_vx_info(%d) = %p (new)"
2416 +       "loc_vx_info(%d) = %p (not available)"
2417 + 1   2 "create_vx_info(%d)*"
2418 +       "loc_vx_info(%d)*"
2419 + 2   4 "get_vx_info(%p[#%d.%d])"
2420 +       "put_vx_info(%p[#%d.%d])"
2421 + 3   8 "claim_vx_info(%p[#%d.%d.%d]) %p"
2422 +       "clr_vx_info(%p[#%d.%d])"
2423 +       "init_vx_info(%p[#%d.%d])"
2424 +       "release_vx_info(%p[#%d.%d.%d]) %p"
2425 +       "set_vx_info(%p[#%d.%d])"
2426 + 4  10 "__hash_vx_info: %p[#%d]"
2427 +       "__unhash_vx_info: %p[#%d.%d.%d]"
2428 +       "__vx_dynamic_id: [#%d]"
2429 + 5  20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
2430 +       "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
2431 +       "moved task %p into vxi:%p[#%d]"
2432 +       "task_get_vx_info(%p)"
2433 +       "vx_migrate_task(%p,%p[#%d.%d])"
2434 + 6  40 "vx_clear_persistent(%p[#%d])"
2435 +       "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
2436 +       "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
2437 +       "vx_set_persistent(%p[#%d])"
2438 +       "vx_set_reaper(%p[#%d],%p[#%d,%d])"
2439 + 7  80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
2440 +
2441 +
2442 +debug_limit:
2443 +
2444 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
2445 +       "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
2446 +
2447 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
2448 +       "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
2449 +       "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
2450 diff -NurpP --minimal linux-2.6.35/drivers/block/Kconfig linux-2.6.35-vs2.3.0.36.31/drivers/block/Kconfig
2451 --- linux-2.6.35/drivers/block/Kconfig  2010-08-02 16:52:14.000000000 +0200
2452 +++ linux-2.6.35-vs2.3.0.36.31/drivers/block/Kconfig    2010-08-02 17:05:05.000000000 +0200
2453 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
2454  
2455  source "drivers/block/drbd/Kconfig"
2456  
2457 +config BLK_DEV_VROOT
2458 +       tristate "Virtual Root device support"
2459 +       depends on QUOTACTL
2460 +       ---help---
2461 +         Saying Y here will allow you to use quota/fs ioctls on a shared
2462 +         partition within a virtual server without compromising security.
2463 +
2464  config BLK_DEV_NBD
2465         tristate "Network block device support"
2466         depends on NET
2467 diff -NurpP --minimal linux-2.6.35/drivers/block/loop.c linux-2.6.35-vs2.3.0.36.31/drivers/block/loop.c
2468 --- linux-2.6.35/drivers/block/loop.c   2010-08-02 16:52:14.000000000 +0200
2469 +++ linux-2.6.35-vs2.3.0.36.31/drivers/block/loop.c     2010-08-02 17:05:05.000000000 +0200
2470 @@ -73,6 +73,7 @@
2471  #include <linux/highmem.h>
2472  #include <linux/kthread.h>
2473  #include <linux/splice.h>
2474 +#include <linux/vs_context.h>
2475  
2476  #include <asm/uaccess.h>
2477  
2478 @@ -813,6 +814,7 @@ static int loop_set_fd(struct loop_devic
2479         lo->lo_blocksize = lo_blocksize;
2480         lo->lo_device = bdev;
2481         lo->lo_flags = lo_flags;
2482 +       lo->lo_xid = vx_current_xid();
2483         lo->lo_backing_file = file;
2484         lo->transfer = transfer_none;
2485         lo->ioctl = NULL;
2486 @@ -941,6 +943,7 @@ static int loop_clr_fd(struct loop_devic
2487         lo->lo_encrypt_key_size = 0;
2488         lo->lo_flags = 0;
2489         lo->lo_thread = NULL;
2490 +       lo->lo_xid = 0;
2491         memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2492         memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2493         memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2494 @@ -978,7 +981,7 @@ loop_set_status(struct loop_device *lo, 
2495  
2496         if (lo->lo_encrypt_key_size &&
2497             lo->lo_key_owner != uid &&
2498 -           !capable(CAP_SYS_ADMIN))
2499 +           !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2500                 return -EPERM;
2501         if (lo->lo_state != Lo_bound)
2502                 return -ENXIO;
2503 @@ -1062,7 +1065,8 @@ loop_get_status(struct loop_device *lo, 
2504         memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2505         info->lo_encrypt_type =
2506                 lo->lo_encryption ? lo->lo_encryption->number : 0;
2507 -       if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2508 +       if (lo->lo_encrypt_key_size &&
2509 +               vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2510                 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2511                 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2512                        lo->lo_encrypt_key_size);
2513 @@ -1408,6 +1412,9 @@ static int lo_open(struct block_device *
2514  {
2515         struct loop_device *lo = bdev->bd_disk->private_data;
2516  
2517 +       if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
2518 +               return -EACCES;
2519 +
2520         mutex_lock(&lo->lo_ctl_mutex);
2521         lo->lo_refcnt++;
2522         mutex_unlock(&lo->lo_ctl_mutex);
2523 diff -NurpP --minimal linux-2.6.35/drivers/block/Makefile linux-2.6.35-vs2.3.0.36.31/drivers/block/Makefile
2524 --- linux-2.6.35/drivers/block/Makefile 2010-02-25 11:51:36.000000000 +0100
2525 +++ linux-2.6.35-vs2.3.0.36.31/drivers/block/Makefile   2010-08-02 17:05:05.000000000 +0200
2526 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD)         += viodasd.o
2527  obj-$(CONFIG_BLK_DEV_SX8)      += sx8.o
2528  obj-$(CONFIG_BLK_DEV_UB)       += ub.o
2529  obj-$(CONFIG_BLK_DEV_HD)       += hd.o
2530 +obj-$(CONFIG_BLK_DEV_VROOT)    += vroot.o
2531  
2532  obj-$(CONFIG_XEN_BLKDEV_FRONTEND)      += xen-blkfront.o
2533  obj-$(CONFIG_BLK_DEV_DRBD)     += drbd/
2534 diff -NurpP --minimal linux-2.6.35/drivers/block/vroot.c linux-2.6.35-vs2.3.0.36.31/drivers/block/vroot.c
2535 --- linux-2.6.35/drivers/block/vroot.c  1970-01-01 01:00:00.000000000 +0100
2536 +++ linux-2.6.35-vs2.3.0.36.31/drivers/block/vroot.c    2010-08-02 17:05:05.000000000 +0200
2537 @@ -0,0 +1,282 @@
2538 +/*
2539 + *  linux/drivers/block/vroot.c
2540 + *
2541 + *  written by Herbert Pötzl, 9/11/2002
2542 + *  ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2543 + *
2544 + *  based on the loop.c code by Theodore Ts'o.
2545 + *
2546 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2547 + * Redistribution of this file is permitted under the
2548 + * GNU General Public License.
2549 + *
2550 + */
2551 +
2552 +#include <linux/module.h>
2553 +#include <linux/moduleparam.h>
2554 +#include <linux/file.h>
2555 +#include <linux/major.h>
2556 +#include <linux/blkdev.h>
2557 +#include <linux/slab.h>
2558 +
2559 +#include <linux/vroot.h>
2560 +#include <linux/vs_context.h>
2561 +
2562 +
2563 +static int max_vroot = 8;
2564 +
2565 +static struct vroot_device *vroot_dev;
2566 +static struct gendisk **disks;
2567 +
2568 +
2569 +static int vroot_set_dev(
2570 +       struct vroot_device *vr,
2571 +       struct block_device *bdev,
2572 +       unsigned int arg)
2573 +{
2574 +       struct block_device *real_bdev;
2575 +       struct file *file;
2576 +       struct inode *inode;
2577 +       int error;
2578 +
2579 +       error = -EBUSY;
2580 +       if (vr->vr_state != Vr_unbound)
2581 +               goto out;
2582 +
2583 +       error = -EBADF;
2584 +       file = fget(arg);
2585 +       if (!file)
2586 +               goto out;
2587 +
2588 +       error = -EINVAL;
2589 +       inode = file->f_dentry->d_inode;
2590 +
2591 +
2592 +       if (S_ISBLK(inode->i_mode)) {
2593 +               real_bdev = inode->i_bdev;
2594 +               vr->vr_device = real_bdev;
2595 +               __iget(real_bdev->bd_inode);
2596 +       } else
2597 +               goto out_fput;
2598 +
2599 +       vxdprintk(VXD_CBIT(misc, 0),
2600 +               "vroot[%d]_set_dev: dev=" VXF_DEV,
2601 +               vr->vr_number, VXD_DEV(real_bdev));
2602 +
2603 +       vr->vr_state = Vr_bound;
2604 +       error = 0;
2605 +
2606 + out_fput:
2607 +       fput(file);
2608 + out:
2609 +       return error;
2610 +}
2611 +
2612 +static int vroot_clr_dev(
2613 +       struct vroot_device *vr,
2614 +       struct block_device *bdev)
2615 +{
2616 +       struct block_device *real_bdev;
2617 +
2618 +       if (vr->vr_state != Vr_bound)
2619 +               return -ENXIO;
2620 +       if (vr->vr_refcnt > 1)  /* we needed one fd for the ioctl */
2621 +               return -EBUSY;
2622 +
2623 +       real_bdev = vr->vr_device;
2624 +
2625 +       vxdprintk(VXD_CBIT(misc, 0),
2626 +               "vroot[%d]_clr_dev: dev=" VXF_DEV,
2627 +               vr->vr_number, VXD_DEV(real_bdev));
2628 +
2629 +       bdput(real_bdev);
2630 +       vr->vr_state = Vr_unbound;
2631 +       vr->vr_device = NULL;
2632 +       return 0;
2633 +}
2634 +
2635 +
2636 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
2637 +       unsigned int cmd, unsigned long arg)
2638 +{
2639 +       struct vroot_device *vr = bdev->bd_disk->private_data;
2640 +       int err;
2641 +
2642 +       down(&vr->vr_ctl_mutex);
2643 +       switch (cmd) {
2644 +       case VROOT_SET_DEV:
2645 +               err = vroot_set_dev(vr, bdev, arg);
2646 +               break;
2647 +       case VROOT_CLR_DEV:
2648 +               err = vroot_clr_dev(vr, bdev);
2649 +               break;
2650 +       default:
2651 +               err = -EINVAL;
2652 +               break;
2653 +       }
2654 +       up(&vr->vr_ctl_mutex);
2655 +       return err;
2656 +}
2657 +
2658 +static int vr_open(struct block_device *bdev, fmode_t mode)
2659 +{
2660 +       struct vroot_device *vr = bdev->bd_disk->private_data;
2661 +
2662 +       down(&vr->vr_ctl_mutex);
2663 +       vr->vr_refcnt++;
2664 +       up(&vr->vr_ctl_mutex);
2665 +       return 0;
2666 +}
2667 +
2668 +static int vr_release(struct gendisk *disk, fmode_t mode)
2669 +{
2670 +       struct vroot_device *vr = disk->private_data;
2671 +
2672 +       down(&vr->vr_ctl_mutex);
2673 +       --vr->vr_refcnt;
2674 +       up(&vr->vr_ctl_mutex);
2675 +       return 0;
2676 +}
2677 +
2678 +static struct block_device_operations vr_fops = {
2679 +       .owner =        THIS_MODULE,
2680 +       .open =         vr_open,
2681 +       .release =      vr_release,
2682 +       .ioctl =        vr_ioctl,
2683 +};
2684 +
2685 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2686 +{
2687 +       struct inode *inode = bdev->bd_inode;
2688 +       struct vroot_device *vr;
2689 +       struct block_device *real_bdev;
2690 +       int minor = iminor(inode);
2691 +
2692 +       vr = &vroot_dev[minor];
2693 +       real_bdev = vr->vr_device;
2694 +
2695 +       vxdprintk(VXD_CBIT(misc, 0),
2696 +               "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2697 +               vr->vr_number, VXD_DEV(real_bdev));
2698 +
2699 +       if (vr->vr_state != Vr_bound)
2700 +               return ERR_PTR(-ENXIO);
2701 +
2702 +       __iget(real_bdev->bd_inode);
2703 +       return real_bdev;
2704 +}
2705 +
2706 +/*
2707 + * And now the modules code and kernel interface.
2708 + */
2709 +
2710 +module_param(max_vroot, int, 0);
2711 +
2712 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
2713 +MODULE_LICENSE("GPL");
2714 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
2715 +
2716 +MODULE_AUTHOR ("Herbert Pötzl");
2717 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
2718 +
2719 +
2720 +int __init vroot_init(void)
2721 +{
2722 +       int err, i;
2723 +
2724 +       if (max_vroot < 1 || max_vroot > 256) {
2725 +               max_vroot = MAX_VROOT_DEFAULT;
2726 +               printk(KERN_WARNING "vroot: invalid max_vroot "
2727 +                       "(must be between 1 and 256), "
2728 +                       "using default (%d)\n", max_vroot);
2729 +       }
2730 +
2731 +       if (register_blkdev(VROOT_MAJOR, "vroot"))
2732 +               return -EIO;
2733 +
2734 +       err = -ENOMEM;
2735 +       vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2736 +       if (!vroot_dev)
2737 +               goto out_mem1;
2738 +       memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2739 +
2740 +       disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2741 +       if (!disks)
2742 +               goto out_mem2;
2743 +
2744 +       for (i = 0; i < max_vroot; i++) {
2745 +               disks[i] = alloc_disk(1);
2746 +               if (!disks[i])
2747 +                       goto out_mem3;
2748 +               disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
2749 +               if (!disks[i]->queue)
2750 +                       goto out_mem3;
2751 +       }
2752 +
2753 +       for (i = 0; i < max_vroot; i++) {
2754 +               struct vroot_device *vr = &vroot_dev[i];
2755 +               struct gendisk *disk = disks[i];
2756 +
2757 +               memset(vr, 0, sizeof(*vr));
2758 +               init_MUTEX(&vr->vr_ctl_mutex);
2759 +               vr->vr_number = i;
2760 +               disk->major = VROOT_MAJOR;
2761 +               disk->first_minor = i;
2762 +               disk->fops = &vr_fops;
2763 +               sprintf(disk->disk_name, "vroot%d", i);
2764 +               disk->private_data = vr;
2765 +       }
2766 +
2767 +       err = register_vroot_grb(&__vroot_get_real_bdev);
2768 +       if (err)
2769 +               goto out_mem3;
2770 +
2771 +       for (i = 0; i < max_vroot; i++)
2772 +               add_disk(disks[i]);
2773 +       printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2774 +       return 0;
2775 +
2776 +out_mem3:
2777 +       while (i--)
2778 +               put_disk(disks[i]);
2779 +       kfree(disks);
2780 +out_mem2:
2781 +       kfree(vroot_dev);
2782 +out_mem1:
2783 +       unregister_blkdev(VROOT_MAJOR, "vroot");
2784 +       printk(KERN_ERR "vroot: ran out of memory\n");
2785 +       return err;
2786 +}
2787 +
2788 +void vroot_exit(void)
2789 +{
2790 +       int i;
2791 +
2792 +       if (unregister_vroot_grb(&__vroot_get_real_bdev))
2793 +               printk(KERN_WARNING "vroot: cannot unregister grb\n");
2794 +
2795 +       for (i = 0; i < max_vroot; i++) {
2796 +               del_gendisk(disks[i]);
2797 +               put_disk(disks[i]);
2798 +       }
2799 +       unregister_blkdev(VROOT_MAJOR, "vroot");
2800 +
2801 +       kfree(disks);
2802 +       kfree(vroot_dev);
2803 +}
2804 +
2805 +module_init(vroot_init);
2806 +module_exit(vroot_exit);
2807 +
2808 +#ifndef MODULE
2809 +
2810 +static int __init max_vroot_setup(char *str)
2811 +{
2812 +       max_vroot = simple_strtol(str, NULL, 0);
2813 +       return 1;
2814 +}
2815 +
2816 +__setup("max_vroot=", max_vroot_setup);
2817 +
2818 +#endif
2819 +
2820 diff -NurpP --minimal linux-2.6.35/drivers/char/sysrq.c linux-2.6.35-vs2.3.0.36.31/drivers/char/sysrq.c
2821 --- linux-2.6.35/drivers/char/sysrq.c   2010-08-02 16:52:15.000000000 +0200
2822 +++ linux-2.6.35-vs2.3.0.36.31/drivers/char/sysrq.c     2010-08-02 17:39:50.000000000 +0200
2823 @@ -42,6 +42,7 @@
2824  #include <linux/oom.h>
2825  #include <linux/slab.h>
2826  #include <linux/input.h>
2827 +#include <linux/vserver/debug.h>
2828  
2829  #include <asm/ptrace.h>
2830  #include <asm/irq_regs.h>
2831 @@ -396,6 +397,21 @@ static struct sysrq_key_op sysrq_unrt_op
2832         .enable_mask    = SYSRQ_ENABLE_RTNICE,
2833  };
2834  
2835 +
2836 +#ifdef CONFIG_VSERVER_DEBUG
2837 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
2838 +{
2839 +       dump_vx_info_inactive((key == 'x')?0:1);
2840 +}
2841 +
2842 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2843 +       .handler        = sysrq_handle_vxinfo,
2844 +       .help_msg       = "conteXt",
2845 +       .action_msg     = "Show Context Info",
2846 +       .enable_mask    = SYSRQ_ENABLE_DUMP,
2847 +};
2848 +#endif
2849 +
2850  /* Key Operations table and lock */
2851  static DEFINE_SPINLOCK(sysrq_key_table_lock);
2852  
2853 @@ -450,7 +466,11 @@ static struct sysrq_key_op *sysrq_key_ta
2854         NULL,                           /* v */
2855         &sysrq_showstate_blocked_op,    /* w */
2856         /* x: May be registered on ppc/powerpc for xmon */
2857 +#ifdef CONFIG_VSERVER_DEBUG
2858 +       &sysrq_showvxinfo_op,           /* x */
2859 +#else
2860         NULL,                           /* x */
2861 +#endif
2862         /* y: May be registered on sparc64 for global register dump */
2863         NULL,                           /* y */
2864         &sysrq_ftrace_dump_op,          /* z */
2865 @@ -465,6 +485,8 @@ static int sysrq_key_table_key2index(int
2866                 retval = key - '0';
2867         else if ((key >= 'a') && (key <= 'z'))
2868                 retval = key + 10 - 'a';
2869 +       else if ((key >= 'A') && (key <= 'Z'))
2870 +               retval = key + 10 - 'A';
2871         else
2872                 retval = -1;
2873         return retval;
2874 diff -NurpP --minimal linux-2.6.35/drivers/char/tty_io.c linux-2.6.35-vs2.3.0.36.31/drivers/char/tty_io.c
2875 --- linux-2.6.35/drivers/char/tty_io.c  2010-07-07 18:31:15.000000000 +0200
2876 +++ linux-2.6.35-vs2.3.0.36.31/drivers/char/tty_io.c    2010-08-02 17:05:05.000000000 +0200
2877 @@ -106,6 +106,7 @@
2878  
2879  #include <linux/kmod.h>
2880  #include <linux/nsproxy.h>
2881 +#include <linux/vs_pid.h>
2882  
2883  #undef TTY_DEBUG_HANGUP
2884  
2885 @@ -1992,7 +1993,8 @@ static int tiocsti(struct tty_struct *tt
2886         char ch, mbz = 0;
2887         struct tty_ldisc *ld;
2888  
2889 -       if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
2890 +       if (((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN)) ||
2891 +               !vx_ccaps(VXC_TIOCSTI))
2892                 return -EPERM;
2893         if (get_user(ch, p))
2894                 return -EFAULT;
2895 @@ -2280,6 +2282,7 @@ static int tiocspgrp(struct tty_struct *
2896                 return -ENOTTY;
2897         if (get_user(pgrp_nr, p))
2898                 return -EFAULT;
2899 +       pgrp_nr = vx_rmap_pid(pgrp_nr);
2900         if (pgrp_nr < 0)
2901                 return -EINVAL;
2902         rcu_read_lock();
2903 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r100_reg_safe.h
2904 --- linux-2.6.35/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
2905 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r100_reg_safe.h   2010-08-02 17:05:05.000000000 +0200
2906 @@ -0,0 +1,28 @@
2907 +static const unsigned r100_reg_safe_bm[102] = {
2908 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2909 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2910 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2911 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2912 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2913 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2914 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2915 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2916 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2917 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2918 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
2919 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
2920 +       0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2921 +       0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2922 +       0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
2923 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2924 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
2925 +       0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
2926 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2927 +       0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2928 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2929 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2930 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2931 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2932 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2933 +       0xFFFFFFFF, 0xFFFFFFEF,
2934 +};
2935 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r200_reg_safe.h
2936 --- linux-2.6.35/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
2937 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r200_reg_safe.h   2010-08-02 17:05:05.000000000 +0200
2938 @@ -0,0 +1,28 @@
2939 +static const unsigned r200_reg_safe_bm[102] = {
2940 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2941 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2942 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2943 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2944 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2945 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2946 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2947 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2948 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2949 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2950 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
2951 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
2952 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2953 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2954 +       0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
2955 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2956 +       0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
2957 +       0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
2958 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2959 +       0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2960 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2961 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2962 +       0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
2963 +       0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
2964 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2965 +       0xFFFFFE3F, 0xFFFFFFEF,
2966 +};
2967 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r300_reg_safe.h
2968 --- linux-2.6.35/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
2969 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r300_reg_safe.h   2010-08-02 17:05:05.000000000 +0200
2970 @@ -0,0 +1,42 @@
2971 +static const unsigned r300_reg_safe_bm[159] = {
2972 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2973 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2974 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2975 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2976 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2977 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2978 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2979 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2980 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2981 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2982 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
2983 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
2984 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2985 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2986 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
2987 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2988 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
2989 +       0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
2990 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2991 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2992 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2993 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2994 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2995 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2996 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2997 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2998 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2999 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3000 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3001 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3002 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3003 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3004 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3005 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3006 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3007 +       0x00000000, 0x0000C100, 0x00000000, 0x00000000,
3008 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3009 +       0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
3010 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3011 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3012 +};
3013 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r420_reg_safe.h
3014 --- linux-2.6.35/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3015 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/r420_reg_safe.h   2010-08-02 17:05:05.000000000 +0200
3016 @@ -0,0 +1,42 @@
3017 +static const unsigned r420_reg_safe_bm[159] = {
3018 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3019 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3020 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3021 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3022 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3023 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3024 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3025 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3026 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3027 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3028 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3029 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3030 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3031 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3032 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3033 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3034 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3035 +       0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3036 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3037 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3038 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3039 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3040 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3041 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3042 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3043 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3044 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3045 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3046 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3047 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3048 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3049 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3050 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3051 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3052 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3053 +       0x00000000, 0x00000100, 0x00000000, 0x00000000,
3054 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3055 +       0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3056 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3057 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3058 +};
3059 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rn50_reg_safe.h
3060 --- linux-2.6.35/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3061 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rn50_reg_safe.h   2010-08-02 17:05:05.000000000 +0200
3062 @@ -0,0 +1,28 @@
3063 +static const unsigned rn50_reg_safe_bm[102] = {
3064 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3065 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3066 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3067 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3068 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3069 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3070 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3071 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3072 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3073 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3074 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3075 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3076 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3077 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3078 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3079 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3080 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3081 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3082 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3083 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3084 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3085 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3086 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3087 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3088 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3089 +       0xFFFFFFFF, 0xFFFFFFFF,
3090 +};
3091 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rs600_reg_safe.h
3092 --- linux-2.6.35/drivers/gpu/drm/radeon/rs600_reg_safe.h        1970-01-01 01:00:00.000000000 +0100
3093 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rs600_reg_safe.h  2010-08-02 17:05:05.000000000 +0200
3094 @@ -0,0 +1,57 @@
3095 +static const unsigned rs600_reg_safe_bm[219] = {
3096 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3097 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3098 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3099 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3100 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3101 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3102 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3103 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3104 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3105 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3106 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3107 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3108 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3109 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3110 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3111 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3112 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3113 +       0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3114 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3115 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3116 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3117 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3118 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3119 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3120 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3121 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3122 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3123 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3124 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3125 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3126 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3127 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3128 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3129 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3130 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3131 +       0x00000000, 0x00000100, 0x00000000, 0x00000000,
3132 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3133 +       0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3134 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3135 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
3136 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3137 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3138 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3139 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3140 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3141 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3142 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3143 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3144 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3145 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3146 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3147 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3148 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3149 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3150 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3151 +};
3152 diff -NurpP --minimal linux-2.6.35/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rv515_reg_safe.h
3153 --- linux-2.6.35/drivers/gpu/drm/radeon/rv515_reg_safe.h        1970-01-01 01:00:00.000000000 +0100
3154 +++ linux-2.6.35-vs2.3.0.36.31/drivers/gpu/drm/radeon/rv515_reg_safe.h  2010-08-02 17:05:05.000000000 +0200
3155 @@ -0,0 +1,57 @@
3156 +static const unsigned rv515_reg_safe_bm[219] = {
3157 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3158 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3159 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3160 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3161 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3162 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3163 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3164 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3165 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3166 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3167 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3168 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3169 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3170 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3171 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3172 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3173 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3174 +       0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3175 +       0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
3176 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3177 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3178 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3179 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3180 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3181 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3182 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3183 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3184 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3185 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3186 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3187 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3188 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3189 +       0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
3190 +       0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
3191 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3192 +       0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
3193 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3194 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
3195 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3196 +       0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
3197 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3198 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3199 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3200 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3201 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3202 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3203 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3204 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3205 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3206 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3207 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3208 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3209 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3210 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3211 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3212 +};
3213 diff -NurpP --minimal linux-2.6.35/drivers/infiniband/core/addr.c linux-2.6.35-vs2.3.0.36.31/drivers/infiniband/core/addr.c
3214 --- linux-2.6.35/drivers/infiniband/core/addr.c 2010-07-07 18:31:18.000000000 +0200
3215 +++ linux-2.6.35-vs2.3.0.36.31/drivers/infiniband/core/addr.c   2010-08-02 17:05:05.000000000 +0200
3216 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
3217  
3218         if (ipv6_addr_any(&fl.fl6_src)) {
3219                 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
3220 -                                        &fl.fl6_dst, 0, &fl.fl6_src);
3221 +                                        &fl.fl6_dst, 0, &fl.fl6_src, NULL);
3222                 if (ret)
3223                         goto put;
3224  
3225 diff -NurpP --minimal linux-2.6.35/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.35-vs2.3.0.36.31/drivers/infiniband/hw/ipath/ipath_user_pages.c
3226 --- linux-2.6.35/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-07-07 18:31:19.000000000 +0200
3227 +++ linux-2.6.35-vs2.3.0.36.31/drivers/infiniband/hw/ipath/ipath_user_pages.c   2010-08-02 17:05:05.000000000 +0200
3228 @@ -35,6 +35,7 @@
3229  #include <linux/device.h>
3230  #include <linux/slab.h>
3231  #include <linux/sched.h>
3232 +#include <linux/vs_memory.h>
3233  
3234  #include "ipath_kernel.h"
3235  
3236 diff -NurpP --minimal linux-2.6.35/drivers/md/dm.c linux-2.6.35-vs2.3.0.36.31/drivers/md/dm.c
3237 --- linux-2.6.35/drivers/md/dm.c        2010-07-07 18:31:21.000000000 +0200
3238 +++ linux-2.6.35-vs2.3.0.36.31/drivers/md/dm.c  2010-08-02 17:05:05.000000000 +0200
3239 @@ -19,6 +19,7 @@
3240  #include <linux/slab.h>
3241  #include <linux/idr.h>
3242  #include <linux/hdreg.h>
3243 +#include <linux/vs_base.h>
3244  
3245  #include <trace/events/block.h>
3246  
3247 @@ -119,6 +120,7 @@ struct mapped_device {
3248         rwlock_t map_lock;
3249         atomic_t holders;
3250         atomic_t open_count;
3251 +       xid_t xid;
3252  
3253         unsigned long flags;
3254  
3255 @@ -337,6 +339,7 @@ int dm_deleting_md(struct mapped_device 
3256  static int dm_blk_open(struct block_device *bdev, fmode_t mode)
3257  {
3258         struct mapped_device *md;
3259 +       int ret = -ENXIO;
3260  
3261         spin_lock(&_minor_lock);
3262  
3263 @@ -345,18 +348,19 @@ static int dm_blk_open(struct block_devi
3264                 goto out;
3265  
3266         if (test_bit(DMF_FREEING, &md->flags) ||
3267 -           dm_deleting_md(md)) {
3268 -               md = NULL;
3269 +           dm_deleting_md(md))
3270 +               goto out;
3271 +
3272 +       ret = -EACCES;
3273 +       if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
3274                 goto out;
3275 -       }
3276  
3277         dm_get(md);
3278         atomic_inc(&md->open_count);
3279 -
3280 +       ret = 0;
3281  out:
3282         spin_unlock(&_minor_lock);
3283 -
3284 -       return md ? 0 : -ENXIO;
3285 +       return ret;
3286  }
3287  
3288  static int dm_blk_close(struct gendisk *disk, fmode_t mode)
3289 @@ -574,6 +578,14 @@ int dm_set_geometry(struct mapped_device
3290         return 0;
3291  }
3292  
3293 +/*
3294 + * Get the xid associated with a dm device
3295 + */
3296 +xid_t dm_get_xid(struct mapped_device *md)
3297 +{
3298 +       return md->xid;
3299 +}
3300 +
3301  /*-----------------------------------------------------------------
3302   * CRUD START:
3303   *   A more elegant soln is in the works that uses the queue
3304 @@ -1886,6 +1898,7 @@ static struct mapped_device *alloc_dev(i
3305         INIT_LIST_HEAD(&md->uevent_list);
3306         spin_lock_init(&md->uevent_lock);
3307  
3308 +       md->xid = vx_current_xid();
3309         md->queue = blk_init_queue(dm_request_fn, NULL);
3310         if (!md->queue)
3311                 goto bad_queue;
3312 diff -NurpP --minimal linux-2.6.35/drivers/md/dm.h linux-2.6.35-vs2.3.0.36.31/drivers/md/dm.h
3313 --- linux-2.6.35/drivers/md/dm.h        2010-07-07 18:31:21.000000000 +0200
3314 +++ linux-2.6.35-vs2.3.0.36.31/drivers/md/dm.h  2010-08-02 17:05:05.000000000 +0200
3315 @@ -41,6 +41,8 @@ struct dm_dev_internal {
3316  struct dm_table;
3317  struct dm_md_mempools;
3318  
3319 +xid_t dm_get_xid(struct mapped_device *md);
3320 +
3321  /*-----------------------------------------------------------------
3322   * Internal table functions.
3323   *---------------------------------------------------------------*/
3324 diff -NurpP --minimal linux-2.6.35/drivers/md/dm-ioctl.c linux-2.6.35-vs2.3.0.36.31/drivers/md/dm-ioctl.c
3325 --- linux-2.6.35/drivers/md/dm-ioctl.c  2010-07-07 18:31:21.000000000 +0200
3326 +++ linux-2.6.35-vs2.3.0.36.31/drivers/md/dm-ioctl.c    2010-08-02 17:05:05.000000000 +0200
3327 @@ -16,6 +16,7 @@
3328  #include <linux/dm-ioctl.h>
3329  #include <linux/hdreg.h>
3330  #include <linux/compat.h>
3331 +#include <linux/vs_context.h>
3332  
3333  #include <asm/uaccess.h>
3334  
3335 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
3336         unsigned int h = hash_str(str);
3337  
3338         list_for_each_entry (hc, _name_buckets + h, name_list)
3339 -               if (!strcmp(hc->name, str)) {
3340 +               if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3341 +                       !strcmp(hc->name, str)) {
3342                         dm_get(hc->md);
3343                         return hc;
3344                 }
3345 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
3346         unsigned int h = hash_str(str);
3347  
3348         list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
3349 -               if (!strcmp(hc->uuid, str)) {
3350 +               if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3351 +                       !strcmp(hc->uuid, str)) {
3352                         dm_get(hc->md);
3353                         return hc;
3354                 }
3355 @@ -365,6 +368,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl 
3356  
3357  static int remove_all(struct dm_ioctl *param, size_t param_size)
3358  {
3359 +       if (!vx_check(0, VS_ADMIN))
3360 +               return -EPERM;
3361 +
3362         dm_hash_remove_all(1);
3363         param->data_size = 0;
3364         return 0;
3365 @@ -412,6 +418,8 @@ static int list_devices(struct dm_ioctl 
3366          */
3367         for (i = 0; i < NUM_BUCKETS; i++) {
3368                 list_for_each_entry (hc, _name_buckets + i, name_list) {
3369 +                       if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3370 +                               continue;
3371                         needed += sizeof(struct dm_name_list);
3372                         needed += strlen(hc->name) + 1;
3373                         needed += ALIGN_MASK;
3374 @@ -435,6 +443,8 @@ static int list_devices(struct dm_ioctl 
3375          */
3376         for (i = 0; i < NUM_BUCKETS; i++) {
3377                 list_for_each_entry (hc, _name_buckets + i, name_list) {
3378 +                       if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3379 +                               continue;
3380                         if (old_nl)
3381                                 old_nl->next = (uint32_t) ((void *) nl -
3382                                                            (void *) old_nl);
3383 @@ -669,10 +679,11 @@ static struct hash_cell *__find_device_h
3384         if (!md)
3385                 goto out;
3386  
3387 -       mdptr = dm_get_mdptr(md);
3388 +       if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
3389 +               mdptr = dm_get_mdptr(md);
3390 +
3391         if (!mdptr)
3392                 dm_put(md);
3393 -
3394  out:
3395         return mdptr;
3396  }
3397 @@ -1514,8 +1525,8 @@ static int ctl_ioctl(uint command, struc
3398         ioctl_fn fn = NULL;
3399         size_t param_size;
3400  
3401 -       /* only root can play with this */
3402 -       if (!capable(CAP_SYS_ADMIN))
3403 +       /* only root and certain contexts can play with this */
3404 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
3405                 return -EACCES;
3406  
3407         if (_IOC_TYPE(command) != DM_IOCTL)
3408 diff -NurpP --minimal linux-2.6.35/drivers/net/tun.c linux-2.6.35-vs2.3.0.36.31/drivers/net/tun.c
3409 --- linux-2.6.35/drivers/net/tun.c      2010-08-02 16:52:27.000000000 +0200
3410 +++ linux-2.6.35-vs2.3.0.36.31/drivers/net/tun.c        2010-08-02 17:05:05.000000000 +0200
3411 @@ -62,6 +62,7 @@
3412  #include <linux/nsproxy.h>
3413  #include <linux/virtio_net.h>
3414  #include <linux/rcupdate.h>
3415 +#include <linux/vs_network.h>
3416  #include <net/net_namespace.h>
3417  #include <net/netns/generic.h>
3418  #include <net/rtnetlink.h>
3419 @@ -103,6 +104,7 @@ struct tun_struct {
3420         unsigned int            flags;
3421         uid_t                   owner;
3422         gid_t                   group;
3423 +       nid_t                   nid;
3424  
3425         struct net_device       *dev;
3426         struct fasync_struct    *fasync;
3427 @@ -851,6 +853,7 @@ static void tun_setup(struct net_device 
3428  
3429         tun->owner = -1;
3430         tun->group = -1;
3431 +       tun->nid = current->nid;
3432  
3433         dev->ethtool_ops = &tun_ethtool_ops;
3434         dev->destructor = tun_free_netdev;
3435 @@ -1001,7 +1004,7 @@ static int tun_set_iff(struct net *net, 
3436  
3437                 if (((tun->owner != -1 && cred->euid != tun->owner) ||
3438                      (tun->group != -1 && !in_egroup_p(tun->group))) &&
3439 -                   !capable(CAP_NET_ADMIN))
3440 +               !cap_raised(current_cap(), CAP_NET_ADMIN))
3441                         return -EPERM;
3442                 err = security_tun_dev_attach(tun->socket.sk);
3443                 if (err < 0)
3444 @@ -1015,7 +1018,7 @@ static int tun_set_iff(struct net *net, 
3445                 char *name;
3446                 unsigned long flags = 0;
3447  
3448 -               if (!capable(CAP_NET_ADMIN))
3449 +               if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
3450                         return -EPERM;
3451                 err = security_tun_dev_create();
3452                 if (err < 0)
3453 @@ -1085,6 +1088,9 @@ static int tun_set_iff(struct net *net, 
3454  
3455                 sk->sk_destruct = tun_sock_destruct;
3456  
3457 +               if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
3458 +                       return -EPERM;
3459 +
3460                 err = tun_attach(tun, file);
3461                 if (err < 0)
3462                         goto failed;
3463 @@ -1276,6 +1282,16 @@ static long __tun_chr_ioctl(struct file 
3464                 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
3465                 break;
3466  
3467 +       case TUNSETNID:
3468 +               if (!capable(CAP_CONTEXT))
3469 +                       return -EPERM;
3470 +
3471 +               /* Set nid owner of the device */
3472 +               tun->nid = (nid_t) arg;
3473 +
3474 +               DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
3475 +               break;
3476 +
3477         case TUNSETLINK:
3478                 /* Only allow setting the type when the interface is down */
3479                 if (tun->dev->flags & IFF_UP) {
3480 diff -NurpP --minimal linux-2.6.35/fs/attr.c linux-2.6.35-vs2.3.0.36.31/fs/attr.c
3481 --- linux-2.6.35/fs/attr.c      2010-08-02 16:52:47.000000000 +0200
3482 +++ linux-2.6.35-vs2.3.0.36.31/fs/attr.c        2010-08-02 21:00:32.000000000 +0200
3483 @@ -13,6 +13,9 @@
3484  #include <linux/fsnotify.h>
3485  #include <linux/fcntl.h>
3486  #include <linux/security.h>
3487 +#include <linux/proc_fs.h>
3488 +#include <linux/devpts_fs.h>
3489 +#include <linux/vs_tag.h>
3490  
3491  /* Taken over from the old code... */
3492  
3493 @@ -54,6 +57,10 @@ int inode_change_ok(const struct inode *
3494                 if (!is_owner_or_cap(inode))
3495                         goto error;
3496         }
3497 +
3498 +       if (dx_permission(inode, MAY_WRITE))
3499 +               goto error;
3500 +
3501  fine:
3502         retval = 0;
3503  error:
3504 @@ -127,6 +134,8 @@ void generic_setattr(struct inode *inode
3505                 inode->i_uid = attr->ia_uid;
3506         if (ia_valid & ATTR_GID)
3507                 inode->i_gid = attr->ia_gid;
3508 +       if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3509 +               inode->i_tag = attr->ia_tag;
3510         if (ia_valid & ATTR_ATIME)
3511                 inode->i_atime = timespec_trunc(attr->ia_atime,
3512                                                 inode->i_sb->s_time_gran);
3513 @@ -179,7 +188,8 @@ int notify_change(struct dentry * dentry
3514         struct timespec now;
3515         unsigned int ia_valid = attr->ia_valid;
3516  
3517 -       if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
3518 +       if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
3519 +               ATTR_TAG | ATTR_TIMES_SET)) {
3520                 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
3521                         return -EPERM;
3522         }
3523 diff -NurpP --minimal linux-2.6.35/fs/binfmt_aout.c linux-2.6.35-vs2.3.0.36.31/fs/binfmt_aout.c
3524 --- linux-2.6.35/fs/binfmt_aout.c       2010-07-07 18:31:50.000000000 +0200
3525 +++ linux-2.6.35-vs2.3.0.36.31/fs/binfmt_aout.c 2010-08-02 17:05:05.000000000 +0200
3526 @@ -25,6 +25,7 @@
3527  #include <linux/init.h>
3528  #include <linux/coredump.h>
3529  #include <linux/slab.h>
3530 +#include <linux/vs_memory.h>
3531  
3532  #include <asm/system.h>
3533  #include <asm/uaccess.h>
3534 diff -NurpP --minimal linux-2.6.35/fs/binfmt_elf.c linux-2.6.35-vs2.3.0.36.31/fs/binfmt_elf.c
3535 --- linux-2.6.35/fs/binfmt_elf.c        2010-07-07 18:31:50.000000000 +0200
3536 +++ linux-2.6.35-vs2.3.0.36.31/fs/binfmt_elf.c  2010-08-02 17:05:05.000000000 +0200
3537 @@ -32,6 +32,7 @@
3538  #include <linux/elf.h>
3539  #include <linux/utsname.h>
3540  #include <linux/coredump.h>
3541 +#include <linux/vs_memory.h>
3542  #include <asm/uaccess.h>
3543  #include <asm/param.h>
3544  #include <asm/page.h>
3545 diff -NurpP --minimal linux-2.6.35/fs/binfmt_flat.c linux-2.6.35-vs2.3.0.36.31/fs/binfmt_flat.c
3546 --- linux-2.6.35/fs/binfmt_flat.c       2010-08-02 16:52:47.000000000 +0200
3547 +++ linux-2.6.35-vs2.3.0.36.31/fs/binfmt_flat.c 2010-08-02 17:05:05.000000000 +0200
3548 @@ -35,6 +35,7 @@
3549  #include <linux/init.h>
3550  #include <linux/flat.h>
3551  #include <linux/syscalls.h>
3552 +#include <linux/vs_memory.h>
3553  
3554  #include <asm/byteorder.h>
3555  #include <asm/system.h>
3556 diff -NurpP --minimal linux-2.6.35/fs/binfmt_som.c linux-2.6.35-vs2.3.0.36.31/fs/binfmt_som.c
3557 --- linux-2.6.35/fs/binfmt_som.c        2010-02-25 11:52:04.000000000 +0100
3558 +++ linux-2.6.35-vs2.3.0.36.31/fs/binfmt_som.c  2010-08-02 17:05:05.000000000 +0200
3559 @@ -28,6 +28,7 @@
3560  #include <linux/shm.h>
3561  #include <linux/personality.h>
3562  #include <linux/init.h>
3563 +#include <linux/vs_memory.h>
3564  
3565  #include <asm/uaccess.h>
3566  #include <asm/pgtable.h>
3567 diff -NurpP --minimal linux-2.6.35/fs/block_dev.c linux-2.6.35-vs2.3.0.36.31/fs/block_dev.c
3568 --- linux-2.6.35/fs/block_dev.c 2010-08-02 16:52:47.000000000 +0200
3569 +++ linux-2.6.35-vs2.3.0.36.31/fs/block_dev.c   2010-08-02 17:05:05.000000000 +0200
3570 @@ -26,6 +26,7 @@
3571  #include <linux/namei.h>
3572  #include <linux/log2.h>
3573  #include <linux/kmemleak.h>
3574 +#include <linux/vs_device.h>
3575  #include <asm/uaccess.h>
3576  #include "internal.h"
3577  
3578 @@ -529,6 +530,7 @@ struct block_device *bdget(dev_t dev)
3579                 bdev->bd_invalidated = 0;
3580                 inode->i_mode = S_IFBLK;
3581                 inode->i_rdev = dev;
3582 +               inode->i_mdev = dev;
3583                 inode->i_bdev = bdev;
3584                 inode->i_data.a_ops = &def_blk_aops;
3585                 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
3586 @@ -575,6 +577,11 @@ EXPORT_SYMBOL(bdput);
3587  static struct block_device *bd_acquire(struct inode *inode)
3588  {
3589         struct block_device *bdev;
3590 +       dev_t mdev;
3591 +
3592 +       if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
3593 +               return NULL;
3594 +       inode->i_mdev = mdev;
3595  
3596         spin_lock(&bdev_lock);
3597         bdev = inode->i_bdev;
3598 @@ -585,7 +592,7 @@ static struct block_device *bd_acquire(s
3599         }
3600         spin_unlock(&bdev_lock);
3601  
3602 -       bdev = bdget(inode->i_rdev);
3603 +       bdev = bdget(mdev);
3604         if (bdev) {
3605                 spin_lock(&bdev_lock);
3606                 if (!inode->i_bdev) {
3607 diff -NurpP --minimal linux-2.6.35/fs/btrfs/ctree.h linux-2.6.35-vs2.3.0.36.31/fs/btrfs/ctree.h
3608 --- linux-2.6.35/fs/btrfs/ctree.h       2010-08-02 16:52:47.000000000 +0200
3609 +++ linux-2.6.35-vs2.3.0.36.31/fs/btrfs/ctree.h 2010-08-02 17:05:05.000000000 +0200
3610 @@ -551,11 +551,14 @@ struct btrfs_inode_item {
3611         /* modification sequence number for NFS */
3612         __le64 sequence;
3613  
3614 +       __le16 tag;
3615         /*
3616          * a little future expansion, for more than this we can
3617          * just grow the inode item and version it
3618          */
3619 -       __le64 reserved[4];
3620 +       __le16 reserved16;
3621 +       __le32 reserved32;
3622 +       __le64 reserved[3];
3623         struct btrfs_timespec atime;
3624         struct btrfs_timespec ctime;
3625         struct btrfs_timespec mtime;
3626 @@ -1193,6 +1196,8 @@ struct btrfs_root {
3627  #define BTRFS_MOUNT_DISCARD            (1 << 10)
3628  #define BTRFS_MOUNT_FORCE_COMPRESS      (1 << 11)
3629  
3630 +#define BTRFS_MOUNT_TAGGED             (1 << 24)
3631 +
3632  #define btrfs_clear_opt(o, opt)                ((o) &= ~BTRFS_MOUNT_##opt)
3633  #define btrfs_set_opt(o, opt)          ((o) |= BTRFS_MOUNT_##opt)
3634  #define btrfs_test_opt(root, opt)      ((root)->fs_info->mount_opt & \
3635 @@ -1413,6 +1418,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
3636  BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
3637  BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
3638  BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
3639 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
3640  BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
3641  BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
3642  BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
3643 @@ -1474,6 +1480,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct 
3644  
3645  BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
3646  
3647 +#define BTRFS_INODE_IXUNLINK           (1 << 24)
3648 +#define BTRFS_INODE_BARRIER            (1 << 25)
3649 +#define BTRFS_INODE_COW                        (1 << 26)
3650 +
3651  
3652  BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
3653  
3654 @@ -2432,6 +2442,7 @@ extern const struct dentry_operations bt
3655  long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3656  void btrfs_update_iflags(struct inode *inode);
3657  void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
3658 +int btrfs_sync_flags(struct inode *inode, int, int);
3659  
3660  /* file.c */
3661  int btrfs_sync_file(struct file *file, int datasync);
3662 diff -NurpP --minimal linux-2.6.35/fs/btrfs/disk-io.c linux-2.6.35-vs2.3.0.36.31/fs/btrfs/disk-io.c
3663 --- linux-2.6.35/fs/btrfs/disk-io.c     2010-08-02 16:52:47.000000000 +0200
3664 +++ linux-2.6.35-vs2.3.0.36.31/fs/btrfs/disk-io.c       2010-08-02 17:05:05.000000000 +0200
3665 @@ -1707,6 +1707,9 @@ struct btrfs_root *open_ctree(struct sup
3666                 goto fail_iput;
3667         }
3668  
3669 +       if (btrfs_test_opt(tree_root, TAGGED))
3670 +               sb->s_flags |= MS_TAGGED;
3671 +
3672         features = btrfs_super_incompat_flags(disk_super) &
3673                 ~BTRFS_FEATURE_INCOMPAT_SUPP;
3674         if (features) {
3675 diff -NurpP --minimal linux-2.6.35/fs/btrfs/inode.c linux-2.6.35-vs2.3.0.36.31/fs/btrfs/inode.c
3676 --- linux-2.6.35/fs/btrfs/inode.c       2010-08-02 16:52:47.000000000 +0200
3677 +++ linux-2.6.35-vs2.3.0.36.31/fs/btrfs/inode.c 2010-08-02 17:05:05.000000000 +0200
3678 @@ -37,6 +37,8 @@
3679  #include <linux/posix_acl.h>
3680  #include <linux/falloc.h>
3681  #include <linux/slab.h>
3682 +#include <linux/vs_tag.h>
3683 +
3684  #include "compat.h"
3685  #include "ctree.h"
3686  #include "disk-io.h"
3687 @@ -2415,6 +2417,8 @@ static void btrfs_read_locked_inode(stru
3688         int maybe_acls;
3689         u64 alloc_group_block;
3690         u32 rdev;
3691 +       uid_t uid;
3692 +       gid_t gid;
3693         int ret;
3694  
3695         path = btrfs_alloc_path();
3696 @@ -2431,8 +2435,13 @@ static void btrfs_read_locked_inode(stru
3697  
3698         inode->i_mode = btrfs_inode_mode(leaf, inode_item);
3699         inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
3700 -       inode->i_uid = btrfs_inode_uid(leaf, inode_item);
3701 -       inode->i_gid = btrfs_inode_gid(leaf, inode_item);
3702 +
3703 +       uid = btrfs_inode_uid(leaf, inode_item);
3704 +       gid = btrfs_inode_gid(leaf, inode_item);
3705 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3706 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3707 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3708 +               btrfs_inode_tag(leaf, inode_item));
3709         btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
3710  
3711         tspec = btrfs_inode_atime(inode_item);
3712 @@ -2514,8 +2523,15 @@ static void fill_inode_item(struct btrfs
3713                             struct btrfs_inode_item *item,
3714                             struct inode *inode)
3715  {
3716 -       btrfs_set_inode_uid(leaf, item, inode->i_uid);
3717 -       btrfs_set_inode_gid(leaf, item, inode->i_gid);
3718 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3719 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3720 +
3721 +       btrfs_set_inode_uid(leaf, item, uid);
3722 +       btrfs_set_inode_gid(leaf, item, gid);
3723 +#ifdef CONFIG_TAGGING_INTERN
3724 +       btrfs_set_inode_tag(leaf, item, inode->i_tag);
3725 +#endif
3726 +
3727         btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
3728         btrfs_set_inode_mode(leaf, item, inode->i_mode);
3729         btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
3730 @@ -6940,6 +6956,7 @@ static const struct inode_operations btr
3731         .listxattr      = btrfs_listxattr,
3732         .removexattr    = btrfs_removexattr,
3733         .permission     = btrfs_permission,
3734 +       .sync_flags     = btrfs_sync_flags,
3735  };
3736  static const struct inode_operations btrfs_dir_ro_inode_operations = {
3737         .lookup         = btrfs_lookup,
3738 @@ -7015,6 +7032,7 @@ static const struct inode_operations btr
3739         .permission     = btrfs_permission,
3740         .fallocate      = btrfs_fallocate,
3741         .fiemap         = btrfs_fiemap,
3742 +       .sync_flags     = btrfs_sync_flags,
3743  };
3744  static const struct inode_operations btrfs_special_inode_operations = {
3745         .getattr        = btrfs_getattr,
3746 diff -NurpP --minimal linux-2.6.35/fs/btrfs/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/btrfs/ioctl.c
3747 --- linux-2.6.35/fs/btrfs/ioctl.c       2010-08-02 16:52:47.000000000 +0200
3748 +++ linux-2.6.35-vs2.3.0.36.31/fs/btrfs/ioctl.c 2010-08-02 17:05:05.000000000 +0200
3749 @@ -68,10 +68,13 @@ static unsigned int btrfs_flags_to_ioctl
3750  {
3751         unsigned int iflags = 0;
3752  
3753 -       if (flags & BTRFS_INODE_SYNC)
3754 -               iflags |= FS_SYNC_FL;
3755         if (flags & BTRFS_INODE_IMMUTABLE)
3756                 iflags |= FS_IMMUTABLE_FL;
3757 +       if (flags & BTRFS_INODE_IXUNLINK)
3758 +               iflags |= FS_IXUNLINK_FL;
3759 +
3760 +       if (flags & BTRFS_INODE_SYNC)
3761 +               iflags |= FS_SYNC_FL;
3762         if (flags & BTRFS_INODE_APPEND)
3763                 iflags |= FS_APPEND_FL;
3764         if (flags & BTRFS_INODE_NODUMP)
3765 @@ -81,28 +84,78 @@ static unsigned int btrfs_flags_to_ioctl
3766         if (flags & BTRFS_INODE_DIRSYNC)
3767                 iflags |= FS_DIRSYNC_FL;
3768  
3769 +       if (flags & BTRFS_INODE_BARRIER)
3770 +               iflags |= FS_BARRIER_FL;
3771 +       if (flags & BTRFS_INODE_COW)
3772 +               iflags |= FS_COW_FL;
3773         return iflags;
3774  }
3775  
3776  /*
3777 - * Update inode->i_flags based on the btrfs internal flags.
3778 + * Update inode->i_(v)flags based on the btrfs internal flags.
3779   */
3780  void btrfs_update_iflags(struct inode *inode)
3781  {
3782         struct btrfs_inode *ip = BTRFS_I(inode);
3783  
3784 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3785 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3786 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3787  
3788 -       if (ip->flags & BTRFS_INODE_SYNC)
3789 -               inode->i_flags |= S_SYNC;
3790         if (ip->flags & BTRFS_INODE_IMMUTABLE)
3791                 inode->i_flags |= S_IMMUTABLE;
3792 +       if (ip->flags & BTRFS_INODE_IXUNLINK)
3793 +               inode->i_flags |= S_IXUNLINK;
3794 +
3795 +       if (ip->flags & BTRFS_INODE_SYNC)
3796 +               inode->i_flags |= S_SYNC;
3797         if (ip->flags & BTRFS_INODE_APPEND)
3798                 inode->i_flags |= S_APPEND;
3799         if (ip->flags & BTRFS_INODE_NOATIME)
3800                 inode->i_flags |= S_NOATIME;
3801         if (ip->flags & BTRFS_INODE_DIRSYNC)
3802                 inode->i_flags |= S_DIRSYNC;
3803 +
3804 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
3805 +
3806 +       if (ip->flags & BTRFS_INODE_BARRIER)
3807 +               inode->i_vflags |= V_BARRIER;
3808 +       if (ip->flags & BTRFS_INODE_COW)
3809 +               inode->i_vflags |= V_COW;
3810 +}
3811 +
3812 +/*
3813 + * Update btrfs internal flags from inode->i_(v)flags.
3814 + */
3815 +void btrfs_update_flags(struct inode *inode)
3816 +{
3817 +       struct btrfs_inode *ip = BTRFS_I(inode);
3818 +
3819 +       unsigned int flags = inode->i_flags;
3820 +       unsigned int vflags = inode->i_vflags;
3821 +
3822 +       ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
3823 +                       BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
3824 +                       BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
3825 +                       BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
3826 +
3827 +       if (flags & S_IMMUTABLE)
3828 +               ip->flags |= BTRFS_INODE_IMMUTABLE;
3829 +       if (flags & S_IXUNLINK)
3830 +               ip->flags |= BTRFS_INODE_IXUNLINK;
3831 +
3832 +       if (flags & S_SYNC)
3833 +               ip->flags |= BTRFS_INODE_SYNC;
3834 +       if (flags & S_APPEND)
3835 +               ip->flags |= BTRFS_INODE_APPEND;
3836 +       if (flags & S_NOATIME)
3837 +               ip->flags |= BTRFS_INODE_NOATIME;
3838 +       if (flags & S_DIRSYNC)
3839 +               ip->flags |= BTRFS_INODE_DIRSYNC;
3840 +
3841 +       if (vflags & V_BARRIER)
3842 +               ip->flags |= BTRFS_INODE_BARRIER;
3843 +       if (vflags & V_COW)
3844 +               ip->flags |= BTRFS_INODE_COW;
3845  }
3846  
3847  /*
3848 @@ -120,7 +173,7 @@ void btrfs_inherit_iflags(struct inode *
3849         flags = BTRFS_I(dir)->flags;
3850  
3851         if (S_ISREG(inode->i_mode))
3852 -               flags &= ~BTRFS_INODE_DIRSYNC;
3853 +               flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
3854         else if (!S_ISDIR(inode->i_mode))
3855                 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
3856  
3857 @@ -128,6 +181,30 @@ void btrfs_inherit_iflags(struct inode *
3858         btrfs_update_iflags(inode);
3859  }
3860  
3861 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
3862 +{
3863 +       struct btrfs_inode *ip = BTRFS_I(inode);
3864 +       struct btrfs_root *root = ip->root;
3865 +       struct btrfs_trans_handle *trans;
3866 +       int ret;
3867 +
3868 +       trans = btrfs_join_transaction(root, 1);
3869 +       BUG_ON(!trans);
3870 +
3871 +       inode->i_flags = flags;
3872 +       inode->i_vflags = vflags;
3873 +       btrfs_update_flags(inode);
3874 +
3875 +       ret = btrfs_update_inode(trans, root, inode);
3876 +       BUG_ON(ret);
3877 +
3878 +       btrfs_update_iflags(inode);
3879 +       inode->i_ctime = CURRENT_TIME;
3880 +       btrfs_end_transaction(trans, root);
3881 +
3882 +       return 0;
3883 +}
3884 +
3885  static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
3886  {
3887         struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
3888 @@ -150,6 +227,7 @@ static int btrfs_ioctl_setflags(struct f
3889         if (copy_from_user(&flags, arg, sizeof(flags)))
3890                 return -EFAULT;
3891  
3892 +       /* maybe add FS_IXUNLINK_FL ? */
3893         if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
3894                       FS_NOATIME_FL | FS_NODUMP_FL | \
3895                       FS_SYNC_FL | FS_DIRSYNC_FL))
3896 @@ -162,7 +240,8 @@ static int btrfs_ioctl_setflags(struct f
3897  
3898         flags = btrfs_mask_flags(inode->i_mode, flags);
3899         oldflags = btrfs_flags_to_ioctl(ip->flags);
3900 -       if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
3901 +       if ((flags ^ oldflags) & (FS_APPEND_FL |
3902 +               FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
3903                 if (!capable(CAP_LINUX_IMMUTABLE)) {
3904                         ret = -EPERM;
3905                         goto out_unlock;
3906 @@ -173,14 +252,19 @@ static int btrfs_ioctl_setflags(struct f
3907         if (ret)
3908                 goto out_unlock;
3909  
3910 -       if (flags & FS_SYNC_FL)
3911 -               ip->flags |= BTRFS_INODE_SYNC;
3912 -       else
3913 -               ip->flags &= ~BTRFS_INODE_SYNC;
3914         if (flags & FS_IMMUTABLE_FL)
3915                 ip->flags |= BTRFS_INODE_IMMUTABLE;
3916         else
3917                 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
3918 +       if (flags & FS_IXUNLINK_FL)
3919 +               ip->flags |= BTRFS_INODE_IXUNLINK;
3920 +       else
3921 +               ip->flags &= ~BTRFS_INODE_IXUNLINK;
3922 +
3923 +       if (flags & FS_SYNC_FL)
3924 +               ip->flags |= BTRFS_INODE_SYNC;
3925 +       else
3926 +               ip->flags &= ~BTRFS_INODE_SYNC;
3927         if (flags & FS_APPEND_FL)
3928                 ip->flags |= BTRFS_INODE_APPEND;
3929         else
3930 diff -NurpP --minimal linux-2.6.35/fs/btrfs/super.c linux-2.6.35-vs2.3.0.36.31/fs/btrfs/super.c
3931 --- linux-2.6.35/fs/btrfs/super.c       2010-08-02 16:52:47.000000000 +0200
3932 +++ linux-2.6.35-vs2.3.0.36.31/fs/btrfs/super.c 2010-08-02 17:05:05.000000000 +0200
3933 @@ -68,7 +68,7 @@ enum {
3934         Opt_nodatacow, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, Opt_ssd,
3935         Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress,
3936         Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
3937 -       Opt_discard, Opt_err,
3938 +       Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
3939  };
3940  
3941  static match_table_t tokens = {
3942 @@ -92,6 +92,9 @@ static match_table_t tokens = {
3943         {Opt_flushoncommit, "flushoncommit"},
3944         {Opt_ratio, "metadata_ratio=%d"},
3945         {Opt_discard, "discard"},
3946 +       {Opt_tag, "tag"},
3947 +       {Opt_notag, "notag"},
3948 +       {Opt_tagid, "tagid=%u"},
3949         {Opt_err, NULL},
3950  };
3951  
3952 @@ -235,6 +238,22 @@ int btrfs_parse_options(struct btrfs_roo
3953                 case Opt_discard:
3954                         btrfs_set_opt(info->mount_opt, DISCARD);
3955                         break;
3956 +#ifndef CONFIG_TAGGING_NONE
3957 +               case Opt_tag:
3958 +                       printk(KERN_INFO "btrfs: use tagging\n");
3959 +                       btrfs_set_opt(info->mount_opt, TAGGED);
3960 +                       break;
3961 +               case Opt_notag:
3962 +                       printk(KERN_INFO "btrfs: disabled tagging\n");
3963 +                       btrfs_clear_opt(info->mount_opt, TAGGED);
3964 +                       break;
3965 +#endif
3966 +#ifdef CONFIG_PROPAGATE
3967 +               case Opt_tagid:
3968 +                       /* use args[0] */
3969 +                       btrfs_set_opt(info->mount_opt, TAGGED);
3970 +                       break;
3971 +#endif
3972                 case Opt_err:
3973                         printk(KERN_INFO "btrfs: unrecognized mount option "
3974                                "'%s'\n", p);
3975 @@ -681,6 +700,12 @@ static int btrfs_remount(struct super_bl
3976         if (ret)
3977                 return -EINVAL;
3978  
3979 +       if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
3980 +               printk("btrfs: %s: tagging not permitted on remount.\n",
3981 +                       sb->s_id);
3982 +               return -EINVAL;
3983 +       }
3984 +
3985         if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
3986                 return 0;
3987  
3988 diff -NurpP --minimal linux-2.6.35/fs/char_dev.c linux-2.6.35-vs2.3.0.36.31/fs/char_dev.c
3989 --- linux-2.6.35/fs/char_dev.c  2009-12-03 20:02:51.000000000 +0100
3990 +++ linux-2.6.35-vs2.3.0.36.31/fs/char_dev.c    2010-08-02 17:05:05.000000000 +0200
3991 @@ -20,6 +20,8 @@
3992  #include <linux/cdev.h>
3993  #include <linux/mutex.h>
3994  #include <linux/backing-dev.h>
3995 +#include <linux/vs_context.h>
3996 +#include <linux/vs_device.h>
3997  
3998  #include "internal.h"
3999  
4000 @@ -368,14 +370,21 @@ static int chrdev_open(struct inode *ino
4001         struct cdev *p;
4002         struct cdev *new = NULL;
4003         int ret = 0;
4004 +       dev_t mdev;
4005 +
4006 +       if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
4007 +               return -EPERM;
4008 +       inode->i_mdev = mdev;
4009  
4010         spin_lock(&cdev_lock);
4011         p = inode->i_cdev;
4012         if (!p) {
4013                 struct kobject *kobj;
4014                 int idx;
4015 +
4016                 spin_unlock(&cdev_lock);
4017 -               kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
4018 +
4019 +               kobj = kobj_lookup(cdev_map, mdev, &idx);
4020                 if (!kobj)
4021                         return -ENXIO;
4022                 new = container_of(kobj, struct cdev, kobj);
4023 diff -NurpP --minimal linux-2.6.35/fs/dcache.c linux-2.6.35-vs2.3.0.36.31/fs/dcache.c
4024 --- linux-2.6.35/fs/dcache.c    2010-08-02 16:52:48.000000000 +0200
4025 +++ linux-2.6.35-vs2.3.0.36.31/fs/dcache.c      2010-08-02 17:05:05.000000000 +0200
4026 @@ -33,6 +33,7 @@
4027  #include <linux/bootmem.h>
4028  #include <linux/fs_struct.h>
4029  #include <linux/hardirq.h>
4030 +#include <linux/vs_limit.h>
4031  #include "internal.h"
4032  
4033  int sysctl_vfs_cache_pressure __read_mostly = 100;
4034 @@ -230,6 +231,8 @@ repeat:
4035                 return;
4036         }
4037  
4038 +       vx_dentry_dec(dentry);
4039 +
4040         /*
4041          * AV: ->d_delete() is _NOT_ allowed to block now.
4042          */
4043 @@ -323,6 +326,7 @@ static inline struct dentry * __dget_loc
4044  {
4045         atomic_inc(&dentry->d_count);
4046         dentry_lru_del_init(dentry);
4047 +       vx_dentry_inc(dentry);
4048         return dentry;
4049  }
4050  
4051 @@ -926,6 +930,9 @@ struct dentry *d_alloc(struct dentry * p
4052         struct dentry *dentry;
4053         char *dname;
4054  
4055 +       if (!vx_dentry_avail(1))
4056 +               return NULL;
4057 +
4058         dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
4059         if (!dentry)
4060                 return NULL;
4061 @@ -971,6 +978,7 @@ struct dentry *d_alloc(struct dentry * p
4062         if (parent)
4063                 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
4064         dentry_stat.nr_dentry++;
4065 +       vx_dentry_inc(dentry);
4066         spin_unlock(&dcache_lock);
4067  
4068         return dentry;
4069 @@ -1420,6 +1428,7 @@ struct dentry * __d_lookup(struct dentry
4070                 }
4071  
4072                 atomic_inc(&dentry->d_count);
4073 +               vx_dentry_inc(dentry);
4074                 found = dentry;
4075                 spin_unlock(&dentry->d_lock);
4076                 break;
4077 diff -NurpP --minimal linux-2.6.35/fs/devpts/inode.c linux-2.6.35-vs2.3.0.36.31/fs/devpts/inode.c
4078 --- linux-2.6.35/fs/devpts/inode.c      2010-08-02 16:52:48.000000000 +0200
4079 +++ linux-2.6.35-vs2.3.0.36.31/fs/devpts/inode.c        2010-08-02 17:05:05.000000000 +0200
4080 @@ -25,6 +25,7 @@
4081  #include <linux/parser.h>
4082  #include <linux/fsnotify.h>
4083  #include <linux/seq_file.h>
4084 +#include <linux/vs_base.h>
4085  
4086  #define DEVPTS_DEFAULT_MODE 0600
4087  /*
4088 @@ -36,6 +37,20 @@
4089  #define DEVPTS_DEFAULT_PTMX_MODE 0000
4090  #define PTMX_MINOR     2
4091  
4092 +static int devpts_permission(struct inode *inode, int mask)
4093 +{
4094 +       int ret = -EACCES;
4095 +
4096 +       /* devpts is xid tagged */
4097 +       if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
4098 +               ret = generic_permission(inode, mask, NULL);
4099 +       return ret;
4100 +}
4101 +
4102 +static struct inode_operations devpts_file_inode_operations = {
4103 +       .permission     = devpts_permission,
4104 +};
4105 +
4106  extern int pty_limit;                  /* Config limit on Unix98 ptys */
4107  static DEFINE_MUTEX(allocated_ptys_lock);
4108  
4109 @@ -263,6 +278,25 @@ static int devpts_show_options(struct se
4110         return 0;
4111  }
4112  
4113 +static int devpts_filter(struct dentry *de)
4114 +{
4115 +       /* devpts is xid tagged */
4116 +       return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
4117 +}
4118 +
4119 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
4120 +{
4121 +       return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
4122 +}
4123 +
4124 +static struct file_operations devpts_dir_operations = {
4125 +       .open           = dcache_dir_open,
4126 +       .release        = dcache_dir_close,
4127 +       .llseek         = dcache_dir_lseek,
4128 +       .read           = generic_read_dir,
4129 +       .readdir        = devpts_readdir,
4130 +};
4131 +
4132  static const struct super_operations devpts_sops = {
4133         .statfs         = simple_statfs,
4134         .remount_fs     = devpts_remount,
4135 @@ -302,12 +336,15 @@ devpts_fill_super(struct super_block *s,
4136         inode = new_inode(s);
4137         if (!inode)
4138                 goto free_fsi;
4139 +
4140         inode->i_ino = 1;
4141         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4142         inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
4143         inode->i_op = &simple_dir_inode_operations;
4144 -       inode->i_fop = &simple_dir_operations;
4145 +       inode->i_fop = &devpts_dir_operations;
4146         inode->i_nlink = 2;
4147 +       /* devpts is xid tagged */
4148 +       inode->i_tag = (tag_t)vx_current_xid();
4149  
4150         s->s_root = d_alloc_root(inode);
4151         if (s->s_root)
4152 @@ -495,6 +532,9 @@ int devpts_pty_new(struct inode *ptmx_in
4153         inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
4154         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4155         init_special_inode(inode, S_IFCHR|opts->mode, device);
4156 +       /* devpts is xid tagged */
4157 +       inode->i_tag = (tag_t)vx_current_xid();
4158 +       inode->i_op = &devpts_file_inode_operations;
4159         inode->i_private = tty;
4160         tty->driver_data = inode;
4161  
4162 diff -NurpP --minimal linux-2.6.35/fs/exec.c linux-2.6.35-vs2.3.0.36.31/fs/exec.c
4163 --- linux-2.6.35/fs/exec.c      2010-08-02 16:52:48.000000000 +0200
4164 +++ linux-2.6.35-vs2.3.0.36.31/fs/exec.c        2010-08-02 17:05:05.000000000 +0200
4165 @@ -1506,7 +1506,7 @@ static int format_corename(char *corenam
4166                         /* UNIX time of coredump */
4167                         case 't': {
4168                                 struct timeval tv;
4169 -                               do_gettimeofday(&tv);
4170 +                               vx_gettimeofday(&tv);
4171                                 rc = snprintf(out_ptr, out_end - out_ptr,
4172                                               "%lu", tv.tv_sec);
4173                                 if (rc > out_end - out_ptr)
4174 diff -NurpP --minimal linux-2.6.35/fs/ext2/balloc.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/balloc.c
4175 --- linux-2.6.35/fs/ext2/balloc.c       2010-08-02 16:52:48.000000000 +0200
4176 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/balloc.c 2010-08-02 17:05:05.000000000 +0200
4177 @@ -702,7 +702,6 @@ ext2_try_to_allocate(struct super_block 
4178                         start = 0;
4179                 end = EXT2_BLOCKS_PER_GROUP(sb);
4180         }
4181 -
4182         BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
4183  
4184  repeat:
4185 diff -NurpP --minimal linux-2.6.35/fs/ext2/ext2.h linux-2.6.35-vs2.3.0.36.31/fs/ext2/ext2.h
4186 --- linux-2.6.35/fs/ext2/ext2.h 2010-08-02 16:52:48.000000000 +0200
4187 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/ext2.h   2010-08-02 17:05:05.000000000 +0200
4188 @@ -130,6 +130,7 @@ extern int ext2_fiemap(struct inode *ino
4189  int __ext2_write_begin(struct file *file, struct address_space *mapping,
4190                 loff_t pos, unsigned len, unsigned flags,
4191                 struct page **pagep, void **fsdata);
4192 +extern int ext2_sync_flags(struct inode *, int, int);
4193  
4194  /* ioctl.c */
4195  extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
4196 diff -NurpP --minimal linux-2.6.35/fs/ext2/file.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/file.c
4197 --- linux-2.6.35/fs/ext2/file.c 2010-08-02 16:52:48.000000000 +0200
4198 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/file.c   2010-08-02 17:05:05.000000000 +0200
4199 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
4200         .setattr        = ext2_setattr,
4201         .check_acl      = ext2_check_acl,
4202         .fiemap         = ext2_fiemap,
4203 +       .sync_flags     = ext2_sync_flags,
4204  };
4205 diff -NurpP --minimal linux-2.6.35/fs/ext2/ialloc.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/ialloc.c
4206 --- linux-2.6.35/fs/ext2/ialloc.c       2010-08-02 16:52:48.000000000 +0200
4207 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/ialloc.c 2010-08-02 18:15:12.000000000 +0200
4208 @@ -17,6 +17,7 @@
4209  #include <linux/backing-dev.h>
4210  #include <linux/buffer_head.h>
4211  #include <linux/random.h>
4212 +#include <linux/vs_tag.h>
4213  #include "ext2.h"
4214  #include "xattr.h"
4215  #include "acl.h"
4216 @@ -553,6 +554,7 @@ got:
4217                 inode->i_mode = mode;
4218                 inode->i_uid = current_fsuid();
4219                 inode->i_gid = dir->i_gid;
4220 +               inode->i_tag = dx_current_fstag(sb);
4221         } else
4222                 inode_init_owner(inode, dir, mode);
4223  
4224 diff -NurpP --minimal linux-2.6.35/fs/ext2/inode.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/inode.c
4225 --- linux-2.6.35/fs/ext2/inode.c        2010-08-02 16:52:48.000000000 +0200
4226 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/inode.c  2010-08-02 17:05:05.000000000 +0200
4227 @@ -32,6 +32,7 @@
4228  #include <linux/mpage.h>
4229  #include <linux/fiemap.h>
4230  #include <linux/namei.h>
4231 +#include <linux/vs_tag.h>
4232  #include "ext2.h"
4233  #include "acl.h"
4234  #include "xip.h"
4235 @@ -1164,7 +1165,7 @@ static void ext2_truncate_blocks(struct 
4236                 return;
4237         if (ext2_inode_is_fast_symlink(inode))
4238                 return;
4239 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4240 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4241                 return;
4242         __ext2_truncate_blocks(inode, offset);
4243  }
4244 @@ -1261,36 +1262,61 @@ void ext2_set_inode_flags(struct inode *
4245  {
4246         unsigned int flags = EXT2_I(inode)->i_flags;
4247  
4248 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4249 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4250 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4251 +
4252 +
4253 +       if (flags & EXT2_IMMUTABLE_FL)
4254 +               inode->i_flags |= S_IMMUTABLE;
4255 +       if (flags & EXT2_IXUNLINK_FL)
4256 +               inode->i_flags |= S_IXUNLINK;
4257 +
4258         if (flags & EXT2_SYNC_FL)
4259                 inode->i_flags |= S_SYNC;
4260         if (flags & EXT2_APPEND_FL)
4261                 inode->i_flags |= S_APPEND;
4262 -       if (flags & EXT2_IMMUTABLE_FL)
4263 -               inode->i_flags |= S_IMMUTABLE;
4264         if (flags & EXT2_NOATIME_FL)
4265                 inode->i_flags |= S_NOATIME;
4266         if (flags & EXT2_DIRSYNC_FL)
4267                 inode->i_flags |= S_DIRSYNC;
4268 +
4269 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
4270 +
4271 +       if (flags & EXT2_BARRIER_FL)
4272 +               inode->i_vflags |= V_BARRIER;
4273 +       if (flags & EXT2_COW_FL)
4274 +               inode->i_vflags |= V_COW;
4275  }
4276  
4277  /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
4278  void ext2_get_inode_flags(struct ext2_inode_info *ei)
4279  {
4280         unsigned int flags = ei->vfs_inode.i_flags;
4281 +       unsigned int vflags = ei->vfs_inode.i_vflags;
4282 +
4283 +       ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
4284 +                       EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
4285 +                       EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
4286 +                       EXT2_BARRIER_FL | EXT2_COW_FL);
4287 +
4288 +       if (flags & S_IMMUTABLE)
4289 +               ei->i_flags |= EXT2_IMMUTABLE_FL;
4290 +       if (flags & S_IXUNLINK)
4291 +               ei->i_flags |= EXT2_IXUNLINK_FL;
4292  
4293 -       ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
4294 -                       EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
4295         if (flags & S_SYNC)
4296                 ei->i_flags |= EXT2_SYNC_FL;
4297         if (flags & S_APPEND)
4298                 ei->i_flags |= EXT2_APPEND_FL;
4299 -       if (flags & S_IMMUTABLE)
4300 -               ei->i_flags |= EXT2_IMMUTABLE_FL;
4301         if (flags & S_NOATIME)
4302                 ei->i_flags |= EXT2_NOATIME_FL;
4303         if (flags & S_DIRSYNC)
4304                 ei->i_flags |= EXT2_DIRSYNC_FL;
4305 +
4306 +       if (vflags & V_BARRIER)
4307 +               ei->i_flags |= EXT2_BARRIER_FL;
4308 +       if (vflags & V_COW)
4309 +               ei->i_flags |= EXT2_COW_FL;
4310  }
4311  
4312  struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
4313 @@ -1300,6 +1326,8 @@ struct inode *ext2_iget (struct super_bl
4314         struct ext2_inode *raw_inode;
4315         struct inode *inode;
4316         long ret = -EIO;
4317 +       uid_t uid;
4318 +       gid_t gid;
4319         int n;
4320  
4321         inode = iget_locked(sb, ino);
4322 @@ -1318,12 +1346,17 @@ struct inode *ext2_iget (struct super_bl
4323         }
4324  
4325         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4326 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4327 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4328 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4329 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4330         if (!(test_opt (inode->i_sb, NO_UID32))) {
4331 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4332 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4333 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4334 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4335         }
4336 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4337 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4338 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4339 +               le16_to_cpu(raw_inode->i_raw_tag));
4340 +
4341         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4342         inode->i_size = le32_to_cpu(raw_inode->i_size);
4343         inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4344 @@ -1421,8 +1454,8 @@ static int __ext2_write_inode(struct ino
4345         struct ext2_inode_info *ei = EXT2_I(inode);
4346         struct super_block *sb = inode->i_sb;
4347         ino_t ino = inode->i_ino;
4348 -       uid_t uid = inode->i_uid;
4349 -       gid_t gid = inode->i_gid;
4350 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4351 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4352         struct buffer_head * bh;
4353         struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
4354         int n;
4355 @@ -1458,6 +1491,9 @@ static int __ext2_write_inode(struct ino
4356                 raw_inode->i_uid_high = 0;
4357                 raw_inode->i_gid_high = 0;
4358         }
4359 +#ifdef CONFIG_TAGGING_INTERN
4360 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4361 +#endif
4362         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4363         raw_inode->i_size = cpu_to_le32(inode->i_size);
4364         raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4365 @@ -1547,7 +1583,8 @@ int ext2_setattr(struct dentry *dentry, 
4366         if (is_quota_modification(inode, iattr))
4367                 dquot_initialize(inode);
4368         if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4369 -           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4370 +           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4371 +           (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4372                 error = dquot_transfer(inode, iattr);
4373                 if (error)
4374                         return error;
4375 diff -NurpP --minimal linux-2.6.35/fs/ext2/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/ioctl.c
4376 --- linux-2.6.35/fs/ext2/ioctl.c        2009-09-10 15:26:21.000000000 +0200
4377 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/ioctl.c  2010-08-02 17:05:05.000000000 +0200
4378 @@ -17,6 +17,16 @@
4379  #include <asm/uaccess.h>
4380  
4381  
4382 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
4383 +{
4384 +       inode->i_flags = flags;
4385 +       inode->i_vflags = vflags;
4386 +       ext2_get_inode_flags(EXT2_I(inode));
4387 +       inode->i_ctime = CURRENT_TIME_SEC;
4388 +       mark_inode_dirty(inode);
4389 +       return 0;
4390 +}
4391 +
4392  long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4393  {
4394         struct inode *inode = filp->f_dentry->d_inode;
4395 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
4396  
4397                 flags = ext2_mask_flags(inode->i_mode, flags);
4398  
4399 +               if (IS_BARRIER(inode)) {
4400 +                       vxwprintk_task(1, "messing with the barrier.");
4401 +                       return -EACCES;
4402 +               }
4403 +
4404                 mutex_lock(&inode->i_mutex);
4405                 /* Is it quota file? Do not allow user to mess with it */
4406                 if (IS_NOQUOTA(inode)) {
4407 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
4408                  *
4409                  * This test looks nicer. Thanks to Pauline Middelink
4410                  */
4411 -               if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
4412 +               if ((oldflags & EXT2_IMMUTABLE_FL) ||
4413 +                       ((flags ^ oldflags) & (EXT2_APPEND_FL |
4414 +                       EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
4415                         if (!capable(CAP_LINUX_IMMUTABLE)) {
4416                                 mutex_unlock(&inode->i_mutex);
4417                                 ret = -EPERM;
4418 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
4419                         }
4420                 }
4421  
4422 -               flags = flags & EXT2_FL_USER_MODIFIABLE;
4423 +               flags &= EXT2_FL_USER_MODIFIABLE;
4424                 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
4425                 ei->i_flags = flags;
4426                 mutex_unlock(&inode->i_mutex);
4427 diff -NurpP --minimal linux-2.6.35/fs/ext2/namei.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/namei.c
4428 --- linux-2.6.35/fs/ext2/namei.c        2010-07-07 18:31:51.000000000 +0200
4429 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/namei.c  2010-08-02 17:05:05.000000000 +0200
4430 @@ -32,6 +32,7 @@
4431  
4432  #include <linux/pagemap.h>
4433  #include <linux/quotaops.h>
4434 +#include <linux/vs_tag.h>
4435  #include "ext2.h"
4436  #include "xattr.h"
4437  #include "acl.h"
4438 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
4439                                 return ERR_PTR(-EIO);
4440                         } else {
4441                                 return ERR_CAST(inode);
4442 +               dx_propagate_tag(nd, inode);
4443                         }
4444                 }
4445         }
4446 @@ -418,6 +420,7 @@ const struct inode_operations ext2_dir_i
4447  #endif
4448         .setattr        = ext2_setattr,
4449         .check_acl      = ext2_check_acl,
4450 +       .sync_flags     = ext2_sync_flags,
4451  };
4452  
4453  const struct inode_operations ext2_special_inode_operations = {
4454 diff -NurpP --minimal linux-2.6.35/fs/ext2/super.c linux-2.6.35-vs2.3.0.36.31/fs/ext2/super.c
4455 --- linux-2.6.35/fs/ext2/super.c        2010-08-02 16:52:48.000000000 +0200
4456 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext2/super.c  2010-08-02 17:05:05.000000000 +0200
4457 @@ -390,7 +390,8 @@ enum {
4458         Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
4459         Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
4460         Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
4461 -       Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
4462 +       Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
4463 +       Opt_tag, Opt_notag, Opt_tagid
4464  };
4465  
4466  static const match_table_t tokens = {
4467 @@ -418,6 +419,9 @@ static const match_table_t tokens = {
4468         {Opt_acl, "acl"},
4469         {Opt_noacl, "noacl"},
4470         {Opt_xip, "xip"},
4471 +       {Opt_tag, "tag"},
4472 +       {Opt_notag, "notag"},
4473 +       {Opt_tagid, "tagid=%u"},
4474         {Opt_grpquota, "grpquota"},
4475         {Opt_ignore, "noquota"},
4476         {Opt_quota, "quota"},
4477 @@ -488,6 +492,20 @@ static int parse_options(char *options, 
4478                 case Opt_nouid32:
4479                         set_opt (sbi->s_mount_opt, NO_UID32);
4480                         break;
4481 +#ifndef CONFIG_TAGGING_NONE
4482 +               case Opt_tag:
4483 +                       set_opt (sbi->s_mount_opt, TAGGED);
4484 +                       break;
4485 +               case Opt_notag:
4486 +                       clear_opt (sbi->s_mount_opt, TAGGED);
4487 +                       break;
4488 +#endif
4489 +#ifdef CONFIG_PROPAGATE
4490 +               case Opt_tagid:
4491 +                       /* use args[0] */
4492 +                       set_opt (sbi->s_mount_opt, TAGGED);
4493 +                       break;
4494 +#endif
4495                 case Opt_nocheck:
4496                         clear_opt (sbi->s_mount_opt, CHECK);
4497                         break;
4498 @@ -845,6 +863,8 @@ static int ext2_fill_super(struct super_
4499         if (!parse_options((char *) data, sb))
4500                 goto failed_mount;
4501  
4502 +       if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
4503 +               sb->s_flags |= MS_TAGGED;
4504         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4505                 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
4506                  MS_POSIXACL : 0);
4507 @@ -1217,6 +1237,14 @@ static int ext2_remount (struct super_bl
4508                 goto restore_opts;
4509         }
4510  
4511 +       if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
4512 +               !(sb->s_flags & MS_TAGGED)) {
4513 +               printk("EXT2-fs: %s: tagging not permitted on remount.\n",
4514 +                      sb->s_id);
4515 +               err = -EINVAL;
4516 +               goto restore_opts;
4517 +       }
4518 +
4519         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4520                 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4521  
4522 diff -NurpP --minimal linux-2.6.35/fs/ext3/file.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/file.c
4523 --- linux-2.6.35/fs/ext3/file.c 2010-07-07 18:31:51.000000000 +0200
4524 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/file.c   2010-08-02 17:05:05.000000000 +0200
4525 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
4526  #endif
4527         .check_acl      = ext3_check_acl,
4528         .fiemap         = ext3_fiemap,
4529 +       .sync_flags     = ext3_sync_flags,
4530  };
4531  
4532 diff -NurpP --minimal linux-2.6.35/fs/ext3/ialloc.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/ialloc.c
4533 --- linux-2.6.35/fs/ext3/ialloc.c       2010-08-02 16:52:48.000000000 +0200
4534 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/ialloc.c 2010-08-02 18:14:48.000000000 +0200
4535 @@ -23,6 +23,7 @@
4536  #include <linux/buffer_head.h>
4537  #include <linux/random.h>
4538  #include <linux/bitops.h>
4539 +#include <linux/vs_tag.h>
4540  
4541  #include <asm/byteorder.h>
4542  
4543 @@ -543,6 +544,7 @@ got:
4544                 inode->i_mode = mode;
4545                 inode->i_uid = current_fsuid();
4546                 inode->i_gid = dir->i_gid;
4547 +               inode->i_tag = dx_current_fstag(sb);
4548         } else
4549                 inode_init_owner(inode, dir, mode);
4550  
4551 diff -NurpP --minimal linux-2.6.35/fs/ext3/inode.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/inode.c
4552 --- linux-2.6.35/fs/ext3/inode.c        2010-08-02 16:52:48.000000000 +0200
4553 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/inode.c  2010-08-02 17:05:05.000000000 +0200
4554 @@ -38,6 +38,7 @@
4555  #include <linux/bio.h>
4556  #include <linux/fiemap.h>
4557  #include <linux/namei.h>
4558 +#include <linux/vs_tag.h>
4559  #include "xattr.h"
4560  #include "acl.h"
4561  
4562 @@ -2354,7 +2355,7 @@ static void ext3_free_branches(handle_t 
4563  
4564  int ext3_can_truncate(struct inode *inode)
4565  {
4566 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4567 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4568                 return 0;
4569         if (S_ISREG(inode->i_mode))
4570                 return 1;
4571 @@ -2739,36 +2740,60 @@ void ext3_set_inode_flags(struct inode *
4572  {
4573         unsigned int flags = EXT3_I(inode)->i_flags;
4574  
4575 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4576 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4577 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4578 +
4579 +       if (flags & EXT3_IMMUTABLE_FL)
4580 +               inode->i_flags |= S_IMMUTABLE;
4581 +       if (flags & EXT3_IXUNLINK_FL)
4582 +               inode->i_flags |= S_IXUNLINK;
4583 +
4584         if (flags & EXT3_SYNC_FL)
4585                 inode->i_flags |= S_SYNC;
4586         if (flags & EXT3_APPEND_FL)
4587                 inode->i_flags |= S_APPEND;
4588 -       if (flags & EXT3_IMMUTABLE_FL)
4589 -               inode->i_flags |= S_IMMUTABLE;
4590         if (flags & EXT3_NOATIME_FL)
4591                 inode->i_flags |= S_NOATIME;
4592         if (flags & EXT3_DIRSYNC_FL)
4593                 inode->i_flags |= S_DIRSYNC;
4594 +
4595 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
4596 +
4597 +       if (flags & EXT3_BARRIER_FL)
4598 +               inode->i_vflags |= V_BARRIER;
4599 +       if (flags & EXT3_COW_FL)
4600 +               inode->i_vflags |= V_COW;
4601  }
4602  
4603  /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
4604  void ext3_get_inode_flags(struct ext3_inode_info *ei)
4605  {
4606         unsigned int flags = ei->vfs_inode.i_flags;
4607 +       unsigned int vflags = ei->vfs_inode.i_vflags;
4608 +
4609 +       ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
4610 +                       EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
4611 +                       EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
4612 +                       EXT3_BARRIER_FL | EXT3_COW_FL);
4613 +
4614 +       if (flags & S_IMMUTABLE)
4615 +               ei->i_flags |= EXT3_IMMUTABLE_FL;
4616 +       if (flags & S_IXUNLINK)
4617 +               ei->i_flags |= EXT3_IXUNLINK_FL;
4618  
4619 -       ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
4620 -                       EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
4621         if (flags & S_SYNC)
4622                 ei->i_flags |= EXT3_SYNC_FL;
4623         if (flags & S_APPEND)
4624                 ei->i_flags |= EXT3_APPEND_FL;
4625 -       if (flags & S_IMMUTABLE)
4626 -               ei->i_flags |= EXT3_IMMUTABLE_FL;
4627         if (flags & S_NOATIME)
4628                 ei->i_flags |= EXT3_NOATIME_FL;
4629         if (flags & S_DIRSYNC)
4630                 ei->i_flags |= EXT3_DIRSYNC_FL;
4631 +
4632 +       if (vflags & V_BARRIER)
4633 +               ei->i_flags |= EXT3_BARRIER_FL;
4634 +       if (vflags & V_COW)
4635 +               ei->i_flags |= EXT3_COW_FL;
4636  }
4637  
4638  struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
4639 @@ -2782,6 +2807,8 @@ struct inode *ext3_iget(struct super_blo
4640         transaction_t *transaction;
4641         long ret;
4642         int block;
4643 +       uid_t uid;
4644 +       gid_t gid;
4645  
4646         inode = iget_locked(sb, ino);
4647         if (!inode)
4648 @@ -2798,12 +2825,17 @@ struct inode *ext3_iget(struct super_blo
4649         bh = iloc.bh;
4650         raw_inode = ext3_raw_inode(&iloc);
4651         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4652 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4653 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4654 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4655 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4656         if(!(test_opt (inode->i_sb, NO_UID32))) {
4657 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4658 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4659 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4660 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4661         }
4662 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4663 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4664 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4665 +               le16_to_cpu(raw_inode->i_raw_tag));
4666 +
4667         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4668         inode->i_size = le32_to_cpu(raw_inode->i_size);
4669         inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4670 @@ -2958,6 +2990,8 @@ static int ext3_do_update_inode(handle_t
4671         struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
4672         struct ext3_inode_info *ei = EXT3_I(inode);
4673         struct buffer_head *bh = iloc->bh;
4674 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4675 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4676         int err = 0, rc, block;
4677  
4678  again:
4679 @@ -2972,29 +3006,32 @@ again:
4680         ext3_get_inode_flags(ei);
4681         raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4682         if(!(test_opt(inode->i_sb, NO_UID32))) {
4683 -               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4684 -               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4685 +               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4686 +               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4687  /*
4688   * Fix up interoperability with old kernels. Otherwise, old inodes get
4689   * re-used with the upper 16 bits of the uid/gid intact
4690   */
4691                 if(!ei->i_dtime) {
4692                         raw_inode->i_uid_high =
4693 -                               cpu_to_le16(high_16_bits(inode->i_uid));
4694 +                               cpu_to_le16(high_16_bits(uid));
4695                         raw_inode->i_gid_high =
4696 -                               cpu_to_le16(high_16_bits(inode->i_gid));
4697 +                               cpu_to_le16(high_16_bits(gid));
4698                 } else {
4699                         raw_inode->i_uid_high = 0;
4700                         raw_inode->i_gid_high = 0;
4701                 }
4702         } else {
4703                 raw_inode->i_uid_low =
4704 -                       cpu_to_le16(fs_high2lowuid(inode->i_uid));
4705 +                       cpu_to_le16(fs_high2lowuid(uid));
4706                 raw_inode->i_gid_low =
4707 -                       cpu_to_le16(fs_high2lowgid(inode->i_gid));
4708 +                       cpu_to_le16(fs_high2lowgid(gid));
4709                 raw_inode->i_uid_high = 0;
4710                 raw_inode->i_gid_high = 0;
4711         }
4712 +#ifdef CONFIG_TAGGING_INTERN
4713 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4714 +#endif
4715         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4716         raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4717         raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4718 @@ -3154,7 +3191,8 @@ int ext3_setattr(struct dentry *dentry, 
4719         if (is_quota_modification(inode, attr))
4720                 dquot_initialize(inode);
4721         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4722 -               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4723 +               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4724 +               (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4725                 handle_t *handle;
4726  
4727                 /* (user+group)*(old+new) structure, inode write (sb,
4728 @@ -3176,6 +3214,8 @@ int ext3_setattr(struct dentry *dentry, 
4729                         inode->i_uid = attr->ia_uid;
4730                 if (attr->ia_valid & ATTR_GID)
4731                         inode->i_gid = attr->ia_gid;
4732 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4733 +                       inode->i_tag = attr->ia_tag;
4734                 error = ext3_mark_inode_dirty(handle, inode);
4735                 ext3_journal_stop(handle);
4736         }
4737 diff -NurpP --minimal linux-2.6.35/fs/ext3/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/ioctl.c
4738 --- linux-2.6.35/fs/ext3/ioctl.c        2009-06-11 17:13:03.000000000 +0200
4739 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/ioctl.c  2010-08-02 17:05:05.000000000 +0200
4740 @@ -8,6 +8,7 @@
4741   */
4742  
4743  #include <linux/fs.h>
4744 +#include <linux/mount.h>
4745  #include <linux/jbd.h>
4746  #include <linux/capability.h>
4747  #include <linux/ext3_fs.h>
4748 @@ -17,6 +18,34 @@
4749  #include <linux/compat.h>
4750  #include <asm/uaccess.h>
4751  
4752 +
4753 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
4754 +{
4755 +       handle_t *handle = NULL;
4756 +       struct ext3_iloc iloc;
4757 +       int err;
4758 +
4759 +       handle = ext3_journal_start(inode, 1);
4760 +       if (IS_ERR(handle))
4761 +               return PTR_ERR(handle);
4762 +
4763 +       if (IS_SYNC(inode))
4764 +               handle->h_sync = 1;
4765 +       err = ext3_reserve_inode_write(handle, inode, &iloc);
4766 +       if (err)
4767 +               goto flags_err;
4768 +
4769 +       inode->i_flags = flags;
4770 +       inode->i_vflags = vflags;
4771 +       ext3_get_inode_flags(EXT3_I(inode));
4772 +       inode->i_ctime = CURRENT_TIME_SEC;
4773 +
4774 +       err = ext3_mark_iloc_dirty(handle, inode, &iloc);
4775 +flags_err:
4776 +       ext3_journal_stop(handle);
4777 +       return err;
4778 +}
4779 +
4780  long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4781  {
4782         struct inode *inode = filp->f_dentry->d_inode;
4783 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
4784  
4785                 flags = ext3_mask_flags(inode->i_mode, flags);
4786  
4787 +               if (IS_BARRIER(inode)) {
4788 +                       vxwprintk_task(1, "messing with the barrier.");
4789 +                       return -EACCES;
4790 +               }
4791 +
4792                 mutex_lock(&inode->i_mutex);
4793  
4794                 /* Is it quota file? Do not allow user to mess with it */
4795 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
4796                  *
4797                  * This test looks nicer. Thanks to Pauline Middelink
4798                  */
4799 -               if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
4800 +               if ((oldflags & EXT3_IMMUTABLE_FL) ||
4801 +                       ((flags ^ oldflags) & (EXT3_APPEND_FL |
4802 +                       EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
4803                         if (!capable(CAP_LINUX_IMMUTABLE))
4804                                 goto flags_out;
4805                 }
4806 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
4807                 if (err)
4808                         goto flags_err;
4809  
4810 -               flags = flags & EXT3_FL_USER_MODIFIABLE;
4811 +               flags &= EXT3_FL_USER_MODIFIABLE;
4812                 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
4813                 ei->i_flags = flags;
4814  
4815 diff -NurpP --minimal linux-2.6.35/fs/ext3/namei.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/namei.c
4816 --- linux-2.6.35/fs/ext3/namei.c        2010-07-07 18:31:51.000000000 +0200
4817 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/namei.c  2010-08-02 17:05:05.000000000 +0200
4818 @@ -36,6 +36,7 @@
4819  #include <linux/quotaops.h>
4820  #include <linux/buffer_head.h>
4821  #include <linux/bio.h>
4822 +#include <linux/vs_tag.h>
4823  
4824  #include "namei.h"
4825  #include "xattr.h"
4826 @@ -912,6 +913,7 @@ restart:
4827                                 if (bh)
4828                                         ll_rw_block(READ_META, 1, &bh);
4829                         }
4830 +               dx_propagate_tag(nd, inode);
4831                 }
4832                 if ((bh = bh_use[ra_ptr++]) == NULL)
4833                         goto next;
4834 @@ -2466,6 +2468,7 @@ const struct inode_operations ext3_dir_i
4835         .removexattr    = generic_removexattr,
4836  #endif
4837         .check_acl      = ext3_check_acl,
4838 +       .sync_flags     = ext3_sync_flags,
4839  };
4840  
4841  const struct inode_operations ext3_special_inode_operations = {
4842 diff -NurpP --minimal linux-2.6.35/fs/ext3/super.c linux-2.6.35-vs2.3.0.36.31/fs/ext3/super.c
4843 --- linux-2.6.35/fs/ext3/super.c        2010-08-02 16:52:48.000000000 +0200
4844 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext3/super.c  2010-08-02 18:14:19.000000000 +0200
4845 @@ -817,7 +817,8 @@ enum {
4846         Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4847         Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
4848         Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
4849 -       Opt_resize, Opt_usrquota, Opt_grpquota
4850 +       Opt_resize, Opt_usrquota, Opt_grpquota,
4851 +       Opt_tag, Opt_notag, Opt_tagid
4852  };
4853  
4854  static const match_table_t tokens = {
4855 @@ -874,6 +875,9 @@ static const match_table_t tokens = {
4856         {Opt_barrier, "barrier"},
4857         {Opt_nobarrier, "nobarrier"},
4858         {Opt_resize, "resize"},
4859 +       {Opt_tag, "tag"},
4860 +       {Opt_notag, "notag"},
4861 +       {Opt_tagid, "tagid=%u"},
4862         {Opt_err, NULL},
4863  };
4864  
4865 @@ -1026,6 +1030,20 @@ static int parse_options (char *options,
4866                 case Opt_nouid32:
4867                         set_opt (sbi->s_mount_opt, NO_UID32);
4868                         break;
4869 +#ifndef CONFIG_TAGGING_NONE
4870 +               case Opt_tag:
4871 +                       set_opt (sbi->s_mount_opt, TAGGED);
4872 +                       break;
4873 +               case Opt_notag:
4874 +                       clear_opt (sbi->s_mount_opt, TAGGED);
4875 +                       break;
4876 +#endif
4877 +#ifdef CONFIG_PROPAGATE
4878 +               case Opt_tagid:
4879 +                       /* use args[0] */
4880 +                       set_opt (sbi->s_mount_opt, TAGGED);
4881 +                       break;
4882 +#endif
4883                 case Opt_nocheck:
4884                         clear_opt (sbi->s_mount_opt, CHECK);
4885                         break;
4886 @@ -1712,6 +1730,9 @@ static int ext3_fill_super (struct super
4887                             NULL, 0))
4888                 goto failed_mount;
4889  
4890 +       if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
4891 +               sb->s_flags |= MS_TAGGED;
4892 +
4893         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4894                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
4895  
4896 @@ -2585,6 +2606,14 @@ static int ext3_remount (struct super_bl
4897         if (test_opt(sb, ABORT))
4898                 ext3_abort(sb, __func__, "Abort forced by user");
4899  
4900 +       if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
4901 +               !(sb->s_flags & MS_TAGGED)) {
4902 +               printk("EXT3-fs: %s: tagging not permitted on remount.\n",
4903 +                       sb->s_id);
4904 +               err = -EINVAL;
4905 +               goto restore_opts;
4906 +       }
4907 +
4908         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4909                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
4910  
4911 diff -NurpP --minimal linux-2.6.35/fs/ext4/ext4.h linux-2.6.35-vs2.3.0.36.31/fs/ext4/ext4.h
4912 --- linux-2.6.35/fs/ext4/ext4.h 2010-08-02 16:52:48.000000000 +0200
4913 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/ext4.h   2010-08-02 17:05:05.000000000 +0200
4914 @@ -318,8 +318,12 @@ struct flex_groups {
4915  #define EXT4_EXTENTS_FL                        0x00080000 /* Inode uses extents */
4916  #define EXT4_EA_INODE_FL               0x00200000 /* Inode used for large EA */
4917  #define EXT4_EOFBLOCKS_FL              0x00400000 /* Blocks allocated beyond EOF */
4918 +#define EXT4_IXUNLINK_FL               0x08000000 /* Immutable invert on unlink */
4919  #define EXT4_RESERVED_FL               0x80000000 /* reserved for ext4 lib */
4920  
4921 +#define EXT4_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
4922 +#define EXT4_COW_FL                    0x20000000 /* Copy on Write marker */
4923 +
4924  #define EXT4_FL_USER_VISIBLE           0x004BDFFF /* User visible flags */
4925  #define EXT4_FL_USER_MODIFIABLE                0x004B80FF /* User modifiable flags */
4926  
4927 @@ -588,7 +592,8 @@ struct ext4_inode {
4928                         __le16  l_i_file_acl_high;
4929                         __le16  l_i_uid_high;   /* these 2 fields */
4930                         __le16  l_i_gid_high;   /* were reserved2[0] */
4931 -                       __u32   l_i_reserved2;
4932 +                       __le16  l_i_tag;        /* Context Tag */
4933 +                       __u16   l_i_reserved2;
4934                 } linux2;
4935                 struct {
4936                         __le16  h_i_reserved1;  /* Obsoleted fragment number/size which are removed in ext4 */
4937 @@ -702,6 +707,7 @@ do {                                                                               \
4938  #define i_gid_low      i_gid
4939  #define i_uid_high     osd2.linux2.l_i_uid_high
4940  #define i_gid_high     osd2.linux2.l_i_gid_high
4941 +#define i_raw_tag      osd2.linux2.l_i_tag
4942  #define i_reserved2    osd2.linux2.l_i_reserved2
4943  
4944  #elif defined(__GNU__)
4945 @@ -881,6 +887,7 @@ struct ext4_inode_info {
4946  #define EXT4_MOUNT_JOURNAL_CHECKSUM    0x800000 /* Journal checksums */
4947  #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT        0x1000000 /* Journal Async Commit */
4948  #define EXT4_MOUNT_I_VERSION            0x2000000 /* i_version support */
4949 +#define EXT4_MOUNT_TAGGED              0x4000000 /* Enable Context Tags */
4950  #define EXT4_MOUNT_DELALLOC            0x8000000 /* Delalloc support */
4951  #define EXT4_MOUNT_DATA_ERR_ABORT      0x10000000 /* Abort on file data write */
4952  #define EXT4_MOUNT_BLOCK_VALIDITY      0x20000000 /* Block validity checking */
4953 @@ -1910,6 +1917,7 @@ extern int ext4_get_blocks(handle_t *han
4954                            struct buffer_head *bh, int flags);
4955  extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4956                         __u64 start, __u64 len);
4957 +extern int ext4_sync_flags(struct inode *, int, int);
4958  /* move_extent.c */
4959  extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
4960                              __u64 start_orig, __u64 start_donor,
4961 diff -NurpP --minimal linux-2.6.35/fs/ext4/file.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/file.c
4962 --- linux-2.6.35/fs/ext4/file.c 2010-08-02 16:52:48.000000000 +0200
4963 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/file.c   2010-08-02 17:05:05.000000000 +0200
4964 @@ -160,5 +160,6 @@ const struct inode_operations ext4_file_
4965         .check_acl      = ext4_check_acl,
4966         .fallocate      = ext4_fallocate,
4967         .fiemap         = ext4_fiemap,
4968 +       .sync_flags     = ext4_sync_flags,
4969  };
4970  
4971 diff -NurpP --minimal linux-2.6.35/fs/ext4/ialloc.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/ialloc.c
4972 --- linux-2.6.35/fs/ext4/ialloc.c       2010-08-02 16:52:48.000000000 +0200
4973 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/ialloc.c 2010-08-02 18:12:48.000000000 +0200
4974 @@ -22,6 +22,7 @@
4975  #include <linux/random.h>
4976  #include <linux/bitops.h>
4977  #include <linux/blkdev.h>
4978 +#include <linux/vs_tag.h>
4979  #include <asm/byteorder.h>
4980  
4981  #include "ext4.h"
4982 @@ -976,6 +977,7 @@ got:
4983                 inode->i_mode = mode;
4984                 inode->i_uid = current_fsuid();
4985                 inode->i_gid = dir->i_gid;
4986 +               inode->i_tag = dx_current_fstag(sb);
4987         } else
4988                 inode_init_owner(inode, dir, mode);
4989  
4990 diff -NurpP --minimal linux-2.6.35/fs/ext4/inode.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/inode.c
4991 --- linux-2.6.35/fs/ext4/inode.c        2010-08-02 16:52:48.000000000 +0200
4992 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/inode.c  2010-08-02 18:11:10.000000000 +0200
4993 @@ -40,6 +40,7 @@
4994  #include <linux/workqueue.h>
4995  #include <linux/kernel.h>
4996  #include <linux/slab.h>
4997 +#include <linux/vs_tag.h>
4998  
4999  #include "ext4_jbd2.h"
5000  #include "xattr.h"
5001 @@ -4575,7 +4576,7 @@ static void ext4_free_branches(handle_t 
5002  
5003  int ext4_can_truncate(struct inode *inode)
5004  {
5005 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5006 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5007                 return 0;
5008         if (S_ISREG(inode->i_mode))
5009                 return 1;
5010 @@ -4926,41 +4927,64 @@ void ext4_set_inode_flags(struct inode *
5011  {
5012         unsigned int flags = EXT4_I(inode)->i_flags;
5013  
5014 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5015 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5016 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5017 +
5018 +       if (flags & EXT4_IMMUTABLE_FL)
5019 +               inode->i_flags |= S_IMMUTABLE;
5020 +       if (flags & EXT4_IXUNLINK_FL)
5021 +               inode->i_flags |= S_IXUNLINK;
5022 +
5023         if (flags & EXT4_SYNC_FL)
5024                 inode->i_flags |= S_SYNC;
5025         if (flags & EXT4_APPEND_FL)
5026                 inode->i_flags |= S_APPEND;
5027 -       if (flags & EXT4_IMMUTABLE_FL)
5028 -               inode->i_flags |= S_IMMUTABLE;
5029         if (flags & EXT4_NOATIME_FL)
5030                 inode->i_flags |= S_NOATIME;
5031         if (flags & EXT4_DIRSYNC_FL)
5032                 inode->i_flags |= S_DIRSYNC;
5033 +
5034 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
5035 +
5036 +       if (flags & EXT4_BARRIER_FL)
5037 +               inode->i_vflags |= V_BARRIER;
5038 +       if (flags & EXT4_COW_FL)
5039 +               inode->i_vflags |= V_COW;
5040  }
5041  
5042  /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
5043  void ext4_get_inode_flags(struct ext4_inode_info *ei)
5044  {
5045 -       unsigned int vfs_fl;
5046 +       unsigned int vfs_fl, vfs_vf;
5047         unsigned long old_fl, new_fl;
5048  
5049         do {
5050                 vfs_fl = ei->vfs_inode.i_flags;
5051 +               vfs_vf = ei->vfs_inode.i_vflags;
5052                 old_fl = ei->i_flags;
5053                 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
5054                                 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
5055 -                               EXT4_DIRSYNC_FL);
5056 +                               EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
5057 +                               EXT4_COW_FL);
5058 +
5059 +               if (vfs_fl & S_IMMUTABLE)
5060 +                       new_fl |= EXT4_IMMUTABLE_FL;
5061 +               if (vfs_fl & S_IXUNLINK)
5062 +                       new_fl |= EXT4_IXUNLINK_FL;
5063 +
5064                 if (vfs_fl & S_SYNC)
5065                         new_fl |= EXT4_SYNC_FL;
5066                 if (vfs_fl & S_APPEND)
5067                         new_fl |= EXT4_APPEND_FL;
5068 -               if (vfs_fl & S_IMMUTABLE)
5069 -                       new_fl |= EXT4_IMMUTABLE_FL;
5070                 if (vfs_fl & S_NOATIME)
5071                         new_fl |= EXT4_NOATIME_FL;
5072                 if (vfs_fl & S_DIRSYNC)
5073                         new_fl |= EXT4_DIRSYNC_FL;
5074 +
5075 +               if (vfs_vf & V_BARRIER)
5076 +                       new_fl |= EXT4_BARRIER_FL;
5077 +               if (vfs_vf & V_COW)
5078 +                       new_fl |= EXT4_COW_FL;
5079         } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
5080  }
5081  
5082 @@ -4996,6 +5020,8 @@ struct inode *ext4_iget(struct super_blo
5083         journal_t *journal = EXT4_SB(sb)->s_journal;
5084         long ret;
5085         int block;
5086 +       uid_t uid;
5087 +       gid_t gid;
5088  
5089         inode = iget_locked(sb, ino);
5090         if (!inode)
5091 @@ -5011,12 +5037,16 @@ struct inode *ext4_iget(struct super_blo
5092                 goto bad_inode;
5093         raw_inode = ext4_raw_inode(&iloc);
5094         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
5095 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5096 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5097 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5098 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5099         if (!(test_opt(inode->i_sb, NO_UID32))) {
5100 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5101 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5102 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5103 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5104         }
5105 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5106 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5107 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5108 +               le16_to_cpu(raw_inode->i_raw_tag));
5109         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
5110  
5111         ei->i_state_flags = 0;
5112 @@ -5235,6 +5265,8 @@ static int ext4_do_update_inode(handle_t
5113         struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
5114         struct ext4_inode_info *ei = EXT4_I(inode);
5115         struct buffer_head *bh = iloc->bh;
5116 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5117 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5118         int err = 0, rc, block;
5119  
5120         /* For fields not not tracking in the in-memory inode,
5121 @@ -5245,29 +5277,32 @@ static int ext4_do_update_inode(handle_t
5122         ext4_get_inode_flags(ei);
5123         raw_inode->i_mode = cpu_to_le16(inode->i_mode);
5124         if (!(test_opt(inode->i_sb, NO_UID32))) {
5125 -               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
5126 -               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
5127 +               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
5128 +               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
5129  /*
5130   * Fix up interoperability with old kernels. Otherwise, old inodes get
5131   * re-used with the upper 16 bits of the uid/gid intact
5132   */
5133                 if (!ei->i_dtime) {
5134                         raw_inode->i_uid_high =
5135 -                               cpu_to_le16(high_16_bits(inode->i_uid));
5136 +                               cpu_to_le16(high_16_bits(uid));
5137                         raw_inode->i_gid_high =
5138 -                               cpu_to_le16(high_16_bits(inode->i_gid));
5139 +                               cpu_to_le16(high_16_bits(gid));
5140                 } else {
5141                         raw_inode->i_uid_high = 0;
5142                         raw_inode->i_gid_high = 0;
5143                 }
5144         } else {
5145                 raw_inode->i_uid_low =
5146 -                       cpu_to_le16(fs_high2lowuid(inode->i_uid));
5147 +                       cpu_to_le16(fs_high2lowuid(uid));
5148                 raw_inode->i_gid_low =
5149 -                       cpu_to_le16(fs_high2lowgid(inode->i_gid));
5150 +                       cpu_to_le16(fs_high2lowgid(gid));
5151                 raw_inode->i_uid_high = 0;
5152                 raw_inode->i_gid_high = 0;
5153         }
5154 +#ifdef CONFIG_TAGGING_INTERN
5155 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
5156 +#endif
5157         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
5158  
5159         EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
5160 @@ -5453,7 +5488,8 @@ int ext4_setattr(struct dentry *dentry, 
5161         if (is_quota_modification(inode, attr))
5162                 dquot_initialize(inode);
5163         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
5164 -               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
5165 +               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
5166 +               (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
5167                 handle_t *handle;
5168  
5169                 /* (user+group)*(old+new) structure, inode write (sb,
5170 @@ -5475,6 +5511,8 @@ int ext4_setattr(struct dentry *dentry, 
5171                         inode->i_uid = attr->ia_uid;
5172                 if (attr->ia_valid & ATTR_GID)
5173                         inode->i_gid = attr->ia_gid;
5174 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5175 +                       inode->i_tag = attr->ia_tag;
5176                 error = ext4_mark_inode_dirty(handle, inode);
5177                 ext4_journal_stop(handle);
5178         }
5179 diff -NurpP --minimal linux-2.6.35/fs/ext4/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/ioctl.c
5180 --- linux-2.6.35/fs/ext4/ioctl.c        2010-08-02 16:52:48.000000000 +0200
5181 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/ioctl.c  2010-08-02 17:05:05.000000000 +0200
5182 @@ -14,10 +14,39 @@
5183  #include <linux/compat.h>
5184  #include <linux/mount.h>
5185  #include <linux/file.h>
5186 +#include <linux/vs_tag.h>
5187  #include <asm/uaccess.h>
5188  #include "ext4_jbd2.h"
5189  #include "ext4.h"
5190  
5191 +
5192 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
5193 +{
5194 +       handle_t *handle = NULL;
5195 +       struct ext4_iloc iloc;
5196 +       int err;
5197 +
5198 +       handle = ext4_journal_start(inode, 1);
5199 +       if (IS_ERR(handle))
5200 +               return PTR_ERR(handle);
5201 +
5202 +       if (IS_SYNC(inode))
5203 +               ext4_handle_sync(handle);
5204 +       err = ext4_reserve_inode_write(handle, inode, &iloc);
5205 +       if (err)
5206 +               goto flags_err;
5207 +
5208 +       inode->i_flags = flags;
5209 +       inode->i_vflags = vflags;
5210 +       ext4_get_inode_flags(EXT4_I(inode));
5211 +       inode->i_ctime = ext4_current_time(inode);
5212 +
5213 +       err = ext4_mark_iloc_dirty(handle, inode, &iloc);
5214 +flags_err:
5215 +       ext4_journal_stop(handle);
5216 +       return err;
5217 +}
5218 +
5219  long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5220  {
5221         struct inode *inode = filp->f_dentry->d_inode;
5222 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
5223  
5224                 flags = ext4_mask_flags(inode->i_mode, flags);
5225  
5226 +               if (IS_BARRIER(inode)) {
5227 +                       vxwprintk_task(1, "messing with the barrier.");
5228 +                       return -EACCES;
5229 +               }
5230 +
5231                 err = -EPERM;
5232                 mutex_lock(&inode->i_mutex);
5233                 /* Is it quota file? Do not allow user to mess with it */
5234 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
5235                  *
5236                  * This test looks nicer. Thanks to Pauline Middelink
5237                  */
5238 -               if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
5239 +               if ((oldflags & EXT4_IMMUTABLE_FL) ||
5240 +                       ((flags ^ oldflags) & (EXT4_APPEND_FL |
5241 +                       EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
5242                         if (!capable(CAP_LINUX_IMMUTABLE))
5243                                 goto flags_out;
5244                 }
5245 diff -NurpP --minimal linux-2.6.35/fs/ext4/namei.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/namei.c
5246 --- linux-2.6.35/fs/ext4/namei.c        2010-08-02 16:52:48.000000000 +0200
5247 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/namei.c  2010-08-02 17:05:05.000000000 +0200
5248 @@ -34,6 +34,7 @@
5249  #include <linux/quotaops.h>
5250  #include <linux/buffer_head.h>
5251  #include <linux/bio.h>
5252 +#include <linux/vs_tag.h>
5253  #include "ext4.h"
5254  #include "ext4_jbd2.h"
5255  
5256 @@ -937,6 +938,7 @@ restart:
5257                                 if (bh)
5258                                         ll_rw_block(READ_META, 1, &bh);
5259                         }
5260 +               dx_propagate_tag(nd, inode);
5261                 }
5262                 if ((bh = bh_use[ra_ptr++]) == NULL)
5263                         goto next;
5264 @@ -2550,6 +2552,7 @@ const struct inode_operations ext4_dir_i
5265  #endif
5266         .check_acl      = ext4_check_acl,
5267         .fiemap         = ext4_fiemap,
5268 +       .sync_flags     = ext4_sync_flags,
5269  };
5270  
5271  const struct inode_operations ext4_special_inode_operations = {
5272 diff -NurpP --minimal linux-2.6.35/fs/ext4/super.c linux-2.6.35-vs2.3.0.36.31/fs/ext4/super.c
5273 --- linux-2.6.35/fs/ext4/super.c        2010-08-02 16:52:49.000000000 +0200
5274 +++ linux-2.6.35-vs2.3.0.36.31/fs/ext4/super.c  2010-08-02 17:05:05.000000000 +0200
5275 @@ -1161,6 +1161,7 @@ enum {
5276         Opt_inode_readahead_blks, Opt_journal_ioprio,
5277         Opt_dioread_nolock, Opt_dioread_lock,
5278         Opt_discard, Opt_nodiscard,
5279 +       Opt_tag, Opt_notag, Opt_tagid
5280  };
5281  
5282  static const match_table_t tokens = {
5283 @@ -1231,6 +1232,9 @@ static const match_table_t tokens = {
5284         {Opt_dioread_lock, "dioread_lock"},
5285         {Opt_discard, "discard"},
5286         {Opt_nodiscard, "nodiscard"},
5287 +       {Opt_tag, "tag"},
5288 +       {Opt_notag, "notag"},
5289 +       {Opt_tagid, "tagid=%u"},
5290         {Opt_err, NULL},
5291  };
5292  
5293 @@ -1399,6 +1403,20 @@ static int parse_options(char *options, 
5294                 case Opt_nouid32:
5295                         set_opt(sbi->s_mount_opt, NO_UID32);
5296                         break;
5297 +#ifndef CONFIG_TAGGING_NONE
5298 +               case Opt_tag:
5299 +                       set_opt (sbi->s_mount_opt, TAGGED);
5300 +                       break;
5301 +               case Opt_notag:
5302 +                       clear_opt (sbi->s_mount_opt, TAGGED);
5303 +                       break;
5304 +#endif
5305 +#ifdef CONFIG_PROPAGATE
5306 +               case Opt_tagid:
5307 +                       /* use args[0] */
5308 +                       set_opt (sbi->s_mount_opt, TAGGED);
5309 +                       break;
5310 +#endif
5311                 case Opt_debug:
5312                         set_opt(sbi->s_mount_opt, DEBUG);
5313                         break;
5314 @@ -2566,6 +2584,9 @@ static int ext4_fill_super(struct super_
5315                            &journal_ioprio, NULL, 0))
5316                 goto failed_mount;
5317  
5318 +       if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
5319 +               sb->s_flags |= MS_TAGGED;
5320 +
5321         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5322                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5323  
5324 @@ -3618,6 +3639,14 @@ static int ext4_remount(struct super_blo
5325         if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
5326                 ext4_abort(sb, __func__, "Abort forced by user");
5327  
5328 +       if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
5329 +               !(sb->s_flags & MS_TAGGED)) {
5330 +               printk("EXT4-fs: %s: tagging not permitted on remount.\n",
5331 +                       sb->s_id);
5332 +               err = -EINVAL;
5333 +               goto restore_opts;
5334 +       }
5335 +
5336         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5337                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5338  
5339 diff -NurpP --minimal linux-2.6.35/fs/fcntl.c linux-2.6.35-vs2.3.0.36.31/fs/fcntl.c
5340 --- linux-2.6.35/fs/fcntl.c     2010-08-02 16:52:49.000000000 +0200
5341 +++ linux-2.6.35-vs2.3.0.36.31/fs/fcntl.c       2010-08-02 17:05:06.000000000 +0200
5342 @@ -20,6 +20,7 @@
5343  #include <linux/signal.h>
5344  #include <linux/rcupdate.h>
5345  #include <linux/pid_namespace.h>
5346 +#include <linux/vs_limit.h>
5347  
5348  #include <asm/poll.h>
5349  #include <asm/siginfo.h>
5350 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
5351  
5352         if (tofree)
5353                 filp_close(tofree, files);
5354 +       else
5355 +               vx_openfd_inc(newfd);   /* fd was unused */
5356  
5357         return newfd;
5358  
5359 @@ -434,6 +437,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
5360         filp = fget(fd);
5361         if (!filp)
5362                 goto out;
5363 +       if (!vx_files_avail(1))
5364 +               goto out;
5365  
5366         err = security_file_fcntl(filp, cmd, arg);
5367         if (err) {
5368 diff -NurpP --minimal linux-2.6.35/fs/file.c linux-2.6.35-vs2.3.0.36.31/fs/file.c
5369 --- linux-2.6.35/fs/file.c      2010-07-07 18:31:51.000000000 +0200
5370 +++ linux-2.6.35-vs2.3.0.36.31/fs/file.c        2010-08-02 17:05:06.000000000 +0200
5371 @@ -20,6 +20,7 @@
5372  #include <linux/spinlock.h>
5373  #include <linux/rcupdate.h>
5374  #include <linux/workqueue.h>
5375 +#include <linux/vs_limit.h>
5376  
5377  struct fdtable_defer {
5378         spinlock_t lock;
5379 @@ -368,6 +369,8 @@ struct files_struct *dup_fd(struct files
5380                 struct file *f = *old_fds++;
5381                 if (f) {
5382                         get_file(f);
5383 +                       /* TODO: sum it first for check and performance */
5384 +                       vx_openfd_inc(open_files - i);
5385                 } else {
5386                         /*
5387                          * The fd may be claimed in the fd bitmap but not yet
5388 @@ -476,6 +479,7 @@ repeat:
5389         else
5390                 FD_CLR(fd, fdt->close_on_exec);
5391         error = fd;
5392 +       vx_openfd_inc(fd);
5393  #if 1
5394         /* Sanity check */
5395         if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
5396 diff -NurpP --minimal linux-2.6.35/fs/file_table.c linux-2.6.35-vs2.3.0.36.31/fs/file_table.c
5397 --- linux-2.6.35/fs/file_table.c        2010-08-02 16:52:49.000000000 +0200
5398 +++ linux-2.6.35-vs2.3.0.36.31/fs/file_table.c  2010-08-02 17:05:06.000000000 +0200
5399 @@ -22,6 +22,8 @@
5400  #include <linux/sysctl.h>
5401  #include <linux/percpu_counter.h>
5402  #include <linux/ima.h>
5403 +#include <linux/vs_limit.h>
5404 +#include <linux/vs_context.h>
5405  
5406  #include <asm/atomic.h>
5407  
5408 @@ -133,6 +135,8 @@ struct file *get_empty_filp(void)
5409         spin_lock_init(&f->f_lock);
5410         eventpoll_init_file(f);
5411         /* f->f_version: 0 */
5412 +       f->f_xid = vx_current_xid();
5413 +       vx_files_inc(f);
5414         return f;
5415  
5416  over:
5417 @@ -249,6 +253,8 @@ static void __fput(struct file *file)
5418                 cdev_put(inode->i_cdev);
5419         fops_put(file->f_op);
5420         put_pid(file->f_owner.pid);
5421 +       vx_files_dec(file);
5422 +       file->f_xid = 0;
5423         file_kill(file);
5424         if (file->f_mode & FMODE_WRITE)
5425                 drop_file_write_access(file);
5426 @@ -324,6 +330,8 @@ void put_filp(struct file *file)
5427  {
5428         if (atomic_long_dec_and_test(&file->f_count)) {
5429                 security_file_free(file);
5430 +               vx_files_dec(file);
5431 +               file->f_xid = 0;
5432                 file_kill(file);
5433                 file_free(file);
5434         }
5435 diff -NurpP --minimal linux-2.6.35/fs/fs_struct.c linux-2.6.35-vs2.3.0.36.31/fs/fs_struct.c
5436 --- linux-2.6.35/fs/fs_struct.c 2009-06-11 17:13:04.000000000 +0200
5437 +++ linux-2.6.35-vs2.3.0.36.31/fs/fs_struct.c   2010-08-02 17:05:06.000000000 +0200
5438 @@ -4,6 +4,7 @@
5439  #include <linux/path.h>
5440  #include <linux/slab.h>
5441  #include <linux/fs_struct.h>
5442 +#include <linux/vserver/global.h>
5443  
5444  /*
5445   * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
5446 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
5447  {
5448         path_put(&fs->root);
5449         path_put(&fs->pwd);
5450 +       atomic_dec(&vs_global_fs);
5451         kmem_cache_free(fs_cachep, fs);
5452  }
5453  
5454 @@ -112,6 +114,7 @@ struct fs_struct *copy_fs_struct(struct 
5455                 fs->pwd = old->pwd;
5456                 path_get(&old->pwd);
5457                 read_unlock(&old->lock);
5458 +               atomic_inc(&vs_global_fs);
5459         }
5460         return fs;
5461  }
5462 diff -NurpP --minimal linux-2.6.35/fs/gfs2/file.c linux-2.6.35-vs2.3.0.36.31/fs/gfs2/file.c
5463 --- linux-2.6.35/fs/gfs2/file.c 2010-08-02 16:52:49.000000000 +0200
5464 +++ linux-2.6.35-vs2.3.0.36.31/fs/gfs2/file.c   2010-08-02 17:05:06.000000000 +0200
5465 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
5466         [7] = GFS2_DIF_NOATIME,
5467         [12] = GFS2_DIF_EXHASH,
5468         [14] = GFS2_DIF_INHERIT_JDATA,
5469 +       [27] = GFS2_DIF_IXUNLINK,
5470 +       [26] = GFS2_DIF_BARRIER,
5471 +       [29] = GFS2_DIF_COW,
5472  };
5473  
5474  static const u32 gfs2_to_fsflags[32] = {
5475 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
5476         [gfs2fl_NoAtime] = FS_NOATIME_FL,
5477         [gfs2fl_ExHash] = FS_INDEX_FL,
5478         [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
5479 +       [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
5480 +       [gfs2fl_Barrier] = FS_BARRIER_FL,
5481 +       [gfs2fl_Cow] = FS_COW_FL,
5482  };
5483  
5484  static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
5485 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
5486  {
5487         struct gfs2_inode *ip = GFS2_I(inode);
5488         unsigned int flags = inode->i_flags;
5489 +       unsigned int vflags = inode->i_vflags;
5490 +
5491 +       flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5492 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5493  
5494 -       flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5495         if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
5496                 flags |= S_IMMUTABLE;
5497 +       if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
5498 +               flags |= S_IXUNLINK;
5499 +
5500         if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
5501                 flags |= S_APPEND;
5502         if (ip->i_diskflags & GFS2_DIF_NOATIME)
5503 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
5504         if (ip->i_diskflags & GFS2_DIF_SYNC)
5505                 flags |= S_SYNC;
5506         inode->i_flags = flags;
5507 +
5508 +       vflags &= ~(V_BARRIER | V_COW);
5509 +
5510 +       if (ip->i_diskflags & GFS2_DIF_BARRIER)
5511 +               vflags |= V_BARRIER;
5512 +       if (ip->i_diskflags & GFS2_DIF_COW)
5513 +               vflags |= V_COW;
5514 +       inode->i_vflags = vflags;
5515 +}
5516 +
5517 +void gfs2_get_inode_flags(struct inode *inode)
5518 +{
5519 +       struct gfs2_inode *ip = GFS2_I(inode);
5520 +       unsigned int flags = inode->i_flags;
5521 +       unsigned int vflags = inode->i_vflags;
5522 +
5523 +       ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
5524 +                       GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
5525 +                       GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
5526 +                       GFS2_DIF_BARRIER | GFS2_DIF_COW);
5527 +
5528 +       if (flags & S_IMMUTABLE)
5529 +               ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
5530 +       if (flags & S_IXUNLINK)
5531 +               ip->i_diskflags |= GFS2_DIF_IXUNLINK;
5532 +
5533 +       if (flags & S_APPEND)
5534 +               ip->i_diskflags |= GFS2_DIF_APPENDONLY;
5535 +       if (flags & S_NOATIME)
5536 +               ip->i_diskflags |= GFS2_DIF_NOATIME;
5537 +       if (flags & S_SYNC)
5538 +               ip->i_diskflags |= GFS2_DIF_SYNC;
5539 +
5540 +       if (vflags & V_BARRIER)
5541 +               ip->i_diskflags |= GFS2_DIF_BARRIER;
5542 +       if (vflags & V_COW)
5543 +               ip->i_diskflags |= GFS2_DIF_COW;
5544  }
5545  
5546  /* Flags that can be set by user space */
5547 @@ -293,6 +342,37 @@ static int gfs2_set_flags(struct file *f
5548         return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
5549  }
5550  
5551 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
5552 +{
5553 +       struct gfs2_inode *ip = GFS2_I(inode);
5554 +       struct gfs2_sbd *sdp = GFS2_SB(inode);
5555 +       struct buffer_head *bh;
5556 +       struct gfs2_holder gh;
5557 +       int error;
5558 +
5559 +       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
5560 +       if (error)
5561 +               return error;
5562 +       error = gfs2_trans_begin(sdp, RES_DINODE, 0);
5563 +       if (error)
5564 +               goto out;
5565 +       error = gfs2_meta_inode_buffer(ip, &bh);
5566 +       if (error)
5567 +               goto out_trans_end;
5568 +       gfs2_trans_add_bh(ip->i_gl, bh, 1);
5569 +       inode->i_flags = flags;
5570 +       inode->i_vflags = vflags;
5571 +       gfs2_get_inode_flags(inode);
5572 +       gfs2_dinode_out(ip, bh->b_data);
5573 +       brelse(bh);
5574 +       gfs2_set_aops(inode);
5575 +out_trans_end:
5576 +       gfs2_trans_end(sdp);
5577 +out:
5578 +       gfs2_glock_dq_uninit(&gh);
5579 +       return error;
5580 +}
5581 +
5582  static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5583  {
5584         switch(cmd) {
5585 diff -NurpP --minimal linux-2.6.35/fs/gfs2/inode.h linux-2.6.35-vs2.3.0.36.31/fs/gfs2/inode.h
5586 --- linux-2.6.35/fs/gfs2/inode.h        2010-08-02 16:52:49.000000000 +0200
5587 +++ linux-2.6.35-vs2.3.0.36.31/fs/gfs2/inode.h  2010-08-02 17:05:06.000000000 +0200
5588 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
5589  extern const struct file_operations gfs2_dir_fops_nolock;
5590  
5591  extern void gfs2_set_inode_flags(struct inode *inode);
5592 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
5593   
5594  #ifdef CONFIG_GFS2_FS_LOCKING_DLM
5595  extern const struct file_operations gfs2_file_fops;
5596 diff -NurpP --minimal linux-2.6.35/fs/gfs2/ops_inode.c linux-2.6.35-vs2.3.0.36.31/fs/gfs2/ops_inode.c
5597 --- linux-2.6.35/fs/gfs2/ops_inode.c    2010-08-02 16:52:49.000000000 +0200
5598 +++ linux-2.6.35-vs2.3.0.36.31/fs/gfs2/ops_inode.c      2010-08-02 17:05:06.000000000 +0200
5599 @@ -1346,6 +1346,7 @@ const struct inode_operations gfs2_file_
5600         .listxattr = gfs2_listxattr,
5601         .removexattr = gfs2_removexattr,
5602         .fiemap = gfs2_fiemap,
5603 +       .sync_flags = gfs2_sync_flags,
5604  };
5605  
5606  const struct inode_operations gfs2_dir_iops = {
5607 @@ -1366,6 +1367,7 @@ const struct inode_operations gfs2_dir_i
5608         .listxattr = gfs2_listxattr,
5609         .removexattr = gfs2_removexattr,
5610         .fiemap = gfs2_fiemap,
5611 +       .sync_flags = gfs2_sync_flags,
5612  };
5613  
5614  const struct inode_operations gfs2_symlink_iops = {
5615 diff -NurpP --minimal linux-2.6.35/fs/hfsplus/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/hfsplus/ioctl.c
5616 --- linux-2.6.35/fs/hfsplus/ioctl.c     2010-08-02 16:52:49.000000000 +0200
5617 +++ linux-2.6.35-vs2.3.0.36.31/fs/hfsplus/ioctl.c       2010-08-02 17:48:55.000000000 +0200
5618 @@ -18,6 +18,7 @@
5619  #include <linux/sched.h>
5620  #include <linux/xattr.h>
5621  #include <linux/smp_lock.h>
5622 +// #include <linux/mount.h>
5623  #include <asm/uaccess.h>
5624  #include "hfsplus_fs.h"
5625  
5626 diff -NurpP --minimal linux-2.6.35/fs/inode.c linux-2.6.35-vs2.3.0.36.31/fs/inode.c
5627 --- linux-2.6.35/fs/inode.c     2010-08-02 16:52:49.000000000 +0200
5628 +++ linux-2.6.35-vs2.3.0.36.31/fs/inode.c       2010-08-02 19:08:57.000000000 +0200
5629 @@ -25,6 +25,7 @@
5630  #include <linux/mount.h>
5631  #include <linux/async.h>
5632  #include <linux/posix_acl.h>
5633 +#include <linux/vs_tag.h>
5634  
5635  /*
5636   * This is needed for the following functions:
5637 @@ -131,6 +132,9 @@ int inode_init_always(struct super_block
5638         struct address_space *const mapping = &inode->i_data;
5639  
5640         inode->i_sb = sb;
5641 +
5642 +       /* essential because of inode slab reuse */
5643 +       inode->i_tag = 0;
5644         inode->i_blkbits = sb->s_blocksize_bits;
5645         inode->i_flags = 0;
5646         atomic_set(&inode->i_count, 1);
5647 @@ -151,6 +155,7 @@ int inode_init_always(struct super_block
5648         inode->i_bdev = NULL;
5649         inode->i_cdev = NULL;
5650         inode->i_rdev = 0;
5651 +       inode->i_mdev = 0;
5652         inode->dirtied_when = 0;
5653  
5654         if (security_inode_alloc(inode))
5655 @@ -294,6 +299,8 @@ void __iget(struct inode *inode)
5656         inodes_stat.nr_unused--;
5657  }
5658  
5659 +EXPORT_SYMBOL_GPL(__iget);
5660 +
5661  /**
5662   * clear_inode - clear an inode
5663   * @inode: inode to clear
5664 @@ -1593,9 +1600,11 @@ void init_special_inode(struct inode *in
5665         if (S_ISCHR(mode)) {
5666                 inode->i_fop = &def_chr_fops;
5667                 inode->i_rdev = rdev;
5668 +               inode->i_mdev = rdev;
5669         } else if (S_ISBLK(mode)) {
5670                 inode->i_fop = &def_blk_fops;
5671                 inode->i_rdev = rdev;
5672 +               inode->i_mdev = rdev;
5673         } else if (S_ISFIFO(mode))
5674                 inode->i_fop = &def_fifo_fops;
5675         else if (S_ISSOCK(mode))
5676 @@ -1624,5 +1633,6 @@ void inode_init_owner(struct inode *inod
5677         } else
5678                 inode->i_gid = current_fsgid();
5679         inode->i_mode = mode;
5680 +       inode->i_tag = dx_current_fstag(inode->i_sb);
5681  }
5682  EXPORT_SYMBOL(inode_init_owner);
5683 diff -NurpP --minimal linux-2.6.35/fs/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/ioctl.c
5684 --- linux-2.6.35/fs/ioctl.c     2010-08-02 16:52:49.000000000 +0200
5685 +++ linux-2.6.35-vs2.3.0.36.31/fs/ioctl.c       2010-08-02 17:05:06.000000000 +0200
5686 @@ -16,6 +16,9 @@
5687  #include <linux/writeback.h>
5688  #include <linux/buffer_head.h>
5689  #include <linux/falloc.h>
5690 +#include <linux/proc_fs.h>
5691 +#include <linux/vserver/inode.h>
5692 +#include <linux/vs_tag.h>
5693  
5694  #include <asm/ioctls.h>
5695  
5696 diff -NurpP --minimal linux-2.6.35/fs/ioprio.c linux-2.6.35-vs2.3.0.36.31/fs/ioprio.c
5697 --- linux-2.6.35/fs/ioprio.c    2010-07-07 18:31:52.000000000 +0200
5698 +++ linux-2.6.35-vs2.3.0.36.31/fs/ioprio.c      2010-08-02 17:05:06.000000000 +0200
5699 @@ -27,6 +27,7 @@
5700  #include <linux/syscalls.h>
5701  #include <linux/security.h>
5702  #include <linux/pid_namespace.h>
5703 +#include <linux/vs_base.h>
5704  
5705  int set_task_ioprio(struct task_struct *task, int ioprio)
5706  {
5707 @@ -124,6 +125,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which, 
5708                         else
5709                                 pgrp = find_vpid(who);
5710                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5711 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5712 +                                       continue;
5713                                 ret = set_task_ioprio(p, ioprio);
5714                                 if (ret)
5715                                         break;
5716 @@ -213,6 +216,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which, 
5717                         else
5718                                 pgrp = find_vpid(who);
5719                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5720 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5721 +                                       continue;
5722                                 tmpio = get_task_ioprio(p);
5723                                 if (tmpio < 0)
5724                                         continue;
5725 diff -NurpP --minimal linux-2.6.35/fs/jfs/file.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/file.c
5726 --- linux-2.6.35/fs/jfs/file.c  2010-08-02 16:52:49.000000000 +0200
5727 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/file.c    2010-08-02 17:05:06.000000000 +0200
5728 @@ -101,7 +101,8 @@ int jfs_setattr(struct dentry *dentry, s
5729         if (is_quota_modification(inode, iattr))
5730                 dquot_initialize(inode);
5731         if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5732 -           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5733 +           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5734 +           (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5735                 rc = dquot_transfer(inode, iattr);
5736                 if (rc)
5737                         return rc;
5738 @@ -125,6 +126,7 @@ const struct inode_operations jfs_file_i
5739  #ifdef CONFIG_JFS_POSIX_ACL
5740         .check_acl      = jfs_check_acl,
5741  #endif
5742 +       .sync_flags     = jfs_sync_flags,
5743  };
5744  
5745  const struct file_operations jfs_file_operations = {
5746 diff -NurpP --minimal linux-2.6.35/fs/jfs/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/ioctl.c
5747 --- linux-2.6.35/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
5748 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/ioctl.c   2010-08-02 17:05:06.000000000 +0200
5749 @@ -11,6 +11,7 @@
5750  #include <linux/mount.h>
5751  #include <linux/time.h>
5752  #include <linux/sched.h>
5753 +#include <linux/mount.h>
5754  #include <asm/current.h>
5755  #include <asm/uaccess.h>
5756  
5757 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
5758  }
5759  
5760  
5761 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
5762 +{
5763 +       inode->i_flags = flags;
5764 +       inode->i_vflags = vflags;
5765 +       jfs_get_inode_flags(JFS_IP(inode));
5766 +       inode->i_ctime = CURRENT_TIME_SEC;
5767 +       mark_inode_dirty(inode);
5768 +       return 0;
5769 +}
5770 +
5771  long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5772  {
5773         struct inode *inode = filp->f_dentry->d_inode;
5774 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
5775                 if (!S_ISDIR(inode->i_mode))
5776                         flags &= ~JFS_DIRSYNC_FL;
5777  
5778 +               if (IS_BARRIER(inode)) {
5779 +                       vxwprintk_task(1, "messing with the barrier.");
5780 +                       return -EACCES;
5781 +               }
5782 +
5783                 /* Is it quota file? Do not allow user to mess with it */
5784                 if (IS_NOQUOTA(inode)) {
5785                         err = -EPERM;
5786 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
5787                  * the relevant capability.
5788                  */
5789                 if ((oldflags & JFS_IMMUTABLE_FL) ||
5790 -                       ((flags ^ oldflags) &
5791 -                       (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5792 +                       ((flags ^ oldflags) & (JFS_APPEND_FL |
5793 +                       JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
5794                         if (!capable(CAP_LINUX_IMMUTABLE)) {
5795                                 mutex_unlock(&inode->i_mutex);
5796                                 err = -EPERM;
5797 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
5798                         }
5799                 }
5800  
5801 -               flags = flags & JFS_FL_USER_MODIFIABLE;
5802 +               flags &= JFS_FL_USER_MODIFIABLE;
5803                 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
5804                 jfs_inode->mode2 = flags;
5805  
5806 diff -NurpP --minimal linux-2.6.35/fs/jfs/jfs_dinode.h linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_dinode.h
5807 --- linux-2.6.35/fs/jfs/jfs_dinode.h    2008-12-25 00:26:37.000000000 +0100
5808 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_dinode.h      2010-08-02 17:05:06.000000000 +0200
5809 @@ -161,9 +161,13 @@ struct dinode {
5810  
5811  #define JFS_APPEND_FL          0x01000000 /* writes to file may only append */
5812  #define JFS_IMMUTABLE_FL       0x02000000 /* Immutable file */
5813 +#define JFS_IXUNLINK_FL                0x08000000 /* Immutable invert on unlink */
5814  
5815 -#define JFS_FL_USER_VISIBLE    0x03F80000
5816 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
5817 +#define JFS_BARRIER_FL         0x04000000 /* Barrier for chroot() */
5818 +#define JFS_COW_FL             0x20000000 /* Copy on Write marker */
5819 +
5820 +#define JFS_FL_USER_VISIBLE    0x07F80000
5821 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
5822  #define JFS_FL_INHERIT         0x03C80000
5823  
5824  /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5825 diff -NurpP --minimal linux-2.6.35/fs/jfs/jfs_filsys.h linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_filsys.h
5826 --- linux-2.6.35/fs/jfs/jfs_filsys.h    2008-12-25 00:26:37.000000000 +0100
5827 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_filsys.h      2010-08-02 17:05:06.000000000 +0200
5828 @@ -263,6 +263,7 @@
5829  #define JFS_NAME_MAX   255
5830  #define JFS_PATH_MAX   BPSIZE
5831  
5832 +#define JFS_TAGGED             0x00800000      /* Context Tagging */
5833  
5834  /*
5835   *     file system state (superblock state)
5836 diff -NurpP --minimal linux-2.6.35/fs/jfs/jfs_imap.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_imap.c
5837 --- linux-2.6.35/fs/jfs/jfs_imap.c      2010-07-07 18:31:52.000000000 +0200
5838 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_imap.c        2010-08-02 17:05:06.000000000 +0200
5839 @@ -46,6 +46,7 @@
5840  #include <linux/pagemap.h>
5841  #include <linux/quotaops.h>
5842  #include <linux/slab.h>
5843 +#include <linux/vs_tag.h>
5844  
5845  #include "jfs_incore.h"
5846  #include "jfs_inode.h"
5847 @@ -3060,6 +3061,8 @@ static int copy_from_dinode(struct dinod
5848  {
5849         struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5850         struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5851 +       uid_t uid;
5852 +       gid_t gid;
5853  
5854         jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5855         jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5856 @@ -3080,14 +3083,18 @@ static int copy_from_dinode(struct dinod
5857         }
5858         ip->i_nlink = le32_to_cpu(dip->di_nlink);
5859  
5860 -       jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
5861 +       uid = le32_to_cpu(dip->di_uid);
5862 +       gid = le32_to_cpu(dip->di_gid);
5863 +       ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
5864 +
5865 +       jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
5866         if (sbi->uid == -1)
5867                 ip->i_uid = jfs_ip->saved_uid;
5868         else {
5869                 ip->i_uid = sbi->uid;
5870         }
5871  
5872 -       jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
5873 +       jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
5874         if (sbi->gid == -1)
5875                 ip->i_gid = jfs_ip->saved_gid;
5876         else {
5877 @@ -3152,14 +3159,12 @@ static void copy_to_dinode(struct dinode
5878         dip->di_size = cpu_to_le64(ip->i_size);
5879         dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
5880         dip->di_nlink = cpu_to_le32(ip->i_nlink);
5881 -       if (sbi->uid == -1)
5882 -               dip->di_uid = cpu_to_le32(ip->i_uid);
5883 -       else
5884 -               dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
5885 -       if (sbi->gid == -1)
5886 -               dip->di_gid = cpu_to_le32(ip->i_gid);
5887 -       else
5888 -               dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
5889 +
5890 +       dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
5891 +               (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
5892 +       dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
5893 +               (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
5894 +
5895         jfs_get_inode_flags(jfs_ip);
5896         /*
5897          * mode2 is only needed for storing the higher order bits.
5898 diff -NurpP --minimal linux-2.6.35/fs/jfs/jfs_inode.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_inode.c
5899 --- linux-2.6.35/fs/jfs/jfs_inode.c     2010-08-02 16:52:49.000000000 +0200
5900 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_inode.c       2010-08-02 17:05:06.000000000 +0200
5901 @@ -18,6 +18,7 @@
5902  
5903  #include <linux/fs.h>
5904  #include <linux/quotaops.h>
5905 +#include <linux/vs_tag.h>
5906  #include "jfs_incore.h"
5907  #include "jfs_inode.h"
5908  #include "jfs_filsys.h"
5909 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
5910  {
5911         unsigned int flags = JFS_IP(inode)->mode2;
5912  
5913 -       inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
5914 -               S_NOATIME | S_DIRSYNC | S_SYNC);
5915 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5916 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5917  
5918         if (flags & JFS_IMMUTABLE_FL)
5919                 inode->i_flags |= S_IMMUTABLE;
5920 +       if (flags & JFS_IXUNLINK_FL)
5921 +               inode->i_flags |= S_IXUNLINK;
5922 +
5923 +       if (flags & JFS_SYNC_FL)
5924 +               inode->i_flags |= S_SYNC;
5925         if (flags & JFS_APPEND_FL)
5926                 inode->i_flags |= S_APPEND;
5927         if (flags & JFS_NOATIME_FL)
5928                 inode->i_flags |= S_NOATIME;
5929         if (flags & JFS_DIRSYNC_FL)
5930                 inode->i_flags |= S_DIRSYNC;
5931 -       if (flags & JFS_SYNC_FL)
5932 -               inode->i_flags |= S_SYNC;
5933 +
5934 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
5935 +
5936 +       if (flags & JFS_BARRIER_FL)
5937 +               inode->i_vflags |= V_BARRIER;
5938 +       if (flags & JFS_COW_FL)
5939 +               inode->i_vflags |= V_COW;
5940  }
5941  
5942  void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
5943  {
5944         unsigned int flags = jfs_ip->vfs_inode.i_flags;
5945 +       unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
5946 +
5947 +       jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
5948 +                          JFS_APPEND_FL | JFS_NOATIME_FL |
5949 +                          JFS_DIRSYNC_FL | JFS_SYNC_FL |
5950 +                          JFS_BARRIER_FL | JFS_COW_FL);
5951  
5952 -       jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
5953 -                          JFS_DIRSYNC_FL | JFS_SYNC_FL);
5954         if (flags & S_IMMUTABLE)
5955                 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
5956 +       if (flags & S_IXUNLINK)
5957 +               jfs_ip->mode2 |= JFS_IXUNLINK_FL;
5958 +
5959         if (flags & S_APPEND)
5960                 jfs_ip->mode2 |= JFS_APPEND_FL;
5961         if (flags & S_NOATIME)
5962 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
5963                 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
5964         if (flags & S_SYNC)
5965                 jfs_ip->mode2 |= JFS_SYNC_FL;
5966 +
5967 +       if (vflags & V_BARRIER)
5968 +               jfs_ip->mode2 |= JFS_BARRIER_FL;
5969 +       if (vflags & V_COW)
5970 +               jfs_ip->mode2 |= JFS_COW_FL;
5971  }
5972  
5973  /*
5974 diff -NurpP --minimal linux-2.6.35/fs/jfs/jfs_inode.h linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_inode.h
5975 --- linux-2.6.35/fs/jfs/jfs_inode.h     2010-08-02 16:52:49.000000000 +0200
5976 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/jfs_inode.h       2010-08-02 17:05:06.000000000 +0200
5977 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
5978  extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
5979         int fh_len, int fh_type);
5980  extern void jfs_set_inode_flags(struct inode *);
5981 +extern int jfs_sync_flags(struct inode *, int, int);
5982  extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
5983  extern int jfs_setattr(struct dentry *, struct iattr *);
5984  
5985 diff -NurpP --minimal linux-2.6.35/fs/jfs/namei.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/namei.c
5986 --- linux-2.6.35/fs/jfs/namei.c 2010-07-07 18:31:52.000000000 +0200
5987 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/namei.c   2010-08-02 17:05:06.000000000 +0200
5988 @@ -21,6 +21,7 @@
5989  #include <linux/ctype.h>
5990  #include <linux/quotaops.h>
5991  #include <linux/exportfs.h>
5992 +#include <linux/vs_tag.h>
5993  #include "jfs_incore.h"
5994  #include "jfs_superblock.h"
5995  #include "jfs_inode.h"
5996 @@ -1491,6 +1492,7 @@ static struct dentry *jfs_lookup(struct 
5997                 return ERR_CAST(ip);
5998         }
5999  
6000 +       dx_propagate_tag(nd, ip);
6001         dentry = d_splice_alias(ip, dentry);
6002  
6003         if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
6004 @@ -1560,6 +1562,7 @@ const struct inode_operations jfs_dir_in
6005  #ifdef CONFIG_JFS_POSIX_ACL
6006         .check_acl      = jfs_check_acl,
6007  #endif
6008 +       .sync_flags     = jfs_sync_flags,
6009  };
6010  
6011  const struct file_operations jfs_dir_operations = {
6012 diff -NurpP --minimal linux-2.6.35/fs/jfs/super.c linux-2.6.35-vs2.3.0.36.31/fs/jfs/super.c
6013 --- linux-2.6.35/fs/jfs/super.c 2010-08-02 16:52:49.000000000 +0200
6014 +++ linux-2.6.35-vs2.3.0.36.31/fs/jfs/super.c   2010-08-02 17:05:06.000000000 +0200
6015 @@ -200,7 +200,8 @@ static void jfs_put_super(struct super_b
6016  enum {
6017         Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
6018         Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
6019 -       Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
6020 +       Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
6021 +       Opt_tag, Opt_notag, Opt_tagid
6022  };
6023  
6024  static const match_table_t tokens = {
6025 @@ -210,6 +211,10 @@ static const match_table_t tokens = {
6026         {Opt_resize, "resize=%u"},
6027         {Opt_resize_nosize, "resize"},
6028         {Opt_errors, "errors=%s"},
6029 +       {Opt_tag, "tag"},
6030 +       {Opt_notag, "notag"},
6031 +       {Opt_tagid, "tagid=%u"},
6032 +       {Opt_tag, "tagxid"},
6033         {Opt_ignore, "noquota"},
6034         {Opt_ignore, "quota"},
6035         {Opt_usrquota, "usrquota"},
6036 @@ -344,6 +349,20 @@ static int parse_options(char *options, 
6037                         }
6038                         break;
6039                 }
6040 +#ifndef CONFIG_TAGGING_NONE
6041 +               case Opt_tag:
6042 +                       *flag |= JFS_TAGGED;
6043 +                       break;
6044 +               case Opt_notag:
6045 +                       *flag &= JFS_TAGGED;
6046 +                       break;
6047 +#endif
6048 +#ifdef CONFIG_PROPAGATE
6049 +               case Opt_tagid:
6050 +                       /* use args[0] */
6051 +                       *flag |= JFS_TAGGED;
6052 +                       break;
6053 +#endif
6054                 default:
6055                         printk("jfs: Unrecognized mount option \"%s\" "
6056                                         " or missing value\n", p);
6057 @@ -374,6 +393,12 @@ static int jfs_remount(struct super_bloc
6058         if (!parse_options(data, sb, &newLVSize, &flag)) {
6059                 return -EINVAL;
6060         }
6061 +       if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
6062 +               printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
6063 +                       sb->s_id);
6064 +               return -EINVAL;
6065 +       }
6066 +
6067         lock_kernel();
6068         if (newLVSize) {
6069                 if (sb->s_flags & MS_RDONLY) {
6070 @@ -465,6 +490,9 @@ static int jfs_fill_super(struct super_b
6071  #ifdef CONFIG_JFS_POSIX_ACL
6072         sb->s_flags |= MS_POSIXACL;
6073  #endif
6074 +       /* map mount option tagxid */
6075 +       if (sbi->flag & JFS_TAGGED)
6076 +               sb->s_flags |= MS_TAGGED;
6077  
6078         if (newLVSize) {
6079                 printk(KERN_ERR "resize option for remount only\n");
6080 diff -NurpP --minimal linux-2.6.35/fs/libfs.c linux-2.6.35-vs2.3.0.36.31/fs/libfs.c
6081 --- linux-2.6.35/fs/libfs.c     2010-08-02 16:52:49.000000000 +0200
6082 +++ linux-2.6.35-vs2.3.0.36.31/fs/libfs.c       2010-08-02 17:05:06.000000000 +0200
6083 @@ -124,7 +124,8 @@ static inline unsigned char dt_type(stru
6084   * both impossible due to the lock on directory.
6085   */
6086  
6087 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6088 +static inline int do_dcache_readdir_filter(struct file *filp,
6089 +       void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6090  {
6091         struct dentry *dentry = filp->f_path.dentry;
6092         struct dentry *cursor = filp->private_data;
6093 @@ -157,6 +158,8 @@ int dcache_readdir(struct file * filp, v
6094                                 next = list_entry(p, struct dentry, d_u.d_child);
6095                                 if (d_unhashed(next) || !next->d_inode)
6096                                         continue;
6097 +                               if (filter && !filter(next))
6098 +                                       continue;
6099  
6100                                 spin_unlock(&dcache_lock);
6101                                 if (filldir(dirent, next->d_name.name, 
6102 @@ -175,6 +178,18 @@ int dcache_readdir(struct file * filp, v
6103         return 0;
6104  }
6105  
6106 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6107 +{
6108 +       return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6109 +}
6110 +
6111 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6112 +       int (*filter)(struct dentry *))
6113 +{
6114 +       return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6115 +}
6116 +
6117 +
6118  ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6119  {
6120         return -EISDIR;
6121 @@ -967,6 +982,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6122  EXPORT_SYMBOL(dcache_dir_lseek);
6123  EXPORT_SYMBOL(dcache_dir_open);
6124  EXPORT_SYMBOL(dcache_readdir);
6125 +EXPORT_SYMBOL(dcache_readdir_filter);
6126  EXPORT_SYMBOL(generic_read_dir);
6127  EXPORT_SYMBOL(get_sb_pseudo);
6128  EXPORT_SYMBOL(simple_write_begin);
6129 diff -NurpP --minimal linux-2.6.35/fs/locks.c linux-2.6.35-vs2.3.0.36.31/fs/locks.c
6130 --- linux-2.6.35/fs/locks.c     2010-07-07 18:31:52.000000000 +0200
6131 +++ linux-2.6.35-vs2.3.0.36.31/fs/locks.c       2010-08-02 17:05:06.000000000 +0200
6132 @@ -127,6 +127,8 @@
6133  #include <linux/time.h>
6134  #include <linux/rcupdate.h>
6135  #include <linux/pid_namespace.h>
6136 +#include <linux/vs_base.h>
6137 +#include <linux/vs_limit.h>
6138  
6139  #include <asm/uaccess.h>
6140  
6141 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
6142  /* Allocate an empty lock structure. */
6143  static struct file_lock *locks_alloc_lock(void)
6144  {
6145 +       if (!vx_locks_avail(1))
6146 +               return NULL;
6147         return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6148  }
6149  
6150 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
6151         BUG_ON(!list_empty(&fl->fl_block));
6152         BUG_ON(!list_empty(&fl->fl_link));
6153  
6154 +       vx_locks_dec(fl);
6155         locks_release_private(fl);
6156         kmem_cache_free(filelock_cache, fl);
6157  }
6158 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
6159         fl->fl_start = fl->fl_end = 0;
6160         fl->fl_ops = NULL;
6161         fl->fl_lmops = NULL;
6162 +       fl->fl_xid = -1;
6163  }
6164  
6165  EXPORT_SYMBOL(locks_init_lock);
6166 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
6167         new->fl_file = fl->fl_file;
6168         new->fl_ops = fl->fl_ops;
6169         new->fl_lmops = fl->fl_lmops;
6170 +       new->fl_xid = fl->fl_xid;
6171  
6172         locks_copy_private(new, fl);
6173  }
6174 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
6175         fl->fl_flags = FL_FLOCK;
6176         fl->fl_type = type;
6177         fl->fl_end = OFFSET_MAX;
6178 +
6179 +       vxd_assert(filp->f_xid == vx_current_xid(),
6180 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6181 +       fl->fl_xid = filp->f_xid;
6182 +       vx_locks_inc(fl);
6183         
6184         *lock = fl;
6185         return 0;
6186 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
6187  
6188         fl->fl_owner = current->files;
6189         fl->fl_pid = current->tgid;
6190 +       fl->fl_xid = vx_current_xid();
6191  
6192         fl->fl_file = filp;
6193         fl->fl_flags = FL_LEASE;
6194 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
6195         if (fl == NULL)
6196                 return ERR_PTR(error);
6197  
6198 +       fl->fl_xid = vx_current_xid();
6199 +       if (filp)
6200 +               vxd_assert(filp->f_xid == fl->fl_xid,
6201 +                       "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6202 +       vx_locks_inc(fl);
6203         error = lease_init(filp, type, fl);
6204         if (error) {
6205                 locks_free_lock(fl);
6206 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
6207         if (found)
6208                 cond_resched();
6209  
6210 +       new_fl->fl_xid = -1;
6211  find_conflict:
6212         for_each_lock(inode, before) {
6213                 struct file_lock *fl = *before;
6214 @@ -790,6 +809,7 @@ find_conflict:
6215                 goto out;
6216         locks_copy_lock(new_fl, request);
6217         locks_insert_lock(before, new_fl);
6218 +       vx_locks_inc(new_fl);
6219         new_fl = NULL;
6220         error = 0;
6221  
6222 @@ -800,7 +820,8 @@ out:
6223         return error;
6224  }
6225  
6226 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6227 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6228 +       struct file_lock *conflock, xid_t xid)
6229  {
6230         struct file_lock *fl;
6231         struct file_lock *new_fl = NULL;
6232 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
6233         struct file_lock **before;
6234         int error, added = 0;
6235  
6236 +       vxd_assert(xid == vx_current_xid(),
6237 +               "xid(%d) == current(%d)", xid, vx_current_xid());
6238         /*
6239          * We may need two file_lock structures for this operation,
6240          * so we get them in advance to avoid races.
6241 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
6242             (request->fl_type != F_UNLCK ||
6243              request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6244                 new_fl = locks_alloc_lock();
6245 +               new_fl->fl_xid = xid;
6246 +               vx_locks_inc(new_fl);
6247                 new_fl2 = locks_alloc_lock();
6248 +               new_fl2->fl_xid = xid;
6249 +               vx_locks_inc(new_fl2);
6250         }
6251  
6252         lock_kernel();
6253 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
6254  int posix_lock_file(struct file *filp, struct file_lock *fl,
6255                         struct file_lock *conflock)
6256  {
6257 -       return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6258 +       return __posix_lock_file(filp->f_path.dentry->d_inode,
6259 +               fl, conflock, filp->f_xid);
6260  }
6261  EXPORT_SYMBOL(posix_lock_file);
6262  
6263 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
6264         fl.fl_end = offset + count - 1;
6265  
6266         for (;;) {
6267 -               error = __posix_lock_file(inode, &fl, NULL);
6268 +               error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6269                 if (error != FILE_LOCK_DEFERRED)
6270                         break;
6271                 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
6272 @@ -1425,6 +1453,7 @@ int generic_setlease(struct file *filp, 
6273  
6274         locks_copy_lock(new_fl, lease);
6275         locks_insert_lock(before, new_fl);
6276 +       vx_locks_inc(new_fl);
6277  
6278         *flp = new_fl;
6279         return 0;
6280 @@ -1780,6 +1809,11 @@ int fcntl_setlk(unsigned int fd, struct 
6281         if (file_lock == NULL)
6282                 return -ENOLCK;
6283  
6284 +       vxd_assert(filp->f_xid == vx_current_xid(),
6285 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6286 +       file_lock->fl_xid = filp->f_xid;
6287 +       vx_locks_inc(file_lock);
6288 +
6289         /*
6290          * This might block, so we do it before checking the inode.
6291          */
6292 @@ -1898,6 +1932,11 @@ int fcntl_setlk64(unsigned int fd, struc
6293         if (file_lock == NULL)
6294                 return -ENOLCK;
6295  
6296 +       vxd_assert(filp->f_xid == vx_current_xid(),
6297 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6298 +       file_lock->fl_xid = filp->f_xid;
6299 +       vx_locks_inc(file_lock);
6300 +
6301         /*
6302          * This might block, so we do it before checking the inode.
6303          */
6304 @@ -2163,8 +2202,11 @@ static int locks_show(struct seq_file *f
6305  
6306         lock_get_status(f, fl, (long)f->private, "");
6307  
6308 -       list_for_each_entry(bfl, &fl->fl_block, fl_block)
6309 +       list_for_each_entry(bfl, &fl->fl_block, fl_block) {
6310 +               if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6311 +                       continue;
6312                 lock_get_status(f, bfl, (long)f->private, " ->");
6313 +       }
6314  
6315         f->private++;
6316         return 0;
6317 diff -NurpP --minimal linux-2.6.35/fs/namei.c linux-2.6.35-vs2.3.0.36.31/fs/namei.c
6318 --- linux-2.6.35/fs/namei.c     2010-08-02 16:52:50.000000000 +0200
6319 +++ linux-2.6.35-vs2.3.0.36.31/fs/namei.c       2010-08-02 20:33:11.000000000 +0200
6320 @@ -32,6 +32,14 @@
6321  #include <linux/fcntl.h>
6322  #include <linux/device_cgroup.h>
6323  #include <linux/fs_struct.h>
6324 +#include <linux/proc_fs.h>
6325 +#include <linux/vserver/inode.h>
6326 +#include <linux/vs_base.h>
6327 +#include <linux/vs_tag.h>
6328 +#include <linux/vs_cowbl.h>
6329 +#include <linux/vs_device.h>
6330 +#include <linux/vs_context.h>
6331 +#include <linux/pid_namespace.h>
6332  #include <asm/uaccess.h>
6333  
6334  #include "internal.h"
6335 @@ -166,6 +174,77 @@ void putname(const char *name)
6336  EXPORT_SYMBOL(putname);
6337  #endif
6338  
6339 +static inline int dx_barrier(const struct inode *inode)
6340 +{
6341 +       if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
6342 +               vxwprintk_task(1, "did hit the barrier.");
6343 +               return 1;
6344 +       }
6345 +       return 0;
6346 +}
6347 +
6348 +static int __dx_permission(const struct inode *inode, int mask)
6349 +{
6350 +       if (dx_barrier(inode))
6351 +               return -EACCES;
6352 +
6353 +       if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6354 +               /* devpts is xid tagged */
6355 +               if (S_ISDIR(inode->i_mode) ||
6356 +                   vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
6357 +                       return 0;
6358 +       }
6359 +       else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6360 +               struct proc_dir_entry *de = PDE(inode);
6361 +
6362 +               if (de && !vx_hide_check(0, de->vx_flags))
6363 +                       goto out;
6364 +
6365 +               if ((mask & (MAY_WRITE | MAY_APPEND))) {
6366 +                       struct pid *pid;
6367 +                       struct task_struct *tsk;
6368 +
6369 +                       if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
6370 +                           vx_flags(VXF_STATE_SETUP, 0))
6371 +                               return 0;
6372 +
6373 +                       pid = PROC_I(inode)->pid;
6374 +                       if (!pid)
6375 +                               goto out;
6376 +
6377 +                       tsk = pid_task(pid, PIDTYPE_PID);
6378 +                       vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
6379 +                                 tsk, (tsk ? vx_task_xid(tsk) : 0));
6380 +                       if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
6381 +                               return 0;
6382 +               }
6383 +               else {
6384 +                       /* FIXME: Should we block some entries here? */
6385 +                       return 0;
6386 +               }
6387 +       }
6388 +       else {
6389 +               if (dx_notagcheck(inode->i_sb) ||
6390 +                   dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
6391 +                            DX_IDENT))
6392 +                       return 0;
6393 +       }
6394 +
6395 +out:
6396 +       return -EACCES;
6397 +}
6398 +
6399 +int dx_permission(const struct inode *inode, int mask)
6400 +{
6401 +       int ret = __dx_permission(inode, mask);
6402 +       if (unlikely(ret)) {
6403 +               vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
6404 +                       mask, inode->i_sb->s_id, inode, inode->i_tag,
6405 +                       inode->i_ino);
6406 +       }
6407 +       return ret;
6408 +}
6409 +
6410  /*
6411   * This does basic POSIX ACL permission checking
6412   */
6413 @@ -266,10 +345,14 @@ int inode_permission(struct inode *inode
6414                 /*
6415                  * Nobody gets write access to an immutable file.
6416                  */
6417 -               if (IS_IMMUTABLE(inode))
6418 +               if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6419                         return -EACCES;
6420         }
6421  
6422 +       retval = dx_permission(inode, mask);
6423 +       if (retval)
6424 +               return retval;
6425 +
6426         if (inode->i_op->permission)
6427                 retval = inode->i_op->permission(inode, mask);
6428         else
6429 @@ -464,6 +547,9 @@ static int exec_permission(struct inode 
6430  {
6431         int ret;
6432  
6433 +       if (dx_barrier(inode))
6434 +               return -EACCES;
6435 +
6436         if (inode->i_op->permission) {
6437                 ret = inode->i_op->permission(inode, MAY_EXEC);
6438                 if (!ret)
6439 @@ -677,7 +763,8 @@ static __always_inline void follow_dotdo
6440  
6441                 if (nd->path.dentry == nd->root.dentry &&
6442                     nd->path.mnt == nd->root.mnt) {
6443 -                       break;
6444 +                       /* for sane '/' avoid follow_mount() */
6445 +                       return;
6446                 }
6447                 if (nd->path.dentry != nd->path.mnt->mnt_root) {
6448                         /* rare case of legitimate dget_parent()... */
6449 @@ -701,7 +788,7 @@ static int do_lookup(struct nameidata *n
6450  {
6451         struct vfsmount *mnt = nd->path.mnt;
6452         struct dentry *dentry, *parent;
6453 -       struct inode *dir;
6454 +       struct inode *dir, *inode;
6455         /*
6456          * See if the low-level filesystem might want
6457          * to use its own hash..
6458 @@ -717,12 +804,26 @@ static int do_lookup(struct nameidata *n
6459                 goto need_lookup;
6460         if (dentry->d_op && dentry->d_op->d_revalidate)
6461                 goto need_revalidate;
6462 +
6463 +       inode = dentry->d_inode;
6464 +       if (!inode)
6465 +               goto done;
6466 +
6467 +       if (__dx_permission(inode, MAY_ACCESS))
6468 +               goto hidden;
6469  done:
6470         path->mnt = mnt;
6471         path->dentry = dentry;
6472         __follow_mount(path);
6473         return 0;
6474  
6475 +hidden:
6476 +       vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] Â»%s/%.*s«.",
6477 +               inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
6478 +               vxd_path(&nd->path), name->len, name->name);
6479 +       dput(dentry);
6480 +       return -ENOENT;
6481 +
6482  need_lookup:
6483         parent = nd->path.dentry;
6484         dir = parent->d_inode;
6485 @@ -1326,7 +1427,7 @@ static int may_delete(struct inode *dir,
6486         if (IS_APPEND(dir))
6487                 return -EPERM;
6488         if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6489 -           IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6490 +               IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6491                 return -EPERM;
6492         if (isdir) {
6493                 if (!S_ISDIR(victim->d_inode->i_mode))
6494 @@ -1449,6 +1550,16 @@ int may_open(struct path *path, int acc_
6495                 break;
6496         }
6497  
6498 +#ifdef CONFIG_VSERVER_COWBL
6499 +       if (IS_COW(inode))
6500 +               printk("cow inode: %p, flag=%x\n", inode, flag);
6501 +       if (IS_COW(inode) && (flag & FMODE_WRITE)) {
6502 +               if (IS_COW_LINK(inode))
6503 +                       return -EMLINK;
6504 +               inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
6505 +               mark_inode_dirty(inode);
6506 +       }
6507 +#endif
6508         error = inode_permission(inode, acc_mode);
6509         if (error)
6510                 return error;
6511 @@ -1558,7 +1669,8 @@ static int open_will_truncate(int flag, 
6512  }
6513  
6514  static struct file *finish_open(struct nameidata *nd,
6515 -                               int open_flag, int acc_mode)
6516 +                               int open_flag, int acc_mode,
6517 +                               const char *pathname)
6518  {
6519         struct file *filp;
6520         int will_truncate;
6521 @@ -1571,6 +1683,23 @@ static struct file *finish_open(struct n
6522                         goto exit;
6523         }
6524         error = may_open(&nd->path, acc_mode, open_flag);
6525 +#ifdef CONFIG_VSERVER_COWBL
6526 +       if (error == -EMLINK) {
6527 +               struct dentry *dentry;
6528 +               dentry = cow_break_link(pathname);
6529 +               if (IS_ERR(dentry)) {
6530 +                       error = PTR_ERR(dentry);
6531 +                       goto exit_cow;
6532 +               }
6533 +               dput(dentry);
6534 +               if (will_truncate)
6535 +                       mnt_drop_write(nd->path.mnt);
6536 +               release_open_intent(nd);
6537 +               path_put(&nd->path);
6538 +               return ERR_PTR(-EMLINK);
6539 +       }
6540 +exit_cow:
6541 +#endif
6542         if (error) {
6543                 if (will_truncate)
6544                         mnt_drop_write(nd->path.mnt);
6545 @@ -1739,7 +1868,7 @@ static struct file *do_last(struct namei
6546         if (S_ISDIR(path->dentry->d_inode->i_mode))
6547                 goto exit;
6548  ok:
6549 -       filp = finish_open(nd, open_flag, acc_mode);
6550 +       filp = finish_open(nd, open_flag, acc_mode, pathname);
6551         return filp;
6552  
6553  exit_mutex_unlock:
6554 @@ -1768,7 +1897,11 @@ struct file *do_filp_open(int dfd, const
6555         int count = 0;
6556         int flag = open_to_namei_flags(open_flag);
6557         int force_reval = 0;
6558 -
6559 +#ifdef CONFIG_VSERVER_COWBL
6560 +       int rflag = flag;
6561 +       int rmode = mode;
6562 +restart:
6563 +#endif
6564         if (!(open_flag & O_CREAT))
6565                 mode = 0;
6566  
6567 @@ -1834,6 +1967,13 @@ reval:
6568         if (!(open_flag & O_NOFOLLOW))
6569                 nd.flags |= LOOKUP_FOLLOW;
6570         filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
6571 +#ifdef CONFIG_VSERVER_COWBL
6572 +       if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
6573 +               flag = rflag;
6574 +               mode = rmode;
6575 +               goto restart;
6576 +       }
6577 +#endif
6578         while (unlikely(!filp)) { /* trailing symlink */
6579                 struct path holder;
6580                 struct inode *inode = path.dentry->d_inode;
6581 @@ -1872,6 +2012,13 @@ reval:
6582                 holder = path;
6583                 nd.flags &= ~LOOKUP_PARENT;
6584                 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
6585 +#ifdef CONFIG_VSERVER_COWBL
6586 +               if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
6587 +                       flag = rflag;
6588 +                       mode = rmode;
6589 +                       goto restart;
6590 +               }
6591 +#endif
6592                 if (inode->i_op->put_link)
6593                         inode->i_op->put_link(holder.dentry, &nd, cookie);
6594                 path_put(&holder);
6595 @@ -1972,9 +2119,17 @@ int vfs_mknod(struct inode *dir, struct 
6596         if (error)
6597                 return error;
6598  
6599 -       if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
6600 +       if (!(S_ISCHR(mode) || S_ISBLK(mode)))
6601 +               goto okay;
6602 +
6603 +       if (!capable(CAP_MKNOD))
6604                 return -EPERM;
6605  
6606 +       if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
6607 +               return -EPERM;
6608 +       if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
6609 +               return -EPERM;
6610 +okay:
6611         if (!dir->i_op->mknod)
6612                 return -EPERM;
6613  
6614 @@ -2439,7 +2594,7 @@ int vfs_link(struct dentry *old_dentry, 
6615         /*
6616          * A link to an append-only or immutable file cannot be created.
6617          */
6618 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6619 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6620                 return -EPERM;
6621         if (!dir->i_op->link)
6622                 return -EPERM;
6623 @@ -2811,6 +2966,219 @@ int vfs_follow_link(struct nameidata *nd
6624         return __vfs_follow_link(nd, link);
6625  }
6626  
6627 +
6628 +#ifdef CONFIG_VSERVER_COWBL
6629 +
6630 +#include <linux/file.h>
6631 +
6632 +static inline
6633 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6634 +{
6635 +       loff_t ppos = 0;
6636 +
6637 +       return do_splice_direct(in, &ppos, out, len, 0);
6638 +}
6639 +
6640 +struct dentry *cow_break_link(const char *pathname)
6641 +{
6642 +       int ret, mode, pathlen, redo = 0;
6643 +       struct nameidata old_nd, dir_nd;
6644 +       struct path old_path, new_path;
6645 +       struct dentry *dir, *res = NULL;
6646 +       struct file *old_file;
6647 +       struct file *new_file;
6648 +       char *to, *path, pad='\251';
6649 +       loff_t size;
6650 +
6651 +       vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6652 +       path = kmalloc(PATH_MAX, GFP_KERNEL);
6653 +       ret = -ENOMEM;
6654 +       if (!path)
6655 +               goto out;
6656 +
6657 +       /* old_nd will have refs to dentry and mnt */
6658 +       ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6659 +       vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6660 +       if (ret < 0)
6661 +               goto out_free_path;
6662 +
6663 +       old_path = old_nd.path;
6664 +       mode = old_path.dentry->d_inode->i_mode;
6665 +
6666 +       to = d_path(&old_path, path, PATH_MAX-2);
6667 +       pathlen = strlen(to);
6668 +       vxdprintk(VXD_CBIT(misc, 2), "old path Â»%s« [»%.*s«:%d]", to,
6669 +               old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6670 +               old_path.dentry->d_name.len);
6671 +
6672 +       to[pathlen + 1] = 0;
6673 +retry:
6674 +       to[pathlen] = pad--;
6675 +       ret = -EMLINK;
6676 +       if (pad <= '\240')
6677 +               goto out_rel_old;
6678 +
6679 +       vxdprintk(VXD_CBIT(misc, 1), "temp copy Â»%s«", to);
6680 +       /* dir_nd will have refs to dentry and mnt */
6681 +       ret = path_lookup(to,
6682 +               LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6683 +       vxdprintk(VXD_CBIT(misc, 2),
6684 +               "path_lookup(new): %d", ret);
6685 +       if (ret < 0)
6686 +               goto retry;
6687 +
6688 +       /* this puppy downs the inode mutex */
6689 +       new_path.dentry = lookup_create(&dir_nd, 0);
6690 +       if (!new_path.dentry || IS_ERR(new_path.dentry)) {
6691 +               vxdprintk(VXD_CBIT(misc, 2),
6692 +                       "lookup_create(new): %p", new_path.dentry);
6693 +               mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
6694 +               path_put(&dir_nd.path);
6695 +               goto retry;
6696 +       }
6697 +       vxdprintk(VXD_CBIT(misc, 2),
6698 +               "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
6699 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6700 +               new_path.dentry->d_name.len);
6701 +       dir = dir_nd.path.dentry;
6702 +
6703 +       ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
6704 +       vxdprintk(VXD_CBIT(misc, 2),
6705 +               "vfs_create(new): %d", ret);
6706 +       if (ret == -EEXIST) {
6707 +               mutex_unlock(&dir->d_inode->i_mutex);
6708 +               dput(new_path.dentry);
6709 +               path_put(&dir_nd.path);
6710 +               goto retry;
6711 +       }
6712 +       else if (ret < 0)
6713 +               goto out_unlock_new;
6714 +
6715 +       /* drop out early, ret passes ENOENT */
6716 +       ret = -ENOENT;
6717 +       if ((redo = d_unhashed(old_path.dentry)))
6718 +               goto out_unlock_new;
6719 +
6720 +       new_path.mnt = dir_nd.path.mnt;
6721 +       dget(old_path.dentry);
6722 +       mntget(old_path.mnt);
6723 +       /* this one cleans up the dentry/mnt in case of failure */
6724 +       old_file = dentry_open(old_path.dentry, old_path.mnt,
6725 +               O_RDONLY, current_cred());
6726 +       vxdprintk(VXD_CBIT(misc, 2),
6727 +               "dentry_open(old): %p", old_file);
6728 +       if (!old_file || IS_ERR(old_file)) {
6729 +               res = IS_ERR(old_file) ? (void *) old_file : res;
6730 +               goto out_unlock_new;
6731 +       }
6732 +
6733 +       dget(new_path.dentry);
6734 +       mntget(new_path.mnt);
6735 +       /* this one cleans up the dentry/mnt in case of failure */
6736 +       new_file = dentry_open(new_path.dentry, new_path.mnt,
6737 +               O_WRONLY, current_cred());
6738 +       vxdprintk(VXD_CBIT(misc, 2),
6739 +               "dentry_open(new): %p", new_file);
6740 +
6741 +       ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
6742 +       if (!new_file || IS_ERR(new_file))
6743 +               goto out_fput_old;
6744 +
6745 +       size = i_size_read(old_file->f_dentry->d_inode);
6746 +       ret = do_cow_splice(old_file, new_file, size);
6747 +       vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
6748 +       if (ret < 0) {
6749 +               goto out_fput_both;
6750 +       } else if (ret < size) {
6751 +               ret = -ENOSPC;
6752 +               goto out_fput_both;
6753 +       } else {
6754 +               struct inode *old_inode = old_path.dentry->d_inode;
6755 +               struct inode *new_inode = new_path.dentry->d_inode;
6756 +               struct iattr attr = {
6757 +                       .ia_uid = old_inode->i_uid,
6758 +                       .ia_gid = old_inode->i_gid,
6759 +                       .ia_valid = ATTR_UID | ATTR_GID
6760 +                       };
6761 +
6762 +               ret = inode_setattr(new_inode, &attr);
6763 +               if (ret)
6764 +                       goto out_fput_both;
6765 +       }
6766 +
6767 +       mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6768 +
6769 +       /* drop out late */
6770 +       ret = -ENOENT;
6771 +       if ((redo = d_unhashed(old_path.dentry)))
6772 +               goto out_unlock;
6773 +
6774 +       vxdprintk(VXD_CBIT(misc, 2),
6775 +               "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
6776 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6777 +               new_path.dentry->d_name.len,
6778 +               old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6779 +               old_path.dentry->d_name.len);
6780 +       ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
6781 +               old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
6782 +       vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
6783 +       res = new_path.dentry;
6784 +
6785 +out_unlock:
6786 +       mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6787 +
6788 +out_fput_both:
6789 +       vxdprintk(VXD_CBIT(misc, 3),
6790 +               "fput(new_file=%p[#%ld])", new_file,
6791 +               atomic_long_read(&new_file->f_count));
6792 +       fput(new_file);
6793 +
6794 +out_fput_old:
6795 +       vxdprintk(VXD_CBIT(misc, 3),
6796 +               "fput(old_file=%p[#%ld])", old_file,
6797 +               atomic_long_read(&old_file->f_count));
6798 +       fput(old_file);
6799 +
6800 +out_unlock_new:
6801 +       mutex_unlock(&dir->d_inode->i_mutex);
6802 +       if (!ret)
6803 +               goto out_redo;
6804 +
6805 +       /* error path cleanup */
6806 +       vfs_unlink(dir->d_inode, new_path.dentry);
6807 +       dput(new_path.dentry);
6808 +
6809 +out_redo:
6810 +       if (!redo)
6811 +               goto out_rel_both;
6812 +       /* lookup dentry once again */
6813 +       path_put(&old_nd.path);
6814 +       ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6815 +       if (ret)
6816 +               goto out_rel_both;
6817 +
6818 +       new_path.dentry = old_nd.path.dentry;
6819 +       vxdprintk(VXD_CBIT(misc, 2),
6820 +               "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
6821 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6822 +               new_path.dentry->d_name.len);
6823 +       dget(new_path.dentry);
6824 +       res = new_path.dentry;
6825 +
6826 +out_rel_both:
6827 +       path_put(&dir_nd.path);
6828 +out_rel_old:
6829 +       path_put(&old_nd.path);
6830 +out_free_path:
6831 +       kfree(path);
6832 +out:
6833 +       if (ret)
6834 +               res = ERR_PTR(ret);
6835 +       return res;
6836 +}
6837 +
6838 +#endif
6839 +
6840  /* get the link contents into pagecache */
6841  static char *page_getlink(struct dentry * dentry, struct page **ppage)
6842  {
6843 diff -NurpP --minimal linux-2.6.35/fs/namespace.c linux-2.6.35-vs2.3.0.36.31/fs/namespace.c
6844 --- linux-2.6.35/fs/namespace.c 2010-08-02 16:52:50.000000000 +0200
6845 +++ linux-2.6.35-vs2.3.0.36.31/fs/namespace.c   2010-08-02 17:05:06.000000000 +0200
6846 @@ -29,6 +29,11 @@
6847  #include <linux/log2.h>
6848  #include <linux/idr.h>
6849  #include <linux/fs_struct.h>
6850 +#include <linux/vs_base.h>
6851 +#include <linux/vs_context.h>
6852 +#include <linux/vs_tag.h>
6853 +#include <linux/vserver/space.h>
6854 +#include <linux/vserver/global.h>
6855  #include <asm/uaccess.h>
6856  #include <asm/unistd.h>
6857  #include "pnode.h"
6858 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
6859                 mnt->mnt_root = dget(root);
6860                 mnt->mnt_mountpoint = mnt->mnt_root;
6861                 mnt->mnt_parent = mnt;
6862 +               mnt->mnt_tag = old->mnt_tag;
6863  
6864                 if (flag & CL_SLAVE) {
6865                         list_add(&mnt->mnt_slave, &old->mnt_slave_list);
6866 @@ -660,6 +666,31 @@ static inline void mangle(struct seq_fil
6867         seq_escape(m, s, " \t\n\\");
6868  }
6869  
6870 +static int mnt_is_reachable(struct vfsmount *mnt)
6871 +{
6872 +       struct path root;
6873 +       struct dentry *point;
6874 +       int ret;
6875 +
6876 +       if (mnt == mnt->mnt_ns->root)
6877 +               return 1;
6878 +
6879 +       spin_lock(&vfsmount_lock);
6880 +       root = current->fs->root;
6881 +       point = root.dentry;
6882 +
6883 +       while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
6884 +               point = mnt->mnt_mountpoint;
6885 +               mnt = mnt->mnt_parent;
6886 +       }
6887 +
6888 +       ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
6889 +
6890 +       spin_unlock(&vfsmount_lock);
6891 +
6892 +       return ret;
6893 +}
6894 +
6895  /*
6896   * Simple .show_options callback for filesystems which don't want to
6897   * implement more complex mount option showing.
6898 @@ -762,6 +793,8 @@ static int show_sb_opts(struct seq_file 
6899                 { MS_SYNCHRONOUS, ",sync" },
6900                 { MS_DIRSYNC, ",dirsync" },
6901                 { MS_MANDLOCK, ",mand" },
6902 +               { MS_TAGGED, ",tag" },
6903 +               { MS_NOTAGCHECK, ",notagcheck" },
6904                 { 0, NULL }
6905         };
6906         const struct proc_fs_info *fs_infop;
6907 @@ -809,10 +842,20 @@ static int show_vfsmnt(struct seq_file *
6908         int err = 0;
6909         struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6910  
6911 -       mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6912 -       seq_putc(m, ' ');
6913 -       seq_path(m, &mnt_path, " \t\n\\");
6914 -       seq_putc(m, ' ');
6915 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
6916 +               return SEQ_SKIP;
6917 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6918 +               return SEQ_SKIP;
6919 +
6920 +       if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6921 +               mnt == current->fs->root.mnt) {
6922 +               seq_puts(m, "/dev/root / ");
6923 +       } else {
6924 +               mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6925 +               seq_putc(m, ' ');
6926 +               seq_path(m, &mnt_path, " \t\n\\");
6927 +               seq_putc(m, ' ');
6928 +       }
6929         show_type(m, mnt->mnt_sb);
6930         seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6931         err = show_sb_opts(m, mnt->mnt_sb);
6932 @@ -842,6 +885,11 @@ static int show_mountinfo(struct seq_fil
6933         struct path root = p->root;
6934         int err = 0;
6935  
6936 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
6937 +               return SEQ_SKIP;
6938 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6939 +               return SEQ_SKIP;
6940 +
6941         seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
6942                    MAJOR(sb->s_dev), MINOR(sb->s_dev));
6943         seq_dentry(m, mnt->mnt_root, " \t\n\\");
6944 @@ -900,17 +948,27 @@ static int show_vfsstat(struct seq_file 
6945         struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6946         int err = 0;
6947  
6948 -       /* device */
6949 -       if (mnt->mnt_devname) {
6950 -               seq_puts(m, "device ");
6951 -               mangle(m, mnt->mnt_devname);
6952 -       } else
6953 -               seq_puts(m, "no device");
6954 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
6955 +               return SEQ_SKIP;
6956 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6957 +               return SEQ_SKIP;
6958  
6959 -       /* mount point */
6960 -       seq_puts(m, " mounted on ");
6961 -       seq_path(m, &mnt_path, " \t\n\\");
6962 -       seq_putc(m, ' ');
6963 +       if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6964 +               mnt == current->fs->root.mnt) {
6965 +               seq_puts(m, "device /dev/root mounted on / ");
6966 +       } else {
6967 +               /* device */
6968 +               if (mnt->mnt_devname) {
6969 +                       seq_puts(m, "device ");
6970 +                       mangle(m, mnt->mnt_devname);
6971 +               } else
6972 +                       seq_puts(m, "no device");
6973 +
6974 +               /* mount point */
6975 +               seq_puts(m, " mounted on ");
6976 +               seq_path(m, &mnt_path, " \t\n\\");
6977 +               seq_putc(m, ' ');
6978 +       }
6979  
6980         /* file system type */
6981         seq_puts(m, "with fstype ");
6982 @@ -1151,7 +1209,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
6983                 goto dput_and_out;
6984  
6985         retval = -EPERM;
6986 -       if (!capable(CAP_SYS_ADMIN))
6987 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6988                 goto dput_and_out;
6989  
6990         retval = do_umount(path.mnt, flags);
6991 @@ -1177,7 +1235,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
6992  
6993  static int mount_is_safe(struct path *path)
6994  {
6995 -       if (capable(CAP_SYS_ADMIN))
6996 +       if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6997                 return 0;
6998         return -EPERM;
6999  #ifdef notyet
7000 @@ -1449,7 +1507,7 @@ static int do_change_type(struct path *p
7001         int type = flag & ~MS_REC;
7002         int err = 0;
7003  
7004 -       if (!capable(CAP_SYS_ADMIN))
7005 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
7006                 return -EPERM;
7007  
7008         if (path->dentry != path->mnt->mnt_root)
7009 @@ -1476,11 +1534,13 @@ static int do_change_type(struct path *p
7010   * do loopback mount.
7011   */
7012  static int do_loopback(struct path *path, char *old_name,
7013 -                               int recurse)
7014 +       tag_t tag, unsigned long flags, int mnt_flags)
7015  {
7016         struct path old_path;
7017         struct vfsmount *mnt = NULL;
7018         int err = mount_is_safe(path);
7019 +       int recurse = flags & MS_REC;
7020 +
7021         if (err)
7022                 return err;
7023         if (!old_name || !*old_name)
7024 @@ -1514,6 +1574,7 @@ static int do_loopback(struct path *path
7025                 spin_unlock(&vfsmount_lock);
7026                 release_mounts(&umount_list);
7027         }
7028 +       mnt->mnt_flags = mnt_flags;
7029  
7030  out:
7031         up_write(&namespace_sem);
7032 @@ -1544,12 +1605,12 @@ static int change_mount_flags(struct vfs
7033   * on it - tough luck.
7034   */
7035  static int do_remount(struct path *path, int flags, int mnt_flags,
7036 -                     void *data)
7037 +       void *data, xid_t xid)
7038  {
7039         int err;
7040         struct super_block *sb = path->mnt->mnt_sb;
7041  
7042 -       if (!capable(CAP_SYS_ADMIN))
7043 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7044                 return -EPERM;
7045  
7046         if (!check_mnt(path->mnt))
7047 @@ -1593,7 +1654,7 @@ static int do_move_mount(struct path *pa
7048         struct path old_path, parent_path;
7049         struct vfsmount *p;
7050         int err = 0;
7051 -       if (!capable(CAP_SYS_ADMIN))
7052 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7053                 return -EPERM;
7054         if (!old_name || !*old_name)
7055                 return -EINVAL;
7056 @@ -1675,7 +1736,7 @@ static int do_new_mount(struct path *pat
7057                 return -EINVAL;
7058  
7059         /* we need capabilities... */
7060 -       if (!capable(CAP_SYS_ADMIN))
7061 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7062                 return -EPERM;
7063  
7064         lock_kernel();
7065 @@ -1941,6 +2002,7 @@ long do_mount(char *dev_name, char *dir_
7066         struct path path;
7067         int retval = 0;
7068         int mnt_flags = 0;
7069 +       tag_t tag = 0;
7070  
7071         /* Discard magic */
7072         if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7073 @@ -1968,6 +2030,12 @@ long do_mount(char *dev_name, char *dir_
7074         if (!(flags & MS_NOATIME))
7075                 mnt_flags |= MNT_RELATIME;
7076  
7077 +       if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
7078 +               /* FIXME: bind and re-mounts get the tag flag? */
7079 +               if (flags & (MS_BIND|MS_REMOUNT))
7080 +                       flags |= MS_TAGID;
7081 +       }
7082 +
7083         /* Separate the per-mountpoint flags */
7084         if (flags & MS_NOSUID)
7085                 mnt_flags |= MNT_NOSUID;
7086 @@ -1984,15 +2052,17 @@ long do_mount(char *dev_name, char *dir_
7087         if (flags & MS_RDONLY)
7088                 mnt_flags |= MNT_READONLY;
7089  
7090 +       if (!capable(CAP_SYS_ADMIN))
7091 +               mnt_flags |= MNT_NODEV;
7092         flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
7093                    MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
7094                    MS_STRICTATIME);
7095  
7096         if (flags & MS_REMOUNT)
7097                 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
7098 -                                   data_page);
7099 +                                   data_page, tag);
7100         else if (flags & MS_BIND)
7101 -               retval = do_loopback(&path, dev_name, flags & MS_REC);
7102 +               retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
7103         else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7104                 retval = do_change_type(&path, flags);
7105         else if (flags & MS_MOVE)
7106 @@ -2071,6 +2141,7 @@ static struct mnt_namespace *dup_mnt_ns(
7107                 q = next_mnt(q, new_ns->root);
7108         }
7109         up_write(&namespace_sem);
7110 +       atomic_inc(&vs_global_mnt_ns);
7111  
7112         if (rootmnt)
7113                 mntput(rootmnt);
7114 @@ -2215,9 +2286,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
7115         down_write(&namespace_sem);
7116         mutex_lock(&old.dentry->d_inode->i_mutex);
7117         error = -EINVAL;
7118 -       if (IS_MNT_SHARED(old.mnt) ||
7119 +       if ((IS_MNT_SHARED(old.mnt) ||
7120                 IS_MNT_SHARED(new.mnt->mnt_parent) ||
7121 -               IS_MNT_SHARED(root.mnt->mnt_parent))
7122 +               IS_MNT_SHARED(root.mnt->mnt_parent)) &&
7123 +               !vx_flags(VXF_STATE_SETUP, 0))
7124                 goto out2;
7125         if (!check_mnt(root.mnt))
7126                 goto out2;
7127 @@ -2348,6 +2420,7 @@ void put_mnt_ns(struct mnt_namespace *ns
7128         spin_unlock(&vfsmount_lock);
7129         up_write(&namespace_sem);
7130         release_mounts(&umount_list);
7131 +       atomic_dec(&vs_global_mnt_ns);
7132         kfree(ns);
7133  }
7134  EXPORT_SYMBOL(put_mnt_ns);
7135 diff -NurpP --minimal linux-2.6.35/fs/nfs/client.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/client.c
7136 --- linux-2.6.35/fs/nfs/client.c        2010-08-02 16:52:50.000000000 +0200
7137 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/client.c  2010-08-02 17:05:06.000000000 +0200
7138 @@ -739,6 +739,9 @@ static int nfs_init_server_rpcclient(str
7139         if (server->flags & NFS_MOUNT_SOFT)
7140                 server->client->cl_softrtry = 1;
7141  
7142 +       server->client->cl_tag = 0;
7143 +       if (server->flags & NFS_MOUNT_TAGGED)
7144 +               server->client->cl_tag = 1;
7145         return 0;
7146  }
7147  
7148 @@ -910,6 +913,10 @@ static void nfs_server_set_fsinfo(struct
7149                 server->acdirmin = server->acdirmax = 0;
7150         }
7151  
7152 +       /* FIXME: needs fsinfo
7153 +       if (server->flags & NFS_MOUNT_TAGGED)
7154 +               sb->s_flags |= MS_TAGGED;       */
7155 +
7156         server->maxfilesize = fsinfo->maxfilesize;
7157  
7158         /* We're airborne Set socket buffersize */
7159 diff -NurpP --minimal linux-2.6.35/fs/nfs/dir.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/dir.c
7160 --- linux-2.6.35/fs/nfs/dir.c   2010-08-02 16:52:50.000000000 +0200
7161 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/dir.c     2010-08-02 17:05:06.000000000 +0200
7162 @@ -33,6 +33,7 @@
7163  #include <linux/namei.h>
7164  #include <linux/mount.h>
7165  #include <linux/sched.h>
7166 +#include <linux/vs_tag.h>
7167  
7168  #include "nfs4_fs.h"
7169  #include "delegation.h"
7170 @@ -979,6 +980,7 @@ static struct dentry *nfs_lookup(struct 
7171         if (IS_ERR(res))
7172                 goto out_unblock_sillyrename;
7173  
7174 +       dx_propagate_tag(nd, inode);
7175  no_entry:
7176         res = d_materialise_unique(dentry, inode);
7177         if (res != NULL) {
7178 diff -NurpP --minimal linux-2.6.35/fs/nfs/inode.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/inode.c
7179 --- linux-2.6.35/fs/nfs/inode.c 2010-08-02 16:52:50.000000000 +0200
7180 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/inode.c   2010-08-02 17:05:06.000000000 +0200
7181 @@ -37,6 +37,7 @@
7182  #include <linux/inet.h>
7183  #include <linux/nfs_xdr.h>
7184  #include <linux/slab.h>
7185 +#include <linux/vs_tag.h>
7186  
7187  #include <asm/system.h>
7188  #include <asm/uaccess.h>
7189 @@ -260,6 +261,8 @@ nfs_fhget(struct super_block *sb, struct
7190         if (inode->i_state & I_NEW) {
7191                 struct nfs_inode *nfsi = NFS_I(inode);
7192                 unsigned long now = jiffies;
7193 +               uid_t uid;
7194 +               gid_t gid;
7195  
7196                 /* We set i_ino for the few things that still rely on it,
7197                  * such as stat(2) */
7198 @@ -308,8 +311,8 @@ nfs_fhget(struct super_block *sb, struct
7199                 nfsi->change_attr = 0;
7200                 inode->i_size = 0;
7201                 inode->i_nlink = 0;
7202 -               inode->i_uid = -2;
7203 -               inode->i_gid = -2;
7204 +               uid = -2;
7205 +               gid = -2;
7206                 inode->i_blocks = 0;
7207                 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
7208  
7209 @@ -346,13 +349,13 @@ nfs_fhget(struct super_block *sb, struct
7210                 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
7211                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
7212                 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
7213 -                       inode->i_uid = fattr->uid;
7214 +                       uid = fattr->uid;
7215                 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
7216                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7217                                 | NFS_INO_INVALID_ACCESS
7218                                 | NFS_INO_INVALID_ACL;
7219                 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
7220 -                       inode->i_gid = fattr->gid;
7221 +                       gid = fattr->gid;
7222                 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
7223                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7224                                 | NFS_INO_INVALID_ACCESS
7225 @@ -365,6 +368,11 @@ nfs_fhget(struct super_block *sb, struct
7226                          */
7227                         inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
7228                 }
7229 +               inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7230 +               inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7231 +               inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7232 +                               /* maybe fattr->xid someday */
7233 +
7234                 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
7235                 nfsi->attrtimeo_timestamp = now;
7236                 nfsi->access_cache = RB_ROOT;
7237 @@ -483,6 +491,8 @@ void nfs_setattr_update_inode(struct ino
7238                         inode->i_uid = attr->ia_uid;
7239                 if ((attr->ia_valid & ATTR_GID) != 0)
7240                         inode->i_gid = attr->ia_gid;
7241 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7242 +                       inode->i_tag = attr->ia_tag;
7243                 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7244                 spin_unlock(&inode->i_lock);
7245         }
7246 @@ -856,6 +866,9 @@ static int nfs_check_inode_attributes(st
7247         struct nfs_inode *nfsi = NFS_I(inode);
7248         loff_t cur_size, new_isize;
7249         unsigned long invalid = 0;
7250 +       uid_t uid;
7251 +       gid_t gid;
7252 +       tag_t tag;
7253  
7254  
7255         /* Has the inode gone and changed behind our back? */
7256 @@ -879,13 +892,18 @@ static int nfs_check_inode_attributes(st
7257                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7258         }
7259  
7260 +       uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7261 +       gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7262 +       tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7263 +
7264         /* Have any file permissions changed? */
7265         if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
7266                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7267 -       if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
7268 +       if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
7269                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7270 -       if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
7271 +       if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
7272                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7273 +               /* maybe check for tag too? */
7274  
7275         /* Has the link count changed? */
7276         if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
7277 @@ -1120,6 +1138,9 @@ static int nfs_update_inode(struct inode
7278         unsigned long invalid = 0;
7279         unsigned long now = jiffies;
7280         unsigned long save_cache_validity;
7281 +       uid_t uid;
7282 +       gid_t gid;
7283 +       tag_t tag;
7284  
7285         dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7286                         __func__, inode->i_sb->s_id, inode->i_ino,
7287 @@ -1222,6 +1243,9 @@ static int nfs_update_inode(struct inode
7288                                 | NFS_INO_REVAL_PAGECACHE
7289                                 | NFS_INO_REVAL_FORCED);
7290  
7291 +       uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7292 +       gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7293 +       tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7294  
7295         if (fattr->valid & NFS_ATTR_FATTR_ATIME)
7296                 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7297 @@ -1243,9 +1267,9 @@ static int nfs_update_inode(struct inode
7298                                 | NFS_INO_REVAL_FORCED);
7299  
7300         if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
7301 -               if (inode->i_uid != fattr->uid) {
7302 +               if (uid != fattr->uid) {
7303                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7304 -                       inode->i_uid = fattr->uid;
7305 +                       uid = fattr->uid;
7306                 }
7307         } else if (server->caps & NFS_CAP_OWNER)
7308                 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7309 @@ -1254,9 +1278,9 @@ static int nfs_update_inode(struct inode
7310                                 | NFS_INO_REVAL_FORCED);
7311  
7312         if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
7313 -               if (inode->i_gid != fattr->gid) {
7314 +               if (gid != fattr->gid) {
7315                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7316 -                       inode->i_gid = fattr->gid;
7317 +                       gid = fattr->gid;
7318                 }
7319         } else if (server->caps & NFS_CAP_OWNER_GROUP)
7320                 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7321 @@ -1264,6 +1288,10 @@ static int nfs_update_inode(struct inode
7322                                 | NFS_INO_INVALID_ACL
7323                                 | NFS_INO_REVAL_FORCED);
7324  
7325 +       inode->i_uid = uid;
7326 +       inode->i_gid = gid;
7327 +       inode->i_tag = tag;
7328 +
7329         if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
7330                 if (inode->i_nlink != fattr->nlink) {
7331                         invalid |= NFS_INO_INVALID_ATTR;
7332 diff -NurpP --minimal linux-2.6.35/fs/nfs/nfs3xdr.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/nfs3xdr.c
7333 --- linux-2.6.35/fs/nfs/nfs3xdr.c       2010-08-02 16:52:50.000000000 +0200
7334 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/nfs3xdr.c 2010-08-02 17:05:06.000000000 +0200
7335 @@ -20,6 +20,7 @@
7336  #include <linux/nfs3.h>
7337  #include <linux/nfs_fs.h>
7338  #include <linux/nfsacl.h>
7339 +#include <linux/vs_tag.h>
7340  #include "internal.h"
7341  
7342  #define NFSDBG_FACILITY                NFSDBG_XDR
7343 @@ -175,7 +176,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7344  }
7345  
7346  static inline __be32 *
7347 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7348 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7349  {
7350         if (attr->ia_valid & ATTR_MODE) {
7351                 *p++ = xdr_one;
7352 @@ -183,15 +184,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7353         } else {
7354                 *p++ = xdr_zero;
7355         }
7356 -       if (attr->ia_valid & ATTR_UID) {
7357 +       if (attr->ia_valid & ATTR_UID ||
7358 +               (tag && (attr->ia_valid & ATTR_TAG))) {
7359                 *p++ = xdr_one;
7360 -               *p++ = htonl(attr->ia_uid);
7361 +               *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7362         } else {
7363                 *p++ = xdr_zero;
7364         }
7365 -       if (attr->ia_valid & ATTR_GID) {
7366 +       if (attr->ia_valid & ATTR_GID ||
7367 +               (tag && (attr->ia_valid & ATTR_TAG))) {
7368                 *p++ = xdr_one;
7369 -               *p++ = htonl(attr->ia_gid);
7370 +               *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7371         } else {
7372                 *p++ = xdr_zero;
7373         }
7374 @@ -278,7 +281,8 @@ static int
7375  nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7376  {
7377         p = xdr_encode_fhandle(p, args->fh);
7378 -       p = xdr_encode_sattr(p, args->sattr);
7379 +       p = xdr_encode_sattr(p, args->sattr,
7380 +               req->rq_task->tk_client->cl_tag);
7381         *p++ = htonl(args->guard);
7382         if (args->guard)
7383                 p = xdr_encode_time3(p, &args->guardtime);
7384 @@ -383,7 +387,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7385                 *p++ = args->verifier[0];
7386                 *p++ = args->verifier[1];
7387         } else
7388 -               p = xdr_encode_sattr(p, args->sattr);
7389 +               p = xdr_encode_sattr(p, args->sattr,
7390 +                       req->rq_task->tk_client->cl_tag);
7391  
7392         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7393         return 0;
7394 @@ -397,7 +402,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7395  {
7396         p = xdr_encode_fhandle(p, args->fh);
7397         p = xdr_encode_array(p, args->name, args->len);
7398 -       p = xdr_encode_sattr(p, args->sattr);
7399 +       p = xdr_encode_sattr(p, args->sattr,
7400 +               req->rq_task->tk_client->cl_tag);
7401         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7402         return 0;
7403  }
7404 @@ -410,7 +416,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7405  {
7406         p = xdr_encode_fhandle(p, args->fromfh);
7407         p = xdr_encode_array(p, args->fromname, args->fromlen);
7408 -       p = xdr_encode_sattr(p, args->sattr);
7409 +       p = xdr_encode_sattr(p, args->sattr,
7410 +               req->rq_task->tk_client->cl_tag);
7411         *p++ = htonl(args->pathlen);
7412         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7413  
7414 @@ -428,7 +435,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7415         p = xdr_encode_fhandle(p, args->fh);
7416         p = xdr_encode_array(p, args->name, args->len);
7417         *p++ = htonl(args->type);
7418 -       p = xdr_encode_sattr(p, args->sattr);
7419 +       p = xdr_encode_sattr(p, args->sattr,
7420 +               req->rq_task->tk_client->cl_tag);
7421         if (args->type == NF3CHR || args->type == NF3BLK) {
7422                 *p++ = htonl(MAJOR(args->rdev));
7423                 *p++ = htonl(MINOR(args->rdev));
7424 diff -NurpP --minimal linux-2.6.35/fs/nfs/nfsroot.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/nfsroot.c
7425 --- linux-2.6.35/fs/nfs/nfsroot.c       2010-08-02 16:52:50.000000000 +0200
7426 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/nfsroot.c 2010-08-02 17:05:06.000000000 +0200
7427 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0;             /
7428  enum {
7429         /* Options that take integer arguments */
7430         Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7431 -       Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7432 +       Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7433         /* Options that take no arguments */
7434         Opt_soft, Opt_hard, Opt_intr,
7435         Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac, 
7436         Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7437 -       Opt_acl, Opt_noacl,
7438 +       Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7439         /* Error token */
7440         Opt_err
7441  };
7442 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
7443         {Opt_tcp, "tcp"},
7444         {Opt_acl, "acl"},
7445         {Opt_noacl, "noacl"},
7446 +       {Opt_tag, "tag"},
7447 +       {Opt_notag, "notag"},
7448 +       {Opt_tagid, "tagid=%u"},
7449         {Opt_err, NULL}
7450         
7451  };
7452 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
7453                         case Opt_noacl:
7454                                 nfs_data.flags |= NFS_MOUNT_NOACL;
7455                                 break;
7456 +#ifndef CONFIG_TAGGING_NONE
7457 +                       case Opt_tag:
7458 +                               nfs_data.flags |= NFS_MOUNT_TAGGED;
7459 +                               break;
7460 +                       case Opt_notag:
7461 +                               nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7462 +                               break;
7463 +#endif
7464 +#ifdef CONFIG_PROPAGATE
7465 +                       case Opt_tagid:
7466 +                               /* use args[0] */
7467 +                               nfs_data.flags |= NFS_MOUNT_TAGGED;
7468 +                               break;
7469 +#endif
7470                         default:
7471                                 printk(KERN_WARNING "Root-NFS: unknown "
7472                                         "option: %s\n", p);
7473 diff -NurpP --minimal linux-2.6.35/fs/nfs/super.c linux-2.6.35-vs2.3.0.36.31/fs/nfs/super.c
7474 --- linux-2.6.35/fs/nfs/super.c 2010-08-02 16:52:50.000000000 +0200
7475 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfs/super.c   2010-08-02 17:05:06.000000000 +0200
7476 @@ -54,6 +54,7 @@
7477  #include <linux/nfs_xdr.h>
7478  #include <linux/magic.h>
7479  #include <linux/parser.h>
7480 +#include <linux/vs_tag.h>
7481  
7482  #include <asm/system.h>
7483  #include <asm/uaccess.h>
7484 @@ -606,6 +607,7 @@ static void nfs_show_mount_options(struc
7485                 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7486                 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
7487                 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
7488 +               { NFS_MOUNT_TAGGED, ",tag", "" },
7489                 { 0, NULL, NULL }
7490         };
7491         const struct proc_nfs_info *nfs_infop;
7492 diff -NurpP --minimal linux-2.6.35/fs/nfsd/auth.c linux-2.6.35-vs2.3.0.36.31/fs/nfsd/auth.c
7493 --- linux-2.6.35/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
7494 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfsd/auth.c   2010-08-02 17:05:06.000000000 +0200
7495 @@ -1,6 +1,7 @@
7496  /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
7497  
7498  #include <linux/sched.h>
7499 +#include <linux/vs_tag.h>
7500  #include "nfsd.h"
7501  #include "auth.h"
7502  
7503 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7504  
7505         new->fsuid = rqstp->rq_cred.cr_uid;
7506         new->fsgid = rqstp->rq_cred.cr_gid;
7507 +       /* FIXME: this desperately needs a tag :)
7508 +       new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7509 +                       */
7510  
7511         rqgi = rqstp->rq_cred.cr_group_info;
7512  
7513 diff -NurpP --minimal linux-2.6.35/fs/nfsd/nfs3xdr.c linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfs3xdr.c
7514 --- linux-2.6.35/fs/nfsd/nfs3xdr.c      2010-02-25 11:52:05.000000000 +0100
7515 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfs3xdr.c        2010-08-02 17:05:06.000000000 +0200
7516 @@ -7,6 +7,7 @@
7517   */
7518  
7519  #include <linux/namei.h>
7520 +#include <linux/vs_tag.h>
7521  #include "xdr3.h"
7522  #include "auth.h"
7523  
7524 @@ -95,6 +96,8 @@ static __be32 *
7525  decode_sattr3(__be32 *p, struct iattr *iap)
7526  {
7527         u32     tmp;
7528 +       uid_t   uid = 0;
7529 +       gid_t   gid = 0;
7530  
7531         iap->ia_valid = 0;
7532  
7533 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7534         }
7535         if (*p++) {
7536                 iap->ia_valid |= ATTR_UID;
7537 -               iap->ia_uid = ntohl(*p++);
7538 +               uid = ntohl(*p++);
7539         }
7540         if (*p++) {
7541                 iap->ia_valid |= ATTR_GID;
7542 -               iap->ia_gid = ntohl(*p++);
7543 +               gid = ntohl(*p++);
7544         }
7545 +       iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7546 +       iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7547 +       iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7548         if (*p++) {
7549                 u64     newsize;
7550  
7551 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
7552         *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7553         *p++ = htonl((u32) stat->mode);
7554         *p++ = htonl((u32) stat->nlink);
7555 -       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7556 -       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7557 +       *p++ = htonl((u32) nfsd_ruid(rqstp,
7558 +               TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7559 +               stat->uid, stat->tag)));
7560 +       *p++ = htonl((u32) nfsd_rgid(rqstp,
7561 +               TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7562 +               stat->gid, stat->tag)));
7563         if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7564                 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7565         } else {
7566 diff -NurpP --minimal linux-2.6.35/fs/nfsd/nfs4xdr.c linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfs4xdr.c
7567 --- linux-2.6.35/fs/nfsd/nfs4xdr.c      2010-08-02 16:52:50.000000000 +0200
7568 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfs4xdr.c        2010-08-02 17:05:06.000000000 +0200
7569 @@ -47,6 +47,7 @@
7570  #include <linux/nfsd_idmap.h>
7571  #include <linux/nfs4_acl.h>
7572  #include <linux/sunrpc/svcauth_gss.h>
7573 +#include <linux/vs_tag.h>
7574  
7575  #include "xdr4.h"
7576  #include "vfs.h"
7577 @@ -2053,14 +2054,18 @@ out_acl:
7578                 WRITE32(stat.nlink);
7579         }
7580         if (bmval1 & FATTR4_WORD1_OWNER) {
7581 -               status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7582 +               status = nfsd4_encode_user(rqstp,
7583 +                       TAGINO_UID(DX_TAG(dentry->d_inode),
7584 +                       stat.uid, stat.tag), &p, &buflen);
7585                 if (status == nfserr_resource)
7586                         goto out_resource;
7587                 if (status)
7588                         goto out;
7589         }
7590         if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7591 -               status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7592 +               status = nfsd4_encode_group(rqstp,
7593 +                       TAGINO_GID(DX_TAG(dentry->d_inode),
7594 +                       stat.gid, stat.tag), &p, &buflen);
7595                 if (status == nfserr_resource)
7596                         goto out_resource;
7597                 if (status)
7598 diff -NurpP --minimal linux-2.6.35/fs/nfsd/nfsxdr.c linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfsxdr.c
7599 --- linux-2.6.35/fs/nfsd/nfsxdr.c       2010-02-25 11:52:05.000000000 +0100
7600 +++ linux-2.6.35-vs2.3.0.36.31/fs/nfsd/nfsxdr.c 2010-08-02 17:05:06.000000000 +0200
7601 @@ -6,6 +6,7 @@
7602  
7603  #include "xdr.h"
7604  #include "auth.h"
7605 +#include <linux/vs_tag.h>
7606  
7607  #define NFSDDBG_FACILITY               NFSDDBG_XDR
7608  
7609 @@ -88,6 +89,8 @@ static __be32 *
7610  decode_sattr(__be32 *p, struct iattr *iap)
7611  {
7612         u32     tmp, tmp1;
7613 +       uid_t   uid = 0;
7614 +       gid_t   gid = 0;
7615  
7616         iap->ia_valid = 0;
7617  
7618 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7619         }
7620         if ((tmp = ntohl(*p++)) != (u32)-1) {
7621                 iap->ia_valid |= ATTR_UID;
7622 -               iap->ia_uid = tmp;
7623 +               uid = tmp;
7624         }
7625         if ((tmp = ntohl(*p++)) != (u32)-1) {
7626                 iap->ia_valid |= ATTR_GID;
7627 -               iap->ia_gid = tmp;
7628 +               gid = tmp;
7629         }
7630 +       iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7631 +       iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7632 +       iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7633         if ((tmp = ntohl(*p++)) != (u32)-1) {
7634                 iap->ia_valid |= ATTR_SIZE;
7635                 iap->ia_size = tmp;
7636 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7637         *p++ = htonl(nfs_ftypes[type >> 12]);
7638         *p++ = htonl((u32) stat->mode);
7639         *p++ = htonl((u32) stat->nlink);
7640 -       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7641 -       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7642 +       *p++ = htonl((u32) nfsd_ruid(rqstp,
7643 +               TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7644 +       *p++ = htonl((u32) nfsd_rgid(rqstp,
7645 +               TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7646  
7647         if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7648                 *p++ = htonl(NFS_MAXPATHLEN);
7649 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/dlmglue.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/dlmglue.c
7650 --- linux-2.6.35/fs/ocfs2/dlmglue.c     2010-08-02 16:52:51.000000000 +0200
7651 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/dlmglue.c       2010-08-02 17:05:06.000000000 +0200
7652 @@ -2114,6 +2114,7 @@ static void __ocfs2_stuff_meta_lvb(struc
7653         lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
7654         lvb->lvb_iuid      = cpu_to_be32(inode->i_uid);
7655         lvb->lvb_igid      = cpu_to_be32(inode->i_gid);
7656 +       lvb->lvb_itag      = cpu_to_be16(inode->i_tag);
7657         lvb->lvb_imode     = cpu_to_be16(inode->i_mode);
7658         lvb->lvb_inlink    = cpu_to_be16(inode->i_nlink);
7659         lvb->lvb_iatime_packed  =
7660 @@ -2168,6 +2169,7 @@ static void ocfs2_refresh_inode_from_lvb
7661  
7662         inode->i_uid     = be32_to_cpu(lvb->lvb_iuid);
7663         inode->i_gid     = be32_to_cpu(lvb->lvb_igid);
7664 +       inode->i_tag     = be16_to_cpu(lvb->lvb_itag);
7665         inode->i_mode    = be16_to_cpu(lvb->lvb_imode);
7666         inode->i_nlink   = be16_to_cpu(lvb->lvb_inlink);
7667         ocfs2_unpack_timespec(&inode->i_atime,
7668 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/dlmglue.h linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/dlmglue.h
7669 --- linux-2.6.35/fs/ocfs2/dlmglue.h     2009-12-03 20:02:53.000000000 +0100
7670 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/dlmglue.h       2010-08-02 17:05:06.000000000 +0200
7671 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
7672         __be16       lvb_inlink;
7673         __be32       lvb_iattr;
7674         __be32       lvb_igeneration;
7675 -       __be32       lvb_reserved2;
7676 +       __be16       lvb_itag;
7677 +       __be16       lvb_reserved2;
7678  };
7679  
7680  #define OCFS2_QINFO_LVB_VERSION 1
7681 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/file.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/file.c
7682 --- linux-2.6.35/fs/ocfs2/file.c        2010-08-02 16:52:51.000000000 +0200
7683 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/file.c  2010-08-02 17:05:06.000000000 +0200
7684 @@ -1129,13 +1129,15 @@ int ocfs2_setattr(struct dentry *dentry,
7685                 mlog(0, "uid change: %d\n", attr->ia_uid);
7686         if (attr->ia_valid & ATTR_GID)
7687                 mlog(0, "gid change: %d\n", attr->ia_gid);
7688 +       if (attr->ia_valid & ATTR_TAG)
7689 +               mlog(0, "tag change: %d\n", attr->ia_tag);
7690         if (attr->ia_valid & ATTR_SIZE)
7691                 mlog(0, "size change...\n");
7692         if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
7693                 mlog(0, "time change...\n");
7694  
7695  #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
7696 -                          | ATTR_GID | ATTR_UID | ATTR_MODE)
7697 +                          | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
7698         if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
7699                 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
7700                 return 0;
7701 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/inode.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/inode.c
7702 --- linux-2.6.35/fs/ocfs2/inode.c       2010-08-02 16:52:51.000000000 +0200
7703 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/inode.c 2010-08-02 17:05:06.000000000 +0200
7704 @@ -28,6 +28,7 @@
7705  #include <linux/highmem.h>
7706  #include <linux/pagemap.h>
7707  #include <linux/quotaops.h>
7708 +#include <linux/vs_tag.h>
7709  
7710  #include <asm/byteorder.h>
7711  
7712 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode 
7713  {
7714         unsigned int flags = OCFS2_I(inode)->ip_attr;
7715  
7716 -       inode->i_flags &= ~(S_IMMUTABLE |
7717 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
7718                 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
7719  
7720         if (flags & OCFS2_IMMUTABLE_FL)
7721                 inode->i_flags |= S_IMMUTABLE;
7722 +       if (flags & OCFS2_IXUNLINK_FL)
7723 +               inode->i_flags |= S_IXUNLINK;
7724  
7725         if (flags & OCFS2_SYNC_FL)
7726                 inode->i_flags |= S_SYNC;
7727 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode 
7728                 inode->i_flags |= S_NOATIME;
7729         if (flags & OCFS2_DIRSYNC_FL)
7730                 inode->i_flags |= S_DIRSYNC;
7731 +
7732 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
7733 +
7734 +       if (flags & OCFS2_BARRIER_FL)
7735 +               inode->i_vflags |= V_BARRIER;
7736 +       if (flags & OCFS2_COW_FL)
7737 +               inode->i_vflags |= V_COW;
7738  }
7739  
7740  /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
7741  void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
7742  {
7743         unsigned int flags = oi->vfs_inode.i_flags;
7744 +       unsigned int vflags = oi->vfs_inode.i_vflags;
7745 +
7746 +       oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
7747 +                       OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
7748 +                       OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
7749 +                       OCFS2_BARRIER_FL | OCFS2_COW_FL);
7750 +
7751 +       if (flags & S_IMMUTABLE)
7752 +               oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7753 +       if (flags & S_IXUNLINK)
7754 +               oi->ip_attr |= OCFS2_IXUNLINK_FL;
7755  
7756 -       oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
7757 -                       OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
7758         if (flags & S_SYNC)
7759                 oi->ip_attr |= OCFS2_SYNC_FL;
7760         if (flags & S_APPEND)
7761                 oi->ip_attr |= OCFS2_APPEND_FL;
7762 -       if (flags & S_IMMUTABLE)
7763 -               oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7764         if (flags & S_NOATIME)
7765                 oi->ip_attr |= OCFS2_NOATIME_FL;
7766         if (flags & S_DIRSYNC)
7767                 oi->ip_attr |= OCFS2_DIRSYNC_FL;
7768 +
7769 +       if (vflags & V_BARRIER)
7770 +               oi->ip_attr |= OCFS2_BARRIER_FL;
7771 +       if (vflags & V_COW)
7772 +               oi->ip_attr |= OCFS2_COW_FL;
7773  }
7774  
7775  struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
7776 @@ -245,6 +267,8 @@ void ocfs2_populate_inode(struct inode *
7777         struct super_block *sb;
7778         struct ocfs2_super *osb;
7779         int use_plocks = 1;
7780 +       uid_t uid;
7781 +       gid_t gid;
7782  
7783         mlog_entry("(0x%p, size:%llu)\n", inode,
7784                    (unsigned long long)le64_to_cpu(fe->i_size));
7785 @@ -276,8 +300,12 @@ void ocfs2_populate_inode(struct inode *
7786         inode->i_generation = le32_to_cpu(fe->i_generation);
7787         inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
7788         inode->i_mode = le16_to_cpu(fe->i_mode);
7789 -       inode->i_uid = le32_to_cpu(fe->i_uid);
7790 -       inode->i_gid = le32_to_cpu(fe->i_gid);
7791 +       uid = le32_to_cpu(fe->i_uid);
7792 +       gid = le32_to_cpu(fe->i_gid);
7793 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7794 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7795 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7796 +               /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7797  
7798         /* Fast symlinks will have i_size but no allocated clusters. */
7799         if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
7800 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/inode.h linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/inode.h
7801 --- linux-2.6.35/fs/ocfs2/inode.h       2010-08-02 16:52:51.000000000 +0200
7802 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/inode.h 2010-08-02 17:05:06.000000000 +0200
7803 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
7804  
7805  void ocfs2_set_inode_flags(struct inode *inode);
7806  void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
7807 +int ocfs2_sync_flags(struct inode *inode, int, int);
7808  
7809  static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
7810  {
7811 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ioctl.c
7812 --- linux-2.6.35/fs/ocfs2/ioctl.c       2010-02-25 11:52:06.000000000 +0100
7813 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ioctl.c 2010-08-02 17:05:06.000000000 +0200
7814 @@ -43,7 +43,41 @@ static int ocfs2_get_inode_attr(struct i
7815         return status;
7816  }
7817  
7818 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7819 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
7820 +{
7821 +       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7822 +       struct buffer_head *bh = NULL;
7823 +       handle_t *handle = NULL;
7824 +       int status;
7825 +
7826 +       status = ocfs2_inode_lock(inode, &bh, 1);
7827 +       if (status < 0) {
7828 +               mlog_errno(status);
7829 +               return status;
7830 +       }
7831 +       handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7832 +       if (IS_ERR(handle)) {
7833 +               status = PTR_ERR(handle);
7834 +               mlog_errno(status);
7835 +               goto bail_unlock;
7836 +       }
7837 +
7838 +       inode->i_flags = flags;
7839 +       inode->i_vflags = vflags;
7840 +       ocfs2_get_inode_flags(OCFS2_I(inode));
7841 +
7842 +       status = ocfs2_mark_inode_dirty(handle, inode, bh);
7843 +       if (status < 0)
7844 +               mlog_errno(status);
7845 +
7846 +       ocfs2_commit_trans(osb, handle);
7847 +bail_unlock:
7848 +       ocfs2_inode_unlock(inode, 1);
7849 +       brelse(bh);
7850 +       return status;
7851 +}
7852 +
7853 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7854                                 unsigned mask)
7855  {
7856         struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
7857 @@ -68,6 +102,11 @@ static int ocfs2_set_inode_attr(struct i
7858         if (!S_ISDIR(inode->i_mode))
7859                 flags &= ~OCFS2_DIRSYNC_FL;
7860  
7861 +       if (IS_BARRIER(inode)) {
7862 +               vxwprintk_task(1, "messing with the barrier.");
7863 +               goto bail_unlock;
7864 +       }
7865 +
7866         handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7867         if (IS_ERR(handle)) {
7868                 status = PTR_ERR(handle);
7869 @@ -109,6 +148,7 @@ bail:
7870         return status;
7871  }
7872  
7873 +
7874  long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7875  {
7876         struct inode *inode = filp->f_path.dentry->d_inode;
7877 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/namei.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/namei.c
7878 --- linux-2.6.35/fs/ocfs2/namei.c       2010-08-02 16:52:51.000000000 +0200
7879 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/namei.c 2010-08-02 17:05:06.000000000 +0200
7880 @@ -41,6 +41,7 @@
7881  #include <linux/slab.h>
7882  #include <linux/highmem.h>
7883  #include <linux/quotaops.h>
7884 +#include <linux/vs_tag.h>
7885  
7886  #define MLOG_MASK_PREFIX ML_NAMEI
7887  #include <cluster/masklog.h>
7888 @@ -487,6 +488,7 @@ static int ocfs2_mknod_locked(struct ocf
7889         u64 suballoc_loc, fe_blkno = 0;
7890         u16 suballoc_bit;
7891         u16 feat;
7892 +       tag_t tag;
7893  
7894         *new_fe_bh = NULL;
7895  
7896 @@ -532,8 +534,11 @@ static int ocfs2_mknod_locked(struct ocf
7897         fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
7898         fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
7899         fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
7900 -       fe->i_uid = cpu_to_le32(inode->i_uid);
7901 -       fe->i_gid = cpu_to_le32(inode->i_gid);
7902 +
7903 +       tag = dx_current_fstag(osb->sb);
7904 +       fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
7905 +       fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
7906 +       inode->i_tag = tag;
7907         fe->i_mode = cpu_to_le16(inode->i_mode);
7908         if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
7909                 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
7910 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/ocfs2_fs.h linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ocfs2_fs.h
7911 --- linux-2.6.35/fs/ocfs2/ocfs2_fs.h    2010-08-02 16:52:51.000000000 +0200
7912 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ocfs2_fs.h      2010-08-02 17:05:06.000000000 +0200
7913 @@ -235,18 +235,23 @@
7914  #define OCFS2_HAS_REFCOUNT_FL   (0x0010)
7915  
7916  /* Inode attributes, keep in sync with EXT2 */
7917 -#define OCFS2_SECRM_FL         (0x00000001)    /* Secure deletion */
7918 -#define OCFS2_UNRM_FL          (0x00000002)    /* Undelete */
7919 -#define OCFS2_COMPR_FL         (0x00000004)    /* Compress file */
7920 -#define OCFS2_SYNC_FL          (0x00000008)    /* Synchronous updates */
7921 -#define OCFS2_IMMUTABLE_FL     (0x00000010)    /* Immutable file */
7922 -#define OCFS2_APPEND_FL                (0x00000020)    /* writes to file may only append */
7923 -#define OCFS2_NODUMP_FL                (0x00000040)    /* do not dump file */
7924 -#define OCFS2_NOATIME_FL       (0x00000080)    /* do not update atime */
7925 -#define OCFS2_DIRSYNC_FL       (0x00010000)    /* dirsync behaviour (directories only) */
7926 +#define OCFS2_SECRM_FL         FS_SECRM_FL     /* Secure deletion */
7927 +#define OCFS2_UNRM_FL          FS_UNRM_FL      /* Undelete */
7928 +#define OCFS2_COMPR_FL         FS_COMPR_FL     /* Compress file */
7929 +#define OCFS2_SYNC_FL          FS_SYNC_FL      /* Synchronous updates */
7930 +#define OCFS2_IMMUTABLE_FL     FS_IMMUTABLE_FL /* Immutable file */
7931 +#define OCFS2_APPEND_FL                FS_APPEND_FL    /* writes to file may only append */
7932 +#define OCFS2_NODUMP_FL                FS_NODUMP_FL    /* do not dump file */
7933 +#define OCFS2_NOATIME_FL       FS_NOATIME_FL   /* do not update atime */
7934  
7935 -#define OCFS2_FL_VISIBLE       (0x000100FF)    /* User visible flags */
7936 -#define OCFS2_FL_MODIFIABLE    (0x000100FF)    /* User modifiable flags */
7937 +#define OCFS2_DIRSYNC_FL       FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
7938 +#define OCFS2_IXUNLINK_FL      FS_IXUNLINK_FL  /* Immutable invert on unlink */
7939 +
7940 +#define OCFS2_BARRIER_FL       FS_BARRIER_FL   /* Barrier for chroot() */
7941 +#define OCFS2_COW_FL           FS_COW_FL       /* Copy on Write marker */
7942 +
7943 +#define OCFS2_FL_VISIBLE       (0x010300FF)    /* User visible flags */
7944 +#define OCFS2_FL_MODIFIABLE    (0x010300FF)    /* User modifiable flags */
7945  
7946  /*
7947   * Extent record flags (e_node.leaf.flags)
7948 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/ocfs2.h linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ocfs2.h
7949 --- linux-2.6.35/fs/ocfs2/ocfs2.h       2010-08-02 16:52:51.000000000 +0200
7950 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/ocfs2.h 2010-08-02 17:05:06.000000000 +0200
7951 @@ -256,6 +256,7 @@ enum ocfs2_mount_options
7952                                                    control lists */
7953         OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
7954         OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
7955 +       OCFS2_MOUNT_TAGGED = 1 << 12, /* use tagging */
7956  };
7957  
7958  #define OCFS2_OSB_SOFT_RO                      0x0001
7959 diff -NurpP --minimal linux-2.6.35/fs/ocfs2/super.c linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/super.c
7960 --- linux-2.6.35/fs/ocfs2/super.c       2010-08-02 16:52:51.000000000 +0200
7961 +++ linux-2.6.35-vs2.3.0.36.31/fs/ocfs2/super.c 2010-08-02 18:00:11.000000000 +0200
7962 @@ -180,6 +180,7 @@ enum {
7963         Opt_grpquota,
7964         Opt_resv_level,
7965         Opt_dir_resv_level,
7966 +       Opt_tag, Opt_notag, Opt_tagid,
7967         Opt_err,
7968  };
7969  
7970 @@ -208,6 +209,9 @@ static const match_table_t tokens = {
7971         {Opt_grpquota, "grpquota"},
7972         {Opt_resv_level, "resv_level=%u"},
7973         {Opt_dir_resv_level, "dir_resv_level=%u"},
7974 +       {Opt_tag, "tag"},
7975 +       {Opt_notag, "notag"},
7976 +       {Opt_tagid, "tagid=%u"},
7977         {Opt_err, NULL}
7978  };
7979  
7980 @@ -618,6 +622,13 @@ static int ocfs2_remount(struct super_bl
7981                 goto out;
7982         }
7983  
7984 +       if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
7985 +           (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
7986 +               ret = -EINVAL;
7987 +               mlog(ML_ERROR, "Cannot change tagging on remount\n");
7988 +               goto out;
7989 +       }
7990 +
7991         if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
7992             (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
7993                 ret = -EINVAL;
7994 @@ -1154,6 +1165,9 @@ static int ocfs2_fill_super(struct super
7995  
7996         ocfs2_complete_mount_recovery(osb);
7997  
7998 +       if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
7999 +               sb->s_flags |= MS_TAGGED;
8000 +
8001         if (ocfs2_mount_local(osb))
8002                 snprintf(nodestr, sizeof(nodestr), "local");
8003         else
8004 @@ -1469,6 +1483,20 @@ static int ocfs2_parse_options(struct su
8005                             option < OCFS2_MAX_RESV_LEVEL)
8006                                 mopt->dir_resv_level = option;
8007                         break;
8008 +#ifndef CONFIG_TAGGING_NONE
8009 +               case Opt_tag:
8010 +                       mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8011 +                       break;
8012 +               case Opt_notag:
8013 +                       mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
8014 +                       break;
8015 +#endif
8016 +#ifdef CONFIG_PROPAGATE
8017 +               case Opt_tagid:
8018 +                       /* use args[0] */
8019 +                       mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8020 +                       break;
8021 +#endif
8022                 default:
8023                         mlog(ML_ERROR,
8024                              "Unrecognized mount option \"%s\" "
8025 diff -NurpP --minimal linux-2.6.35/fs/open.c linux-2.6.35-vs2.3.0.36.31/fs/open.c
8026 --- linux-2.6.35/fs/open.c      2010-08-02 16:52:51.000000000 +0200
8027 +++ linux-2.6.35-vs2.3.0.36.31/fs/open.c        2010-08-02 21:36:22.000000000 +0200
8028 @@ -29,6 +29,11 @@
8029  #include <linux/falloc.h>
8030  #include <linux/fs_struct.h>
8031  #include <linux/ima.h>
8032 +#include <linux/vs_base.h>
8033 +#include <linux/vs_limit.h>
8034 +#include <linux/vs_tag.h>
8035 +#include <linux/vs_cowbl.h>
8036 +#include <linux/vserver/dlimit.h>
8037  
8038  #include "internal.h"
8039  
8040 @@ -481,6 +486,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
8041         error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
8042         if (error)
8043                 goto out;
8044 +
8045 +#ifdef CONFIG_VSERVER_COWBL
8046 +       error = cow_check_and_break(&path);
8047 +       if (error)
8048 +               goto dput_and_out;
8049 +#endif
8050         inode = path.dentry->d_inode;
8051  
8052         error = mnt_want_write(path.mnt);
8053 @@ -518,11 +529,11 @@ static int chown_common(struct path *pat
8054         newattrs.ia_valid =  ATTR_CTIME;
8055         if (user != (uid_t) -1) {
8056                 newattrs.ia_valid |= ATTR_UID;
8057 -               newattrs.ia_uid = user;
8058 +               newattrs.ia_uid = dx_map_uid(user);
8059         }
8060         if (group != (gid_t) -1) {
8061                 newattrs.ia_valid |= ATTR_GID;
8062 -               newattrs.ia_gid = group;
8063 +               newattrs.ia_gid = dx_map_gid(group);
8064         }
8065         if (!S_ISDIR(inode->i_mode))
8066                 newattrs.ia_valid |=
8067 @@ -547,6 +558,10 @@ SYSCALL_DEFINE3(chown, const char __user
8068         error = mnt_want_write(path.mnt);
8069         if (error)
8070                 goto out_release;
8071 +#ifdef CONFIG_VSERVER_COWBL
8072 +       error = cow_check_and_break(&path);
8073 +       if (!error)
8074 +#endif
8075         error = chown_common(&path, user, group);
8076         mnt_drop_write(path.mnt);
8077  out_release:
8078 @@ -572,6 +587,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
8079         error = mnt_want_write(path.mnt);
8080         if (error)
8081                 goto out_release;
8082 +#ifdef CONFIG_VSERVER_COWBL
8083 +       error = cow_check_and_break(&path);
8084 +       if (!error)
8085 +#endif
8086         error = chown_common(&path, user, group);
8087         mnt_drop_write(path.mnt);
8088  out_release:
8089 @@ -591,6 +610,10 @@ SYSCALL_DEFINE3(lchown, const char __use
8090         error = mnt_want_write(path.mnt);
8091         if (error)
8092                 goto out_release;
8093 +#ifdef CONFIG_VSERVER_COWBL
8094 +       error = cow_check_and_break(&path);
8095 +       if (!error)
8096 +#endif
8097         error = chown_common(&path, user, group);
8098         mnt_drop_write(path.mnt);
8099  out_release:
8100 @@ -837,6 +860,7 @@ static void __put_unused_fd(struct files
8101         __FD_CLR(fd, fdt->open_fds);
8102         if (fd < files->next_fd)
8103                 files->next_fd = fd;
8104 +       vx_openfd_dec(fd);
8105  }
8106  
8107  void put_unused_fd(unsigned int fd)
8108 diff -NurpP --minimal linux-2.6.35/fs/proc/array.c linux-2.6.35-vs2.3.0.36.31/fs/proc/array.c
8109 --- linux-2.6.35/fs/proc/array.c        2010-08-02 16:52:51.000000000 +0200
8110 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/array.c  2010-08-02 17:05:06.000000000 +0200
8111 @@ -81,6 +81,8 @@
8112  #include <linux/pid_namespace.h>
8113  #include <linux/ptrace.h>
8114  #include <linux/tracehook.h>
8115 +#include <linux/vs_context.h>
8116 +#include <linux/vs_network.h>
8117  
8118  #include <asm/pgtable.h>
8119  #include <asm/processor.h>
8120 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
8121         rcu_read_lock();
8122         ppid = pid_alive(p) ?
8123                 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
8124 +       if (unlikely(vx_current_initpid(p->pid)))
8125 +               ppid = 0;
8126 +
8127         tpid = 0;
8128         if (pid_alive(p)) {
8129                 struct task_struct *tracer = tracehook_tracer_task(p);
8130 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
8131  }
8132  
8133  static void render_cap_t(struct seq_file *m, const char *header,
8134 -                       kernel_cap_t *a)
8135 +                       struct vx_info *vxi, kernel_cap_t *a)
8136  {
8137         unsigned __capi;
8138  
8139 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
8140         cap_bset        = cred->cap_bset;
8141         rcu_read_unlock();
8142  
8143 -       render_cap_t(m, "CapInh:\t", &cap_inheritable);
8144 -       render_cap_t(m, "CapPrm:\t", &cap_permitted);
8145 -       render_cap_t(m, "CapEff:\t", &cap_effective);
8146 -       render_cap_t(m, "CapBnd:\t", &cap_bset);
8147 +       /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
8148 +       render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
8149 +       render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
8150 +       render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
8151 +       render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
8152  }
8153  
8154  static inline void task_context_switch_counts(struct seq_file *m,
8155 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
8156         seq_printf(m, "\n");
8157  }
8158  
8159 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8160 +                       struct pid *pid, struct task_struct *task)
8161 +{
8162 +       seq_printf(m,   "Proxy:\t%p(%c)\n"
8163 +                       "Count:\t%u\n"
8164 +                       "uts:\t%p(%c)\n"
8165 +                       "ipc:\t%p(%c)\n"
8166 +                       "mnt:\t%p(%c)\n"
8167 +                       "pid:\t%p(%c)\n"
8168 +                       "net:\t%p(%c)\n",
8169 +                       task->nsproxy,
8170 +                       (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
8171 +                       atomic_read(&task->nsproxy->count),
8172 +                       task->nsproxy->uts_ns,
8173 +                       (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
8174 +                       task->nsproxy->ipc_ns,
8175 +                       (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
8176 +                       task->nsproxy->mnt_ns,
8177 +                       (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
8178 +                       task->nsproxy->pid_ns,
8179 +                       (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
8180 +                       task->nsproxy->net_ns,
8181 +                       (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
8182 +       return 0;
8183 +}
8184 +
8185 +void task_vs_id(struct seq_file *m, struct task_struct *task)
8186 +{
8187 +       if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8188 +               return;
8189 +
8190 +       seq_printf(m, "VxID: %d\n", vx_task_xid(task));
8191 +       seq_printf(m, "NxID: %d\n", nx_task_nid(task));
8192 +}
8193 +
8194 +
8195  int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
8196                         struct pid *pid, struct task_struct *task)
8197  {
8198 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m, 
8199         task_cap(m, task);
8200         task_cpus_allowed(m, task);
8201         cpuset_task_status_allowed(m, task);
8202 +       task_vs_id(m, task);
8203  #if defined(CONFIG_S390)
8204         task_show_regs(m, task);
8205  #endif
8206 @@ -465,6 +508,17 @@ static int do_task_stat(struct seq_file 
8207         /* convert nsec -> ticks */
8208         start_time = nsec_to_clock_t(start_time);
8209  
8210 +       /* fixup start time for virt uptime */
8211 +       if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8212 +               unsigned long long bias =
8213 +                       current->vx_info->cvirt.bias_clock;
8214 +
8215 +               if (start_time > bias)
8216 +                       start_time -= bias;
8217 +               else
8218 +                       start_time = 0;
8219 +       }
8220 +
8221         seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
8222  %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8223  %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
8224 diff -NurpP --minimal linux-2.6.35/fs/proc/base.c linux-2.6.35-vs2.3.0.36.31/fs/proc/base.c
8225 --- linux-2.6.35/fs/proc/base.c 2010-08-02 16:52:51.000000000 +0200
8226 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/base.c   2010-08-02 17:05:06.000000000 +0200
8227 @@ -82,6 +82,8 @@
8228  #include <linux/pid_namespace.h>
8229  #include <linux/fs_struct.h>
8230  #include <linux/slab.h>
8231 +#include <linux/vs_context.h>
8232 +#include <linux/vs_network.h>
8233  #include "internal.h"
8234  
8235  /* NOTE:
8236 @@ -1033,12 +1035,17 @@ static ssize_t oom_adjust_write(struct f
8237                 return -ESRCH;
8238         }
8239  
8240 -       if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
8241 +       if (oom_adjust < task->signal->oom_adj &&
8242 +               !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
8243                 unlock_task_sighand(task, &flags);
8244                 put_task_struct(task);
8245                 return -EACCES;
8246         }
8247  
8248 +       /* prevent guest processes from circumventing the oom killer */
8249 +       if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
8250 +               oom_adjust = OOM_ADJUST_MIN;
8251 +
8252         task->signal->oom_adj = oom_adjust;
8253  
8254         unlock_task_sighand(task, &flags);
8255 @@ -1079,7 +1086,7 @@ static ssize_t proc_loginuid_write(struc
8256         ssize_t length;
8257         uid_t loginuid;
8258  
8259 -       if (!capable(CAP_AUDIT_CONTROL))
8260 +       if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
8261                 return -EPERM;
8262  
8263         rcu_read_lock();
8264 @@ -1517,6 +1524,8 @@ static struct inode *proc_pid_make_inode
8265                 inode->i_gid = cred->egid;
8266                 rcu_read_unlock();
8267         }
8268 +       /* procfs is xid tagged */
8269 +       inode->i_tag = (tag_t)vx_task_xid(task);
8270         security_task_to_inode(task, inode);
8271  
8272  out:
8273 @@ -2067,6 +2076,13 @@ static struct dentry *proc_pident_lookup
8274         if (!task)
8275                 goto out_no_task;
8276  
8277 +       /* TODO: maybe we can come up with a generic approach? */
8278 +       if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8279 +               (dentry->d_name.len == 5) &&
8280 +               (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8281 +               !memcmp(dentry->d_name.name, "ninfo", 5)))
8282 +               goto out;
8283 +
8284         /*
8285          * Yes, it does not scale. And it should not. Don't add
8286          * new entries into /proc/<tgid>/ without very good reasons.
8287 @@ -2474,7 +2490,7 @@ out_iput:
8288  static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8289  {
8290         struct dentry *error;
8291 -       struct task_struct *task = get_proc_task(dir);
8292 +       struct task_struct *task = get_proc_task_real(dir);
8293         const struct pid_entry *p, *last;
8294  
8295         error = ERR_PTR(-ENOENT);
8296 @@ -2564,6 +2580,9 @@ static int proc_pid_personality(struct s
8297  static const struct file_operations proc_task_operations;
8298  static const struct inode_operations proc_task_inode_operations;
8299  
8300 +extern int proc_pid_vx_info(struct task_struct *, char *);
8301 +extern int proc_pid_nx_info(struct task_struct *, char *);
8302 +
8303  static const struct pid_entry tgid_base_stuff[] = {
8304         DIR("task",       S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
8305         DIR("fd",         S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
8306 @@ -2623,6 +2642,8 @@ static const struct pid_entry tgid_base_
8307  #ifdef CONFIG_CGROUPS
8308         REG("cgroup",  S_IRUGO, proc_cgroup_operations),
8309  #endif
8310 +       INF("vinfo",      S_IRUGO, proc_pid_vx_info),
8311 +       INF("ninfo",      S_IRUGO, proc_pid_nx_info),
8312         INF("oom_score",  S_IRUGO, proc_oom_score),
8313         REG("oom_adj",    S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
8314  #ifdef CONFIG_AUDITSYSCALL
8315 @@ -2638,6 +2659,7 @@ static const struct pid_entry tgid_base_
8316  #ifdef CONFIG_TASK_IO_ACCOUNTING
8317         INF("io",       S_IRUGO, proc_tgid_io_accounting),
8318  #endif
8319 +       ONE("nsproxy",  S_IRUGO, proc_pid_nsproxy),
8320  };
8321  
8322  static int proc_tgid_base_readdir(struct file * filp,
8323 @@ -2829,7 +2851,7 @@ retry:
8324         iter.task = NULL;
8325         pid = find_ge_pid(iter.tgid, ns);
8326         if (pid) {
8327 -               iter.tgid = pid_nr_ns(pid, ns);
8328 +               iter.tgid = pid_unmapped_nr_ns(pid, ns);
8329                 iter.task = pid_task(pid, PIDTYPE_PID);
8330                 /* What we to know is if the pid we have find is the
8331                  * pid of a thread_group_leader.  Testing for task
8332 @@ -2859,7 +2881,7 @@ static int proc_pid_fill_cache(struct fi
8333         struct tgid_iter iter)
8334  {
8335         char name[PROC_NUMBUF];
8336 -       int len = snprintf(name, sizeof(name), "%d", iter.tgid);
8337 +       int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
8338         return proc_fill_cache(filp, dirent, filldir, name, len,
8339                                 proc_pid_instantiate, iter.task, NULL);
8340  }
8341 @@ -2868,7 +2890,7 @@ static int proc_pid_fill_cache(struct fi
8342  int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8343  {
8344         unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8345 -       struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8346 +       struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8347         struct tgid_iter iter;
8348         struct pid_namespace *ns;
8349  
8350 @@ -2888,6 +2910,8 @@ int proc_pid_readdir(struct file * filp,
8351              iter.task;
8352              iter.tgid += 1, iter = next_tgid(ns, iter)) {
8353                 filp->f_pos = iter.tgid + TGID_OFFSET;
8354 +               if (!vx_proc_task_visible(iter.task))
8355 +                       continue;
8356                 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
8357                         put_task_struct(iter.task);
8358                         goto out;
8359 @@ -3035,6 +3059,8 @@ static struct dentry *proc_task_lookup(s
8360         tid = name_to_int(dentry);
8361         if (tid == ~0U)
8362                 goto out;
8363 +       if (vx_current_initpid(tid))
8364 +               goto out;
8365  
8366         ns = dentry->d_sb->s_fs_info;
8367         rcu_read_lock();
8368 diff -NurpP --minimal linux-2.6.35/fs/proc/generic.c linux-2.6.35-vs2.3.0.36.31/fs/proc/generic.c
8369 --- linux-2.6.35/fs/proc/generic.c      2010-08-02 16:52:51.000000000 +0200
8370 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/generic.c        2010-08-02 17:05:06.000000000 +0200
8371 @@ -21,6 +21,7 @@
8372  #include <linux/bitops.h>
8373  #include <linux/spinlock.h>
8374  #include <linux/completion.h>
8375 +#include <linux/vserver/inode.h>
8376  #include <asm/uaccess.h>
8377  
8378  #include "internal.h"
8379 @@ -418,6 +419,8 @@ struct dentry *proc_lookup_de(struct pro
8380         for (de = de->subdir; de ; de = de->next) {
8381                 if (de->namelen != dentry->d_name.len)
8382                         continue;
8383 +                       if (!vx_hide_check(0, de->vx_flags))
8384 +                               continue;
8385                 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8386                         unsigned int ino;
8387  
8388 @@ -426,6 +429,8 @@ struct dentry *proc_lookup_de(struct pro
8389                         spin_unlock(&proc_subdir_lock);
8390                         error = -EINVAL;
8391                         inode = proc_get_inode(dir->i_sb, ino, de);
8392 +                               /* generic proc entries belong to the host */
8393 +                               inode->i_tag = 0;
8394                         goto out_unlock;
8395                 }
8396         }
8397 @@ -503,6 +508,8 @@ int proc_readdir_de(struct proc_dir_entr
8398  
8399                                 /* filldir passes info to user space */
8400                                 pde_get(de);
8401 +                               if (!vx_hide_check(0, de->vx_flags))
8402 +                                       goto skip;
8403                                 spin_unlock(&proc_subdir_lock);
8404                                 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8405                                             de->low_ino, de->mode >> 12) < 0) {
8406 @@ -510,6 +517,7 @@ int proc_readdir_de(struct proc_dir_entr
8407                                         goto out;
8408                                 }
8409                                 spin_lock(&proc_subdir_lock);
8410 +                       skip:
8411                                 filp->f_pos++;
8412                                 next = de->next;
8413                                 pde_put(de);
8414 @@ -624,6 +632,7 @@ static struct proc_dir_entry *__proc_cre
8415         ent->nlink = nlink;
8416         atomic_set(&ent->count, 1);
8417         ent->pde_users = 0;
8418 +       ent->vx_flags = IATTR_PROC_DEFAULT;
8419         spin_lock_init(&ent->pde_unload_lock);
8420         ent->pde_unload_completion = NULL;
8421         INIT_LIST_HEAD(&ent->pde_openers);
8422 @@ -647,7 +656,8 @@ struct proc_dir_entry *proc_symlink(cons
8423                                 kfree(ent->data);
8424                                 kfree(ent);
8425                                 ent = NULL;
8426 -                       }
8427 +                       } else
8428 +                               ent->vx_flags = IATTR_PROC_SYMLINK;
8429                 } else {
8430                         kfree(ent);
8431                         ent = NULL;
8432 diff -NurpP --minimal linux-2.6.35/fs/proc/inode.c linux-2.6.35-vs2.3.0.36.31/fs/proc/inode.c
8433 --- linux-2.6.35/fs/proc/inode.c        2010-08-02 16:52:51.000000000 +0200
8434 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/inode.c  2010-08-02 17:05:06.000000000 +0200
8435 @@ -437,6 +437,8 @@ struct inode *proc_get_inode(struct supe
8436                         inode->i_uid = de->uid;
8437                         inode->i_gid = de->gid;
8438                 }
8439 +               if (de->vx_flags)
8440 +                       PROC_I(inode)->vx_flags = de->vx_flags;
8441                 if (de->size)
8442                         inode->i_size = de->size;
8443                 if (de->nlink)
8444 diff -NurpP --minimal linux-2.6.35/fs/proc/internal.h linux-2.6.35-vs2.3.0.36.31/fs/proc/internal.h
8445 --- linux-2.6.35/fs/proc/internal.h     2010-02-25 11:52:06.000000000 +0100
8446 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/internal.h       2010-08-02 17:05:06.000000000 +0200
8447 @@ -10,6 +10,7 @@
8448   */
8449  
8450  #include <linux/proc_fs.h>
8451 +#include <linux/vs_pid.h>
8452  
8453  extern struct proc_dir_entry proc_root;
8454  #ifdef CONFIG_PROC_SYSCTL
8455 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
8456                                 struct pid *pid, struct task_struct *task);
8457  extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
8458                                 struct pid *pid, struct task_struct *task);
8459 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8460 +                               struct pid *pid, struct task_struct *task);
8461 +
8462  extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
8463  
8464  extern const struct file_operations proc_maps_operations;
8465 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
8466         return PROC_I(inode)->pid;
8467  }
8468  
8469 -static inline struct task_struct *get_proc_task(struct inode *inode)
8470 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
8471  {
8472         return get_pid_task(proc_pid(inode), PIDTYPE_PID);
8473  }
8474  
8475 +static inline struct task_struct *get_proc_task(struct inode *inode)
8476 +{
8477 +       return vx_get_proc_task(inode, proc_pid(inode));
8478 +}
8479 +
8480  static inline int proc_fd(struct inode *inode)
8481  {
8482         return PROC_I(inode)->fd;
8483 diff -NurpP --minimal linux-2.6.35/fs/proc/loadavg.c linux-2.6.35-vs2.3.0.36.31/fs/proc/loadavg.c
8484 --- linux-2.6.35/fs/proc/loadavg.c      2009-09-10 15:26:23.000000000 +0200
8485 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/loadavg.c        2010-08-02 17:05:06.000000000 +0200
8486 @@ -12,15 +12,27 @@
8487  
8488  static int loadavg_proc_show(struct seq_file *m, void *v)
8489  {
8490 +       unsigned long running;
8491 +       unsigned int threads;
8492         unsigned long avnrun[3];
8493  
8494         get_avenrun(avnrun, FIXED_1/200, 0);
8495  
8496 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
8497 +               struct vx_info *vxi = current_vx_info();
8498 +
8499 +               running = atomic_read(&vxi->cvirt.nr_running);
8500 +               threads = atomic_read(&vxi->cvirt.nr_threads);
8501 +       } else {
8502 +               running = nr_running();
8503 +               threads = nr_threads;
8504 +       }
8505 +
8506         seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
8507                 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
8508                 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
8509                 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
8510 -               nr_running(), nr_threads,
8511 +               running, threads,
8512                 task_active_pid_ns(current)->last_pid);
8513         return 0;
8514  }
8515 diff -NurpP --minimal linux-2.6.35/fs/proc/meminfo.c linux-2.6.35-vs2.3.0.36.31/fs/proc/meminfo.c
8516 --- linux-2.6.35/fs/proc/meminfo.c      2009-12-03 20:02:53.000000000 +0100
8517 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/meminfo.c        2010-08-02 17:05:06.000000000 +0200
8518 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
8519         allowed = ((totalram_pages - hugetlb_total_pages())
8520                 * sysctl_overcommit_ratio / 100) + total_swap_pages;
8521  
8522 -       cached = global_page_state(NR_FILE_PAGES) -
8523 +       cached = vx_flags(VXF_VIRT_MEM, 0) ?
8524 +               vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
8525                         total_swapcache_pages - i.bufferram;
8526         if (cached < 0)
8527                 cached = 0;
8528 diff -NurpP --minimal linux-2.6.35/fs/proc/root.c linux-2.6.35-vs2.3.0.36.31/fs/proc/root.c
8529 --- linux-2.6.35/fs/proc/root.c 2010-08-02 16:52:51.000000000 +0200
8530 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/root.c   2010-08-02 17:05:06.000000000 +0200
8531 @@ -18,9 +18,14 @@
8532  #include <linux/bitops.h>
8533  #include <linux/mount.h>
8534  #include <linux/pid_namespace.h>
8535 +#include <linux/vserver/inode.h>
8536  
8537  #include "internal.h"
8538  
8539 +struct proc_dir_entry *proc_virtual;
8540 +
8541 +extern void proc_vx_init(void);
8542 +
8543  static int proc_test_super(struct super_block *sb, void *data)
8544  {
8545         return sb->s_fs_info == data;
8546 @@ -135,6 +140,7 @@ void __init proc_root_init(void)
8547  #endif
8548         proc_mkdir("bus", NULL);
8549         proc_sys_init();
8550 +       proc_vx_init();
8551  }
8552  
8553  static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
8554 @@ -202,6 +208,7 @@ struct proc_dir_entry proc_root = {
8555         .proc_iops      = &proc_root_inode_operations, 
8556         .proc_fops      = &proc_root_operations,
8557         .parent         = &proc_root,
8558 +       .vx_flags       = IATTR_ADMIN | IATTR_WATCH,
8559  };
8560  
8561  int pid_ns_prepare_proc(struct pid_namespace *ns)
8562 diff -NurpP --minimal linux-2.6.35/fs/proc/uptime.c linux-2.6.35-vs2.3.0.36.31/fs/proc/uptime.c
8563 --- linux-2.6.35/fs/proc/uptime.c       2009-12-03 20:02:53.000000000 +0100
8564 +++ linux-2.6.35-vs2.3.0.36.31/fs/proc/uptime.c 2010-08-02 17:05:06.000000000 +0200
8565 @@ -4,22 +4,22 @@
8566  #include <linux/sched.h>
8567  #include <linux/seq_file.h>
8568  #include <linux/time.h>
8569 -#include <linux/kernel_stat.h>
8570 +#include <linux/vserver/cvirt.h>
8571  #include <asm/cputime.h>
8572  
8573  static int uptime_proc_show(struct seq_file *m, void *v)
8574  {
8575         struct timespec uptime;
8576         struct timespec idle;
8577 -       int i;
8578 -       cputime_t idletime = cputime_zero;
8579 -
8580 -       for_each_possible_cpu(i)
8581 -               idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
8582 +       cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
8583  
8584         do_posix_clock_monotonic_gettime(&uptime);
8585         monotonic_to_bootbased(&uptime);
8586         cputime_to_timespec(idletime, &idle);
8587 +
8588 +       if (vx_flags(VXF_VIRT_UPTIME, 0))
8589 +               vx_vsi_uptime(&uptime, &idle);
8590 +
8591         seq_printf(m, "%lu.%02lu %lu.%02lu\n",
8592                         (unsigned long) uptime.tv_sec,
8593                         (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
8594 diff -NurpP --minimal linux-2.6.35/fs/quota/dquot.c linux-2.6.35-vs2.3.0.36.31/fs/quota/dquot.c
8595 --- linux-2.6.35/fs/quota/dquot.c       2010-08-02 16:52:51.000000000 +0200
8596 +++ linux-2.6.35-vs2.3.0.36.31/fs/quota/dquot.c 2010-08-02 22:36:48.000000000 +0200
8597 @@ -1503,6 +1503,9 @@ int __dquot_alloc_space(struct inode *in
8598         int reserve = flags & DQUOT_SPACE_RESERVE;
8599         int nofail = flags & DQUOT_SPACE_NOFAIL;
8600  
8601 +       if ((ret = dl_alloc_space(inode, number)))
8602 +               return ret;
8603 +
8604         /*
8605          * First test before acquiring mutex - solves deadlocks when we
8606          * re-enter the quota code and are already holding the mutex
8607 @@ -1557,6 +1560,9 @@ int dquot_alloc_inode(const struct inode
8608         int cnt, ret = 0;
8609         char warntype[MAXQUOTAS];
8610  
8611 +       if ((ret = dl_alloc_inode(inode)))
8612 +               return ret;
8613 +
8614         /* First test before acquiring mutex - solves deadlocks when we
8615           * re-enter the quota code and are already holding the mutex */
8616         if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
8617 @@ -1627,6 +1633,8 @@ void __dquot_free_space(struct inode *in
8618         char warntype[MAXQUOTAS];
8619         int reserve = flags & DQUOT_SPACE_RESERVE;
8620  
8621 +       dl_free_space(inode, number);
8622 +
8623         /* First test before acquiring mutex - solves deadlocks when we
8624           * re-enter the quota code and are already holding the mutex */
8625         if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
8626 @@ -1665,6 +1673,8 @@ void dquot_free_inode(const struct inode
8627         unsigned int cnt;
8628         char warntype[MAXQUOTAS];
8629  
8630 +       dl_free_inode(inode);
8631 +
8632         /* First test before acquiring mutex - solves deadlocks when we
8633           * re-enter the quota code and are already holding the mutex */
8634         if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
8635 diff -NurpP --minimal linux-2.6.35/fs/quota/quota.c linux-2.6.35-vs2.3.0.36.31/fs/quota/quota.c
8636 --- linux-2.6.35/fs/quota/quota.c       2010-08-02 16:52:51.000000000 +0200
8637 +++ linux-2.6.35-vs2.3.0.36.31/fs/quota/quota.c 2010-08-02 17:05:06.000000000 +0200
8638 @@ -8,6 +8,7 @@
8639  #include <linux/fs.h>
8640  #include <linux/namei.h>
8641  #include <linux/slab.h>
8642 +#include <linux/vs_context.h>
8643  #include <asm/current.h>
8644  #include <asm/uaccess.h>
8645  #include <linux/kernel.h>
8646 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
8647                         break;
8648                 /*FALLTHROUGH*/
8649         default:
8650 -               if (!capable(CAP_SYS_ADMIN))
8651 +               if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8652                         return -EPERM;
8653         }
8654  
8655 @@ -296,6 +297,46 @@ static int do_quotactl(struct super_bloc
8656         }
8657  }
8658  
8659 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8660 +
8661 +#include <linux/vroot.h>
8662 +#include <linux/major.h>
8663 +#include <linux/module.h>
8664 +#include <linux/kallsyms.h>
8665 +#include <linux/vserver/debug.h>
8666 +
8667 +static vroot_grb_func *vroot_get_real_bdev = NULL;
8668 +
8669 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
8670 +
8671 +int register_vroot_grb(vroot_grb_func *func) {
8672 +       int ret = -EBUSY;
8673 +
8674 +       spin_lock(&vroot_grb_lock);
8675 +       if (!vroot_get_real_bdev) {
8676 +               vroot_get_real_bdev = func;
8677 +               ret = 0;
8678 +       }
8679 +       spin_unlock(&vroot_grb_lock);
8680 +       return ret;
8681 +}
8682 +EXPORT_SYMBOL(register_vroot_grb);
8683 +
8684 +int unregister_vroot_grb(vroot_grb_func *func) {
8685 +       int ret = -EINVAL;
8686 +
8687 +       spin_lock(&vroot_grb_lock);
8688 +       if (vroot_get_real_bdev) {
8689 +               vroot_get_real_bdev = NULL;
8690 +               ret = 0;
8691 +       }
8692 +       spin_unlock(&vroot_grb_lock);
8693 +       return ret;
8694 +}
8695 +EXPORT_SYMBOL(unregister_vroot_grb);
8696 +
8697 +#endif
8698 +
8699  /*
8700   * look up a superblock on which quota ops will be performed
8701   * - use the name of a block device to find the superblock thereon
8702 @@ -313,6 +354,22 @@ static struct super_block *quotactl_bloc
8703         putname(tmp);
8704         if (IS_ERR(bdev))
8705                 return ERR_CAST(bdev);
8706 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8707 +       if (bdev && bdev->bd_inode &&
8708 +                       imajor(bdev->bd_inode) == VROOT_MAJOR) {
8709 +               struct block_device *bdnew = (void *)-EINVAL;
8710 +
8711 +               if (vroot_get_real_bdev)
8712 +                       bdnew = vroot_get_real_bdev(bdev);
8713 +               else
8714 +                       vxdprintk(VXD_CBIT(misc, 0),
8715 +                                       "vroot_get_real_bdev not set");
8716 +               bdput(bdev);
8717 +               if (IS_ERR(bdnew))
8718 +                       return ERR_PTR(PTR_ERR(bdnew));
8719 +               bdev = bdnew;
8720 +       }
8721 +#endif
8722         sb = get_super(bdev);
8723         bdput(bdev);
8724         if (!sb)
8725 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/file.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/file.c
8726 --- linux-2.6.35/fs/reiserfs/file.c     2010-08-02 16:52:52.000000000 +0200
8727 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/file.c       2010-08-02 17:05:06.000000000 +0200
8728 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
8729         .listxattr = reiserfs_listxattr,
8730         .removexattr = reiserfs_removexattr,
8731         .permission = reiserfs_permission,
8732 +       .sync_flags = reiserfs_sync_flags,
8733  };
8734 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/inode.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/inode.c
8735 --- linux-2.6.35/fs/reiserfs/inode.c    2010-08-02 16:52:52.000000000 +0200
8736 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/inode.c      2010-08-02 17:05:06.000000000 +0200
8737 @@ -19,6 +19,7 @@
8738  #include <linux/writeback.h>
8739  #include <linux/quotaops.h>
8740  #include <linux/swap.h>
8741 +#include <linux/vs_tag.h>
8742  
8743  int reiserfs_commit_write(struct file *f, struct page *page,
8744                           unsigned from, unsigned to);
8745 @@ -1125,6 +1126,8 @@ static void init_inode(struct inode *ino
8746         struct buffer_head *bh;
8747         struct item_head *ih;
8748         __u32 rdev;
8749 +       uid_t uid;
8750 +       gid_t gid;
8751         //int version = ITEM_VERSION_1;
8752  
8753         bh = PATH_PLAST_BUFFER(path);
8754 @@ -1146,12 +1149,13 @@ static void init_inode(struct inode *ino
8755                     (struct stat_data_v1 *)B_I_PITEM(bh, ih);
8756                 unsigned long blocks;
8757  
8758 +               uid = sd_v1_uid(sd);
8759 +               gid = sd_v1_gid(sd);
8760 +
8761                 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
8762                 set_inode_sd_version(inode, STAT_DATA_V1);
8763                 inode->i_mode = sd_v1_mode(sd);
8764                 inode->i_nlink = sd_v1_nlink(sd);
8765 -               inode->i_uid = sd_v1_uid(sd);
8766 -               inode->i_gid = sd_v1_gid(sd);
8767                 inode->i_size = sd_v1_size(sd);
8768                 inode->i_atime.tv_sec = sd_v1_atime(sd);
8769                 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
8770 @@ -1193,11 +1197,12 @@ static void init_inode(struct inode *ino
8771                 // (directories and symlinks)
8772                 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
8773  
8774 +               uid    = sd_v2_uid(sd);
8775 +               gid    = sd_v2_gid(sd);
8776 +
8777                 inode->i_mode = sd_v2_mode(sd);
8778                 inode->i_nlink = sd_v2_nlink(sd);
8779 -               inode->i_uid = sd_v2_uid(sd);
8780                 inode->i_size = sd_v2_size(sd);
8781 -               inode->i_gid = sd_v2_gid(sd);
8782                 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
8783                 inode->i_atime.tv_sec = sd_v2_atime(sd);
8784                 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
8785 @@ -1227,6 +1232,10 @@ static void init_inode(struct inode *ino
8786                 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
8787         }
8788  
8789 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8790 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8791 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
8792 +
8793         pathrelse(path);
8794         if (S_ISREG(inode->i_mode)) {
8795                 inode->i_op = &reiserfs_file_inode_operations;
8796 @@ -1249,13 +1258,15 @@ static void init_inode(struct inode *ino
8797  static void inode2sd(void *sd, struct inode *inode, loff_t size)
8798  {
8799         struct stat_data *sd_v2 = (struct stat_data *)sd;
8800 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
8801 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
8802         __u16 flags;
8803  
8804 +       set_sd_v2_uid(sd_v2, uid);
8805 +       set_sd_v2_gid(sd_v2, gid);
8806         set_sd_v2_mode(sd_v2, inode->i_mode);
8807         set_sd_v2_nlink(sd_v2, inode->i_nlink);
8808 -       set_sd_v2_uid(sd_v2, inode->i_uid);
8809         set_sd_v2_size(sd_v2, size);
8810 -       set_sd_v2_gid(sd_v2, inode->i_gid);
8811         set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
8812         set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
8813         set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
8814 @@ -2856,14 +2867,19 @@ int reiserfs_commit_write(struct file *f
8815  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
8816  {
8817         if (reiserfs_attrs(inode->i_sb)) {
8818 -               if (sd_attrs & REISERFS_SYNC_FL)
8819 -                       inode->i_flags |= S_SYNC;
8820 -               else
8821 -                       inode->i_flags &= ~S_SYNC;
8822                 if (sd_attrs & REISERFS_IMMUTABLE_FL)
8823                         inode->i_flags |= S_IMMUTABLE;
8824                 else
8825                         inode->i_flags &= ~S_IMMUTABLE;
8826 +               if (sd_attrs & REISERFS_IXUNLINK_FL)
8827 +                       inode->i_flags |= S_IXUNLINK;
8828 +               else
8829 +                       inode->i_flags &= ~S_IXUNLINK;
8830 +
8831 +               if (sd_attrs & REISERFS_SYNC_FL)
8832 +                       inode->i_flags |= S_SYNC;
8833 +               else
8834 +                       inode->i_flags &= ~S_SYNC;
8835                 if (sd_attrs & REISERFS_APPEND_FL)
8836                         inode->i_flags |= S_APPEND;
8837                 else
8838 @@ -2876,6 +2892,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
8839                         REISERFS_I(inode)->i_flags |= i_nopack_mask;
8840                 else
8841                         REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
8842 +
8843 +               if (sd_attrs & REISERFS_BARRIER_FL)
8844 +                       inode->i_vflags |= V_BARRIER;
8845 +               else
8846 +                       inode->i_vflags &= ~V_BARRIER;
8847 +               if (sd_attrs & REISERFS_COW_FL)
8848 +                       inode->i_vflags |= V_COW;
8849 +               else
8850 +                       inode->i_vflags &= ~V_COW;
8851         }
8852  }
8853  
8854 @@ -2886,6 +2911,11 @@ void i_attrs_to_sd_attrs(struct inode *i
8855                         *sd_attrs |= REISERFS_IMMUTABLE_FL;
8856                 else
8857                         *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
8858 +               if (inode->i_flags & S_IXUNLINK)
8859 +                       *sd_attrs |= REISERFS_IXUNLINK_FL;
8860 +               else
8861 +                       *sd_attrs &= ~REISERFS_IXUNLINK_FL;
8862 +
8863                 if (inode->i_flags & S_SYNC)
8864                         *sd_attrs |= REISERFS_SYNC_FL;
8865                 else
8866 @@ -2898,6 +2928,15 @@ void i_attrs_to_sd_attrs(struct inode *i
8867                         *sd_attrs |= REISERFS_NOTAIL_FL;
8868                 else
8869                         *sd_attrs &= ~REISERFS_NOTAIL_FL;
8870 +
8871 +               if (inode->i_vflags & V_BARRIER)
8872 +                       *sd_attrs |= REISERFS_BARRIER_FL;
8873 +               else
8874 +                       *sd_attrs &= ~REISERFS_BARRIER_FL;
8875 +               if (inode->i_vflags & V_COW)
8876 +                       *sd_attrs |= REISERFS_COW_FL;
8877 +               else
8878 +                       *sd_attrs &= ~REISERFS_COW_FL;
8879         }
8880  }
8881  
8882 @@ -3122,9 +3161,11 @@ int reiserfs_setattr(struct dentry *dent
8883         }
8884  
8885         error = inode_change_ok(inode, attr);
8886 +
8887         if (!error) {
8888                 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
8889 -                   (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
8890 +                   (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
8891 +                   (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
8892                         error = reiserfs_chown_xattrs(inode, attr);
8893  
8894                         if (!error) {
8895 @@ -3153,6 +3194,9 @@ int reiserfs_setattr(struct dentry *dent
8896                                         inode->i_uid = attr->ia_uid;
8897                                 if (attr->ia_valid & ATTR_GID)
8898                                         inode->i_gid = attr->ia_gid;
8899 +                               if ((attr->ia_valid & ATTR_TAG) &&
8900 +                                       IS_TAGGED(inode))
8901 +                                       inode->i_tag = attr->ia_tag;
8902                                 mark_inode_dirty(inode);
8903                                 error =
8904                                     journal_end(&th, inode->i_sb, jbegin_count);
8905 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/ioctl.c
8906 --- linux-2.6.35/fs/reiserfs/ioctl.c    2010-02-25 11:52:06.000000000 +0100
8907 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/ioctl.c      2010-08-02 17:05:06.000000000 +0200
8908 @@ -7,11 +7,27 @@
8909  #include <linux/mount.h>
8910  #include <linux/reiserfs_fs.h>
8911  #include <linux/time.h>
8912 +#include <linux/mount.h>
8913  #include <asm/uaccess.h>
8914  #include <linux/pagemap.h>
8915  #include <linux/smp_lock.h>
8916  #include <linux/compat.h>
8917  
8918 +
8919 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
8920 +{
8921 +       __u16 sd_attrs = 0;
8922 +
8923 +       inode->i_flags = flags;
8924 +       inode->i_vflags = vflags;
8925 +
8926 +       i_attrs_to_sd_attrs(inode, &sd_attrs);
8927 +       REISERFS_I(inode)->i_attrs = sd_attrs;
8928 +       inode->i_ctime = CURRENT_TIME_SEC;
8929 +       mark_inode_dirty(inode);
8930 +       return 0;
8931 +}
8932 +
8933  /*
8934   * reiserfs_ioctl - handler for ioctl for inode
8935   * supported commands:
8936 @@ -23,7 +39,7 @@
8937  long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
8938  {
8939         struct inode *inode = filp->f_path.dentry->d_inode;
8940 -       unsigned int flags;
8941 +       unsigned int flags, oldflags;
8942         int err = 0;
8943  
8944         reiserfs_write_lock(inode->i_sb);
8945 @@ -48,6 +64,7 @@ long reiserfs_ioctl(struct file *filp, u
8946  
8947                 flags = REISERFS_I(inode)->i_attrs;
8948                 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
8949 +               flags &= REISERFS_FL_USER_VISIBLE;
8950                 err = put_user(flags, (int __user *)arg);
8951                 break;
8952         case REISERFS_IOC_SETFLAGS:{
8953 @@ -68,6 +85,10 @@ long reiserfs_ioctl(struct file *filp, u
8954                                 err = -EFAULT;
8955                                 goto setflags_out;
8956                         }
8957 +                       if (IS_BARRIER(inode)) {
8958 +                               vxwprintk_task(1, "messing with the barrier.");
8959 +                               return -EACCES;
8960 +                       }
8961                         /*
8962                          * Is it quota file? Do not allow user to mess with it
8963                          */
8964 @@ -92,6 +113,10 @@ long reiserfs_ioctl(struct file *filp, u
8965                                         goto setflags_out;
8966                                 }
8967                         }
8968 +
8969 +                       oldflags = REISERFS_I(inode)->i_attrs;
8970 +                       flags &= REISERFS_FL_USER_MODIFIABLE;
8971 +                       flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
8972                         sd_attrs_to_i_attrs(flags, inode);
8973                         REISERFS_I(inode)->i_attrs = flags;
8974                         inode->i_ctime = CURRENT_TIME_SEC;
8975 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/namei.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/namei.c
8976 --- linux-2.6.35/fs/reiserfs/namei.c    2010-08-02 16:52:52.000000000 +0200
8977 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/namei.c      2010-08-02 17:05:06.000000000 +0200
8978 @@ -18,6 +18,7 @@
8979  #include <linux/reiserfs_acl.h>
8980  #include <linux/reiserfs_xattr.h>
8981  #include <linux/quotaops.h>
8982 +#include <linux/vs_tag.h>
8983  
8984  #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
8985  #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
8986 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
8987         if (retval == IO_ERROR) {
8988                 return ERR_PTR(-EIO);
8989         }
8990 +               dx_propagate_tag(nd, inode);
8991  
8992         return d_splice_alias(inode, dentry);
8993  }
8994 @@ -1532,6 +1534,7 @@ const struct inode_operations reiserfs_d
8995         .listxattr = reiserfs_listxattr,
8996         .removexattr = reiserfs_removexattr,
8997         .permission = reiserfs_permission,
8998 +       .sync_flags = reiserfs_sync_flags,
8999  };
9000  
9001  /*
9002 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/super.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/super.c
9003 --- linux-2.6.35/fs/reiserfs/super.c    2010-08-02 16:52:52.000000000 +0200
9004 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/super.c      2010-08-02 17:05:06.000000000 +0200
9005 @@ -897,6 +897,14 @@ static int reiserfs_parse_options(struct
9006                 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9007                 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9008  #endif
9009 +#ifndef CONFIG_TAGGING_NONE
9010 +               {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9011 +               {"tag",.setmask = 1 << REISERFS_TAGGED},
9012 +               {"notag",.clrmask = 1 << REISERFS_TAGGED},
9013 +#endif
9014 +#ifdef CONFIG_PROPAGATE
9015 +               {"tag",.arg_required = 'T',.values = NULL},
9016 +#endif
9017  #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9018                 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9019                 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9020 @@ -1206,6 +1214,14 @@ static int reiserfs_remount(struct super
9021         handle_quota_files(s, qf_names, &qfmt);
9022  #endif
9023  
9024 +       if ((mount_options & (1 << REISERFS_TAGGED)) &&
9025 +               !(s->s_flags & MS_TAGGED)) {
9026 +               reiserfs_warning(s, "super-vs01",
9027 +                       "reiserfs: tagging not permitted on remount.");
9028 +               err = -EINVAL;
9029 +               goto out_err;
9030 +       }
9031 +
9032         handle_attrs(s);
9033  
9034         /* Add options that are safe here */
9035 @@ -1688,6 +1704,10 @@ static int reiserfs_fill_super(struct su
9036                 goto error;
9037         }
9038  
9039 +       /* map mount option tagxid */
9040 +       if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9041 +               s->s_flags |= MS_TAGGED;
9042 +
9043         rs = SB_DISK_SUPER_BLOCK(s);
9044         /* Let's do basic sanity check to verify that underlying device is not
9045            smaller than the filesystem. If the check fails then abort and scream,
9046 diff -NurpP --minimal linux-2.6.35/fs/reiserfs/xattr.c linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/xattr.c
9047 --- linux-2.6.35/fs/reiserfs/xattr.c    2010-08-02 16:52:52.000000000 +0200
9048 +++ linux-2.6.35-vs2.3.0.36.31/fs/reiserfs/xattr.c      2010-08-02 17:05:06.000000000 +0200
9049 @@ -40,6 +40,7 @@
9050  #include <linux/errno.h>
9051  #include <linux/gfp.h>
9052  #include <linux/fs.h>
9053 +#include <linux/mount.h>
9054  #include <linux/file.h>
9055  #include <linux/pagemap.h>
9056  #include <linux/xattr.h>
9057 diff -NurpP --minimal linux-2.6.35/fs/stat.c linux-2.6.35-vs2.3.0.36.31/fs/stat.c
9058 --- linux-2.6.35/fs/stat.c      2010-02-25 11:52:06.000000000 +0100
9059 +++ linux-2.6.35-vs2.3.0.36.31/fs/stat.c        2010-08-02 17:05:06.000000000 +0200
9060 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9061         stat->nlink = inode->i_nlink;
9062         stat->uid = inode->i_uid;
9063         stat->gid = inode->i_gid;
9064 +       stat->tag = inode->i_tag;
9065         stat->rdev = inode->i_rdev;
9066         stat->atime = inode->i_atime;
9067         stat->mtime = inode->i_mtime;
9068 diff -NurpP --minimal linux-2.6.35/fs/statfs.c linux-2.6.35-vs2.3.0.36.31/fs/statfs.c
9069 --- linux-2.6.35/fs/statfs.c    2010-08-02 16:52:52.000000000 +0200
9070 +++ linux-2.6.35-vs2.3.0.36.31/fs/statfs.c      2010-08-02 19:10:27.000000000 +0200
9071 @@ -6,22 +6,28 @@
9072  #include <linux/statfs.h>
9073  #include <linux/security.h>
9074  #include <linux/uaccess.h>
9075 +#include <linux/vs_base.h>
9076 +#include <linux/vs_dlimit.h>
9077  
9078  int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
9079  {
9080         int retval = -ENODEV;
9081  
9082         if (dentry) {
9083 +               struct super_block *sb = dentry->d_sb;
9084 +
9085                 retval = -ENOSYS;
9086 -               if (dentry->d_sb->s_op->statfs) {
9087 +               if (sb->s_op->statfs) {
9088                         memset(buf, 0, sizeof(*buf));
9089                         retval = security_sb_statfs(dentry);
9090                         if (retval)
9091                                 return retval;
9092 -                       retval = dentry->d_sb->s_op->statfs(dentry, buf);
9093 +                       retval = sb->s_op->statfs(dentry, buf);
9094                         if (retval == 0 && buf->f_frsize == 0)
9095                                 buf->f_frsize = buf->f_bsize;
9096                 }
9097 +               if (!vx_check(0, VS_ADMIN|VS_WATCH))
9098 +                       vx_vsi_statfs(sb, buf);
9099         }
9100         return retval;
9101  }
9102 diff -NurpP --minimal linux-2.6.35/fs/super.c linux-2.6.35-vs2.3.0.36.31/fs/super.c
9103 --- linux-2.6.35/fs/super.c     2010-08-02 16:52:52.000000000 +0200
9104 +++ linux-2.6.35-vs2.3.0.36.31/fs/super.c       2010-08-02 17:59:27.000000000 +0200
9105 @@ -30,6 +30,9 @@
9106  #include <linux/idr.h>
9107  #include <linux/mutex.h>
9108  #include <linux/backing-dev.h>
9109 +#include <linux/devpts_fs.h>
9110 +#include <linux/proc_fs.h>
9111 +#include <linux/vs_context.h>
9112  #include "internal.h"
9113  
9114  
9115 @@ -880,12 +883,18 @@ struct vfsmount *
9116  vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9117  {
9118         struct vfsmount *mnt;
9119 +       struct super_block *sb;
9120         char *secdata = NULL;
9121         int error;
9122  
9123         if (!type)
9124                 return ERR_PTR(-ENODEV);
9125  
9126 +       error = -EPERM;
9127 +       if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9128 +               !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9129 +               goto out;
9130 +
9131         error = -ENOMEM;
9132         mnt = alloc_vfsmnt(name);
9133         if (!mnt)
9134 @@ -907,10 +916,18 @@ vfs_kern_mount(struct file_system_type *
9135         error = type->get_sb(type, flags, name, data, mnt);
9136         if (error < 0)
9137                 goto out_free_secdata;
9138 -       BUG_ON(!mnt->mnt_sb);
9139 -       WARN_ON(!mnt->mnt_sb->s_bdi);
9140  
9141 -       error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
9142 +       sb = mnt->mnt_sb;
9143 +       BUG_ON(!sb);
9144 +       WARN_ON(!sb->s_bdi);
9145 +
9146 +       error = -EPERM;
9147 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9148 +               (sb->s_magic != PROC_SUPER_MAGIC) &&
9149 +               (sb->s_magic != DEVPTS_SUPER_MAGIC))
9150 +               goto out_sb;
9151 +
9152 +       error = security_sb_kern_mount(sb, flags, secdata);
9153         if (error)
9154                 goto out_sb;
9155  
9156 diff -NurpP --minimal linux-2.6.35/fs/sysfs/mount.c linux-2.6.35-vs2.3.0.36.31/fs/sysfs/mount.c
9157 --- linux-2.6.35/fs/sysfs/mount.c       2010-08-02 16:52:52.000000000 +0200
9158 +++ linux-2.6.35-vs2.3.0.36.31/fs/sysfs/mount.c 2010-08-02 17:05:06.000000000 +0200
9159 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
9160  
9161         sb->s_blocksize = PAGE_CACHE_SIZE;
9162         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9163 -       sb->s_magic = SYSFS_MAGIC;
9164 +       sb->s_magic = SYSFS_SUPER_MAGIC;
9165         sb->s_op = &sysfs_ops;
9166         sb->s_time_gran = 1;
9167  
9168 diff -NurpP --minimal linux-2.6.35/fs/utimes.c linux-2.6.35-vs2.3.0.36.31/fs/utimes.c
9169 --- linux-2.6.35/fs/utimes.c    2009-03-24 14:22:37.000000000 +0100
9170 +++ linux-2.6.35-vs2.3.0.36.31/fs/utimes.c      2010-08-02 22:52:28.000000000 +0200
9171 @@ -8,6 +8,8 @@
9172  #include <linux/stat.h>
9173  #include <linux/utime.h>
9174  #include <linux/syscalls.h>
9175 +#include <linux/mount.h>
9176 +#include <linux/vs_cowbl.h>
9177  #include <asm/uaccess.h>
9178  #include <asm/unistd.h>
9179  
9180 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
9181  {
9182         int error;
9183         struct iattr newattrs;
9184 -       struct inode *inode = path->dentry->d_inode;
9185 +       struct inode *inode;
9186  
9187         error = mnt_want_write(path->mnt);
9188         if (error)
9189                 goto out;
9190  
9191 +       error = cow_check_and_break(path);
9192 +       if (error)
9193 +               goto mnt_drop_write_and_out;
9194 +
9195 +       inode = path->dentry->d_inode;
9196 +
9197         if (times && times[0].tv_nsec == UTIME_NOW &&
9198                      times[1].tv_nsec == UTIME_NOW)
9199                 times = NULL;
9200 diff -NurpP --minimal linux-2.6.35/fs/xattr.c linux-2.6.35-vs2.3.0.36.31/fs/xattr.c
9201 --- linux-2.6.35/fs/xattr.c     2010-08-02 16:52:52.000000000 +0200
9202 +++ linux-2.6.35-vs2.3.0.36.31/fs/xattr.c       2010-08-02 17:05:06.000000000 +0200
9203 @@ -18,6 +18,7 @@
9204  #include <linux/module.h>
9205  #include <linux/fsnotify.h>
9206  #include <linux/audit.h>
9207 +#include <linux/mount.h>
9208  #include <asm/uaccess.h>
9209  
9210  
9211 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
9212          * The trusted.* namespace can only be accessed by a privileged user.
9213          */
9214         if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
9215 -               return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
9216 +               return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
9217  
9218         /* In user.* namespace, only regular files and directories can have
9219          * extended attributes. For sticky directories, only the owner and
9220 diff -NurpP --minimal linux-2.6.35/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.c
9221 --- linux-2.6.35/fs/xfs/linux-2.6/xfs_ioctl.c   2010-08-02 16:52:52.000000000 +0200
9222 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.c     2010-08-02 17:05:06.000000000 +0200
9223 @@ -34,7 +34,6 @@
9224  #include "xfs_dir2_sf.h"
9225  #include "xfs_dinode.h"
9226  #include "xfs_inode.h"
9227 -#include "xfs_ioctl.h"
9228  #include "xfs_btree.h"
9229  #include "xfs_ialloc.h"
9230  #include "xfs_rtalloc.h"
9231 @@ -747,6 +746,10 @@ xfs_merge_ioc_xflags(
9232                 xflags |= XFS_XFLAG_IMMUTABLE;
9233         else
9234                 xflags &= ~XFS_XFLAG_IMMUTABLE;
9235 +       if (flags & FS_IXUNLINK_FL)
9236 +               xflags |= XFS_XFLAG_IXUNLINK;
9237 +       else
9238 +               xflags &= ~XFS_XFLAG_IXUNLINK;
9239         if (flags & FS_APPEND_FL)
9240                 xflags |= XFS_XFLAG_APPEND;
9241         else
9242 @@ -775,6 +778,8 @@ xfs_di2lxflags(
9243  
9244         if (di_flags & XFS_DIFLAG_IMMUTABLE)
9245                 flags |= FS_IMMUTABLE_FL;
9246 +       if (di_flags & XFS_DIFLAG_IXUNLINK)
9247 +               flags |= FS_IXUNLINK_FL;
9248         if (di_flags & XFS_DIFLAG_APPEND)
9249                 flags |= FS_APPEND_FL;
9250         if (di_flags & XFS_DIFLAG_SYNC)
9251 @@ -833,6 +838,8 @@ xfs_set_diflags(
9252         di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
9253         if (xflags & XFS_XFLAG_IMMUTABLE)
9254                 di_flags |= XFS_DIFLAG_IMMUTABLE;
9255 +       if (xflags & XFS_XFLAG_IXUNLINK)
9256 +               di_flags |= XFS_DIFLAG_IXUNLINK;
9257         if (xflags & XFS_XFLAG_APPEND)
9258                 di_flags |= XFS_DIFLAG_APPEND;
9259         if (xflags & XFS_XFLAG_SYNC)
9260 @@ -875,6 +882,10 @@ xfs_diflags_to_linux(
9261                 inode->i_flags |= S_IMMUTABLE;
9262         else
9263                 inode->i_flags &= ~S_IMMUTABLE;
9264 +       if (xflags & XFS_XFLAG_IXUNLINK)
9265 +               inode->i_flags |= S_IXUNLINK;
9266 +       else
9267 +               inode->i_flags &= ~S_IXUNLINK;
9268         if (xflags & XFS_XFLAG_APPEND)
9269                 inode->i_flags |= S_APPEND;
9270         else
9271 @@ -1351,10 +1362,18 @@ xfs_file_ioctl(
9272         case XFS_IOC_FSGETXATTRA:
9273                 return xfs_ioc_fsgetxattr(ip, 1, arg);
9274         case XFS_IOC_FSSETXATTR:
9275 +               if (IS_BARRIER(inode)) {
9276 +                       vxwprintk_task(1, "messing with the barrier.");
9277 +                       return -XFS_ERROR(EACCES);
9278 +               }
9279                 return xfs_ioc_fssetxattr(ip, filp, arg);
9280         case XFS_IOC_GETXFLAGS:
9281                 return xfs_ioc_getxflags(ip, arg);
9282         case XFS_IOC_SETXFLAGS:
9283 +               if (IS_BARRIER(inode)) {
9284 +                       vxwprintk_task(1, "messing with the barrier.");
9285 +                       return -XFS_ERROR(EACCES);
9286 +               }
9287                 return xfs_ioc_setxflags(ip, filp, arg);
9288  
9289         case XFS_IOC_FSSETDM: {
9290 diff -NurpP --minimal linux-2.6.35/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.h
9291 --- linux-2.6.35/fs/xfs/linux-2.6/xfs_ioctl.h   2010-07-07 18:31:54.000000000 +0200
9292 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.h     2010-08-02 17:05:06.000000000 +0200
9293 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
9294         void __user             *uhandle,
9295         u32                     hlen);
9296  
9297 +extern int
9298 +xfs_sync_flags(
9299 +       struct inode            *inode,
9300 +       int                     flags,
9301 +       int                     vflags);
9302 +
9303  extern long
9304  xfs_file_ioctl(
9305         struct file             *filp,
9306 diff -NurpP --minimal linux-2.6.35/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_iops.c
9307 --- linux-2.6.35/fs/xfs/linux-2.6/xfs_iops.c    2010-08-02 16:52:52.000000000 +0200
9308 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_iops.c      2010-08-02 17:05:06.000000000 +0200
9309 @@ -36,6 +36,7 @@
9310  #include "xfs_attr_sf.h"
9311  #include "xfs_dinode.h"
9312  #include "xfs_inode.h"
9313 +#include "xfs_ioctl.h"
9314  #include "xfs_bmap.h"
9315  #include "xfs_btree.h"
9316  #include "xfs_ialloc.h"
9317 @@ -57,6 +58,7 @@
9318  #include <linux/falloc.h>
9319  #include <linux/fiemap.h>
9320  #include <linux/slab.h>
9321 +#include <linux/vs_tag.h>
9322  
9323  /*
9324   * Bring the timestamps in the XFS inode uptodate.
9325 @@ -507,6 +509,7 @@ xfs_vn_getattr(
9326         stat->nlink = ip->i_d.di_nlink;
9327         stat->uid = ip->i_d.di_uid;
9328         stat->gid = ip->i_d.di_gid;
9329 +       stat->tag = ip->i_d.di_tag;
9330         stat->ino = ip->i_ino;
9331         stat->atime = inode->i_atime;
9332         stat->mtime = inode->i_mtime;
9333 @@ -711,6 +714,7 @@ static const struct inode_operations xfs
9334         .listxattr              = xfs_vn_listxattr,
9335         .fallocate              = xfs_vn_fallocate,
9336         .fiemap                 = xfs_vn_fiemap,
9337 +       .sync_flags             = xfs_sync_flags,
9338  };
9339  
9340  static const struct inode_operations xfs_dir_inode_operations = {
9341 @@ -736,6 +740,7 @@ static const struct inode_operations xfs
9342         .getxattr               = generic_getxattr,
9343         .removexattr            = generic_removexattr,
9344         .listxattr              = xfs_vn_listxattr,
9345 +       .sync_flags             = xfs_sync_flags,
9346  };
9347  
9348  static const struct inode_operations xfs_dir_ci_inode_operations = {
9349 @@ -785,6 +790,10 @@ xfs_diflags_to_iflags(
9350                 inode->i_flags |= S_IMMUTABLE;
9351         else
9352                 inode->i_flags &= ~S_IMMUTABLE;
9353 +       if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
9354 +               inode->i_flags |= S_IXUNLINK;
9355 +       else
9356 +               inode->i_flags &= ~S_IXUNLINK;
9357         if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
9358                 inode->i_flags |= S_APPEND;
9359         else
9360 @@ -797,6 +806,15 @@ xfs_diflags_to_iflags(
9361                 inode->i_flags |= S_NOATIME;
9362         else
9363                 inode->i_flags &= ~S_NOATIME;
9364 +
9365 +       if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
9366 +               inode->i_vflags |= V_BARRIER;
9367 +       else
9368 +               inode->i_vflags &= ~V_BARRIER;
9369 +       if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
9370 +               inode->i_vflags |= V_COW;
9371 +       else
9372 +               inode->i_vflags &= ~V_COW;
9373  }
9374  
9375  /*
9376 @@ -825,6 +843,7 @@ xfs_setup_inode(
9377         inode->i_nlink  = ip->i_d.di_nlink;
9378         inode->i_uid    = ip->i_d.di_uid;
9379         inode->i_gid    = ip->i_d.di_gid;
9380 +       inode->i_tag    = ip->i_d.di_tag;
9381  
9382         switch (inode->i_mode & S_IFMT) {
9383         case S_IFBLK:
9384 diff -NurpP --minimal linux-2.6.35/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_linux.h
9385 --- linux-2.6.35/fs/xfs/linux-2.6/xfs_linux.h   2010-07-07 18:31:54.000000000 +0200
9386 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_linux.h     2010-08-02 17:05:06.000000000 +0200
9387 @@ -117,6 +117,7 @@
9388  
9389  #define current_cpu()          (raw_smp_processor_id())
9390  #define current_pid()          (current->pid)
9391 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
9392  #define current_test_flags(f)  (current->flags & (f))
9393  #define current_set_flags_nested(sp, f)                \
9394                 (*(sp) = current->flags, current->flags |= (f))
9395 diff -NurpP --minimal linux-2.6.35/fs/xfs/linux-2.6/xfs_super.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_super.c
9396 --- linux-2.6.35/fs/xfs/linux-2.6/xfs_super.c   2010-08-02 16:52:52.000000000 +0200
9397 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_super.c     2010-08-02 18:00:35.000000000 +0200
9398 @@ -121,6 +121,9 @@ mempool_t *xfs_ioend_pool;
9399  #define MNTOPT_DMI     "dmi"           /* DMI enabled (DMAPI / XDSM) */
9400  #define MNTOPT_DELAYLOG   "delaylog"   /* Delayed loging enabled */
9401  #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed loging disabled */
9402 +#define MNTOPT_TAGXID  "tagxid"        /* context tagging for inodes */
9403 +#define MNTOPT_TAGGED  "tag"           /* context tagging for inodes */
9404 +#define MNTOPT_NOTAGTAG        "notag"         /* do not use context tagging */
9405  
9406  /*
9407   * Table driven mount option parser.
9408 @@ -129,10 +132,14 @@ mempool_t *xfs_ioend_pool;
9409   * in the future, too.
9410   */
9411  enum {
9412 +       Opt_tag, Opt_notag,
9413         Opt_barrier, Opt_nobarrier, Opt_err
9414  };
9415  
9416  static const match_table_t tokens = {
9417 +       {Opt_tag, "tagxid"},
9418 +       {Opt_tag, "tag"},
9419 +       {Opt_notag, "notag"},
9420         {Opt_barrier, "barrier"},
9421         {Opt_nobarrier, "nobarrier"},
9422         {Opt_err, NULL}
9423 @@ -393,6 +400,19 @@ xfs_parseargs(
9424                 } else if (!strcmp(this_char, "irixsgid")) {
9425                         cmn_err(CE_WARN,
9426         "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
9427 +#ifndef CONFIG_TAGGING_NONE
9428 +               } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9429 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9430 +               } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
9431 +                       mp->m_flags &= ~XFS_MOUNT_TAGGED;
9432 +               } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
9433 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9434 +#endif
9435 +#ifdef CONFIG_PROPAGATE
9436 +               } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9437 +                       /* use value */
9438 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9439 +#endif
9440                 } else {
9441                         cmn_err(CE_WARN,
9442                                 "XFS: unknown mount option [%s].", this_char);
9443 @@ -1376,6 +1396,16 @@ xfs_fs_remount(
9444                 case Opt_nobarrier:
9445                         mp->m_flags &= ~XFS_MOUNT_BARRIER;
9446                         break;
9447 +               case Opt_tag:
9448 +                       if (!(sb->s_flags & MS_TAGGED)) {
9449 +                               printk(KERN_INFO
9450 +                                       "XFS: %s: tagging not permitted on remount.\n",
9451 +                                       sb->s_id);
9452 +                               return -EINVAL;
9453 +                       }
9454 +                       break;
9455 +               case Opt_notag:
9456 +                       break;
9457                 default:
9458                         /*
9459                          * Logically we would return an error here to prevent
9460 @@ -1610,6 +1640,9 @@ xfs_fs_fill_super(
9461  
9462         XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
9463  
9464 +       if (mp->m_flags & XFS_MOUNT_TAGGED)
9465 +               sb->s_flags |= MS_TAGGED;
9466 +
9467         sb->s_magic = XFS_SB_MAGIC;
9468         sb->s_blocksize = mp->m_sb.sb_blocksize;
9469         sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
9470 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_dinode.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_dinode.h
9471 --- linux-2.6.35/fs/xfs/xfs_dinode.h    2009-06-11 17:13:09.000000000 +0200
9472 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_dinode.h      2010-08-02 17:05:06.000000000 +0200
9473 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
9474         __be32          di_gid;         /* owner's group id */
9475         __be32          di_nlink;       /* number of links to file */
9476         __be16          di_projid;      /* owner's project id */
9477 -       __u8            di_pad[8];      /* unused, zeroed space */
9478 +       __be16          di_tag;         /* context tagging */
9479 +       __be16          di_vflags;      /* vserver specific flags */
9480 +       __u8            di_pad[4];      /* unused, zeroed space */
9481         __be16          di_flushiter;   /* incremented on flush */
9482         xfs_timestamp_t di_atime;       /* time last accessed */
9483         xfs_timestamp_t di_mtime;       /* time last modified */
9484 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
9485  #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
9486  #define XFS_DIFLAG_NODEFRAG_BIT     13 /* do not reorganize/defragment */
9487  #define XFS_DIFLAG_FILESTREAM_BIT   14  /* use filestream allocator */
9488 +#define XFS_DIFLAG_IXUNLINK_BIT     15 /* Immutable inver on unlink */
9489 +
9490  #define XFS_DIFLAG_REALTIME      (1 << XFS_DIFLAG_REALTIME_BIT)
9491  #define XFS_DIFLAG_PREALLOC      (1 << XFS_DIFLAG_PREALLOC_BIT)
9492  #define XFS_DIFLAG_NEWRTBM       (1 << XFS_DIFLAG_NEWRTBM_BIT)
9493 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
9494  #define XFS_DIFLAG_EXTSZINHERIT  (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
9495  #define XFS_DIFLAG_NODEFRAG      (1 << XFS_DIFLAG_NODEFRAG_BIT)
9496  #define XFS_DIFLAG_FILESTREAM    (1 << XFS_DIFLAG_FILESTREAM_BIT)
9497 +#define XFS_DIFLAG_IXUNLINK      (1 << XFS_DIFLAG_IXUNLINK_BIT)
9498  
9499  #ifdef CONFIG_XFS_RT
9500  #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
9501 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
9502          XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
9503          XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
9504          XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
9505 -        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
9506 +        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
9507 +        XFS_DIFLAG_IXUNLINK)
9508 +
9509 +#define XFS_DIVFLAG_BARRIER    0x01
9510 +#define XFS_DIVFLAG_COW                0x02
9511  
9512  #endif /* __XFS_DINODE_H__ */
9513 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_fs.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_fs.h
9514 --- linux-2.6.35/fs/xfs/xfs_fs.h        2010-07-07 18:31:54.000000000 +0200
9515 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_fs.h  2010-08-02 17:05:06.000000000 +0200
9516 @@ -67,6 +67,9 @@ struct fsxattr {
9517  #define XFS_XFLAG_EXTSZINHERIT 0x00001000      /* inherit inode extent size */
9518  #define XFS_XFLAG_NODEFRAG     0x00002000      /* do not defragment */
9519  #define XFS_XFLAG_FILESTREAM   0x00004000      /* use filestream allocator */
9520 +#define XFS_XFLAG_IXUNLINK     0x00008000      /* immutable invert on unlink */
9521 +#define XFS_XFLAG_BARRIER      0x10000000      /* chroot() barrier */
9522 +#define XFS_XFLAG_COW          0x20000000      /* copy on write mark */
9523  #define XFS_XFLAG_HASATTR      0x80000000      /* no DIFLAG for this   */
9524  
9525  /*
9526 @@ -293,7 +296,8 @@ typedef struct xfs_bstat {
9527         __u32           bs_gen;         /* generation count             */
9528         __u16           bs_projid;      /* project id                   */
9529         __u16           bs_forkoff;     /* inode fork offset in bytes   */
9530 -       unsigned char   bs_pad[12];     /* pad space, unused            */
9531 +       __u16           bs_tag;         /* context tagging              */
9532 +       unsigned char   bs_pad[10];     /* pad space, unused            */
9533         __u32           bs_dmevmask;    /* DMIG event mask              */
9534         __u16           bs_dmstate;     /* DMIG state info              */
9535         __u16           bs_aextents;    /* attribute number of extents  */
9536 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_ialloc.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_ialloc.c
9537 --- linux-2.6.35/fs/xfs/xfs_ialloc.c    2010-08-02 16:52:53.000000000 +0200
9538 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_ialloc.c      2010-08-02 17:05:06.000000000 +0200
9539 @@ -41,7 +41,6 @@
9540  #include "xfs_error.h"
9541  #include "xfs_bmap.h"
9542  
9543 -
9544  /*
9545   * Allocation group level functions.
9546   */
9547 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_inode.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_inode.c
9548 --- linux-2.6.35/fs/xfs/xfs_inode.c     2010-08-02 16:52:53.000000000 +0200
9549 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_inode.c       2010-08-02 17:05:06.000000000 +0200
9550 @@ -249,6 +249,7 @@ xfs_inotobp(
9551         return 0;
9552  }
9553  
9554 +#include <linux/vs_tag.h>
9555  
9556  /*
9557   * This routine is called to map an inode to the buffer containing
9558 @@ -654,15 +655,25 @@ xfs_iformat_btree(
9559  STATIC void
9560  xfs_dinode_from_disk(
9561         xfs_icdinode_t          *to,
9562 -       xfs_dinode_t            *from)
9563 +       xfs_dinode_t            *from,
9564 +       int tagged)
9565  {
9566 +       uint32_t uid, gid, tag;
9567 +
9568         to->di_magic = be16_to_cpu(from->di_magic);
9569         to->di_mode = be16_to_cpu(from->di_mode);
9570         to->di_version = from ->di_version;
9571         to->di_format = from->di_format;
9572         to->di_onlink = be16_to_cpu(from->di_onlink);
9573 -       to->di_uid = be32_to_cpu(from->di_uid);
9574 -       to->di_gid = be32_to_cpu(from->di_gid);
9575 +
9576 +       uid = be32_to_cpu(from->di_uid);
9577 +       gid = be32_to_cpu(from->di_gid);
9578 +       tag = be16_to_cpu(from->di_tag);
9579 +
9580 +       to->di_uid = INOTAG_UID(tagged, uid, gid);
9581 +       to->di_gid = INOTAG_GID(tagged, uid, gid);
9582 +       to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
9583 +
9584         to->di_nlink = be32_to_cpu(from->di_nlink);
9585         to->di_projid = be16_to_cpu(from->di_projid);
9586         memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
9587 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
9588         to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
9589         to->di_dmstate  = be16_to_cpu(from->di_dmstate);
9590         to->di_flags    = be16_to_cpu(from->di_flags);
9591 +       to->di_vflags   = be16_to_cpu(from->di_vflags);
9592         to->di_gen      = be32_to_cpu(from->di_gen);
9593  }
9594  
9595  void
9596  xfs_dinode_to_disk(
9597         xfs_dinode_t            *to,
9598 -       xfs_icdinode_t          *from)
9599 +       xfs_icdinode_t          *from,
9600 +       int tagged)
9601  {
9602         to->di_magic = cpu_to_be16(from->di_magic);
9603         to->di_mode = cpu_to_be16(from->di_mode);
9604         to->di_version = from ->di_version;
9605         to->di_format = from->di_format;
9606         to->di_onlink = cpu_to_be16(from->di_onlink);
9607 -       to->di_uid = cpu_to_be32(from->di_uid);
9608 -       to->di_gid = cpu_to_be32(from->di_gid);
9609 +
9610 +       to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
9611 +       to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
9612 +       to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
9613 +
9614         to->di_nlink = cpu_to_be32(from->di_nlink);
9615         to->di_projid = cpu_to_be16(from->di_projid);
9616         memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
9617 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
9618         to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
9619         to->di_dmstate = cpu_to_be16(from->di_dmstate);
9620         to->di_flags = cpu_to_be16(from->di_flags);
9621 +       to->di_vflags = cpu_to_be16(from->di_vflags);
9622         to->di_gen = cpu_to_be32(from->di_gen);
9623  }
9624  
9625  STATIC uint
9626  _xfs_dic2xflags(
9627 -       __uint16_t              di_flags)
9628 +       __uint16_t              di_flags,
9629 +       __uint16_t              di_vflags)
9630  {
9631         uint                    flags = 0;
9632  
9633 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
9634                         flags |= XFS_XFLAG_PREALLOC;
9635                 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9636                         flags |= XFS_XFLAG_IMMUTABLE;
9637 +               if (di_flags & XFS_DIFLAG_IXUNLINK)
9638 +                       flags |= XFS_XFLAG_IXUNLINK;
9639                 if (di_flags & XFS_DIFLAG_APPEND)
9640                         flags |= XFS_XFLAG_APPEND;
9641                 if (di_flags & XFS_DIFLAG_SYNC)
9642 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
9643                         flags |= XFS_XFLAG_FILESTREAM;
9644         }
9645  
9646 +       if (di_vflags & XFS_DIVFLAG_BARRIER)
9647 +               flags |= FS_BARRIER_FL;
9648 +       if (di_vflags & XFS_DIVFLAG_COW)
9649 +               flags |= FS_COW_FL;
9650         return flags;
9651  }
9652  
9653 @@ -767,7 +791,7 @@ xfs_ip2xflags(
9654  {
9655         xfs_icdinode_t          *dic = &ip->i_d;
9656  
9657 -       return _xfs_dic2xflags(dic->di_flags) |
9658 +       return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
9659                                 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
9660  }
9661  
9662 @@ -775,7 +799,8 @@ uint
9663  xfs_dic2xflags(
9664         xfs_dinode_t            *dip)
9665  {
9666 -       return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
9667 +       return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
9668 +                               be16_to_cpu(dip->di_vflags)) |
9669                                 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
9670  }
9671  
9672 @@ -808,7 +833,6 @@ xfs_iread(
9673         if (error)
9674                 return error;
9675         dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
9676 -
9677         /*
9678          * If we got something that isn't an inode it means someone
9679          * (nfs or dmi) has a stale handle.
9680 @@ -833,7 +857,8 @@ xfs_iread(
9681          * Otherwise, just get the truly permanent information.
9682          */
9683         if (dip->di_mode) {
9684 -               xfs_dinode_from_disk(&ip->i_d, dip);
9685 +               xfs_dinode_from_disk(&ip->i_d, dip,
9686 +                       mp->m_flags & XFS_MOUNT_TAGGED);
9687                 error = xfs_iformat(ip, dip);
9688                 if (error)  {
9689  #ifdef DEBUG
9690 @@ -1033,6 +1058,7 @@ xfs_ialloc(
9691         ASSERT(ip->i_d.di_nlink == nlink);
9692         ip->i_d.di_uid = current_fsuid();
9693         ip->i_d.di_gid = current_fsgid();
9694 +       ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
9695         ip->i_d.di_projid = prid;
9696         memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
9697  
9698 @@ -1093,6 +1119,7 @@ xfs_ialloc(
9699         ip->i_d.di_dmevmask = 0;
9700         ip->i_d.di_dmstate = 0;
9701         ip->i_d.di_flags = 0;
9702 +       ip->i_d.di_vflags = 0;
9703         flags = XFS_ILOG_CORE;
9704         switch (mode & S_IFMT) {
9705         case S_IFIFO:
9706 @@ -2116,6 +2143,7 @@ xfs_ifree(
9707         }
9708         ip->i_d.di_mode = 0;            /* mark incore inode as free */
9709         ip->i_d.di_flags = 0;
9710 +       ip->i_d.di_vflags = 0;
9711         ip->i_d.di_dmevmask = 0;
9712         ip->i_d.di_forkoff = 0;         /* mark the attr fork not in use */
9713         ip->i_df.if_ext_max =
9714 @@ -2985,7 +3013,8 @@ xfs_iflush_int(
9715          * because if the inode is dirty at all the core must
9716          * be.
9717          */
9718 -       xfs_dinode_to_disk(dip, &ip->i_d);
9719 +       xfs_dinode_to_disk(dip, &ip->i_d,
9720 +               mp->m_flags & XFS_MOUNT_TAGGED);
9721  
9722         /* Wrap, we never let the log put out DI_MAX_FLUSH */
9723         if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
9724 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_inode.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_inode.h
9725 --- linux-2.6.35/fs/xfs/xfs_inode.h     2010-08-02 16:52:53.000000000 +0200
9726 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_inode.h       2010-08-02 17:05:06.000000000 +0200
9727 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
9728         __uint32_t      di_gid;         /* owner's group id */
9729         __uint32_t      di_nlink;       /* number of links to file */
9730         __uint16_t      di_projid;      /* owner's project id */
9731 -       __uint8_t       di_pad[8];      /* unused, zeroed space */
9732 +       __uint16_t      di_tag;         /* context tagging */
9733 +       __uint16_t      di_vflags;      /* vserver specific flags */
9734 +       __uint8_t       di_pad[4];      /* unused, zeroed space */
9735         __uint16_t      di_flushiter;   /* incremented on flush */
9736         xfs_ictimestamp_t di_atime;     /* time last accessed */
9737         xfs_ictimestamp_t di_mtime;     /* time last modified */
9738 @@ -511,7 +513,7 @@ int         xfs_itobp(struct xfs_mount *, struc
9739  int            xfs_iread(struct xfs_mount *, struct xfs_trans *,
9740                           struct xfs_inode *, uint);
9741  void           xfs_dinode_to_disk(struct xfs_dinode *,
9742 -                                  struct xfs_icdinode *);
9743 +                                  struct xfs_icdinode *, int);
9744  void           xfs_idestroy_fork(struct xfs_inode *, int);
9745  void           xfs_idata_realloc(struct xfs_inode *, int, int);
9746  void           xfs_iroot_realloc(struct xfs_inode *, int, int);
9747 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_itable.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_itable.c
9748 --- linux-2.6.35/fs/xfs/xfs_itable.c    2010-08-02 16:52:53.000000000 +0200
9749 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_itable.c      2010-08-02 17:05:06.000000000 +0200
9750 @@ -100,6 +100,7 @@ xfs_bulkstat_one_int(
9751         buf->bs_mode = dic->di_mode;
9752         buf->bs_uid = dic->di_uid;
9753         buf->bs_gid = dic->di_gid;
9754 +       buf->bs_tag = dic->di_tag;
9755         buf->bs_size = dic->di_size;
9756  
9757         /*
9758 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_log_recover.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_log_recover.c
9759 --- linux-2.6.35/fs/xfs/xfs_log_recover.c       2010-08-02 16:52:53.000000000 +0200
9760 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_log_recover.c 2010-08-02 17:05:06.000000000 +0200
9761 @@ -2461,7 +2461,8 @@ xlog_recover_do_inode_trans(
9762         }
9763  
9764         /* The core is in in-core format */
9765 -       xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
9766 +       xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
9767 +               mp->m_flags & XFS_MOUNT_TAGGED);
9768  
9769         /* the rest is in on-disk format */
9770         if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
9771 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_mount.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_mount.h
9772 --- linux-2.6.35/fs/xfs/xfs_mount.h     2010-08-02 16:52:53.000000000 +0200
9773 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_mount.h       2010-08-02 17:05:06.000000000 +0200
9774 @@ -302,6 +302,7 @@ typedef struct xfs_mount {
9775                                                    allocator */
9776  #define XFS_MOUNT_NOATTR2      (1ULL << 25)    /* disable use of attr2 format */
9777  
9778 +#define XFS_MOUNT_TAGGED       (1ULL << 31)    /* context tagging */
9779  
9780  /*
9781   * Default minimum read and write sizes.
9782 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_vnodeops.c linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.c
9783 --- linux-2.6.35/fs/xfs/xfs_vnodeops.c  2010-08-02 16:52:53.000000000 +0200
9784 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.c    2010-08-02 17:05:06.000000000 +0200
9785 @@ -55,6 +55,80 @@
9786  #include "xfs_vnodeops.h"
9787  #include "xfs_trace.h"
9788  
9789 +
9790 +STATIC void
9791 +xfs_get_inode_flags(
9792 +       xfs_inode_t     *ip)
9793 +{
9794 +       struct inode    *inode = VFS_I(ip);
9795 +       unsigned int    flags = inode->i_flags;
9796 +       unsigned int    vflags = inode->i_vflags;
9797 +
9798 +       if (flags & S_IMMUTABLE)
9799 +               ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
9800 +       else
9801 +               ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
9802 +       if (flags & S_IXUNLINK)
9803 +               ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
9804 +       else
9805 +               ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
9806 +
9807 +       if (vflags & V_BARRIER)
9808 +               ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
9809 +       else
9810 +               ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
9811 +       if (vflags & V_COW)
9812 +               ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
9813 +       else
9814 +               ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
9815 +}
9816 +
9817 +int
9818 +xfs_sync_flags(
9819 +       struct inode            *inode,
9820 +       int                     flags,
9821 +       int                     vflags)
9822 +{
9823 +       struct xfs_inode        *ip = XFS_I(inode);
9824 +       struct xfs_mount        *mp = ip->i_mount;
9825 +       struct xfs_trans        *tp;
9826 +       unsigned int            lock_flags = 0;
9827 +       int                     code;
9828 +
9829 +       tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
9830 +       code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
9831 +       if (code)
9832 +               goto error_out;
9833 +
9834 +       lock_flags = XFS_ILOCK_EXCL;
9835 +       xfs_ilock(ip, lock_flags);
9836 +
9837 +       xfs_trans_ijoin(tp, ip, lock_flags);
9838 +       xfs_trans_ihold(tp, ip);
9839 +
9840 +       inode->i_flags = flags;
9841 +       inode->i_vflags = vflags;
9842 +       xfs_get_inode_flags(ip);
9843 +
9844 +       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
9845 +       xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
9846 +
9847 +       XFS_STATS_INC(xs_ig_attrchg);
9848 +
9849 +       if (mp->m_flags & XFS_MOUNT_WSYNC)
9850 +               xfs_trans_set_sync(tp);
9851 +       code = xfs_trans_commit(tp, 0);
9852 +       xfs_iunlock(ip, lock_flags);
9853 +       return code;
9854 +
9855 +error_out:
9856 +       xfs_trans_cancel(tp, 0);
9857 +       if (lock_flags)
9858 +               xfs_iunlock(ip, lock_flags);
9859 +       return code;
9860 +}
9861 +
9862 +
9863  int
9864  xfs_setattr(
9865         struct xfs_inode        *ip,
9866 @@ -70,6 +144,7 @@ xfs_setattr(
9867         uint                    commit_flags=0;
9868         uid_t                   uid=0, iuid=0;
9869         gid_t                   gid=0, igid=0;
9870 +       tag_t                   tag=0, itag=0;
9871         struct xfs_dquot        *udqp, *gdqp, *olddquot1, *olddquot2;
9872         int                     need_iolock = 1;
9873  
9874 @@ -162,7 +237,7 @@ xfs_setattr(
9875         /*
9876          * Change file ownership.  Must be the owner or privileged.
9877          */
9878 -       if (mask & (ATTR_UID|ATTR_GID)) {
9879 +       if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9880                 /*
9881                  * These IDs could have changed since we last looked at them.
9882                  * But, we're assured that if the ownership did change
9883 @@ -171,8 +246,10 @@ xfs_setattr(
9884                  */
9885                 iuid = ip->i_d.di_uid;
9886                 igid = ip->i_d.di_gid;
9887 +               itag = ip->i_d.di_tag;
9888                 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
9889                 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
9890 +               tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
9891  
9892                 /*
9893                  * Do a quota reservation only if uid/gid is actually
9894 @@ -180,7 +257,8 @@ xfs_setattr(
9895                  */
9896                 if (XFS_IS_QUOTA_RUNNING(mp) &&
9897                     ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
9898 -                    (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
9899 +                    (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
9900 +                    (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
9901                         ASSERT(tp);
9902                         code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
9903                                                 capable(CAP_FOWNER) ?
9904 @@ -341,7 +419,7 @@ xfs_setattr(
9905         /*
9906          * Change file ownership.  Must be the owner or privileged.
9907          */
9908 -       if (mask & (ATTR_UID|ATTR_GID)) {
9909 +       if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9910                 /*
9911                  * CAP_FSETID overrides the following restrictions:
9912                  *
9913 @@ -357,6 +435,10 @@ xfs_setattr(
9914                  * Change the ownerships and register quota modifications
9915                  * in the transaction.
9916                  */
9917 +               if (itag != tag) {
9918 +                       ip->i_d.di_tag = tag;
9919 +                       inode->i_tag = tag;
9920 +               }
9921                 if (iuid != uid) {
9922                         if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
9923                                 ASSERT(mask & ATTR_UID);
9924 diff -NurpP --minimal linux-2.6.35/fs/xfs/xfs_vnodeops.h linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.h
9925 --- linux-2.6.35/fs/xfs/xfs_vnodeops.h  2010-07-07 18:31:54.000000000 +0200
9926 +++ linux-2.6.35-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.h    2010-08-02 17:05:06.000000000 +0200
9927 @@ -14,6 +14,7 @@ struct xfs_inode;
9928  struct xfs_iomap;
9929  
9930  
9931 +int xfs_sync_xflags(struct xfs_inode *ip);
9932  int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
9933  #define        XFS_ATTR_DMI            0x01    /* invocation from a DMI function */
9934  #define        XFS_ATTR_NONBLOCK       0x02    /* return EAGAIN if operation would block */
9935 diff -NurpP --minimal linux-2.6.35/include/asm-generic/tlb.h linux-2.6.35-vs2.3.0.36.31/include/asm-generic/tlb.h
9936 --- linux-2.6.35/include/asm-generic/tlb.h      2009-09-10 15:26:24.000000000 +0200
9937 +++ linux-2.6.35-vs2.3.0.36.31/include/asm-generic/tlb.h        2010-08-02 17:05:06.000000000 +0200
9938 @@ -14,6 +14,7 @@
9939  #define _ASM_GENERIC__TLB_H
9940  
9941  #include <linux/swap.h>
9942 +#include <linux/vs_memory.h>
9943  #include <asm/pgalloc.h>
9944  #include <asm/tlbflush.h>
9945  
9946 diff -NurpP --minimal linux-2.6.35/include/linux/capability.h linux-2.6.35-vs2.3.0.36.31/include/linux/capability.h
9947 --- linux-2.6.35/include/linux/capability.h     2010-02-25 11:52:07.000000000 +0100
9948 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/capability.h       2010-08-02 17:05:06.000000000 +0200
9949 @@ -283,6 +283,7 @@ struct cpu_vfs_cap_data {
9950     arbitrary SCSI commands */
9951  /* Allow setting encryption key on loopback filesystem */
9952  /* Allow setting zone reclaim policy */
9953 +/* Allow the selection of a security context */
9954  
9955  #define CAP_SYS_ADMIN        21
9956  
9957 @@ -355,7 +356,13 @@ struct cpu_vfs_cap_data {
9958  
9959  #define CAP_MAC_ADMIN        33
9960  
9961 -#define CAP_LAST_CAP         CAP_MAC_ADMIN
9962 +/* Allow context manipulations */
9963 +/* Allow changing context info on files */
9964 +
9965 +#define CAP_CONTEXT         34
9966 +
9967 +
9968 +#define CAP_LAST_CAP         CAP_CONTEXT
9969  
9970  #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
9971  
9972 diff -NurpP --minimal linux-2.6.35/include/linux/devpts_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/devpts_fs.h
9973 --- linux-2.6.35/include/linux/devpts_fs.h      2008-12-25 00:26:37.000000000 +0100
9974 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/devpts_fs.h        2010-08-02 17:05:06.000000000 +0200
9975 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
9976  
9977  #endif
9978  
9979 -
9980  #endif /* _LINUX_DEVPTS_FS_H */
9981 diff -NurpP --minimal linux-2.6.35/include/linux/ext2_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/ext2_fs.h
9982 --- linux-2.6.35/include/linux/ext2_fs.h        2010-02-25 11:52:07.000000000 +0100
9983 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/ext2_fs.h  2010-08-02 17:05:06.000000000 +0200
9984 @@ -189,8 +189,12 @@ struct ext2_group_desc
9985  #define EXT2_NOTAIL_FL                 FS_NOTAIL_FL    /* file tail should not be merged */
9986  #define EXT2_DIRSYNC_FL                        FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
9987  #define EXT2_TOPDIR_FL                 FS_TOPDIR_FL    /* Top of directory hierarchies*/
9988 +#define EXT2_IXUNLINK_FL               FS_IXUNLINK_FL  /* Immutable invert on unlink */
9989  #define EXT2_RESERVED_FL               FS_RESERVED_FL  /* reserved for ext2 lib */
9990  
9991 +#define EXT2_BARRIER_FL                        FS_BARRIER_FL   /* Barrier for chroot() */
9992 +#define EXT2_COW_FL                    FS_COW_FL       /* Copy on Write marker */
9993 +
9994  #define EXT2_FL_USER_VISIBLE           FS_FL_USER_VISIBLE      /* User visible flags */
9995  #define EXT2_FL_USER_MODIFIABLE                FS_FL_USER_MODIFIABLE   /* User modifiable flags */
9996  
9997 @@ -274,7 +278,8 @@ struct ext2_inode {
9998                         __u16   i_pad1;
9999                         __le16  l_i_uid_high;   /* these 2 fields    */
10000                         __le16  l_i_gid_high;   /* were reserved2[0] */
10001 -                       __u32   l_i_reserved2;
10002 +                       __le16  l_i_tag;        /* Context Tag */
10003 +                       __u16   l_i_reserved2;
10004                 } linux2;
10005                 struct {
10006                         __u8    h_i_frag;       /* Fragment number */
10007 @@ -303,6 +308,7 @@ struct ext2_inode {
10008  #define i_gid_low      i_gid
10009  #define i_uid_high     osd2.linux2.l_i_uid_high
10010  #define i_gid_high     osd2.linux2.l_i_gid_high
10011 +#define i_raw_tag      osd2.linux2.l_i_tag
10012  #define i_reserved2    osd2.linux2.l_i_reserved2
10013  #endif
10014  
10015 @@ -347,6 +353,7 @@ struct ext2_inode {
10016  #define EXT2_MOUNT_USRQUOTA            0x020000  /* user quota */
10017  #define EXT2_MOUNT_GRPQUOTA            0x040000  /* group quota */
10018  #define EXT2_MOUNT_RESERVATION         0x080000  /* Preallocation */
10019 +#define EXT2_MOUNT_TAGGED              (1<<24)   /* Enable Context Tags */
10020  
10021  
10022  #define clear_opt(o, opt)              o &= ~EXT2_MOUNT_##opt
10023 diff -NurpP --minimal linux-2.6.35/include/linux/ext3_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/ext3_fs.h
10024 --- linux-2.6.35/include/linux/ext3_fs.h        2010-08-02 16:52:54.000000000 +0200
10025 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/ext3_fs.h  2010-08-02 17:05:06.000000000 +0200
10026 @@ -173,10 +173,14 @@ struct ext3_group_desc
10027  #define EXT3_NOTAIL_FL                 0x00008000 /* file tail should not be merged */
10028  #define EXT3_DIRSYNC_FL                        0x00010000 /* dirsync behaviour (directories only) */
10029  #define EXT3_TOPDIR_FL                 0x00020000 /* Top of directory hierarchies*/
10030 +#define EXT3_IXUNLINK_FL               0x08000000 /* Immutable invert on unlink */
10031  #define EXT3_RESERVED_FL               0x80000000 /* reserved for ext3 lib */
10032  
10033 -#define EXT3_FL_USER_VISIBLE           0x0003DFFF /* User visible flags */
10034 -#define EXT3_FL_USER_MODIFIABLE                0x000380FF /* User modifiable flags */
10035 +#define EXT3_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
10036 +#define EXT3_COW_FL                    0x20000000 /* Copy on Write marker */
10037 +
10038 +#define EXT3_FL_USER_VISIBLE           0x0103DFFF /* User visible flags */
10039 +#define EXT3_FL_USER_MODIFIABLE                0x010380FF /* User modifiable flags */
10040  
10041  /* Flags that should be inherited by new inodes from their parent. */
10042  #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
10043 @@ -312,7 +316,8 @@ struct ext3_inode {
10044                         __u16   i_pad1;
10045                         __le16  l_i_uid_high;   /* these 2 fields    */
10046                         __le16  l_i_gid_high;   /* were reserved2[0] */
10047 -                       __u32   l_i_reserved2;
10048 +                       __le16  l_i_tag;        /* Context Tag */
10049 +                       __u16   l_i_reserved2;
10050                 } linux2;
10051                 struct {
10052                         __u8    h_i_frag;       /* Fragment number */
10053 @@ -343,6 +348,7 @@ struct ext3_inode {
10054  #define i_gid_low      i_gid
10055  #define i_uid_high     osd2.linux2.l_i_uid_high
10056  #define i_gid_high     osd2.linux2.l_i_gid_high
10057 +#define i_raw_tag      osd2.linux2.l_i_tag
10058  #define i_reserved2    osd2.linux2.l_i_reserved2
10059  
10060  #elif defined(__GNU__)
10061 @@ -406,6 +412,7 @@ struct ext3_inode {
10062  #define EXT3_MOUNT_GRPQUOTA            0x200000 /* "old" group quota */
10063  #define EXT3_MOUNT_DATA_ERR_ABORT      0x400000 /* Abort on file data write
10064                                                   * error in ordered mode */
10065 +#define EXT3_MOUNT_TAGGED              (1<<24) /* Enable Context Tags */
10066  
10067  /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
10068  #ifndef _LINUX_EXT2_FS_H
10069 @@ -909,6 +916,7 @@ extern void ext3_get_inode_flags(struct 
10070  extern void ext3_set_aops(struct inode *inode);
10071  extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
10072                        u64 start, u64 len);
10073 +extern int ext3_sync_flags(struct inode *, int, int);
10074  
10075  /* ioctl.c */
10076  extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
10077 diff -NurpP --minimal linux-2.6.35/include/linux/fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/fs.h
10078 --- linux-2.6.35/include/linux/fs.h     2010-08-02 16:52:54.000000000 +0200
10079 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/fs.h       2010-08-02 18:15:53.000000000 +0200
10080 @@ -209,6 +209,9 @@ struct inodes_stat_t {
10081  #define MS_KERNMOUNT   (1<<22) /* this is a kern_mount call */
10082  #define MS_I_VERSION   (1<<23) /* Update inode I_version field */
10083  #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
10084 +#define MS_TAGGED      (1<<25) /* use generic inode tagging */
10085 +#define MS_TAGID       (1<<26) /* use specific tag for this mount */
10086 +#define MS_NOTAGCHECK  (1<<27) /* don't check tags */
10087  #define MS_ACTIVE      (1<<30)
10088  #define MS_NOUSER      (1<<31)
10089  
10090 @@ -235,6 +238,14 @@ struct inodes_stat_t {
10091  #define S_NOCMTIME     128     /* Do not update file c/mtime */
10092  #define S_SWAPFILE     256     /* Do not truncate: swapon got its bmaps */
10093  #define S_PRIVATE      512     /* Inode is fs-internal */
10094 +#define S_IXUNLINK     1024    /* Immutable Invert on unlink */
10095 +
10096 +/* Linux-VServer related Inode flags */
10097 +
10098 +#define V_VALID                1
10099 +#define V_XATTR                2
10100 +#define V_BARRIER      4       /* Barrier for chroot() */
10101 +#define V_COW          8       /* Copy on Write */
10102  
10103  /*
10104   * Note that nosuid etc flags are inode-specific: setting some file-system
10105 @@ -257,12 +268,15 @@ struct inodes_stat_t {
10106  #define IS_DIRSYNC(inode)      (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
10107                                         ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
10108  #define IS_MANDLOCK(inode)     __IS_FLG(inode, MS_MANDLOCK)
10109 -#define IS_NOATIME(inode)   __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10110 -#define IS_I_VERSION(inode)   __IS_FLG(inode, MS_I_VERSION)
10111 +#define IS_NOATIME(inode)      __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10112 +#define IS_I_VERSION(inode)    __IS_FLG(inode, MS_I_VERSION)
10113 +#define IS_TAGGED(inode)       __IS_FLG(inode, MS_TAGGED)
10114  
10115  #define IS_NOQUOTA(inode)      ((inode)->i_flags & S_NOQUOTA)
10116  #define IS_APPEND(inode)       ((inode)->i_flags & S_APPEND)
10117  #define IS_IMMUTABLE(inode)    ((inode)->i_flags & S_IMMUTABLE)
10118 +#define IS_IXUNLINK(inode)     ((inode)->i_flags & S_IXUNLINK)
10119 +#define IS_IXORUNLINK(inode)   ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
10120  #define IS_POSIXACL(inode)     __IS_FLG(inode, MS_POSIXACL)
10121  
10122  #define IS_DEADDIR(inode)      ((inode)->i_flags & S_DEAD)
10123 @@ -270,6 +284,16 @@ struct inodes_stat_t {
10124  #define IS_SWAPFILE(inode)     ((inode)->i_flags & S_SWAPFILE)
10125  #define IS_PRIVATE(inode)      ((inode)->i_flags & S_PRIVATE)
10126  
10127 +#define IS_BARRIER(inode)      (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
10128 +
10129 +#ifdef CONFIG_VSERVER_COWBL
10130 +#  define IS_COW(inode)                (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
10131 +#  define IS_COW_LINK(inode)   (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
10132 +#else
10133 +#  define IS_COW(inode)                (0)
10134 +#  define IS_COW_LINK(inode)   (0)
10135 +#endif
10136 +
10137  /* the read-only stuff doesn't really belong here, but any other place is
10138     probably as bad and I don't want to create yet another include file. */
10139  
10140 @@ -352,11 +376,14 @@ struct inodes_stat_t {
10141  #define FS_TOPDIR_FL                   0x00020000 /* Top of directory hierarchies*/
10142  #define FS_EXTENT_FL                   0x00080000 /* Extents */
10143  #define FS_DIRECTIO_FL                 0x00100000 /* Use direct i/o */
10144 +#define FS_IXUNLINK_FL                 0x08000000 /* Immutable invert on unlink */
10145  #define FS_RESERVED_FL                 0x80000000 /* reserved for ext2 lib */
10146  
10147 -#define FS_FL_USER_VISIBLE             0x0003DFFF /* User visible flags */
10148 -#define FS_FL_USER_MODIFIABLE          0x000380FF /* User modifiable flags */
10149 +#define FS_BARRIER_FL                  0x04000000 /* Barrier for chroot() */
10150 +#define FS_COW_FL                      0x20000000 /* Copy on Write marker */
10151  
10152 +#define FS_FL_USER_VISIBLE             0x0103DFFF /* User visible flags */
10153 +#define FS_FL_USER_MODIFIABLE          0x010380FF /* User modifiable flags */
10154  
10155  #define SYNC_FILE_RANGE_WAIT_BEFORE    1
10156  #define SYNC_FILE_RANGE_WRITE          2
10157 @@ -438,6 +465,7 @@ typedef void (dio_iodone_t)(struct kiocb
10158  #define ATTR_KILL_PRIV (1 << 14)
10159  #define ATTR_OPEN      (1 << 15) /* Truncating from open(O_TRUNC) */
10160  #define ATTR_TIMES_SET (1 << 16)
10161 +#define ATTR_TAG       (1 << 17)
10162  
10163  /*
10164   * This is the Inode Attributes structure, used for notify_change().  It
10165 @@ -453,6 +481,7 @@ struct iattr {
10166         umode_t         ia_mode;
10167         uid_t           ia_uid;
10168         gid_t           ia_gid;
10169 +       tag_t           ia_tag;
10170         loff_t          ia_size;
10171         struct timespec ia_atime;
10172         struct timespec ia_mtime;
10173 @@ -466,6 +495,9 @@ struct iattr {
10174         struct file     *ia_file;
10175  };
10176  
10177 +#define ATTR_FLAG_BARRIER      512     /* Barrier for chroot() */
10178 +#define ATTR_FLAG_IXUNLINK     1024    /* Immutable invert on unlink */
10179 +
10180  /*
10181   * Includes for diskquotas.
10182   */
10183 @@ -732,7 +764,9 @@ struct inode {
10184         unsigned int            i_nlink;
10185         uid_t                   i_uid;
10186         gid_t                   i_gid;
10187 +       tag_t                   i_tag;
10188         dev_t                   i_rdev;
10189 +       dev_t                   i_mdev;
10190         unsigned int            i_blkbits;
10191         u64                     i_version;
10192         loff_t                  i_size;
10193 @@ -779,7 +813,8 @@ struct inode {
10194         unsigned long           i_state;
10195         unsigned long           dirtied_when;   /* jiffies of first dirtying */
10196  
10197 -       unsigned int            i_flags;
10198 +       unsigned short          i_flags;
10199 +       unsigned short          i_vflags;
10200  
10201         atomic_t                i_writecount;
10202  #ifdef CONFIG_SECURITY
10203 @@ -867,12 +902,12 @@ static inline void i_size_write(struct i
10204  
10205  static inline unsigned iminor(const struct inode *inode)
10206  {
10207 -       return MINOR(inode->i_rdev);
10208 +       return MINOR(inode->i_mdev);
10209  }
10210  
10211  static inline unsigned imajor(const struct inode *inode)
10212  {
10213 -       return MAJOR(inode->i_rdev);
10214 +       return MAJOR(inode->i_mdev);
10215  }
10216  
10217  extern struct block_device *I_BDEV(struct inode *inode);
10218 @@ -931,6 +966,7 @@ struct file {
10219         loff_t                  f_pos;
10220         struct fown_struct      f_owner;
10221         const struct cred       *f_cred;
10222 +       xid_t                   f_xid;
10223         struct file_ra_state    f_ra;
10224  
10225         u64                     f_version;
10226 @@ -1073,6 +1109,7 @@ struct file_lock {
10227         struct file *fl_file;
10228         loff_t fl_start;
10229         loff_t fl_end;
10230 +       xid_t fl_xid;
10231  
10232         struct fasync_struct *  fl_fasync; /* for lease break notifications */
10233         unsigned long fl_break_time;    /* for nonblocking lease breaks */
10234 @@ -1534,6 +1571,7 @@ struct inode_operations {
10235         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
10236         ssize_t (*listxattr) (struct dentry *, char *, size_t);
10237         int (*removexattr) (struct dentry *, const char *);
10238 +       int (*sync_flags) (struct inode *, int, int);
10239         void (*truncate_range)(struct inode *, loff_t, loff_t);
10240         long (*fallocate)(struct inode *inode, int mode, loff_t offset,
10241                           loff_t len);
10242 @@ -1554,6 +1592,7 @@ extern ssize_t vfs_readv(struct file *, 
10243                 unsigned long, loff_t *);
10244  extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
10245                 unsigned long, loff_t *);
10246 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
10247  
10248  struct super_operations {
10249         struct inode *(*alloc_inode)(struct super_block *sb);
10250 @@ -2377,6 +2416,7 @@ extern int dcache_dir_open(struct inode 
10251  extern int dcache_dir_close(struct inode *, struct file *);
10252  extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
10253  extern int dcache_readdir(struct file *, void *, filldir_t);
10254 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
10255  extern int simple_setattr(struct dentry *, struct iattr *);
10256  extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
10257  extern int simple_statfs(struct dentry *, struct kstatfs *);
10258 diff -NurpP --minimal linux-2.6.35/include/linux/gfs2_ondisk.h linux-2.6.35-vs2.3.0.36.31/include/linux/gfs2_ondisk.h
10259 --- linux-2.6.35/include/linux/gfs2_ondisk.h    2010-07-07 18:31:55.000000000 +0200
10260 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/gfs2_ondisk.h      2010-08-02 17:05:06.000000000 +0200
10261 @@ -211,6 +211,9 @@ enum {
10262         gfs2fl_NoAtime          = 7,
10263         gfs2fl_Sync             = 8,
10264         gfs2fl_System           = 9,
10265 +       gfs2fl_IXUnlink         = 16,
10266 +       gfs2fl_Barrier          = 17,
10267 +       gfs2fl_Cow              = 18,
10268         gfs2fl_TruncInProg      = 29,
10269         gfs2fl_InheritDirectio  = 30,
10270         gfs2fl_InheritJdata     = 31,
10271 @@ -227,6 +230,9 @@ enum {
10272  #define GFS2_DIF_NOATIME               0x00000080
10273  #define GFS2_DIF_SYNC                  0x00000100
10274  #define GFS2_DIF_SYSTEM                        0x00000200 /* New in gfs2 */
10275 +#define GFS2_DIF_IXUNLINK              0x00010000
10276 +#define GFS2_DIF_BARRIER               0x00020000
10277 +#define GFS2_DIF_COW                   0x00040000
10278  #define GFS2_DIF_TRUNC_IN_PROG         0x20000000 /* New in gfs2 */
10279  #define GFS2_DIF_INHERIT_DIRECTIO      0x40000000
10280  #define GFS2_DIF_INHERIT_JDATA         0x80000000
10281 diff -NurpP --minimal linux-2.6.35/include/linux/if_tun.h linux-2.6.35-vs2.3.0.36.31/include/linux/if_tun.h
10282 --- linux-2.6.35/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
10283 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/if_tun.h   2010-08-02 18:17:46.000000000 +0200
10284 @@ -53,6 +53,7 @@
10285  #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
10286  #define TUNGETVNETHDRSZ _IOR('T', 215, int)
10287  #define TUNSETVNETHDRSZ _IOW('T', 216, int)
10288 +#define TUNSETNID     _IOW('T', 217, int)
10289  
10290  /* TUNSETIFF ifr flags */
10291  #define IFF_TUN                0x0001
10292 diff -NurpP --minimal linux-2.6.35/include/linux/init_task.h linux-2.6.35-vs2.3.0.36.31/include/linux/init_task.h
10293 --- linux-2.6.35/include/linux/init_task.h      2010-08-02 16:52:54.000000000 +0200
10294 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/init_task.h        2010-08-02 17:05:06.000000000 +0200
10295 @@ -172,6 +172,10 @@ extern struct cred init_cred;
10296         INIT_FTRACE_GRAPH                                               \
10297         INIT_TRACE_RECURSION                                            \
10298         INIT_TASK_RCU_PREEMPT(tsk)                                      \
10299 +       .xid            = 0,                                            \
10300 +       .vx_info        = NULL,                                         \
10301 +       .nid            = 0,                                            \
10302 +       .nx_info        = NULL,                                         \
10303  }
10304  
10305  
10306 diff -NurpP --minimal linux-2.6.35/include/linux/ipc.h linux-2.6.35-vs2.3.0.36.31/include/linux/ipc.h
10307 --- linux-2.6.35/include/linux/ipc.h    2009-12-03 20:02:55.000000000 +0100
10308 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/ipc.h      2010-08-02 17:05:06.000000000 +0200
10309 @@ -91,6 +91,7 @@ struct kern_ipc_perm
10310         key_t           key;
10311         uid_t           uid;
10312         gid_t           gid;
10313 +       xid_t           xid;
10314         uid_t           cuid;
10315         gid_t           cgid;
10316         mode_t          mode; 
10317 diff -NurpP --minimal linux-2.6.35/include/linux/Kbuild linux-2.6.35-vs2.3.0.36.31/include/linux/Kbuild
10318 --- linux-2.6.35/include/linux/Kbuild   2010-08-02 16:52:53.000000000 +0200
10319 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/Kbuild     2010-08-02 17:05:06.000000000 +0200
10320 @@ -387,5 +387,8 @@ unifdef-y += xattr.h
10321  unifdef-y += xfrm.h
10322  
10323  objhdr-y += version.h
10324 +
10325 +header-y += vserver/
10326  header-y += wimax.h
10327  header-y += wimax/
10328 +
10329 diff -NurpP --minimal linux-2.6.35/include/linux/loop.h linux-2.6.35-vs2.3.0.36.31/include/linux/loop.h
10330 --- linux-2.6.35/include/linux/loop.h   2009-09-10 15:26:25.000000000 +0200
10331 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/loop.h     2010-08-02 17:05:06.000000000 +0200
10332 @@ -45,6 +45,7 @@ struct loop_device {
10333         struct loop_func_table *lo_encryption;
10334         __u32           lo_init[2];
10335         uid_t           lo_key_owner;   /* Who set the key */
10336 +       xid_t           lo_xid;
10337         int             (*ioctl)(struct loop_device *, int cmd, 
10338                                  unsigned long arg); 
10339  
10340 diff -NurpP --minimal linux-2.6.35/include/linux/magic.h linux-2.6.35-vs2.3.0.36.31/include/linux/magic.h
10341 --- linux-2.6.35/include/linux/magic.h  2010-07-07 18:31:55.000000000 +0200
10342 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/magic.h    2010-08-02 17:05:06.000000000 +0200
10343 @@ -3,7 +3,7 @@
10344  
10345  #define ADFS_SUPER_MAGIC       0xadf5
10346  #define AFFS_SUPER_MAGIC       0xadff
10347 -#define AFS_SUPER_MAGIC                0x5346414F
10348 +#define AFS_SUPER_MAGIC                0x5346414F
10349  #define AUTOFS_SUPER_MAGIC     0x0187
10350  #define CODA_SUPER_MAGIC       0x73757245
10351  #define CRAMFS_MAGIC           0x28cd3d45      /* some random number */
10352 @@ -38,6 +38,7 @@
10353  #define NFS_SUPER_MAGIC                0x6969
10354  #define OPENPROM_SUPER_MAGIC   0x9fa1
10355  #define PROC_SUPER_MAGIC       0x9fa0
10356 +#define DEVPTS_SUPER_MAGIC     0x1cd1
10357  #define QNX4_SUPER_MAGIC       0x002f          /* qnx4 fs detection */
10358  
10359  #define REISERFS_SUPER_MAGIC   0x52654973      /* used by gcc */
10360 diff -NurpP --minimal linux-2.6.35/include/linux/major.h linux-2.6.35-vs2.3.0.36.31/include/linux/major.h
10361 --- linux-2.6.35/include/linux/major.h  2009-09-10 15:26:25.000000000 +0200
10362 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/major.h    2010-08-02 17:05:06.000000000 +0200
10363 @@ -15,6 +15,7 @@
10364  #define HD_MAJOR               IDE0_MAJOR
10365  #define PTY_SLAVE_MAJOR                3
10366  #define TTY_MAJOR              4
10367 +#define VROOT_MAJOR            4
10368  #define TTYAUX_MAJOR           5
10369  #define LP_MAJOR               6
10370  #define VCS_MAJOR              7
10371 diff -NurpP --minimal linux-2.6.35/include/linux/memcontrol.h linux-2.6.35-vs2.3.0.36.31/include/linux/memcontrol.h
10372 --- linux-2.6.35/include/linux/memcontrol.h     2010-08-02 16:52:54.000000000 +0200
10373 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/memcontrol.h       2010-08-02 17:05:06.000000000 +0200
10374 @@ -77,6 +77,13 @@ int task_in_mem_cgroup(struct task_struc
10375  extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
10376  extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
10377  
10378 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
10379 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
10380 +
10381 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
10382 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
10383 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
10384 +
10385  static inline
10386  int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
10387  {
10388 diff -NurpP --minimal linux-2.6.35/include/linux/mm_types.h linux-2.6.35-vs2.3.0.36.31/include/linux/mm_types.h
10389 --- linux-2.6.35/include/linux/mm_types.h       2010-07-07 18:31:55.000000000 +0200
10390 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/mm_types.h 2010-08-02 17:05:06.000000000 +0200
10391 @@ -269,6 +269,7 @@ struct mm_struct {
10392  
10393         /* Architecture-specific MM context */
10394         mm_context_t context;
10395 +       struct vx_info *mm_vx_info;
10396  
10397         /* Swap token stuff */
10398         /*
10399 diff -NurpP --minimal linux-2.6.35/include/linux/mount.h linux-2.6.35-vs2.3.0.36.31/include/linux/mount.h
10400 --- linux-2.6.35/include/linux/mount.h  2010-07-07 18:31:56.000000000 +0200
10401 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/mount.h    2010-08-02 17:05:06.000000000 +0200
10402 @@ -47,6 +47,9 @@ struct mnt_namespace;
10403  
10404  #define MNT_INTERNAL   0x4000
10405  
10406 +#define MNT_TAGID      0x10000
10407 +#define MNT_NOTAG      0x20000
10408 +
10409  struct vfsmount {
10410         struct list_head mnt_hash;
10411         struct vfsmount *mnt_parent;    /* fs we are mounted on */
10412 @@ -81,6 +84,7 @@ struct vfsmount {
10413  #else
10414         int mnt_writers;
10415  #endif
10416 +       tag_t mnt_tag;                  /* tagging used for vfsmount */
10417  };
10418  
10419  static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
10420 diff -NurpP --minimal linux-2.6.35/include/linux/net.h linux-2.6.35-vs2.3.0.36.31/include/linux/net.h
10421 --- linux-2.6.35/include/linux/net.h    2010-08-02 16:52:55.000000000 +0200
10422 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/net.h      2010-08-02 17:05:06.000000000 +0200
10423 @@ -71,6 +71,7 @@ struct net;
10424  #define SOCK_NOSPACE           2
10425  #define SOCK_PASSCRED          3
10426  #define SOCK_PASSSEC           4
10427 +#define SOCK_USER_SOCKET       5
10428  
10429  #ifndef ARCH_HAS_SOCKET_TYPES
10430  /**
10431 diff -NurpP --minimal linux-2.6.35/include/linux/nfs_mount.h linux-2.6.35-vs2.3.0.36.31/include/linux/nfs_mount.h
10432 --- linux-2.6.35/include/linux/nfs_mount.h      2009-03-24 14:22:43.000000000 +0100
10433 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/nfs_mount.h        2010-08-02 17:05:06.000000000 +0200
10434 @@ -63,7 +63,8 @@ struct nfs_mount_data {
10435  #define NFS_MOUNT_SECFLAVOUR   0x2000  /* 5 */
10436  #define NFS_MOUNT_NORDIRPLUS   0x4000  /* 5 */
10437  #define NFS_MOUNT_UNSHARED     0x8000  /* 5 */
10438 -#define NFS_MOUNT_FLAGMASK     0xFFFF
10439 +#define NFS_MOUNT_TAGGED       0x10000 /* context tagging */
10440 +#define NFS_MOUNT_FLAGMASK     0x1FFFF
10441  
10442  /* The following are for internal use only */
10443  #define NFS_MOUNT_LOOKUP_CACHE_NONEG   0x10000
10444 diff -NurpP --minimal linux-2.6.35/include/linux/nsproxy.h linux-2.6.35-vs2.3.0.36.31/include/linux/nsproxy.h
10445 --- linux-2.6.35/include/linux/nsproxy.h        2009-06-11 17:13:17.000000000 +0200
10446 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/nsproxy.h  2010-08-02 17:05:06.000000000 +0200
10447 @@ -3,6 +3,7 @@
10448  
10449  #include <linux/spinlock.h>
10450  #include <linux/sched.h>
10451 +#include <linux/vserver/debug.h>
10452  
10453  struct mnt_namespace;
10454  struct uts_namespace;
10455 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
10456  }
10457  
10458  int copy_namespaces(unsigned long flags, struct task_struct *tsk);
10459 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
10460  void exit_task_namespaces(struct task_struct *tsk);
10461  void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
10462  void free_nsproxy(struct nsproxy *ns);
10463  int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
10464         struct fs_struct *);
10465  
10466 -static inline void put_nsproxy(struct nsproxy *ns)
10467 +#define        get_nsproxy(n)  __get_nsproxy(n, __FILE__, __LINE__)
10468 +
10469 +static inline void __get_nsproxy(struct nsproxy *ns,
10470 +       const char *_file, int _line)
10471  {
10472 -       if (atomic_dec_and_test(&ns->count)) {
10473 -               free_nsproxy(ns);
10474 -       }
10475 +       vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
10476 +               ns, atomic_read(&ns->count), _file, _line);
10477 +       atomic_inc(&ns->count);
10478  }
10479  
10480 -static inline void get_nsproxy(struct nsproxy *ns)
10481 +#define        put_nsproxy(n)  __put_nsproxy(n, __FILE__, __LINE__)
10482 +
10483 +static inline void __put_nsproxy(struct nsproxy *ns,
10484 +       const char *_file, int _line)
10485  {
10486 -       atomic_inc(&ns->count);
10487 +       vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
10488 +               ns, atomic_read(&ns->count), _file, _line);
10489 +       if (atomic_dec_and_test(&ns->count)) {
10490 +               free_nsproxy(ns);
10491 +       }
10492  }
10493  
10494  #ifdef CONFIG_CGROUP_NS
10495 diff -NurpP --minimal linux-2.6.35/include/linux/pid.h linux-2.6.35-vs2.3.0.36.31/include/linux/pid.h
10496 --- linux-2.6.35/include/linux/pid.h    2009-03-24 14:22:43.000000000 +0100
10497 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/pid.h      2010-08-02 17:05:06.000000000 +0200
10498 @@ -8,7 +8,8 @@ enum pid_type
10499         PIDTYPE_PID,
10500         PIDTYPE_PGID,
10501         PIDTYPE_SID,
10502 -       PIDTYPE_MAX
10503 +       PIDTYPE_MAX,
10504 +       PIDTYPE_REALPID
10505  };
10506  
10507  /*
10508 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
10509  }
10510  
10511  pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
10512 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
10513  pid_t pid_vnr(struct pid *pid);
10514  
10515  #define do_each_pid_task(pid, type, task)                              \
10516 diff -NurpP --minimal linux-2.6.35/include/linux/proc_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/proc_fs.h
10517 --- linux-2.6.35/include/linux/proc_fs.h        2009-12-03 20:02:56.000000000 +0100
10518 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/proc_fs.h  2010-08-02 17:05:06.000000000 +0200
10519 @@ -56,6 +56,7 @@ struct proc_dir_entry {
10520         nlink_t nlink;
10521         uid_t uid;
10522         gid_t gid;
10523 +       int vx_flags;
10524         loff_t size;
10525         const struct inode_operations *proc_iops;
10526         /*
10527 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void 
10528  extern void kclist_add(struct kcore_list *, void *, size_t, int type);
10529  #endif
10530  
10531 +struct vx_info;
10532 +struct nx_info;
10533 +
10534  union proc_op {
10535         int (*proc_get_link)(struct inode *, struct path *);
10536         int (*proc_read)(struct task_struct *task, char *page);
10537         int (*proc_show)(struct seq_file *m,
10538                 struct pid_namespace *ns, struct pid *pid,
10539                 struct task_struct *task);
10540 +       int (*proc_vs_read)(char *page);
10541 +       int (*proc_vxi_read)(struct vx_info *vxi, char *page);
10542 +       int (*proc_nxi_read)(struct nx_info *nxi, char *page);
10543  };
10544  
10545  struct ctl_table_header;
10546 @@ -263,6 +270,7 @@ struct ctl_table;
10547  
10548  struct proc_inode {
10549         struct pid *pid;
10550 +       int vx_flags;
10551         int fd;
10552         union proc_op op;
10553         struct proc_dir_entry *pde;
10554 diff -NurpP --minimal linux-2.6.35/include/linux/quotaops.h linux-2.6.35-vs2.3.0.36.31/include/linux/quotaops.h
10555 --- linux-2.6.35/include/linux/quotaops.h       2010-08-02 16:52:55.000000000 +0200
10556 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/quotaops.h 2010-08-02 22:35:47.000000000 +0200
10557 @@ -8,6 +8,7 @@
10558  #define _LINUX_QUOTAOPS_
10559  
10560  #include <linux/fs.h>
10561 +#include <linux/vs_dlimit.h>
10562  
10563  #define DQUOT_SPACE_WARN       0x1
10564  #define DQUOT_SPACE_RESERVE    0x2
10565 @@ -209,11 +210,12 @@ static inline void dquot_drop(struct ino
10566  
10567  static inline int dquot_alloc_inode(const struct inode *inode)
10568  {
10569 -       return 0;
10570 +       return dl_alloc_inode(inode);
10571  }
10572  
10573  static inline void dquot_free_inode(const struct inode *inode)
10574  {
10575 +       dl_free_inode(inode);
10576  }
10577  
10578  static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
10579 @@ -224,6 +226,10 @@ static inline int dquot_transfer(struct 
10580  static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
10581                 int flags)
10582  {
10583 +       int ret = 0;
10584 +
10585 +       if ((ret = dl_alloc_space(inode, number)))
10586 +               return ret;
10587         if (!(flags & DQUOT_SPACE_RESERVE))
10588                 inode_add_bytes(inode, number);
10589         return 0;
10590 @@ -234,6 +240,7 @@ static inline void __dquot_free_space(st
10591  {
10592         if (!(flags & DQUOT_SPACE_RESERVE))
10593                 inode_sub_bytes(inode, number);
10594 +       dl_free_space(inode, number);
10595  }
10596  
10597  static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
10598 diff -NurpP --minimal linux-2.6.35/include/linux/reboot.h linux-2.6.35-vs2.3.0.36.31/include/linux/reboot.h
10599 --- linux-2.6.35/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
10600 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/reboot.h   2010-08-02 17:05:06.000000000 +0200
10601 @@ -33,6 +33,7 @@
10602  #define        LINUX_REBOOT_CMD_RESTART2       0xA1B2C3D4
10603  #define        LINUX_REBOOT_CMD_SW_SUSPEND     0xD000FCE2
10604  #define        LINUX_REBOOT_CMD_KEXEC          0x45584543
10605 +#define        LINUX_REBOOT_CMD_OOM            0xDEADBEEF
10606  
10607  
10608  #ifdef __KERNEL__
10609 diff -NurpP --minimal linux-2.6.35/include/linux/reiserfs_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/reiserfs_fs.h
10610 --- linux-2.6.35/include/linux/reiserfs_fs.h    2010-07-07 18:31:56.000000000 +0200
10611 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/reiserfs_fs.h      2010-08-02 17:05:06.000000000 +0200
10612 @@ -977,6 +977,11 @@ struct stat_data_v1 {
10613  #define REISERFS_COMPR_FL     FS_COMPR_FL
10614  #define REISERFS_NOTAIL_FL    FS_NOTAIL_FL
10615  
10616 +/* unfortunately reiserfs sdattr is only 16 bit */
10617 +#define REISERFS_IXUNLINK_FL  (FS_IXUNLINK_FL >> 16)
10618 +#define REISERFS_BARRIER_FL   (FS_BARRIER_FL >> 16)
10619 +#define REISERFS_COW_FL       (FS_COW_FL >> 16)
10620 +
10621  /* persistent flags that file inherits from the parent directory */
10622  #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL |        \
10623                                 REISERFS_SYNC_FL |      \
10624 @@ -986,6 +991,9 @@ struct stat_data_v1 {
10625                                 REISERFS_COMPR_FL |     \
10626                                 REISERFS_NOTAIL_FL )
10627  
10628 +#define REISERFS_FL_USER_VISIBLE       0x80FF
10629 +#define REISERFS_FL_USER_MODIFIABLE    0x80FF
10630 +
10631  /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10632     address blocks) */
10633  struct stat_data {
10634 @@ -2071,6 +2079,7 @@ static inline void reiserfs_update_sd(st
10635  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10636  void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10637  int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10638 +int reiserfs_sync_flags(struct inode *inode, int, int);
10639  
10640  /* namei.c */
10641  void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
10642 diff -NurpP --minimal linux-2.6.35/include/linux/reiserfs_fs_sb.h linux-2.6.35-vs2.3.0.36.31/include/linux/reiserfs_fs_sb.h
10643 --- linux-2.6.35/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
10644 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/reiserfs_fs_sb.h   2010-08-02 17:05:06.000000000 +0200
10645 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
10646         REISERFS_EXPOSE_PRIVROOT,
10647         REISERFS_BARRIER_NONE,
10648         REISERFS_BARRIER_FLUSH,
10649 +       REISERFS_TAGGED,
10650  
10651         /* Actions on error */
10652         REISERFS_ERROR_PANIC,
10653 diff -NurpP --minimal linux-2.6.35/include/linux/sched.h linux-2.6.35-vs2.3.0.36.31/include/linux/sched.h
10654 --- linux-2.6.35/include/linux/sched.h  2010-08-02 16:52:55.000000000 +0200
10655 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/sched.h    2010-08-02 17:05:06.000000000 +0200
10656 @@ -1349,6 +1349,14 @@ struct task_struct {
10657  #endif
10658         seccomp_t seccomp;
10659  
10660 +/* vserver context data */
10661 +       struct vx_info *vx_info;
10662 +       struct nx_info *nx_info;
10663 +
10664 +       xid_t xid;
10665 +       nid_t nid;
10666 +       tag_t tag;
10667 +
10668  /* Thread group tracking */
10669         u32 parent_exec_id;
10670         u32 self_exec_id;
10671 @@ -1583,6 +1591,11 @@ struct pid_namespace;
10672  pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
10673                         struct pid_namespace *ns);
10674  
10675 +#include <linux/vserver/base.h>
10676 +#include <linux/vserver/context.h>
10677 +#include <linux/vserver/debug.h>
10678 +#include <linux/vserver/pid.h>
10679 +
10680  static inline pid_t task_pid_nr(struct task_struct *tsk)
10681  {
10682         return tsk->pid;
10683 @@ -1596,7 +1609,8 @@ static inline pid_t task_pid_nr_ns(struc
10684  
10685  static inline pid_t task_pid_vnr(struct task_struct *tsk)
10686  {
10687 -       return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10688 +       // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10689 +       return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
10690  }
10691  
10692  
10693 @@ -1609,7 +1623,7 @@ pid_t task_tgid_nr_ns(struct task_struct
10694  
10695  static inline pid_t task_tgid_vnr(struct task_struct *tsk)
10696  {
10697 -       return pid_vnr(task_tgid(tsk));
10698 +       return vx_map_tgid(pid_vnr(task_tgid(tsk)));
10699  }
10700  
10701  
10702 diff -NurpP --minimal linux-2.6.35/include/linux/shmem_fs.h linux-2.6.35-vs2.3.0.36.31/include/linux/shmem_fs.h
10703 --- linux-2.6.35/include/linux/shmem_fs.h       2010-02-25 11:52:08.000000000 +0100
10704 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/shmem_fs.h 2010-08-02 17:05:06.000000000 +0200
10705 @@ -8,6 +8,9 @@
10706  
10707  #define SHMEM_NR_DIRECT 16
10708  
10709 +#define TMPFS_SUPER_MAGIC      0x01021994
10710 +
10711 +
10712  struct shmem_inode_info {
10713         spinlock_t              lock;
10714         unsigned long           flags;
10715 diff -NurpP --minimal linux-2.6.35/include/linux/stat.h linux-2.6.35-vs2.3.0.36.31/include/linux/stat.h
10716 --- linux-2.6.35/include/linux/stat.h   2008-12-25 00:26:37.000000000 +0100
10717 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/stat.h     2010-08-02 17:05:06.000000000 +0200
10718 @@ -66,6 +66,7 @@ struct kstat {
10719         unsigned int    nlink;
10720         uid_t           uid;
10721         gid_t           gid;
10722 +       tag_t           tag;
10723         dev_t           rdev;
10724         loff_t          size;
10725         struct timespec  atime;
10726 diff -NurpP --minimal linux-2.6.35/include/linux/sunrpc/auth.h linux-2.6.35-vs2.3.0.36.31/include/linux/sunrpc/auth.h
10727 --- linux-2.6.35/include/linux/sunrpc/auth.h    2010-08-02 16:52:56.000000000 +0200
10728 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/sunrpc/auth.h      2010-08-02 17:05:06.000000000 +0200
10729 @@ -25,6 +25,7 @@
10730  struct auth_cred {
10731         uid_t   uid;
10732         gid_t   gid;
10733 +       tag_t   tag;
10734         struct group_info *group_info;
10735         unsigned char machine_cred : 1;
10736  };
10737 diff -NurpP --minimal linux-2.6.35/include/linux/sunrpc/clnt.h linux-2.6.35-vs2.3.0.36.31/include/linux/sunrpc/clnt.h
10738 --- linux-2.6.35/include/linux/sunrpc/clnt.h    2009-12-03 20:02:56.000000000 +0100
10739 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/sunrpc/clnt.h      2010-08-02 17:05:06.000000000 +0200
10740 @@ -49,7 +49,8 @@ struct rpc_clnt {
10741         unsigned int            cl_softrtry : 1,/* soft timeouts */
10742                                 cl_discrtry : 1,/* disconnect before retry */
10743                                 cl_autobind : 1,/* use getport() */
10744 -                               cl_chatty   : 1;/* be verbose */
10745 +                               cl_chatty   : 1,/* be verbose */
10746 +                               cl_tag      : 1;/* context tagging */
10747  
10748         struct rpc_rtt *        cl_rtt;         /* RTO estimator data */
10749         const struct rpc_timeout *cl_timeout;   /* Timeout strategy */
10750 diff -NurpP --minimal linux-2.6.35/include/linux/syscalls.h linux-2.6.35-vs2.3.0.36.31/include/linux/syscalls.h
10751 --- linux-2.6.35/include/linux/syscalls.h       2010-08-02 16:52:56.000000000 +0200
10752 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/syscalls.h 2010-08-02 17:05:06.000000000 +0200
10753 @@ -479,6 +479,8 @@ asmlinkage long sys_symlink(const char _
10754  asmlinkage long sys_unlink(const char __user *pathname);
10755  asmlinkage long sys_rename(const char __user *oldname,
10756                                 const char __user *newname);
10757 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
10758 +                               umode_t mode);
10759  asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
10760  asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
10761  
10762 diff -NurpP --minimal linux-2.6.35/include/linux/sysctl.h linux-2.6.35-vs2.3.0.36.31/include/linux/sysctl.h
10763 --- linux-2.6.35/include/linux/sysctl.h 2010-08-02 16:52:56.000000000 +0200
10764 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/sysctl.h   2010-08-02 17:05:06.000000000 +0200
10765 @@ -60,6 +60,7 @@ enum
10766         CTL_ABI=9,              /* Binary emulation */
10767         CTL_CPU=10,             /* CPU stuff (speed scaling, etc) */
10768         CTL_ARLAN=254,          /* arlan wireless driver */
10769 +       CTL_VSERVER=4242,       /* Linux-VServer debug */
10770         CTL_S390DBF=5677,       /* s390 debug */
10771         CTL_SUNRPC=7249,        /* sunrpc debug */
10772         CTL_PM=9899,            /* frv power management */
10773 @@ -94,6 +95,7 @@ enum
10774  
10775         KERN_PANIC=15,          /* int: panic timeout */
10776         KERN_REALROOTDEV=16,    /* real root device to mount after initrd */
10777 +       KERN_VSHELPER=17,       /* string: path to vshelper policy agent */
10778  
10779         KERN_SPARC_REBOOT=21,   /* reboot command on Sparc */
10780         KERN_CTLALTDEL=22,      /* int: allow ctl-alt-del to reboot */
10781 diff -NurpP --minimal linux-2.6.35/include/linux/sysfs.h linux-2.6.35-vs2.3.0.36.31/include/linux/sysfs.h
10782 --- linux-2.6.35/include/linux/sysfs.h  2010-08-02 16:52:56.000000000 +0200
10783 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/sysfs.h    2010-08-02 17:05:06.000000000 +0200
10784 @@ -18,6 +18,8 @@
10785  #include <linux/lockdep.h>
10786  #include <asm/atomic.h>
10787  
10788 +#define SYSFS_SUPER_MAGIC      0x62656572
10789 +
10790  struct kobject;
10791  struct module;
10792  enum kobj_ns_type;
10793 diff -NurpP --minimal linux-2.6.35/include/linux/time.h linux-2.6.35-vs2.3.0.36.31/include/linux/time.h
10794 --- linux-2.6.35/include/linux/time.h   2010-08-02 16:52:56.000000000 +0200
10795 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/time.h     2010-08-02 17:05:06.000000000 +0200
10796 @@ -237,6 +237,9 @@ static __always_inline void timespec_add
10797         a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
10798         a->tv_nsec = ns;
10799  }
10800 +
10801 +#include <linux/vs_time.h>
10802 +
10803  #endif /* __KERNEL__ */
10804  
10805  #define NFDBITS                        __NFDBITS
10806 diff -NurpP --minimal linux-2.6.35/include/linux/types.h linux-2.6.35-vs2.3.0.36.31/include/linux/types.h
10807 --- linux-2.6.35/include/linux/types.h  2010-08-02 16:52:56.000000000 +0200
10808 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/types.h    2010-08-02 17:05:06.000000000 +0200
10809 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t      uid_t;
10810  typedef __kernel_gid32_t       gid_t;
10811  typedef __kernel_uid16_t        uid16_t;
10812  typedef __kernel_gid16_t        gid16_t;
10813 +typedef unsigned int           xid_t;
10814 +typedef unsigned int           nid_t;
10815 +typedef unsigned int           tag_t;
10816  
10817  typedef unsigned long          uintptr_t;
10818  
10819 diff -NurpP --minimal linux-2.6.35/include/linux/vroot.h linux-2.6.35-vs2.3.0.36.31/include/linux/vroot.h
10820 --- linux-2.6.35/include/linux/vroot.h  1970-01-01 01:00:00.000000000 +0100
10821 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vroot.h    2010-08-02 17:05:06.000000000 +0200
10822 @@ -0,0 +1,51 @@
10823 +
10824 +/*
10825 + * include/linux/vroot.h
10826 + *
10827 + * written by Herbert Pötzl, 9/11/2002
10828 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
10829 + *
10830 + * Copyright (C) 2002-2007 by Herbert Pötzl.
10831 + * Redistribution of this file is permitted under the
10832 + * GNU General Public License.
10833 + */
10834 +
10835 +#ifndef _LINUX_VROOT_H
10836 +#define _LINUX_VROOT_H
10837 +
10838 +
10839 +#ifdef __KERNEL__
10840 +
10841 +/* Possible states of device */
10842 +enum {
10843 +       Vr_unbound,
10844 +       Vr_bound,
10845 +};
10846 +
10847 +struct vroot_device {
10848 +       int             vr_number;
10849 +       int             vr_refcnt;
10850 +
10851 +       struct semaphore        vr_ctl_mutex;
10852 +       struct block_device    *vr_device;
10853 +       int                     vr_state;
10854 +};
10855 +
10856 +
10857 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
10858 +
10859 +extern int register_vroot_grb(vroot_grb_func *);
10860 +extern int unregister_vroot_grb(vroot_grb_func *);
10861 +
10862 +#endif /* __KERNEL__ */
10863 +
10864 +#define MAX_VROOT_DEFAULT      8
10865 +
10866 +/*
10867 + * IOCTL commands --- we will commandeer 0x56 ('V')
10868 + */
10869 +
10870 +#define VROOT_SET_DEV          0x5600
10871 +#define VROOT_CLR_DEV          0x5601
10872 +
10873 +#endif /* _LINUX_VROOT_H */
10874 diff -NurpP --minimal linux-2.6.35/include/linux/vs_base.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_base.h
10875 --- linux-2.6.35/include/linux/vs_base.h        1970-01-01 01:00:00.000000000 +0100
10876 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_base.h  2010-08-02 17:05:06.000000000 +0200
10877 @@ -0,0 +1,10 @@
10878 +#ifndef _VS_BASE_H
10879 +#define _VS_BASE_H
10880 +
10881 +#include "vserver/base.h"
10882 +#include "vserver/check.h"
10883 +#include "vserver/debug.h"
10884 +
10885 +#else
10886 +#warning duplicate inclusion
10887 +#endif
10888 diff -NurpP --minimal linux-2.6.35/include/linux/vs_context.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_context.h
10889 --- linux-2.6.35/include/linux/vs_context.h     1970-01-01 01:00:00.000000000 +0100
10890 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_context.h       2010-08-02 17:05:06.000000000 +0200
10891 @@ -0,0 +1,242 @@
10892 +#ifndef _VS_CONTEXT_H
10893 +#define _VS_CONTEXT_H
10894 +
10895 +#include "vserver/base.h"
10896 +#include "vserver/check.h"
10897 +#include "vserver/context.h"
10898 +#include "vserver/history.h"
10899 +#include "vserver/debug.h"
10900 +
10901 +#include <linux/sched.h>
10902 +
10903 +
10904 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
10905 +
10906 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
10907 +       const char *_file, int _line, void *_here)
10908 +{
10909 +       if (!vxi)
10910 +               return NULL;
10911 +
10912 +       vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
10913 +               vxi, vxi ? vxi->vx_id : 0,
10914 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10915 +               _file, _line);
10916 +       __vxh_get_vx_info(vxi, _here);
10917 +
10918 +       atomic_inc(&vxi->vx_usecnt);
10919 +       return vxi;
10920 +}
10921 +
10922 +
10923 +extern void free_vx_info(struct vx_info *);
10924 +
10925 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
10926 +
10927 +static inline void __put_vx_info(struct vx_info *vxi,
10928 +       const char *_file, int _line, void *_here)
10929 +{
10930 +       if (!vxi)
10931 +               return;
10932 +
10933 +       vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
10934 +               vxi, vxi ? vxi->vx_id : 0,
10935 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10936 +               _file, _line);
10937 +       __vxh_put_vx_info(vxi, _here);
10938 +
10939 +       if (atomic_dec_and_test(&vxi->vx_usecnt))
10940 +               free_vx_info(vxi);
10941 +}
10942 +
10943 +
10944 +#define init_vx_info(p, i) \
10945 +       __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10946 +
10947 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10948 +       const char *_file, int _line, void *_here)
10949 +{
10950 +       if (vxi) {
10951 +               vxlprintk(VXD_CBIT(xid, 3),
10952 +                       "init_vx_info(%p[#%d.%d])",
10953 +                       vxi, vxi ? vxi->vx_id : 0,
10954 +                       vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10955 +                       _file, _line);
10956 +               __vxh_init_vx_info(vxi, vxp, _here);
10957 +
10958 +               atomic_inc(&vxi->vx_usecnt);
10959 +       }
10960 +       *vxp = vxi;
10961 +}
10962 +
10963 +
10964 +#define set_vx_info(p, i) \
10965 +       __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10966 +
10967 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10968 +       const char *_file, int _line, void *_here)
10969 +{
10970 +       struct vx_info *vxo;
10971 +
10972 +       if (!vxi)
10973 +               return;
10974 +
10975 +       vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
10976 +               vxi, vxi ? vxi->vx_id : 0,
10977 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10978 +               _file, _line);
10979 +       __vxh_set_vx_info(vxi, vxp, _here);
10980 +
10981 +       atomic_inc(&vxi->vx_usecnt);
10982 +       vxo = xchg(vxp, vxi);
10983 +       BUG_ON(vxo);
10984 +}
10985 +
10986 +
10987 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
10988 +
10989 +static inline void __clr_vx_info(struct vx_info **vxp,
10990 +       const char *_file, int _line, void *_here)
10991 +{
10992 +       struct vx_info *vxo;
10993 +
10994 +       vxo = xchg(vxp, NULL);
10995 +       if (!vxo)
10996 +               return;
10997 +
10998 +       vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
10999 +               vxo, vxo ? vxo->vx_id : 0,
11000 +               vxo ? atomic_read(&vxo->vx_usecnt) : 0,
11001 +               _file, _line);
11002 +       __vxh_clr_vx_info(vxo, vxp, _here);
11003 +
11004 +       if (atomic_dec_and_test(&vxo->vx_usecnt))
11005 +               free_vx_info(vxo);
11006 +}
11007 +
11008 +
11009 +#define claim_vx_info(v, p) \
11010 +       __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11011 +
11012 +static inline void __claim_vx_info(struct vx_info *vxi,
11013 +       struct task_struct *task,
11014 +       const char *_file, int _line, void *_here)
11015 +{
11016 +       vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
11017 +               vxi, vxi ? vxi->vx_id : 0,
11018 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11019 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11020 +               task, _file, _line);
11021 +       __vxh_claim_vx_info(vxi, task, _here);
11022 +
11023 +       atomic_inc(&vxi->vx_tasks);
11024 +}
11025 +
11026 +
11027 +extern void unhash_vx_info(struct vx_info *);
11028 +
11029 +#define release_vx_info(v, p) \
11030 +       __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11031 +
11032 +static inline void __release_vx_info(struct vx_info *vxi,
11033 +       struct task_struct *task,
11034 +       const char *_file, int _line, void *_here)
11035 +{
11036 +       vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
11037 +               vxi, vxi ? vxi->vx_id : 0,
11038 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11039 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11040 +               task, _file, _line);
11041 +       __vxh_release_vx_info(vxi, task, _here);
11042 +
11043 +       might_sleep();
11044 +
11045 +       if (atomic_dec_and_test(&vxi->vx_tasks))
11046 +               unhash_vx_info(vxi);
11047 +}
11048 +
11049 +
11050 +#define task_get_vx_info(p) \
11051 +       __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
11052 +
11053 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
11054 +       const char *_file, int _line, void *_here)
11055 +{
11056 +       struct vx_info *vxi;
11057 +
11058 +       task_lock(p);
11059 +       vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
11060 +               p, _file, _line);
11061 +       vxi = __get_vx_info(p->vx_info, _file, _line, _here);
11062 +       task_unlock(p);
11063 +       return vxi;
11064 +}
11065 +
11066 +
11067 +static inline void __wakeup_vx_info(struct vx_info *vxi)
11068 +{
11069 +       if (waitqueue_active(&vxi->vx_wait))
11070 +               wake_up_interruptible(&vxi->vx_wait);
11071 +}
11072 +
11073 +
11074 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
11075 +
11076 +static inline void __enter_vx_info(struct vx_info *vxi,
11077 +       struct vx_info_save *vxis, const char *_file, int _line)
11078 +{
11079 +       vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
11080 +               vxi, vxi ? vxi->vx_id : 0, vxis, current,
11081 +               current->xid, current->vx_info, _file, _line);
11082 +       vxis->vxi = xchg(&current->vx_info, vxi);
11083 +       vxis->xid = current->xid;
11084 +       current->xid = vxi ? vxi->vx_id : 0;
11085 +}
11086 +
11087 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
11088 +
11089 +static inline void __leave_vx_info(struct vx_info_save *vxis,
11090 +       const char *_file, int _line)
11091 +{
11092 +       vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
11093 +               vxis, vxis->xid, vxis->vxi, current,
11094 +               current->xid, current->vx_info, _file, _line);
11095 +       (void)xchg(&current->vx_info, vxis->vxi);
11096 +       current->xid = vxis->xid;
11097 +}
11098 +
11099 +
11100 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
11101 +{
11102 +       vxis->vxi = xchg(&current->vx_info, NULL);
11103 +       vxis->xid = xchg(&current->xid, (xid_t)0);
11104 +}
11105 +
11106 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
11107 +{
11108 +       (void)xchg(&current->xid, vxis->xid);
11109 +       (void)xchg(&current->vx_info, vxis->vxi);
11110 +}
11111 +
11112 +#define task_is_init(p) \
11113 +       __task_is_init(p, __FILE__, __LINE__, __HERE__)
11114 +
11115 +static inline int __task_is_init(struct task_struct *p,
11116 +       const char *_file, int _line, void *_here)
11117 +{
11118 +       int is_init = is_global_init(p);
11119 +
11120 +       task_lock(p);
11121 +       if (p->vx_info)
11122 +               is_init = p->vx_info->vx_initpid == p->pid;
11123 +       task_unlock(p);
11124 +       return is_init;
11125 +}
11126 +
11127 +extern void exit_vx_info(struct task_struct *, int);
11128 +extern void exit_vx_info_early(struct task_struct *, int);
11129 +
11130 +
11131 +#else
11132 +#warning duplicate inclusion
11133 +#endif
11134 diff -NurpP --minimal linux-2.6.35/include/linux/vs_cowbl.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_cowbl.h
11135 --- linux-2.6.35/include/linux/vs_cowbl.h       1970-01-01 01:00:00.000000000 +0100
11136 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_cowbl.h 2010-08-02 21:01:17.000000000 +0200
11137 @@ -0,0 +1,48 @@
11138 +#ifndef _VS_COWBL_H
11139 +#define _VS_COWBL_H
11140 +
11141 +#include <linux/fs.h>
11142 +#include <linux/dcache.h>
11143 +#include <linux/namei.h>
11144 +#include <linux/slab.h>
11145 +
11146 +extern struct dentry *cow_break_link(const char *pathname);
11147 +
11148 +static inline int cow_check_and_break(struct path *path)
11149 +{
11150 +       struct inode *inode = path->dentry->d_inode;
11151 +       int error = 0;
11152 +
11153 +       /* do we need this check? */
11154 +       if (IS_RDONLY(inode))
11155 +               return -EROFS;
11156 +
11157 +       if (IS_COW(inode)) {
11158 +               if (IS_COW_LINK(inode)) {
11159 +                       struct dentry *new_dentry, *old_dentry = path->dentry;
11160 +                       char *pp, *buf;
11161 +
11162 +                       buf = kmalloc(PATH_MAX, GFP_KERNEL);
11163 +                       if (!buf) {
11164 +                               return -ENOMEM;
11165 +                       }
11166 +                       pp = d_path(path, buf, PATH_MAX);
11167 +                       new_dentry = cow_break_link(pp);
11168 +                       kfree(buf);
11169 +                       if (!IS_ERR(new_dentry)) {
11170 +                               path->dentry = new_dentry;
11171 +                               dput(old_dentry);
11172 +                       } else
11173 +                               error = PTR_ERR(new_dentry);
11174 +               } else {
11175 +                       inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
11176 +                       inode->i_ctime = CURRENT_TIME;
11177 +                       mark_inode_dirty(inode);
11178 +               }
11179 +       }
11180 +       return error;
11181 +}
11182 +
11183 +#else
11184 +#warning duplicate inclusion
11185 +#endif
11186 diff -NurpP --minimal linux-2.6.35/include/linux/vs_cvirt.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_cvirt.h
11187 --- linux-2.6.35/include/linux/vs_cvirt.h       1970-01-01 01:00:00.000000000 +0100
11188 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_cvirt.h 2010-08-02 17:05:06.000000000 +0200
11189 @@ -0,0 +1,50 @@
11190 +#ifndef _VS_CVIRT_H
11191 +#define _VS_CVIRT_H
11192 +
11193 +#include "vserver/cvirt.h"
11194 +#include "vserver/context.h"
11195 +#include "vserver/base.h"
11196 +#include "vserver/check.h"
11197 +#include "vserver/debug.h"
11198 +
11199 +
11200 +static inline void vx_activate_task(struct task_struct *p)
11201 +{
11202 +       struct vx_info *vxi;
11203 +
11204 +       if ((vxi = p->vx_info)) {
11205 +               vx_update_load(vxi);
11206 +               atomic_inc(&vxi->cvirt.nr_running);
11207 +       }
11208 +}
11209 +
11210 +static inline void vx_deactivate_task(struct task_struct *p)
11211 +{
11212 +       struct vx_info *vxi;
11213 +
11214 +       if ((vxi = p->vx_info)) {
11215 +               vx_update_load(vxi);
11216 +               atomic_dec(&vxi->cvirt.nr_running);
11217 +       }
11218 +}
11219 +
11220 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11221 +{
11222 +       struct vx_info *vxi;
11223 +
11224 +       if ((vxi = p->vx_info))
11225 +               atomic_inc(&vxi->cvirt.nr_uninterruptible);
11226 +}
11227 +
11228 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11229 +{
11230 +       struct vx_info *vxi;
11231 +
11232 +       if ((vxi = p->vx_info))
11233 +               atomic_dec(&vxi->cvirt.nr_uninterruptible);
11234 +}
11235 +
11236 +
11237 +#else
11238 +#warning duplicate inclusion
11239 +#endif
11240 diff -NurpP --minimal linux-2.6.35/include/linux/vs_device.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_device.h
11241 --- linux-2.6.35/include/linux/vs_device.h      1970-01-01 01:00:00.000000000 +0100
11242 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_device.h        2010-08-02 17:05:06.000000000 +0200
11243 @@ -0,0 +1,45 @@
11244 +#ifndef _VS_DEVICE_H
11245 +#define _VS_DEVICE_H
11246 +
11247 +#include "vserver/base.h"
11248 +#include "vserver/device.h"
11249 +#include "vserver/debug.h"
11250 +
11251 +
11252 +#ifdef CONFIG_VSERVER_DEVICE
11253 +
11254 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
11255 +
11256 +#define vs_device_perm(v, d, m, p) \
11257 +       ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
11258 +
11259 +#else
11260 +
11261 +static inline
11262 +int vs_map_device(struct vx_info *vxi,
11263 +       dev_t device, dev_t *target, umode_t mode)
11264 +{
11265 +       if (target)
11266 +               *target = device;
11267 +       return ~0;
11268 +}
11269 +
11270 +#define vs_device_perm(v, d, m, p) ((p) == (p))
11271 +
11272 +#endif
11273 +
11274 +
11275 +#define vs_map_chrdev(d, t, p) \
11276 +       ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
11277 +#define vs_map_blkdev(d, t, p) \
11278 +       ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
11279 +
11280 +#define vs_chrdev_perm(d, p) \
11281 +       vs_device_perm(current_vx_info(), d, S_IFCHR, p)
11282 +#define vs_blkdev_perm(d, p) \
11283 +       vs_device_perm(current_vx_info(), d, S_IFBLK, p)
11284 +
11285 +
11286 +#else
11287 +#warning duplicate inclusion
11288 +#endif
11289 diff -NurpP --minimal linux-2.6.35/include/linux/vs_dlimit.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_dlimit.h
11290 --- linux-2.6.35/include/linux/vs_dlimit.h      1970-01-01 01:00:00.000000000 +0100
11291 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_dlimit.h        2010-08-02 22:21:17.000000000 +0200
11292 @@ -0,0 +1,215 @@
11293 +#ifndef _VS_DLIMIT_H
11294 +#define _VS_DLIMIT_H
11295 +
11296 +#include <linux/fs.h>
11297 +
11298 +#include "vserver/dlimit.h"
11299 +#include "vserver/base.h"
11300 +#include "vserver/debug.h"
11301 +
11302 +
11303 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11304 +
11305 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11306 +       const char *_file, int _line)
11307 +{
11308 +       if (!dli)
11309 +               return NULL;
11310 +       vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11311 +               dli, dli ? dli->dl_tag : 0,
11312 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11313 +               _file, _line);
11314 +       atomic_inc(&dli->dl_usecnt);
11315 +       return dli;
11316 +}
11317 +
11318 +
11319 +#define free_dl_info(i) \
11320 +       call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11321 +
11322 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11323 +
11324 +static inline void __put_dl_info(struct dl_info *dli,
11325 +       const char *_file, int _line)
11326 +{
11327 +       if (!dli)
11328 +               return;
11329 +       vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11330 +               dli, dli ? dli->dl_tag : 0,
11331 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11332 +               _file, _line);
11333 +       if (atomic_dec_and_test(&dli->dl_usecnt))
11334 +               free_dl_info(dli);
11335 +}
11336 +
11337 +
11338 +#define __dlimit_char(d)       ((d) ? '*' : ' ')
11339 +
11340 +static inline int __dl_alloc_space(struct super_block *sb,
11341 +       tag_t tag, dlsize_t nr, const char *file, int line)
11342 +{
11343 +       struct dl_info *dli = NULL;
11344 +       int ret = 0;
11345 +
11346 +       if (nr == 0)
11347 +               goto out;
11348 +       dli = locate_dl_info(sb, tag);
11349 +       if (!dli)
11350 +               goto out;
11351 +
11352 +       spin_lock(&dli->dl_lock);
11353 +       ret = (dli->dl_space_used + nr > dli->dl_space_total);
11354 +       if (!ret)
11355 +               dli->dl_space_used += nr;
11356 +       spin_unlock(&dli->dl_lock);
11357 +       put_dl_info(dli);
11358 +out:
11359 +       vxlprintk(VXD_CBIT(dlim, 1),
11360 +               "ALLOC (%p,#%d)%c %lld bytes (%d)",
11361 +               sb, tag, __dlimit_char(dli), (long long)nr,
11362 +               ret, file, line);
11363 +       return ret ? -ENOSPC : 0;
11364 +}
11365 +
11366 +static inline void __dl_free_space(struct super_block *sb,
11367 +       tag_t tag, dlsize_t nr, const char *_file, int _line)
11368 +{
11369 +       struct dl_info *dli = NULL;
11370 +
11371 +       if (nr == 0)
11372 +               goto out;
11373 +       dli = locate_dl_info(sb, tag);
11374 +       if (!dli)
11375 +               goto out;
11376 +
11377 +       spin_lock(&dli->dl_lock);
11378 +       if (dli->dl_space_used > nr)
11379 +               dli->dl_space_used -= nr;
11380 +       else
11381 +               dli->dl_space_used = 0;
11382 +       spin_unlock(&dli->dl_lock);
11383 +       put_dl_info(dli);
11384 +out:
11385 +       vxlprintk(VXD_CBIT(dlim, 1),
11386 +               "FREE  (%p,#%d)%c %lld bytes",
11387 +               sb, tag, __dlimit_char(dli), (long long)nr,
11388 +               _file, _line);
11389 +}
11390 +
11391 +static inline int __dl_alloc_inode(struct super_block *sb,
11392 +       tag_t tag, const char *_file, int _line)
11393 +{
11394 +       struct dl_info *dli;
11395 +       int ret = 0;
11396 +
11397 +       dli = locate_dl_info(sb, tag);
11398 +       if (!dli)
11399 +               goto out;
11400 +
11401 +       spin_lock(&dli->dl_lock);
11402 +       dli->dl_inodes_used++;
11403 +       ret = (dli->dl_inodes_used > dli->dl_inodes_total);
11404 +       spin_unlock(&dli->dl_lock);
11405 +       put_dl_info(dli);
11406 +out:
11407 +       vxlprintk(VXD_CBIT(dlim, 0),
11408 +               "ALLOC (%p,#%d)%c inode (%d)",
11409 +               sb, tag, __dlimit_char(dli), ret, _file, _line);
11410 +       return ret ? -ENOSPC : 0;
11411 +}
11412 +
11413 +static inline void __dl_free_inode(struct super_block *sb,
11414 +       tag_t tag, const char *_file, int _line)
11415 +{
11416 +       struct dl_info *dli;
11417 +
11418 +       dli = locate_dl_info(sb, tag);
11419 +       if (!dli)
11420 +               goto out;
11421 +
11422 +       spin_lock(&dli->dl_lock);
11423 +       if (dli->dl_inodes_used > 1)
11424 +               dli->dl_inodes_used--;
11425 +       else
11426 +               dli->dl_inodes_used = 0;
11427 +       spin_unlock(&dli->dl_lock);
11428 +       put_dl_info(dli);
11429 +out:
11430 +       vxlprintk(VXD_CBIT(dlim, 0),
11431 +               "FREE  (%p,#%d)%c inode",
11432 +               sb, tag, __dlimit_char(dli), _file, _line);
11433 +}
11434 +
11435 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11436 +       unsigned long long *free_blocks, unsigned long long *root_blocks,
11437 +       const char *_file, int _line)
11438 +{
11439 +       struct dl_info *dli;
11440 +       uint64_t broot, bfree;
11441 +
11442 +       dli = locate_dl_info(sb, tag);
11443 +       if (!dli)
11444 +               return;
11445 +
11446 +       spin_lock(&dli->dl_lock);
11447 +       broot = (dli->dl_space_total -
11448 +               (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11449 +               >> sb->s_blocksize_bits;
11450 +       bfree = (dli->dl_space_total - dli->dl_space_used)
11451 +                       >> sb->s_blocksize_bits;
11452 +       spin_unlock(&dli->dl_lock);
11453 +
11454 +       vxlprintk(VXD_CBIT(dlim, 2),
11455 +               "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11456 +               (long long)bfree, (long long)broot,
11457 +               *free_blocks, *root_blocks, dli->dl_nrlmult,
11458 +               _file, _line);
11459 +       if (free_blocks) {
11460 +               if (*free_blocks > bfree)
11461 +                       *free_blocks = bfree;
11462 +       }
11463 +       if (root_blocks) {
11464 +               if (*root_blocks > broot)
11465 +                       *root_blocks = broot;
11466 +       }
11467 +       put_dl_info(dli);
11468 +}
11469 +
11470 +#define dl_prealloc_space(in, bytes) \
11471 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11472 +               __FILE__, __LINE__ )
11473 +
11474 +#define dl_alloc_space(in, bytes) \
11475 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11476 +               __FILE__, __LINE__ )
11477 +
11478 +#define dl_reserve_space(in, bytes) \
11479 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11480 +               __FILE__, __LINE__ )
11481 +
11482 +#define dl_claim_space(in, bytes) (0)
11483 +
11484 +#define dl_release_space(in, bytes) \
11485 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11486 +               __FILE__, __LINE__ )
11487 +
11488 +#define dl_free_space(in, bytes) \
11489 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11490 +               __FILE__, __LINE__ )
11491 +
11492 +
11493 +
11494 +#define dl_alloc_inode(in) \
11495 +       __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11496 +
11497 +#define dl_free_inode(in) \
11498 +       __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11499 +
11500 +
11501 +#define dl_adjust_block(sb, tag, fb, rb) \
11502 +       __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11503 +
11504 +
11505 +#else
11506 +#warning duplicate inclusion
11507 +#endif
11508 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/base.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/base.h
11509 --- linux-2.6.35/include/linux/vserver/base.h   1970-01-01 01:00:00.000000000 +0100
11510 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/base.h     2010-08-02 17:05:06.000000000 +0200
11511 @@ -0,0 +1,170 @@
11512 +#ifndef _VX_BASE_H
11513 +#define _VX_BASE_H
11514 +
11515 +
11516 +/* context state changes */
11517 +
11518 +enum {
11519 +       VSC_STARTUP = 1,
11520 +       VSC_SHUTDOWN,
11521 +
11522 +       VSC_NETUP,
11523 +       VSC_NETDOWN,
11524 +};
11525 +
11526 +
11527 +
11528 +#define vx_task_xid(t) ((t)->xid)
11529 +
11530 +#define vx_current_xid() vx_task_xid(current)
11531 +
11532 +#define current_vx_info() (current->vx_info)
11533 +
11534 +
11535 +#define nx_task_nid(t) ((t)->nid)
11536 +
11537 +#define nx_current_nid() nx_task_nid(current)
11538 +
11539 +#define current_nx_info() (current->nx_info)
11540 +
11541 +
11542 +/* generic flag merging */
11543 +
11544 +#define vs_check_flags(v, m, f)        (((v) & (m)) ^ (f))
11545 +
11546 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11547 +
11548 +#define vs_mask_mask(v, f, m)  (((v) & ~(m)) | ((v) & (f) & (m)))
11549 +
11550 +#define vs_check_bit(v, n)     ((v) & (1LL << (n)))
11551 +
11552 +
11553 +/* context flags */
11554 +
11555 +#define __vx_flags(v)  ((v) ? (v)->vx_flags : 0)
11556 +
11557 +#define vx_current_flags()     __vx_flags(current_vx_info())
11558 +
11559 +#define vx_info_flags(v, m, f) \
11560 +       vs_check_flags(__vx_flags(v), m, f)
11561 +
11562 +#define task_vx_flags(t, m, f) \
11563 +       ((t) && vx_info_flags((t)->vx_info, m, f))
11564 +
11565 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11566 +
11567 +
11568 +/* context caps */
11569 +
11570 +#define __vx_ccaps(v)  ((v) ? (v)->vx_ccaps : 0)
11571 +
11572 +#define vx_current_ccaps()     __vx_ccaps(current_vx_info())
11573 +
11574 +#define vx_info_ccaps(v, c)    (__vx_ccaps(v) & (c))
11575 +
11576 +#define vx_ccaps(c)    vx_info_ccaps(current_vx_info(), (c))
11577 +
11578 +
11579 +
11580 +/* network flags */
11581 +
11582 +#define __nx_flags(n)  ((n) ? (n)->nx_flags : 0)
11583 +
11584 +#define nx_current_flags()     __nx_flags(current_nx_info())
11585 +
11586 +#define nx_info_flags(n, m, f) \
11587 +       vs_check_flags(__nx_flags(n), m, f)
11588 +
11589 +#define task_nx_flags(t, m, f) \
11590 +       ((t) && nx_info_flags((t)->nx_info, m, f))
11591 +
11592 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11593 +
11594 +
11595 +/* network caps */
11596 +
11597 +#define __nx_ncaps(n)  ((n) ? (n)->nx_ncaps : 0)
11598 +
11599 +#define nx_current_ncaps()     __nx_ncaps(current_nx_info())
11600 +
11601 +#define nx_info_ncaps(n, c)    (__nx_ncaps(n) & (c))
11602 +
11603 +#define nx_ncaps(c)    nx_info_ncaps(current_nx_info(), c)
11604 +
11605 +
11606 +/* context mask capabilities */
11607 +
11608 +#define __vx_mcaps(v)  ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11609 +
11610 +#define vx_info_mcaps(v, c)    (__vx_mcaps(v) & (c))
11611 +
11612 +#define vx_mcaps(c)    vx_info_mcaps(current_vx_info(), c)
11613 +
11614 +
11615 +/* context bcap mask */
11616 +
11617 +#define __vx_bcaps(v)          ((v)->vx_bcaps)
11618 +
11619 +#define vx_current_bcaps()     __vx_bcaps(current_vx_info())
11620 +
11621 +
11622 +/* mask given bcaps */
11623 +
11624 +#define vx_info_mbcaps(v, c)   ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11625 +
11626 +#define vx_mbcaps(c)           vx_info_mbcaps(current_vx_info(), c)
11627 +
11628 +
11629 +/* masked cap_bset */
11630 +
11631 +#define vx_info_cap_bset(v)    vx_info_mbcaps(v, current->cap_bset)
11632 +
11633 +#define vx_current_cap_bset()  vx_info_cap_bset(current_vx_info())
11634 +
11635 +#if 0
11636 +#define vx_info_mbcap(v, b) \
11637 +       (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11638 +       vx_info_bcaps(v, b) : (b))
11639 +
11640 +#define task_vx_mbcap(t, b) \
11641 +       vx_info_mbcap((t)->vx_info, (t)->b)
11642 +
11643 +#define vx_mbcap(b)    task_vx_mbcap(current, b)
11644 +#endif
11645 +
11646 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11647 +
11648 +#define vx_capable(b, c) (capable(b) || \
11649 +       (cap_raised(current_cap(), b) && vx_ccaps(c)))
11650 +
11651 +#define nx_capable(b, c) (capable(b) || \
11652 +       (cap_raised(current_cap(), b) && nx_ncaps(c)))
11653 +
11654 +#define vx_task_initpid(t, n) \
11655 +       ((t)->vx_info && \
11656 +       ((t)->vx_info->vx_initpid == (n)))
11657 +
11658 +#define vx_current_initpid(n)  vx_task_initpid(current, n)
11659 +
11660 +
11661 +/* context unshare mask */
11662 +
11663 +#define __vx_umask(v)          ((v)->vx_umask)
11664 +
11665 +#define vx_current_umask()     __vx_umask(current_vx_info())
11666 +
11667 +#define vx_can_unshare(b, f) (capable(b) || \
11668 +       (cap_raised(current_cap(), b) && \
11669 +       !((f) & ~vx_current_umask())))
11670 +
11671 +
11672 +#define __vx_state(v)  ((v) ? ((v)->vx_state) : 0)
11673 +
11674 +#define vx_info_state(v, m)    (__vx_state(v) & (m))
11675 +
11676 +
11677 +#define __nx_state(n)  ((n) ? ((n)->nx_state) : 0)
11678 +
11679 +#define nx_info_state(n, m)    (__nx_state(n) & (m))
11680 +
11681 +#endif
11682 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cacct_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_cmd.h
11683 --- linux-2.6.35/include/linux/vserver/cacct_cmd.h      1970-01-01 01:00:00.000000000 +0100
11684 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_cmd.h        2010-08-02 17:05:06.000000000 +0200
11685 @@ -0,0 +1,23 @@
11686 +#ifndef _VX_CACCT_CMD_H
11687 +#define _VX_CACCT_CMD_H
11688 +
11689 +
11690 +/* virtual host info name commands */
11691 +
11692 +#define VCMD_sock_stat         VC_CMD(VSTAT, 5, 0)
11693 +
11694 +struct vcmd_sock_stat_v0 {
11695 +       uint32_t field;
11696 +       uint32_t count[3];
11697 +       uint64_t total[3];
11698 +};
11699 +
11700 +
11701 +#ifdef __KERNEL__
11702 +
11703 +#include <linux/compiler.h>
11704 +
11705 +extern int vc_sock_stat(struct vx_info *, void __user *);
11706 +
11707 +#endif /* __KERNEL__ */
11708 +#endif /* _VX_CACCT_CMD_H */
11709 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cacct_def.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_def.h
11710 --- linux-2.6.35/include/linux/vserver/cacct_def.h      1970-01-01 01:00:00.000000000 +0100
11711 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_def.h        2010-08-02 17:05:06.000000000 +0200
11712 @@ -0,0 +1,43 @@
11713 +#ifndef _VX_CACCT_DEF_H
11714 +#define _VX_CACCT_DEF_H
11715 +
11716 +#include <asm/atomic.h>
11717 +#include <linux/vserver/cacct.h>
11718 +
11719 +
11720 +struct _vx_sock_acc {
11721 +       atomic_long_t count;
11722 +       atomic_long_t total;
11723 +};
11724 +
11725 +/* context sub struct */
11726 +
11727 +struct _vx_cacct {
11728 +       struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11729 +       atomic_t slab[8];
11730 +       atomic_t page[6][8];
11731 +};
11732 +
11733 +#ifdef CONFIG_VSERVER_DEBUG
11734 +
11735 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11736 +{
11737 +       int i, j;
11738 +
11739 +       printk("\t_vx_cacct:");
11740 +       for (i = 0; i < 6; i++) {
11741 +               struct _vx_sock_acc *ptr = cacct->sock[i];
11742 +
11743 +               printk("\t [%d] =", i);
11744 +               for (j = 0; j < 3; j++) {
11745 +                       printk(" [%d] = %8lu, %8lu", j,
11746 +                               atomic_long_read(&ptr[j].count),
11747 +                               atomic_long_read(&ptr[j].total));
11748 +               }
11749 +               printk("\n");
11750 +       }
11751 +}
11752 +
11753 +#endif
11754 +
11755 +#endif /* _VX_CACCT_DEF_H */
11756 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cacct.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct.h
11757 --- linux-2.6.35/include/linux/vserver/cacct.h  1970-01-01 01:00:00.000000000 +0100
11758 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct.h    2010-08-02 17:05:06.000000000 +0200
11759 @@ -0,0 +1,15 @@
11760 +#ifndef _VX_CACCT_H
11761 +#define _VX_CACCT_H
11762 +
11763 +
11764 +enum sock_acc_field {
11765 +       VXA_SOCK_UNSPEC = 0,
11766 +       VXA_SOCK_UNIX,
11767 +       VXA_SOCK_INET,
11768 +       VXA_SOCK_INET6,
11769 +       VXA_SOCK_PACKET,
11770 +       VXA_SOCK_OTHER,
11771 +       VXA_SOCK_SIZE   /* array size */
11772 +};
11773 +
11774 +#endif /* _VX_CACCT_H */
11775 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cacct_int.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_int.h
11776 --- linux-2.6.35/include/linux/vserver/cacct_int.h      1970-01-01 01:00:00.000000000 +0100
11777 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cacct_int.h        2010-08-02 17:05:06.000000000 +0200
11778 @@ -0,0 +1,21 @@
11779 +#ifndef _VX_CACCT_INT_H
11780 +#define _VX_CACCT_INT_H
11781 +
11782 +
11783 +#ifdef __KERNEL__
11784 +
11785 +static inline
11786 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11787 +{
11788 +       return atomic_long_read(&cacct->sock[type][pos].count);
11789 +}
11790 +
11791 +
11792 +static inline
11793 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11794 +{
11795 +       return atomic_long_read(&cacct->sock[type][pos].total);
11796 +}
11797 +
11798 +#endif /* __KERNEL__ */
11799 +#endif /* _VX_CACCT_INT_H */
11800 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/check.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/check.h
11801 --- linux-2.6.35/include/linux/vserver/check.h  1970-01-01 01:00:00.000000000 +0100
11802 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/check.h    2010-08-02 17:05:06.000000000 +0200
11803 @@ -0,0 +1,89 @@
11804 +#ifndef _VS_CHECK_H
11805 +#define _VS_CHECK_H
11806 +
11807 +
11808 +#define MAX_S_CONTEXT  65535   /* Arbitrary limit */
11809 +
11810 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11811 +#define MIN_D_CONTEXT  49152   /* dynamic contexts start here */
11812 +#else
11813 +#define MIN_D_CONTEXT  65536
11814 +#endif
11815 +
11816 +/* check conditions */
11817 +
11818 +#define VS_ADMIN       0x0001
11819 +#define VS_WATCH       0x0002
11820 +#define VS_HIDE                0x0004
11821 +#define VS_HOSTID      0x0008
11822 +
11823 +#define VS_IDENT       0x0010
11824 +#define VS_EQUIV       0x0020
11825 +#define VS_PARENT      0x0040
11826 +#define VS_CHILD       0x0080
11827 +
11828 +#define VS_ARG_MASK    0x00F0
11829 +
11830 +#define VS_DYNAMIC     0x0100
11831 +#define VS_STATIC      0x0200
11832 +
11833 +#define VS_ATR_MASK    0x0F00
11834 +
11835 +#ifdef CONFIG_VSERVER_PRIVACY
11836 +#define VS_ADMIN_P     (0)
11837 +#define VS_WATCH_P     (0)
11838 +#else
11839 +#define VS_ADMIN_P     VS_ADMIN
11840 +#define VS_WATCH_P     VS_WATCH
11841 +#endif
11842 +
11843 +#define VS_HARDIRQ     0x1000
11844 +#define VS_SOFTIRQ     0x2000
11845 +#define VS_IRQ         0x4000
11846 +
11847 +#define VS_IRQ_MASK    0xF000
11848 +
11849 +#include <linux/hardirq.h>
11850 +
11851 +/*
11852 + * check current context for ADMIN/WATCH and
11853 + * optionally against supplied argument
11854 + */
11855 +static inline int __vs_check(int cid, int id, unsigned int mode)
11856 +{
11857 +       if (mode & VS_ARG_MASK) {
11858 +               if ((mode & VS_IDENT) && (id == cid))
11859 +                       return 1;
11860 +       }
11861 +       if (mode & VS_ATR_MASK) {
11862 +               if ((mode & VS_DYNAMIC) &&
11863 +                       (id >= MIN_D_CONTEXT) &&
11864 +                       (id <= MAX_S_CONTEXT))
11865 +                       return 1;
11866 +               if ((mode & VS_STATIC) &&
11867 +                       (id > 1) && (id < MIN_D_CONTEXT))
11868 +                       return 1;
11869 +       }
11870 +       if (mode & VS_IRQ_MASK) {
11871 +               if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11872 +                       return 1;
11873 +               if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11874 +                       return 1;
11875 +               if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11876 +                       return 1;
11877 +       }
11878 +       return (((mode & VS_ADMIN) && (cid == 0)) ||
11879 +               ((mode & VS_WATCH) && (cid == 1)) ||
11880 +               ((mode & VS_HOSTID) && (id == 0)));
11881 +}
11882 +
11883 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11884 +
11885 +#define vx_weak_check(c, m)    ((m) ? vx_check(c, m) : 1)
11886 +
11887 +
11888 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11889 +
11890 +#define nx_weak_check(c, m)    ((m) ? nx_check(c, m) : 1)
11891 +
11892 +#endif
11893 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/context_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/context_cmd.h
11894 --- linux-2.6.35/include/linux/vserver/context_cmd.h    1970-01-01 01:00:00.000000000 +0100
11895 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/context_cmd.h      2010-08-02 17:05:06.000000000 +0200
11896 @@ -0,0 +1,145 @@
11897 +#ifndef _VX_CONTEXT_CMD_H
11898 +#define _VX_CONTEXT_CMD_H
11899 +
11900 +
11901 +/* vinfo commands */
11902 +
11903 +#define VCMD_task_xid          VC_CMD(VINFO, 1, 0)
11904 +
11905 +#ifdef __KERNEL__
11906 +extern int vc_task_xid(uint32_t);
11907 +
11908 +#endif /* __KERNEL__ */
11909 +
11910 +#define VCMD_vx_info           VC_CMD(VINFO, 5, 0)
11911 +
11912 +struct vcmd_vx_info_v0 {
11913 +       uint32_t xid;
11914 +       uint32_t initpid;
11915 +       /* more to come */
11916 +};
11917 +
11918 +#ifdef __KERNEL__
11919 +extern int vc_vx_info(struct vx_info *, void __user *);
11920 +
11921 +#endif /* __KERNEL__ */
11922 +
11923 +#define VCMD_ctx_stat          VC_CMD(VSTAT, 0, 0)
11924 +
11925 +struct vcmd_ctx_stat_v0 {
11926 +       uint32_t usecnt;
11927 +       uint32_t tasks;
11928 +       /* more to come */
11929 +};
11930 +
11931 +#ifdef __KERNEL__
11932 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11933 +
11934 +#endif /* __KERNEL__ */
11935 +
11936 +/* context commands */
11937 +
11938 +#define VCMD_ctx_create_v0     VC_CMD(VPROC, 1, 0)
11939 +#define VCMD_ctx_create                VC_CMD(VPROC, 1, 1)
11940 +
11941 +struct vcmd_ctx_create {
11942 +       uint64_t flagword;
11943 +};
11944 +
11945 +#define VCMD_ctx_migrate_v0    VC_CMD(PROCMIG, 1, 0)
11946 +#define VCMD_ctx_migrate       VC_CMD(PROCMIG, 1, 1)
11947 +
11948 +struct vcmd_ctx_migrate {
11949 +       uint64_t flagword;
11950 +};
11951 +
11952 +#ifdef __KERNEL__
11953 +extern int vc_ctx_create(uint32_t, void __user *);
11954 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11955 +
11956 +#endif /* __KERNEL__ */
11957 +
11958 +
11959 +/* flag commands */
11960 +
11961 +#define VCMD_get_cflags                VC_CMD(FLAGS, 1, 0)
11962 +#define VCMD_set_cflags                VC_CMD(FLAGS, 2, 0)
11963 +
11964 +struct vcmd_ctx_flags_v0 {
11965 +       uint64_t flagword;
11966 +       uint64_t mask;
11967 +};
11968 +
11969 +#ifdef __KERNEL__
11970 +extern int vc_get_cflags(struct vx_info *, void __user *);
11971 +extern int vc_set_cflags(struct vx_info *, void __user *);
11972 +
11973 +#endif /* __KERNEL__ */
11974 +
11975 +
11976 +/* context caps commands */
11977 +
11978 +#define VCMD_get_ccaps         VC_CMD(FLAGS, 3, 1)
11979 +#define VCMD_set_ccaps         VC_CMD(FLAGS, 4, 1)
11980 +
11981 +struct vcmd_ctx_caps_v1 {
11982 +       uint64_t ccaps;
11983 +       uint64_t cmask;
11984 +};
11985 +
11986 +#ifdef __KERNEL__
11987 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11988 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11989 +
11990 +#endif /* __KERNEL__ */
11991 +
11992 +
11993 +/* bcaps commands */
11994 +
11995 +#define VCMD_get_bcaps         VC_CMD(FLAGS, 9, 0)
11996 +#define VCMD_set_bcaps         VC_CMD(FLAGS, 10, 0)
11997 +
11998 +struct vcmd_bcaps {
11999 +       uint64_t bcaps;
12000 +       uint64_t bmask;
12001 +};
12002 +
12003 +#ifdef __KERNEL__
12004 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12005 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12006 +
12007 +#endif /* __KERNEL__ */
12008 +
12009 +
12010 +/* umask commands */
12011 +
12012 +#define VCMD_get_umask         VC_CMD(FLAGS, 13, 0)
12013 +#define VCMD_set_umask         VC_CMD(FLAGS, 14, 0)
12014 +
12015 +struct vcmd_umask {
12016 +       uint64_t umask;
12017 +       uint64_t mask;
12018 +};
12019 +
12020 +#ifdef __KERNEL__
12021 +extern int vc_get_umask(struct vx_info *, void __user *);
12022 +extern int vc_set_umask(struct vx_info *, void __user *);
12023 +
12024 +#endif /* __KERNEL__ */
12025 +
12026 +
12027 +/* OOM badness */
12028 +
12029 +#define VCMD_get_badness       VC_CMD(MEMCTRL, 5, 0)
12030 +#define VCMD_set_badness       VC_CMD(MEMCTRL, 6, 0)
12031 +
12032 +struct vcmd_badness_v0 {
12033 +       int64_t bias;
12034 +};
12035 +
12036 +#ifdef __KERNEL__
12037 +extern int vc_get_badness(struct vx_info *, void __user *);
12038 +extern int vc_set_badness(struct vx_info *, void __user *);
12039 +
12040 +#endif /* __KERNEL__ */
12041 +#endif /* _VX_CONTEXT_CMD_H */
12042 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/context.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/context.h
12043 --- linux-2.6.35/include/linux/vserver/context.h        1970-01-01 01:00:00.000000000 +0100
12044 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/context.h  2010-08-02 17:05:06.000000000 +0200
12045 @@ -0,0 +1,184 @@
12046 +#ifndef _VX_CONTEXT_H
12047 +#define _VX_CONTEXT_H
12048 +
12049 +#include <linux/types.h>
12050 +#include <linux/capability.h>
12051 +
12052 +
12053 +/* context flags */
12054 +
12055 +#define VXF_INFO_SCHED         0x00000002
12056 +#define VXF_INFO_NPROC         0x00000004
12057 +#define VXF_INFO_PRIVATE       0x00000008
12058 +
12059 +#define VXF_INFO_INIT          0x00000010
12060 +#define VXF_INFO_HIDE          0x00000020
12061 +#define VXF_INFO_ULIMIT                0x00000040
12062 +#define VXF_INFO_NSPACE                0x00000080
12063 +
12064 +#define VXF_SCHED_HARD         0x00000100
12065 +#define VXF_SCHED_PRIO         0x00000200
12066 +#define VXF_SCHED_PAUSE                0x00000400
12067 +
12068 +#define VXF_VIRT_MEM           0x00010000
12069 +#define VXF_VIRT_UPTIME                0x00020000
12070 +#define VXF_VIRT_CPU           0x00040000
12071 +#define VXF_VIRT_LOAD          0x00080000
12072 +#define VXF_VIRT_TIME          0x00100000
12073 +
12074 +#define VXF_HIDE_MOUNT         0x01000000
12075 +/* was VXF_HIDE_NETIF          0x02000000 */
12076 +#define VXF_HIDE_VINFO         0x04000000
12077 +
12078 +#define VXF_STATE_SETUP                (1ULL << 32)
12079 +#define VXF_STATE_INIT         (1ULL << 33)
12080 +#define VXF_STATE_ADMIN                (1ULL << 34)
12081 +
12082 +#define VXF_SC_HELPER          (1ULL << 36)
12083 +#define VXF_REBOOT_KILL                (1ULL << 37)
12084 +#define VXF_PERSISTENT         (1ULL << 38)
12085 +
12086 +#define VXF_FORK_RSS           (1ULL << 48)
12087 +#define VXF_PROLIFIC           (1ULL << 49)
12088 +
12089 +#define VXF_IGNEG_NICE         (1ULL << 52)
12090 +
12091 +#define VXF_ONE_TIME           (0x0007ULL << 32)
12092 +
12093 +#define VXF_INIT_SET           (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12094 +
12095 +
12096 +/* context migration */
12097 +
12098 +#define VXM_SET_INIT           0x00000001
12099 +#define VXM_SET_REAPER         0x00000002
12100 +
12101 +/* context caps */
12102 +
12103 +#define VXC_CAP_MASK           0x00000000
12104 +
12105 +#define VXC_SET_UTSNAME                0x00000001
12106 +#define VXC_SET_RLIMIT         0x00000002
12107 +#define VXC_FS_SECURITY                0x00000004
12108 +#define VXC_FS_TRUSTED         0x00000008
12109 +#define VXC_TIOCSTI            0x00000010
12110 +
12111 +/* was VXC_RAW_ICMP            0x00000100 */
12112 +#define VXC_SYSLOG             0x00001000
12113 +#define VXC_OOM_ADJUST         0x00002000
12114 +#define VXC_AUDIT_CONTROL      0x00004000
12115 +
12116 +#define VXC_SECURE_MOUNT       0x00010000
12117 +#define VXC_SECURE_REMOUNT     0x00020000
12118 +#define VXC_BINARY_MOUNT       0x00040000
12119 +
12120 +#define VXC_QUOTA_CTL          0x00100000
12121 +#define VXC_ADMIN_MAPPER       0x00200000
12122 +#define VXC_ADMIN_CLOOP                0x00400000
12123 +
12124 +#define VXC_KTHREAD            0x01000000
12125 +#define VXC_NAMESPACE          0x02000000
12126 +
12127 +
12128 +#ifdef __KERNEL__
12129 +
12130 +#include <linux/list.h>
12131 +#include <linux/spinlock.h>
12132 +#include <linux/rcupdate.h>
12133 +
12134 +#include "limit_def.h"
12135 +#include "sched_def.h"
12136 +#include "cvirt_def.h"
12137 +#include "cacct_def.h"
12138 +#include "device_def.h"
12139 +
12140 +#define VX_SPACES      2
12141 +
12142 +struct _vx_info_pc {
12143 +       struct _vx_sched_pc sched_pc;
12144 +       struct _vx_cvirt_pc cvirt_pc;
12145 +};
12146 +
12147 +struct vx_info {
12148 +       struct hlist_node vx_hlist;             /* linked list of contexts */
12149 +       xid_t vx_id;                            /* context id */
12150 +       atomic_t vx_usecnt;                     /* usage count */
12151 +       atomic_t vx_tasks;                      /* tasks count */
12152 +       struct vx_info *vx_parent;              /* parent context */
12153 +       int vx_state;                           /* context state */
12154 +
12155 +       unsigned long vx_nsmask[VX_SPACES];     /* assignment mask */
12156 +       struct nsproxy *vx_nsproxy[VX_SPACES];  /* private namespaces */
12157 +       struct fs_struct *vx_fs[VX_SPACES];     /* private namespace fs */
12158 +
12159 +       uint64_t vx_flags;                      /* context flags */
12160 +       uint64_t vx_ccaps;                      /* context caps (vserver) */
12161 +       kernel_cap_t vx_bcaps;                  /* bounding caps (system) */
12162 +       unsigned long vx_umask;                 /* unshare mask (guest) */
12163 +
12164 +       struct task_struct *vx_reaper;          /* guest reaper process */
12165 +       pid_t vx_initpid;                       /* PID of guest init */
12166 +       int64_t vx_badness_bias;                /* OOM points bias */
12167 +
12168 +       struct _vx_limit limit;                 /* vserver limits */
12169 +       struct _vx_sched sched;                 /* vserver scheduler */
12170 +       struct _vx_cvirt cvirt;                 /* virtual/bias stuff */
12171 +       struct _vx_cacct cacct;                 /* context accounting */
12172 +
12173 +       struct _vx_device dmap;                 /* default device map targets */
12174 +
12175 +#ifndef CONFIG_SMP
12176 +       struct _vx_info_pc info_pc;             /* per cpu data */
12177 +#else
12178 +       struct _vx_info_pc *ptr_pc;             /* per cpu array */
12179 +#endif
12180 +
12181 +       wait_queue_head_t vx_wait;              /* context exit waitqueue */
12182 +       int reboot_cmd;                         /* last sys_reboot() cmd */
12183 +       int exit_code;                          /* last process exit code */
12184 +
12185 +       char vx_name[65];                       /* vserver name */
12186 +};
12187 +
12188 +#ifndef CONFIG_SMP
12189 +#define        vx_ptr_pc(vxi)          (&(vxi)->info_pc)
12190 +#define        vx_per_cpu(vxi, v, id)  vx_ptr_pc(vxi)->v
12191 +#else
12192 +#define        vx_ptr_pc(vxi)          ((vxi)->ptr_pc)
12193 +#define        vx_per_cpu(vxi, v, id)  per_cpu_ptr(vx_ptr_pc(vxi), id)->v
12194 +#endif
12195 +
12196 +#define        vx_cpu(vxi, v)          vx_per_cpu(vxi, v, smp_processor_id())
12197 +
12198 +
12199 +struct vx_info_save {
12200 +       struct vx_info *vxi;
12201 +       xid_t xid;
12202 +};
12203 +
12204 +
12205 +/* status flags */
12206 +
12207 +#define VXS_HASHED     0x0001
12208 +#define VXS_PAUSED     0x0010
12209 +#define VXS_SHUTDOWN   0x0100
12210 +#define VXS_HELPER     0x1000
12211 +#define VXS_RELEASED   0x8000
12212 +
12213 +
12214 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
12215 +extern void release_vx_info(struct vx_info *, struct task_struct *);
12216 +
12217 +extern struct vx_info *lookup_vx_info(int);
12218 +extern struct vx_info *lookup_or_create_vx_info(int);
12219 +
12220 +extern int get_xid_list(int, unsigned int *, int);
12221 +extern int xid_is_hashed(xid_t);
12222 +
12223 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
12224 +
12225 +extern long vs_state_change(struct vx_info *, unsigned int);
12226 +
12227 +
12228 +#endif /* __KERNEL__ */
12229 +#endif /* _VX_CONTEXT_H */
12230 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cvirt_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt_cmd.h
12231 --- linux-2.6.35/include/linux/vserver/cvirt_cmd.h      1970-01-01 01:00:00.000000000 +0100
12232 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt_cmd.h        2010-08-02 17:05:06.000000000 +0200
12233 @@ -0,0 +1,53 @@
12234 +#ifndef _VX_CVIRT_CMD_H
12235 +#define _VX_CVIRT_CMD_H
12236 +
12237 +
12238 +/* virtual host info name commands */
12239 +
12240 +#define VCMD_set_vhi_name      VC_CMD(VHOST, 1, 0)
12241 +#define VCMD_get_vhi_name      VC_CMD(VHOST, 2, 0)
12242 +
12243 +struct vcmd_vhi_name_v0 {
12244 +       uint32_t field;
12245 +       char name[65];
12246 +};
12247 +
12248 +
12249 +enum vhi_name_field {
12250 +       VHIN_CONTEXT = 0,
12251 +       VHIN_SYSNAME,
12252 +       VHIN_NODENAME,
12253 +       VHIN_RELEASE,
12254 +       VHIN_VERSION,
12255 +       VHIN_MACHINE,
12256 +       VHIN_DOMAINNAME,
12257 +};
12258 +
12259 +
12260 +#ifdef __KERNEL__
12261 +
12262 +#include <linux/compiler.h>
12263 +
12264 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12265 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12266 +
12267 +#endif /* __KERNEL__ */
12268 +
12269 +#define VCMD_virt_stat         VC_CMD(VSTAT, 3, 0)
12270 +
12271 +struct vcmd_virt_stat_v0 {
12272 +       uint64_t offset;
12273 +       uint64_t uptime;
12274 +       uint32_t nr_threads;
12275 +       uint32_t nr_running;
12276 +       uint32_t nr_uninterruptible;
12277 +       uint32_t nr_onhold;
12278 +       uint32_t nr_forks;
12279 +       uint32_t load[3];
12280 +};
12281 +
12282 +#ifdef __KERNEL__
12283 +extern int vc_virt_stat(struct vx_info *, void __user *);
12284 +
12285 +#endif /* __KERNEL__ */
12286 +#endif /* _VX_CVIRT_CMD_H */
12287 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cvirt_def.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt_def.h
12288 --- linux-2.6.35/include/linux/vserver/cvirt_def.h      1970-01-01 01:00:00.000000000 +0100
12289 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt_def.h        2010-08-02 17:05:06.000000000 +0200
12290 @@ -0,0 +1,80 @@
12291 +#ifndef _VX_CVIRT_DEF_H
12292 +#define _VX_CVIRT_DEF_H
12293 +
12294 +#include <linux/jiffies.h>
12295 +#include <linux/spinlock.h>
12296 +#include <linux/wait.h>
12297 +#include <linux/time.h>
12298 +#include <asm/atomic.h>
12299 +
12300 +
12301 +struct _vx_usage_stat {
12302 +       uint64_t user;
12303 +       uint64_t nice;
12304 +       uint64_t system;
12305 +       uint64_t softirq;
12306 +       uint64_t irq;
12307 +       uint64_t idle;
12308 +       uint64_t iowait;
12309 +};
12310 +
12311 +struct _vx_syslog {
12312 +       wait_queue_head_t log_wait;
12313 +       spinlock_t logbuf_lock;         /* lock for the log buffer */
12314 +
12315 +       unsigned long log_start;        /* next char to be read by syslog() */
12316 +       unsigned long con_start;        /* next char to be sent to consoles */
12317 +       unsigned long log_end;  /* most-recently-written-char + 1 */
12318 +       unsigned long logged_chars;     /* #chars since last read+clear operation */
12319 +
12320 +       char log_buf[1024];
12321 +};
12322 +
12323 +
12324 +/* context sub struct */
12325 +
12326 +struct _vx_cvirt {
12327 +       atomic_t nr_threads;            /* number of current threads */
12328 +       atomic_t nr_running;            /* number of running threads */
12329 +       atomic_t nr_uninterruptible;    /* number of uninterruptible threads */
12330 +
12331 +       atomic_t nr_onhold;             /* processes on hold */
12332 +       uint32_t onhold_last;           /* jiffies when put on hold */
12333 +
12334 +       struct timeval bias_tv;         /* time offset to the host */
12335 +       struct timespec bias_idle;
12336 +       struct timespec bias_uptime;    /* context creation point */
12337 +       uint64_t bias_clock;            /* offset in clock_t */
12338 +
12339 +       spinlock_t load_lock;           /* lock for the load averages */
12340 +       atomic_t load_updates;          /* nr of load updates done so far */
12341 +       uint32_t load_last;             /* last time load was calculated */
12342 +       uint32_t load[3];               /* load averages 1,5,15 */
12343 +
12344 +       atomic_t total_forks;           /* number of forks so far */
12345 +
12346 +       struct _vx_syslog syslog;
12347 +};
12348 +
12349 +struct _vx_cvirt_pc {
12350 +       struct _vx_usage_stat cpustat;
12351 +};
12352 +
12353 +
12354 +#ifdef CONFIG_VSERVER_DEBUG
12355 +
12356 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12357 +{
12358 +       printk("\t_vx_cvirt:\n");
12359 +       printk("\t threads: %4d, %4d, %4d, %4d\n",
12360 +               atomic_read(&cvirt->nr_threads),
12361 +               atomic_read(&cvirt->nr_running),
12362 +               atomic_read(&cvirt->nr_uninterruptible),
12363 +               atomic_read(&cvirt->nr_onhold));
12364 +       /* add rest here */
12365 +       printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12366 +}
12367 +
12368 +#endif
12369 +
12370 +#endif /* _VX_CVIRT_DEF_H */
12371 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/cvirt.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt.h
12372 --- linux-2.6.35/include/linux/vserver/cvirt.h  1970-01-01 01:00:00.000000000 +0100
12373 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/cvirt.h    2010-08-02 17:05:06.000000000 +0200
12374 @@ -0,0 +1,20 @@
12375 +#ifndef _VX_CVIRT_H
12376 +#define _VX_CVIRT_H
12377 +
12378 +
12379 +#ifdef __KERNEL__
12380 +
12381 +struct timespec;
12382 +
12383 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12384 +
12385 +
12386 +struct vx_info;
12387 +
12388 +void vx_update_load(struct vx_info *);
12389 +
12390 +
12391 +int vx_do_syslog(int, char __user *, int);
12392 +
12393 +#endif /* __KERNEL__ */
12394 +#endif /* _VX_CVIRT_H */
12395 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/debug_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/debug_cmd.h
12396 --- linux-2.6.35/include/linux/vserver/debug_cmd.h      1970-01-01 01:00:00.000000000 +0100
12397 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/debug_cmd.h        2010-08-02 17:05:06.000000000 +0200
12398 @@ -0,0 +1,58 @@
12399 +#ifndef _VX_DEBUG_CMD_H
12400 +#define _VX_DEBUG_CMD_H
12401 +
12402 +
12403 +/* debug commands */
12404 +
12405 +#define VCMD_dump_history      VC_CMD(DEBUG, 1, 0)
12406 +
12407 +#define VCMD_read_history      VC_CMD(DEBUG, 5, 0)
12408 +#define VCMD_read_monitor      VC_CMD(DEBUG, 6, 0)
12409 +
12410 +struct  vcmd_read_history_v0 {
12411 +       uint32_t index;
12412 +       uint32_t count;
12413 +       char __user *data;
12414 +};
12415 +
12416 +struct  vcmd_read_monitor_v0 {
12417 +       uint32_t index;
12418 +       uint32_t count;
12419 +       char __user *data;
12420 +};
12421 +
12422 +
12423 +#ifdef __KERNEL__
12424 +
12425 +#ifdef CONFIG_COMPAT
12426 +
12427 +#include <asm/compat.h>
12428 +
12429 +struct vcmd_read_history_v0_x32 {
12430 +       uint32_t index;
12431 +       uint32_t count;
12432 +       compat_uptr_t data_ptr;
12433 +};
12434 +
12435 +struct vcmd_read_monitor_v0_x32 {
12436 +       uint32_t index;
12437 +       uint32_t count;
12438 +       compat_uptr_t data_ptr;
12439 +};
12440 +
12441 +#endif  /* CONFIG_COMPAT */
12442 +
12443 +extern int vc_dump_history(uint32_t);
12444 +
12445 +extern int vc_read_history(uint32_t, void __user *);
12446 +extern int vc_read_monitor(uint32_t, void __user *);
12447 +
12448 +#ifdef CONFIG_COMPAT
12449 +
12450 +extern int vc_read_history_x32(uint32_t, void __user *);
12451 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12452 +
12453 +#endif  /* CONFIG_COMPAT */
12454 +
12455 +#endif /* __KERNEL__ */
12456 +#endif /* _VX_DEBUG_CMD_H */
12457 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/debug.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/debug.h
12458 --- linux-2.6.35/include/linux/vserver/debug.h  1970-01-01 01:00:00.000000000 +0100
12459 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/debug.h    2010-08-02 17:05:06.000000000 +0200
12460 @@ -0,0 +1,127 @@
12461 +#ifndef _VX_DEBUG_H
12462 +#define _VX_DEBUG_H
12463 +
12464 +
12465 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12466 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12467 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12468 +
12469 +#define VXD_DEV(d)     (d), (d)->bd_inode->i_ino,              \
12470 +                       imajor((d)->bd_inode), iminor((d)->bd_inode)
12471 +#define VXF_DEV                "%p[%lu,%d:%d]"
12472 +
12473 +
12474 +#define vxd_path(p)                                            \
12475 +       ({ static char _buffer[PATH_MAX];                       \
12476 +          d_path(p, _buffer, sizeof(_buffer)); })
12477 +
12478 +#define vxd_cond_path(n)                                       \
12479 +       ((n) ? vxd_path(&(n)->path) : "<null>" )
12480 +
12481 +
12482 +#ifdef CONFIG_VSERVER_DEBUG
12483 +
12484 +extern unsigned int vx_debug_switch;
12485 +extern unsigned int vx_debug_xid;
12486 +extern unsigned int vx_debug_nid;
12487 +extern unsigned int vx_debug_tag;
12488 +extern unsigned int vx_debug_net;
12489 +extern unsigned int vx_debug_limit;
12490 +extern unsigned int vx_debug_cres;
12491 +extern unsigned int vx_debug_dlim;
12492 +extern unsigned int vx_debug_quota;
12493 +extern unsigned int vx_debug_cvirt;
12494 +extern unsigned int vx_debug_space;
12495 +extern unsigned int vx_debug_misc;
12496 +
12497 +
12498 +#define VX_LOGLEVEL    "vxD: "
12499 +#define VX_PROC_FMT    "%p: "
12500 +#define VX_PROCESS     current
12501 +
12502 +#define vxdprintk(c, f, x...)                                  \
12503 +       do {                                                    \
12504 +               if (c)                                          \
12505 +                       printk(VX_LOGLEVEL VX_PROC_FMT f "\n",  \
12506 +                               VX_PROCESS , ##x);              \
12507 +       } while (0)
12508 +
12509 +#define vxlprintk(c, f, x...)                                  \
12510 +       do {                                                    \
12511 +               if (c)                                          \
12512 +                       printk(VX_LOGLEVEL f " @%s:%d\n", x);   \
12513 +       } while (0)
12514 +
12515 +#define vxfprintk(c, f, x...)                                  \
12516 +       do {                                                    \
12517 +               if (c)                                          \
12518 +                       printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12519 +       } while (0)
12520 +
12521 +
12522 +struct vx_info;
12523 +
12524 +void dump_vx_info(struct vx_info *, int);
12525 +void dump_vx_info_inactive(int);
12526 +
12527 +#else  /* CONFIG_VSERVER_DEBUG */
12528 +
12529 +#define vx_debug_switch 0
12530 +#define vx_debug_xid   0
12531 +#define vx_debug_nid   0
12532 +#define vx_debug_tag   0
12533 +#define vx_debug_net   0
12534 +#define vx_debug_limit 0
12535 +#define vx_debug_cres  0
12536 +#define vx_debug_dlim  0
12537 +#define vx_debug_cvirt 0
12538 +
12539 +#define vxdprintk(x...) do { } while (0)
12540 +#define vxlprintk(x...) do { } while (0)
12541 +#define vxfprintk(x...) do { } while (0)
12542 +
12543 +#endif /* CONFIG_VSERVER_DEBUG */
12544 +
12545 +
12546 +#ifdef CONFIG_VSERVER_WARN
12547 +
12548 +#define VX_WARNLEVEL   KERN_WARNING "vxW: "
12549 +#define VX_WARN_TASK   "[»%s«,%u:#%u|%u|%u] "
12550 +#define VX_WARN_XID    "[xid #%u] "
12551 +#define VX_WARN_NID    "[nid #%u] "
12552 +#define VX_WARN_TAG    "[tag #%u] "
12553 +
12554 +#define vxwprintk(c, f, x...)                                  \
12555 +       do {                                                    \
12556 +               if (c)                                          \
12557 +                       printk(VX_WARNLEVEL f "\n", ##x);       \
12558 +       } while (0)
12559 +
12560 +#else  /* CONFIG_VSERVER_WARN */
12561 +
12562 +#define vxwprintk(x...) do { } while (0)
12563 +
12564 +#endif /* CONFIG_VSERVER_WARN */
12565 +
12566 +#define vxwprintk_task(c, f, x...)                             \
12567 +       vxwprintk(c, VX_WARN_TASK f,                            \
12568 +               current->comm, current->pid,                    \
12569 +               current->xid, current->nid, current->tag, ##x)
12570 +#define vxwprintk_xid(c, f, x...)                              \
12571 +       vxwprintk(c, VX_WARN_XID f, current->xid, x)
12572 +#define vxwprintk_nid(c, f, x...)                              \
12573 +       vxwprintk(c, VX_WARN_NID f, current->nid, x)
12574 +#define vxwprintk_tag(c, f, x...)                              \
12575 +       vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12576 +
12577 +#ifdef CONFIG_VSERVER_DEBUG
12578 +#define vxd_assert_lock(l)     assert_spin_locked(l)
12579 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12580 +       "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12581 +#else
12582 +#define vxd_assert_lock(l)     do { } while (0)
12583 +#define vxd_assert(c, f, x...) do { } while (0)
12584 +#endif
12585 +
12586 +
12587 +#endif /* _VX_DEBUG_H */
12588 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/device_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device_cmd.h
12589 --- linux-2.6.35/include/linux/vserver/device_cmd.h     1970-01-01 01:00:00.000000000 +0100
12590 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device_cmd.h       2010-08-02 17:05:06.000000000 +0200
12591 @@ -0,0 +1,44 @@
12592 +#ifndef _VX_DEVICE_CMD_H
12593 +#define _VX_DEVICE_CMD_H
12594 +
12595 +
12596 +/*  device vserver commands */
12597 +
12598 +#define VCMD_set_mapping       VC_CMD(DEVICE, 1, 0)
12599 +#define VCMD_unset_mapping     VC_CMD(DEVICE, 2, 0)
12600 +
12601 +struct vcmd_set_mapping_v0 {
12602 +       const char __user *device;
12603 +       const char __user *target;
12604 +       uint32_t flags;
12605 +};
12606 +
12607 +
12608 +#ifdef __KERNEL__
12609 +
12610 +#ifdef CONFIG_COMPAT
12611 +
12612 +#include <asm/compat.h>
12613 +
12614 +struct vcmd_set_mapping_v0_x32 {
12615 +       compat_uptr_t device_ptr;
12616 +       compat_uptr_t target_ptr;
12617 +       uint32_t flags;
12618 +};
12619 +
12620 +#endif /* CONFIG_COMPAT */
12621 +
12622 +#include <linux/compiler.h>
12623 +
12624 +extern int vc_set_mapping(struct vx_info *, void __user *);
12625 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12626 +
12627 +#ifdef CONFIG_COMPAT
12628 +
12629 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12630 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12631 +
12632 +#endif /* CONFIG_COMPAT */
12633 +
12634 +#endif /* __KERNEL__ */
12635 +#endif /* _VX_DEVICE_CMD_H */
12636 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/device_def.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device_def.h
12637 --- linux-2.6.35/include/linux/vserver/device_def.h     1970-01-01 01:00:00.000000000 +0100
12638 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device_def.h       2010-08-02 17:05:06.000000000 +0200
12639 @@ -0,0 +1,17 @@
12640 +#ifndef _VX_DEVICE_DEF_H
12641 +#define _VX_DEVICE_DEF_H
12642 +
12643 +#include <linux/types.h>
12644 +
12645 +struct vx_dmap_target {
12646 +       dev_t target;
12647 +       uint32_t flags;
12648 +};
12649 +
12650 +struct _vx_device {
12651 +#ifdef CONFIG_VSERVER_DEVICE
12652 +       struct vx_dmap_target targets[2];
12653 +#endif
12654 +};
12655 +
12656 +#endif /* _VX_DEVICE_DEF_H */
12657 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/device.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device.h
12658 --- linux-2.6.35/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
12659 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/device.h   2010-08-02 17:05:06.000000000 +0200
12660 @@ -0,0 +1,15 @@
12661 +#ifndef _VX_DEVICE_H
12662 +#define _VX_DEVICE_H
12663 +
12664 +
12665 +#define DATTR_CREATE   0x00000001
12666 +#define DATTR_OPEN     0x00000002
12667 +
12668 +#define DATTR_REMAP    0x00000010
12669 +
12670 +#define DATTR_MASK     0x00000013
12671 +
12672 +
12673 +#else  /* _VX_DEVICE_H */
12674 +#warning duplicate inclusion
12675 +#endif /* _VX_DEVICE_H */
12676 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/dlimit_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/dlimit_cmd.h
12677 --- linux-2.6.35/include/linux/vserver/dlimit_cmd.h     1970-01-01 01:00:00.000000000 +0100
12678 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/dlimit_cmd.h       2010-08-02 17:05:06.000000000 +0200
12679 @@ -0,0 +1,109 @@
12680 +#ifndef _VX_DLIMIT_CMD_H
12681 +#define _VX_DLIMIT_CMD_H
12682 +
12683 +
12684 +/*  dlimit vserver commands */
12685 +
12686 +#define VCMD_add_dlimit                VC_CMD(DLIMIT, 1, 0)
12687 +#define VCMD_rem_dlimit                VC_CMD(DLIMIT, 2, 0)
12688 +
12689 +#define VCMD_set_dlimit                VC_CMD(DLIMIT, 5, 0)
12690 +#define VCMD_get_dlimit                VC_CMD(DLIMIT, 6, 0)
12691 +
12692 +struct vcmd_ctx_dlimit_base_v0 {
12693 +       const char __user *name;
12694 +       uint32_t flags;
12695 +};
12696 +
12697 +struct vcmd_ctx_dlimit_v0 {
12698 +       const char __user *name;
12699 +       uint32_t space_used;                    /* used space in kbytes */
12700 +       uint32_t space_total;                   /* maximum space in kbytes */
12701 +       uint32_t inodes_used;                   /* used inodes */
12702 +       uint32_t inodes_total;                  /* maximum inodes */
12703 +       uint32_t reserved;                      /* reserved for root in % */
12704 +       uint32_t flags;
12705 +};
12706 +
12707 +#define CDLIM_UNSET            ((uint32_t)0UL)
12708 +#define CDLIM_INFINITY         ((uint32_t)~0UL)
12709 +#define CDLIM_KEEP             ((uint32_t)~1UL)
12710 +
12711 +#define DLIME_UNIT     0
12712 +#define DLIME_KILO     1
12713 +#define DLIME_MEGA     2
12714 +#define DLIME_GIGA     3
12715 +
12716 +#define DLIMF_SHIFT    0x10
12717 +
12718 +#define DLIMS_USED     0
12719 +#define DLIMS_TOTAL    2
12720 +
12721 +static inline
12722 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12723 +{
12724 +       int exp = (flags & DLIMF_SHIFT) ?
12725 +               (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12726 +       return ((uint64_t)val) << (10 * exp);
12727 +}
12728 +
12729 +static inline
12730 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12731 +{
12732 +       int exp = 0;
12733 +
12734 +       if (*flags & DLIMF_SHIFT) {
12735 +               while (val > (1LL << 32) && (exp < 3)) {
12736 +                       val >>= 10;
12737 +                       exp++;
12738 +               }
12739 +               *flags &= ~(DLIME_GIGA << shift);
12740 +               *flags |= exp << shift;
12741 +       } else
12742 +               val >>= 10;
12743 +       return val;
12744 +}
12745 +
12746 +#ifdef __KERNEL__
12747 +
12748 +#ifdef CONFIG_COMPAT
12749 +
12750 +#include <asm/compat.h>
12751 +
12752 +struct vcmd_ctx_dlimit_base_v0_x32 {
12753 +       compat_uptr_t name_ptr;
12754 +       uint32_t flags;
12755 +};
12756 +
12757 +struct vcmd_ctx_dlimit_v0_x32 {
12758 +       compat_uptr_t name_ptr;
12759 +       uint32_t space_used;                    /* used space in kbytes */
12760 +       uint32_t space_total;                   /* maximum space in kbytes */
12761 +       uint32_t inodes_used;                   /* used inodes */
12762 +       uint32_t inodes_total;                  /* maximum inodes */
12763 +       uint32_t reserved;                      /* reserved for root in % */
12764 +       uint32_t flags;
12765 +};
12766 +
12767 +#endif /* CONFIG_COMPAT */
12768 +
12769 +#include <linux/compiler.h>
12770 +
12771 +extern int vc_add_dlimit(uint32_t, void __user *);
12772 +extern int vc_rem_dlimit(uint32_t, void __user *);
12773 +
12774 +extern int vc_set_dlimit(uint32_t, void __user *);
12775 +extern int vc_get_dlimit(uint32_t, void __user *);
12776 +
12777 +#ifdef CONFIG_COMPAT
12778 +
12779 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12780 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12781 +
12782 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12783 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12784 +
12785 +#endif /* CONFIG_COMPAT */
12786 +
12787 +#endif /* __KERNEL__ */
12788 +#endif /* _VX_DLIMIT_CMD_H */
12789 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/dlimit.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/dlimit.h
12790 --- linux-2.6.35/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12791 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/dlimit.h   2010-08-02 17:05:06.000000000 +0200
12792 @@ -0,0 +1,54 @@
12793 +#ifndef _VX_DLIMIT_H
12794 +#define _VX_DLIMIT_H
12795 +
12796 +#include "switch.h"
12797 +
12798 +
12799 +#ifdef __KERNEL__
12800 +
12801 +/*      keep in sync with CDLIM_INFINITY       */
12802 +
12803 +#define DLIM_INFINITY          (~0ULL)
12804 +
12805 +#include <linux/spinlock.h>
12806 +#include <linux/rcupdate.h>
12807 +
12808 +struct super_block;
12809 +
12810 +struct dl_info {
12811 +       struct hlist_node dl_hlist;             /* linked list of contexts */
12812 +       struct rcu_head dl_rcu;                 /* the rcu head */
12813 +       tag_t dl_tag;                           /* context tag */
12814 +       atomic_t dl_usecnt;                     /* usage count */
12815 +       atomic_t dl_refcnt;                     /* reference count */
12816 +
12817 +       struct super_block *dl_sb;              /* associated superblock */
12818 +
12819 +       spinlock_t dl_lock;                     /* protect the values */
12820 +
12821 +       unsigned long long dl_space_used;       /* used space in bytes */
12822 +       unsigned long long dl_space_total;      /* maximum space in bytes */
12823 +       unsigned long dl_inodes_used;           /* used inodes */
12824 +       unsigned long dl_inodes_total;          /* maximum inodes */
12825 +
12826 +       unsigned int dl_nrlmult;                /* non root limit mult */
12827 +};
12828 +
12829 +struct rcu_head;
12830 +
12831 +extern void rcu_free_dl_info(struct rcu_head *);
12832 +extern void unhash_dl_info(struct dl_info *);
12833 +
12834 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12835 +
12836 +
12837 +struct kstatfs;
12838 +
12839 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12840 +
12841 +typedef uint64_t dlsize_t;
12842 +
12843 +#endif /* __KERNEL__ */
12844 +#else  /* _VX_DLIMIT_H */
12845 +#warning duplicate inclusion
12846 +#endif /* _VX_DLIMIT_H */
12847 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/global.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/global.h
12848 --- linux-2.6.35/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12849 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/global.h   2010-08-02 17:05:06.000000000 +0200
12850 @@ -0,0 +1,19 @@
12851 +#ifndef _VX_GLOBAL_H
12852 +#define _VX_GLOBAL_H
12853 +
12854 +
12855 +extern atomic_t vx_global_ctotal;
12856 +extern atomic_t vx_global_cactive;
12857 +
12858 +extern atomic_t nx_global_ctotal;
12859 +extern atomic_t nx_global_cactive;
12860 +
12861 +extern atomic_t vs_global_nsproxy;
12862 +extern atomic_t vs_global_fs;
12863 +extern atomic_t vs_global_mnt_ns;
12864 +extern atomic_t vs_global_uts_ns;
12865 +extern atomic_t vs_global_user_ns;
12866 +extern atomic_t vs_global_pid_ns;
12867 +
12868 +
12869 +#endif /* _VX_GLOBAL_H */
12870 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/history.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/history.h
12871 --- linux-2.6.35/include/linux/vserver/history.h        1970-01-01 01:00:00.000000000 +0100
12872 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/history.h  2010-08-02 17:05:06.000000000 +0200
12873 @@ -0,0 +1,197 @@
12874 +#ifndef _VX_HISTORY_H
12875 +#define _VX_HISTORY_H
12876 +
12877 +
12878 +enum {
12879 +       VXH_UNUSED = 0,
12880 +       VXH_THROW_OOPS = 1,
12881 +
12882 +       VXH_GET_VX_INFO,
12883 +       VXH_PUT_VX_INFO,
12884 +       VXH_INIT_VX_INFO,
12885 +       VXH_SET_VX_INFO,
12886 +       VXH_CLR_VX_INFO,
12887 +       VXH_CLAIM_VX_INFO,
12888 +       VXH_RELEASE_VX_INFO,
12889 +       VXH_ALLOC_VX_INFO,
12890 +       VXH_DEALLOC_VX_INFO,
12891 +       VXH_HASH_VX_INFO,
12892 +       VXH_UNHASH_VX_INFO,
12893 +       VXH_LOC_VX_INFO,
12894 +       VXH_LOOKUP_VX_INFO,
12895 +       VXH_CREATE_VX_INFO,
12896 +};
12897 +
12898 +struct _vxhe_vxi {
12899 +       struct vx_info *ptr;
12900 +       unsigned xid;
12901 +       unsigned usecnt;
12902 +       unsigned tasks;
12903 +};
12904 +
12905 +struct _vxhe_set_clr {
12906 +       void *data;
12907 +};
12908 +
12909 +struct _vxhe_loc_lookup {
12910 +       unsigned arg;
12911 +};
12912 +
12913 +struct _vx_hist_entry {
12914 +       void *loc;
12915 +       unsigned short seq;
12916 +       unsigned short type;
12917 +       struct _vxhe_vxi vxi;
12918 +       union {
12919 +               struct _vxhe_set_clr sc;
12920 +               struct _vxhe_loc_lookup ll;
12921 +       };
12922 +};
12923 +
12924 +#ifdef CONFIG_VSERVER_HISTORY
12925 +
12926 +extern unsigned volatile int vxh_active;
12927 +
12928 +struct _vx_hist_entry *vxh_advance(void *loc);
12929 +
12930 +
12931 +static inline
12932 +void   __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12933 +{
12934 +       entry->vxi.ptr = vxi;
12935 +       if (vxi) {
12936 +               entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12937 +               entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12938 +               entry->vxi.xid = vxi->vx_id;
12939 +       }
12940 +}
12941 +
12942 +
12943 +#define        __HERE__ current_text_addr()
12944 +
12945 +#define __VXH_BODY(__type, __data, __here)     \
12946 +       struct _vx_hist_entry *entry;           \
12947 +                                               \
12948 +       preempt_disable();                      \
12949 +       entry = vxh_advance(__here);            \
12950 +       __data;                                 \
12951 +       entry->type = __type;                   \
12952 +       preempt_enable();
12953 +
12954 +
12955 +       /* pass vxi only */
12956 +
12957 +#define __VXH_SMPL                             \
12958 +       __vxh_copy_vxi(entry, vxi)
12959 +
12960 +static inline
12961 +void   __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12962 +{
12963 +       __VXH_BODY(__type, __VXH_SMPL, __here)
12964 +}
12965 +
12966 +       /* pass vxi and data (void *) */
12967 +
12968 +#define __VXH_DATA                             \
12969 +       __vxh_copy_vxi(entry, vxi);             \
12970 +       entry->sc.data = data
12971 +
12972 +static inline
12973 +void   __vxh_data(struct vx_info *vxi, void *data,
12974 +                       int __type, void *__here)
12975 +{
12976 +       __VXH_BODY(__type, __VXH_DATA, __here)
12977 +}
12978 +
12979 +       /* pass vxi and arg (long) */
12980 +
12981 +#define __VXH_LONG                             \
12982 +       __vxh_copy_vxi(entry, vxi);             \
12983 +       entry->ll.arg = arg
12984 +
12985 +static inline
12986 +void   __vxh_long(struct vx_info *vxi, long arg,
12987 +                       int __type, void *__here)
12988 +{
12989 +       __VXH_BODY(__type, __VXH_LONG, __here)
12990 +}
12991 +
12992 +
12993 +static inline
12994 +void   __vxh_throw_oops(void *__here)
12995 +{
12996 +       __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12997 +       /* prevent further acquisition */
12998 +       vxh_active = 0;
12999 +}
13000 +
13001 +
13002 +#define vxh_throw_oops()       __vxh_throw_oops(__HERE__);
13003 +
13004 +#define __vxh_get_vx_info(v, h)        __vxh_smpl(v, VXH_GET_VX_INFO, h);
13005 +#define __vxh_put_vx_info(v, h)        __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13006 +
13007 +#define __vxh_init_vx_info(v, d, h) \
13008 +       __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13009 +#define __vxh_set_vx_info(v, d, h) \
13010 +       __vxh_data(v, d, VXH_SET_VX_INFO, h);
13011 +#define __vxh_clr_vx_info(v, d, h) \
13012 +       __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13013 +
13014 +#define __vxh_claim_vx_info(v, d, h) \
13015 +       __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13016 +#define __vxh_release_vx_info(v, d, h) \
13017 +       __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13018 +
13019 +#define vxh_alloc_vx_info(v) \
13020 +       __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13021 +#define vxh_dealloc_vx_info(v) \
13022 +       __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13023 +
13024 +#define vxh_hash_vx_info(v) \
13025 +       __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13026 +#define vxh_unhash_vx_info(v) \
13027 +       __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13028 +
13029 +#define vxh_loc_vx_info(v, l) \
13030 +       __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13031 +#define vxh_lookup_vx_info(v, l) \
13032 +       __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13033 +#define vxh_create_vx_info(v, l) \
13034 +       __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13035 +
13036 +extern void vxh_dump_history(void);
13037 +
13038 +
13039 +#else  /* CONFIG_VSERVER_HISTORY */
13040 +
13041 +#define        __HERE__        0
13042 +
13043 +#define vxh_throw_oops()               do { } while (0)
13044 +
13045 +#define __vxh_get_vx_info(v, h)                do { } while (0)
13046 +#define __vxh_put_vx_info(v, h)                do { } while (0)
13047 +
13048 +#define __vxh_init_vx_info(v, d, h)    do { } while (0)
13049 +#define __vxh_set_vx_info(v, d, h)     do { } while (0)
13050 +#define __vxh_clr_vx_info(v, d, h)     do { } while (0)
13051 +
13052 +#define __vxh_claim_vx_info(v, d, h)   do { } while (0)
13053 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13054 +
13055 +#define vxh_alloc_vx_info(v)           do { } while (0)
13056 +#define vxh_dealloc_vx_info(v)         do { } while (0)
13057 +
13058 +#define vxh_hash_vx_info(v)            do { } while (0)
13059 +#define vxh_unhash_vx_info(v)          do { } while (0)
13060 +
13061 +#define vxh_loc_vx_info(v, l)          do { } while (0)
13062 +#define vxh_lookup_vx_info(v, l)       do { } while (0)
13063 +#define vxh_create_vx_info(v, l)       do { } while (0)
13064 +
13065 +#define vxh_dump_history()             do { } while (0)
13066 +
13067 +
13068 +#endif /* CONFIG_VSERVER_HISTORY */
13069 +
13070 +#endif /* _VX_HISTORY_H */
13071 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/inode_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/inode_cmd.h
13072 --- linux-2.6.35/include/linux/vserver/inode_cmd.h      1970-01-01 01:00:00.000000000 +0100
13073 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/inode_cmd.h        2010-08-02 17:05:06.000000000 +0200
13074 @@ -0,0 +1,59 @@
13075 +#ifndef _VX_INODE_CMD_H
13076 +#define _VX_INODE_CMD_H
13077 +
13078 +
13079 +/*  inode vserver commands */
13080 +
13081 +#define VCMD_get_iattr         VC_CMD(INODE, 1, 1)
13082 +#define VCMD_set_iattr         VC_CMD(INODE, 2, 1)
13083 +
13084 +#define VCMD_fget_iattr                VC_CMD(INODE, 3, 0)
13085 +#define VCMD_fset_iattr                VC_CMD(INODE, 4, 0)
13086 +
13087 +struct vcmd_ctx_iattr_v1 {
13088 +       const char __user *name;
13089 +       uint32_t tag;
13090 +       uint32_t flags;
13091 +       uint32_t mask;
13092 +};
13093 +
13094 +struct vcmd_ctx_fiattr_v0 {
13095 +       uint32_t tag;
13096 +       uint32_t flags;
13097 +       uint32_t mask;
13098 +};
13099 +
13100 +
13101 +#ifdef __KERNEL__
13102 +
13103 +
13104 +#ifdef CONFIG_COMPAT
13105 +
13106 +#include <asm/compat.h>
13107 +
13108 +struct vcmd_ctx_iattr_v1_x32 {
13109 +       compat_uptr_t name_ptr;
13110 +       uint32_t tag;
13111 +       uint32_t flags;
13112 +       uint32_t mask;
13113 +};
13114 +
13115 +#endif /* CONFIG_COMPAT */
13116 +
13117 +#include <linux/compiler.h>
13118 +
13119 +extern int vc_get_iattr(void __user *);
13120 +extern int vc_set_iattr(void __user *);
13121 +
13122 +extern int vc_fget_iattr(uint32_t, void __user *);
13123 +extern int vc_fset_iattr(uint32_t, void __user *);
13124 +
13125 +#ifdef CONFIG_COMPAT
13126 +
13127 +extern int vc_get_iattr_x32(void __user *);
13128 +extern int vc_set_iattr_x32(void __user *);
13129 +
13130 +#endif /* CONFIG_COMPAT */
13131 +
13132 +#endif /* __KERNEL__ */
13133 +#endif /* _VX_INODE_CMD_H */
13134 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/inode.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/inode.h
13135 --- linux-2.6.35/include/linux/vserver/inode.h  1970-01-01 01:00:00.000000000 +0100
13136 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/inode.h    2010-08-02 17:05:06.000000000 +0200
13137 @@ -0,0 +1,39 @@
13138 +#ifndef _VX_INODE_H
13139 +#define _VX_INODE_H
13140 +
13141 +
13142 +#define IATTR_TAG      0x01000000
13143 +
13144 +#define IATTR_ADMIN    0x00000001
13145 +#define IATTR_WATCH    0x00000002
13146 +#define IATTR_HIDE     0x00000004
13147 +#define IATTR_FLAGS    0x00000007
13148 +
13149 +#define IATTR_BARRIER  0x00010000
13150 +#define IATTR_IXUNLINK 0x00020000
13151 +#define IATTR_IMMUTABLE 0x00040000
13152 +#define IATTR_COW      0x00080000
13153 +
13154 +#ifdef __KERNEL__
13155 +
13156 +
13157 +#ifdef CONFIG_VSERVER_PROC_SECURE
13158 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN | IATTR_HIDE )
13159 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
13160 +#else
13161 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN )
13162 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
13163 +#endif
13164 +
13165 +#define vx_hide_check(c, m)    (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
13166 +
13167 +#endif /* __KERNEL__ */
13168 +
13169 +/* inode ioctls */
13170 +
13171 +#define FIOC_GETXFLG   _IOR('x', 5, long)
13172 +#define FIOC_SETXFLG   _IOW('x', 6, long)
13173 +
13174 +#else  /* _VX_INODE_H */
13175 +#warning duplicate inclusion
13176 +#endif /* _VX_INODE_H */
13177 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/Kbuild linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/Kbuild
13178 --- linux-2.6.35/include/linux/vserver/Kbuild   1970-01-01 01:00:00.000000000 +0100
13179 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/Kbuild     2010-08-02 17:05:06.000000000 +0200
13180 @@ -0,0 +1,8 @@
13181 +
13182 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
13183 +       cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
13184 +       inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
13185 +       debug_cmd.h device_cmd.h
13186 +
13187 +unifdef-y += switch.h network.h monitor.h inode.h device.h
13188 +
13189 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/limit_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_cmd.h
13190 --- linux-2.6.35/include/linux/vserver/limit_cmd.h      1970-01-01 01:00:00.000000000 +0100
13191 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_cmd.h        2010-08-02 17:05:06.000000000 +0200
13192 @@ -0,0 +1,71 @@
13193 +#ifndef _VX_LIMIT_CMD_H
13194 +#define _VX_LIMIT_CMD_H
13195 +
13196 +
13197 +/*  rlimit vserver commands */
13198 +
13199 +#define VCMD_get_rlimit                VC_CMD(RLIMIT, 1, 0)
13200 +#define VCMD_set_rlimit                VC_CMD(RLIMIT, 2, 0)
13201 +#define VCMD_get_rlimit_mask   VC_CMD(RLIMIT, 3, 0)
13202 +#define VCMD_reset_hits                VC_CMD(RLIMIT, 7, 0)
13203 +#define VCMD_reset_minmax      VC_CMD(RLIMIT, 9, 0)
13204 +
13205 +struct vcmd_ctx_rlimit_v0 {
13206 +       uint32_t id;
13207 +       uint64_t minimum;
13208 +       uint64_t softlimit;
13209 +       uint64_t maximum;
13210 +};
13211 +
13212 +struct vcmd_ctx_rlimit_mask_v0 {
13213 +       uint32_t minimum;
13214 +       uint32_t softlimit;
13215 +       uint32_t maximum;
13216 +};
13217 +
13218 +#define VCMD_rlimit_stat       VC_CMD(VSTAT, 1, 0)
13219 +
13220 +struct vcmd_rlimit_stat_v0 {
13221 +       uint32_t id;
13222 +       uint32_t hits;
13223 +       uint64_t value;
13224 +       uint64_t minimum;
13225 +       uint64_t maximum;
13226 +};
13227 +
13228 +#define CRLIM_UNSET            (0ULL)
13229 +#define CRLIM_INFINITY         (~0ULL)
13230 +#define CRLIM_KEEP             (~1ULL)
13231 +
13232 +#ifdef __KERNEL__
13233 +
13234 +#ifdef CONFIG_IA32_EMULATION
13235 +
13236 +struct vcmd_ctx_rlimit_v0_x32 {
13237 +       uint32_t id;
13238 +       uint64_t minimum;
13239 +       uint64_t softlimit;
13240 +       uint64_t maximum;
13241 +} __attribute__ ((packed));
13242 +
13243 +#endif /* CONFIG_IA32_EMULATION */
13244 +
13245 +#include <linux/compiler.h>
13246 +
13247 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13248 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13249 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13250 +extern int vc_reset_hits(struct vx_info *, void __user *);
13251 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13252 +
13253 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13254 +
13255 +#ifdef CONFIG_IA32_EMULATION
13256 +
13257 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13258 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13259 +
13260 +#endif /* CONFIG_IA32_EMULATION */
13261 +
13262 +#endif /* __KERNEL__ */
13263 +#endif /* _VX_LIMIT_CMD_H */
13264 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/limit_def.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_def.h
13265 --- linux-2.6.35/include/linux/vserver/limit_def.h      1970-01-01 01:00:00.000000000 +0100
13266 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_def.h        2010-08-02 17:05:06.000000000 +0200
13267 @@ -0,0 +1,47 @@
13268 +#ifndef _VX_LIMIT_DEF_H
13269 +#define _VX_LIMIT_DEF_H
13270 +
13271 +#include <asm/atomic.h>
13272 +#include <asm/resource.h>
13273 +
13274 +#include "limit.h"
13275 +
13276 +
13277 +struct _vx_res_limit {
13278 +       rlim_t soft;            /* Context soft limit */
13279 +       rlim_t hard;            /* Context hard limit */
13280 +
13281 +       rlim_atomic_t rcur;     /* Current value */
13282 +       rlim_t rmin;            /* Context minimum */
13283 +       rlim_t rmax;            /* Context maximum */
13284 +
13285 +       atomic_t lhit;          /* Limit hits */
13286 +};
13287 +
13288 +/* context sub struct */
13289 +
13290 +struct _vx_limit {
13291 +       struct _vx_res_limit res[NUM_LIMITS];
13292 +};
13293 +
13294 +#ifdef CONFIG_VSERVER_DEBUG
13295 +
13296 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13297 +{
13298 +       int i;
13299 +
13300 +       printk("\t_vx_limit:");
13301 +       for (i = 0; i < NUM_LIMITS; i++) {
13302 +               printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13303 +                       i, (unsigned long)__rlim_get(limit, i),
13304 +                       (unsigned long)__rlim_rmin(limit, i),
13305 +                       (unsigned long)__rlim_rmax(limit, i),
13306 +                       (long)__rlim_soft(limit, i),
13307 +                       (long)__rlim_hard(limit, i),
13308 +                       atomic_read(&__rlim_lhit(limit, i)));
13309 +       }
13310 +}
13311 +
13312 +#endif
13313 +
13314 +#endif /* _VX_LIMIT_DEF_H */
13315 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/limit.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit.h
13316 --- linux-2.6.35/include/linux/vserver/limit.h  1970-01-01 01:00:00.000000000 +0100
13317 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit.h    2010-08-02 17:05:06.000000000 +0200
13318 @@ -0,0 +1,71 @@
13319 +#ifndef _VX_LIMIT_H
13320 +#define _VX_LIMIT_H
13321 +
13322 +#define VLIMIT_NSOCK   16
13323 +#define VLIMIT_OPENFD  17
13324 +#define VLIMIT_ANON    18
13325 +#define VLIMIT_SHMEM   19
13326 +#define VLIMIT_SEMARY  20
13327 +#define VLIMIT_NSEMS   21
13328 +#define VLIMIT_DENTRY  22
13329 +#define VLIMIT_MAPPED  23
13330 +
13331 +
13332 +#ifdef __KERNEL__
13333 +
13334 +#define        VLIM_NOCHECK    ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13335 +
13336 +/*     keep in sync with CRLIM_INFINITY */
13337 +
13338 +#define        VLIM_INFINITY   (~0ULL)
13339 +
13340 +#include <asm/atomic.h>
13341 +#include <asm/resource.h>
13342 +
13343 +#ifndef RLIM_INFINITY
13344 +#warning RLIM_INFINITY is undefined
13345 +#endif
13346 +
13347 +#define __rlim_val(l, r, v)    ((l)->res[r].v)
13348 +
13349 +#define __rlim_soft(l, r)      __rlim_val(l, r, soft)
13350 +#define __rlim_hard(l, r)      __rlim_val(l, r, hard)
13351 +
13352 +#define __rlim_rcur(l, r)      __rlim_val(l, r, rcur)
13353 +#define __rlim_rmin(l, r)      __rlim_val(l, r, rmin)
13354 +#define __rlim_rmax(l, r)      __rlim_val(l, r, rmax)
13355 +
13356 +#define __rlim_lhit(l, r)      __rlim_val(l, r, lhit)
13357 +#define __rlim_hit(l, r)       atomic_inc(&__rlim_lhit(l, r))
13358 +
13359 +typedef atomic_long_t rlim_atomic_t;
13360 +typedef unsigned long rlim_t;
13361 +
13362 +#define __rlim_get(l, r)       atomic_long_read(&__rlim_rcur(l, r))
13363 +#define __rlim_set(l, r, v)    atomic_long_set(&__rlim_rcur(l, r), v)
13364 +#define __rlim_inc(l, r)       atomic_long_inc(&__rlim_rcur(l, r))
13365 +#define __rlim_dec(l, r)       atomic_long_dec(&__rlim_rcur(l, r))
13366 +#define __rlim_add(l, r, v)    atomic_long_add(v, &__rlim_rcur(l, r))
13367 +#define __rlim_sub(l, r, v)    atomic_long_sub(v, &__rlim_rcur(l, r))
13368 +
13369 +
13370 +#if    (RLIM_INFINITY == VLIM_INFINITY)
13371 +#define        VX_VLIM(r) ((long long)(long)(r))
13372 +#define        VX_RLIM(v) ((rlim_t)(v))
13373 +#else
13374 +#define        VX_VLIM(r) (((r) == RLIM_INFINITY) \
13375 +               ? VLIM_INFINITY : (long long)(r))
13376 +#define        VX_RLIM(v) (((v) == VLIM_INFINITY) \
13377 +               ? RLIM_INFINITY : (rlim_t)(v))
13378 +#endif
13379 +
13380 +struct sysinfo;
13381 +
13382 +void vx_vsi_meminfo(struct sysinfo *);
13383 +void vx_vsi_swapinfo(struct sysinfo *);
13384 +long vx_vsi_cached(struct sysinfo *);
13385 +
13386 +#define NUM_LIMITS     24
13387 +
13388 +#endif /* __KERNEL__ */
13389 +#endif /* _VX_LIMIT_H */
13390 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/limit_int.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_int.h
13391 --- linux-2.6.35/include/linux/vserver/limit_int.h      1970-01-01 01:00:00.000000000 +0100
13392 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/limit_int.h        2010-08-02 17:05:06.000000000 +0200
13393 @@ -0,0 +1,198 @@
13394 +#ifndef _VX_LIMIT_INT_H
13395 +#define _VX_LIMIT_INT_H
13396 +
13397 +#include "context.h"
13398 +
13399 +#ifdef __KERNEL__
13400 +
13401 +#define VXD_RCRES_COND(r)      VXD_CBIT(cres, r)
13402 +#define VXD_RLIMIT_COND(r)     VXD_CBIT(limit, r)
13403 +
13404 +extern const char *vlimit_name[NUM_LIMITS];
13405 +
13406 +static inline void __vx_acc_cres(struct vx_info *vxi,
13407 +       int res, int dir, void *_data, char *_file, int _line)
13408 +{
13409 +       if (VXD_RCRES_COND(res))
13410 +               vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13411 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13412 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13413 +                       (dir > 0) ? "++" : "--", _data, _file, _line);
13414 +       if (!vxi)
13415 +               return;
13416 +
13417 +       if (dir > 0)
13418 +               __rlim_inc(&vxi->limit, res);
13419 +       else
13420 +               __rlim_dec(&vxi->limit, res);
13421 +}
13422 +
13423 +static inline void __vx_add_cres(struct vx_info *vxi,
13424 +       int res, int amount, void *_data, char *_file, int _line)
13425 +{
13426 +       if (VXD_RCRES_COND(res))
13427 +               vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13428 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13429 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13430 +                       amount, _data, _file, _line);
13431 +       if (amount == 0)
13432 +               return;
13433 +       if (!vxi)
13434 +               return;
13435 +       __rlim_add(&vxi->limit, res, amount);
13436 +}
13437 +
13438 +static inline
13439 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13440 +{
13441 +       int cond = (value > __rlim_rmax(limit, res));
13442 +
13443 +       if (cond)
13444 +               __rlim_rmax(limit, res) = value;
13445 +       return cond;
13446 +}
13447 +
13448 +static inline
13449 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13450 +{
13451 +       int cond = (value < __rlim_rmin(limit, res));
13452 +
13453 +       if (cond)
13454 +               __rlim_rmin(limit, res) = value;
13455 +       return cond;
13456 +}
13457 +
13458 +static inline
13459 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13460 +{
13461 +       if (!__vx_cres_adjust_max(limit, res, value))
13462 +               __vx_cres_adjust_min(limit, res, value);
13463 +}
13464 +
13465 +
13466 +/*     return values:
13467 +        +1 ... no limit hit
13468 +        -1 ... over soft limit
13469 +         0 ... over hard limit         */
13470 +
13471 +static inline int __vx_cres_avail(struct vx_info *vxi,
13472 +       int res, int num, char *_file, int _line)
13473 +{
13474 +       struct _vx_limit *limit;
13475 +       rlim_t value;
13476 +
13477 +       if (VXD_RLIMIT_COND(res))
13478 +               vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13479 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13480 +                       (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13481 +                       (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13482 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13483 +                       num, _file, _line);
13484 +       if (!vxi)
13485 +               return 1;
13486 +
13487 +       limit = &vxi->limit;
13488 +       value = __rlim_get(limit, res);
13489 +
13490 +       if (!__vx_cres_adjust_max(limit, res, value))
13491 +               __vx_cres_adjust_min(limit, res, value);
13492 +
13493 +       if (num == 0)
13494 +               return 1;
13495 +
13496 +       if (__rlim_soft(limit, res) == RLIM_INFINITY)
13497 +               return -1;
13498 +       if (value + num <= __rlim_soft(limit, res))
13499 +               return -1;
13500 +
13501 +       if (__rlim_hard(limit, res) == RLIM_INFINITY)
13502 +               return 1;
13503 +       if (value + num <= __rlim_hard(limit, res))
13504 +               return 1;
13505 +
13506 +       __rlim_hit(limit, res);
13507 +       return 0;
13508 +}
13509 +
13510 +
13511 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13512 +
13513 +static inline
13514 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13515 +{
13516 +       rlim_t value, sum = 0;
13517 +       int res;
13518 +
13519 +       while ((res = *array++)) {
13520 +               value = __rlim_get(limit, res);
13521 +               __vx_cres_fixup(limit, res, value);
13522 +               sum += value;
13523 +       }
13524 +       return sum;
13525 +}
13526 +
13527 +static inline
13528 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13529 +{
13530 +       rlim_t value = __vx_cres_array_sum(limit, array + 1);
13531 +       int res = *array;
13532 +
13533 +       if (value == __rlim_get(limit, res))
13534 +               return value;
13535 +
13536 +       __rlim_set(limit, res, value);
13537 +       /* now adjust min/max */
13538 +       if (!__vx_cres_adjust_max(limit, res, value))
13539 +               __vx_cres_adjust_min(limit, res, value);
13540 +
13541 +       return value;
13542 +}
13543 +
13544 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13545 +       const int *array, int num, char *_file, int _line)
13546 +{
13547 +       struct _vx_limit *limit;
13548 +       rlim_t value = 0;
13549 +       int res;
13550 +
13551 +       if (num == 0)
13552 +               return 1;
13553 +       if (!vxi)
13554 +               return 1;
13555 +
13556 +       limit = &vxi->limit;
13557 +       res = *array;
13558 +       value = __vx_cres_array_sum(limit, array + 1);
13559 +
13560 +       __rlim_set(limit, res, value);
13561 +       __vx_cres_fixup(limit, res, value);
13562 +
13563 +       return __vx_cres_avail(vxi, res, num, _file, _line);
13564 +}
13565 +
13566 +
13567 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13568 +{
13569 +       rlim_t value;
13570 +       int res;
13571 +
13572 +       /* complex resources first */
13573 +       if ((id < 0) || (id == RLIMIT_RSS))
13574 +               __vx_cres_array_fixup(limit, VLA_RSS);
13575 +
13576 +       for (res = 0; res < NUM_LIMITS; res++) {
13577 +               if ((id > 0) && (res != id))
13578 +                       continue;
13579 +
13580 +               value = __rlim_get(limit, res);
13581 +               __vx_cres_fixup(limit, res, value);
13582 +
13583 +               /* not supposed to happen, maybe warn? */
13584 +               if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13585 +                       __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13586 +       }
13587 +}
13588 +
13589 +
13590 +#endif /* __KERNEL__ */
13591 +#endif /* _VX_LIMIT_INT_H */
13592 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/monitor.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/monitor.h
13593 --- linux-2.6.35/include/linux/vserver/monitor.h        1970-01-01 01:00:00.000000000 +0100
13594 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/monitor.h  2010-08-02 17:05:06.000000000 +0200
13595 @@ -0,0 +1,96 @@
13596 +#ifndef _VX_MONITOR_H
13597 +#define _VX_MONITOR_H
13598 +
13599 +#include <linux/types.h>
13600 +
13601 +enum {
13602 +       VXM_UNUSED = 0,
13603 +
13604 +       VXM_SYNC = 0x10,
13605 +
13606 +       VXM_UPDATE = 0x20,
13607 +       VXM_UPDATE_1,
13608 +       VXM_UPDATE_2,
13609 +
13610 +       VXM_RQINFO_1 = 0x24,
13611 +       VXM_RQINFO_2,
13612 +
13613 +       VXM_ACTIVATE = 0x40,
13614 +       VXM_DEACTIVATE,
13615 +       VXM_IDLE,
13616 +
13617 +       VXM_HOLD = 0x44,
13618 +       VXM_UNHOLD,
13619 +
13620 +       VXM_MIGRATE = 0x48,
13621 +       VXM_RESCHED,
13622 +
13623 +       /* all other bits are flags */
13624 +       VXM_SCHED = 0x80,
13625 +};
13626 +
13627 +struct _vxm_update_1 {
13628 +       uint32_t tokens_max;
13629 +       uint32_t fill_rate;
13630 +       uint32_t interval;
13631 +};
13632 +
13633 +struct _vxm_update_2 {
13634 +       uint32_t tokens_min;
13635 +       uint32_t fill_rate;
13636 +       uint32_t interval;
13637 +};
13638 +
13639 +struct _vxm_rqinfo_1 {
13640 +       uint16_t running;
13641 +       uint16_t onhold;
13642 +       uint16_t iowait;
13643 +       uint16_t uintr;
13644 +       uint32_t idle_tokens;
13645 +};
13646 +
13647 +struct _vxm_rqinfo_2 {
13648 +       uint32_t norm_time;
13649 +       uint32_t idle_time;
13650 +       uint32_t idle_skip;
13651 +};
13652 +
13653 +struct _vxm_sched {
13654 +       uint32_t tokens;
13655 +       uint32_t norm_time;
13656 +       uint32_t idle_time;
13657 +};
13658 +
13659 +struct _vxm_task {
13660 +       uint16_t pid;
13661 +       uint16_t state;
13662 +};
13663 +
13664 +struct _vxm_event {
13665 +       uint32_t jif;
13666 +       union {
13667 +               uint32_t seq;
13668 +               uint32_t sec;
13669 +       };
13670 +       union {
13671 +               uint32_t tokens;
13672 +               uint32_t nsec;
13673 +               struct _vxm_task tsk;
13674 +       };
13675 +};
13676 +
13677 +struct _vx_mon_entry {
13678 +       uint16_t type;
13679 +       uint16_t xid;
13680 +       union {
13681 +               struct _vxm_event ev;
13682 +               struct _vxm_sched sd;
13683 +               struct _vxm_update_1 u1;
13684 +               struct _vxm_update_2 u2;
13685 +               struct _vxm_rqinfo_1 q1;
13686 +               struct _vxm_rqinfo_2 q2;
13687 +       };
13688 +};
13689 +
13690 +
13691 +#endif /* _VX_MONITOR_H */
13692 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/network_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/network_cmd.h
13693 --- linux-2.6.35/include/linux/vserver/network_cmd.h    1970-01-01 01:00:00.000000000 +0100
13694 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/network_cmd.h      2010-08-02 17:05:06.000000000 +0200
13695 @@ -0,0 +1,150 @@
13696 +#ifndef _VX_NETWORK_CMD_H
13697 +#define _VX_NETWORK_CMD_H
13698 +
13699 +
13700 +/* vinfo commands */
13701 +
13702 +#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
13703 +
13704 +#ifdef __KERNEL__
13705 +extern int vc_task_nid(uint32_t);
13706 +
13707 +#endif /* __KERNEL__ */
13708 +
13709 +#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
13710 +
13711 +struct vcmd_nx_info_v0 {
13712 +       uint32_t nid;
13713 +       /* more to come */
13714 +};
13715 +
13716 +#ifdef __KERNEL__
13717 +extern int vc_nx_info(struct nx_info *, void __user *);
13718 +
13719 +#endif /* __KERNEL__ */
13720 +
13721 +#include <linux/in.h>
13722 +#include <linux/in6.h>
13723 +
13724 +#define VCMD_net_create_v0     VC_CMD(VNET, 1, 0)
13725 +#define VCMD_net_create                VC_CMD(VNET, 1, 1)
13726 +
13727 +struct  vcmd_net_create {
13728 +       uint64_t flagword;
13729 +};
13730 +
13731 +#define VCMD_net_migrate       VC_CMD(NETMIG, 1, 0)
13732 +
13733 +#define VCMD_net_add           VC_CMD(NETALT, 1, 0)
13734 +#define VCMD_net_remove                VC_CMD(NETALT, 2, 0)
13735 +
13736 +struct vcmd_net_addr_v0 {
13737 +       uint16_t type;
13738 +       uint16_t count;
13739 +       struct in_addr ip[4];
13740 +       struct in_addr mask[4];
13741 +};
13742 +
13743 +#define VCMD_net_add_ipv4      VC_CMD(NETALT, 1, 1)
13744 +#define VCMD_net_remove_ipv4   VC_CMD(NETALT, 2, 1)
13745 +
13746 +struct vcmd_net_addr_ipv4_v1 {
13747 +       uint16_t type;
13748 +       uint16_t flags;
13749 +       struct in_addr ip;
13750 +       struct in_addr mask;
13751 +};
13752 +
13753 +#define VCMD_net_add_ipv6      VC_CMD(NETALT, 3, 1)
13754 +#define VCMD_net_remove_ipv6   VC_CMD(NETALT, 4, 1)
13755 +
13756 +struct vcmd_net_addr_ipv6_v1 {
13757 +       uint16_t type;
13758 +       uint16_t flags;
13759 +       uint32_t prefix;
13760 +       struct in6_addr ip;
13761 +       struct in6_addr mask;
13762 +};
13763 +
13764 +#define VCMD_add_match_ipv4    VC_CMD(NETALT, 5, 0)
13765 +#define VCMD_get_match_ipv4    VC_CMD(NETALT, 6, 0)
13766 +
13767 +struct vcmd_match_ipv4_v0 {
13768 +       uint16_t type;
13769 +       uint16_t flags;
13770 +       uint16_t parent;
13771 +       uint16_t prefix;
13772 +       struct in_addr ip;
13773 +       struct in_addr ip2;
13774 +       struct in_addr mask;
13775 +};
13776 +
13777 +#define VCMD_add_match_ipv6    VC_CMD(NETALT, 7, 0)
13778 +#define VCMD_get_match_ipv6    VC_CMD(NETALT, 8, 0)
13779 +
13780 +struct vcmd_match_ipv6_v0 {
13781 +       uint16_t type;
13782 +       uint16_t flags;
13783 +       uint16_t parent;
13784 +       uint16_t prefix;
13785 +       struct in6_addr ip;
13786 +       struct in6_addr ip2;
13787 +       struct in6_addr mask;
13788 +};
13789 +
13790 +
13791 +#ifdef __KERNEL__
13792 +extern int vc_net_create(uint32_t, void __user *);
13793 +extern int vc_net_migrate(struct nx_info *, void __user *);
13794 +
13795 +extern int vc_net_add(struct nx_info *, void __user *);
13796 +extern int vc_net_remove(struct nx_info *, void __user *);
13797 +
13798 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13799 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
13800 +
13801 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13802 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13803 +
13804 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13805 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13806 +
13807 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13808 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13809 +
13810 +#endif /* __KERNEL__ */
13811 +
13812 +
13813 +/* flag commands */
13814 +
13815 +#define VCMD_get_nflags                VC_CMD(FLAGS, 5, 0)
13816 +#define VCMD_set_nflags                VC_CMD(FLAGS, 6, 0)
13817 +
13818 +struct vcmd_net_flags_v0 {
13819 +       uint64_t flagword;
13820 +       uint64_t mask;
13821 +};
13822 +
13823 +#ifdef __KERNEL__
13824 +extern int vc_get_nflags(struct nx_info *, void __user *);
13825 +extern int vc_set_nflags(struct nx_info *, void __user *);
13826 +
13827 +#endif /* __KERNEL__ */
13828 +
13829 +
13830 +/* network caps commands */
13831 +
13832 +#define VCMD_get_ncaps         VC_CMD(FLAGS, 7, 0)
13833 +#define VCMD_set_ncaps         VC_CMD(FLAGS, 8, 0)
13834 +
13835 +struct vcmd_net_caps_v0 {
13836 +       uint64_t ncaps;
13837 +       uint64_t cmask;
13838 +};
13839 +
13840 +#ifdef __KERNEL__
13841 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13842 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13843 +
13844 +#endif /* __KERNEL__ */
13845 +#endif /* _VX_CONTEXT_CMD_H */
13846 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/network.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/network.h
13847 --- linux-2.6.35/include/linux/vserver/network.h        1970-01-01 01:00:00.000000000 +0100
13848 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/network.h  2010-08-02 17:05:06.000000000 +0200
13849 @@ -0,0 +1,146 @@
13850 +#ifndef _VX_NETWORK_H
13851 +#define _VX_NETWORK_H
13852 +
13853 +#include <linux/types.h>
13854 +
13855 +
13856 +#define MAX_N_CONTEXT  65535   /* Arbitrary limit */
13857 +
13858 +
13859 +/* network flags */
13860 +
13861 +#define NXF_INFO_PRIVATE       0x00000008
13862 +
13863 +#define NXF_SINGLE_IP          0x00000100
13864 +#define NXF_LBACK_REMAP                0x00000200
13865 +#define NXF_LBACK_ALLOW                0x00000400
13866 +
13867 +#define NXF_HIDE_NETIF         0x02000000
13868 +#define NXF_HIDE_LBACK         0x04000000
13869 +
13870 +#define NXF_STATE_SETUP                (1ULL << 32)
13871 +#define NXF_STATE_ADMIN                (1ULL << 34)
13872 +
13873 +#define NXF_SC_HELPER          (1ULL << 36)
13874 +#define NXF_PERSISTENT         (1ULL << 38)
13875 +
13876 +#define NXF_ONE_TIME           (0x0005ULL << 32)
13877 +
13878 +
13879 +#define        NXF_INIT_SET            (__nxf_init_set())
13880 +
13881 +static inline uint64_t __nxf_init_set(void) {
13882 +       return    NXF_STATE_ADMIN
13883 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13884 +               | NXF_LBACK_REMAP
13885 +               | NXF_HIDE_LBACK
13886 +#endif
13887 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13888 +               | NXF_SINGLE_IP
13889 +#endif
13890 +               | NXF_HIDE_NETIF;
13891 +}
13892 +
13893 +
13894 +/* network caps */
13895 +
13896 +#define NXC_TUN_CREATE         0x00000001
13897 +
13898 +#define NXC_RAW_ICMP           0x00000100
13899 +
13900 +
13901 +/* address types */
13902 +
13903 +#define NXA_TYPE_IPV4          0x0001
13904 +#define NXA_TYPE_IPV6          0x0002
13905 +
13906 +#define NXA_TYPE_NONE          0x0000
13907 +#define NXA_TYPE_ANY           0x00FF
13908 +
13909 +#define NXA_TYPE_ADDR          0x0010
13910 +#define NXA_TYPE_MASK          0x0020
13911 +#define NXA_TYPE_RANGE         0x0040
13912 +
13913 +#define NXA_MASK_ALL           (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13914 +
13915 +#define NXA_MOD_BCAST          0x0100
13916 +#define NXA_MOD_LBACK          0x0200
13917 +
13918 +#define NXA_LOOPBACK           0x1000
13919 +
13920 +#define NXA_MASK_BIND          (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13921 +#define NXA_MASK_SHOW          (NXA_MASK_ALL | NXA_LOOPBACK)
13922 +
13923 +#ifdef __KERNEL__
13924 +
13925 +#include <linux/list.h>
13926 +#include <linux/spinlock.h>
13927 +#include <linux/rcupdate.h>
13928 +#include <linux/in.h>
13929 +#include <linux/in6.h>
13930 +#include <asm/atomic.h>
13931 +
13932 +struct nx_addr_v4 {
13933 +       struct nx_addr_v4 *next;
13934 +       struct in_addr ip[2];
13935 +       struct in_addr mask;
13936 +       uint16_t type;
13937 +       uint16_t flags;
13938 +};
13939 +
13940 +struct nx_addr_v6 {
13941 +       struct nx_addr_v6 *next;
13942 +       struct in6_addr ip;
13943 +       struct in6_addr mask;
13944 +       uint32_t prefix;
13945 +       uint16_t type;
13946 +       uint16_t flags;
13947 +};
13948 +
13949 +struct nx_info {
13950 +       struct hlist_node nx_hlist;     /* linked list of nxinfos */
13951 +       nid_t nx_id;                    /* vnet id */
13952 +       atomic_t nx_usecnt;             /* usage count */
13953 +       atomic_t nx_tasks;              /* tasks count */
13954 +       int nx_state;                   /* context state */
13955 +
13956 +       uint64_t nx_flags;              /* network flag word */
13957 +       uint64_t nx_ncaps;              /* network capabilities */
13958 +
13959 +       struct in_addr v4_lback;        /* Loopback address */
13960 +       struct in_addr v4_bcast;        /* Broadcast address */
13961 +       struct nx_addr_v4 v4;           /* First/Single ipv4 address */
13962 +#ifdef CONFIG_IPV6
13963 +       struct nx_addr_v6 v6;           /* First/Single ipv6 address */
13964 +#endif
13965 +       char nx_name[65];               /* network context name */
13966 +};
13967 +
13968 +
13969 +/* status flags */
13970 +
13971 +#define NXS_HASHED      0x0001
13972 +#define NXS_SHUTDOWN    0x0100
13973 +#define NXS_RELEASED    0x8000
13974 +
13975 +extern struct nx_info *lookup_nx_info(int);
13976 +
13977 +extern int get_nid_list(int, unsigned int *, int);
13978 +extern int nid_is_hashed(nid_t);
13979 +
13980 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13981 +
13982 +extern long vs_net_change(struct nx_info *, unsigned int);
13983 +
13984 +struct sock;
13985 +
13986 +
13987 +#define NX_IPV4(n)     ((n)->v4.type != NXA_TYPE_NONE)
13988 +#ifdef  CONFIG_IPV6
13989 +#define NX_IPV6(n)     ((n)->v6.type != NXA_TYPE_NONE)
13990 +#else
13991 +#define NX_IPV6(n)     (0)
13992 +#endif
13993 +
13994 +#endif /* __KERNEL__ */
13995 +#endif /* _VX_NETWORK_H */
13996 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/percpu.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/percpu.h
13997 --- linux-2.6.35/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13998 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/percpu.h   2010-08-02 17:05:06.000000000 +0200
13999 @@ -0,0 +1,14 @@
14000 +#ifndef _VX_PERCPU_H
14001 +#define _VX_PERCPU_H
14002 +
14003 +#include "cvirt_def.h"
14004 +#include "sched_def.h"
14005 +
14006 +struct _vx_percpu {
14007 +       struct _vx_cvirt_pc cvirt;
14008 +       struct _vx_sched_pc sched;
14009 +};
14010 +
14011 +#define        PERCPU_PERCTX   (sizeof(struct _vx_percpu))
14012 +
14013 +#endif /* _VX_PERCPU_H */
14014 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/pid.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/pid.h
14015 --- linux-2.6.35/include/linux/vserver/pid.h    1970-01-01 01:00:00.000000000 +0100
14016 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/pid.h      2010-08-02 17:05:06.000000000 +0200
14017 @@ -0,0 +1,51 @@
14018 +#ifndef _VSERVER_PID_H
14019 +#define _VSERVER_PID_H
14020 +
14021 +/* pid faking stuff */
14022 +
14023 +#define vx_info_map_pid(v, p) \
14024 +       __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
14025 +#define vx_info_map_tgid(v,p)  vx_info_map_pid(v,p)
14026 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
14027 +#define vx_map_tgid(p) vx_map_pid(p)
14028 +
14029 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
14030 +       const char *func, const char *file, int line)
14031 +{
14032 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14033 +               vxfprintk(VXD_CBIT(cvirt, 2),
14034 +                       "vx_map_tgid: %p/%llx: %d -> %d",
14035 +                       vxi, (long long)vxi->vx_flags, pid,
14036 +                       (pid && pid == vxi->vx_initpid) ? 1 : pid,
14037 +                       func, file, line);
14038 +               if (pid == 0)
14039 +                       return 0;
14040 +               if (pid == vxi->vx_initpid)
14041 +                       return 1;
14042 +       }
14043 +       return pid;
14044 +}
14045 +
14046 +#define vx_info_rmap_pid(v, p) \
14047 +       __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
14048 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
14049 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
14050 +
14051 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
14052 +       const char *func, const char *file, int line)
14053 +{
14054 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14055 +               vxfprintk(VXD_CBIT(cvirt, 2),
14056 +                       "vx_rmap_tgid: %p/%llx: %d -> %d",
14057 +                       vxi, (long long)vxi->vx_flags, pid,
14058 +                       (pid == 1) ? vxi->vx_initpid : pid,
14059 +                       func, file, line);
14060 +               if ((pid == 1) && vxi->vx_initpid)
14061 +                       return vxi->vx_initpid;
14062 +               if (pid == vxi->vx_initpid)
14063 +                       return ~0U;
14064 +       }
14065 +       return pid;
14066 +}
14067 +
14068 +#endif
14069 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/sched_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched_cmd.h
14070 --- linux-2.6.35/include/linux/vserver/sched_cmd.h      1970-01-01 01:00:00.000000000 +0100
14071 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched_cmd.h        2010-08-02 17:05:06.000000000 +0200
14072 @@ -0,0 +1,108 @@
14073 +#ifndef _VX_SCHED_CMD_H
14074 +#define _VX_SCHED_CMD_H
14075 +
14076 +
14077 +/*  sched vserver commands */
14078 +
14079 +#define VCMD_set_sched_v2      VC_CMD(SCHED, 1, 2)
14080 +#define VCMD_set_sched_v3      VC_CMD(SCHED, 1, 3)
14081 +#define VCMD_set_sched_v4      VC_CMD(SCHED, 1, 4)
14082 +
14083 +struct vcmd_set_sched_v2 {
14084 +       int32_t fill_rate;
14085 +       int32_t interval;
14086 +       int32_t tokens;
14087 +       int32_t tokens_min;
14088 +       int32_t tokens_max;
14089 +       uint64_t cpu_mask;
14090 +};
14091 +
14092 +struct vcmd_set_sched_v3 {
14093 +       uint32_t set_mask;
14094 +       int32_t fill_rate;
14095 +       int32_t interval;
14096 +       int32_t tokens;
14097 +       int32_t tokens_min;
14098 +       int32_t tokens_max;
14099 +       int32_t priority_bias;
14100 +};
14101 +
14102 +struct vcmd_set_sched_v4 {
14103 +       uint32_t set_mask;
14104 +       int32_t fill_rate;
14105 +       int32_t interval;
14106 +       int32_t tokens;
14107 +       int32_t tokens_min;
14108 +       int32_t tokens_max;
14109 +       int32_t prio_bias;
14110 +       int32_t cpu_id;
14111 +       int32_t bucket_id;
14112 +};
14113 +
14114 +#define VCMD_set_sched         VC_CMD(SCHED, 1, 5)
14115 +#define VCMD_get_sched         VC_CMD(SCHED, 2, 5)
14116 +
14117 +struct vcmd_sched_v5 {
14118 +       uint32_t mask;
14119 +       int32_t cpu_id;
14120 +       int32_t bucket_id;
14121 +       int32_t fill_rate[2];
14122 +       int32_t interval[2];
14123 +       int32_t tokens;
14124 +       int32_t tokens_min;
14125 +       int32_t tokens_max;
14126 +       int32_t prio_bias;
14127 +};
14128 +
14129 +#define VXSM_FILL_RATE         0x0001
14130 +#define VXSM_INTERVAL          0x0002
14131 +#define VXSM_FILL_RATE2                0x0004
14132 +#define VXSM_INTERVAL2         0x0008
14133 +#define VXSM_TOKENS            0x0010
14134 +#define VXSM_TOKENS_MIN                0x0020
14135 +#define VXSM_TOKENS_MAX                0x0040
14136 +#define VXSM_PRIO_BIAS         0x0100
14137 +
14138 +#define VXSM_IDLE_TIME         0x0200
14139 +#define VXSM_FORCE             0x0400
14140 +
14141 +#define        VXSM_V3_MASK            0x0173
14142 +#define        VXSM_SET_MASK           0x01FF
14143 +
14144 +#define VXSM_CPU_ID            0x1000
14145 +#define VXSM_BUCKET_ID         0x2000
14146 +
14147 +#define VXSM_MSEC              0x4000
14148 +
14149 +#define SCHED_KEEP             (-2)    /* only for v2 */
14150 +
14151 +#ifdef __KERNEL__
14152 +
14153 +#include <linux/compiler.h>
14154 +
14155 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
14156 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
14157 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
14158 +extern int vc_set_sched(struct vx_info *, void __user *);
14159 +extern int vc_get_sched(struct vx_info *, void __user *);
14160 +
14161 +#endif /* __KERNEL__ */
14162 +
14163 +#define VCMD_sched_info                VC_CMD(SCHED, 3, 0)
14164 +
14165 +struct vcmd_sched_info {
14166 +       int32_t cpu_id;
14167 +       int32_t bucket_id;
14168 +       uint64_t user_msec;
14169 +       uint64_t sys_msec;
14170 +       uint64_t hold_msec;
14171 +       uint32_t token_usec;
14172 +       int32_t vavavoom;
14173 +};
14174 +
14175 +#ifdef __KERNEL__
14176 +
14177 +extern int vc_sched_info(struct vx_info *, void __user *);
14178 +
14179 +#endif /* __KERNEL__ */
14180 +#endif /* _VX_SCHED_CMD_H */
14181 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/sched_def.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched_def.h
14182 --- linux-2.6.35/include/linux/vserver/sched_def.h      1970-01-01 01:00:00.000000000 +0100
14183 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched_def.h        2010-08-02 17:05:06.000000000 +0200
14184 @@ -0,0 +1,68 @@
14185 +#ifndef _VX_SCHED_DEF_H
14186 +#define _VX_SCHED_DEF_H
14187 +
14188 +#include <linux/spinlock.h>
14189 +#include <linux/jiffies.h>
14190 +#include <linux/cpumask.h>
14191 +#include <asm/atomic.h>
14192 +#include <asm/param.h>
14193 +
14194 +
14195 +/* context sub struct */
14196 +
14197 +struct _vx_sched {
14198 +       spinlock_t tokens_lock;         /* lock for token bucket */
14199 +
14200 +       int tokens;                     /* number of CPU tokens */
14201 +       int fill_rate[2];               /* Fill rate: add X tokens... */
14202 +       int interval[2];                /* Divisor:   per Y jiffies   */
14203 +       int tokens_min;                 /* Limit:     minimum for unhold */
14204 +       int tokens_max;                 /* Limit:     no more than N tokens */
14205 +
14206 +       int prio_bias;                  /* bias offset for priority */
14207 +
14208 +       unsigned update_mask;           /* which features should be updated */
14209 +       cpumask_t update;               /* CPUs which should update */
14210 +};
14211 +
14212 +struct _vx_sched_pc {
14213 +       int tokens;                     /* number of CPU tokens */
14214 +       int flags;                      /* bucket flags */
14215 +
14216 +       int fill_rate[2];               /* Fill rate: add X tokens... */
14217 +       int interval[2];                /* Divisor:   per Y jiffies   */
14218 +       int tokens_min;                 /* Limit:     minimum for unhold */
14219 +       int tokens_max;                 /* Limit:     no more than N tokens */
14220 +
14221 +       int prio_bias;                  /* bias offset for priority */
14222 +       int vavavoom;                   /* last calculated vavavoom */
14223 +
14224 +       unsigned long norm_time;        /* last time accounted */
14225 +       unsigned long idle_time;        /* non linear time for fair sched */
14226 +       unsigned long token_time;       /* token time for accounting */
14227 +       unsigned long onhold;           /* jiffies when put on hold */
14228 +
14229 +       uint64_t user_ticks;            /* token tick events */
14230 +       uint64_t sys_ticks;             /* token tick events */
14231 +       uint64_t hold_ticks;            /* token ticks paused */
14232 +};
14233 +
14234 +
14235 +#define VXSF_ONHOLD    0x0001
14236 +#define VXSF_IDLE_TIME 0x0100
14237 +
14238 +#ifdef CONFIG_VSERVER_DEBUG
14239 +
14240 +static inline void __dump_vx_sched(struct _vx_sched *sched)
14241 +{
14242 +       printk("\t_vx_sched:\n");
14243 +       printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
14244 +               sched->fill_rate[0], sched->interval[0],
14245 +               sched->fill_rate[1], sched->interval[1],
14246 +               sched->tokens_min, sched->tokens_max);
14247 +       printk("\t priority = %4d\n", sched->prio_bias);
14248 +}
14249 +
14250 +#endif
14251 +
14252 +#endif /* _VX_SCHED_DEF_H */
14253 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/sched.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched.h
14254 --- linux-2.6.35/include/linux/vserver/sched.h  1970-01-01 01:00:00.000000000 +0100
14255 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/sched.h    2010-08-02 17:05:06.000000000 +0200
14256 @@ -0,0 +1,26 @@
14257 +#ifndef _VX_SCHED_H
14258 +#define _VX_SCHED_H
14259 +
14260 +
14261 +#ifdef __KERNEL__
14262 +
14263 +struct timespec;
14264 +
14265 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14266 +
14267 +
14268 +struct vx_info;
14269 +
14270 +void vx_update_load(struct vx_info *);
14271 +
14272 +
14273 +int vx_tokens_recalc(struct _vx_sched_pc *,
14274 +       unsigned long *, unsigned long *, int [2]);
14275 +
14276 +void vx_update_sched_param(struct _vx_sched *sched,
14277 +       struct _vx_sched_pc *sched_pc);
14278 +
14279 +#endif /* __KERNEL__ */
14280 +#else  /* _VX_SCHED_H */
14281 +#warning duplicate inclusion
14282 +#endif /* _VX_SCHED_H */
14283 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/signal_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/signal_cmd.h
14284 --- linux-2.6.35/include/linux/vserver/signal_cmd.h     1970-01-01 01:00:00.000000000 +0100
14285 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/signal_cmd.h       2010-08-02 17:05:06.000000000 +0200
14286 @@ -0,0 +1,43 @@
14287 +#ifndef _VX_SIGNAL_CMD_H
14288 +#define _VX_SIGNAL_CMD_H
14289 +
14290 +
14291 +/*  signalling vserver commands */
14292 +
14293 +#define VCMD_ctx_kill          VC_CMD(PROCTRL, 1, 0)
14294 +#define VCMD_wait_exit         VC_CMD(EVENT, 99, 0)
14295 +
14296 +struct vcmd_ctx_kill_v0 {
14297 +       int32_t pid;
14298 +       int32_t sig;
14299 +};
14300 +
14301 +struct vcmd_wait_exit_v0 {
14302 +       int32_t reboot_cmd;
14303 +       int32_t exit_code;
14304 +};
14305 +
14306 +#ifdef __KERNEL__
14307 +
14308 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14309 +extern int vc_wait_exit(struct vx_info *, void __user *);
14310 +
14311 +#endif /* __KERNEL__ */
14312 +
14313 +/*  process alteration commands */
14314 +
14315 +#define VCMD_get_pflags                VC_CMD(PROCALT, 5, 0)
14316 +#define VCMD_set_pflags                VC_CMD(PROCALT, 6, 0)
14317 +
14318 +struct vcmd_pflags_v0 {
14319 +       uint32_t flagword;
14320 +       uint32_t mask;
14321 +};
14322 +
14323 +#ifdef __KERNEL__
14324 +
14325 +extern int vc_get_pflags(uint32_t pid, void __user *);
14326 +extern int vc_set_pflags(uint32_t pid, void __user *);
14327 +
14328 +#endif /* __KERNEL__ */
14329 +#endif /* _VX_SIGNAL_CMD_H */
14330 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/signal.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/signal.h
14331 --- linux-2.6.35/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
14332 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/signal.h   2010-08-02 17:05:06.000000000 +0200
14333 @@ -0,0 +1,14 @@
14334 +#ifndef _VX_SIGNAL_H
14335 +#define _VX_SIGNAL_H
14336 +
14337 +
14338 +#ifdef __KERNEL__
14339 +
14340 +struct vx_info;
14341 +
14342 +int vx_info_kill(struct vx_info *, int, int);
14343 +
14344 +#endif /* __KERNEL__ */
14345 +#else  /* _VX_SIGNAL_H */
14346 +#warning duplicate inclusion
14347 +#endif /* _VX_SIGNAL_H */
14348 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/space_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/space_cmd.h
14349 --- linux-2.6.35/include/linux/vserver/space_cmd.h      1970-01-01 01:00:00.000000000 +0100
14350 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/space_cmd.h        2010-08-02 17:05:06.000000000 +0200
14351 @@ -0,0 +1,38 @@
14352 +#ifndef _VX_SPACE_CMD_H
14353 +#define _VX_SPACE_CMD_H
14354 +
14355 +
14356 +#define VCMD_enter_space_v0    VC_CMD(PROCALT, 1, 0)
14357 +#define VCMD_enter_space_v1    VC_CMD(PROCALT, 1, 1)
14358 +#define VCMD_enter_space       VC_CMD(PROCALT, 1, 2)
14359 +
14360 +#define VCMD_set_space_v0      VC_CMD(PROCALT, 3, 0)
14361 +#define VCMD_set_space_v1      VC_CMD(PROCALT, 3, 1)
14362 +#define VCMD_set_space         VC_CMD(PROCALT, 3, 2)
14363 +
14364 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14365 +
14366 +#define VCMD_get_space_mask    VC_CMD(VSPACE, 0, 1)
14367 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14368 +
14369 +
14370 +struct vcmd_space_mask_v1 {
14371 +       uint64_t mask;
14372 +};
14373 +
14374 +struct vcmd_space_mask_v2 {
14375 +       uint64_t mask;
14376 +       uint32_t index;
14377 +};
14378 +
14379 +
14380 +#ifdef __KERNEL__
14381 +
14382 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14383 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14384 +extern int vc_enter_space(struct vx_info *, void __user *);
14385 +extern int vc_set_space(struct vx_info *, void __user *);
14386 +extern int vc_get_space_mask(void __user *, int);
14387 +
14388 +#endif /* __KERNEL__ */
14389 +#endif /* _VX_SPACE_CMD_H */
14390 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/space.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/space.h
14391 --- linux-2.6.35/include/linux/vserver/space.h  1970-01-01 01:00:00.000000000 +0100
14392 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/space.h    2010-08-02 17:05:06.000000000 +0200
14393 @@ -0,0 +1,12 @@
14394 +#ifndef _VX_SPACE_H
14395 +#define _VX_SPACE_H
14396 +
14397 +#include <linux/types.h>
14398 +
14399 +struct vx_info;
14400 +
14401 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14402 +
14403 +#else  /* _VX_SPACE_H */
14404 +#warning duplicate inclusion
14405 +#endif /* _VX_SPACE_H */
14406 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/switch.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/switch.h
14407 --- linux-2.6.35/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
14408 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/switch.h   2010-08-02 17:05:06.000000000 +0200
14409 @@ -0,0 +1,98 @@
14410 +#ifndef _VX_SWITCH_H
14411 +#define _VX_SWITCH_H
14412 +
14413 +#include <linux/types.h>
14414 +
14415 +
14416 +#define VC_CATEGORY(c)         (((c) >> 24) & 0x3F)
14417 +#define VC_COMMAND(c)          (((c) >> 16) & 0xFF)
14418 +#define VC_VERSION(c)          ((c) & 0xFFF)
14419 +
14420 +#define VC_CMD(c, i, v)                ((((VC_CAT_ ## c) & 0x3F) << 24) \
14421 +                               | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14422 +
14423 +/*
14424 +
14425 +  Syscall Matrix V2.8
14426 +
14427 +        |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14428 +        |STATS  |DESTROY|ALTER  |CHANGE |LIMIT  |TEST   | |       |       |
14429 +        |INFO   |SETUP  |       |MOVE   |       |       | |       |       |
14430 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14431 +  SYSTEM |VERSION|VSETUP |VHOST  |       |       |       | |DEVICE |       |
14432 +  HOST   |     00|     01|     02|     03|     04|     05| |     06|     07|
14433 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14434 +  CPU    |       |VPROC  |PROCALT|PROCMIG|PROCTRL|       | |SCHED. |       |
14435 +  PROCESS|     08|     09|     10|     11|     12|     13| |     14|     15|
14436 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14437 +  MEMORY |       |       |       |       |MEMCTRL|       | |SWAP   |       |
14438 +        |     16|     17|     18|     19|     20|     21| |     22|     23|
14439 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14440 +  NETWORK|       |VNET   |NETALT |NETMIG |NETCTL |       | |SERIAL |       |
14441 +        |     24|     25|     26|     27|     28|     29| |     30|     31|
14442 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14443 +  DISK   |       |       |       |TAGMIG |DLIMIT |       | |INODE  |       |
14444 +  VFS    |     32|     33|     34|     35|     36|     37| |     38|     39|
14445 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14446 +  OTHER  |VSTAT  |       |       |       |       |       | |VINFO  |       |
14447 +        |     40|     41|     42|     43|     44|     45| |     46|     47|
14448 +  =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14449 +  SPECIAL|EVENT  |       |       |       |FLAGS  |       | |VSPACE |       |
14450 +        |     48|     49|     50|     51|     52|     53| |     54|     55|
14451 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14452 +  SPECIAL|DEBUG  |       |       |       |RLIMIT |SYSCALL| |       |COMPAT |
14453 +        |     56|     57|     58|     59|     60|TEST 61| |     62|     63|
14454 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14455 +
14456 +*/
14457 +
14458 +#define VC_CAT_VERSION         0
14459 +
14460 +#define VC_CAT_VSETUP          1
14461 +#define VC_CAT_VHOST           2
14462 +
14463 +#define VC_CAT_DEVICE          6
14464 +
14465 +#define VC_CAT_VPROC           9
14466 +#define VC_CAT_PROCALT         10
14467 +#define VC_CAT_PROCMIG         11
14468 +#define VC_CAT_PROCTRL         12
14469 +
14470 +#define VC_CAT_SCHED           14
14471 +#define VC_CAT_MEMCTRL         20
14472 +
14473 +#define VC_CAT_VNET            25
14474 +#define VC_CAT_NETALT          26
14475 +#define VC_CAT_NETMIG          27
14476 +#define VC_CAT_NETCTRL         28
14477 +
14478 +#define VC_CAT_TAGMIG          35
14479 +#define VC_CAT_DLIMIT          36
14480 +#define VC_CAT_INODE           38
14481 +
14482 +#define VC_CAT_VSTAT           40
14483 +#define VC_CAT_VINFO           46
14484 +#define VC_CAT_EVENT           48
14485 +
14486 +#define VC_CAT_FLAGS           52
14487 +#define VC_CAT_VSPACE          54
14488 +#define VC_CAT_DEBUG           56
14489 +#define VC_CAT_RLIMIT          60
14490 +
14491 +#define VC_CAT_SYSTEST         61
14492 +#define VC_CAT_COMPAT          63
14493 +
14494 +/*  query version */
14495 +
14496 +#define VCMD_get_version       VC_CMD(VERSION, 0, 0)
14497 +#define VCMD_get_vci           VC_CMD(VERSION, 1, 0)
14498 +
14499 +
14500 +#ifdef __KERNEL__
14501 +
14502 +#include <linux/errno.h>
14503 +
14504 +#endif /* __KERNEL__ */
14505 +
14506 +#endif /* _VX_SWITCH_H */
14507 +
14508 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/tag_cmd.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/tag_cmd.h
14509 --- linux-2.6.35/include/linux/vserver/tag_cmd.h        1970-01-01 01:00:00.000000000 +0100
14510 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/tag_cmd.h  2010-08-02 17:05:06.000000000 +0200
14511 @@ -0,0 +1,22 @@
14512 +#ifndef _VX_TAG_CMD_H
14513 +#define _VX_TAG_CMD_H
14514 +
14515 +
14516 +/* vinfo commands */
14517 +
14518 +#define VCMD_task_tag          VC_CMD(VINFO, 3, 0)
14519 +
14520 +#ifdef __KERNEL__
14521 +extern int vc_task_tag(uint32_t);
14522 +
14523 +#endif /* __KERNEL__ */
14524 +
14525 +/* context commands */
14526 +
14527 +#define VCMD_tag_migrate       VC_CMD(TAGMIG, 1, 0)
14528 +
14529 +#ifdef __KERNEL__
14530 +extern int vc_tag_migrate(uint32_t);
14531 +
14532 +#endif /* __KERNEL__ */
14533 +#endif /* _VX_TAG_CMD_H */
14534 diff -NurpP --minimal linux-2.6.35/include/linux/vserver/tag.h linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/tag.h
14535 --- linux-2.6.35/include/linux/vserver/tag.h    1970-01-01 01:00:00.000000000 +0100
14536 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vserver/tag.h      2010-08-02 17:05:06.000000000 +0200
14537 @@ -0,0 +1,143 @@
14538 +#ifndef _DX_TAG_H
14539 +#define _DX_TAG_H
14540 +
14541 +#include <linux/types.h>
14542 +
14543 +
14544 +#define DX_TAG(in)     (IS_TAGGED(in))
14545 +
14546 +
14547 +#ifdef CONFIG_TAG_NFSD
14548 +#define DX_TAG_NFSD    1
14549 +#else
14550 +#define DX_TAG_NFSD    0
14551 +#endif
14552 +
14553 +
14554 +#ifdef CONFIG_TAGGING_NONE
14555 +
14556 +#define MAX_UID                0xFFFFFFFF
14557 +#define MAX_GID                0xFFFFFFFF
14558 +
14559 +#define INOTAG_TAG(cond, uid, gid, tag)        (0)
14560 +
14561 +#define TAGINO_UID(cond, uid, tag)     (uid)
14562 +#define TAGINO_GID(cond, gid, tag)     (gid)
14563 +
14564 +#endif
14565 +
14566 +
14567 +#ifdef CONFIG_TAGGING_GID16
14568 +
14569 +#define MAX_UID                0xFFFFFFFF
14570 +#define MAX_GID                0x0000FFFF
14571 +
14572 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14573 +       ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14574 +
14575 +#define TAGINO_UID(cond, uid, tag)     (uid)
14576 +#define TAGINO_GID(cond, gid, tag)     \
14577 +       ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14578 +
14579 +#endif
14580 +
14581 +
14582 +#ifdef CONFIG_TAGGING_ID24
14583 +
14584 +#define MAX_UID                0x00FFFFFF
14585 +#define MAX_GID                0x00FFFFFF
14586 +
14587 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14588 +       ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14589 +
14590 +#define TAGINO_UID(cond, uid, tag)     \
14591 +       ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14592 +#define TAGINO_GID(cond, gid, tag)     \
14593 +       ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14594 +
14595 +#endif
14596 +
14597 +
14598 +#ifdef CONFIG_TAGGING_UID16
14599 +
14600 +#define MAX_UID                0x0000FFFF
14601 +#define MAX_GID                0xFFFFFFFF
14602 +
14603 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14604 +       ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14605 +
14606 +#define TAGINO_UID(cond, uid, tag)     \
14607 +       ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14608 +#define TAGINO_GID(cond, gid, tag)     (gid)
14609 +
14610 +#endif
14611 +
14612 +
14613 +#ifdef CONFIG_TAGGING_INTERN
14614 +
14615 +#define MAX_UID                0xFFFFFFFF
14616 +#define MAX_GID                0xFFFFFFFF
14617 +
14618 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14619 +       ((cond) ? (tag) : 0)
14620 +
14621 +#define TAGINO_UID(cond, uid, tag)     (uid)
14622 +#define TAGINO_GID(cond, gid, tag)     (gid)
14623 +
14624 +#endif
14625 +
14626 +
14627 +#ifndef CONFIG_TAGGING_NONE
14628 +#define dx_current_fstag(sb)   \
14629 +       ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14630 +#else
14631 +#define dx_current_fstag(sb)   (0)
14632 +#endif
14633 +
14634 +#ifndef CONFIG_TAGGING_INTERN
14635 +#define TAGINO_TAG(cond, tag)  (0)
14636 +#else
14637 +#define TAGINO_TAG(cond, tag)  ((cond) ? (tag) : 0)
14638 +#endif
14639 +
14640 +#define INOTAG_UID(cond, uid, gid)     \
14641 +       ((cond) ? ((uid) & MAX_UID) : (uid))
14642 +#define INOTAG_GID(cond, uid, gid)     \
14643 +       ((cond) ? ((gid) & MAX_GID) : (gid))
14644 +
14645 +
14646 +static inline uid_t dx_map_uid(uid_t uid)
14647 +{
14648 +       if ((uid > MAX_UID) && (uid != -1))
14649 +               uid = -2;
14650 +       return (uid & MAX_UID);
14651 +}
14652 +
14653 +static inline gid_t dx_map_gid(gid_t gid)
14654 +{
14655 +       if ((gid > MAX_GID) && (gid != -1))
14656 +               gid = -2;
14657 +       return (gid & MAX_GID);
14658 +}
14659 +
14660 +struct peer_tag {
14661 +       int32_t xid;
14662 +       int32_t nid;
14663 +};
14664 +
14665 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14666 +
14667 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14668 +                unsigned long *flags);
14669 +
14670 +#ifdef CONFIG_PROPAGATE
14671 +
14672 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14673 +
14674 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14675 +
14676 +#else
14677 +#define dx_propagate_tag(n, i) do { } while (0)
14678 +#endif
14679 +
14680 +#endif /* _DX_TAG_H */
14681 diff -NurpP --minimal linux-2.6.35/include/linux/vs_inet6.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_inet6.h
14682 --- linux-2.6.35/include/linux/vs_inet6.h       1970-01-01 01:00:00.000000000 +0100
14683 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_inet6.h 2010-08-02 17:05:06.000000000 +0200
14684 @@ -0,0 +1,246 @@
14685 +#ifndef _VS_INET6_H
14686 +#define _VS_INET6_H
14687 +
14688 +#include "vserver/base.h"
14689 +#include "vserver/network.h"
14690 +#include "vserver/debug.h"
14691 +
14692 +#include <net/ipv6.h>
14693 +
14694 +#define NXAV6(a)       &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
14695 +#define NXAV6_FMT      "[%pI6/%pI6/%d:%04x]"
14696 +
14697 +
14698 +#ifdef CONFIG_IPV6
14699 +
14700 +static inline
14701 +int v6_addr_match(struct nx_addr_v6 *nxa,
14702 +       const struct in6_addr *addr, uint16_t mask)
14703 +{
14704 +       int ret = 0;
14705 +
14706 +       switch (nxa->type & mask) {
14707 +       case NXA_TYPE_MASK:
14708 +               ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
14709 +               break;
14710 +       case NXA_TYPE_ADDR:
14711 +               ret = ipv6_addr_equal(&nxa->ip, addr);
14712 +               break;
14713 +       case NXA_TYPE_ANY:
14714 +               ret = 1;
14715 +               break;
14716 +       }
14717 +       vxdprintk(VXD_CBIT(net, 0),
14718 +               "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
14719 +               nxa, NXAV6(nxa), addr, mask, ret);
14720 +       return ret;
14721 +}
14722 +
14723 +static inline
14724 +int v6_addr_in_nx_info(struct nx_info *nxi,
14725 +       const struct in6_addr *addr, uint16_t mask)
14726 +{
14727 +       struct nx_addr_v6 *nxa;
14728 +       int ret = 1;
14729 +
14730 +       if (!nxi)
14731 +               goto out;
14732 +       for (nxa = &nxi->v6; nxa; nxa = nxa->next)
14733 +               if (v6_addr_match(nxa, addr, mask))
14734 +                       goto out;
14735 +       ret = 0;
14736 +out:
14737 +       vxdprintk(VXD_CBIT(net, 0),
14738 +               "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
14739 +               nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
14740 +       return ret;
14741 +}
14742 +
14743 +static inline
14744 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
14745 +{
14746 +       /* FIXME: needs full range checks */
14747 +       return v6_addr_match(nxa, &addr->ip, mask);
14748 +}
14749 +
14750 +static inline
14751 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
14752 +{
14753 +       struct nx_addr_v6 *ptr;
14754 +
14755 +       for (ptr = &nxi->v6; ptr; ptr = ptr->next)
14756 +               if (v6_nx_addr_match(ptr, nxa, mask))
14757 +                       return 1;
14758 +       return 0;
14759 +}
14760 +
14761 +
14762 +/*
14763 + *     Check if a given address matches for a socket
14764 + *
14765 + *     nxi:            the socket's nx_info if any
14766 + *     addr:           to be verified address
14767 + */
14768 +static inline
14769 +int v6_sock_addr_match (
14770 +       struct nx_info *nxi,
14771 +       struct inet_sock *inet,
14772 +       struct in6_addr *addr)
14773 +{
14774 +       struct sock *sk = &inet->sk;
14775 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
14776 +
14777 +       if (!ipv6_addr_any(addr) &&
14778 +               ipv6_addr_equal(saddr, addr))
14779 +               return 1;
14780 +       if (ipv6_addr_any(saddr))
14781 +               return v6_addr_in_nx_info(nxi, addr, -1);
14782 +       return 0;
14783 +}
14784 +
14785 +/*
14786 + *     check if address is covered by socket
14787 + *
14788 + *     sk:     the socket to check against
14789 + *     addr:   the address in question (must be != 0)
14790 + */
14791 +
14792 +static inline
14793 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
14794 +{
14795 +       struct nx_info *nxi = sk->sk_nx_info;
14796 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
14797 +
14798 +       vxdprintk(VXD_CBIT(net, 5),
14799 +               "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
14800 +               sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
14801 +               (sk->sk_socket?sk->sk_socket->flags:0));
14802 +
14803 +       if (!ipv6_addr_any(saddr)) {    /* direct address match */
14804 +               return v6_addr_match(nxa, saddr, -1);
14805 +       } else if (nxi) {               /* match against nx_info */
14806 +               return v6_nx_addr_in_nx_info(nxi, nxa, -1);
14807 +       } else {                        /* unrestricted any socket */
14808 +               return 1;
14809 +       }
14810 +}
14811 +
14812 +
14813 +/* inet related checks and helpers */
14814 +
14815 +
14816 +struct in_ifaddr;
14817 +struct net_device;
14818 +struct sock;
14819 +
14820 +
14821 +#include <linux/netdevice.h>
14822 +#include <linux/inetdevice.h>
14823 +#include <net/inet_timewait_sock.h>
14824 +
14825 +
14826 +int dev_in_nx_info(struct net_device *, struct nx_info *);
14827 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
14828 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
14829 +
14830 +
14831 +
14832 +static inline
14833 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
14834 +{
14835 +       if (!nxi)
14836 +               return 1;
14837 +       if (!ifa)
14838 +               return 0;
14839 +       return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
14840 +}
14841 +
14842 +static inline
14843 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
14844 +{
14845 +       vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
14846 +               nxi, nxi ? nxi->nx_id : 0, ifa,
14847 +               nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
14848 +
14849 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
14850 +               return 1;
14851 +       if (v6_ifa_in_nx_info(ifa, nxi))
14852 +               return 1;
14853 +       return 0;
14854 +}
14855 +
14856 +
14857 +struct nx_v6_sock_addr {
14858 +       struct in6_addr saddr;  /* Address used for validation */
14859 +       struct in6_addr baddr;  /* Address used for socket bind */
14860 +};
14861 +
14862 +static inline
14863 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
14864 +       struct nx_v6_sock_addr *nsa)
14865 +{
14866 +       // struct sock *sk = &inet->sk;
14867 +       // struct nx_info *nxi = sk->sk_nx_info;
14868 +       struct in6_addr saddr = addr->sin6_addr;
14869 +       struct in6_addr baddr = saddr;
14870 +
14871 +       nsa->saddr = saddr;
14872 +       nsa->baddr = baddr;
14873 +       return 0;
14874 +}
14875 +
14876 +static inline
14877 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
14878 +{
14879 +       // struct sock *sk = &inet->sk;
14880 +       // struct in6_addr *saddr = inet6_rcv_saddr(sk);
14881 +
14882 +       // *saddr = nsa->baddr;
14883 +       // inet->inet_saddr = nsa->baddr;
14884 +}
14885 +
14886 +static inline
14887 +int nx_info_has_v6(struct nx_info *nxi)
14888 +{
14889 +       if (!nxi)
14890 +               return 1;
14891 +       if (NX_IPV6(nxi))
14892 +               return 1;
14893 +       return 0;
14894 +}
14895 +
14896 +#else /* CONFIG_IPV6 */
14897 +
14898 +static inline
14899 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
14900 +{
14901 +       return 1;
14902 +}
14903 +
14904 +
14905 +static inline
14906 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
14907 +{
14908 +       return 1;
14909 +}
14910 +
14911 +static inline
14912 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
14913 +{
14914 +       return 1;
14915 +}
14916 +
14917 +static inline
14918 +int nx_info_has_v6(struct nx_info *nxi)
14919 +{
14920 +       return 0;
14921 +}
14922 +
14923 +#endif /* CONFIG_IPV6 */
14924 +
14925 +#define current_nx_info_has_v6() \
14926 +       nx_info_has_v6(current_nx_info())
14927 +
14928 +#else
14929 +#warning duplicate inclusion
14930 +#endif
14931 diff -NurpP --minimal linux-2.6.35/include/linux/vs_inet.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_inet.h
14932 --- linux-2.6.35/include/linux/vs_inet.h        1970-01-01 01:00:00.000000000 +0100
14933 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_inet.h  2010-08-02 17:05:06.000000000 +0200
14934 @@ -0,0 +1,342 @@
14935 +#ifndef _VS_INET_H
14936 +#define _VS_INET_H
14937 +
14938 +#include "vserver/base.h"
14939 +#include "vserver/network.h"
14940 +#include "vserver/debug.h"
14941 +
14942 +#define IPI_LOOPBACK   htonl(INADDR_LOOPBACK)
14943 +
14944 +#define NXAV4(a)       NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
14945 +                       NIPQUAD((a)->mask), (a)->type
14946 +#define NXAV4_FMT      "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
14947 +
14948 +
14949 +static inline
14950 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
14951 +{
14952 +       __be32 ip = nxa->ip[0].s_addr;
14953 +       __be32 mask = nxa->mask.s_addr;
14954 +       __be32 bcast = ip | ~mask;
14955 +       int ret = 0;
14956 +
14957 +       switch (nxa->type & tmask) {
14958 +       case NXA_TYPE_MASK:
14959 +               ret = (ip == (addr & mask));
14960 +               break;
14961 +       case NXA_TYPE_ADDR:
14962 +               ret = 3;
14963 +               if (addr == ip)
14964 +                       break;
14965 +               /* fall through to broadcast */
14966 +       case NXA_MOD_BCAST:
14967 +               ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
14968 +               break;
14969 +       case NXA_TYPE_RANGE:
14970 +               ret = ((nxa->ip[0].s_addr <= addr) &&
14971 +                       (nxa->ip[1].s_addr > addr));
14972 +               break;
14973 +       case NXA_TYPE_ANY:
14974 +               ret = 2;
14975 +               break;
14976 +       }
14977 +
14978 +       vxdprintk(VXD_CBIT(net, 0),
14979 +               "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
14980 +               nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
14981 +       return ret;
14982 +}
14983 +
14984 +static inline
14985 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
14986 +{
14987 +       struct nx_addr_v4 *nxa;
14988 +       int ret = 1;
14989 +
14990 +       if (!nxi)
14991 +               goto out;
14992 +
14993 +       ret = 2;
14994 +       /* allow 127.0.0.1 when remapping lback */
14995 +       if ((tmask & NXA_LOOPBACK) &&
14996 +               (addr == IPI_LOOPBACK) &&
14997 +               nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
14998 +               goto out;
14999 +       ret = 3;
15000 +       /* check for lback address */
15001 +       if ((tmask & NXA_MOD_LBACK) &&
15002 +               (nxi->v4_lback.s_addr == addr))
15003 +               goto out;
15004 +       ret = 4;
15005 +       /* check for broadcast address */
15006 +       if ((tmask & NXA_MOD_BCAST) &&
15007 +               (nxi->v4_bcast.s_addr == addr))
15008 +               goto out;
15009 +       ret = 5;
15010 +       /* check for v4 addresses */
15011 +       for (nxa = &nxi->v4; nxa; nxa = nxa->next)
15012 +               if (v4_addr_match(nxa, addr, tmask))
15013 +                       goto out;
15014 +       ret = 0;
15015 +out:
15016 +       vxdprintk(VXD_CBIT(net, 0),
15017 +               "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
15018 +               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
15019 +       return ret;
15020 +}
15021 +
15022 +static inline
15023 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
15024 +{
15025 +       /* FIXME: needs full range checks */
15026 +       return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
15027 +}
15028 +
15029 +static inline
15030 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
15031 +{
15032 +       struct nx_addr_v4 *ptr;
15033 +
15034 +       for (ptr = &nxi->v4; ptr; ptr = ptr->next)
15035 +               if (v4_nx_addr_match(ptr, nxa, mask))
15036 +                       return 1;
15037 +       return 0;
15038 +}
15039 +
15040 +#include <net/inet_sock.h>
15041 +
15042 +/*
15043 + *     Check if a given address matches for a socket
15044 + *
15045 + *     nxi:            the socket's nx_info if any
15046 + *     addr:           to be verified address
15047 + */
15048 +static inline
15049 +int v4_sock_addr_match (
15050 +       struct nx_info *nxi,
15051 +       struct inet_sock *inet,
15052 +       __be32 addr)
15053 +{
15054 +       __be32 saddr = inet->inet_rcv_saddr;
15055 +       __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
15056 +
15057 +       if (addr && (saddr == addr || bcast == addr))
15058 +               return 1;
15059 +       if (!saddr)
15060 +               return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
15061 +       return 0;
15062 +}
15063 +
15064 +
15065 +/* inet related checks and helpers */
15066 +
15067 +
15068 +struct in_ifaddr;
15069 +struct net_device;
15070 +struct sock;
15071 +
15072 +#ifdef CONFIG_INET
15073 +
15074 +#include <linux/netdevice.h>
15075 +#include <linux/inetdevice.h>
15076 +#include <net/inet_sock.h>
15077 +#include <net/inet_timewait_sock.h>
15078 +
15079 +
15080 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15081 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
15082 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
15083 +
15084 +
15085 +/*
15086 + *     check if address is covered by socket
15087 + *
15088 + *     sk:     the socket to check against
15089 + *     addr:   the address in question (must be != 0)
15090 + */
15091 +
15092 +static inline
15093 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
15094 +{
15095 +       struct nx_info *nxi = sk->sk_nx_info;
15096 +       __be32 saddr = inet_rcv_saddr(sk);
15097 +
15098 +       vxdprintk(VXD_CBIT(net, 5),
15099 +               "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
15100 +               sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
15101 +               (sk->sk_socket?sk->sk_socket->flags:0));
15102 +
15103 +       if (saddr) {            /* direct address match */
15104 +               return v4_addr_match(nxa, saddr, -1);
15105 +       } else if (nxi) {       /* match against nx_info */
15106 +               return v4_nx_addr_in_nx_info(nxi, nxa, -1);
15107 +       } else {                /* unrestricted any socket */
15108 +               return 1;
15109 +       }
15110 +}
15111 +
15112 +
15113 +
15114 +static inline
15115 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
15116 +{
15117 +       vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p Â»%s«) %d",
15118 +               nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
15119 +               nxi ? dev_in_nx_info(dev, nxi) : 0);
15120 +
15121 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15122 +               return 1;
15123 +       if (dev_in_nx_info(dev, nxi))
15124 +               return 1;
15125 +       return 0;
15126 +}
15127 +
15128 +
15129 +static inline
15130 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
15131 +{
15132 +       if (!nxi)
15133 +               return 1;
15134 +       if (!ifa)
15135 +               return 0;
15136 +       return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
15137 +}
15138 +
15139 +static inline
15140 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
15141 +{
15142 +       vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
15143 +               nxi, nxi ? nxi->nx_id : 0, ifa,
15144 +               nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
15145 +
15146 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15147 +               return 1;
15148 +       if (v4_ifa_in_nx_info(ifa, nxi))
15149 +               return 1;
15150 +       return 0;
15151 +}
15152 +
15153 +
15154 +struct nx_v4_sock_addr {
15155 +       __be32 saddr;   /* Address used for validation */
15156 +       __be32 baddr;   /* Address used for socket bind */
15157 +};
15158 +
15159 +static inline
15160 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
15161 +       struct nx_v4_sock_addr *nsa)
15162 +{
15163 +       struct sock *sk = &inet->sk;
15164 +       struct nx_info *nxi = sk->sk_nx_info;
15165 +       __be32 saddr = addr->sin_addr.s_addr;
15166 +       __be32 baddr = saddr;
15167 +
15168 +       vxdprintk(VXD_CBIT(net, 3),
15169 +               "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
15170 +               sk, sk->sk_nx_info, sk->sk_socket,
15171 +               (sk->sk_socket ? sk->sk_socket->flags : 0),
15172 +               NIPQUAD(saddr));
15173 +
15174 +       if (nxi) {
15175 +               if (saddr == INADDR_ANY) {
15176 +                       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
15177 +                               baddr = nxi->v4.ip[0].s_addr;
15178 +               } else if (saddr == IPI_LOOPBACK) {
15179 +                       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15180 +                               baddr = nxi->v4_lback.s_addr;
15181 +               } else {        /* normal address bind */
15182 +                       if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
15183 +                               return -EADDRNOTAVAIL;
15184 +               }
15185 +       }
15186 +
15187 +       vxdprintk(VXD_CBIT(net, 3),
15188 +               "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
15189 +               sk, NIPQUAD(saddr), NIPQUAD(baddr));
15190 +
15191 +       nsa->saddr = saddr;
15192 +       nsa->baddr = baddr;
15193 +       return 0;
15194 +}
15195 +
15196 +static inline
15197 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
15198 +{
15199 +       inet->inet_saddr = nsa->baddr;
15200 +       inet->inet_rcv_saddr = nsa->baddr;
15201 +}
15202 +
15203 +
15204 +/*
15205 + *      helper to simplify inet_lookup_listener
15206 + *
15207 + *      nxi:   the socket's nx_info if any
15208 + *      addr:  to be verified address
15209 + *      saddr: socket address
15210 + */
15211 +static inline int v4_inet_addr_match (
15212 +       struct nx_info *nxi,
15213 +       __be32 addr,
15214 +       __be32 saddr)
15215 +{
15216 +       if (addr && (saddr == addr))
15217 +               return 1;
15218 +       if (!saddr)
15219 +               return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
15220 +       return 0;
15221 +}
15222 +
15223 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
15224 +{
15225 +       if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
15226 +               (addr == nxi->v4_lback.s_addr))
15227 +               return IPI_LOOPBACK;
15228 +       return addr;
15229 +}
15230 +
15231 +static inline
15232 +int nx_info_has_v4(struct nx_info *nxi)
15233 +{
15234 +       if (!nxi)
15235 +               return 1;
15236 +       if (NX_IPV4(nxi))
15237 +               return 1;
15238 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15239 +               return 1;
15240 +       return 0;
15241 +}
15242 +
15243 +#else /* CONFIG_INET */
15244 +
15245 +static inline
15246 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
15247 +{
15248 +       return 1;
15249 +}
15250 +
15251 +static inline
15252 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
15253 +{
15254 +       return 1;
15255 +}
15256 +
15257 +static inline
15258 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
15259 +{
15260 +       return 1;
15261 +}
15262 +
15263 +static inline
15264 +int nx_info_has_v4(struct nx_info *nxi)
15265 +{
15266 +       return 0;
15267 +}
15268 +
15269 +#endif /* CONFIG_INET */
15270 +
15271 +#define current_nx_info_has_v4() \
15272 +       nx_info_has_v4(current_nx_info())
15273 +
15274 +#else
15275 +// #warning duplicate inclusion
15276 +#endif
15277 diff -NurpP --minimal linux-2.6.35/include/linux/vs_limit.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_limit.h
15278 --- linux-2.6.35/include/linux/vs_limit.h       1970-01-01 01:00:00.000000000 +0100
15279 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_limit.h 2010-08-02 17:05:06.000000000 +0200
15280 @@ -0,0 +1,140 @@
15281 +#ifndef _VS_LIMIT_H
15282 +#define _VS_LIMIT_H
15283 +
15284 +#include "vserver/limit.h"
15285 +#include "vserver/base.h"
15286 +#include "vserver/context.h"
15287 +#include "vserver/debug.h"
15288 +#include "vserver/context.h"
15289 +#include "vserver/limit_int.h"
15290 +
15291 +
15292 +#define vx_acc_cres(v, d, p, r) \
15293 +       __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
15294 +
15295 +#define vx_acc_cres_cond(x, d, p, r) \
15296 +       __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15297 +       r, d, p, __FILE__, __LINE__)
15298 +
15299 +
15300 +#define vx_add_cres(v, a, p, r) \
15301 +       __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
15302 +#define vx_sub_cres(v, a, p, r)                vx_add_cres(v, -(a), p, r)
15303 +
15304 +#define vx_add_cres_cond(x, a, p, r) \
15305 +       __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15306 +       r, a, p, __FILE__, __LINE__)
15307 +#define vx_sub_cres_cond(x, a, p, r)   vx_add_cres_cond(x, -(a), p, r)
15308 +
15309 +
15310 +/* process and file limits */
15311 +
15312 +#define vx_nproc_inc(p) \
15313 +       vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
15314 +
15315 +#define vx_nproc_dec(p) \
15316 +       vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
15317 +
15318 +#define vx_files_inc(f) \
15319 +       vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
15320 +
15321 +#define vx_files_dec(f) \
15322 +       vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
15323 +
15324 +#define vx_locks_inc(l) \
15325 +       vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
15326 +
15327 +#define vx_locks_dec(l) \
15328 +       vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
15329 +
15330 +#define vx_openfd_inc(f) \
15331 +       vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
15332 +
15333 +#define vx_openfd_dec(f) \
15334 +       vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
15335 +
15336 +
15337 +#define vx_cres_avail(v, n, r) \
15338 +       __vx_cres_avail(v, r, n, __FILE__, __LINE__)
15339 +
15340 +
15341 +#define vx_nproc_avail(n) \
15342 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
15343 +
15344 +#define vx_files_avail(n) \
15345 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
15346 +
15347 +#define vx_locks_avail(n) \
15348 +       vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
15349 +
15350 +#define vx_openfd_avail(n) \
15351 +       vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
15352 +
15353 +
15354 +/* dentry limits */
15355 +
15356 +#define vx_dentry_inc(d) do {                                          \
15357 +       if (atomic_read(&d->d_count) == 1)                              \
15358 +               vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY);    \
15359 +       } while (0)
15360 +
15361 +#define vx_dentry_dec(d) do {                                          \
15362 +       if (atomic_read(&d->d_count) == 0)                              \
15363 +               vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY);    \
15364 +       } while (0)
15365 +
15366 +#define vx_dentry_avail(n) \
15367 +       vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
15368 +
15369 +
15370 +/* socket limits */
15371 +
15372 +#define vx_sock_inc(s) \
15373 +       vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
15374 +
15375 +#define vx_sock_dec(s) \
15376 +       vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
15377 +
15378 +#define vx_sock_avail(n) \
15379 +       vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
15380 +
15381 +
15382 +/* ipc resource limits */
15383 +
15384 +#define vx_ipcmsg_add(v, u, a) \
15385 +       vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
15386 +
15387 +#define vx_ipcmsg_sub(v, u, a) \
15388 +       vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
15389 +
15390 +#define vx_ipcmsg_avail(v, a) \
15391 +       vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
15392 +
15393 +
15394 +#define vx_ipcshm_add(v, k, a) \
15395 +       vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15396 +
15397 +#define vx_ipcshm_sub(v, k, a) \
15398 +       vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15399 +
15400 +#define vx_ipcshm_avail(v, a) \
15401 +       vx_cres_avail(v, a, VLIMIT_SHMEM)
15402 +
15403 +
15404 +#define vx_semary_inc(a) \
15405 +       vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
15406 +
15407 +#define vx_semary_dec(a) \
15408 +       vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
15409 +
15410 +
15411 +#define vx_nsems_add(a,n) \
15412 +       vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15413 +
15414 +#define vx_nsems_sub(a,n) \
15415 +       vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15416 +
15417 +
15418 +#else
15419 +#warning duplicate inclusion
15420 +#endif
15421 diff -NurpP --minimal linux-2.6.35/include/linux/vs_memory.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_memory.h
15422 --- linux-2.6.35/include/linux/vs_memory.h      1970-01-01 01:00:00.000000000 +0100
15423 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_memory.h        2010-08-02 17:05:06.000000000 +0200
15424 @@ -0,0 +1,58 @@
15425 +#ifndef _VS_MEMORY_H
15426 +#define _VS_MEMORY_H
15427 +
15428 +#include "vserver/limit.h"
15429 +#include "vserver/base.h"
15430 +#include "vserver/context.h"
15431 +#include "vserver/debug.h"
15432 +#include "vserver/context.h"
15433 +#include "vserver/limit_int.h"
15434 +
15435 +enum {
15436 +       VXPT_UNKNOWN = 0,
15437 +       VXPT_ANON,
15438 +       VXPT_NONE,
15439 +       VXPT_FILE,
15440 +       VXPT_SWAP,
15441 +       VXPT_WRITE
15442 +};
15443 +
15444 +#if 0
15445 +#define        vx_page_fault(mm, vma, type, ret)
15446 +#else
15447 +
15448 +static inline
15449 +void __vx_page_fault(struct mm_struct *mm,
15450 +       struct vm_area_struct *vma, int type, int ret)
15451 +{
15452 +       struct vx_info *vxi = mm->mm_vx_info;
15453 +       int what;
15454 +/*
15455 +       static char *page_type[6] =
15456 +               { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
15457 +       static char *page_what[4] =
15458 +               { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
15459 +*/
15460 +
15461 +       if (!vxi)
15462 +               return;
15463 +
15464 +       what = (ret & 0x3);
15465 +
15466 +/*     printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
15467 +               type, what, ret, page_type[type], page_what[what]);
15468 +*/
15469 +       if (ret & VM_FAULT_WRITE)
15470 +               what |= 0x4;
15471 +       atomic_inc(&vxi->cacct.page[type][what]);
15472 +}
15473 +
15474 +#define        vx_page_fault(mm, vma, type, ret)       __vx_page_fault(mm, vma, type, ret)
15475 +#endif
15476 +
15477 +
15478 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
15479 +
15480 +#else
15481 +#warning duplicate inclusion
15482 +#endif
15483 diff -NurpP --minimal linux-2.6.35/include/linux/vs_network.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_network.h
15484 --- linux-2.6.35/include/linux/vs_network.h     1970-01-01 01:00:00.000000000 +0100
15485 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_network.h       2010-08-02 17:05:06.000000000 +0200
15486 @@ -0,0 +1,169 @@
15487 +#ifndef _NX_VS_NETWORK_H
15488 +#define _NX_VS_NETWORK_H
15489 +
15490 +#include "vserver/context.h"
15491 +#include "vserver/network.h"
15492 +#include "vserver/base.h"
15493 +#include "vserver/check.h"
15494 +#include "vserver/debug.h"
15495 +
15496 +#include <linux/sched.h>
15497 +
15498 +
15499 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
15500 +
15501 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
15502 +       const char *_file, int _line)
15503 +{
15504 +       if (!nxi)
15505 +               return NULL;
15506 +
15507 +       vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
15508 +               nxi, nxi ? nxi->nx_id : 0,
15509 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15510 +               _file, _line);
15511 +
15512 +       atomic_inc(&nxi->nx_usecnt);
15513 +       return nxi;
15514 +}
15515 +
15516 +
15517 +extern void free_nx_info(struct nx_info *);
15518 +
15519 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
15520 +
15521 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
15522 +{
15523 +       if (!nxi)
15524 +               return;
15525 +
15526 +       vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
15527 +               nxi, nxi ? nxi->nx_id : 0,
15528 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15529 +               _file, _line);
15530 +
15531 +       if (atomic_dec_and_test(&nxi->nx_usecnt))
15532 +               free_nx_info(nxi);
15533 +}
15534 +
15535 +
15536 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
15537 +
15538 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15539 +               const char *_file, int _line)
15540 +{
15541 +       if (nxi) {
15542 +               vxlprintk(VXD_CBIT(nid, 3),
15543 +                       "init_nx_info(%p[#%d.%d])",
15544 +                       nxi, nxi ? nxi->nx_id : 0,
15545 +                       nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15546 +                       _file, _line);
15547 +
15548 +               atomic_inc(&nxi->nx_usecnt);
15549 +       }
15550 +       *nxp = nxi;
15551 +}
15552 +
15553 +
15554 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
15555 +
15556 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15557 +       const char *_file, int _line)
15558 +{
15559 +       struct nx_info *nxo;
15560 +
15561 +       if (!nxi)
15562 +               return;
15563 +
15564 +       vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
15565 +               nxi, nxi ? nxi->nx_id : 0,
15566 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15567 +               _file, _line);
15568 +
15569 +       atomic_inc(&nxi->nx_usecnt);
15570 +       nxo = xchg(nxp, nxi);
15571 +       BUG_ON(nxo);
15572 +}
15573 +
15574 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
15575 +
15576 +static inline void __clr_nx_info(struct nx_info **nxp,
15577 +       const char *_file, int _line)
15578 +{
15579 +       struct nx_info *nxo;
15580 +
15581 +       nxo = xchg(nxp, NULL);
15582 +       if (!nxo)
15583 +               return;
15584 +
15585 +       vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
15586 +               nxo, nxo ? nxo->nx_id : 0,
15587 +               nxo ? atomic_read(&nxo->nx_usecnt) : 0,
15588 +               _file, _line);
15589 +
15590 +       if (atomic_dec_and_test(&nxo->nx_usecnt))
15591 +               free_nx_info(nxo);
15592 +}
15593 +
15594 +
15595 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
15596 +
15597 +static inline void __claim_nx_info(struct nx_info *nxi,
15598 +       struct task_struct *task, const char *_file, int _line)
15599 +{
15600 +       vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
15601 +               nxi, nxi ? nxi->nx_id : 0,
15602 +               nxi?atomic_read(&nxi->nx_usecnt):0,
15603 +               nxi?atomic_read(&nxi->nx_tasks):0,
15604 +               task, _file, _line);
15605 +
15606 +       atomic_inc(&nxi->nx_tasks);
15607 +}
15608 +
15609 +
15610 +extern void unhash_nx_info(struct nx_info *);
15611 +
15612 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
15613 +
15614 +static inline void __release_nx_info(struct nx_info *nxi,
15615 +       struct task_struct *task, const char *_file, int _line)
15616 +{
15617 +       vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
15618 +               nxi, nxi ? nxi->nx_id : 0,
15619 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15620 +               nxi ? atomic_read(&nxi->nx_tasks) : 0,
15621 +               task, _file, _line);
15622 +
15623 +       might_sleep();
15624 +
15625 +       if (atomic_dec_and_test(&nxi->nx_tasks))
15626 +               unhash_nx_info(nxi);
15627 +}
15628 +
15629 +
15630 +#define task_get_nx_info(i)    __task_get_nx_info(i, __FILE__, __LINE__)
15631 +
15632 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
15633 +       const char *_file, int _line)
15634 +{
15635 +       struct nx_info *nxi;
15636 +
15637 +       task_lock(p);
15638 +       vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
15639 +               p, _file, _line);
15640 +       nxi = __get_nx_info(p->nx_info, _file, _line);
15641 +       task_unlock(p);
15642 +       return nxi;
15643 +}
15644 +
15645 +
15646 +static inline void exit_nx_info(struct task_struct *p)
15647 +{
15648 +       if (p->nx_info)
15649 +               release_nx_info(p->nx_info, p);
15650 +}
15651 +
15652 +
15653 +#else
15654 +#warning duplicate inclusion
15655 +#endif
15656 diff -NurpP --minimal linux-2.6.35/include/linux/vs_pid.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_pid.h
15657 --- linux-2.6.35/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
15658 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_pid.h   2010-08-02 17:05:06.000000000 +0200
15659 @@ -0,0 +1,95 @@
15660 +#ifndef _VS_PID_H
15661 +#define _VS_PID_H
15662 +
15663 +#include "vserver/base.h"
15664 +#include "vserver/check.h"
15665 +#include "vserver/context.h"
15666 +#include "vserver/debug.h"
15667 +#include "vserver/pid.h"
15668 +#include <linux/pid_namespace.h>
15669 +
15670 +
15671 +#define VXF_FAKE_INIT  (VXF_INFO_INIT | VXF_STATE_INIT)
15672 +
15673 +static inline
15674 +int vx_proc_task_visible(struct task_struct *task)
15675 +{
15676 +       if ((task->pid == 1) &&
15677 +               !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
15678 +               /* show a blend through init */
15679 +               goto visible;
15680 +       if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
15681 +               goto visible;
15682 +       return 0;
15683 +visible:
15684 +       return 1;
15685 +}
15686 +
15687 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
15688 +
15689 +#if 0
15690 +
15691 +static inline
15692 +struct task_struct *vx_find_proc_task_by_pid(int pid)
15693 +{
15694 +       struct task_struct *task = find_task_by_real_pid(pid);
15695 +
15696 +       if (task && !vx_proc_task_visible(task)) {
15697 +               vxdprintk(VXD_CBIT(misc, 6),
15698 +                       "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
15699 +                       task, task->xid, task->pid,
15700 +                       current, current->xid, current->pid);
15701 +               task = NULL;
15702 +       }
15703 +       return task;
15704 +}
15705 +
15706 +#endif
15707 +
15708 +static inline
15709 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
15710 +{
15711 +       struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
15712 +
15713 +       if (task && !vx_proc_task_visible(task)) {
15714 +               vxdprintk(VXD_CBIT(misc, 6),
15715 +                       "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
15716 +                       task, task->xid, task->pid,
15717 +                       current, current->xid, current->pid);
15718 +               put_task_struct(task);
15719 +               task = NULL;
15720 +       }
15721 +       return task;
15722 +}
15723 +
15724 +#if 0
15725 +
15726 +static inline
15727 +struct task_struct *vx_child_reaper(struct task_struct *p)
15728 +{
15729 +       struct vx_info *vxi = p->vx_info;
15730 +       struct task_struct *reaper = child_reaper(p);
15731 +
15732 +       if (!vxi)
15733 +               goto out;
15734 +
15735 +       BUG_ON(!p->vx_info->vx_reaper);
15736 +
15737 +       /* child reaper for the guest reaper */
15738 +       if (vxi->vx_reaper == p)
15739 +               goto out;
15740 +
15741 +       reaper = vxi->vx_reaper;
15742 +out:
15743 +       vxdprintk(VXD_CBIT(xid, 7),
15744 +               "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
15745 +               p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
15746 +       return reaper;
15747 +}
15748 +
15749 +#endif
15750 +
15751 +
15752 +#else
15753 +#warning duplicate inclusion
15754 +#endif
15755 diff -NurpP --minimal linux-2.6.35/include/linux/vs_sched.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_sched.h
15756 --- linux-2.6.35/include/linux/vs_sched.h       1970-01-01 01:00:00.000000000 +0100
15757 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_sched.h 2010-08-02 17:05:06.000000000 +0200
15758 @@ -0,0 +1,110 @@
15759 +#ifndef _VS_SCHED_H
15760 +#define _VS_SCHED_H
15761 +
15762 +#include "vserver/base.h"
15763 +#include "vserver/context.h"
15764 +#include "vserver/sched.h"
15765 +
15766 +
15767 +#define VAVAVOOM_RATIO          50
15768 +
15769 +#define MAX_PRIO_BIAS           20
15770 +#define MIN_PRIO_BIAS          -20
15771 +
15772 +
15773 +#ifdef CONFIG_VSERVER_HARDCPU
15774 +
15775 +/*
15776 + * effective_prio - return the priority that is based on the static
15777 + * priority but is modified by bonuses/penalties.
15778 + *
15779 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
15780 + * into a -4 ... 0 ... +4 bonus/penalty range.
15781 + *
15782 + * Additionally, we scale another amount based on the number of
15783 + * CPU tokens currently held by the context, if the process is
15784 + * part of a context (and the appropriate SCHED flag is set).
15785 + * This ranges from -5 ... 0 ... +15, quadratically.
15786 + *
15787 + * So, the total bonus is -9 .. 0 .. +19
15788 + * We use ~50% of the full 0...39 priority range so that:
15789 + *
15790 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
15791 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
15792 + *    unless that context is far exceeding its CPU allocation.
15793 + *
15794 + * Both properties are important to certain workloads.
15795 + */
15796 +static inline
15797 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
15798 +{
15799 +       int vavavoom, max;
15800 +
15801 +       /* lots of tokens = lots of vavavoom
15802 +        *      no tokens = no vavavoom      */
15803 +       if ((vavavoom = sched_pc->tokens) >= 0) {
15804 +               max = sched_pc->tokens_max;
15805 +               vavavoom = max - vavavoom;
15806 +               max = max * max;
15807 +               vavavoom = max_prio * VAVAVOOM_RATIO / 100
15808 +                       * (vavavoom*vavavoom - (max >> 2)) / max;
15809 +               return vavavoom;
15810 +       }
15811 +       return 0;
15812 +}
15813 +
15814 +
15815 +static inline
15816 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
15817 +{
15818 +       struct vx_info *vxi = p->vx_info;
15819 +       struct _vx_sched_pc *sched_pc;
15820 +
15821 +       if (!vxi)
15822 +               return prio;
15823 +
15824 +       sched_pc = &vx_cpu(vxi, sched_pc);
15825 +       if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
15826 +               int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
15827 +
15828 +               sched_pc->vavavoom = vavavoom;
15829 +               prio += vavavoom;
15830 +       }
15831 +       prio += sched_pc->prio_bias;
15832 +       return prio;
15833 +}
15834 +
15835 +#else /* !CONFIG_VSERVER_HARDCPU */
15836 +
15837 +static inline
15838 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
15839 +{
15840 +       struct vx_info *vxi = p->vx_info;
15841 +
15842 +       if (vxi)
15843 +               prio += vx_cpu(vxi, sched_pc).prio_bias;
15844 +       return prio;
15845 +}
15846 +
15847 +#endif /* CONFIG_VSERVER_HARDCPU */
15848 +
15849 +
15850 +static inline void vx_account_user(struct vx_info *vxi,
15851 +       cputime_t cputime, int nice)
15852 +{
15853 +       if (!vxi)
15854 +               return;
15855 +       vx_cpu(vxi, sched_pc).user_ticks += cputime;
15856 +}
15857 +
15858 +static inline void vx_account_system(struct vx_info *vxi,
15859 +       cputime_t cputime, int idle)
15860 +{
15861 +       if (!vxi)
15862 +               return;
15863 +       vx_cpu(vxi, sched_pc).sys_ticks += cputime;
15864 +}
15865 +
15866 +#else
15867 +#warning duplicate inclusion
15868 +#endif
15869 diff -NurpP --minimal linux-2.6.35/include/linux/vs_socket.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_socket.h
15870 --- linux-2.6.35/include/linux/vs_socket.h      1970-01-01 01:00:00.000000000 +0100
15871 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_socket.h        2010-08-02 17:05:06.000000000 +0200
15872 @@ -0,0 +1,67 @@
15873 +#ifndef _VS_SOCKET_H
15874 +#define _VS_SOCKET_H
15875 +
15876 +#include "vserver/debug.h"
15877 +#include "vserver/base.h"
15878 +#include "vserver/cacct.h"
15879 +#include "vserver/context.h"
15880 +#include "vserver/tag.h"
15881 +
15882 +
15883 +/* socket accounting */
15884 +
15885 +#include <linux/socket.h>
15886 +
15887 +static inline int vx_sock_type(int family)
15888 +{
15889 +       switch (family) {
15890 +       case PF_UNSPEC:
15891 +               return VXA_SOCK_UNSPEC;
15892 +       case PF_UNIX:
15893 +               return VXA_SOCK_UNIX;
15894 +       case PF_INET:
15895 +               return VXA_SOCK_INET;
15896 +       case PF_INET6:
15897 +               return VXA_SOCK_INET6;
15898 +       case PF_PACKET:
15899 +               return VXA_SOCK_PACKET;
15900 +       default:
15901 +               return VXA_SOCK_OTHER;
15902 +       }
15903 +}
15904 +
15905 +#define vx_acc_sock(v, f, p, s) \
15906 +       __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
15907 +
15908 +static inline void __vx_acc_sock(struct vx_info *vxi,
15909 +       int family, int pos, int size, char *file, int line)
15910 +{
15911 +       if (vxi) {
15912 +               int type = vx_sock_type(family);
15913 +
15914 +               atomic_long_inc(&vxi->cacct.sock[type][pos].count);
15915 +               atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
15916 +       }
15917 +}
15918 +
15919 +#define vx_sock_recv(sk, s) \
15920 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
15921 +#define vx_sock_send(sk, s) \
15922 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
15923 +#define vx_sock_fail(sk, s) \
15924 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
15925 +
15926 +
15927 +#define sock_vx_init(s) do {           \
15928 +       (s)->sk_xid = 0;                \
15929 +       (s)->sk_vx_info = NULL;         \
15930 +       } while (0)
15931 +
15932 +#define sock_nx_init(s) do {           \
15933 +       (s)->sk_nid = 0;                \
15934 +       (s)->sk_nx_info = NULL;         \
15935 +       } while (0)
15936 +
15937 +#else
15938 +#warning duplicate inclusion
15939 +#endif
15940 diff -NurpP --minimal linux-2.6.35/include/linux/vs_tag.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_tag.h
15941 --- linux-2.6.35/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
15942 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_tag.h   2010-08-02 17:05:06.000000000 +0200
15943 @@ -0,0 +1,47 @@
15944 +#ifndef _VS_TAG_H
15945 +#define _VS_TAG_H
15946 +
15947 +#include <linux/vserver/tag.h>
15948 +
15949 +/* check conditions */
15950 +
15951 +#define DX_ADMIN       0x0001
15952 +#define DX_WATCH       0x0002
15953 +#define DX_HOSTID      0x0008
15954 +
15955 +#define DX_IDENT       0x0010
15956 +
15957 +#define DX_ARG_MASK    0x0010
15958 +
15959 +
15960 +#define dx_task_tag(t) ((t)->tag)
15961 +
15962 +#define dx_current_tag() dx_task_tag(current)
15963 +
15964 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
15965 +
15966 +#define dx_weak_check(c, m)    ((m) ? dx_check(c, m) : 1)
15967 +
15968 +
15969 +/*
15970 + * check current context for ADMIN/WATCH and
15971 + * optionally against supplied argument
15972 + */
15973 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
15974 +{
15975 +       if (mode & DX_ARG_MASK) {
15976 +               if ((mode & DX_IDENT) && (id == cid))
15977 +                       return 1;
15978 +       }
15979 +       return (((mode & DX_ADMIN) && (cid == 0)) ||
15980 +               ((mode & DX_WATCH) && (cid == 1)) ||
15981 +               ((mode & DX_HOSTID) && (id == 0)));
15982 +}
15983 +
15984 +struct inode;
15985 +int dx_permission(const struct inode *inode, int mask);
15986 +
15987 +
15988 +#else
15989 +#warning duplicate inclusion
15990 +#endif
15991 diff -NurpP --minimal linux-2.6.35/include/linux/vs_time.h linux-2.6.35-vs2.3.0.36.31/include/linux/vs_time.h
15992 --- linux-2.6.35/include/linux/vs_time.h        1970-01-01 01:00:00.000000000 +0100
15993 +++ linux-2.6.35-vs2.3.0.36.31/include/linux/vs_time.h  2010-08-02 17:05:06.000000000 +0200
15994 @@ -0,0 +1,19 @@
15995 +#ifndef _VS_TIME_H
15996 +#define _VS_TIME_H
15997 +
15998 +
15999 +/* time faking stuff */
16000 +
16001 +#ifdef CONFIG_VSERVER_VTIME
16002 +
16003 +extern void vx_gettimeofday(struct timeval *tv);
16004 +extern int vx_settimeofday(struct timespec *ts);
16005 +
16006 +#else
16007 +#define        vx_gettimeofday(t)      do_gettimeofday(t)
16008 +#define        vx_settimeofday(t)      do_settimeofday(t)
16009 +#endif
16010 +
16011 +#else
16012 +#warning duplicate inclusion
16013 +#endif
16014 diff -NurpP --minimal linux-2.6.35/include/net/addrconf.h linux-2.6.35-vs2.3.0.36.31/include/net/addrconf.h
16015 --- linux-2.6.35/include/net/addrconf.h 2010-07-07 18:31:56.000000000 +0200
16016 +++ linux-2.6.35-vs2.3.0.36.31/include/net/addrconf.h   2010-08-02 17:05:06.000000000 +0200
16017 @@ -84,7 +84,8 @@ extern int                    ipv6_dev_get_saddr(struct n
16018                                                struct net_device *dev,
16019                                                const struct in6_addr *daddr,
16020                                                unsigned int srcprefs,
16021 -                                              struct in6_addr *saddr);
16022 +                                              struct in6_addr *saddr,
16023 +                                              struct nx_info *nxi);
16024  extern int                     ipv6_get_lladdr(struct net_device *dev,
16025                                                 struct in6_addr *addr,
16026                                                 unsigned char banned_flags);
16027 diff -NurpP --minimal linux-2.6.35/include/net/af_unix.h linux-2.6.35-vs2.3.0.36.31/include/net/af_unix.h
16028 --- linux-2.6.35/include/net/af_unix.h  2010-08-02 16:52:56.000000000 +0200
16029 +++ linux-2.6.35-vs2.3.0.36.31/include/net/af_unix.h    2010-08-02 17:05:06.000000000 +0200
16030 @@ -4,6 +4,7 @@
16031  #include <linux/socket.h>
16032  #include <linux/un.h>
16033  #include <linux/mutex.h>
16034 +#include <linux/vs_base.h>
16035  #include <net/sock.h>
16036  
16037  extern void unix_inflight(struct file *fp);
16038 diff -NurpP --minimal linux-2.6.35/include/net/inet_timewait_sock.h linux-2.6.35-vs2.3.0.36.31/include/net/inet_timewait_sock.h
16039 --- linux-2.6.35/include/net/inet_timewait_sock.h       2010-08-02 16:52:56.000000000 +0200
16040 +++ linux-2.6.35-vs2.3.0.36.31/include/net/inet_timewait_sock.h 2010-08-02 17:05:06.000000000 +0200
16041 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
16042  #define tw_hash                        __tw_common.skc_hash
16043  #define tw_prot                        __tw_common.skc_prot
16044  #define tw_net                 __tw_common.skc_net
16045 +#define tw_xid                 __tw_common.skc_xid
16046 +#define tw_vx_info             __tw_common.skc_vx_info
16047 +#define tw_nid                 __tw_common.skc_nid
16048 +#define tw_nx_info             __tw_common.skc_nx_info
16049         int                     tw_timeout;
16050         volatile unsigned char  tw_substate;
16051         /* 3 bits hole, try to pack */
16052 diff -NurpP --minimal linux-2.6.35/include/net/route.h linux-2.6.35-vs2.3.0.36.31/include/net/route.h
16053 --- linux-2.6.35/include/net/route.h    2010-08-02 16:52:57.000000000 +0200
16054 +++ linux-2.6.35-vs2.3.0.36.31/include/net/route.h      2010-08-02 17:05:06.000000000 +0200
16055 @@ -147,6 +147,9 @@ static inline void ip_rt_put(struct rtab
16056                 dst_release(&rt->u.dst);
16057  }
16058  
16059 +#include <linux/vs_base.h>
16060 +#include <linux/vs_inet.h>
16061 +
16062  #define IPTOS_RT_MASK  (IPTOS_TOS_MASK & ~3)
16063  
16064  extern const __u8 ip_tos2prio[16];
16065 @@ -156,6 +159,9 @@ static inline char rt_tos2priority(u8 to
16066         return ip_tos2prio[IPTOS_TOS(tos)>>1];
16067  }
16068  
16069 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
16070 +       struct rtable **, struct flowi *);
16071 +
16072  static inline int ip_route_connect(struct rtable **rp, __be32 dst,
16073                                    __be32 src, u32 tos, int oif, u8 protocol,
16074                                    __be16 sport, __be16 dport, struct sock *sk,
16075 @@ -173,11 +179,24 @@ static inline int ip_route_connect(struc
16076  
16077         int err;
16078         struct net *net = sock_net(sk);
16079 +       struct nx_info *nx_info = current_nx_info();
16080  
16081         if (inet_sk(sk)->transparent)
16082                 fl.flags |= FLOWI_FLAG_ANYSRC;
16083  
16084 -       if (!dst || !src) {
16085 +       if (sk)
16086 +               nx_info = sk->sk_nx_info;
16087 +
16088 +       vxdprintk(VXD_CBIT(net, 4),
16089 +               "ip_route_connect(%p) %p,%p;%lx",
16090 +               sk, nx_info, sk->sk_socket,
16091 +               (sk->sk_socket?sk->sk_socket->flags:0));
16092 +
16093 +       err = ip_v4_find_src(net, nx_info, rp, &fl);
16094 +       if (err)
16095 +               return err;
16096 +
16097 +       if (!fl.fl4_dst || !fl.fl4_src) {
16098                 err = __ip_route_output_key(net, rp, &fl);
16099                 if (err)
16100                         return err;
16101 diff -NurpP --minimal linux-2.6.35/include/net/sock.h linux-2.6.35-vs2.3.0.36.31/include/net/sock.h
16102 --- linux-2.6.35/include/net/sock.h     2010-08-02 16:52:57.000000000 +0200
16103 +++ linux-2.6.35-vs2.3.0.36.31/include/net/sock.h       2010-08-02 17:05:06.000000000 +0200
16104 @@ -150,6 +150,10 @@ struct sock_common {
16105  #ifdef CONFIG_NET_NS
16106         struct net              *skc_net;
16107  #endif
16108 +       xid_t                   skc_xid;
16109 +       struct vx_info          *skc_vx_info;
16110 +       nid_t                   skc_nid;
16111 +       struct nx_info          *skc_nx_info;
16112  };
16113  
16114  /**
16115 @@ -239,6 +243,10 @@ struct sock {
16116  #define sk_bind_node           __sk_common.skc_bind_node
16117  #define sk_prot                        __sk_common.skc_prot
16118  #define sk_net                 __sk_common.skc_net
16119 +#define sk_xid                 __sk_common.skc_xid
16120 +#define sk_vx_info             __sk_common.skc_vx_info
16121 +#define sk_nid                 __sk_common.skc_nid
16122 +#define sk_nx_info             __sk_common.skc_nx_info
16123         kmemcheck_bitfield_begin(flags);
16124         unsigned int            sk_shutdown  : 2,
16125                                 sk_no_check  : 2,
16126 diff -NurpP --minimal linux-2.6.35/init/Kconfig linux-2.6.35-vs2.3.0.36.31/init/Kconfig
16127 --- linux-2.6.35/init/Kconfig   2010-08-02 16:52:57.000000000 +0200
16128 +++ linux-2.6.35-vs2.3.0.36.31/init/Kconfig     2010-08-02 17:05:06.000000000 +0200
16129 @@ -472,6 +472,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
16130  menuconfig CGROUPS
16131         boolean "Control Group support"
16132         depends on EVENTFD
16133 +       default y
16134         help
16135           This option adds support for grouping sets of processes together, for
16136           use with process control subsystems such as Cpusets, CFS, memory
16137 @@ -499,6 +500,7 @@ config CGROUP_DEBUG
16138  config CGROUP_NS
16139         bool "Namespace cgroup subsystem"
16140         depends on CGROUPS
16141 +       default n
16142         help
16143           Provides a simple namespace cgroup subsystem to
16144           provide hierarchical naming of sets of namespaces,
16145 diff -NurpP --minimal linux-2.6.35/init/main.c linux-2.6.35-vs2.3.0.36.31/init/main.c
16146 --- linux-2.6.35/init/main.c    2010-08-02 16:52:57.000000000 +0200
16147 +++ linux-2.6.35-vs2.3.0.36.31/init/main.c      2010-08-02 17:05:06.000000000 +0200
16148 @@ -71,6 +71,7 @@
16149  #include <linux/shmem_fs.h>
16150  #include <linux/slab.h>
16151  #include <trace/boot.h>
16152 +#include <linux/vserver/percpu.h>
16153  
16154  #include <asm/io.h>
16155  #include <asm/bugs.h>
16156 diff -NurpP --minimal linux-2.6.35/ipc/mqueue.c linux-2.6.35-vs2.3.0.36.31/ipc/mqueue.c
16157 --- linux-2.6.35/ipc/mqueue.c   2010-08-02 16:52:57.000000000 +0200
16158 +++ linux-2.6.35-vs2.3.0.36.31/ipc/mqueue.c     2010-08-02 17:05:06.000000000 +0200
16159 @@ -33,6 +33,8 @@
16160  #include <linux/pid.h>
16161  #include <linux/ipc_namespace.h>
16162  #include <linux/slab.h>
16163 +#include <linux/vs_context.h>
16164 +#include <linux/vs_limit.h>
16165  
16166  #include <net/sock.h>
16167  #include "util.h"
16168 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
16169         struct sigevent notify;
16170         struct pid* notify_owner;
16171         struct user_struct *user;       /* user who created, for accounting */
16172 +       struct vx_info *vxi;
16173         struct sock *notify_sock;
16174         struct sk_buff *notify_cookie;
16175  
16176 @@ -125,6 +128,7 @@ static struct inode *mqueue_get_inode(st
16177                 if (S_ISREG(mode)) {
16178                         struct mqueue_inode_info *info;
16179                         struct task_struct *p = current;
16180 +                       struct vx_info *vxi = p->vx_info;
16181                         unsigned long mq_bytes, mq_msg_tblsz;
16182  
16183                         inode->i_fop = &mqueue_file_operations;
16184 @@ -138,6 +142,7 @@ static struct inode *mqueue_get_inode(st
16185                         info->notify_owner = NULL;
16186                         info->qsize = 0;
16187                         info->user = NULL;      /* set when all is ok */
16188 +                       info->vxi = NULL;
16189                         memset(&info->attr, 0, sizeof(info->attr));
16190                         info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
16191                         info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
16192 @@ -156,16 +161,19 @@ static struct inode *mqueue_get_inode(st
16193                         spin_lock(&mq_lock);
16194                         if (u->mq_bytes + mq_bytes < u->mq_bytes ||
16195                             u->mq_bytes + mq_bytes >
16196 -                           task_rlimit(p, RLIMIT_MSGQUEUE)) {
16197 +                           task_rlimit(p, RLIMIT_MSGQUEUE) ||
16198 +                           !vx_ipcmsg_avail(vxi, mq_bytes)) {
16199                                 spin_unlock(&mq_lock);
16200                                 /* mqueue_delete_inode() releases info->messages */
16201                                 goto out_inode;
16202                         }
16203                         u->mq_bytes += mq_bytes;
16204 +                       vx_ipcmsg_add(vxi, u, mq_bytes);
16205                         spin_unlock(&mq_lock);
16206  
16207                         /* all is ok */
16208                         info->user = get_uid(u);
16209 +                       info->vxi = get_vx_info(vxi);
16210                 } else if (S_ISDIR(mode)) {
16211                         inc_nlink(inode);
16212                         /* Some things misbehave if size == 0 on a directory */
16213 @@ -268,8 +276,11 @@ static void mqueue_delete_inode(struct i
16214             + info->attr.mq_msgsize);
16215         user = info->user;
16216         if (user) {
16217 +               struct vx_info *vxi = info->vxi;
16218 +
16219                 spin_lock(&mq_lock);
16220                 user->mq_bytes -= mq_bytes;
16221 +               vx_ipcmsg_sub(vxi, user, mq_bytes);
16222                 /*
16223                  * get_ns_from_inode() ensures that the
16224                  * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
16225 @@ -279,6 +290,7 @@ static void mqueue_delete_inode(struct i
16226                 if (ipc_ns)
16227                         ipc_ns->mq_queues_count--;
16228                 spin_unlock(&mq_lock);
16229 +               put_vx_info(vxi);
16230                 free_uid(user);
16231         }
16232         if (ipc_ns)
16233 diff -NurpP --minimal linux-2.6.35/ipc/msg.c linux-2.6.35-vs2.3.0.36.31/ipc/msg.c
16234 --- linux-2.6.35/ipc/msg.c      2010-08-02 16:52:57.000000000 +0200
16235 +++ linux-2.6.35-vs2.3.0.36.31/ipc/msg.c        2010-08-02 17:05:06.000000000 +0200
16236 @@ -37,6 +37,7 @@
16237  #include <linux/rwsem.h>
16238  #include <linux/nsproxy.h>
16239  #include <linux/ipc_namespace.h>
16240 +#include <linux/vs_base.h>
16241  
16242  #include <asm/current.h>
16243  #include <asm/uaccess.h>
16244 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
16245  
16246         msq->q_perm.mode = msgflg & S_IRWXUGO;
16247         msq->q_perm.key = key;
16248 +       msq->q_perm.xid = vx_current_xid();
16249  
16250         msq->q_perm.security = NULL;
16251         retval = security_msg_queue_alloc(msq);
16252 diff -NurpP --minimal linux-2.6.35/ipc/namespace.c linux-2.6.35-vs2.3.0.36.31/ipc/namespace.c
16253 --- linux-2.6.35/ipc/namespace.c        2009-09-10 15:26:27.000000000 +0200
16254 +++ linux-2.6.35-vs2.3.0.36.31/ipc/namespace.c  2010-08-02 17:05:06.000000000 +0200
16255 @@ -11,6 +11,8 @@
16256  #include <linux/slab.h>
16257  #include <linux/fs.h>
16258  #include <linux/mount.h>
16259 +#include <linux/vs_base.h>
16260 +#include <linux/vserver/global.h>
16261  
16262  #include "util.h"
16263  
16264 diff -NurpP --minimal linux-2.6.35/ipc/sem.c linux-2.6.35-vs2.3.0.36.31/ipc/sem.c
16265 --- linux-2.6.35/ipc/sem.c      2010-08-02 16:52:57.000000000 +0200
16266 +++ linux-2.6.35-vs2.3.0.36.31/ipc/sem.c        2010-08-02 17:05:06.000000000 +0200
16267 @@ -86,6 +86,8 @@
16268  #include <linux/rwsem.h>
16269  #include <linux/nsproxy.h>
16270  #include <linux/ipc_namespace.h>
16271 +#include <linux/vs_base.h>
16272 +#include <linux/vs_limit.h>
16273  
16274  #include <asm/uaccess.h>
16275  #include "util.h"
16276 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
16277  
16278         sma->sem_perm.mode = (semflg & S_IRWXUGO);
16279         sma->sem_perm.key = key;
16280 +       sma->sem_perm.xid = vx_current_xid();
16281  
16282         sma->sem_perm.security = NULL;
16283         retval = security_sem_alloc(sma);
16284 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
16285                 return id;
16286         }
16287         ns->used_sems += nsems;
16288 +       /* FIXME: obsoleted? */
16289 +       vx_semary_inc(sma);
16290 +       vx_nsems_add(sma, nsems);
16291  
16292         sma->sem_base = (struct sem *) &sma[1];
16293  
16294 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
16295  
16296         wake_up_sem_queue_do(&tasks);
16297         ns->used_sems -= sma->sem_nsems;
16298 +       /* FIXME: obsoleted? */
16299 +       vx_nsems_sub(sma, sma->sem_nsems);
16300 +       vx_semary_dec(sma);
16301         security_sem_free(sma);
16302         ipc_rcu_putref(sma);
16303  }
16304 diff -NurpP --minimal linux-2.6.35/ipc/shm.c linux-2.6.35-vs2.3.0.36.31/ipc/shm.c
16305 --- linux-2.6.35/ipc/shm.c      2010-08-02 16:52:57.000000000 +0200
16306 +++ linux-2.6.35-vs2.3.0.36.31/ipc/shm.c        2010-08-02 17:05:06.000000000 +0200
16307 @@ -39,6 +39,8 @@
16308  #include <linux/nsproxy.h>
16309  #include <linux/mount.h>
16310  #include <linux/ipc_namespace.h>
16311 +#include <linux/vs_context.h>
16312 +#include <linux/vs_limit.h>
16313  
16314  #include <asm/uaccess.h>
16315  
16316 @@ -169,7 +171,12 @@ static void shm_open(struct vm_area_stru
16317   */
16318  static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
16319  {
16320 -       ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16321 +       struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
16322 +       int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16323 +
16324 +       vx_ipcshm_sub(vxi, shp, numpages);
16325 +       ns->shm_tot -= numpages;
16326 +
16327         shm_rmid(ns, shp);
16328         shm_unlock(shp);
16329         if (!is_file_hugepages(shp->shm_file))
16330 @@ -179,6 +186,7 @@ static void shm_destroy(struct ipc_names
16331                                                 shp->mlock_user);
16332         fput (shp->shm_file);
16333         security_shm_free(shp);
16334 +       put_vx_info(vxi);
16335         ipc_rcu_putref(shp);
16336  }
16337  
16338 @@ -349,11 +357,15 @@ static int newseg(struct ipc_namespace *
16339         if (ns->shm_tot + numpages > ns->shm_ctlall)
16340                 return -ENOSPC;
16341  
16342 +       if (!vx_ipcshm_avail(current_vx_info(), numpages))
16343 +               return -ENOSPC;
16344 +
16345         shp = ipc_rcu_alloc(sizeof(*shp));
16346         if (!shp)
16347                 return -ENOMEM;
16348  
16349         shp->shm_perm.key = key;
16350 +       shp->shm_perm.xid = vx_current_xid();
16351         shp->shm_perm.mode = (shmflg & S_IRWXUGO);
16352         shp->mlock_user = NULL;
16353  
16354 @@ -407,6 +419,7 @@ static int newseg(struct ipc_namespace *
16355         ns->shm_tot += numpages;
16356         error = shp->shm_perm.id;
16357         shm_unlock(shp);
16358 +       vx_ipcshm_add(current_vx_info(), key, numpages);
16359         return error;
16360  
16361  no_id:
16362 diff -NurpP --minimal linux-2.6.35/kernel/capability.c linux-2.6.35-vs2.3.0.36.31/kernel/capability.c
16363 --- linux-2.6.35/kernel/capability.c    2010-08-02 16:52:57.000000000 +0200
16364 +++ linux-2.6.35-vs2.3.0.36.31/kernel/capability.c      2010-08-02 17:05:06.000000000 +0200
16365 @@ -14,6 +14,7 @@
16366  #include <linux/security.h>
16367  #include <linux/syscalls.h>
16368  #include <linux/pid_namespace.h>
16369 +#include <linux/vs_context.h>
16370  #include <asm/uaccess.h>
16371  
16372  /*
16373 @@ -119,6 +120,7 @@ static int cap_validate_magic(cap_user_h
16374         return 0;
16375  }
16376  
16377 +
16378  /*
16379   * The only thing that can change the capabilities of the current
16380   * process is the current process. As such, we can't be in this code
16381 @@ -289,6 +291,8 @@ error:
16382         return ret;
16383  }
16384  
16385 +#include <linux/vserver/base.h>
16386 +
16387  /**
16388   * capable - Determine if the current task has a superior capability in effect
16389   * @cap: The capability to be tested for
16390 @@ -301,6 +305,9 @@ error:
16391   */
16392  int capable(int cap)
16393  {
16394 +       /* here for now so we don't require task locking */
16395 +       if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
16396 +               return 0;
16397         if (unlikely(!cap_valid(cap))) {
16398                 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
16399                 BUG();
16400 diff -NurpP --minimal linux-2.6.35/kernel/compat.c linux-2.6.35-vs2.3.0.36.31/kernel/compat.c
16401 --- linux-2.6.35/kernel/compat.c        2010-08-02 16:52:57.000000000 +0200
16402 +++ linux-2.6.35-vs2.3.0.36.31/kernel/compat.c  2010-08-02 17:05:06.000000000 +0200
16403 @@ -900,7 +900,7 @@ asmlinkage long compat_sys_time(compat_t
16404         compat_time_t i;
16405         struct timeval tv;
16406  
16407 -       do_gettimeofday(&tv);
16408 +       vx_gettimeofday(&tv);
16409         i = tv.tv_sec;
16410  
16411         if (tloc) {
16412 @@ -925,7 +925,7 @@ asmlinkage long compat_sys_stime(compat_
16413         if (err)
16414                 return err;
16415  
16416 -       do_settimeofday(&tv);
16417 +       vx_settimeofday(&tv);
16418         return 0;
16419  }
16420  
16421 diff -NurpP --minimal linux-2.6.35/kernel/exit.c linux-2.6.35-vs2.3.0.36.31/kernel/exit.c
16422 --- linux-2.6.35/kernel/exit.c  2010-08-02 16:52:57.000000000 +0200
16423 +++ linux-2.6.35-vs2.3.0.36.31/kernel/exit.c    2010-08-02 17:05:06.000000000 +0200
16424 @@ -48,6 +48,10 @@
16425  #include <linux/fs_struct.h>
16426  #include <linux/init_task.h>
16427  #include <linux/perf_event.h>
16428 +#include <linux/vs_limit.h>
16429 +#include <linux/vs_context.h>
16430 +#include <linux/vs_network.h>
16431 +#include <linux/vs_pid.h>
16432  #include <trace/events/sched.h>
16433  #include <linux/hw_breakpoint.h>
16434  
16435 @@ -487,9 +491,11 @@ static void close_files(struct files_str
16436                                         filp_close(file, files);
16437                                         cond_resched();
16438                                 }
16439 +                               vx_openfd_dec(i);
16440                         }
16441                         i++;
16442                         set >>= 1;
16443 +                       cond_resched();
16444                 }
16445         }
16446  }
16447 @@ -1020,11 +1026,16 @@ NORET_TYPE void do_exit(long code)
16448  
16449         validate_creds_for_do_exit(tsk);
16450  
16451 +       /* needs to stay after exit_notify() */
16452 +       exit_vx_info(tsk, code);
16453 +       exit_nx_info(tsk);
16454 +
16455         preempt_disable();
16456         exit_rcu();
16457         /* causes final put_task_struct in finish_task_switch(). */
16458         tsk->state = TASK_DEAD;
16459         schedule();
16460 +       printk("bad task: %p [%lx]\n", current, current->state);
16461         BUG();
16462         /* Avoid "noreturn function does return".  */
16463         for (;;)
16464 diff -NurpP --minimal linux-2.6.35/kernel/fork.c linux-2.6.35-vs2.3.0.36.31/kernel/fork.c
16465 --- linux-2.6.35/kernel/fork.c  2010-08-02 16:52:57.000000000 +0200
16466 +++ linux-2.6.35-vs2.3.0.36.31/kernel/fork.c    2010-08-02 17:05:06.000000000 +0200
16467 @@ -65,6 +65,10 @@
16468  #include <linux/perf_event.h>
16469  #include <linux/posix-timers.h>
16470  #include <linux/user-return-notifier.h>
16471 +#include <linux/vs_context.h>
16472 +#include <linux/vs_network.h>
16473 +#include <linux/vs_limit.h>
16474 +#include <linux/vs_memory.h>
16475  
16476  #include <asm/pgtable.h>
16477  #include <asm/pgalloc.h>
16478 @@ -160,6 +164,8 @@ void free_task(struct task_struct *tsk)
16479         account_kernel_stack(tsk->stack, -1);
16480         free_thread_info(tsk->stack);
16481         rt_mutex_debug_task_free(tsk);
16482 +       clr_vx_info(&tsk->vx_info);
16483 +       clr_nx_info(&tsk->nx_info);
16484         ftrace_graph_exit_task(tsk);
16485         free_task_struct(tsk);
16486  }
16487 @@ -489,6 +495,7 @@ static struct mm_struct * mm_init(struct
16488         if (likely(!mm_alloc_pgd(mm))) {
16489                 mm->def_flags = 0;
16490                 mmu_notifier_mm_init(mm);
16491 +               set_vx_info(&mm->mm_vx_info, p->vx_info);
16492                 return mm;
16493         }
16494  
16495 @@ -522,6 +529,7 @@ void __mmdrop(struct mm_struct *mm)
16496         mm_free_pgd(mm);
16497         destroy_context(mm);
16498         mmu_notifier_mm_destroy(mm);
16499 +       clr_vx_info(&mm->mm_vx_info);
16500         free_mm(mm);
16501  }
16502  EXPORT_SYMBOL_GPL(__mmdrop);
16503 @@ -657,6 +665,7 @@ struct mm_struct *dup_mm(struct task_str
16504                 goto fail_nomem;
16505  
16506         memcpy(mm, oldmm, sizeof(*mm));
16507 +       mm->mm_vx_info = NULL;
16508  
16509         /* Initializing for Swap token stuff */
16510         mm->token_priority = 0;
16511 @@ -695,6 +704,7 @@ fail_nocontext:
16512          * If init_new_context() failed, we cannot use mmput() to free the mm
16513          * because it calls destroy_context()
16514          */
16515 +       clr_vx_info(&mm->mm_vx_info);
16516         mm_free_pgd(mm);
16517         free_mm(mm);
16518         return NULL;
16519 @@ -969,6 +979,8 @@ static struct task_struct *copy_process(
16520         int retval;
16521         struct task_struct *p;
16522         int cgroup_callbacks_done = 0;
16523 +       struct vx_info *vxi;
16524 +       struct nx_info *nxi;
16525  
16526         if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
16527                 return ERR_PTR(-EINVAL);
16528 @@ -1015,7 +1027,12 @@ static struct task_struct *copy_process(
16529         DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
16530         DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
16531  #endif
16532 +       init_vx_info(&p->vx_info, current_vx_info());
16533 +       init_nx_info(&p->nx_info, current_nx_info());
16534 +
16535         retval = -EAGAIN;
16536 +       if (!vx_nproc_avail(1))
16537 +               goto bad_fork_free;
16538         if (atomic_read(&p->real_cred->user->processes) >=
16539                         task_rlimit(p, RLIMIT_NPROC)) {
16540                 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
16541 @@ -1280,6 +1297,18 @@ static struct task_struct *copy_process(
16542  
16543         total_forks++;
16544         spin_unlock(&current->sighand->siglock);
16545 +
16546 +       /* p is copy of current */
16547 +       vxi = p->vx_info;
16548 +       if (vxi) {
16549 +               claim_vx_info(vxi, p);
16550 +               atomic_inc(&vxi->cvirt.nr_threads);
16551 +               atomic_inc(&vxi->cvirt.total_forks);
16552 +               vx_nproc_inc(p);
16553 +       }
16554 +       nxi = p->nx_info;
16555 +       if (nxi)
16556 +               claim_nx_info(nxi, p);
16557         write_unlock_irq(&tasklist_lock);
16558         proc_fork_connector(p);
16559         cgroup_post_fork(p);
16560 diff -NurpP --minimal linux-2.6.35/kernel/kthread.c linux-2.6.35-vs2.3.0.36.31/kernel/kthread.c
16561 --- linux-2.6.35/kernel/kthread.c       2010-07-07 18:31:57.000000000 +0200
16562 +++ linux-2.6.35-vs2.3.0.36.31/kernel/kthread.c 2010-08-02 17:05:06.000000000 +0200
16563 @@ -14,6 +14,7 @@
16564  #include <linux/file.h>
16565  #include <linux/module.h>
16566  #include <linux/mutex.h>
16567 +#include <linux/vs_pid.h>
16568  #include <trace/events/sched.h>
16569  
16570  static DEFINE_SPINLOCK(kthread_create_lock);
16571 diff -NurpP --minimal linux-2.6.35/kernel/Makefile linux-2.6.35-vs2.3.0.36.31/kernel/Makefile
16572 --- linux-2.6.35/kernel/Makefile        2010-08-02 16:52:57.000000000 +0200
16573 +++ linux-2.6.35-vs2.3.0.36.31/kernel/Makefile  2010-08-02 17:05:06.000000000 +0200
16574 @@ -25,6 +25,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
16575  CFLAGS_REMOVE_perf_event.o = -pg
16576  endif
16577  
16578 +obj-y += vserver/
16579  obj-$(CONFIG_FREEZER) += freezer.o
16580  obj-$(CONFIG_PROFILING) += profile.o
16581  obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
16582 diff -NurpP --minimal linux-2.6.35/kernel/nsproxy.c linux-2.6.35-vs2.3.0.36.31/kernel/nsproxy.c
16583 --- linux-2.6.35/kernel/nsproxy.c       2010-07-07 18:31:57.000000000 +0200
16584 +++ linux-2.6.35-vs2.3.0.36.31/kernel/nsproxy.c 2010-08-02 17:05:06.000000000 +0200
16585 @@ -20,6 +20,8 @@
16586  #include <linux/mnt_namespace.h>
16587  #include <linux/utsname.h>
16588  #include <linux/pid_namespace.h>
16589 +#include <linux/vserver/global.h>
16590 +#include <linux/vserver/debug.h>
16591  #include <net/net_namespace.h>
16592  #include <linux/ipc_namespace.h>
16593  
16594 @@ -43,8 +45,11 @@ static inline struct nsproxy *create_nsp
16595         struct nsproxy *nsproxy;
16596  
16597         nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
16598 -       if (nsproxy)
16599 +       if (nsproxy) {
16600                 atomic_set(&nsproxy->count, 1);
16601 +               atomic_inc(&vs_global_nsproxy);
16602 +       }
16603 +       vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
16604         return nsproxy;
16605  }
16606  
16607 @@ -53,41 +58,52 @@ static inline struct nsproxy *create_nsp
16608   * Return the newly created nsproxy.  Do not attach this to the task,
16609   * leave it to the caller to do proper locking and attach it to task.
16610   */
16611 -static struct nsproxy *create_new_namespaces(unsigned long flags,
16612 -                       struct task_struct *tsk, struct fs_struct *new_fs)
16613 +static struct nsproxy *unshare_namespaces(unsigned long flags,
16614 +                       struct nsproxy *orig, struct fs_struct *new_fs)
16615  {
16616         struct nsproxy *new_nsp;
16617         int err;
16618  
16619 +       vxdprintk(VXD_CBIT(space, 4),
16620 +               "unshare_namespaces(0x%08lx,%p,%p)",
16621 +               flags, orig, new_fs);
16622 +
16623         new_nsp = create_nsproxy();
16624         if (!new_nsp)
16625                 return ERR_PTR(-ENOMEM);
16626  
16627 -       new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
16628 +       new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
16629         if (IS_ERR(new_nsp->mnt_ns)) {
16630                 err = PTR_ERR(new_nsp->mnt_ns);
16631                 goto out_ns;
16632         }
16633  
16634 -       new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
16635 +       new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
16636         if (IS_ERR(new_nsp->uts_ns)) {
16637                 err = PTR_ERR(new_nsp->uts_ns);
16638                 goto out_uts;
16639         }
16640  
16641 -       new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
16642 +       new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
16643         if (IS_ERR(new_nsp->ipc_ns)) {
16644                 err = PTR_ERR(new_nsp->ipc_ns);
16645                 goto out_ipc;
16646         }
16647  
16648 -       new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
16649 +       new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
16650         if (IS_ERR(new_nsp->pid_ns)) {
16651                 err = PTR_ERR(new_nsp->pid_ns);
16652                 goto out_pid;
16653         }
16654  
16655 -       new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
16656 +       /* disabled now?
16657 +       new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
16658 +       if (IS_ERR(new_nsp->user_ns)) {
16659 +               err = PTR_ERR(new_nsp->user_ns);
16660 +               goto out_user;
16661 +       } */
16662 +
16663 +       new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
16664         if (IS_ERR(new_nsp->net_ns)) {
16665                 err = PTR_ERR(new_nsp->net_ns);
16666                 goto out_net;
16667 @@ -112,6 +128,38 @@ out_ns:
16668         return ERR_PTR(err);
16669  }
16670  
16671 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
16672 +                       struct fs_struct *new_fs)
16673 +{
16674 +       return unshare_namespaces(flags, tsk->nsproxy, new_fs);
16675 +}
16676 +
16677 +/*
16678 + * copies the nsproxy, setting refcount to 1, and grabbing a
16679 + * reference to all contained namespaces.
16680 + */
16681 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
16682 +{
16683 +       struct nsproxy *ns = create_nsproxy();
16684 +
16685 +       if (ns) {
16686 +               memcpy(ns, orig, sizeof(struct nsproxy));
16687 +               atomic_set(&ns->count, 1);
16688 +
16689 +               if (ns->mnt_ns)
16690 +                       get_mnt_ns(ns->mnt_ns);
16691 +               if (ns->uts_ns)
16692 +                       get_uts_ns(ns->uts_ns);
16693 +               if (ns->ipc_ns)
16694 +                       get_ipc_ns(ns->ipc_ns);
16695 +               if (ns->pid_ns)
16696 +                       get_pid_ns(ns->pid_ns);
16697 +               if (ns->net_ns)
16698 +                       get_net(ns->net_ns);
16699 +       }
16700 +       return ns;
16701 +}
16702 +
16703  /*
16704   * called from clone.  This now handles copy for nsproxy and all
16705   * namespaces therein.
16706 @@ -119,9 +167,12 @@ out_ns:
16707  int copy_namespaces(unsigned long flags, struct task_struct *tsk)
16708  {
16709         struct nsproxy *old_ns = tsk->nsproxy;
16710 -       struct nsproxy *new_ns;
16711 +       struct nsproxy *new_ns = NULL;
16712         int err = 0;
16713  
16714 +       vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
16715 +               flags, tsk, old_ns);
16716 +
16717         if (!old_ns)
16718                 return 0;
16719  
16720 @@ -131,7 +182,7 @@ int copy_namespaces(unsigned long flags,
16721                                 CLONE_NEWPID | CLONE_NEWNET)))
16722                 return 0;
16723  
16724 -       if (!capable(CAP_SYS_ADMIN)) {
16725 +       if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
16726                 err = -EPERM;
16727                 goto out;
16728         }
16729 @@ -158,6 +209,9 @@ int copy_namespaces(unsigned long flags,
16730  
16731  out:
16732         put_nsproxy(old_ns);
16733 +       vxdprintk(VXD_CBIT(space, 3),
16734 +               "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
16735 +               flags, tsk, old_ns, err, new_ns);
16736         return err;
16737  }
16738  
16739 @@ -171,7 +225,9 @@ void free_nsproxy(struct nsproxy *ns)
16740                 put_ipc_ns(ns->ipc_ns);
16741         if (ns->pid_ns)
16742                 put_pid_ns(ns->pid_ns);
16743 -       put_net(ns->net_ns);
16744 +       if (ns->net_ns)
16745 +               put_net(ns->net_ns);
16746 +       atomic_dec(&vs_global_nsproxy);
16747         kmem_cache_free(nsproxy_cachep, ns);
16748  }
16749  
16750 @@ -184,11 +240,15 @@ int unshare_nsproxy_namespaces(unsigned 
16751  {
16752         int err = 0;
16753  
16754 +       vxdprintk(VXD_CBIT(space, 4),
16755 +               "unshare_nsproxy_namespaces(0x%08lx,[%p])",
16756 +               unshare_flags, current->nsproxy);
16757 +
16758         if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
16759                                CLONE_NEWNET)))
16760                 return 0;
16761  
16762 -       if (!capable(CAP_SYS_ADMIN))
16763 +       if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
16764                 return -EPERM;
16765  
16766         *new_nsp = create_new_namespaces(unshare_flags, current,
16767 diff -NurpP --minimal linux-2.6.35/kernel/pid.c linux-2.6.35-vs2.3.0.36.31/kernel/pid.c
16768 --- linux-2.6.35/kernel/pid.c   2010-08-02 16:52:57.000000000 +0200
16769 +++ linux-2.6.35-vs2.3.0.36.31/kernel/pid.c     2010-08-02 17:05:06.000000000 +0200
16770 @@ -36,6 +36,7 @@
16771  #include <linux/pid_namespace.h>
16772  #include <linux/init_task.h>
16773  #include <linux/syscalls.h>
16774 +#include <linux/vs_pid.h>
16775  
16776  #define pid_hashfn(nr, ns)     \
16777         hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
16778 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
16779  
16780  struct pid *find_vpid(int nr)
16781  {
16782 -       return find_pid_ns(nr, current->nsproxy->pid_ns);
16783 +       return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
16784  }
16785  EXPORT_SYMBOL_GPL(find_vpid);
16786  
16787 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
16788  struct task_struct *pid_task(struct pid *pid, enum pid_type type)
16789  {
16790         struct task_struct *result = NULL;
16791 +
16792 +       if (type == PIDTYPE_REALPID)
16793 +               type = PIDTYPE_PID;
16794         if (pid) {
16795                 struct hlist_node *first;
16796                 first = rcu_dereference_check(pid->tasks[type].first,
16797 @@ -382,7 +386,7 @@ EXPORT_SYMBOL(pid_task);
16798   */
16799  struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
16800  {
16801 -       return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
16802 +       return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
16803  }
16804  
16805  struct task_struct *find_task_by_vpid(pid_t vnr)
16806 @@ -424,7 +428,7 @@ struct pid *find_get_pid(pid_t nr)
16807  }
16808  EXPORT_SYMBOL_GPL(find_get_pid);
16809  
16810 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16811 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
16812  {
16813         struct upid *upid;
16814         pid_t nr = 0;
16815 @@ -437,6 +441,11 @@ pid_t pid_nr_ns(struct pid *pid, struct 
16816         return nr;
16817  }
16818  
16819 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16820 +{
16821 +       return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
16822 +}
16823 +
16824  pid_t pid_vnr(struct pid *pid)
16825  {
16826         return pid_nr_ns(pid, current->nsproxy->pid_ns);
16827 diff -NurpP --minimal linux-2.6.35/kernel/pid_namespace.c linux-2.6.35-vs2.3.0.36.31/kernel/pid_namespace.c
16828 --- linux-2.6.35/kernel/pid_namespace.c 2010-07-07 18:31:57.000000000 +0200
16829 +++ linux-2.6.35-vs2.3.0.36.31/kernel/pid_namespace.c   2010-08-02 17:05:06.000000000 +0200
16830 @@ -14,6 +14,7 @@
16831  #include <linux/err.h>
16832  #include <linux/acct.h>
16833  #include <linux/slab.h>
16834 +#include <linux/vserver/global.h>
16835  
16836  #define BITS_PER_PAGE          (PAGE_SIZE*8)
16837  
16838 @@ -87,6 +88,7 @@ static struct pid_namespace *create_pid_
16839                 goto out_free_map;
16840  
16841         kref_init(&ns->kref);
16842 +       atomic_inc(&vs_global_pid_ns);
16843         ns->level = level;
16844         ns->parent = get_pid_ns(parent_pid_ns);
16845  
16846 @@ -112,6 +114,7 @@ static void destroy_pid_namespace(struct
16847  
16848         for (i = 0; i < PIDMAP_ENTRIES; i++)
16849                 kfree(ns->pidmap[i].page);
16850 +       atomic_dec(&vs_global_pid_ns);
16851         kmem_cache_free(pid_ns_cachep, ns);
16852  }
16853  
16854 diff -NurpP --minimal linux-2.6.35/kernel/posix-timers.c linux-2.6.35-vs2.3.0.36.31/kernel/posix-timers.c
16855 --- linux-2.6.35/kernel/posix-timers.c  2010-08-02 16:52:57.000000000 +0200
16856 +++ linux-2.6.35-vs2.3.0.36.31/kernel/posix-timers.c    2010-08-02 17:05:06.000000000 +0200
16857 @@ -46,6 +46,7 @@
16858  #include <linux/wait.h>
16859  #include <linux/workqueue.h>
16860  #include <linux/module.h>
16861 +#include <linux/vs_context.h>
16862  
16863  /*
16864   * Management arrays for POSIX timers.  Timers are kept in slab memory
16865 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
16866  {
16867         struct task_struct *task;
16868         int shared, ret = -1;
16869 +
16870         /*
16871          * FIXME: if ->sigq is queued we can race with
16872          * dequeue_signal()->do_schedule_next_timer().
16873 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
16874         rcu_read_lock();
16875         task = pid_task(timr->it_pid, PIDTYPE_PID);
16876         if (task) {
16877 +               struct vx_info_save vxis;
16878 +               struct vx_info *vxi;
16879 +
16880 +               vxi = get_vx_info(task->vx_info);
16881 +               enter_vx_info(vxi, &vxis);
16882                 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
16883                 ret = send_sigqueue(timr->sigq, task, shared);
16884 +               leave_vx_info(&vxis);
16885 +               put_vx_info(vxi);
16886         }
16887         rcu_read_unlock();
16888 +
16889         /* If we failed to send the signal the timer stops. */
16890         return ret > 0;
16891  }
16892 diff -NurpP --minimal linux-2.6.35/kernel/printk.c linux-2.6.35-vs2.3.0.36.31/kernel/printk.c
16893 --- linux-2.6.35/kernel/printk.c        2010-08-02 16:52:57.000000000 +0200
16894 +++ linux-2.6.35-vs2.3.0.36.31/kernel/printk.c  2010-08-02 17:05:06.000000000 +0200
16895 @@ -37,6 +37,7 @@
16896  #include <linux/ratelimit.h>
16897  #include <linux/kmsg_dump.h>
16898  #include <linux/syslog.h>
16899 +#include <linux/vs_cvirt.h>
16900  
16901  #include <asm/uaccess.h>
16902  
16903 @@ -264,18 +265,15 @@ int do_syslog(int type, char __user *buf
16904         unsigned i, j, limit, count;
16905         int do_clear = 0;
16906         char c;
16907 -       int error = 0;
16908 +       int error;
16909  
16910         error = security_syslog(type, from_file);
16911         if (error)
16912                 return error;
16913  
16914 -       switch (type) {
16915 -       case SYSLOG_ACTION_CLOSE:       /* Close log */
16916 -               break;
16917 -       case SYSLOG_ACTION_OPEN:        /* Open log */
16918 -               break;
16919 -       case SYSLOG_ACTION_READ:        /* Read from log */
16920 +       if ((type == SYSLOG_ACTION_READ) ||
16921 +           (type == SYSLOG_ACTION_READ_ALL) ||
16922 +           (type == SYSLOG_ACTION_READ_CLEAR)) {
16923                 error = -EINVAL;
16924                 if (!buf || len < 0)
16925                         goto out;
16926 @@ -286,6 +284,16 @@ int do_syslog(int type, char __user *buf
16927                         error = -EFAULT;
16928                         goto out;
16929                 }
16930 +       }
16931 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
16932 +               return vx_do_syslog(type, buf, len);
16933 +
16934 +       switch (type) {
16935 +       case SYSLOG_ACTION_CLOSE:       /* Close log */
16936 +               break;
16937 +       case SYSLOG_ACTION_OPEN:        /* Open log */
16938 +               break;
16939 +       case SYSLOG_ACTION_READ:        /* Read from log */
16940                 error = wait_event_interruptible(log_wait,
16941                                                         (log_start - log_end));
16942                 if (error)
16943 @@ -312,16 +320,6 @@ int do_syslog(int type, char __user *buf
16944                 /* FALL THRU */
16945         /* Read last kernel messages */
16946         case SYSLOG_ACTION_READ_ALL:
16947 -               error = -EINVAL;
16948 -               if (!buf || len < 0)
16949 -                       goto out;
16950 -               error = 0;
16951 -               if (!len)
16952 -                       goto out;
16953 -               if (!access_ok(VERIFY_WRITE, buf, len)) {
16954 -                       error = -EFAULT;
16955 -                       goto out;
16956 -               }
16957                 count = len;
16958                 if (count > log_buf_len)
16959                         count = log_buf_len;
16960 diff -NurpP --minimal linux-2.6.35/kernel/ptrace.c linux-2.6.35-vs2.3.0.36.31/kernel/ptrace.c
16961 --- linux-2.6.35/kernel/ptrace.c        2010-08-02 16:52:57.000000000 +0200
16962 +++ linux-2.6.35-vs2.3.0.36.31/kernel/ptrace.c  2010-08-02 17:05:06.000000000 +0200
16963 @@ -22,6 +22,7 @@
16964  #include <linux/syscalls.h>
16965  #include <linux/uaccess.h>
16966  #include <linux/regset.h>
16967 +#include <linux/vs_context.h>
16968  
16969  
16970  /*
16971 @@ -150,6 +151,11 @@ int __ptrace_may_access(struct task_stru
16972                 dumpable = get_dumpable(task->mm);
16973         if (!dumpable && !capable(CAP_SYS_PTRACE))
16974                 return -EPERM;
16975 +       if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
16976 +               return -EPERM;
16977 +       if (!vx_check(task->xid, VS_IDENT) &&
16978 +               !task_vx_flags(task, VXF_STATE_ADMIN, 0))
16979 +               return -EACCES;
16980  
16981         return security_ptrace_access_check(task, mode);
16982  }
16983 @@ -703,6 +709,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
16984                 goto out;
16985         }
16986  
16987 +       ret = -EPERM;
16988 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
16989 +               goto out_put_task_struct;
16990 +
16991         if (request == PTRACE_ATTACH) {
16992                 ret = ptrace_attach(child);
16993                 /*
16994 diff -NurpP --minimal linux-2.6.35/kernel/sched.c linux-2.6.35-vs2.3.0.36.31/kernel/sched.c
16995 --- linux-2.6.35/kernel/sched.c 2010-08-02 16:52:57.000000000 +0200
16996 +++ linux-2.6.35-vs2.3.0.36.31/kernel/sched.c   2010-08-02 17:05:06.000000000 +0200
16997 @@ -72,6 +72,8 @@
16998  #include <linux/ctype.h>
16999  #include <linux/ftrace.h>
17000  #include <linux/slab.h>
17001 +#include <linux/vs_sched.h>
17002 +#include <linux/vs_cvirt.h>
17003  
17004  #include <asm/tlb.h>
17005  #include <asm/irq_regs.h>
17006 @@ -2957,9 +2959,17 @@ static inline long calc_load_fold_idle(v
17007   */
17008  void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
17009  {
17010 -       loads[0] = (avenrun[0] + offset) << shift;
17011 -       loads[1] = (avenrun[1] + offset) << shift;
17012 -       loads[2] = (avenrun[2] + offset) << shift;
17013 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
17014 +               struct vx_info *vxi = current_vx_info();
17015 +
17016 +               loads[0] = (vxi->cvirt.load[0] + offset) << shift;
17017 +               loads[1] = (vxi->cvirt.load[1] + offset) << shift;
17018 +               loads[2] = (vxi->cvirt.load[2] + offset) << shift;
17019 +       } else {
17020 +               loads[0] = (avenrun[0] + offset) << shift;
17021 +               loads[1] = (avenrun[1] + offset) << shift;
17022 +               loads[2] = (avenrun[2] + offset) << shift;
17023 +       }
17024  }
17025  
17026  static unsigned long
17027 @@ -3167,16 +3177,19 @@ void account_user_time(struct task_struc
17028                        cputime_t cputime_scaled)
17029  {
17030         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17031 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17032         cputime64_t tmp;
17033 +       int nice = (TASK_NICE(p) > 0);
17034  
17035         /* Add user time to process. */
17036         p->utime = cputime_add(p->utime, cputime);
17037         p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
17038 +       vx_account_user(vxi, cputime, nice);
17039         account_group_user_time(p, cputime);
17040  
17041         /* Add user time to cpustat. */
17042         tmp = cputime_to_cputime64(cputime);
17043 -       if (TASK_NICE(p) > 0)
17044 +       if (nice)
17045                 cpustat->nice = cputime64_add(cpustat->nice, tmp);
17046         else
17047                 cpustat->user = cputime64_add(cpustat->user, tmp);
17048 @@ -3227,6 +3240,7 @@ void account_system_time(struct task_str
17049                          cputime_t cputime, cputime_t cputime_scaled)
17050  {
17051         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17052 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17053         cputime64_t tmp;
17054  
17055         if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
17056 @@ -3237,6 +3251,7 @@ void account_system_time(struct task_str
17057         /* Add system time to process. */
17058         p->stime = cputime_add(p->stime, cputime);
17059         p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
17060 +       vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
17061         account_group_system_time(p, cputime);
17062  
17063         /* Add system time to cpustat. */
17064 @@ -4302,7 +4317,7 @@ SYSCALL_DEFINE1(nice, int, increment)
17065                 nice = 19;
17066  
17067         if (increment < 0 && !can_nice(current, nice))
17068 -               return -EPERM;
17069 +               return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
17070  
17071         retval = security_task_setnice(current, nice);
17072         if (retval)
17073 diff -NurpP --minimal linux-2.6.35/kernel/sched_fair.c linux-2.6.35-vs2.3.0.36.31/kernel/sched_fair.c
17074 --- linux-2.6.35/kernel/sched_fair.c    2010-08-02 16:52:57.000000000 +0200
17075 +++ linux-2.6.35-vs2.3.0.36.31/kernel/sched_fair.c      2010-08-02 17:05:06.000000000 +0200
17076 @@ -782,6 +782,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
17077         check_spread(cfs_rq, se);
17078         if (se != cfs_rq->curr)
17079                 __enqueue_entity(cfs_rq, se);
17080 +
17081 +       if (entity_is_task(se))
17082 +               vx_activate_task(task_of(se));
17083  }
17084  
17085  static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
17086 @@ -825,6 +828,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
17087  
17088         if (se != cfs_rq->curr)
17089                 __dequeue_entity(cfs_rq, se);
17090 +       if (entity_is_task(se))
17091 +               vx_deactivate_task(task_of(se));
17092         account_entity_dequeue(cfs_rq, se);
17093         update_min_vruntime(cfs_rq);
17094  
17095 diff -NurpP --minimal linux-2.6.35/kernel/signal.c linux-2.6.35-vs2.3.0.36.31/kernel/signal.c
17096 --- linux-2.6.35/kernel/signal.c        2010-08-02 16:52:57.000000000 +0200
17097 +++ linux-2.6.35-vs2.3.0.36.31/kernel/signal.c  2010-08-02 17:05:06.000000000 +0200
17098 @@ -28,6 +28,8 @@
17099  #include <linux/freezer.h>
17100  #include <linux/pid_namespace.h>
17101  #include <linux/nsproxy.h>
17102 +#include <linux/vs_context.h>
17103 +#include <linux/vs_pid.h>
17104  #define CREATE_TRACE_POINTS
17105  #include <trace/events/signal.h>
17106  
17107 @@ -646,9 +648,18 @@ static int check_kill_permission(int sig
17108         struct pid *sid;
17109         int error;
17110  
17111 +       vxdprintk(VXD_CBIT(misc, 7),
17112 +               "check_kill_permission(%d,%p,%p[#%u,%u])",
17113 +               sig, info, t, vx_task_xid(t), t->pid);
17114 +
17115         if (!valid_signal(sig))
17116                 return -EINVAL;
17117  
17118 +/*     FIXME: needed? if so, why?
17119 +       if ((info != SEND_SIG_NOINFO) &&
17120 +               (is_si_special(info) || !si_fromuser(info)))
17121 +               goto skip;      */
17122 +
17123         if (!si_fromuser(info))
17124                 return 0;
17125  
17126 @@ -678,6 +689,20 @@ static int check_kill_permission(int sig
17127                 }
17128         }
17129  
17130 +       error = -EPERM;
17131 +       if (t->pid == 1 && current->xid)
17132 +               return error;
17133 +
17134 +       error = -ESRCH;
17135 +       /* FIXME: we shouldn't return ESRCH ever, to avoid
17136 +                 loops, maybe ENOENT or EACCES? */
17137 +       if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17138 +               vxdprintk(current->xid || VXD_CBIT(misc, 7),
17139 +                       "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17140 +                       sig, info, t, vx_task_xid(t), t->pid, current->xid);
17141 +               return error;
17142 +       }
17143 +/* skip: */
17144         return security_task_kill(t, info, sig, 0);
17145  }
17146  
17147 @@ -1167,7 +1192,7 @@ int kill_pid_info(int sig, struct siginf
17148         rcu_read_lock();
17149  retry:
17150         p = pid_task(pid, PIDTYPE_PID);
17151 -       if (p) {
17152 +       if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17153                 error = group_send_sig_info(sig, info, p);
17154                 if (unlikely(error == -ESRCH))
17155                         /*
17156 @@ -1207,7 +1232,7 @@ int kill_pid_info_as_uid(int sig, struct
17157  
17158         rcu_read_lock();
17159         p = pid_task(pid, PIDTYPE_PID);
17160 -       if (!p) {
17161 +       if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17162                 ret = -ESRCH;
17163                 goto out_unlock;
17164         }
17165 @@ -1262,8 +1287,10 @@ static int kill_something_info(int sig, 
17166                 struct task_struct * p;
17167  
17168                 for_each_process(p) {
17169 -                       if (task_pid_vnr(p) > 1 &&
17170 -                                       !same_thread_group(p, current)) {
17171 +                       if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17172 +                               task_pid_vnr(p) > 1 &&
17173 +                               !same_thread_group(p, current) &&
17174 +                               !vx_current_initpid(p->pid)) {
17175                                 int err = group_send_sig_info(sig, info, p);
17176                                 ++count;
17177                                 if (err != -EPERM)
17178 @@ -1930,6 +1957,11 @@ relock:
17179                                 !sig_kernel_only(signr))
17180                         continue;
17181  
17182 +               /* virtual init is protected against user signals */
17183 +               if ((info->si_code == SI_USER) &&
17184 +                       vx_current_initpid(current->pid))
17185 +                       continue;
17186 +
17187                 if (sig_kernel_stop(signr)) {
17188                         /*
17189                          * The default action is to stop all threads in
17190 diff -NurpP --minimal linux-2.6.35/kernel/softirq.c linux-2.6.35-vs2.3.0.36.31/kernel/softirq.c
17191 --- linux-2.6.35/kernel/softirq.c       2010-08-02 16:52:57.000000000 +0200
17192 +++ linux-2.6.35-vs2.3.0.36.31/kernel/softirq.c 2010-08-02 17:05:06.000000000 +0200
17193 @@ -24,6 +24,7 @@
17194  #include <linux/ftrace.h>
17195  #include <linux/smp.h>
17196  #include <linux/tick.h>
17197 +#include <linux/vs_context.h>
17198  
17199  #define CREATE_TRACE_POINTS
17200  #include <trace/events/irq.h>
17201 diff -NurpP --minimal linux-2.6.35/kernel/sys.c linux-2.6.35-vs2.3.0.36.31/kernel/sys.c
17202 --- linux-2.6.35/kernel/sys.c   2010-08-02 16:52:57.000000000 +0200
17203 +++ linux-2.6.35-vs2.3.0.36.31/kernel/sys.c     2010-08-02 17:48:19.000000000 +0200
17204 @@ -42,6 +42,7 @@
17205  #include <linux/syscalls.h>
17206  #include <linux/kprobes.h>
17207  #include <linux/user_namespace.h>
17208 +#include <linux/vs_pid.h>
17209  
17210  #include <asm/uaccess.h>
17211  #include <asm/io.h>
17212 @@ -131,7 +132,10 @@ static int set_one_prio(struct task_stru
17213                 goto out;
17214         }
17215         if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17216 -               error = -EACCES;
17217 +               if (vx_flags(VXF_IGNEG_NICE, 0))
17218 +                       error = 0;
17219 +               else
17220 +                       error = -EACCES;
17221                 goto out;
17222         }
17223         no_nice = security_task_setnice(p, niceval);
17224 @@ -181,6 +185,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17225                         else
17226                                 pgrp = task_pgrp(current);
17227                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17228 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17229 +                                       continue;
17230                                 error = set_one_prio(p, niceval, error);
17231                         } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17232                         break;
17233 @@ -244,6 +250,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17234                         else
17235                                 pgrp = task_pgrp(current);
17236                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17237 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17238 +                                       continue;
17239                                 niceval = 20 - task_nice(p);
17240                                 if (niceval > retval)
17241                                         retval = niceval;
17242 @@ -357,6 +365,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
17243  
17244  static DEFINE_MUTEX(reboot_mutex);
17245  
17246 +long vs_reboot(unsigned int, void __user *);
17247 +
17248  /*
17249   * Reboot system call: for obvious reasons only root may call it,
17250   * and even root needs to set up some magic numbers in the registers
17251 @@ -389,6 +399,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17252         if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17253                 cmd = LINUX_REBOOT_CMD_HALT;
17254  
17255 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
17256 +               return vs_reboot(cmd, arg);
17257 +
17258         mutex_lock(&reboot_mutex);
17259         switch (cmd) {
17260         case LINUX_REBOOT_CMD_RESTART:
17261 @@ -1167,7 +1180,7 @@ SYSCALL_DEFINE2(sethostname, char __user
17262         int errno;
17263         char tmp[__NEW_UTS_LEN];
17264  
17265 -       if (!capable(CAP_SYS_ADMIN))
17266 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17267                 return -EPERM;
17268         if (len < 0 || len > __NEW_UTS_LEN)
17269                 return -EINVAL;
17270 @@ -1216,7 +1229,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
17271         int errno;
17272         char tmp[__NEW_UTS_LEN];
17273  
17274 -       if (!capable(CAP_SYS_ADMIN))
17275 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17276                 return -EPERM;
17277         if (len < 0 || len > __NEW_UTS_LEN)
17278                 return -EINVAL;
17279 @@ -1285,7 +1298,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
17280                 return -EINVAL;
17281         old_rlim = current->signal->rlim + resource;
17282         if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17283 -           !capable(CAP_SYS_RESOURCE))
17284 +           !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17285                 return -EPERM;
17286         if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
17287                 return -EPERM;
17288 diff -NurpP --minimal linux-2.6.35/kernel/sysctl_binary.c linux-2.6.35-vs2.3.0.36.31/kernel/sysctl_binary.c
17289 --- linux-2.6.35/kernel/sysctl_binary.c 2010-08-02 16:52:57.000000000 +0200
17290 +++ linux-2.6.35-vs2.3.0.36.31/kernel/sysctl_binary.c   2010-08-02 17:05:06.000000000 +0200
17291 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
17292  
17293         { CTL_INT,      KERN_PANIC,                     "panic" },
17294         { CTL_INT,      KERN_REALROOTDEV,               "real-root-dev" },
17295 +       { CTL_STR,      KERN_VSHELPER,                  "vshelper" },
17296  
17297         { CTL_STR,      KERN_SPARC_REBOOT,              "reboot-cmd" },
17298         { CTL_INT,      KERN_CTLALTDEL,                 "ctrl-alt-del" },
17299 diff -NurpP --minimal linux-2.6.35/kernel/sysctl.c linux-2.6.35-vs2.3.0.36.31/kernel/sysctl.c
17300 --- linux-2.6.35/kernel/sysctl.c        2010-08-02 16:52:57.000000000 +0200
17301 +++ linux-2.6.35-vs2.3.0.36.31/kernel/sysctl.c  2010-08-02 17:05:06.000000000 +0200
17302 @@ -72,6 +72,7 @@
17303  #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
17304  #include <linux/lockdep.h>
17305  #endif
17306 +extern char vshelper_path[];
17307  #ifdef CONFIG_CHR_DEV_SG
17308  #include <scsi/sg.h>
17309  #endif
17310 @@ -571,6 +572,13 @@ static struct ctl_table kern_table[] = {
17311                 .proc_handler   = proc_dostring,
17312         },
17313  #endif
17314 +       {
17315 +               .procname       = "vshelper",
17316 +               .data           = &vshelper_path,
17317 +               .maxlen         = 256,
17318 +               .mode           = 0644,
17319 +               .proc_handler   = &proc_dostring,
17320 +       },
17321  #ifdef CONFIG_CHR_DEV_SG
17322         {
17323                 .procname       = "sg-big-buff",
17324 diff -NurpP --minimal linux-2.6.35/kernel/time.c linux-2.6.35-vs2.3.0.36.31/kernel/time.c
17325 --- linux-2.6.35/kernel/time.c  2010-08-02 16:52:57.000000000 +0200
17326 +++ linux-2.6.35-vs2.3.0.36.31/kernel/time.c    2010-08-02 17:05:06.000000000 +0200
17327 @@ -62,6 +62,7 @@ EXPORT_SYMBOL(sys_tz);
17328  SYSCALL_DEFINE1(time, time_t __user *, tloc)
17329  {
17330         time_t i = get_seconds();
17331 +/*     FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17332  
17333         if (tloc) {
17334                 if (put_user(i,tloc))
17335 @@ -92,7 +93,7 @@ SYSCALL_DEFINE1(stime, time_t __user *, 
17336         if (err)
17337                 return err;
17338  
17339 -       do_settimeofday(&tv);
17340 +       vx_settimeofday(&tv);
17341         return 0;
17342  }
17343  
17344 @@ -103,7 +104,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
17345  {
17346         if (likely(tv != NULL)) {
17347                 struct timeval ktv;
17348 -               do_gettimeofday(&ktv);
17349 +               vx_gettimeofday(&ktv);
17350                 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17351                         return -EFAULT;
17352         }
17353 @@ -177,7 +178,7 @@ int do_sys_settimeofday(struct timespec 
17354                 /* SMP safe, again the code in arch/foo/time.c should
17355                  * globally block out interrupts when it runs.
17356                  */
17357 -               return do_settimeofday(tv);
17358 +               return vx_settimeofday(tv);
17359         }
17360         return 0;
17361  }
17362 @@ -309,7 +310,7 @@ void getnstimeofday(struct timespec *tv)
17363  {
17364         struct timeval x;
17365  
17366 -       do_gettimeofday(&x);
17367 +       vx_gettimeofday(&x);
17368         tv->tv_sec = x.tv_sec;
17369         tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17370  }
17371 diff -NurpP --minimal linux-2.6.35/kernel/timer.c linux-2.6.35-vs2.3.0.36.31/kernel/timer.c
17372 --- linux-2.6.35/kernel/timer.c 2010-08-02 16:52:58.000000000 +0200
17373 +++ linux-2.6.35-vs2.3.0.36.31/kernel/timer.c   2010-08-02 17:05:06.000000000 +0200
17374 @@ -40,6 +40,10 @@
17375  #include <linux/perf_event.h>
17376  #include <linux/sched.h>
17377  #include <linux/slab.h>
17378 +#include <linux/vs_base.h>
17379 +#include <linux/vs_cvirt.h>
17380 +#include <linux/vs_pid.h>
17381 +#include <linux/vserver/sched.h>
17382  
17383  #include <asm/uaccess.h>
17384  #include <asm/unistd.h>
17385 @@ -1318,12 +1322,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17386  
17387  #endif
17388  
17389 -#ifndef __alpha__
17390 -
17391 -/*
17392 - * The Alpha uses getxpid, getxuid, and getxgid instead.  Maybe this
17393 - * should be moved into arch/i386 instead?
17394 - */
17395  
17396  /**
17397   * sys_getpid - return the thread group id of the current process
17398 @@ -1352,10 +1350,23 @@ SYSCALL_DEFINE0(getppid)
17399         rcu_read_lock();
17400         pid = task_tgid_vnr(current->real_parent);
17401         rcu_read_unlock();
17402 +       return vx_map_pid(pid);
17403 +}
17404  
17405 -       return pid;
17406 +#ifdef __alpha__
17407 +
17408 +/*
17409 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17410 + */
17411 +
17412 +asmlinkage long do_getxpid(long *ppid)
17413 +{
17414 +       *ppid = sys_getppid();
17415 +       return sys_getpid();
17416  }
17417  
17418 +#else /* _alpha_ */
17419 +
17420  SYSCALL_DEFINE0(getuid)
17421  {
17422         /* Only we change this so SMP safe */
17423 diff -NurpP --minimal linux-2.6.35/kernel/user_namespace.c linux-2.6.35-vs2.3.0.36.31/kernel/user_namespace.c
17424 --- linux-2.6.35/kernel/user_namespace.c        2010-08-02 16:52:58.000000000 +0200
17425 +++ linux-2.6.35-vs2.3.0.36.31/kernel/user_namespace.c  2010-08-02 17:05:06.000000000 +0200
17426 @@ -10,6 +10,7 @@
17427  #include <linux/slab.h>
17428  #include <linux/user_namespace.h>
17429  #include <linux/cred.h>
17430 +#include <linux/vserver/global.h>
17431  
17432  /*
17433   * Create a new user namespace, deriving the creator from the user in the
17434 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
17435                 return -ENOMEM;
17436  
17437         kref_init(&ns->kref);
17438 +       atomic_inc(&vs_global_user_ns);
17439  
17440         for (n = 0; n < UIDHASH_SZ; ++n)
17441                 INIT_HLIST_HEAD(ns->uidhash_table + n);
17442 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
17443         struct user_namespace *ns =
17444                 container_of(kref, struct user_namespace, kref);
17445  
17446 +       /* FIXME: maybe move into destroyer? */
17447 +       atomic_dec(&vs_global_user_ns);
17448         INIT_WORK(&ns->destroyer, free_user_ns_work);
17449         schedule_work(&ns->destroyer);
17450  }
17451 diff -NurpP --minimal linux-2.6.35/kernel/utsname.c linux-2.6.35-vs2.3.0.36.31/kernel/utsname.c
17452 --- linux-2.6.35/kernel/utsname.c       2009-09-10 15:26:28.000000000 +0200
17453 +++ linux-2.6.35-vs2.3.0.36.31/kernel/utsname.c 2010-08-02 17:05:06.000000000 +0200
17454 @@ -14,14 +14,17 @@
17455  #include <linux/utsname.h>
17456  #include <linux/err.h>
17457  #include <linux/slab.h>
17458 +#include <linux/vserver/global.h>
17459  
17460  static struct uts_namespace *create_uts_ns(void)
17461  {
17462         struct uts_namespace *uts_ns;
17463  
17464         uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17465 -       if (uts_ns)
17466 +       if (uts_ns) {
17467                 kref_init(&uts_ns->kref);
17468 +               atomic_inc(&vs_global_uts_ns);
17469 +       }
17470         return uts_ns;
17471  }
17472  
17473 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
17474         struct uts_namespace *ns;
17475  
17476         ns = container_of(kref, struct uts_namespace, kref);
17477 +       atomic_dec(&vs_global_uts_ns);
17478         kfree(ns);
17479  }
17480 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cacct.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct.c
17481 --- linux-2.6.35/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17482 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct.c   2010-08-02 17:05:06.000000000 +0200
17483 @@ -0,0 +1,42 @@
17484 +/*
17485 + *  linux/kernel/vserver/cacct.c
17486 + *
17487 + *  Virtual Server: Context Accounting
17488 + *
17489 + *  Copyright (C) 2006-2007 Herbert Pötzl
17490 + *
17491 + *  V0.01  added accounting stats
17492 + *
17493 + */
17494 +
17495 +#include <linux/types.h>
17496 +#include <linux/vs_context.h>
17497 +#include <linux/vserver/cacct_cmd.h>
17498 +#include <linux/vserver/cacct_int.h>
17499 +
17500 +#include <asm/errno.h>
17501 +#include <asm/uaccess.h>
17502 +
17503 +
17504 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17505 +{
17506 +       struct vcmd_sock_stat_v0 vc_data;
17507 +       int j, field;
17508 +
17509 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17510 +               return -EFAULT;
17511 +
17512 +       field = vc_data.field;
17513 +       if ((field < 0) || (field >= VXA_SOCK_SIZE))
17514 +               return -EINVAL;
17515 +
17516 +       for (j = 0; j < 3; j++) {
17517 +               vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17518 +               vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17519 +       }
17520 +
17521 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17522 +               return -EFAULT;
17523 +       return 0;
17524 +}
17525 +
17526 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cacct_init.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct_init.h
17527 --- linux-2.6.35/kernel/vserver/cacct_init.h    1970-01-01 01:00:00.000000000 +0100
17528 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct_init.h      2010-08-02 17:05:06.000000000 +0200
17529 @@ -0,0 +1,25 @@
17530 +
17531 +
17532 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17533 +{
17534 +       int i, j;
17535 +
17536 +
17537 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
17538 +               for (j = 0; j < 3; j++) {
17539 +                       atomic_long_set(&cacct->sock[i][j].count, 0);
17540 +                       atomic_long_set(&cacct->sock[i][j].total, 0);
17541 +               }
17542 +       }
17543 +       for (i = 0; i < 8; i++)
17544 +               atomic_set(&cacct->slab[i], 0);
17545 +       for (i = 0; i < 5; i++)
17546 +               for (j = 0; j < 4; j++)
17547 +                       atomic_set(&cacct->page[i][j], 0);
17548 +}
17549 +
17550 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17551 +{
17552 +       return;
17553 +}
17554 +
17555 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cacct_proc.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct_proc.h
17556 --- linux-2.6.35/kernel/vserver/cacct_proc.h    1970-01-01 01:00:00.000000000 +0100
17557 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cacct_proc.h      2010-08-02 17:05:06.000000000 +0200
17558 @@ -0,0 +1,53 @@
17559 +#ifndef _VX_CACCT_PROC_H
17560 +#define _VX_CACCT_PROC_H
17561 +
17562 +#include <linux/vserver/cacct_int.h>
17563 +
17564 +
17565 +#define VX_SOCKA_TOP   \
17566 +       "Type\t    recv #/bytes\t\t   send #/bytes\t\t    fail #/bytes\n"
17567 +
17568 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17569 +{
17570 +       int i, j, length = 0;
17571 +       static char *type[VXA_SOCK_SIZE] = {
17572 +               "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17573 +       };
17574 +
17575 +       length += sprintf(buffer + length, VX_SOCKA_TOP);
17576 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
17577 +               length += sprintf(buffer + length, "%s:", type[i]);
17578 +               for (j = 0; j < 3; j++) {
17579 +                       length += sprintf(buffer + length,
17580 +                               "\t%10lu/%-10lu",
17581 +                               vx_sock_count(cacct, i, j),
17582 +                               vx_sock_total(cacct, i, j));
17583 +               }
17584 +               buffer[length++] = '\n';
17585 +       }
17586 +
17587 +       length += sprintf(buffer + length, "\n");
17588 +       length += sprintf(buffer + length,
17589 +               "slab:\t %8u %8u %8u %8u\n",
17590 +               atomic_read(&cacct->slab[1]),
17591 +               atomic_read(&cacct->slab[4]),
17592 +               atomic_read(&cacct->slab[0]),
17593 +               atomic_read(&cacct->slab[2]));
17594 +
17595 +       length += sprintf(buffer + length, "\n");
17596 +       for (i = 0; i < 5; i++) {
17597 +               length += sprintf(buffer + length,
17598 +                       "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17599 +                       atomic_read(&cacct->page[i][0]),
17600 +                       atomic_read(&cacct->page[i][1]),
17601 +                       atomic_read(&cacct->page[i][2]),
17602 +                       atomic_read(&cacct->page[i][3]),
17603 +                       atomic_read(&cacct->page[i][4]),
17604 +                       atomic_read(&cacct->page[i][5]),
17605 +                       atomic_read(&cacct->page[i][6]),
17606 +                       atomic_read(&cacct->page[i][7]));
17607 +       }
17608 +       return length;
17609 +}
17610 +
17611 +#endif /* _VX_CACCT_PROC_H */
17612 diff -NurpP --minimal linux-2.6.35/kernel/vserver/context.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/context.c
17613 --- linux-2.6.35/kernel/vserver/context.c       1970-01-01 01:00:00.000000000 +0100
17614 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/context.c 2010-08-02 17:05:06.000000000 +0200
17615 @@ -0,0 +1,1058 @@
17616 +/*
17617 + *  linux/kernel/vserver/context.c
17618 + *
17619 + *  Virtual Server: Context Support
17620 + *
17621 + *  Copyright (C) 2003-2007  Herbert Pötzl
17622 + *
17623 + *  V0.01  context helper
17624 + *  V0.02  vx_ctx_kill syscall command
17625 + *  V0.03  replaced context_info calls
17626 + *  V0.04  redesign of struct (de)alloc
17627 + *  V0.05  rlimit basic implementation
17628 + *  V0.06  task_xid and info commands
17629 + *  V0.07  context flags and caps
17630 + *  V0.08  switch to RCU based hash
17631 + *  V0.09  revert to non RCU for now
17632 + *  V0.10  and back to working RCU hash
17633 + *  V0.11  and back to locking again
17634 + *  V0.12  referenced context store
17635 + *  V0.13  separate per cpu data
17636 + *  V0.14  changed vcmds to vxi arg
17637 + *  V0.15  added context stat
17638 + *  V0.16  have __create claim() the vxi
17639 + *  V0.17  removed older and legacy stuff
17640 + *
17641 + */
17642 +
17643 +#include <linux/slab.h>
17644 +#include <linux/types.h>
17645 +#include <linux/security.h>
17646 +#include <linux/pid_namespace.h>
17647 +
17648 +#include <linux/vserver/context.h>
17649 +#include <linux/vserver/network.h>
17650 +#include <linux/vserver/debug.h>
17651 +#include <linux/vserver/limit.h>
17652 +#include <linux/vserver/limit_int.h>
17653 +#include <linux/vserver/space.h>
17654 +#include <linux/init_task.h>
17655 +#include <linux/fs_struct.h>
17656 +
17657 +#include <linux/vs_context.h>
17658 +#include <linux/vs_limit.h>
17659 +#include <linux/vs_pid.h>
17660 +#include <linux/vserver/context_cmd.h>
17661 +
17662 +#include "cvirt_init.h"
17663 +#include "cacct_init.h"
17664 +#include "limit_init.h"
17665 +#include "sched_init.h"
17666 +
17667 +
17668 +atomic_t vx_global_ctotal      = ATOMIC_INIT(0);
17669 +atomic_t vx_global_cactive     = ATOMIC_INIT(0);
17670 +
17671 +
17672 +/*     now inactive context structures */
17673 +
17674 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17675 +
17676 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17677 +
17678 +
17679 +/*     __alloc_vx_info()
17680 +
17681 +       * allocate an initialized vx_info struct
17682 +       * doesn't make it visible (hash)                        */
17683 +
17684 +static struct vx_info *__alloc_vx_info(xid_t xid)
17685 +{
17686 +       struct vx_info *new = NULL;
17687 +       int cpu, index;
17688 +
17689 +       vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17690 +
17691 +       /* would this benefit from a slab cache? */
17692 +       new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17693 +       if (!new)
17694 +               return 0;
17695 +
17696 +       memset(new, 0, sizeof(struct vx_info));
17697 +#ifdef CONFIG_SMP
17698 +       new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17699 +       if (!new->ptr_pc)
17700 +               goto error;
17701 +#endif
17702 +       new->vx_id = xid;
17703 +       INIT_HLIST_NODE(&new->vx_hlist);
17704 +       atomic_set(&new->vx_usecnt, 0);
17705 +       atomic_set(&new->vx_tasks, 0);
17706 +       new->vx_parent = NULL;
17707 +       new->vx_state = 0;
17708 +       init_waitqueue_head(&new->vx_wait);
17709 +
17710 +       /* prepare reaper */
17711 +       get_task_struct(init_pid_ns.child_reaper);
17712 +       new->vx_reaper = init_pid_ns.child_reaper;
17713 +       new->vx_badness_bias = 0;
17714 +
17715 +       /* rest of init goes here */
17716 +       vx_info_init_limit(&new->limit);
17717 +       vx_info_init_sched(&new->sched);
17718 +       vx_info_init_cvirt(&new->cvirt);
17719 +       vx_info_init_cacct(&new->cacct);
17720 +
17721 +       /* per cpu data structures */
17722 +       for_each_possible_cpu(cpu) {
17723 +               vx_info_init_sched_pc(
17724 +                       &vx_per_cpu(new, sched_pc, cpu), cpu);
17725 +               vx_info_init_cvirt_pc(
17726 +                       &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17727 +       }
17728 +
17729 +       new->vx_flags = VXF_INIT_SET;
17730 +       cap_set_init_eff(new->vx_bcaps);
17731 +       new->vx_ccaps = 0;
17732 +       new->vx_umask = 0;
17733 +
17734 +       new->reboot_cmd = 0;
17735 +       new->exit_code = 0;
17736 +
17737 +       // preconfig fs entries
17738 +       for (index = 0; index < VX_SPACES; index++) {
17739 +               write_lock(&init_fs.lock);
17740 +               init_fs.users++;
17741 +               write_unlock(&init_fs.lock);
17742 +               new->vx_fs[index] = &init_fs;
17743 +       }
17744 +
17745 +       vxdprintk(VXD_CBIT(xid, 0),
17746 +               "alloc_vx_info(%d) = %p", xid, new);
17747 +       vxh_alloc_vx_info(new);
17748 +       atomic_inc(&vx_global_ctotal);
17749 +       return new;
17750 +#ifdef CONFIG_SMP
17751 +error:
17752 +       kfree(new);
17753 +       return 0;
17754 +#endif
17755 +}
17756 +
17757 +/*     __dealloc_vx_info()
17758 +
17759 +       * final disposal of vx_info                             */
17760 +
17761 +static void __dealloc_vx_info(struct vx_info *vxi)
17762 +{
17763 +#ifdef CONFIG_VSERVER_WARN
17764 +       struct vx_info_save vxis;
17765 +       int cpu;
17766 +#endif
17767 +       vxdprintk(VXD_CBIT(xid, 0),
17768 +               "dealloc_vx_info(%p)", vxi);
17769 +       vxh_dealloc_vx_info(vxi);
17770 +
17771 +#ifdef CONFIG_VSERVER_WARN
17772 +       enter_vx_info(vxi, &vxis);
17773 +       vx_info_exit_limit(&vxi->limit);
17774 +       vx_info_exit_sched(&vxi->sched);
17775 +       vx_info_exit_cvirt(&vxi->cvirt);
17776 +       vx_info_exit_cacct(&vxi->cacct);
17777 +
17778 +       for_each_possible_cpu(cpu) {
17779 +               vx_info_exit_sched_pc(
17780 +                       &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17781 +               vx_info_exit_cvirt_pc(
17782 +                       &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17783 +       }
17784 +       leave_vx_info(&vxis);
17785 +#endif
17786 +
17787 +       vxi->vx_id = -1;
17788 +       vxi->vx_state |= VXS_RELEASED;
17789 +
17790 +#ifdef CONFIG_SMP
17791 +       free_percpu(vxi->ptr_pc);
17792 +#endif
17793 +       kfree(vxi);
17794 +       atomic_dec(&vx_global_ctotal);
17795 +}
17796 +
17797 +static void __shutdown_vx_info(struct vx_info *vxi)
17798 +{
17799 +       struct nsproxy *nsproxy;
17800 +       struct fs_struct *fs;
17801 +       int index, kill;
17802 +
17803 +       might_sleep();
17804 +
17805 +       vxi->vx_state |= VXS_SHUTDOWN;
17806 +       vs_state_change(vxi, VSC_SHUTDOWN);
17807 +
17808 +       for (index = 0; index < VX_SPACES; index++) {
17809 +               nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17810 +               if (nsproxy)
17811 +                       put_nsproxy(nsproxy);
17812 +
17813 +               fs = xchg(&vxi->vx_fs[index], NULL);
17814 +               write_lock(&fs->lock);
17815 +               kill = !--fs->users;
17816 +               write_unlock(&fs->lock);
17817 +               if (kill)
17818 +                       free_fs_struct(fs);
17819 +       }
17820 +}
17821 +
17822 +/* exported stuff */
17823 +
17824 +void free_vx_info(struct vx_info *vxi)
17825 +{
17826 +       unsigned long flags;
17827 +       unsigned index;
17828 +
17829 +       /* check for reference counts first */
17830 +       BUG_ON(atomic_read(&vxi->vx_usecnt));
17831 +       BUG_ON(atomic_read(&vxi->vx_tasks));
17832 +
17833 +       /* context must not be hashed */
17834 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
17835 +
17836 +       /* context shutdown is mandatory */
17837 +       BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17838 +
17839 +       /* nsproxy and fs check */
17840 +       for (index = 0; index < VX_SPACES; index++) {
17841 +               BUG_ON(vxi->vx_nsproxy[index]);
17842 +               BUG_ON(vxi->vx_fs[index]);
17843 +       }
17844 +
17845 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
17846 +       hlist_del(&vxi->vx_hlist);
17847 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17848 +
17849 +       __dealloc_vx_info(vxi);
17850 +}
17851 +
17852 +
17853 +/*     hash table for vx_info hash */
17854 +
17855 +#define VX_HASH_SIZE   13
17856 +
17857 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17858 +       { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17859 +
17860 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17861 +
17862 +
17863 +static inline unsigned int __hashval(xid_t xid)
17864 +{
17865 +       return (xid % VX_HASH_SIZE);
17866 +}
17867 +
17868 +
17869 +
17870 +/*     __hash_vx_info()
17871 +
17872 +       * add the vxi to the global hash table
17873 +       * requires the hash_lock to be held                     */
17874 +
17875 +static inline void __hash_vx_info(struct vx_info *vxi)
17876 +{
17877 +       struct hlist_head *head;
17878 +
17879 +       vxd_assert_lock(&vx_info_hash_lock);
17880 +       vxdprintk(VXD_CBIT(xid, 4),
17881 +               "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17882 +       vxh_hash_vx_info(vxi);
17883 +
17884 +       /* context must not be hashed */
17885 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
17886 +
17887 +       vxi->vx_state |= VXS_HASHED;
17888 +       head = &vx_info_hash[__hashval(vxi->vx_id)];
17889 +       hlist_add_head(&vxi->vx_hlist, head);
17890 +       atomic_inc(&vx_global_cactive);
17891 +}
17892 +
17893 +/*     __unhash_vx_info()
17894 +
17895 +       * remove the vxi from the global hash table
17896 +       * requires the hash_lock to be held                     */
17897 +
17898 +static inline void __unhash_vx_info(struct vx_info *vxi)
17899 +{
17900 +       unsigned long flags;
17901 +
17902 +       vxd_assert_lock(&vx_info_hash_lock);
17903 +       vxdprintk(VXD_CBIT(xid, 4),
17904 +               "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17905 +               atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17906 +       vxh_unhash_vx_info(vxi);
17907 +
17908 +       /* context must be hashed */
17909 +       BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17910 +       /* but without tasks */
17911 +       BUG_ON(atomic_read(&vxi->vx_tasks));
17912 +
17913 +       vxi->vx_state &= ~VXS_HASHED;
17914 +       hlist_del_init(&vxi->vx_hlist);
17915 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
17916 +       hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17917 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17918 +       atomic_dec(&vx_global_cactive);
17919 +}
17920 +
17921 +
17922 +/*     __lookup_vx_info()
17923 +
17924 +       * requires the hash_lock to be held
17925 +       * doesn't increment the vx_refcnt                       */
17926 +
17927 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17928 +{
17929 +       struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17930 +       struct hlist_node *pos;
17931 +       struct vx_info *vxi;
17932 +
17933 +       vxd_assert_lock(&vx_info_hash_lock);
17934 +       hlist_for_each(pos, head) {
17935 +               vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17936 +
17937 +               if (vxi->vx_id == xid)
17938 +                       goto found;
17939 +       }
17940 +       vxi = NULL;
17941 +found:
17942 +       vxdprintk(VXD_CBIT(xid, 0),
17943 +               "__lookup_vx_info(#%u): %p[#%u]",
17944 +               xid, vxi, vxi ? vxi->vx_id : 0);
17945 +       vxh_lookup_vx_info(vxi, xid);
17946 +       return vxi;
17947 +}
17948 +
17949 +
17950 +/*     __create_vx_info()
17951 +
17952 +       * create the requested context
17953 +       * get(), claim() and hash it                            */
17954 +
17955 +static struct vx_info *__create_vx_info(int id)
17956 +{
17957 +       struct vx_info *new, *vxi = NULL;
17958 +
17959 +       vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
17960 +
17961 +       if (!(new = __alloc_vx_info(id)))
17962 +               return ERR_PTR(-ENOMEM);
17963 +
17964 +       /* required to make dynamic xids unique */
17965 +       spin_lock(&vx_info_hash_lock);
17966 +
17967 +       /* static context requested */
17968 +       if ((vxi = __lookup_vx_info(id))) {
17969 +               vxdprintk(VXD_CBIT(xid, 0),
17970 +                       "create_vx_info(%d) = %p (already there)", id, vxi);
17971 +               if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17972 +                       vxi = ERR_PTR(-EBUSY);
17973 +               else
17974 +                       vxi = ERR_PTR(-EEXIST);
17975 +               goto out_unlock;
17976 +       }
17977 +       /* new context */
17978 +       vxdprintk(VXD_CBIT(xid, 0),
17979 +               "create_vx_info(%d) = %p (new)", id, new);
17980 +       claim_vx_info(new, NULL);
17981 +       __hash_vx_info(get_vx_info(new));
17982 +       vxi = new, new = NULL;
17983 +
17984 +out_unlock:
17985 +       spin_unlock(&vx_info_hash_lock);
17986 +       vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
17987 +       if (new)
17988 +               __dealloc_vx_info(new);
17989 +       return vxi;
17990 +}
17991 +
17992 +
17993 +/*     exported stuff                                          */
17994 +
17995 +
17996 +void unhash_vx_info(struct vx_info *vxi)
17997 +{
17998 +       __shutdown_vx_info(vxi);
17999 +       spin_lock(&vx_info_hash_lock);
18000 +       __unhash_vx_info(vxi);
18001 +       spin_unlock(&vx_info_hash_lock);
18002 +       __wakeup_vx_info(vxi);
18003 +}
18004 +
18005 +
18006 +/*     lookup_vx_info()
18007 +
18008 +       * search for a vx_info and get() it
18009 +       * negative id means current                             */
18010 +
18011 +struct vx_info *lookup_vx_info(int id)
18012 +{
18013 +       struct vx_info *vxi = NULL;
18014 +
18015 +       if (id < 0) {
18016 +               vxi = get_vx_info(current_vx_info());
18017 +       } else if (id > 1) {
18018 +               spin_lock(&vx_info_hash_lock);
18019 +               vxi = get_vx_info(__lookup_vx_info(id));
18020 +               spin_unlock(&vx_info_hash_lock);
18021 +       }
18022 +       return vxi;
18023 +}
18024 +
18025 +/*     xid_is_hashed()
18026 +
18027 +       * verify that xid is still hashed                       */
18028 +
18029 +int xid_is_hashed(xid_t xid)
18030 +{
18031 +       int hashed;
18032 +
18033 +       spin_lock(&vx_info_hash_lock);
18034 +       hashed = (__lookup_vx_info(xid) != NULL);
18035 +       spin_unlock(&vx_info_hash_lock);
18036 +       return hashed;
18037 +}
18038 +
18039 +#ifdef CONFIG_PROC_FS
18040 +
18041 +/*     get_xid_list()
18042 +
18043 +       * get a subset of hashed xids for proc
18044 +       * assumes size is at least one                          */
18045 +
18046 +int get_xid_list(int index, unsigned int *xids, int size)
18047 +{
18048 +       int hindex, nr_xids = 0;
18049 +
18050 +       /* only show current and children */
18051 +       if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18052 +               if (index > 0)
18053 +                       return 0;
18054 +               xids[nr_xids] = vx_current_xid();
18055 +               return 1;
18056 +       }
18057 +
18058 +       for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18059 +               struct hlist_head *head = &vx_info_hash[hindex];
18060 +               struct hlist_node *pos;
18061 +
18062 +               spin_lock(&vx_info_hash_lock);
18063 +               hlist_for_each(pos, head) {
18064 +                       struct vx_info *vxi;
18065 +
18066 +                       if (--index > 0)
18067 +                               continue;
18068 +
18069 +                       vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18070 +                       xids[nr_xids] = vxi->vx_id;
18071 +                       if (++nr_xids >= size) {
18072 +                               spin_unlock(&vx_info_hash_lock);
18073 +                               goto out;
18074 +                       }
18075 +               }
18076 +               /* keep the lock time short */
18077 +               spin_unlock(&vx_info_hash_lock);
18078 +       }
18079 +out:
18080 +       return nr_xids;
18081 +}
18082 +#endif
18083 +
18084 +#ifdef CONFIG_VSERVER_DEBUG
18085 +
18086 +void   dump_vx_info_inactive(int level)
18087 +{
18088 +       struct hlist_node *entry, *next;
18089 +
18090 +       hlist_for_each_safe(entry, next, &vx_info_inactive) {
18091 +               struct vx_info *vxi =
18092 +                       list_entry(entry, struct vx_info, vx_hlist);
18093 +
18094 +               dump_vx_info(vxi, level);
18095 +       }
18096 +}
18097 +
18098 +#endif
18099 +
18100 +#if 0
18101 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18102 +{
18103 +       struct user_struct *new_user, *old_user;
18104 +
18105 +       if (!p || !vxi)
18106 +               BUG();
18107 +
18108 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18109 +               return -EACCES;
18110 +
18111 +       new_user = alloc_uid(vxi->vx_id, p->uid);
18112 +       if (!new_user)
18113 +               return -ENOMEM;
18114 +
18115 +       old_user = p->user;
18116 +       if (new_user != old_user) {
18117 +               atomic_inc(&new_user->processes);
18118 +               atomic_dec(&old_user->processes);
18119 +               p->user = new_user;
18120 +       }
18121 +       free_uid(old_user);
18122 +       return 0;
18123 +}
18124 +#endif
18125 +
18126 +#if 0
18127 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18128 +{
18129 +       // p->cap_effective &= vxi->vx_cap_bset;
18130 +       p->cap_effective =
18131 +               cap_intersect(p->cap_effective, vxi->cap_bset);
18132 +       // p->cap_inheritable &= vxi->vx_cap_bset;
18133 +       p->cap_inheritable =
18134 +               cap_intersect(p->cap_inheritable, vxi->cap_bset);
18135 +       // p->cap_permitted &= vxi->vx_cap_bset;
18136 +       p->cap_permitted =
18137 +               cap_intersect(p->cap_permitted, vxi->cap_bset);
18138 +}
18139 +#endif
18140 +
18141 +
18142 +#include <linux/file.h>
18143 +#include <linux/fdtable.h>
18144 +
18145 +static int vx_openfd_task(struct task_struct *tsk)
18146 +{
18147 +       struct files_struct *files = tsk->files;
18148 +       struct fdtable *fdt;
18149 +       const unsigned long *bptr;
18150 +       int count, total;
18151 +
18152 +       /* no rcu_read_lock() because of spin_lock() */
18153 +       spin_lock(&files->file_lock);
18154 +       fdt = files_fdtable(files);
18155 +       bptr = fdt->open_fds->fds_bits;
18156 +       count = fdt->max_fds / (sizeof(unsigned long) * 8);
18157 +       for (total = 0; count > 0; count--) {
18158 +               if (*bptr)
18159 +                       total += hweight_long(*bptr);
18160 +               bptr++;
18161 +       }
18162 +       spin_unlock(&files->file_lock);
18163 +       return total;
18164 +}
18165 +
18166 +
18167 +/*     for *space compatibility */
18168 +
18169 +asmlinkage long sys_unshare(unsigned long);
18170 +
18171 +/*
18172 + *     migrate task to new context
18173 + *     gets vxi, puts old_vxi on change
18174 + *     optionally unshares namespaces (hack)
18175 + */
18176 +
18177 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18178 +{
18179 +       struct vx_info *old_vxi;
18180 +       int ret = 0;
18181 +
18182 +       if (!p || !vxi)
18183 +               BUG();
18184 +
18185 +       vxdprintk(VXD_CBIT(xid, 5),
18186 +               "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18187 +               vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18188 +
18189 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18190 +               !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18191 +               return -EACCES;
18192 +
18193 +       if (vx_info_state(vxi, VXS_SHUTDOWN))
18194 +               return -EFAULT;
18195 +
18196 +       old_vxi = task_get_vx_info(p);
18197 +       if (old_vxi == vxi)
18198 +               goto out;
18199 +
18200 +//     if (!(ret = vx_migrate_user(p, vxi))) {
18201 +       {
18202 +               int openfd;
18203 +
18204 +               task_lock(p);
18205 +               openfd = vx_openfd_task(p);
18206 +
18207 +               if (old_vxi) {
18208 +                       atomic_dec(&old_vxi->cvirt.nr_threads);
18209 +                       atomic_dec(&old_vxi->cvirt.nr_running);
18210 +                       __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18211 +                       /* FIXME: what about the struct files here? */
18212 +                       __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18213 +                       /* account for the executable */
18214 +                       __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18215 +               }
18216 +               atomic_inc(&vxi->cvirt.nr_threads);
18217 +               atomic_inc(&vxi->cvirt.nr_running);
18218 +               __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18219 +               /* FIXME: what about the struct files here? */
18220 +               __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18221 +               /* account for the executable */
18222 +               __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18223 +
18224 +               if (old_vxi) {
18225 +                       release_vx_info(old_vxi, p);
18226 +                       clr_vx_info(&p->vx_info);
18227 +               }
18228 +               claim_vx_info(vxi, p);
18229 +               set_vx_info(&p->vx_info, vxi);
18230 +               p->xid = vxi->vx_id;
18231 +
18232 +               vxdprintk(VXD_CBIT(xid, 5),
18233 +                       "moved task %p into vxi:%p[#%d]",
18234 +                       p, vxi, vxi->vx_id);
18235 +
18236 +               // vx_mask_cap_bset(vxi, p);
18237 +               task_unlock(p);
18238 +
18239 +               /* hack for *spaces to provide compatibility */
18240 +               if (unshare) {
18241 +                       struct nsproxy *old_nsp, *new_nsp;
18242 +
18243 +                       ret = unshare_nsproxy_namespaces(
18244 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18245 +                               &new_nsp, NULL);
18246 +                       if (ret)
18247 +                               goto out;
18248 +
18249 +                       old_nsp = xchg(&p->nsproxy, new_nsp);
18250 +                       vx_set_space(vxi,
18251 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18252 +                       put_nsproxy(old_nsp);
18253 +               }
18254 +       }
18255 +out:
18256 +       put_vx_info(old_vxi);
18257 +       return ret;
18258 +}
18259 +
18260 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18261 +{
18262 +       struct task_struct *old_reaper;
18263 +
18264 +       if (!vxi)
18265 +               return -EINVAL;
18266 +
18267 +       vxdprintk(VXD_CBIT(xid, 6),
18268 +               "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18269 +               vxi, vxi->vx_id, p, p->xid, p->pid);
18270 +
18271 +       old_reaper = vxi->vx_reaper;
18272 +       if (old_reaper == p)
18273 +               return 0;
18274 +
18275 +       /* set new child reaper */
18276 +       get_task_struct(p);
18277 +       vxi->vx_reaper = p;
18278 +       put_task_struct(old_reaper);
18279 +       return 0;
18280 +}
18281 +
18282 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18283 +{
18284 +       if (!vxi)
18285 +               return -EINVAL;
18286 +
18287 +       vxdprintk(VXD_CBIT(xid, 6),
18288 +               "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18289 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18290 +
18291 +       vxi->vx_flags &= ~VXF_STATE_INIT;
18292 +       // vxi->vx_initpid = p->tgid;
18293 +       vxi->vx_initpid = p->pid;
18294 +       return 0;
18295 +}
18296 +
18297 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18298 +{
18299 +       vxdprintk(VXD_CBIT(xid, 6),
18300 +               "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18301 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18302 +
18303 +       vxi->exit_code = code;
18304 +       vxi->vx_initpid = 0;
18305 +}
18306 +
18307 +
18308 +void vx_set_persistent(struct vx_info *vxi)
18309 +{
18310 +       vxdprintk(VXD_CBIT(xid, 6),
18311 +               "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18312 +
18313 +       get_vx_info(vxi);
18314 +       claim_vx_info(vxi, NULL);
18315 +}
18316 +
18317 +void vx_clear_persistent(struct vx_info *vxi)
18318 +{
18319 +       vxdprintk(VXD_CBIT(xid, 6),
18320 +               "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18321 +
18322 +       release_vx_info(vxi, NULL);
18323 +       put_vx_info(vxi);
18324 +}
18325 +
18326 +void vx_update_persistent(struct vx_info *vxi)
18327 +{
18328 +       if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18329 +               vx_set_persistent(vxi);
18330 +       else
18331 +               vx_clear_persistent(vxi);
18332 +}
18333 +
18334 +
18335 +/*     task must be current or locked          */
18336 +
18337 +void   exit_vx_info(struct task_struct *p, int code)
18338 +{
18339 +       struct vx_info *vxi = p->vx_info;
18340 +
18341 +       if (vxi) {
18342 +               atomic_dec(&vxi->cvirt.nr_threads);
18343 +               vx_nproc_dec(p);
18344 +
18345 +               vxi->exit_code = code;
18346 +               release_vx_info(vxi, p);
18347 +       }
18348 +}
18349 +
18350 +void   exit_vx_info_early(struct task_struct *p, int code)
18351 +{
18352 +       struct vx_info *vxi = p->vx_info;
18353 +
18354 +       if (vxi) {
18355 +               if (vxi->vx_initpid == p->pid)
18356 +                       vx_exit_init(vxi, p, code);
18357 +               if (vxi->vx_reaper == p)
18358 +                       vx_set_reaper(vxi, init_pid_ns.child_reaper);
18359 +       }
18360 +}
18361 +
18362 +
18363 +/* vserver syscall commands below here */
18364 +
18365 +/* taks xid and vx_info functions */
18366 +
18367 +#include <asm/uaccess.h>
18368 +
18369 +
18370 +int vc_task_xid(uint32_t id)
18371 +{
18372 +       xid_t xid;
18373 +
18374 +       if (id) {
18375 +               struct task_struct *tsk;
18376 +
18377 +               read_lock(&tasklist_lock);
18378 +               tsk = find_task_by_real_pid(id);
18379 +               xid = (tsk) ? tsk->xid : -ESRCH;
18380 +               read_unlock(&tasklist_lock);
18381 +       } else
18382 +               xid = vx_current_xid();
18383 +       return xid;
18384 +}
18385 +
18386 +
18387 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18388 +{
18389 +       struct vcmd_vx_info_v0 vc_data;
18390 +
18391 +       vc_data.xid = vxi->vx_id;
18392 +       vc_data.initpid = vxi->vx_initpid;
18393 +
18394 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18395 +               return -EFAULT;
18396 +       return 0;
18397 +}
18398 +
18399 +
18400 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18401 +{
18402 +       struct vcmd_ctx_stat_v0 vc_data;
18403 +
18404 +       vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18405 +       vc_data.tasks = atomic_read(&vxi->vx_tasks);
18406 +
18407 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18408 +               return -EFAULT;
18409 +       return 0;
18410 +}
18411 +
18412 +
18413 +/* context functions */
18414 +
18415 +int vc_ctx_create(uint32_t xid, void __user *data)
18416 +{
18417 +       struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18418 +       struct vx_info *new_vxi;
18419 +       int ret;
18420 +
18421 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18422 +               return -EFAULT;
18423 +
18424 +       if ((xid > MAX_S_CONTEXT) || (xid < 2))
18425 +               return -EINVAL;
18426 +
18427 +       new_vxi = __create_vx_info(xid);
18428 +       if (IS_ERR(new_vxi))
18429 +               return PTR_ERR(new_vxi);
18430 +
18431 +       /* initial flags */
18432 +       new_vxi->vx_flags = vc_data.flagword;
18433 +
18434 +       ret = -ENOEXEC;
18435 +       if (vs_state_change(new_vxi, VSC_STARTUP))
18436 +               goto out;
18437 +
18438 +       ret = vx_migrate_task(current, new_vxi, (!data));
18439 +       if (ret)
18440 +               goto out;
18441 +
18442 +       /* return context id on success */
18443 +       ret = new_vxi->vx_id;
18444 +
18445 +       /* get a reference for persistent contexts */
18446 +       if ((vc_data.flagword & VXF_PERSISTENT))
18447 +               vx_set_persistent(new_vxi);
18448 +out:
18449 +       release_vx_info(new_vxi, NULL);
18450 +       put_vx_info(new_vxi);
18451 +       return ret;
18452 +}
18453 +
18454 +
18455 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18456 +{
18457 +       struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18458 +       int ret;
18459 +
18460 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18461 +               return -EFAULT;
18462 +
18463 +       ret = vx_migrate_task(current, vxi, 0);
18464 +       if (ret)
18465 +               return ret;
18466 +       if (vc_data.flagword & VXM_SET_INIT)
18467 +               ret = vx_set_init(vxi, current);
18468 +       if (ret)
18469 +               return ret;
18470 +       if (vc_data.flagword & VXM_SET_REAPER)
18471 +               ret = vx_set_reaper(vxi, current);
18472 +       return ret;
18473 +}
18474 +
18475 +
18476 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18477 +{
18478 +       struct vcmd_ctx_flags_v0 vc_data;
18479 +
18480 +       vc_data.flagword = vxi->vx_flags;
18481 +
18482 +       /* special STATE flag handling */
18483 +       vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18484 +
18485 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18486 +               return -EFAULT;
18487 +       return 0;
18488 +}
18489 +
18490 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18491 +{
18492 +       struct vcmd_ctx_flags_v0 vc_data;
18493 +       uint64_t mask, trigger;
18494 +
18495 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18496 +               return -EFAULT;
18497 +
18498 +       /* special STATE flag handling */
18499 +       mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18500 +       trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18501 +
18502 +       if (vxi == current_vx_info()) {
18503 +               /* if (trigger & VXF_STATE_SETUP)
18504 +                       vx_mask_cap_bset(vxi, current); */
18505 +               if (trigger & VXF_STATE_INIT) {
18506 +                       int ret;
18507 +
18508 +                       ret = vx_set_init(vxi, current);
18509 +                       if (ret)
18510 +                               return ret;
18511 +                       ret = vx_set_reaper(vxi, current);
18512 +                       if (ret)
18513 +                               return ret;
18514 +               }
18515 +       }
18516 +
18517 +       vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18518 +               vc_data.flagword, mask);
18519 +       if (trigger & VXF_PERSISTENT)
18520 +               vx_update_persistent(vxi);
18521 +
18522 +       return 0;
18523 +}
18524 +
18525 +
18526 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18527 +{
18528 +       uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18529 +
18530 +       // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18531 +       return v;
18532 +}
18533 +
18534 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18535 +{
18536 +       kernel_cap_t c = __cap_empty_set;
18537 +
18538 +       c.cap[0] = v & 0xFFFFFFFF;
18539 +       c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18540 +
18541 +       // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18542 +       return c;
18543 +}
18544 +
18545 +
18546 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18547 +{
18548 +       if (bcaps)
18549 +               *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18550 +       if (ccaps)
18551 +               *ccaps = vxi->vx_ccaps;
18552 +
18553 +       return 0;
18554 +}
18555 +
18556 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18557 +{
18558 +       struct vcmd_ctx_caps_v1 vc_data;
18559 +       int ret;
18560 +
18561 +       ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18562 +       if (ret)
18563 +               return ret;
18564 +       vc_data.cmask = ~0ULL;
18565 +
18566 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18567 +               return -EFAULT;
18568 +       return 0;
18569 +}
18570 +
18571 +static int do_set_caps(struct vx_info *vxi,
18572 +       uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18573 +{
18574 +       uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18575 +
18576 +#if 0
18577 +       printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18578 +               bcaps, bmask, ccaps, cmask);
18579 +#endif
18580 +       vxi->vx_bcaps = cap_t_from_caps(
18581 +               vs_mask_flags(bcold, bcaps, bmask));
18582 +       vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18583 +
18584 +       return 0;
18585 +}
18586 +
18587 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18588 +{
18589 +       struct vcmd_ctx_caps_v1 vc_data;
18590 +
18591 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18592 +               return -EFAULT;
18593 +
18594 +       return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18595 +}
18596 +
18597 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18598 +{
18599 +       struct vcmd_bcaps vc_data;
18600 +       int ret;
18601 +
18602 +       ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18603 +       if (ret)
18604 +               return ret;
18605 +       vc_data.bmask = ~0ULL;
18606 +
18607 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18608 +               return -EFAULT;
18609 +       return 0;
18610 +}
18611 +
18612 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18613 +{
18614 +       struct vcmd_bcaps vc_data;
18615 +
18616 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18617 +               return -EFAULT;
18618 +
18619 +       return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18620 +}
18621 +
18622 +
18623 +int vc_get_umask(struct vx_info *vxi, void __user *data)
18624 +{
18625 +       struct vcmd_umask vc_data;
18626 +
18627 +       vc_data.umask = vxi->vx_umask;
18628 +       vc_data.mask = ~0ULL;
18629 +
18630 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18631 +               return -EFAULT;
18632 +       return 0;
18633 +}
18634 +
18635 +int vc_set_umask(struct vx_info *vxi, void __user *data)
18636 +{
18637 +       struct vcmd_umask vc_data;
18638 +
18639 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18640 +               return -EFAULT;
18641 +
18642 +       vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
18643 +               vc_data.umask, vc_data.mask);
18644 +       return 0;
18645 +}
18646 +
18647 +
18648 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18649 +{
18650 +       struct vcmd_badness_v0 vc_data;
18651 +
18652 +       vc_data.bias = vxi->vx_badness_bias;
18653 +
18654 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18655 +               return -EFAULT;
18656 +       return 0;
18657 +}
18658 +
18659 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18660 +{
18661 +       struct vcmd_badness_v0 vc_data;
18662 +
18663 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18664 +               return -EFAULT;
18665 +
18666 +       vxi->vx_badness_bias = vc_data.bias;
18667 +       return 0;
18668 +}
18669 +
18670 +#include <linux/module.h>
18671 +
18672 +EXPORT_SYMBOL_GPL(free_vx_info);
18673 +
18674 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cvirt.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt.c
18675 --- linux-2.6.35/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18676 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt.c   2010-08-02 17:05:06.000000000 +0200
18677 @@ -0,0 +1,304 @@
18678 +/*
18679 + *  linux/kernel/vserver/cvirt.c
18680 + *
18681 + *  Virtual Server: Context Virtualization
18682 + *
18683 + *  Copyright (C) 2004-2007  Herbert Pötzl
18684 + *
18685 + *  V0.01  broken out from limit.c
18686 + *  V0.02  added utsname stuff
18687 + *  V0.03  changed vcmds to vxi arg
18688 + *
18689 + */
18690 +
18691 +#include <linux/types.h>
18692 +#include <linux/utsname.h>
18693 +#include <linux/vs_cvirt.h>
18694 +#include <linux/vserver/switch.h>
18695 +#include <linux/vserver/cvirt_cmd.h>
18696 +
18697 +#include <asm/uaccess.h>
18698 +
18699 +
18700 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18701 +{
18702 +       struct vx_info *vxi = current_vx_info();
18703 +
18704 +       set_normalized_timespec(uptime,
18705 +               uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18706 +               uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18707 +       if (!idle)
18708 +               return;
18709 +       set_normalized_timespec(idle,
18710 +               idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18711 +               idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18712 +       return;
18713 +}
18714 +
18715 +uint64_t vx_idle_jiffies(void)
18716 +{
18717 +       return init_task.utime + init_task.stime;
18718 +}
18719 +
18720 +
18721 +
18722 +static inline uint32_t __update_loadavg(uint32_t load,
18723 +       int wsize, int delta, int n)
18724 +{
18725 +       unsigned long long calc, prev;
18726 +
18727 +       /* just set it to n */
18728 +       if (unlikely(delta >= wsize))
18729 +               return (n << FSHIFT);
18730 +
18731 +       calc = delta * n;
18732 +       calc <<= FSHIFT;
18733 +       prev = (wsize - delta);
18734 +       prev *= load;
18735 +       calc += prev;
18736 +       do_div(calc, wsize);
18737 +       return calc;
18738 +}
18739 +
18740 +
18741 +void vx_update_load(struct vx_info *vxi)
18742 +{
18743 +       uint32_t now, last, delta;
18744 +       unsigned int nr_running, nr_uninterruptible;
18745 +       unsigned int total;
18746 +       unsigned long flags;
18747 +
18748 +       spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18749 +
18750 +       now = jiffies;
18751 +       last = vxi->cvirt.load_last;
18752 +       delta = now - last;
18753 +
18754 +       if (delta < 5*HZ)
18755 +               goto out;
18756 +
18757 +       nr_running = atomic_read(&vxi->cvirt.nr_running);
18758 +       nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18759 +       total = nr_running + nr_uninterruptible;
18760 +
18761 +       vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18762 +               60*HZ, delta, total);
18763 +       vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18764 +               5*60*HZ, delta, total);
18765 +       vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18766 +               15*60*HZ, delta, total);
18767 +
18768 +       vxi->cvirt.load_last = now;
18769 +out:
18770 +       atomic_inc(&vxi->cvirt.load_updates);
18771 +       spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18772 +}
18773 +
18774 +
18775 +/*
18776 + * Commands to do_syslog:
18777 + *
18778 + *      0 -- Close the log.  Currently a NOP.
18779 + *      1 -- Open the log. Currently a NOP.
18780 + *      2 -- Read from the log.
18781 + *      3 -- Read all messages remaining in the ring buffer.
18782 + *      4 -- Read and clear all messages remaining in the ring buffer
18783 + *      5 -- Clear ring buffer.
18784 + *      6 -- Disable printk's to console
18785 + *      7 -- Enable printk's to console
18786 + *      8 -- Set level of messages printed to console
18787 + *      9 -- Return number of unread characters in the log buffer
18788 + *     10 -- Return size of the log buffer
18789 + */
18790 +int vx_do_syslog(int type, char __user *buf, int len)
18791 +{
18792 +       int error = 0;
18793 +       int do_clear = 0;
18794 +       struct vx_info *vxi = current_vx_info();
18795 +       struct _vx_syslog *log;
18796 +
18797 +       if (!vxi)
18798 +               return -EINVAL;
18799 +       log = &vxi->cvirt.syslog;
18800 +
18801 +       switch (type) {
18802 +       case 0:         /* Close log */
18803 +       case 1:         /* Open log */
18804 +               break;
18805 +       case 2:         /* Read from log */
18806 +               error = wait_event_interruptible(log->log_wait,
18807 +                       (log->log_start - log->log_end));
18808 +               if (error)
18809 +                       break;
18810 +               spin_lock_irq(&log->logbuf_lock);
18811 +               spin_unlock_irq(&log->logbuf_lock);
18812 +               break;
18813 +       case 4:         /* Read/clear last kernel messages */
18814 +               do_clear = 1;
18815 +               /* fall through */
18816 +       case 3:         /* Read last kernel messages */
18817 +               return 0;
18818 +
18819 +       case 5:         /* Clear ring buffer */
18820 +               return 0;
18821 +
18822 +       case 6:         /* Disable logging to console */
18823 +       case 7:         /* Enable logging to console */
18824 +       case 8:         /* Set level of messages printed to console */
18825 +               break;
18826 +
18827 +       case 9:         /* Number of chars in the log buffer */
18828 +               return 0;
18829 +       case 10:        /* Size of the log buffer */
18830 +               return 0;
18831 +       default:
18832 +               error = -EINVAL;
18833 +               break;
18834 +       }
18835 +       return error;
18836 +}
18837 +
18838 +
18839 +/* virtual host info names */
18840 +
18841 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18842 +{
18843 +       struct nsproxy *nsproxy;
18844 +       struct uts_namespace *uts;
18845 +
18846 +       if (id == VHIN_CONTEXT)
18847 +               return vxi->vx_name;
18848 +
18849 +       nsproxy = vxi->vx_nsproxy[0];
18850 +       if (!nsproxy)
18851 +               return NULL;
18852 +
18853 +       uts = nsproxy->uts_ns;
18854 +       if (!uts)
18855 +               return NULL;
18856 +
18857 +       switch (id) {
18858 +       case VHIN_SYSNAME:
18859 +               return uts->name.sysname;
18860 +       case VHIN_NODENAME:
18861 +               return uts->name.nodename;
18862 +       case VHIN_RELEASE:
18863 +               return uts->name.release;
18864 +       case VHIN_VERSION:
18865 +               return uts->name.version;
18866 +       case VHIN_MACHINE:
18867 +               return uts->name.machine;
18868 +       case VHIN_DOMAINNAME:
18869 +               return uts->name.domainname;
18870 +       default:
18871 +               return NULL;
18872 +       }
18873 +       return NULL;
18874 +}
18875 +
18876 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18877 +{
18878 +       struct vcmd_vhi_name_v0 vc_data;
18879 +       char *name;
18880 +
18881 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18882 +               return -EFAULT;
18883 +
18884 +       name = vx_vhi_name(vxi, vc_data.field);
18885 +       if (!name)
18886 +               return -EINVAL;
18887 +
18888 +       memcpy(name, vc_data.name, 65);
18889 +       return 0;
18890 +}
18891 +
18892 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18893 +{
18894 +       struct vcmd_vhi_name_v0 vc_data;
18895 +       char *name;
18896 +
18897 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18898 +               return -EFAULT;
18899 +
18900 +       name = vx_vhi_name(vxi, vc_data.field);
18901 +       if (!name)
18902 +               return -EINVAL;
18903 +
18904 +       memcpy(vc_data.name, name, 65);
18905 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18906 +               return -EFAULT;
18907 +       return 0;
18908 +}
18909 +
18910 +
18911 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18912 +{
18913 +       struct vcmd_virt_stat_v0 vc_data;
18914 +       struct _vx_cvirt *cvirt = &vxi->cvirt;
18915 +       struct timespec uptime;
18916 +
18917 +       do_posix_clock_monotonic_gettime(&uptime);
18918 +       set_normalized_timespec(&uptime,
18919 +               uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18920 +               uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18921 +
18922 +       vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18923 +       vc_data.uptime = timespec_to_ns(&uptime);
18924 +       vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18925 +       vc_data.nr_running = atomic_read(&cvirt->nr_running);
18926 +       vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18927 +       vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18928 +       vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18929 +       vc_data.load[0] = cvirt->load[0];
18930 +       vc_data.load[1] = cvirt->load[1];
18931 +       vc_data.load[2] = cvirt->load[2];
18932 +
18933 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18934 +               return -EFAULT;
18935 +       return 0;
18936 +}
18937 +
18938 +
18939 +#ifdef CONFIG_VSERVER_VTIME
18940 +
18941 +/* virtualized time base */
18942 +
18943 +void vx_gettimeofday(struct timeval *tv)
18944 +{
18945 +       struct vx_info *vxi;
18946 +
18947 +       do_gettimeofday(tv);
18948 +       if (!vx_flags(VXF_VIRT_TIME, 0))
18949 +               return;
18950 +
18951 +       vxi = current_vx_info();
18952 +       tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
18953 +       tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
18954 +
18955 +       if (tv->tv_usec >= USEC_PER_SEC) {
18956 +               tv->tv_sec++;
18957 +               tv->tv_usec -= USEC_PER_SEC;
18958 +       } else if (tv->tv_usec < 0) {
18959 +               tv->tv_sec--;
18960 +               tv->tv_usec += USEC_PER_SEC;
18961 +       }
18962 +}
18963 +
18964 +int vx_settimeofday(struct timespec *ts)
18965 +{
18966 +       struct timeval tv;
18967 +       struct vx_info *vxi;
18968 +
18969 +       if (!vx_flags(VXF_VIRT_TIME, 0))
18970 +               return do_settimeofday(ts);
18971 +
18972 +       do_gettimeofday(&tv);
18973 +       vxi = current_vx_info();
18974 +       vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
18975 +       vxi->cvirt.bias_tv.tv_usec =
18976 +               (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
18977 +       return 0;
18978 +}
18979 +
18980 +#endif
18981 +
18982 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cvirt_init.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt_init.h
18983 --- linux-2.6.35/kernel/vserver/cvirt_init.h    1970-01-01 01:00:00.000000000 +0100
18984 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt_init.h      2010-08-02 17:05:06.000000000 +0200
18985 @@ -0,0 +1,69 @@
18986 +
18987 +
18988 +extern uint64_t vx_idle_jiffies(void);
18989 +
18990 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
18991 +{
18992 +       uint64_t idle_jiffies = vx_idle_jiffies();
18993 +       uint64_t nsuptime;
18994 +
18995 +       do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
18996 +       nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
18997 +               * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
18998 +       cvirt->bias_clock = nsec_to_clock_t(nsuptime);
18999 +       cvirt->bias_tv.tv_sec = 0;
19000 +       cvirt->bias_tv.tv_usec = 0;
19001 +
19002 +       jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19003 +       atomic_set(&cvirt->nr_threads, 0);
19004 +       atomic_set(&cvirt->nr_running, 0);
19005 +       atomic_set(&cvirt->nr_uninterruptible, 0);
19006 +       atomic_set(&cvirt->nr_onhold, 0);
19007 +
19008 +       spin_lock_init(&cvirt->load_lock);
19009 +       cvirt->load_last = jiffies;
19010 +       atomic_set(&cvirt->load_updates, 0);
19011 +       cvirt->load[0] = 0;
19012 +       cvirt->load[1] = 0;
19013 +       cvirt->load[2] = 0;
19014 +       atomic_set(&cvirt->total_forks, 0);
19015 +
19016 +       spin_lock_init(&cvirt->syslog.logbuf_lock);
19017 +       init_waitqueue_head(&cvirt->syslog.log_wait);
19018 +       cvirt->syslog.log_start = 0;
19019 +       cvirt->syslog.log_end = 0;
19020 +       cvirt->syslog.con_start = 0;
19021 +       cvirt->syslog.logged_chars = 0;
19022 +}
19023 +
19024 +static inline
19025 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19026 +{
19027 +       // cvirt_pc->cpustat = { 0 };
19028 +}
19029 +
19030 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19031 +{
19032 +       int value;
19033 +
19034 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19035 +               "!!! cvirt: %p[nr_threads] = %d on exit.",
19036 +               cvirt, value);
19037 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19038 +               "!!! cvirt: %p[nr_running] = %d on exit.",
19039 +               cvirt, value);
19040 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19041 +               "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19042 +               cvirt, value);
19043 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19044 +               "!!! cvirt: %p[nr_onhold] = %d on exit.",
19045 +               cvirt, value);
19046 +       return;
19047 +}
19048 +
19049 +static inline
19050 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19051 +{
19052 +       return;
19053 +}
19054 +
19055 diff -NurpP --minimal linux-2.6.35/kernel/vserver/cvirt_proc.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt_proc.h
19056 --- linux-2.6.35/kernel/vserver/cvirt_proc.h    1970-01-01 01:00:00.000000000 +0100
19057 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/cvirt_proc.h      2010-08-02 17:05:06.000000000 +0200
19058 @@ -0,0 +1,135 @@
19059 +#ifndef _VX_CVIRT_PROC_H
19060 +#define _VX_CVIRT_PROC_H
19061 +
19062 +#include <linux/nsproxy.h>
19063 +#include <linux/mnt_namespace.h>
19064 +#include <linux/ipc_namespace.h>
19065 +#include <linux/utsname.h>
19066 +#include <linux/ipc.h>
19067 +
19068 +
19069 +static inline
19070 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19071 +{
19072 +       struct mnt_namespace *ns;
19073 +       struct uts_namespace *uts;
19074 +       struct ipc_namespace *ipc;
19075 +       struct path path;
19076 +       char *pstr, *root;
19077 +       int length = 0;
19078 +
19079 +       if (!nsproxy)
19080 +               goto out;
19081 +
19082 +       length += sprintf(buffer + length,
19083 +               "NSProxy:\t%p [%p,%p,%p]\n",
19084 +               nsproxy, nsproxy->mnt_ns,
19085 +               nsproxy->uts_ns, nsproxy->ipc_ns);
19086 +
19087 +       ns = nsproxy->mnt_ns;
19088 +       if (!ns)
19089 +               goto skip_ns;
19090 +
19091 +       pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19092 +       if (!pstr)
19093 +               goto skip_ns;
19094 +
19095 +       path.mnt = ns->root;
19096 +       path.dentry = ns->root->mnt_root;
19097 +       root = d_path(&path, pstr, PATH_MAX - 2);
19098 +       length += sprintf(buffer + length,
19099 +               "Namespace:\t%p [#%u]\n"
19100 +               "RootPath:\t%s\n",
19101 +               ns, atomic_read(&ns->count),
19102 +               root);
19103 +       kfree(pstr);
19104 +skip_ns:
19105 +
19106 +       uts = nsproxy->uts_ns;
19107 +       if (!uts)
19108 +               goto skip_uts;
19109 +
19110 +       length += sprintf(buffer + length,
19111 +               "SysName:\t%.*s\n"
19112 +               "NodeName:\t%.*s\n"
19113 +               "Release:\t%.*s\n"
19114 +               "Version:\t%.*s\n"
19115 +               "Machine:\t%.*s\n"
19116 +               "DomainName:\t%.*s\n",
19117 +               __NEW_UTS_LEN, uts->name.sysname,
19118 +               __NEW_UTS_LEN, uts->name.nodename,
19119 +               __NEW_UTS_LEN, uts->name.release,
19120 +               __NEW_UTS_LEN, uts->name.version,
19121 +               __NEW_UTS_LEN, uts->name.machine,
19122 +               __NEW_UTS_LEN, uts->name.domainname);
19123 +skip_uts:
19124 +
19125 +       ipc = nsproxy->ipc_ns;
19126 +       if (!ipc)
19127 +               goto skip_ipc;
19128 +
19129 +       length += sprintf(buffer + length,
19130 +               "SEMS:\t\t%d %d %d %d  %d\n"
19131 +               "MSG:\t\t%d %d %d\n"
19132 +               "SHM:\t\t%lu %lu  %d %d\n",
19133 +               ipc->sem_ctls[0], ipc->sem_ctls[1],
19134 +               ipc->sem_ctls[2], ipc->sem_ctls[3],
19135 +               ipc->used_sems,
19136 +               ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19137 +               (unsigned long)ipc->shm_ctlmax,
19138 +               (unsigned long)ipc->shm_ctlall,
19139 +               ipc->shm_ctlmni, ipc->shm_tot);
19140 +skip_ipc:
19141 +out:
19142 +       return length;
19143 +}
19144 +
19145 +
19146 +#include <linux/sched.h>
19147 +
19148 +#define LOAD_INT(x) ((x) >> FSHIFT)
19149 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19150 +
19151 +static inline
19152 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19153 +{
19154 +       int length = 0;
19155 +       int a, b, c;
19156 +
19157 +       length += sprintf(buffer + length,
19158 +               "BiasUptime:\t%lu.%02lu\n",
19159 +               (unsigned long)cvirt->bias_uptime.tv_sec,
19160 +               (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19161 +
19162 +       a = cvirt->load[0] + (FIXED_1 / 200);
19163 +       b = cvirt->load[1] + (FIXED_1 / 200);
19164 +       c = cvirt->load[2] + (FIXED_1 / 200);
19165 +       length += sprintf(buffer + length,
19166 +               "nr_threads:\t%d\n"
19167 +               "nr_running:\t%d\n"
19168 +               "nr_unintr:\t%d\n"
19169 +               "nr_onhold:\t%d\n"
19170 +               "load_updates:\t%d\n"
19171 +               "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19172 +               "total_forks:\t%d\n",
19173 +               atomic_read(&cvirt->nr_threads),
19174 +               atomic_read(&cvirt->nr_running),
19175 +               atomic_read(&cvirt->nr_uninterruptible),
19176 +               atomic_read(&cvirt->nr_onhold),
19177 +               atomic_read(&cvirt->load_updates),
19178 +               LOAD_INT(a), LOAD_FRAC(a),
19179 +               LOAD_INT(b), LOAD_FRAC(b),
19180 +               LOAD_INT(c), LOAD_FRAC(c),
19181 +               atomic_read(&cvirt->total_forks));
19182 +       return length;
19183 +}
19184 +
19185 +static inline
19186 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19187 +       char *buffer, int cpu)
19188 +{
19189 +       int length = 0;
19190 +       return length;
19191 +}
19192 +
19193 +#endif /* _VX_CVIRT_PROC_H */
19194 diff -NurpP --minimal linux-2.6.35/kernel/vserver/debug.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/debug.c
19195 --- linux-2.6.35/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
19196 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/debug.c   2010-08-02 17:05:06.000000000 +0200
19197 @@ -0,0 +1,32 @@
19198 +/*
19199 + *  kernel/vserver/debug.c
19200 + *
19201 + *  Copyright (C) 2005-2007 Herbert Pötzl
19202 + *
19203 + *  V0.01  vx_info dump support
19204 + *
19205 + */
19206 +
19207 +#include <linux/module.h>
19208 +
19209 +#include <linux/vserver/context.h>
19210 +
19211 +
19212 +void   dump_vx_info(struct vx_info *vxi, int level)
19213 +{
19214 +       printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19215 +               atomic_read(&vxi->vx_usecnt),
19216 +               atomic_read(&vxi->vx_tasks),
19217 +               vxi->vx_state);
19218 +       if (level > 0) {
19219 +               __dump_vx_limit(&vxi->limit);
19220 +               __dump_vx_sched(&vxi->sched);
19221 +               __dump_vx_cvirt(&vxi->cvirt);
19222 +               __dump_vx_cacct(&vxi->cacct);
19223 +       }
19224 +       printk("---\n");
19225 +}
19226 +
19227 +
19228 +EXPORT_SYMBOL_GPL(dump_vx_info);
19229 +
19230 diff -NurpP --minimal linux-2.6.35/kernel/vserver/device.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/device.c
19231 --- linux-2.6.35/kernel/vserver/device.c        1970-01-01 01:00:00.000000000 +0100
19232 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/device.c  2010-08-02 17:05:06.000000000 +0200
19233 @@ -0,0 +1,443 @@
19234 +/*
19235 + *  linux/kernel/vserver/device.c
19236 + *
19237 + *  Linux-VServer: Device Support
19238 + *
19239 + *  Copyright (C) 2006  Herbert Pötzl
19240 + *  Copyright (C) 2007  Daniel Hokka Zakrisson
19241 + *
19242 + *  V0.01  device mapping basics
19243 + *  V0.02  added defaults
19244 + *
19245 + */
19246 +
19247 +#include <linux/slab.h>
19248 +#include <linux/rcupdate.h>
19249 +#include <linux/fs.h>
19250 +#include <linux/namei.h>
19251 +#include <linux/hash.h>
19252 +
19253 +#include <asm/errno.h>
19254 +#include <asm/uaccess.h>
19255 +#include <linux/vserver/base.h>
19256 +#include <linux/vserver/debug.h>
19257 +#include <linux/vserver/context.h>
19258 +#include <linux/vserver/device.h>
19259 +#include <linux/vserver/device_cmd.h>
19260 +
19261 +
19262 +#define DMAP_HASH_BITS 4
19263 +
19264 +
19265 +struct vs_mapping {
19266 +       union {
19267 +               struct hlist_node hlist;
19268 +               struct list_head list;
19269 +       } u;
19270 +#define dm_hlist       u.hlist
19271 +#define dm_list                u.list
19272 +       xid_t xid;
19273 +       dev_t device;
19274 +       struct vx_dmap_target target;
19275 +};
19276 +
19277 +
19278 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19279 +
19280 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
19281 +
19282 +static struct vx_dmap_target dmap_defaults[2] = {
19283 +       { .flags = DATTR_OPEN },
19284 +       { .flags = DATTR_OPEN },
19285 +};
19286 +
19287 +
19288 +struct kmem_cache *dmap_cachep __read_mostly;
19289 +
19290 +int __init dmap_cache_init(void)
19291 +{
19292 +       dmap_cachep = kmem_cache_create("dmap_cache",
19293 +               sizeof(struct vs_mapping), 0,
19294 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19295 +       return 0;
19296 +}
19297 +
19298 +__initcall(dmap_cache_init);
19299 +
19300 +
19301 +static inline unsigned int __hashval(dev_t dev, int bits)
19302 +{
19303 +       return hash_long((unsigned long)dev, bits);
19304 +}
19305 +
19306 +
19307 +/*     __hash_mapping()
19308 + *     add the mapping to the hash table
19309 + */
19310 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19311 +{
19312 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19313 +       struct hlist_head *head, *hash = dmap_main_hash;
19314 +       int device = vdm->device;
19315 +
19316 +       spin_lock(hash_lock);
19317 +       vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19318 +               vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19319 +
19320 +       head = &hash[__hashval(device, DMAP_HASH_BITS)];
19321 +       hlist_add_head(&vdm->dm_hlist, head);
19322 +       spin_unlock(hash_lock);
19323 +}
19324 +
19325 +
19326 +static inline int __mode_to_default(umode_t mode)
19327 +{
19328 +       switch (mode) {
19329 +       case S_IFBLK:
19330 +               return 0;
19331 +       case S_IFCHR:
19332 +               return 1;
19333 +       default:
19334 +               BUG();
19335 +       }
19336 +}
19337 +
19338 +
19339 +/*     __set_default()
19340 + *     set a default
19341 + */
19342 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19343 +       struct vx_dmap_target *vdmt)
19344 +{
19345 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19346 +       spin_lock(hash_lock);
19347 +
19348 +       if (vxi)
19349 +               vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19350 +       else
19351 +               dmap_defaults[__mode_to_default(mode)] = *vdmt;
19352 +
19353 +
19354 +       spin_unlock(hash_lock);
19355 +
19356 +       vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19357 +                 vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19358 +}
19359 +
19360 +
19361 +/*     __remove_default()
19362 + *     remove a default
19363 + */
19364 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19365 +{
19366 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19367 +       spin_lock(hash_lock);
19368 +
19369 +       if (vxi)
19370 +               vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19371 +       else    /* remove == reset */
19372 +               dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19373 +
19374 +       spin_unlock(hash_lock);
19375 +       return 0;
19376 +}
19377 +
19378 +
19379 +/*     __find_mapping()
19380 + *     find a mapping in the hash table
19381 + *
19382 + *     caller must hold hash_lock
19383 + */
19384 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19385 +       struct vs_mapping **local, struct vs_mapping **global)
19386 +{
19387 +       struct hlist_head *hash = dmap_main_hash;
19388 +       struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19389 +       struct hlist_node *pos;
19390 +       struct vs_mapping *vdm;
19391 +
19392 +       *local = NULL;
19393 +       if (global)
19394 +               *global = NULL;
19395 +
19396 +       hlist_for_each(pos, head) {
19397 +               vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19398 +
19399 +               if ((vdm->device == device) &&
19400 +                       !((vdm->target.flags ^ mode) & S_IFMT)) {
19401 +                       if (vdm->xid == xid) {
19402 +                               *local = vdm;
19403 +                               return 1;
19404 +                       } else if (global && vdm->xid == 0)
19405 +                               *global = vdm;
19406 +               }
19407 +       }
19408 +
19409 +       if (global && *global)
19410 +               return 0;
19411 +       else
19412 +               return -ENOENT;
19413 +}
19414 +
19415 +
19416 +/*     __lookup_mapping()
19417 + *     find a mapping and store the result in target and flags
19418 + */
19419 +static inline int __lookup_mapping(struct vx_info *vxi,
19420 +       dev_t device, dev_t *target, int *flags, umode_t mode)
19421 +{
19422 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19423 +       struct vs_mapping *vdm, *global;
19424 +       struct vx_dmap_target *vdmt;
19425 +       int ret = 0;
19426 +       xid_t xid = vxi->vx_id;
19427 +       int index;
19428 +
19429 +       spin_lock(hash_lock);
19430 +       if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19431 +               ret = 1;
19432 +               vdmt = &vdm->target;
19433 +               goto found;
19434 +       }
19435 +
19436 +       index = __mode_to_default(mode);
19437 +       if (vxi && vxi->dmap.targets[index].flags) {
19438 +               ret = 2;
19439 +               vdmt = &vxi->dmap.targets[index];
19440 +       } else if (global) {
19441 +               ret = 3;
19442 +               vdmt = &global->target;
19443 +               goto found;
19444 +       } else {
19445 +               ret = 4;
19446 +               vdmt = &dmap_defaults[index];
19447 +       }
19448 +
19449 +found:
19450 +       if (target && (vdmt->flags & DATTR_REMAP))
19451 +               *target = vdmt->target;
19452 +       else if (target)
19453 +               *target = device;
19454 +       if (flags)
19455 +               *flags = vdmt->flags;
19456 +
19457 +       spin_unlock(hash_lock);
19458 +
19459 +       return ret;
19460 +}
19461 +
19462 +
19463 +/*     __remove_mapping()
19464 + *     remove a mapping from the hash table
19465 + */
19466 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19467 +       umode_t mode)
19468 +{
19469 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19470 +       struct vs_mapping *vdm = NULL;
19471 +       int ret = 0;
19472 +
19473 +       spin_lock(hash_lock);
19474 +
19475 +       ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19476 +               NULL);
19477 +       vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19478 +               vxi, vxi ? vxi->vx_id : 0, device, mode);
19479 +       if (ret < 0)
19480 +               goto out;
19481 +       hlist_del(&vdm->dm_hlist);
19482 +
19483 +out:
19484 +       spin_unlock(hash_lock);
19485 +       if (vdm)
19486 +               kmem_cache_free(dmap_cachep, vdm);
19487 +       return ret;
19488 +}
19489 +
19490 +
19491 +
19492 +int vs_map_device(struct vx_info *vxi,
19493 +       dev_t device, dev_t *target, umode_t mode)
19494 +{
19495 +       int ret, flags = DATTR_MASK;
19496 +
19497 +       if (!vxi) {
19498 +               if (target)
19499 +                       *target = device;
19500 +               goto out;
19501 +       }
19502 +       ret = __lookup_mapping(vxi, device, target, &flags, mode);
19503 +       vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19504 +               device, target ? *target : 0, flags, mode, ret);
19505 +out:
19506 +       return (flags & DATTR_MASK);
19507 +}
19508 +
19509 +
19510 +
19511 +static int do_set_mapping(struct vx_info *vxi,
19512 +       dev_t device, dev_t target, int flags, umode_t mode)
19513 +{
19514 +       if (device) {
19515 +               struct vs_mapping *new;
19516 +
19517 +               new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19518 +               if (!new)
19519 +                       return -ENOMEM;
19520 +
19521 +               INIT_HLIST_NODE(&new->dm_hlist);
19522 +               new->device = device;
19523 +               new->target.target = target;
19524 +               new->target.flags = flags | mode;
19525 +               new->xid = (vxi ? vxi->vx_id : 0);
19526 +
19527 +               vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19528 +               __hash_mapping(vxi, new);
19529 +       } else {
19530 +               struct vx_dmap_target new = {
19531 +                       .target = target,
19532 +                       .flags = flags | mode,
19533 +               };
19534 +               __set_default(vxi, mode, &new);
19535 +       }
19536 +       return 0;
19537 +}
19538 +
19539 +
19540 +static int do_unset_mapping(struct vx_info *vxi,
19541 +       dev_t device, dev_t target, int flags, umode_t mode)
19542 +{
19543 +       int ret = -EINVAL;
19544 +
19545 +       if (device) {
19546 +               ret = __remove_mapping(vxi, device, mode);
19547 +               if (ret < 0)
19548 +                       goto out;
19549 +       } else {
19550 +               ret = __remove_default(vxi, mode);
19551 +               if (ret < 0)
19552 +                       goto out;
19553 +       }
19554 +
19555 +out:
19556 +       return ret;
19557 +}
19558 +
19559 +
19560 +static inline int __user_device(const char __user *name, dev_t *dev,
19561 +       umode_t *mode)
19562 +{
19563 +       struct nameidata nd;
19564 +       int ret;
19565 +
19566 +       if (!name) {
19567 +               *dev = 0;
19568 +               return 0;
19569 +       }
19570 +       ret = user_lpath(name, &nd.path);
19571 +       if (ret)
19572 +               return ret;
19573 +       if (nd.path.dentry->d_inode) {
19574 +               *dev = nd.path.dentry->d_inode->i_rdev;
19575 +               *mode = nd.path.dentry->d_inode->i_mode;
19576 +       }
19577 +       path_put(&nd.path);
19578 +       return 0;
19579 +}
19580 +
19581 +static inline int __mapping_mode(dev_t device, dev_t target,
19582 +       umode_t device_mode, umode_t target_mode, umode_t *mode)
19583 +{
19584 +       if (device)
19585 +               *mode = device_mode & S_IFMT;
19586 +       else if (target)
19587 +               *mode = target_mode & S_IFMT;
19588 +       else
19589 +               return -EINVAL;
19590 +
19591 +       /* if both given, device and target mode have to match */
19592 +       if (device && target &&
19593 +               ((device_mode ^ target_mode) & S_IFMT))
19594 +               return -EINVAL;
19595 +       return 0;
19596 +}
19597 +
19598 +
19599 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19600 +       const char __user *target_path, int flags, int set)
19601 +{
19602 +       dev_t device = ~0, target = ~0;
19603 +       umode_t device_mode = 0, target_mode = 0, mode;
19604 +       int ret;
19605 +
19606 +       ret = __user_device(device_path, &device, &device_mode);
19607 +       if (ret)
19608 +               return ret;
19609 +       ret = __user_device(target_path, &target, &target_mode);
19610 +       if (ret)
19611 +               return ret;
19612 +
19613 +       ret = __mapping_mode(device, target,
19614 +               device_mode, target_mode, &mode);
19615 +       if (ret)
19616 +               return ret;
19617 +
19618 +       if (set)
19619 +               return do_set_mapping(vxi, device, target,
19620 +                       flags, mode);
19621 +       else
19622 +               return do_unset_mapping(vxi, device, target,
19623 +                       flags, mode);
19624 +}
19625 +
19626 +
19627 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19628 +{
19629 +       struct vcmd_set_mapping_v0 vc_data;
19630 +
19631 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19632 +               return -EFAULT;
19633 +
19634 +       return do_mapping(vxi, vc_data.device, vc_data.target,
19635 +               vc_data.flags, 1);
19636 +}
19637 +
19638 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19639 +{
19640 +       struct vcmd_set_mapping_v0 vc_data;
19641 +
19642 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19643 +               return -EFAULT;
19644 +
19645 +       return do_mapping(vxi, vc_data.device, vc_data.target,
19646 +               vc_data.flags, 0);
19647 +}
19648 +
19649 +
19650 +#ifdef CONFIG_COMPAT
19651 +
19652 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19653 +{
19654 +       struct vcmd_set_mapping_v0_x32 vc_data;
19655 +
19656 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19657 +               return -EFAULT;
19658 +
19659 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19660 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19661 +}
19662 +
19663 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19664 +{
19665 +       struct vcmd_set_mapping_v0_x32 vc_data;
19666 +
19667 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19668 +               return -EFAULT;
19669 +
19670 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19671 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19672 +}
19673 +
19674 +#endif /* CONFIG_COMPAT */
19675 +
19676 +
19677 diff -NurpP --minimal linux-2.6.35/kernel/vserver/dlimit.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/dlimit.c
19678 --- linux-2.6.35/kernel/vserver/dlimit.c        1970-01-01 01:00:00.000000000 +0100
19679 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/dlimit.c  2010-08-02 17:05:06.000000000 +0200
19680 @@ -0,0 +1,531 @@
19681 +/*
19682 + *  linux/kernel/vserver/dlimit.c
19683 + *
19684 + *  Virtual Server: Context Disk Limits
19685 + *
19686 + *  Copyright (C) 2004-2009  Herbert Pötzl
19687 + *
19688 + *  V0.01  initial version
19689 + *  V0.02  compat32 splitup
19690 + *  V0.03  extended interface
19691 + *
19692 + */
19693 +
19694 +#include <linux/statfs.h>
19695 +#include <linux/sched.h>
19696 +#include <linux/namei.h>
19697 +#include <linux/vs_tag.h>
19698 +#include <linux/vs_dlimit.h>
19699 +#include <linux/vserver/dlimit_cmd.h>
19700 +#include <linux/slab.h>
19701 +// #include <linux/gfp.h>
19702 +
19703 +#include <asm/uaccess.h>
19704 +
19705 +/*     __alloc_dl_info()
19706 +
19707 +       * allocate an initialized dl_info struct
19708 +       * doesn't make it visible (hash)                        */
19709 +
19710 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19711 +{
19712 +       struct dl_info *new = NULL;
19713 +
19714 +       vxdprintk(VXD_CBIT(dlim, 5),
19715 +               "alloc_dl_info(%p,%d)*", sb, tag);
19716 +
19717 +       /* would this benefit from a slab cache? */
19718 +       new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19719 +       if (!new)
19720 +               return 0;
19721 +
19722 +       memset(new, 0, sizeof(struct dl_info));
19723 +       new->dl_tag = tag;
19724 +       new->dl_sb = sb;
19725 +       INIT_RCU_HEAD(&new->dl_rcu);
19726 +       INIT_HLIST_NODE(&new->dl_hlist);
19727 +       spin_lock_init(&new->dl_lock);
19728 +       atomic_set(&new->dl_refcnt, 0);
19729 +       atomic_set(&new->dl_usecnt, 0);
19730 +
19731 +       /* rest of init goes here */
19732 +
19733 +       vxdprintk(VXD_CBIT(dlim, 4),
19734 +               "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19735 +       return new;
19736 +}
19737 +
19738 +/*     __dealloc_dl_info()
19739 +
19740 +       * final disposal of dl_info                             */
19741 +
19742 +static void __dealloc_dl_info(struct dl_info *dli)
19743 +{
19744 +       vxdprintk(VXD_CBIT(dlim, 4),
19745 +               "dealloc_dl_info(%p)", dli);
19746 +
19747 +       dli->dl_hlist.next = LIST_POISON1;
19748 +       dli->dl_tag = -1;
19749 +       dli->dl_sb = 0;
19750 +
19751 +       BUG_ON(atomic_read(&dli->dl_usecnt));
19752 +       BUG_ON(atomic_read(&dli->dl_refcnt));
19753 +
19754 +       kfree(dli);
19755 +}
19756 +
19757 +
19758 +/*     hash table for dl_info hash */
19759 +
19760 +#define DL_HASH_SIZE   13
19761 +
19762 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19763 +
19764 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19765 +
19766 +
19767 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19768 +{
19769 +       return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19770 +}
19771 +
19772 +
19773 +
19774 +/*     __hash_dl_info()
19775 +
19776 +       * add the dli to the global hash table
19777 +       * requires the hash_lock to be held                     */
19778 +
19779 +static inline void __hash_dl_info(struct dl_info *dli)
19780 +{
19781 +       struct hlist_head *head;
19782 +
19783 +       vxdprintk(VXD_CBIT(dlim, 6),
19784 +               "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19785 +       get_dl_info(dli);
19786 +       head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19787 +       hlist_add_head_rcu(&dli->dl_hlist, head);
19788 +}
19789 +
19790 +/*     __unhash_dl_info()
19791 +
19792 +       * remove the dli from the global hash table
19793 +       * requires the hash_lock to be held                     */
19794 +
19795 +static inline void __unhash_dl_info(struct dl_info *dli)
19796 +{
19797 +       vxdprintk(VXD_CBIT(dlim, 6),
19798 +               "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19799 +       hlist_del_rcu(&dli->dl_hlist);
19800 +       put_dl_info(dli);
19801 +}
19802 +
19803 +
19804 +/*     __lookup_dl_info()
19805 +
19806 +       * requires the rcu_read_lock()
19807 +       * doesn't increment the dl_refcnt                       */
19808 +
19809 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19810 +{
19811 +       struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19812 +       struct hlist_node *pos;
19813 +       struct dl_info *dli;
19814 +
19815 +       hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19816 +
19817 +               if (dli->dl_tag == tag && dli->dl_sb == sb) {
19818 +                       return dli;
19819 +               }
19820 +       }
19821 +       return NULL;
19822 +}
19823 +
19824 +
19825 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19826 +{
19827 +       struct dl_info *dli;
19828 +
19829 +       rcu_read_lock();
19830 +       dli = get_dl_info(__lookup_dl_info(sb, tag));
19831 +       vxdprintk(VXD_CBIT(dlim, 7),
19832 +               "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19833 +       rcu_read_unlock();
19834 +       return dli;
19835 +}
19836 +
19837 +void rcu_free_dl_info(struct rcu_head *head)
19838 +{
19839 +       struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19840 +       int usecnt, refcnt;
19841 +
19842 +       BUG_ON(!dli || !head);
19843 +
19844 +       usecnt = atomic_read(&dli->dl_usecnt);
19845 +       BUG_ON(usecnt < 0);
19846 +
19847 +       refcnt = atomic_read(&dli->dl_refcnt);
19848 +       BUG_ON(refcnt < 0);
19849 +
19850 +       vxdprintk(VXD_CBIT(dlim, 3),
19851 +               "rcu_free_dl_info(%p)", dli);
19852 +       if (!usecnt)
19853 +               __dealloc_dl_info(dli);
19854 +       else
19855 +               printk("!!! rcu didn't free\n");
19856 +}
19857 +
19858 +
19859 +
19860 +
19861 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19862 +       uint32_t flags, int add)
19863 +{
19864 +       struct path path;
19865 +       int ret;
19866 +
19867 +       ret = user_lpath(name, &path);
19868 +       if (!ret) {
19869 +               struct super_block *sb;
19870 +               struct dl_info *dli;
19871 +
19872 +               ret = -EINVAL;
19873 +               if (!path.dentry->d_inode)
19874 +                       goto out_release;
19875 +               if (!(sb = path.dentry->d_inode->i_sb))
19876 +                       goto out_release;
19877 +
19878 +               if (add) {
19879 +                       dli = __alloc_dl_info(sb, id);
19880 +                       spin_lock(&dl_info_hash_lock);
19881 +
19882 +                       ret = -EEXIST;
19883 +                       if (__lookup_dl_info(sb, id))
19884 +                               goto out_unlock;
19885 +                       __hash_dl_info(dli);
19886 +                       dli = NULL;
19887 +               } else {
19888 +                       spin_lock(&dl_info_hash_lock);
19889 +                       dli = __lookup_dl_info(sb, id);
19890 +
19891 +                       ret = -ESRCH;
19892 +                       if (!dli)
19893 +                               goto out_unlock;
19894 +                       __unhash_dl_info(dli);
19895 +               }
19896 +               ret = 0;
19897 +       out_unlock:
19898 +               spin_unlock(&dl_info_hash_lock);
19899 +               if (add && dli)
19900 +                       __dealloc_dl_info(dli);
19901 +       out_release:
19902 +               path_put(&path);
19903 +       }
19904 +       return ret;
19905 +}
19906 +
19907 +int vc_add_dlimit(uint32_t id, void __user *data)
19908 +{
19909 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
19910 +
19911 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19912 +               return -EFAULT;
19913 +
19914 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19915 +}
19916 +
19917 +int vc_rem_dlimit(uint32_t id, void __user *data)
19918 +{
19919 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
19920 +
19921 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19922 +               return -EFAULT;
19923 +
19924 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19925 +}
19926 +
19927 +#ifdef CONFIG_COMPAT
19928 +
19929 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19930 +{
19931 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19932 +
19933 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19934 +               return -EFAULT;
19935 +
19936 +       return do_addrem_dlimit(id,
19937 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19938 +}
19939 +
19940 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19941 +{
19942 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19943 +
19944 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19945 +               return -EFAULT;
19946 +
19947 +       return do_addrem_dlimit(id,
19948 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19949 +}
19950 +
19951 +#endif /* CONFIG_COMPAT */
19952 +
19953 +
19954 +static inline
19955 +int do_set_dlimit(uint32_t id, const char __user *name,
19956 +       uint32_t space_used, uint32_t space_total,
19957 +       uint32_t inodes_used, uint32_t inodes_total,
19958 +       uint32_t reserved, uint32_t flags)
19959 +{
19960 +       struct path path;
19961 +       int ret;
19962 +
19963 +       ret = user_lpath(name, &path);
19964 +       if (!ret) {
19965 +               struct super_block *sb;
19966 +               struct dl_info *dli;
19967 +
19968 +               ret = -EINVAL;
19969 +               if (!path.dentry->d_inode)
19970 +                       goto out_release;
19971 +               if (!(sb = path.dentry->d_inode->i_sb))
19972 +                       goto out_release;
19973 +
19974 +               /* sanity checks */
19975 +               if ((reserved != CDLIM_KEEP &&
19976 +                       reserved > 100) ||
19977 +                       (inodes_used != CDLIM_KEEP &&
19978 +                       inodes_used > inodes_total) ||
19979 +                       (space_used != CDLIM_KEEP &&
19980 +                       space_used > space_total))
19981 +                       goto out_release;
19982 +
19983 +               ret = -ESRCH;
19984 +               dli = locate_dl_info(sb, id);
19985 +               if (!dli)
19986 +                       goto out_release;
19987 +
19988 +               spin_lock(&dli->dl_lock);
19989 +
19990 +               if (inodes_used != CDLIM_KEEP)
19991 +                       dli->dl_inodes_used = inodes_used;
19992 +               if (inodes_total != CDLIM_KEEP)
19993 +                       dli->dl_inodes_total = inodes_total;
19994 +               if (space_used != CDLIM_KEEP)
19995 +                       dli->dl_space_used = dlimit_space_32to64(
19996 +                               space_used, flags, DLIMS_USED);
19997 +
19998 +               if (space_total == CDLIM_INFINITY)
19999 +                       dli->dl_space_total = DLIM_INFINITY;
20000 +               else if (space_total != CDLIM_KEEP)
20001 +                       dli->dl_space_total = dlimit_space_32to64(
20002 +                               space_total, flags, DLIMS_TOTAL);
20003 +
20004 +               if (reserved != CDLIM_KEEP)
20005 +                       dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20006 +
20007 +               spin_unlock(&dli->dl_lock);
20008 +
20009 +               put_dl_info(dli);
20010 +               ret = 0;
20011 +
20012 +       out_release:
20013 +               path_put(&path);
20014 +       }
20015 +       return ret;
20016 +}
20017 +
20018 +int vc_set_dlimit(uint32_t id, void __user *data)
20019 +{
20020 +       struct vcmd_ctx_dlimit_v0 vc_data;
20021 +
20022 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20023 +               return -EFAULT;
20024 +
20025 +       return do_set_dlimit(id, vc_data.name,
20026 +               vc_data.space_used, vc_data.space_total,
20027 +               vc_data.inodes_used, vc_data.inodes_total,
20028 +               vc_data.reserved, vc_data.flags);
20029 +}
20030 +
20031 +#ifdef CONFIG_COMPAT
20032 +
20033 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20034 +{
20035 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20036 +
20037 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20038 +               return -EFAULT;
20039 +
20040 +       return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20041 +               vc_data.space_used, vc_data.space_total,
20042 +               vc_data.inodes_used, vc_data.inodes_total,
20043 +               vc_data.reserved, vc_data.flags);
20044 +}
20045 +
20046 +#endif /* CONFIG_COMPAT */
20047 +
20048 +
20049 +static inline
20050 +int do_get_dlimit(uint32_t id, const char __user *name,
20051 +       uint32_t *space_used, uint32_t *space_total,
20052 +       uint32_t *inodes_used, uint32_t *inodes_total,
20053 +       uint32_t *reserved, uint32_t *flags)
20054 +{
20055 +       struct path path;
20056 +       int ret;
20057 +
20058 +       ret = user_lpath(name, &path);
20059 +       if (!ret) {
20060 +               struct super_block *sb;
20061 +               struct dl_info *dli;
20062 +
20063 +               ret = -EINVAL;
20064 +               if (!path.dentry->d_inode)
20065 +                       goto out_release;
20066 +               if (!(sb = path.dentry->d_inode->i_sb))
20067 +                       goto out_release;
20068 +
20069 +               ret = -ESRCH;
20070 +               dli = locate_dl_info(sb, id);
20071 +               if (!dli)
20072 +                       goto out_release;
20073 +
20074 +               spin_lock(&dli->dl_lock);
20075 +               *inodes_used = dli->dl_inodes_used;
20076 +               *inodes_total = dli->dl_inodes_total;
20077 +
20078 +               *space_used = dlimit_space_64to32(
20079 +                       dli->dl_space_used, flags, DLIMS_USED);
20080 +
20081 +               if (dli->dl_space_total == DLIM_INFINITY)
20082 +                       *space_total = CDLIM_INFINITY;
20083 +               else
20084 +                       *space_total = dlimit_space_64to32(
20085 +                               dli->dl_space_total, flags, DLIMS_TOTAL);
20086 +
20087 +               *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20088 +               spin_unlock(&dli->dl_lock);
20089 +
20090 +               put_dl_info(dli);
20091 +               ret = -EFAULT;
20092 +
20093 +               ret = 0;
20094 +       out_release:
20095 +               path_put(&path);
20096 +       }
20097 +       return ret;
20098 +}
20099 +
20100 +
20101 +int vc_get_dlimit(uint32_t id, void __user *data)
20102 +{
20103 +       struct vcmd_ctx_dlimit_v0 vc_data;
20104 +       int ret;
20105 +
20106 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20107 +               return -EFAULT;
20108 +
20109 +       ret = do_get_dlimit(id, vc_data.name,
20110 +               &vc_data.space_used, &vc_data.space_total,
20111 +               &vc_data.inodes_used, &vc_data.inodes_total,
20112 +               &vc_data.reserved, &vc_data.flags);
20113 +       if (ret)
20114 +               return ret;
20115 +
20116 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20117 +               return -EFAULT;
20118 +       return 0;
20119 +}
20120 +
20121 +#ifdef CONFIG_COMPAT
20122 +
20123 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20124 +{
20125 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20126 +       int ret;
20127 +
20128 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20129 +               return -EFAULT;
20130 +
20131 +       ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20132 +               &vc_data.space_used, &vc_data.space_total,
20133 +               &vc_data.inodes_used, &vc_data.inodes_total,
20134 +               &vc_data.reserved, &vc_data.flags);
20135 +       if (ret)
20136 +               return ret;
20137 +
20138 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20139 +               return -EFAULT;
20140 +       return 0;
20141 +}
20142 +
20143 +#endif /* CONFIG_COMPAT */
20144 +
20145 +
20146 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20147 +{
20148 +       struct dl_info *dli;
20149 +       __u64 blimit, bfree, bavail;
20150 +       __u32 ifree;
20151 +
20152 +       dli = locate_dl_info(sb, dx_current_tag());
20153 +       if (!dli)
20154 +               return;
20155 +
20156 +       spin_lock(&dli->dl_lock);
20157 +       if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20158 +               goto no_ilim;
20159 +
20160 +       /* reduce max inodes available to limit */
20161 +       if (buf->f_files > dli->dl_inodes_total)
20162 +               buf->f_files = dli->dl_inodes_total;
20163 +
20164 +       ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20165 +       /* reduce free inodes to min */
20166 +       if (ifree < buf->f_ffree)
20167 +               buf->f_ffree = ifree;
20168 +
20169 +no_ilim:
20170 +       if (dli->dl_space_total == DLIM_INFINITY)
20171 +               goto no_blim;
20172 +
20173 +       blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20174 +
20175 +       if (dli->dl_space_total < dli->dl_space_used)
20176 +               bfree = 0;
20177 +       else
20178 +               bfree = (dli->dl_space_total - dli->dl_space_used)
20179 +                       >> sb->s_blocksize_bits;
20180 +
20181 +       bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20182 +       if (bavail < dli->dl_space_used)
20183 +               bavail = 0;
20184 +       else
20185 +               bavail = (bavail - dli->dl_space_used)
20186 +                       >> sb->s_blocksize_bits;
20187 +
20188 +       /* reduce max space available to limit */
20189 +       if (buf->f_blocks > blimit)
20190 +               buf->f_blocks = blimit;
20191 +
20192 +       /* reduce free space to min */
20193 +       if (bfree < buf->f_bfree)
20194 +               buf->f_bfree = bfree;
20195 +
20196 +       /* reduce avail space to min */
20197 +       if (bavail < buf->f_bavail)
20198 +               buf->f_bavail = bavail;
20199 +
20200 +no_blim:
20201 +       spin_unlock(&dli->dl_lock);
20202 +       put_dl_info(dli);
20203 +
20204 +       return;
20205 +}
20206 +
20207 +#include <linux/module.h>
20208 +
20209 +EXPORT_SYMBOL_GPL(locate_dl_info);
20210 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20211 +
20212 diff -NurpP --minimal linux-2.6.35/kernel/vserver/helper.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/helper.c
20213 --- linux-2.6.35/kernel/vserver/helper.c        1970-01-01 01:00:00.000000000 +0100
20214 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/helper.c  2010-08-02 17:05:06.000000000 +0200
20215 @@ -0,0 +1,223 @@
20216 +/*
20217 + *  linux/kernel/vserver/helper.c
20218 + *
20219 + *  Virtual Context Support
20220 + *
20221 + *  Copyright (C) 2004-2007  Herbert Pötzl
20222 + *
20223 + *  V0.01  basic helper
20224 + *
20225 + */
20226 +
20227 +#include <linux/kmod.h>
20228 +#include <linux/reboot.h>
20229 +#include <linux/vs_context.h>
20230 +#include <linux/vs_network.h>
20231 +#include <linux/vserver/signal.h>
20232 +
20233 +
20234 +char vshelper_path[255] = "/sbin/vshelper";
20235 +
20236 +
20237 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20238 +{
20239 +       int ret;
20240 +
20241 +       if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20242 +               printk( KERN_WARNING
20243 +                       "%s: (%s %s) returned %s with %d\n",
20244 +                       name, argv[1], argv[2],
20245 +                       sync ? "sync" : "async", ret);
20246 +       }
20247 +       vxdprintk(VXD_CBIT(switch, 4),
20248 +               "%s: (%s %s) returned %s with %d",
20249 +               name, argv[1], argv[2], sync ? "sync" : "async", ret);
20250 +       return ret;
20251 +}
20252 +
20253 +/*
20254 + *      vshelper path is set via /proc/sys
20255 + *      invoked by vserver sys_reboot(), with
20256 + *      the following arguments
20257 + *
20258 + *      argv [0] = vshelper_path;
20259 + *      argv [1] = action: "restart", "halt", "poweroff", ...
20260 + *      argv [2] = context identifier
20261 + *
20262 + *      envp [*] = type-specific parameters
20263 + */
20264 +
20265 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20266 +{
20267 +       char id_buf[8], cmd_buf[16];
20268 +       char uid_buf[16], pid_buf[16];
20269 +       int ret;
20270 +
20271 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20272 +       char *envp[] = {"HOME=/", "TERM=linux",
20273 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20274 +                       uid_buf, pid_buf, cmd_buf, 0};
20275 +
20276 +       if (vx_info_state(vxi, VXS_HELPER))
20277 +               return -EAGAIN;
20278 +       vxi->vx_state |= VXS_HELPER;
20279 +
20280 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20281 +
20282 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20283 +       snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20284 +       snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20285 +
20286 +       switch (cmd) {
20287 +       case LINUX_REBOOT_CMD_RESTART:
20288 +               argv[1] = "restart";
20289 +               break;
20290 +
20291 +       case LINUX_REBOOT_CMD_HALT:
20292 +               argv[1] = "halt";
20293 +               break;
20294 +
20295 +       case LINUX_REBOOT_CMD_POWER_OFF:
20296 +               argv[1] = "poweroff";
20297 +               break;
20298 +
20299 +       case LINUX_REBOOT_CMD_SW_SUSPEND:
20300 +               argv[1] = "swsusp";
20301 +               break;
20302 +
20303 +       case LINUX_REBOOT_CMD_OOM:
20304 +               argv[1] = "oom";
20305 +               break;
20306 +
20307 +       default:
20308 +               vxi->vx_state &= ~VXS_HELPER;
20309 +               return 0;
20310 +       }
20311 +
20312 +       ret = do_vshelper(vshelper_path, argv, envp, 0);
20313 +       vxi->vx_state &= ~VXS_HELPER;
20314 +       __wakeup_vx_info(vxi);
20315 +       return (ret) ? -EPERM : 0;
20316 +}
20317 +
20318 +
20319 +long vs_reboot(unsigned int cmd, void __user *arg)
20320 +{
20321 +       struct vx_info *vxi = current_vx_info();
20322 +       long ret = 0;
20323 +
20324 +       vxdprintk(VXD_CBIT(misc, 5),
20325 +               "vs_reboot(%p[#%d],%u)",
20326 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20327 +
20328 +       ret = vs_reboot_helper(vxi, cmd, arg);
20329 +       if (ret)
20330 +               return ret;
20331 +
20332 +       vxi->reboot_cmd = cmd;
20333 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20334 +               switch (cmd) {
20335 +               case LINUX_REBOOT_CMD_RESTART:
20336 +               case LINUX_REBOOT_CMD_HALT:
20337 +               case LINUX_REBOOT_CMD_POWER_OFF:
20338 +                       vx_info_kill(vxi, 0, SIGKILL);
20339 +                       vx_info_kill(vxi, 1, SIGKILL);
20340 +               default:
20341 +                       break;
20342 +               }
20343 +       }
20344 +       return 0;
20345 +}
20346 +
20347 +long vs_oom_action(unsigned int cmd)
20348 +{
20349 +       struct vx_info *vxi = current_vx_info();
20350 +       long ret = 0;
20351 +
20352 +       vxdprintk(VXD_CBIT(misc, 5),
20353 +               "vs_oom_action(%p[#%d],%u)",
20354 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20355 +
20356 +       ret = vs_reboot_helper(vxi, cmd, NULL);
20357 +       if (ret)
20358 +               return ret;
20359 +
20360 +       vxi->reboot_cmd = cmd;
20361 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20362 +               vx_info_kill(vxi, 0, SIGKILL);
20363 +               vx_info_kill(vxi, 1, SIGKILL);
20364 +       }
20365 +       return 0;
20366 +}
20367 +
20368 +/*
20369 + *      argv [0] = vshelper_path;
20370 + *      argv [1] = action: "startup", "shutdown"
20371 + *      argv [2] = context identifier
20372 + *
20373 + *      envp [*] = type-specific parameters
20374 + */
20375 +
20376 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20377 +{
20378 +       char id_buf[8], cmd_buf[16];
20379 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20380 +       char *envp[] = {"HOME=/", "TERM=linux",
20381 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20382 +
20383 +       if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20384 +               return 0;
20385 +
20386 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20387 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20388 +
20389 +       switch (cmd) {
20390 +       case VSC_STARTUP:
20391 +               argv[1] = "startup";
20392 +               break;
20393 +       case VSC_SHUTDOWN:
20394 +               argv[1] = "shutdown";
20395 +               break;
20396 +       default:
20397 +               return 0;
20398 +       }
20399 +
20400 +       return do_vshelper(vshelper_path, argv, envp, 1);
20401 +}
20402 +
20403 +
20404 +/*
20405 + *      argv [0] = vshelper_path;
20406 + *      argv [1] = action: "netup", "netdown"
20407 + *      argv [2] = context identifier
20408 + *
20409 + *      envp [*] = type-specific parameters
20410 + */
20411 +
20412 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20413 +{
20414 +       char id_buf[8], cmd_buf[16];
20415 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20416 +       char *envp[] = {"HOME=/", "TERM=linux",
20417 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20418 +
20419 +       if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20420 +               return 0;
20421 +
20422 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20423 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20424 +
20425 +       switch (cmd) {
20426 +       case VSC_NETUP:
20427 +               argv[1] = "netup";
20428 +               break;
20429 +       case VSC_NETDOWN:
20430 +               argv[1] = "netdown";
20431 +               break;
20432 +       default:
20433 +               return 0;
20434 +       }
20435 +
20436 +       return do_vshelper(vshelper_path, argv, envp, 1);
20437 +}
20438 +
20439 diff -NurpP --minimal linux-2.6.35/kernel/vserver/history.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/history.c
20440 --- linux-2.6.35/kernel/vserver/history.c       1970-01-01 01:00:00.000000000 +0100
20441 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/history.c 2010-08-02 17:05:06.000000000 +0200
20442 @@ -0,0 +1,258 @@
20443 +/*
20444 + *  kernel/vserver/history.c
20445 + *
20446 + *  Virtual Context History Backtrace
20447 + *
20448 + *  Copyright (C) 2004-2007  Herbert Pötzl
20449 + *
20450 + *  V0.01  basic structure
20451 + *  V0.02  hash/unhash and trace
20452 + *  V0.03  preemption fixes
20453 + *
20454 + */
20455 +
20456 +#include <linux/module.h>
20457 +#include <asm/uaccess.h>
20458 +
20459 +#include <linux/vserver/context.h>
20460 +#include <linux/vserver/debug.h>
20461 +#include <linux/vserver/debug_cmd.h>
20462 +#include <linux/vserver/history.h>
20463 +
20464 +
20465 +#ifdef CONFIG_VSERVER_HISTORY
20466 +#define VXH_SIZE       CONFIG_VSERVER_HISTORY_SIZE
20467 +#else
20468 +#define VXH_SIZE       64
20469 +#endif
20470 +
20471 +struct _vx_history {
20472 +       unsigned int counter;
20473 +
20474 +       struct _vx_hist_entry entry[VXH_SIZE + 1];
20475 +};
20476 +
20477 +
20478 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20479 +
20480 +unsigned volatile int vxh_active = 1;
20481 +
20482 +static atomic_t sequence = ATOMIC_INIT(0);
20483 +
20484 +
20485 +/*     vxh_advance()
20486 +
20487 +       * requires disabled preemption                          */
20488 +
20489 +struct _vx_hist_entry *vxh_advance(void *loc)
20490 +{
20491 +       unsigned int cpu = smp_processor_id();
20492 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20493 +       struct _vx_hist_entry *entry;
20494 +       unsigned int index;
20495 +
20496 +       index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20497 +       entry = &hist->entry[index];
20498 +
20499 +       entry->seq = atomic_inc_return(&sequence);
20500 +       entry->loc = loc;
20501 +       return entry;
20502 +}
20503 +
20504 +EXPORT_SYMBOL_GPL(vxh_advance);
20505 +
20506 +
20507 +#define VXH_LOC_FMTS   "(#%04x,*%d):%p"
20508 +
20509 +#define VXH_LOC_ARGS(e)        (e)->seq, cpu, (e)->loc
20510 +
20511 +
20512 +#define VXH_VXI_FMTS   "%p[#%d,%d.%d]"
20513 +
20514 +#define VXH_VXI_ARGS(e)        (e)->vxi.ptr,                           \
20515 +                       (e)->vxi.ptr ? (e)->vxi.xid : 0,        \
20516 +                       (e)->vxi.ptr ? (e)->vxi.usecnt : 0,     \
20517 +                       (e)->vxi.ptr ? (e)->vxi.tasks : 0
20518 +
20519 +void   vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20520 +{
20521 +       switch (e->type) {
20522 +       case VXH_THROW_OOPS:
20523 +               printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20524 +               break;
20525 +
20526 +       case VXH_GET_VX_INFO:
20527 +       case VXH_PUT_VX_INFO:
20528 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20529 +                       VXH_LOC_ARGS(e),
20530 +                       (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20531 +                       VXH_VXI_ARGS(e));
20532 +               break;
20533 +
20534 +       case VXH_INIT_VX_INFO:
20535 +       case VXH_SET_VX_INFO:
20536 +       case VXH_CLR_VX_INFO:
20537 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20538 +                       VXH_LOC_ARGS(e),
20539 +                       (e->type == VXH_INIT_VX_INFO) ? "init" :
20540 +                       ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20541 +                       VXH_VXI_ARGS(e), e->sc.data);
20542 +               break;
20543 +
20544 +       case VXH_CLAIM_VX_INFO:
20545 +       case VXH_RELEASE_VX_INFO:
20546 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20547 +                       VXH_LOC_ARGS(e),
20548 +                       (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20549 +                       VXH_VXI_ARGS(e), e->sc.data);
20550 +               break;
20551 +
20552 +       case VXH_ALLOC_VX_INFO:
20553 +       case VXH_DEALLOC_VX_INFO:
20554 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20555 +                       VXH_LOC_ARGS(e),
20556 +                       (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20557 +                       VXH_VXI_ARGS(e));
20558 +               break;
20559 +
20560 +       case VXH_HASH_VX_INFO:
20561 +       case VXH_UNHASH_VX_INFO:
20562 +               printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20563 +                       VXH_LOC_ARGS(e),
20564 +                       (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20565 +                       VXH_VXI_ARGS(e));
20566 +               break;
20567 +
20568 +       case VXH_LOC_VX_INFO:
20569 +       case VXH_LOOKUP_VX_INFO:
20570 +       case VXH_CREATE_VX_INFO:
20571 +               printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20572 +                       VXH_LOC_ARGS(e),
20573 +                       (e->type == VXH_CREATE_VX_INFO) ? "create" :
20574 +                       ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20575 +                       e->ll.arg, VXH_VXI_ARGS(e));
20576 +               break;
20577 +       }
20578 +}
20579 +
20580 +static void __vxh_dump_history(void)
20581 +{
20582 +       unsigned int i, cpu;
20583 +
20584 +       printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20585 +               atomic_read(&sequence), NR_CPUS);
20586 +
20587 +       for (i = 0; i < VXH_SIZE; i++) {
20588 +               for_each_online_cpu(cpu) {
20589 +                       struct _vx_history *hist =
20590 +                               &per_cpu(vx_history_buffer, cpu);
20591 +                       unsigned int index = (hist->counter - i) % VXH_SIZE;
20592 +                       struct _vx_hist_entry *entry = &hist->entry[index];
20593 +
20594 +                       vxh_dump_entry(entry, cpu);
20595 +               }
20596 +       }
20597 +}
20598 +
20599 +void   vxh_dump_history(void)
20600 +{
20601 +       vxh_active = 0;
20602 +#ifdef CONFIG_SMP
20603 +       local_irq_enable();
20604 +       smp_send_stop();
20605 +       local_irq_disable();
20606 +#endif
20607 +       __vxh_dump_history();
20608 +}
20609 +
20610 +
20611 +/* vserver syscall commands below here */
20612 +
20613 +
20614 +int vc_dump_history(uint32_t id)
20615 +{
20616 +       vxh_active = 0;
20617 +       __vxh_dump_history();
20618 +       vxh_active = 1;
20619 +
20620 +       return 0;
20621 +}
20622 +
20623 +
20624 +int do_read_history(struct __user _vx_hist_entry *data,
20625 +       int cpu, uint32_t *index, uint32_t *count)
20626 +{
20627 +       int pos, ret = 0;
20628 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20629 +       int end = hist->counter;
20630 +       int start = end - VXH_SIZE + 2;
20631 +       int idx = *index;
20632 +
20633 +       /* special case: get current pos */
20634 +       if (!*count) {
20635 +               *index = end;
20636 +               return 0;
20637 +       }
20638 +
20639 +       /* have we lost some data? */
20640 +       if (idx < start)
20641 +               idx = start;
20642 +
20643 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20644 +               struct _vx_hist_entry *entry =
20645 +                       &hist->entry[idx % VXH_SIZE];
20646 +
20647 +               /* send entry to userspace */
20648 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20649 +               if (ret)
20650 +                       break;
20651 +       }
20652 +       /* save new index and count */
20653 +       *index = idx;
20654 +       *count = pos;
20655 +       return ret ? ret : (*index < end);
20656 +}
20657 +
20658 +int vc_read_history(uint32_t id, void __user *data)
20659 +{
20660 +       struct vcmd_read_history_v0 vc_data;
20661 +       int ret;
20662 +
20663 +       if (id >= NR_CPUS)
20664 +               return -EINVAL;
20665 +
20666 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20667 +               return -EFAULT;
20668 +
20669 +       ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20670 +               id, &vc_data.index, &vc_data.count);
20671 +
20672 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20673 +               return -EFAULT;
20674 +       return ret;
20675 +}
20676 +
20677 +#ifdef CONFIG_COMPAT
20678 +
20679 +int vc_read_history_x32(uint32_t id, void __user *data)
20680 +{
20681 +       struct vcmd_read_history_v0_x32 vc_data;
20682 +       int ret;
20683 +
20684 +       if (id >= NR_CPUS)
20685 +               return -EINVAL;
20686 +
20687 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20688 +               return -EFAULT;
20689 +
20690 +       ret = do_read_history((struct __user _vx_hist_entry *)
20691 +               compat_ptr(vc_data.data_ptr),
20692 +               id, &vc_data.index, &vc_data.count);
20693 +
20694 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20695 +               return -EFAULT;
20696 +       return ret;
20697 +}
20698 +
20699 +#endif /* CONFIG_COMPAT */
20700 +
20701 diff -NurpP --minimal linux-2.6.35/kernel/vserver/inet.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/inet.c
20702 --- linux-2.6.35/kernel/vserver/inet.c  1970-01-01 01:00:00.000000000 +0100
20703 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/inet.c    2010-08-02 18:54:03.000000000 +0200
20704 @@ -0,0 +1,224 @@
20705 +
20706 +#include <linux/in.h>
20707 +#include <linux/inetdevice.h>
20708 +#include <linux/vs_inet.h>
20709 +#include <linux/vs_inet6.h>
20710 +#include <linux/vserver/debug.h>
20711 +#include <net/route.h>
20712 +#include <net/addrconf.h>
20713 +
20714 +
20715 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20716 +{
20717 +       int ret = 0;
20718 +
20719 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
20720 +               ret = 1;
20721 +       else {
20722 +               struct nx_addr_v4 *ptr;
20723 +
20724 +               for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20725 +                       if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20726 +                               ret = 1;
20727 +                               break;
20728 +                       }
20729 +               }
20730 +       }
20731 +
20732 +       vxdprintk(VXD_CBIT(net, 2),
20733 +               "nx_v4_addr_conflict(%p,%p): %d",
20734 +               nxi1, nxi2, ret);
20735 +
20736 +       return ret;
20737 +}
20738 +
20739 +
20740 +#ifdef CONFIG_IPV6
20741 +
20742 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20743 +{
20744 +       int ret = 0;
20745 +
20746 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
20747 +               ret = 1;
20748 +       else {
20749 +               struct nx_addr_v6 *ptr;
20750 +
20751 +               for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20752 +                       if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20753 +                               ret = 1;
20754 +                               break;
20755 +                       }
20756 +               }
20757 +       }
20758 +
20759 +       vxdprintk(VXD_CBIT(net, 2),
20760 +               "nx_v6_addr_conflict(%p,%p): %d",
20761 +               nxi1, nxi2, ret);
20762 +
20763 +       return ret;
20764 +}
20765 +
20766 +#endif
20767 +
20768 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20769 +{
20770 +       struct in_device *in_dev;
20771 +       struct in_ifaddr **ifap;
20772 +       struct in_ifaddr *ifa;
20773 +       int ret = 0;
20774 +
20775 +       if (!dev)
20776 +               goto out;
20777 +       in_dev = in_dev_get(dev);
20778 +       if (!in_dev)
20779 +               goto out;
20780 +
20781 +       for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20782 +               ifap = &ifa->ifa_next) {
20783 +               if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20784 +                       ret = 1;
20785 +                       break;
20786 +               }
20787 +       }
20788 +       in_dev_put(in_dev);
20789 +out:
20790 +       return ret;
20791 +}
20792 +
20793 +
20794 +#ifdef CONFIG_IPV6
20795 +
20796 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20797 +{
20798 +       struct inet6_dev *in_dev;
20799 +       struct inet6_ifaddr *ifa;
20800 +       int ret = 0;
20801 +
20802 +       if (!dev)
20803 +               goto out;
20804 +       in_dev = in6_dev_get(dev);
20805 +       if (!in_dev)
20806 +               goto out;
20807 +
20808 +       // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20809 +       list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
20810 +               if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20811 +                       ret = 1;
20812 +                       break;
20813 +               }
20814 +       }
20815 +       in6_dev_put(in_dev);
20816 +out:
20817 +       return ret;
20818 +}
20819 +
20820 +#endif
20821 +
20822 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20823 +{
20824 +       int ret = 1;
20825 +
20826 +       if (!nxi)
20827 +               goto out;
20828 +       if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20829 +               goto out;
20830 +#ifdef CONFIG_IPV6
20831 +       ret = 2;
20832 +       if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20833 +               goto out;
20834 +#endif
20835 +       ret = 0;
20836 +out:
20837 +       vxdprintk(VXD_CBIT(net, 3),
20838 +               "dev_in_nx_info(%p,%p[#%d]) = %d",
20839 +               dev, nxi, nxi ? nxi->nx_id : 0, ret);
20840 +       return ret;
20841 +}
20842 +
20843 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20844 +       struct rtable **rp, struct flowi *fl)
20845 +{
20846 +       if (!nxi)
20847 +               return 0;
20848 +
20849 +       /* FIXME: handle lback only case */
20850 +       if (!NX_IPV4(nxi))
20851 +               return -EPERM;
20852 +
20853 +       vxdprintk(VXD_CBIT(net, 4),
20854 +               "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20855 +               nxi, nxi ? nxi->nx_id : 0,
20856 +               NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20857 +
20858 +       /* single IP is unconditional */
20859 +       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20860 +               (fl->fl4_src == INADDR_ANY))
20861 +               fl->fl4_src = nxi->v4.ip[0].s_addr;
20862 +
20863 +       if (fl->fl4_src == INADDR_ANY) {
20864 +               struct nx_addr_v4 *ptr;
20865 +               __be32 found = 0;
20866 +               int err;
20867 +
20868 +               err = __ip_route_output_key(net, rp, fl);
20869 +               if (!err) {
20870 +                       found = (*rp)->rt_src;
20871 +                       ip_rt_put(*rp);
20872 +                       vxdprintk(VXD_CBIT(net, 4),
20873 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20874 +                               nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20875 +                       if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20876 +                               goto found;
20877 +               }
20878 +
20879 +               for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20880 +                       __be32 primary = ptr->ip[0].s_addr;
20881 +                       __be32 mask = ptr->mask.s_addr;
20882 +                       __be32 neta = primary & mask;
20883 +
20884 +                       vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20885 +                               NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20886 +                               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20887 +                               NIPQUAD(mask), NIPQUAD(neta));
20888 +                       if ((found & mask) != neta)
20889 +                               continue;
20890 +
20891 +                       fl->fl4_src = primary;
20892 +                       err = __ip_route_output_key(net, rp, fl);
20893 +                       vxdprintk(VXD_CBIT(net, 4),
20894 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20895 +                               nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20896 +                       if (!err) {
20897 +                               found = (*rp)->rt_src;
20898 +                               ip_rt_put(*rp);
20899 +                               if (found == primary)
20900 +                                       goto found;
20901 +                       }
20902 +               }
20903 +               /* still no source ip? */
20904 +               found = ipv4_is_loopback(fl->fl4_dst)
20905 +                       ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20906 +       found:
20907 +               /* assign src ip to flow */
20908 +               fl->fl4_src = found;
20909 +
20910 +       } else {
20911 +               if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20912 +                       return -EPERM;
20913 +       }
20914 +
20915 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20916 +               if (ipv4_is_loopback(fl->fl4_dst))
20917 +                       fl->fl4_dst = nxi->v4_lback.s_addr;
20918 +               if (ipv4_is_loopback(fl->fl4_src))
20919 +                       fl->fl4_src = nxi->v4_lback.s_addr;
20920 +       } else if (ipv4_is_loopback(fl->fl4_dst) &&
20921 +               !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20922 +               return -EPERM;
20923 +
20924 +       return 0;
20925 +}
20926 +
20927 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20928 +
20929 diff -NurpP --minimal linux-2.6.35/kernel/vserver/init.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/init.c
20930 --- linux-2.6.35/kernel/vserver/init.c  1970-01-01 01:00:00.000000000 +0100
20931 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/init.c    2010-08-02 17:05:06.000000000 +0200
20932 @@ -0,0 +1,45 @@
20933 +/*
20934 + *  linux/kernel/init.c
20935 + *
20936 + *  Virtual Server Init
20937 + *
20938 + *  Copyright (C) 2004-2007  Herbert Pötzl
20939 + *
20940 + *  V0.01  basic structure
20941 + *
20942 + */
20943 +
20944 +#include <linux/init.h>
20945 +
20946 +int    vserver_register_sysctl(void);
20947 +void   vserver_unregister_sysctl(void);
20948 +
20949 +
20950 +static int __init init_vserver(void)
20951 +{
20952 +       int ret = 0;
20953 +
20954 +#ifdef CONFIG_VSERVER_DEBUG
20955 +       vserver_register_sysctl();
20956 +#endif
20957 +       return ret;
20958 +}
20959 +
20960 +
20961 +static void __exit exit_vserver(void)
20962 +{
20963 +
20964 +#ifdef CONFIG_VSERVER_DEBUG
20965 +       vserver_unregister_sysctl();
20966 +#endif
20967 +       return;
20968 +}
20969 +
20970 +/* FIXME: GFP_ZONETYPES gone
20971 +long vx_slab[GFP_ZONETYPES]; */
20972 +long vx_area;
20973 +
20974 +
20975 +module_init(init_vserver);
20976 +module_exit(exit_vserver);
20977 +
20978 diff -NurpP --minimal linux-2.6.35/kernel/vserver/inode.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/inode.c
20979 --- linux-2.6.35/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
20980 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/inode.c   2010-08-02 17:05:06.000000000 +0200
20981 @@ -0,0 +1,433 @@
20982 +/*
20983 + *  linux/kernel/vserver/inode.c
20984 + *
20985 + *  Virtual Server: File System Support
20986 + *
20987 + *  Copyright (C) 2004-2007  Herbert Pötzl
20988 + *
20989 + *  V0.01  separated from vcontext V0.05
20990 + *  V0.02  moved to tag (instead of xid)
20991 + *
20992 + */
20993 +
20994 +#include <linux/tty.h>
20995 +#include <linux/proc_fs.h>
20996 +#include <linux/devpts_fs.h>
20997 +#include <linux/fs.h>
20998 +#include <linux/file.h>
20999 +#include <linux/mount.h>
21000 +#include <linux/parser.h>
21001 +#include <linux/namei.h>
21002 +#include <linux/vserver/inode.h>
21003 +#include <linux/vserver/inode_cmd.h>
21004 +#include <linux/vs_base.h>
21005 +#include <linux/vs_tag.h>
21006 +
21007 +#include <asm/uaccess.h>
21008 +
21009 +
21010 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21011 +{
21012 +       struct proc_dir_entry *entry;
21013 +
21014 +       if (!in || !in->i_sb)
21015 +               return -ESRCH;
21016 +
21017 +       *flags = IATTR_TAG
21018 +               | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21019 +               | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21020 +               | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21021 +               | (IS_COW(in) ? IATTR_COW : 0);
21022 +       *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21023 +
21024 +       if (S_ISDIR(in->i_mode))
21025 +               *mask |= IATTR_BARRIER;
21026 +
21027 +       if (IS_TAGGED(in)) {
21028 +               *tag = in->i_tag;
21029 +               *mask |= IATTR_TAG;
21030 +       }
21031 +
21032 +       switch (in->i_sb->s_magic) {
21033 +       case PROC_SUPER_MAGIC:
21034 +               entry = PROC_I(in)->pde;
21035 +
21036 +               /* check for specific inodes? */
21037 +               if (entry)
21038 +                       *mask |= IATTR_FLAGS;
21039 +               if (entry)
21040 +                       *flags |= (entry->vx_flags & IATTR_FLAGS);
21041 +               else
21042 +                       *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21043 +               break;
21044 +
21045 +       case DEVPTS_SUPER_MAGIC:
21046 +               *tag = in->i_tag;
21047 +               *mask |= IATTR_TAG;
21048 +               break;
21049 +
21050 +       default:
21051 +               break;
21052 +       }
21053 +       return 0;
21054 +}
21055 +
21056 +int vc_get_iattr(void __user *data)
21057 +{
21058 +       struct path path;
21059 +       struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21060 +       int ret;
21061 +
21062 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21063 +               return -EFAULT;
21064 +
21065 +       ret = user_lpath(vc_data.name, &path);
21066 +       if (!ret) {
21067 +               ret = __vc_get_iattr(path.dentry->d_inode,
21068 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21069 +               path_put(&path);
21070 +       }
21071 +       if (ret)
21072 +               return ret;
21073 +
21074 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21075 +               ret = -EFAULT;
21076 +       return ret;
21077 +}
21078 +
21079 +#ifdef CONFIG_COMPAT
21080 +
21081 +int vc_get_iattr_x32(void __user *data)
21082 +{
21083 +       struct path path;
21084 +       struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21085 +       int ret;
21086 +
21087 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21088 +               return -EFAULT;
21089 +
21090 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21091 +       if (!ret) {
21092 +               ret = __vc_get_iattr(path.dentry->d_inode,
21093 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21094 +               path_put(&path);
21095 +       }
21096 +       if (ret)
21097 +               return ret;
21098 +
21099 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21100 +               ret = -EFAULT;
21101 +       return ret;
21102 +}
21103 +
21104 +#endif /* CONFIG_COMPAT */
21105 +
21106 +
21107 +int vc_fget_iattr(uint32_t fd, void __user *data)
21108 +{
21109 +       struct file *filp;
21110 +       struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21111 +       int ret;
21112 +
21113 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21114 +               return -EFAULT;
21115 +
21116 +       filp = fget(fd);
21117 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21118 +               return -EBADF;
21119 +
21120 +       ret = __vc_get_iattr(filp->f_dentry->d_inode,
21121 +               &vc_data.tag, &vc_data.flags, &vc_data.mask);
21122 +
21123 +       fput(filp);
21124 +
21125 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21126 +               ret = -EFAULT;
21127 +       return ret;
21128 +}
21129 +
21130 +
21131 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21132 +{
21133 +       struct inode *in = de->d_inode;
21134 +       int error = 0, is_proc = 0, has_tag = 0;
21135 +       struct iattr attr = { 0 };
21136 +
21137 +       if (!in || !in->i_sb)
21138 +               return -ESRCH;
21139 +
21140 +       is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21141 +       if ((*mask & IATTR_FLAGS) && !is_proc)
21142 +               return -EINVAL;
21143 +
21144 +       has_tag = IS_TAGGED(in) ||
21145 +               (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21146 +       if ((*mask & IATTR_TAG) && !has_tag)
21147 +               return -EINVAL;
21148 +
21149 +       mutex_lock(&in->i_mutex);
21150 +       if (*mask & IATTR_TAG) {
21151 +               attr.ia_tag = *tag;
21152 +               attr.ia_valid |= ATTR_TAG;
21153 +       }
21154 +
21155 +       if (*mask & IATTR_FLAGS) {
21156 +               struct proc_dir_entry *entry = PROC_I(in)->pde;
21157 +               unsigned int iflags = PROC_I(in)->vx_flags;
21158 +
21159 +               iflags = (iflags & ~(*mask & IATTR_FLAGS))
21160 +                       | (*flags & IATTR_FLAGS);
21161 +               PROC_I(in)->vx_flags = iflags;
21162 +               if (entry)
21163 +                       entry->vx_flags = iflags;
21164 +       }
21165 +
21166 +       if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21167 +               IATTR_BARRIER | IATTR_COW)) {
21168 +               int iflags = in->i_flags;
21169 +               int vflags = in->i_vflags;
21170 +
21171 +               if (*mask & IATTR_IMMUTABLE) {
21172 +                       if (*flags & IATTR_IMMUTABLE)
21173 +                               iflags |= S_IMMUTABLE;
21174 +                       else
21175 +                               iflags &= ~S_IMMUTABLE;
21176 +               }
21177 +               if (*mask & IATTR_IXUNLINK) {
21178 +                       if (*flags & IATTR_IXUNLINK)
21179 +                               iflags |= S_IXUNLINK;
21180 +                       else
21181 +                               iflags &= ~S_IXUNLINK;
21182 +               }
21183 +               if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21184 +                       if (*flags & IATTR_BARRIER)
21185 +                               vflags |= V_BARRIER;
21186 +                       else
21187 +                               vflags &= ~V_BARRIER;
21188 +               }
21189 +               if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21190 +                       if (*flags & IATTR_COW)
21191 +                               vflags |= V_COW;
21192 +                       else
21193 +                               vflags &= ~V_COW;
21194 +               }
21195 +               if (in->i_op && in->i_op->sync_flags) {
21196 +                       error = in->i_op->sync_flags(in, iflags, vflags);
21197 +                       if (error)
21198 +                               goto out;
21199 +               }
21200 +       }
21201 +
21202 +       if (attr.ia_valid) {
21203 +               if (in->i_op && in->i_op->setattr)
21204 +                       error = in->i_op->setattr(de, &attr);
21205 +               else {
21206 +                       error = inode_change_ok(in, &attr);
21207 +                       if (!error)
21208 +                               error = inode_setattr(in, &attr);
21209 +               }
21210 +       }
21211 +
21212 +out:
21213 +       mutex_unlock(&in->i_mutex);
21214 +       return error;
21215 +}
21216 +
21217 +int vc_set_iattr(void __user *data)
21218 +{
21219 +       struct path path;
21220 +       struct vcmd_ctx_iattr_v1 vc_data;
21221 +       int ret;
21222 +
21223 +       if (!capable(CAP_LINUX_IMMUTABLE))
21224 +               return -EPERM;
21225 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21226 +               return -EFAULT;
21227 +
21228 +       ret = user_lpath(vc_data.name, &path);
21229 +       if (!ret) {
21230 +               ret = __vc_set_iattr(path.dentry,
21231 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21232 +               path_put(&path);
21233 +       }
21234 +
21235 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21236 +               ret = -EFAULT;
21237 +       return ret;
21238 +}
21239 +
21240 +#ifdef CONFIG_COMPAT
21241 +
21242 +int vc_set_iattr_x32(void __user *data)
21243 +{
21244 +       struct path path;
21245 +       struct vcmd_ctx_iattr_v1_x32 vc_data;
21246 +       int ret;
21247 +
21248 +       if (!capable(CAP_LINUX_IMMUTABLE))
21249 +               return -EPERM;
21250 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21251 +               return -EFAULT;
21252 +
21253 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21254 +       if (!ret) {
21255 +               ret = __vc_set_iattr(path.dentry,
21256 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21257 +               path_put(&path);
21258 +       }
21259 +
21260 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21261 +               ret = -EFAULT;
21262 +       return ret;
21263 +}
21264 +
21265 +#endif /* CONFIG_COMPAT */
21266 +
21267 +int vc_fset_iattr(uint32_t fd, void __user *data)
21268 +{
21269 +       struct file *filp;
21270 +       struct vcmd_ctx_fiattr_v0 vc_data;
21271 +       int ret;
21272 +
21273 +       if (!capable(CAP_LINUX_IMMUTABLE))
21274 +               return -EPERM;
21275 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21276 +               return -EFAULT;
21277 +
21278 +       filp = fget(fd);
21279 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21280 +               return -EBADF;
21281 +
21282 +       ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21283 +               &vc_data.flags, &vc_data.mask);
21284 +
21285 +       fput(filp);
21286 +
21287 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21288 +               return -EFAULT;
21289 +       return ret;
21290 +}
21291 +
21292 +
21293 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21294 +
21295 +static match_table_t tokens = {
21296 +       {Opt_notagcheck, "notagcheck"},
21297 +#ifdef CONFIG_PROPAGATE
21298 +       {Opt_notag, "notag"},
21299 +       {Opt_tag, "tag"},
21300 +       {Opt_tagid, "tagid=%u"},
21301 +#endif
21302 +       {Opt_err, NULL}
21303 +};
21304 +
21305 +
21306 +static void __dx_parse_remove(char *string, char *opt)
21307 +{
21308 +       char *p = strstr(string, opt);
21309 +       char *q = p;
21310 +
21311 +       if (p) {
21312 +               while (*q != '\0' && *q != ',')
21313 +                       q++;
21314 +               while (*q)
21315 +                       *p++ = *q++;
21316 +               while (*p)
21317 +                       *p++ = '\0';
21318 +       }
21319 +}
21320 +
21321 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21322 +                unsigned long *flags)
21323 +{
21324 +       int set = 0;
21325 +       substring_t args[MAX_OPT_ARGS];
21326 +       int token, option = 0;
21327 +       char *s, *p, *opts;
21328 +
21329 +       if (!string)
21330 +               return 0;
21331 +       s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21332 +       if (!s)
21333 +               return 0;
21334 +
21335 +       opts = s;
21336 +       while ((p = strsep(&opts, ",")) != NULL) {
21337 +               token = match_token(p, tokens, args);
21338 +
21339 +               vxdprintk(VXD_CBIT(tag, 7),
21340 +                       "dx_parse_tag(»%s«): %d:#%d",
21341 +                       p, token, option);
21342 +
21343 +               switch (token) {
21344 +#ifdef CONFIG_PROPAGATE
21345 +               case Opt_tag:
21346 +                       if (tag)
21347 +                               *tag = 0;
21348 +                       if (remove)
21349 +                               __dx_parse_remove(s, "tag");
21350 +                       *mnt_flags |= MNT_TAGID;
21351 +                       set |= MNT_TAGID;
21352 +                       break;
21353 +               case Opt_notag:
21354 +                       if (remove)
21355 +                               __dx_parse_remove(s, "notag");
21356 +                       *mnt_flags |= MNT_NOTAG;
21357 +                       set |= MNT_NOTAG;
21358 +                       break;
21359 +               case Opt_tagid:
21360 +                       if (tag && !match_int(args, &option))
21361 +                               *tag = option;
21362 +                       if (remove)
21363 +                               __dx_parse_remove(s, "tagid");
21364 +                       *mnt_flags |= MNT_TAGID;
21365 +                       set |= MNT_TAGID;
21366 +                       break;
21367 +#endif
21368 +               case Opt_notagcheck:
21369 +                       if (remove)
21370 +                               __dx_parse_remove(s, "notagcheck");
21371 +                       *flags |= MS_NOTAGCHECK;
21372 +                       set |= MS_NOTAGCHECK;
21373 +                       break;
21374 +               }
21375 +       }
21376 +       if (set)
21377 +               strcpy(string, s);
21378 +       kfree(s);
21379 +       return set;
21380 +}
21381 +
21382 +#ifdef CONFIG_PROPAGATE
21383 +
21384 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21385 +{
21386 +       tag_t new_tag = 0;
21387 +       struct vfsmount *mnt;
21388 +       int propagate;
21389 +
21390 +       if (!nd)
21391 +               return;
21392 +       mnt = nd->path.mnt;
21393 +       if (!mnt)
21394 +               return;
21395 +
21396 +       propagate = (mnt->mnt_flags & MNT_TAGID);
21397 +       if (propagate)
21398 +               new_tag = mnt->mnt_tag;
21399 +
21400 +       vxdprintk(VXD_CBIT(tag, 7),
21401 +               "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21402 +               inode, inode->i_ino, inode->i_tag,
21403 +               new_tag, (propagate) ? 1 : 0);
21404 +
21405 +       if (propagate)
21406 +               inode->i_tag = new_tag;
21407 +}
21408 +
21409 +#include <linux/module.h>
21410 +
21411 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21412 +
21413 +#endif /* CONFIG_PROPAGATE */
21414 +
21415 diff -NurpP --minimal linux-2.6.35/kernel/vserver/Kconfig linux-2.6.35-vs2.3.0.36.31/kernel/vserver/Kconfig
21416 --- linux-2.6.35/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
21417 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/Kconfig   2010-08-02 17:05:06.000000000 +0200
21418 @@ -0,0 +1,260 @@
21419 +#
21420 +# Linux VServer configuration
21421 +#
21422 +
21423 +menu "Linux VServer"
21424 +
21425 +config VSERVER_AUTO_LBACK
21426 +       bool    "Automatically Assign Loopback IP"
21427 +       default y
21428 +       help
21429 +         Automatically assign a guest specific loopback
21430 +         IP and add it to the kernel network stack on
21431 +         startup.
21432 +
21433 +config VSERVER_AUTO_SINGLE
21434 +       bool    "Automatic Single IP Special Casing"
21435 +       depends on EXPERIMENTAL
21436 +       default y
21437 +       help
21438 +         This allows network contexts with a single IP to
21439 +         automatically remap 0.0.0.0 bindings to that IP,
21440 +         avoiding further network checks and improving
21441 +         performance.
21442 +
21443 +         (note: such guests do not allow to change the ip
21444 +          on the fly and do not show loopback addresses)
21445 +
21446 +config VSERVER_COWBL
21447 +       bool    "Enable COW Immutable Link Breaking"
21448 +       default y
21449 +       help
21450 +         This enables the COW (Copy-On-Write) link break code.
21451 +         It allows you to treat unified files like normal files
21452 +         when writing to them (which will implicitely break the
21453 +         link and create a copy of the unified file)
21454 +
21455 +config VSERVER_VTIME
21456 +       bool    "Enable Virtualized Guest Time"
21457 +       depends on EXPERIMENTAL
21458 +       default n
21459 +       help
21460 +         This enables per guest time offsets to allow for
21461 +         adjusting the system clock individually per guest.
21462 +         this adds some overhead to the time functions and
21463 +         therefore should not be enabled without good reason.
21464 +
21465 +config VSERVER_DEVICE
21466 +       bool    "Enable Guest Device Mapping"
21467 +       depends on EXPERIMENTAL
21468 +       default n
21469 +       help
21470 +         This enables generic device remapping.
21471 +
21472 +config VSERVER_PROC_SECURE
21473 +       bool    "Enable Proc Security"
21474 +       depends on PROC_FS
21475 +       default y
21476 +       help
21477 +         This configures ProcFS security to initially hide
21478 +         non-process entries for all contexts except the main and
21479 +         spectator context (i.e. for all guests), which is a secure
21480 +         default.
21481 +
21482 +         (note: on 1.2x the entries were visible by default)
21483 +
21484 +config VSERVER_HARDCPU
21485 +       bool    "Enable Hard CPU Limits"
21486 +       default y
21487 +       help
21488 +         Activate the Hard CPU Limits
21489 +
21490 +         This will compile in code that allows the Token Bucket
21491 +         Scheduler to put processes on hold when a context's
21492 +         tokens are depleted (provided that its per-context
21493 +         sched_hard flag is set).
21494 +
21495 +         Processes belonging to that context will not be able
21496 +         to consume CPU resources again until a per-context
21497 +         configured minimum of tokens has been reached.
21498 +
21499 +config VSERVER_IDLETIME
21500 +       bool    "Avoid idle CPUs by skipping Time"
21501 +       depends on VSERVER_HARDCPU
21502 +       default y
21503 +       help
21504 +         This option allows the scheduler to artificially
21505 +         advance time (per cpu) when otherwise the idle
21506 +         task would be scheduled, thus keeping the cpu
21507 +         busy and sharing the available resources among
21508 +         certain contexts.
21509 +
21510 +config VSERVER_IDLELIMIT
21511 +       bool    "Limit the IDLE task"
21512 +       depends on VSERVER_HARDCPU
21513 +       default n
21514 +       help
21515 +         Limit the idle slices, so the the next context
21516 +         will be scheduled as soon as possible.
21517 +
21518 +         This might improve interactivity and latency, but
21519 +         will also marginally increase scheduling overhead.
21520 +
21521 +choice
21522 +       prompt  "Persistent Inode Tagging"
21523 +       default TAGGING_ID24
21524 +       help
21525 +         This adds persistent context information to filesystems
21526 +         mounted with the tagxid option. Tagging is a requirement
21527 +         for per-context disk limits and per-context quota.
21528 +
21529 +
21530 +config TAGGING_NONE
21531 +       bool    "Disabled"
21532 +       help
21533 +         do not store per-context information in inodes.
21534 +
21535 +config TAGGING_UID16
21536 +       bool    "UID16/GID32"
21537 +       help
21538 +         reduces UID to 16 bit, but leaves GID at 32 bit.
21539 +
21540 +config TAGGING_GID16
21541 +       bool    "UID32/GID16"
21542 +       help
21543 +         reduces GID to 16 bit, but leaves UID at 32 bit.
21544 +
21545 +config TAGGING_ID24
21546 +       bool    "UID24/GID24"
21547 +       help
21548 +         uses the upper 8bit from UID and GID for XID tagging
21549 +         which leaves 24bit for UID/GID each, which should be
21550 +         more than sufficient for normal use.
21551 +
21552 +config TAGGING_INTERN
21553 +       bool    "UID32/GID32"
21554 +       help
21555 +         this uses otherwise reserved inode fields in the on
21556 +         disk representation, which limits the use to a few
21557 +         filesystems (currently ext2 and ext3)
21558 +
21559 +endchoice
21560 +
21561 +config TAG_NFSD
21562 +       bool    "Tag NFSD User Auth and Files"
21563 +       default n
21564 +       help
21565 +         Enable this if you do want the in-kernel NFS
21566 +         Server to use the tagging specified above.
21567 +         (will require patched clients too)
21568 +
21569 +config VSERVER_PRIVACY
21570 +       bool    "Honor Privacy Aspects of Guests"
21571 +       default n
21572 +       help
21573 +         When enabled, most context checks will disallow
21574 +         access to structures assigned to a specific context,
21575 +         like ptys or loop devices.
21576 +
21577 +config VSERVER_CONTEXTS
21578 +       int     "Maximum number of Contexts (1-65533)"  if EMBEDDED
21579 +       range 1 65533
21580 +       default "768"   if 64BIT
21581 +       default "256"
21582 +       help
21583 +         This setting will optimize certain data structures
21584 +         and memory allocations according to the expected
21585 +         maximum.
21586 +
21587 +         note: this is not a strict upper limit.
21588 +
21589 +config VSERVER_WARN
21590 +       bool    "VServer Warnings"
21591 +       default y
21592 +       help
21593 +         This enables various runtime warnings, which will
21594 +         notify about potential manipulation attempts or
21595 +         resource shortage. It is generally considered to
21596 +         be a good idea to have that enabled.
21597 +
21598 +config VSERVER_DEBUG
21599 +       bool    "VServer Debugging Code"
21600 +       default n
21601 +       help
21602 +         Set this to yes if you want to be able to activate
21603 +         debugging output at runtime. It adds a very small
21604 +         overhead to all vserver related functions and
21605 +         increases the kernel size by about 20k.
21606 +
21607 +config VSERVER_HISTORY
21608 +       bool    "VServer History Tracing"
21609 +       depends on VSERVER_DEBUG
21610 +       default n
21611 +       help
21612 +         Set this to yes if you want to record the history of
21613 +         linux-vserver activities, so they can be replayed in
21614 +         the event of a kernel panic or oops.
21615 +
21616 +config VSERVER_HISTORY_SIZE
21617 +       int     "Per-CPU History Size (32-65536)"
21618 +       depends on VSERVER_HISTORY
21619 +       range 32 65536
21620 +       default 64
21621 +       help
21622 +         This allows you to specify the number of entries in
21623 +         the per-CPU history buffer.
21624 +
21625 +config VSERVER_MONITOR
21626 +       bool    "VServer Scheduling Monitor"
21627 +       depends on VSERVER_DISABLED
21628 +       default n
21629 +       help
21630 +         Set this to yes if you want to record the scheduling
21631 +         decisions, so that they can be relayed to userspace
21632 +         for detailed analysis.
21633 +
21634 +config VSERVER_MONITOR_SIZE
21635 +       int     "Per-CPU Monitor Queue Size (32-65536)"
21636 +       depends on VSERVER_MONITOR
21637 +       range 32 65536
21638 +       default 1024
21639 +       help
21640 +         This allows you to specify the number of entries in
21641 +         the per-CPU scheduling monitor buffer.
21642 +
21643 +config VSERVER_MONITOR_SYNC
21644 +       int     "Per-CPU Monitor Sync Interval (0-65536)"
21645 +       depends on VSERVER_MONITOR
21646 +       range 0 65536
21647 +       default 256
21648 +       help
21649 +         This allows you to specify the interval in ticks
21650 +         when a time sync entry is inserted.
21651 +
21652 +config VSERVER_LEGACY_MEM
21653 +       bool    "Legacy Memory Limits"
21654 +       default n
21655 +       help
21656 +         This provides fake memory limits to keep
21657 +         older tools happy in the face of memory
21658 +         cgroups
21659 +
21660 +
21661 +endmenu
21662 +
21663 +
21664 +config VSERVER
21665 +       bool
21666 +       default y
21667 +       select NAMESPACES
21668 +       select UTS_NS
21669 +       select IPC_NS
21670 +       select USER_NS
21671 +       select SYSVIPC
21672 +
21673 +config VSERVER_SECURITY
21674 +       bool
21675 +       depends on SECURITY
21676 +       default y
21677 +       select SECURITY_CAPABILITIES
21678 +
21679 diff -NurpP --minimal linux-2.6.35/kernel/vserver/limit.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit.c
21680 --- linux-2.6.35/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21681 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit.c   2010-08-02 17:05:06.000000000 +0200
21682 @@ -0,0 +1,354 @@
21683 +/*
21684 + *  linux/kernel/vserver/limit.c
21685 + *
21686 + *  Virtual Server: Context Limits
21687 + *
21688 + *  Copyright (C) 2004-2010  Herbert Pötzl
21689 + *
21690 + *  V0.01  broken out from vcontext V0.05
21691 + *  V0.02  changed vcmds to vxi arg
21692 + *  V0.03  added memory cgroup support
21693 + *
21694 + */
21695 +
21696 +#include <linux/sched.h>
21697 +#include <linux/module.h>
21698 +#include <linux/memcontrol.h>
21699 +#include <linux/res_counter.h>
21700 +#include <linux/vs_limit.h>
21701 +#include <linux/vserver/limit.h>
21702 +#include <linux/vserver/limit_cmd.h>
21703 +
21704 +#include <asm/uaccess.h>
21705 +
21706 +
21707 +const char *vlimit_name[NUM_LIMITS] = {
21708 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21709 +       [RLIMIT_RSS]            = "RSS",
21710 +       [RLIMIT_AS]             = "VM",
21711 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21712 +       [RLIMIT_CPU]            = "CPU",
21713 +       [RLIMIT_NPROC]          = "NPROC",
21714 +       [RLIMIT_NOFILE]         = "NOFILE",
21715 +       [RLIMIT_LOCKS]          = "LOCKS",
21716 +       [RLIMIT_SIGPENDING]     = "SIGP",
21717 +       [RLIMIT_MSGQUEUE]       = "MSGQ",
21718 +
21719 +       [VLIMIT_NSOCK]          = "NSOCK",
21720 +       [VLIMIT_OPENFD]         = "OPENFD",
21721 +       [VLIMIT_SHMEM]          = "SHMEM",
21722 +       [VLIMIT_DENTRY]         = "DENTRY",
21723 +};
21724 +
21725 +EXPORT_SYMBOL_GPL(vlimit_name);
21726 +
21727 +#define MASK_ENTRY(x)  (1 << (x))
21728 +
21729 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21730 +               /* minimum */
21731 +       0
21732 +       ,       /* softlimit */
21733 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21734 +       MASK_ENTRY( RLIMIT_RSS          ) |
21735 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21736 +       0
21737 +       ,       /* maximum */
21738 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21739 +       MASK_ENTRY( RLIMIT_RSS          ) |
21740 +       MASK_ENTRY( RLIMIT_AS           ) |
21741 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21742 +       MASK_ENTRY( RLIMIT_NPROC        ) |
21743 +       MASK_ENTRY( RLIMIT_NOFILE       ) |
21744 +       MASK_ENTRY( RLIMIT_LOCKS        ) |
21745 +       MASK_ENTRY( RLIMIT_MSGQUEUE     ) |
21746 +
21747 +       MASK_ENTRY( VLIMIT_NSOCK        ) |
21748 +       MASK_ENTRY( VLIMIT_OPENFD       ) |
21749 +       MASK_ENTRY( VLIMIT_SHMEM        ) |
21750 +       MASK_ENTRY( VLIMIT_DENTRY       ) |
21751 +       0
21752 +};
21753 +               /* accounting only */
21754 +uint32_t account_mask =
21755 +       MASK_ENTRY( VLIMIT_SEMARY       ) |
21756 +       MASK_ENTRY( VLIMIT_NSEMS        ) |
21757 +       MASK_ENTRY( VLIMIT_MAPPED       ) |
21758 +       0;
21759 +
21760 +
21761 +static int is_valid_vlimit(int id)
21762 +{
21763 +       uint32_t mask = vlimit_mask.minimum |
21764 +               vlimit_mask.softlimit | vlimit_mask.maximum;
21765 +       return mask & (1 << id);
21766 +}
21767 +
21768 +static int is_accounted_vlimit(int id)
21769 +{
21770 +       if (is_valid_vlimit(id))
21771 +               return 1;
21772 +       return account_mask & (1 << id);
21773 +}
21774 +
21775 +
21776 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21777 +{
21778 +       rlim_t limit = __rlim_soft(&vxi->limit, id);
21779 +       return VX_VLIM(limit);
21780 +}
21781 +
21782 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21783 +{
21784 +       rlim_t limit = __rlim_hard(&vxi->limit, id);
21785 +       return VX_VLIM(limit);
21786 +}
21787 +
21788 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21789 +       uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21790 +{
21791 +       if (!is_valid_vlimit(id))
21792 +               return -EINVAL;
21793 +
21794 +       if (minimum)
21795 +               *minimum = CRLIM_UNSET;
21796 +       if (softlimit)
21797 +               *softlimit = vc_get_soft(vxi, id);
21798 +       if (maximum)
21799 +               *maximum = vc_get_hard(vxi, id);
21800 +       return 0;
21801 +}
21802 +
21803 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21804 +{
21805 +       struct vcmd_ctx_rlimit_v0 vc_data;
21806 +       int ret;
21807 +
21808 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21809 +               return -EFAULT;
21810 +
21811 +       ret = do_get_rlimit(vxi, vc_data.id,
21812 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21813 +       if (ret)
21814 +               return ret;
21815 +
21816 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21817 +               return -EFAULT;
21818 +       return 0;
21819 +}
21820 +
21821 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21822 +       uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21823 +{
21824 +       if (!is_valid_vlimit(id))
21825 +               return -EINVAL;
21826 +
21827 +       if (maximum != CRLIM_KEEP)
21828 +               __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21829 +       if (softlimit != CRLIM_KEEP)
21830 +               __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21831 +
21832 +       /* clamp soft limit */
21833 +       if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21834 +               __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21835 +
21836 +       return 0;
21837 +}
21838 +
21839 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21840 +{
21841 +       struct vcmd_ctx_rlimit_v0 vc_data;
21842 +
21843 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21844 +               return -EFAULT;
21845 +
21846 +       return do_set_rlimit(vxi, vc_data.id,
21847 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21848 +}
21849 +
21850 +#ifdef CONFIG_IA32_EMULATION
21851 +
21852 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21853 +{
21854 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
21855 +
21856 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21857 +               return -EFAULT;
21858 +
21859 +       return do_set_rlimit(vxi, vc_data.id,
21860 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21861 +}
21862 +
21863 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21864 +{
21865 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
21866 +       int ret;
21867 +
21868 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21869 +               return -EFAULT;
21870 +
21871 +       ret = do_get_rlimit(vxi, vc_data.id,
21872 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21873 +       if (ret)
21874 +               return ret;
21875 +
21876 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21877 +               return -EFAULT;
21878 +       return 0;
21879 +}
21880 +
21881 +#endif /* CONFIG_IA32_EMULATION */
21882 +
21883 +
21884 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21885 +{
21886 +       if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21887 +               return -EFAULT;
21888 +       return 0;
21889 +}
21890 +
21891 +
21892 +static inline void vx_reset_hits(struct _vx_limit *limit)
21893 +{
21894 +       int lim;
21895 +
21896 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
21897 +               atomic_set(&__rlim_lhit(limit, lim), 0);
21898 +       }
21899 +}
21900 +
21901 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
21902 +{
21903 +       vx_reset_hits(&vxi->limit);
21904 +       return 0;
21905 +}
21906 +
21907 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21908 +{
21909 +       rlim_t value;
21910 +       int lim;
21911 +
21912 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
21913 +               value = __rlim_get(limit, lim);
21914 +               __rlim_rmax(limit, lim) = value;
21915 +               __rlim_rmin(limit, lim) = value;
21916 +       }
21917 +}
21918 +
21919 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21920 +{
21921 +       vx_reset_minmax(&vxi->limit);
21922 +       return 0;
21923 +}
21924 +
21925 +
21926 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21927 +{
21928 +       struct vcmd_rlimit_stat_v0 vc_data;
21929 +       struct _vx_limit *limit = &vxi->limit;
21930 +       int id;
21931 +
21932 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21933 +               return -EFAULT;
21934 +
21935 +       id = vc_data.id;
21936 +       if (!is_accounted_vlimit(id))
21937 +               return -EINVAL;
21938 +
21939 +       vx_limit_fixup(limit, id);
21940 +       vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21941 +       vc_data.value = __rlim_get(limit, id);
21942 +       vc_data.minimum = __rlim_rmin(limit, id);
21943 +       vc_data.maximum = __rlim_rmax(limit, id);
21944 +
21945 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21946 +               return -EFAULT;
21947 +       return 0;
21948 +}
21949 +
21950 +
21951 +void vx_vsi_meminfo(struct sysinfo *val)
21952 +{
21953 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21954 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21955 +       u64 res_limit, res_usage;
21956 +
21957 +       if (!mcg)
21958 +               return;
21959 +
21960 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21961 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21962 +
21963 +       if (res_limit != RESOURCE_MAX)
21964 +               val->totalram = (res_limit >> PAGE_SHIFT);
21965 +       val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
21966 +       val->bufferram = 0;
21967 +       val->totalhigh = 0;
21968 +       val->freehigh = 0;
21969 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
21970 +       return;
21971 +}
21972 +
21973 +void vx_vsi_swapinfo(struct sysinfo *val)
21974 +{
21975 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21976 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
21977 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21978 +       u64 res_limit, res_usage, memsw_limit, memsw_usage;
21979 +       s64 swap_limit, swap_usage;
21980 +
21981 +       if (!mcg)
21982 +               return;
21983 +
21984 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21985 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21986 +       memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
21987 +       memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
21988 +
21989 +       if (res_limit == RESOURCE_MAX)
21990 +               return;
21991 +
21992 +       swap_limit = memsw_limit - res_limit;
21993 +       if (memsw_limit != RESOURCE_MAX)
21994 +               val->totalswap = swap_limit >> PAGE_SHIFT;
21995 +
21996 +       swap_usage = memsw_usage - res_usage;
21997 +       val->freeswap = (swap_usage < swap_limit) ?
21998 +               val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
21999 +#else  /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22000 +       val->totalswap = 0;
22001 +       val->freeswap = 0;
22002 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22003 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22004 +       return;
22005 +}
22006 +
22007 +long vx_vsi_cached(struct sysinfo *val)
22008 +{
22009 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22010 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22011 +
22012 +       return mem_cgroup_stat_read_cache(mcg);
22013 +#else
22014 +       return 0;
22015 +#endif
22016 +}
22017 +
22018 +
22019 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22020 +{
22021 +       struct vx_info *vxi = mm->mm_vx_info;
22022 +       unsigned long points;
22023 +       rlim_t v, w;
22024 +
22025 +       if (!vxi)
22026 +               return 0;
22027 +
22028 +       points = vxi->vx_badness_bias;
22029 +
22030 +       v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22031 +       w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22032 +       points += (v > w) ? (v - w) : 0;
22033 +
22034 +       return points;
22035 +}
22036 +
22037 diff -NurpP --minimal linux-2.6.35/kernel/vserver/limit_init.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit_init.h
22038 --- linux-2.6.35/kernel/vserver/limit_init.h    1970-01-01 01:00:00.000000000 +0100
22039 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit_init.h      2010-08-02 17:05:06.000000000 +0200
22040 @@ -0,0 +1,31 @@
22041 +
22042 +
22043 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22044 +{
22045 +       int lim;
22046 +
22047 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22048 +               __rlim_soft(limit, lim) = RLIM_INFINITY;
22049 +               __rlim_hard(limit, lim) = RLIM_INFINITY;
22050 +               __rlim_set(limit, lim, 0);
22051 +               atomic_set(&__rlim_lhit(limit, lim), 0);
22052 +               __rlim_rmin(limit, lim) = 0;
22053 +               __rlim_rmax(limit, lim) = 0;
22054 +       }
22055 +}
22056 +
22057 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22058 +{
22059 +       rlim_t value;
22060 +       int lim;
22061 +
22062 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22063 +               if ((1 << lim) & VLIM_NOCHECK)
22064 +                       continue;
22065 +               value = __rlim_get(limit, lim);
22066 +               vxwprintk_xid(value,
22067 +                       "!!! limit: %p[%s,%d] = %ld on exit.",
22068 +                       limit, vlimit_name[lim], lim, (long)value);
22069 +       }
22070 +}
22071 +
22072 diff -NurpP --minimal linux-2.6.35/kernel/vserver/limit_proc.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit_proc.h
22073 --- linux-2.6.35/kernel/vserver/limit_proc.h    1970-01-01 01:00:00.000000000 +0100
22074 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/limit_proc.h      2010-08-02 17:05:06.000000000 +0200
22075 @@ -0,0 +1,57 @@
22076 +#ifndef _VX_LIMIT_PROC_H
22077 +#define _VX_LIMIT_PROC_H
22078 +
22079 +#include <linux/vserver/limit_int.h>
22080 +
22081 +
22082 +#define VX_LIMIT_FMT   ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22083 +#define VX_LIMIT_TOP   \
22084 +       "Limit\t current\t     min/max\t\t    soft/hard\t\thits\n"
22085 +
22086 +#define VX_LIMIT_ARG(r)                                \
22087 +       (unsigned long)__rlim_get(limit, r),    \
22088 +       (unsigned long)__rlim_rmin(limit, r),   \
22089 +       (unsigned long)__rlim_rmax(limit, r),   \
22090 +       VX_VLIM(__rlim_soft(limit, r)),         \
22091 +       VX_VLIM(__rlim_hard(limit, r)),         \
22092 +       atomic_read(&__rlim_lhit(limit, r))
22093 +
22094 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22095 +{
22096 +       vx_limit_fixup(limit, -1);
22097 +       return sprintf(buffer, VX_LIMIT_TOP
22098 +               "PROC"  VX_LIMIT_FMT
22099 +               "VM"    VX_LIMIT_FMT
22100 +               "VML"   VX_LIMIT_FMT
22101 +               "RSS"   VX_LIMIT_FMT
22102 +               "ANON"  VX_LIMIT_FMT
22103 +               "RMAP"  VX_LIMIT_FMT
22104 +               "FILES" VX_LIMIT_FMT
22105 +               "OFD"   VX_LIMIT_FMT
22106 +               "LOCKS" VX_LIMIT_FMT
22107 +               "SOCK"  VX_LIMIT_FMT
22108 +               "MSGQ"  VX_LIMIT_FMT
22109 +               "SHM"   VX_LIMIT_FMT
22110 +               "SEMA"  VX_LIMIT_FMT
22111 +               "SEMS"  VX_LIMIT_FMT
22112 +               "DENT"  VX_LIMIT_FMT,
22113 +               VX_LIMIT_ARG(RLIMIT_NPROC),
22114 +               VX_LIMIT_ARG(RLIMIT_AS),
22115 +               VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22116 +               VX_LIMIT_ARG(RLIMIT_RSS),
22117 +               VX_LIMIT_ARG(VLIMIT_ANON),
22118 +               VX_LIMIT_ARG(VLIMIT_MAPPED),
22119 +               VX_LIMIT_ARG(RLIMIT_NOFILE),
22120 +               VX_LIMIT_ARG(VLIMIT_OPENFD),
22121 +               VX_LIMIT_ARG(RLIMIT_LOCKS),
22122 +               VX_LIMIT_ARG(VLIMIT_NSOCK),
22123 +               VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22124 +               VX_LIMIT_ARG(VLIMIT_SHMEM),
22125 +               VX_LIMIT_ARG(VLIMIT_SEMARY),
22126 +               VX_LIMIT_ARG(VLIMIT_NSEMS),
22127 +               VX_LIMIT_ARG(VLIMIT_DENTRY));
22128 +}
22129 +
22130 +#endif /* _VX_LIMIT_PROC_H */
22131 +
22132 +
22133 diff -NurpP --minimal linux-2.6.35/kernel/vserver/Makefile linux-2.6.35-vs2.3.0.36.31/kernel/vserver/Makefile
22134 --- linux-2.6.35/kernel/vserver/Makefile        1970-01-01 01:00:00.000000000 +0100
22135 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/Makefile  2010-08-02 17:05:06.000000000 +0200
22136 @@ -0,0 +1,18 @@
22137 +#
22138 +# Makefile for the Linux vserver routines.
22139 +#
22140 +
22141 +
22142 +obj-y          += vserver.o
22143 +
22144 +vserver-y      := switch.o context.o space.o sched.o network.o inode.o \
22145 +                  limit.o cvirt.o cacct.o signal.o helper.o init.o \
22146 +                  dlimit.o tag.o
22147 +
22148 +vserver-$(CONFIG_INET) += inet.o
22149 +vserver-$(CONFIG_PROC_FS) += proc.o
22150 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
22151 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
22152 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
22153 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
22154 +
22155 diff -NurpP --minimal linux-2.6.35/kernel/vserver/monitor.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/monitor.c
22156 --- linux-2.6.35/kernel/vserver/monitor.c       1970-01-01 01:00:00.000000000 +0100
22157 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/monitor.c 2010-08-02 17:05:06.000000000 +0200
22158 @@ -0,0 +1,138 @@
22159 +/*
22160 + *  kernel/vserver/monitor.c
22161 + *
22162 + *  Virtual Context Scheduler Monitor
22163 + *
22164 + *  Copyright (C) 2006-2007 Herbert Pötzl
22165 + *
22166 + *  V0.01  basic design
22167 + *
22168 + */
22169 +
22170 +#include <linux/module.h>
22171 +#include <linux/jiffies.h>
22172 +#include <asm/uaccess.h>
22173 +#include <asm/atomic.h>
22174 +
22175 +#include <linux/vserver/monitor.h>
22176 +#include <linux/vserver/debug_cmd.h>
22177 +
22178 +
22179 +#ifdef CONFIG_VSERVER_MONITOR
22180 +#define VXM_SIZE       CONFIG_VSERVER_MONITOR_SIZE
22181 +#else
22182 +#define VXM_SIZE       64
22183 +#endif
22184 +
22185 +struct _vx_monitor {
22186 +       unsigned int counter;
22187 +
22188 +       struct _vx_mon_entry entry[VXM_SIZE+1];
22189 +};
22190 +
22191 +
22192 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
22193 +
22194 +unsigned volatile int vxm_active = 1;
22195 +
22196 +static atomic_t sequence = ATOMIC_INIT(0);
22197 +
22198 +
22199 +/*     vxm_advance()
22200 +
22201 +       * requires disabled preemption                          */
22202 +
22203 +struct _vx_mon_entry *vxm_advance(int cpu)
22204 +{
22205 +       struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22206 +       struct _vx_mon_entry *entry;
22207 +       unsigned int index;
22208 +
22209 +       index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
22210 +       entry = &mon->entry[index];
22211 +
22212 +       entry->ev.seq = atomic_inc_return(&sequence);
22213 +       entry->ev.jif = jiffies;
22214 +       return entry;
22215 +}
22216 +
22217 +EXPORT_SYMBOL_GPL(vxm_advance);
22218 +
22219 +
22220 +int do_read_monitor(struct __user _vx_mon_entry *data,
22221 +       int cpu, uint32_t *index, uint32_t *count)
22222 +{
22223 +       int pos, ret = 0;
22224 +       struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22225 +       int end = mon->counter;
22226 +       int start = end - VXM_SIZE + 2;
22227 +       int idx = *index;
22228 +
22229 +       /* special case: get current pos */
22230 +       if (!*count) {
22231 +               *index = end;
22232 +               return 0;
22233 +       }
22234 +
22235 +       /* have we lost some data? */
22236 +       if (idx < start)
22237 +               idx = start;
22238 +
22239 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22240 +               struct _vx_mon_entry *entry =
22241 +                       &mon->entry[idx % VXM_SIZE];
22242 +
22243 +               /* send entry to userspace */
22244 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22245 +               if (ret)
22246 +                       break;
22247 +       }
22248 +       /* save new index and count */
22249 +       *index = idx;
22250 +       *count = pos;
22251 +       return ret ? ret : (*index < end);
22252 +}
22253 +
22254 +int vc_read_monitor(uint32_t id, void __user *data)
22255 +{
22256 +       struct vcmd_read_monitor_v0 vc_data;
22257 +       int ret;
22258 +
22259 +       if (id >= NR_CPUS)
22260 +               return -EINVAL;
22261 +
22262 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22263 +               return -EFAULT;
22264 +
22265 +       ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22266 +               id, &vc_data.index, &vc_data.count);
22267 +
22268 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22269 +               return -EFAULT;
22270 +       return ret;
22271 +}
22272 +
22273 +#ifdef CONFIG_COMPAT
22274 +
22275 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22276 +{
22277 +       struct vcmd_read_monitor_v0_x32 vc_data;
22278 +       int ret;
22279 +
22280 +       if (id >= NR_CPUS)
22281 +               return -EINVAL;
22282 +
22283 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22284 +               return -EFAULT;
22285 +
22286 +       ret = do_read_monitor((struct __user _vx_mon_entry *)
22287 +               compat_ptr(vc_data.data_ptr),
22288 +               id, &vc_data.index, &vc_data.count);
22289 +
22290 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22291 +               return -EFAULT;
22292 +       return ret;
22293 +}
22294 +
22295 +#endif /* CONFIG_COMPAT */
22296 +
22297 diff -NurpP --minimal linux-2.6.35/kernel/vserver/network.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/network.c
22298 --- linux-2.6.35/kernel/vserver/network.c       1970-01-01 01:00:00.000000000 +0100
22299 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/network.c 2010-08-02 17:05:06.000000000 +0200
22300 @@ -0,0 +1,864 @@
22301 +/*
22302 + *  linux/kernel/vserver/network.c
22303 + *
22304 + *  Virtual Server: Network Support
22305 + *
22306 + *  Copyright (C) 2003-2007  Herbert Pötzl
22307 + *
22308 + *  V0.01  broken out from vcontext V0.05
22309 + *  V0.02  cleaned up implementation
22310 + *  V0.03  added equiv nx commands
22311 + *  V0.04  switch to RCU based hash
22312 + *  V0.05  and back to locking again
22313 + *  V0.06  changed vcmds to nxi arg
22314 + *  V0.07  have __create claim() the nxi
22315 + *
22316 + */
22317 +
22318 +#include <linux/err.h>
22319 +#include <linux/slab.h>
22320 +#include <linux/rcupdate.h>
22321 +
22322 +#include <linux/vs_network.h>
22323 +#include <linux/vs_pid.h>
22324 +#include <linux/vserver/network_cmd.h>
22325 +
22326 +
22327 +atomic_t nx_global_ctotal      = ATOMIC_INIT(0);
22328 +atomic_t nx_global_cactive     = ATOMIC_INIT(0);
22329 +
22330 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22331 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22332 +
22333 +
22334 +static int __init init_network(void)
22335 +{
22336 +       nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22337 +               sizeof(struct nx_addr_v4), 0,
22338 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22339 +       nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22340 +               sizeof(struct nx_addr_v6), 0,
22341 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22342 +       return 0;
22343 +}
22344 +
22345 +
22346 +/*     __alloc_nx_addr_v4()                                    */
22347 +
22348 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22349 +{
22350 +       struct nx_addr_v4 *nxa = kmem_cache_alloc(
22351 +               nx_addr_v4_cachep, GFP_KERNEL);
22352 +
22353 +       if (!IS_ERR(nxa))
22354 +               memset(nxa, 0, sizeof(*nxa));
22355 +       return nxa;
22356 +}
22357 +
22358 +/*     __dealloc_nx_addr_v4()                                  */
22359 +
22360 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22361 +{
22362 +       kmem_cache_free(nx_addr_v4_cachep, nxa);
22363 +}
22364 +
22365 +/*     __dealloc_nx_addr_v4_all()                              */
22366 +
22367 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22368 +{
22369 +       while (nxa) {
22370 +               struct nx_addr_v4 *next = nxa->next;
22371 +
22372 +               __dealloc_nx_addr_v4(nxa);
22373 +               nxa = next;
22374 +       }
22375 +}
22376 +
22377 +
22378 +#ifdef CONFIG_IPV6
22379 +
22380 +/*     __alloc_nx_addr_v6()                                    */
22381 +
22382 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22383 +{
22384 +       struct nx_addr_v6 *nxa = kmem_cache_alloc(
22385 +               nx_addr_v6_cachep, GFP_KERNEL);
22386 +
22387 +       if (!IS_ERR(nxa))
22388 +               memset(nxa, 0, sizeof(*nxa));
22389 +       return nxa;
22390 +}
22391 +
22392 +/*     __dealloc_nx_addr_v6()                                  */
22393 +
22394 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22395 +{
22396 +       kmem_cache_free(nx_addr_v6_cachep, nxa);
22397 +}
22398 +
22399 +/*     __dealloc_nx_addr_v6_all()                              */
22400 +
22401 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22402 +{
22403 +       while (nxa) {
22404 +               struct nx_addr_v6 *next = nxa->next;
22405 +
22406 +               __dealloc_nx_addr_v6(nxa);
22407 +               nxa = next;
22408 +       }
22409 +}
22410 +
22411 +#endif /* CONFIG_IPV6 */
22412 +
22413 +/*     __alloc_nx_info()
22414 +
22415 +       * allocate an initialized nx_info struct
22416 +       * doesn't make it visible (hash)                        */
22417 +
22418 +static struct nx_info *__alloc_nx_info(nid_t nid)
22419 +{
22420 +       struct nx_info *new = NULL;
22421 +
22422 +       vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22423 +
22424 +       /* would this benefit from a slab cache? */
22425 +       new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22426 +       if (!new)
22427 +               return 0;
22428 +
22429 +       memset(new, 0, sizeof(struct nx_info));
22430 +       new->nx_id = nid;
22431 +       INIT_HLIST_NODE(&new->nx_hlist);
22432 +       atomic_set(&new->nx_usecnt, 0);
22433 +       atomic_set(&new->nx_tasks, 0);
22434 +       new->nx_state = 0;
22435 +
22436 +       new->nx_flags = NXF_INIT_SET;
22437 +
22438 +       /* rest of init goes here */
22439 +
22440 +       new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22441 +       new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22442 +
22443 +       vxdprintk(VXD_CBIT(nid, 0),
22444 +               "alloc_nx_info(%d) = %p", nid, new);
22445 +       atomic_inc(&nx_global_ctotal);
22446 +       return new;
22447 +}
22448 +
22449 +/*     __dealloc_nx_info()
22450 +
22451 +       * final disposal of nx_info                             */
22452 +
22453 +static void __dealloc_nx_info(struct nx_info *nxi)
22454 +{
22455 +       vxdprintk(VXD_CBIT(nid, 0),
22456 +               "dealloc_nx_info(%p)", nxi);
22457 +
22458 +       nxi->nx_hlist.next = LIST_POISON1;
22459 +       nxi->nx_id = -1;
22460 +
22461 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
22462 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22463 +
22464 +       __dealloc_nx_addr_v4_all(nxi->v4.next);
22465 +
22466 +       nxi->nx_state |= NXS_RELEASED;
22467 +       kfree(nxi);
22468 +       atomic_dec(&nx_global_ctotal);
22469 +}
22470 +
22471 +static void __shutdown_nx_info(struct nx_info *nxi)
22472 +{
22473 +       nxi->nx_state |= NXS_SHUTDOWN;
22474 +       vs_net_change(nxi, VSC_NETDOWN);
22475 +}
22476 +
22477 +/*     exported stuff                                          */
22478 +
22479 +void free_nx_info(struct nx_info *nxi)
22480 +{
22481 +       /* context shutdown is mandatory */
22482 +       BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22483 +
22484 +       /* context must not be hashed */
22485 +       BUG_ON(nxi->nx_state & NXS_HASHED);
22486 +
22487 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
22488 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22489 +
22490 +       __dealloc_nx_info(nxi);
22491 +}
22492 +
22493 +
22494 +void __nx_set_lback(struct nx_info *nxi)
22495 +{
22496 +       int nid = nxi->nx_id;
22497 +       __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22498 +
22499 +       nxi->v4_lback.s_addr = lback;
22500 +}
22501 +
22502 +extern int __nx_inet_add_lback(__be32 addr);
22503 +extern int __nx_inet_del_lback(__be32 addr);
22504 +
22505 +
22506 +/*     hash table for nx_info hash */
22507 +
22508 +#define NX_HASH_SIZE   13
22509 +
22510 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22511 +
22512 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22513 +
22514 +
22515 +static inline unsigned int __hashval(nid_t nid)
22516 +{
22517 +       return (nid % NX_HASH_SIZE);
22518 +}
22519 +
22520 +
22521 +
22522 +/*     __hash_nx_info()
22523 +
22524 +       * add the nxi to the global hash table
22525 +       * requires the hash_lock to be held                     */
22526 +
22527 +static inline void __hash_nx_info(struct nx_info *nxi)
22528 +{
22529 +       struct hlist_head *head;
22530 +
22531 +       vxd_assert_lock(&nx_info_hash_lock);
22532 +       vxdprintk(VXD_CBIT(nid, 4),
22533 +               "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22534 +
22535 +       /* context must not be hashed */
22536 +       BUG_ON(nx_info_state(nxi, NXS_HASHED));
22537 +
22538 +       nxi->nx_state |= NXS_HASHED;
22539 +       head = &nx_info_hash[__hashval(nxi->nx_id)];
22540 +       hlist_add_head(&nxi->nx_hlist, head);
22541 +       atomic_inc(&nx_global_cactive);
22542 +}
22543 +
22544 +/*     __unhash_nx_info()
22545 +
22546 +       * remove the nxi from the global hash table
22547 +       * requires the hash_lock to be held                     */
22548 +
22549 +static inline void __unhash_nx_info(struct nx_info *nxi)
22550 +{
22551 +       vxd_assert_lock(&nx_info_hash_lock);
22552 +       vxdprintk(VXD_CBIT(nid, 4),
22553 +               "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22554 +               atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22555 +
22556 +       /* context must be hashed */
22557 +       BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22558 +       /* but without tasks */
22559 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22560 +
22561 +       nxi->nx_state &= ~NXS_HASHED;
22562 +       hlist_del(&nxi->nx_hlist);
22563 +       atomic_dec(&nx_global_cactive);
22564 +}
22565 +
22566 +
22567 +/*     __lookup_nx_info()
22568 +
22569 +       * requires the hash_lock to be held
22570 +       * doesn't increment the nx_refcnt                       */
22571 +
22572 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22573 +{
22574 +       struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22575 +       struct hlist_node *pos;
22576 +       struct nx_info *nxi;
22577 +
22578 +       vxd_assert_lock(&nx_info_hash_lock);
22579 +       hlist_for_each(pos, head) {
22580 +               nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22581 +
22582 +               if (nxi->nx_id == nid)
22583 +                       goto found;
22584 +       }
22585 +       nxi = NULL;
22586 +found:
22587 +       vxdprintk(VXD_CBIT(nid, 0),
22588 +               "__lookup_nx_info(#%u): %p[#%u]",
22589 +               nid, nxi, nxi ? nxi->nx_id : 0);
22590 +       return nxi;
22591 +}
22592 +
22593 +
22594 +/*     __create_nx_info()
22595 +
22596 +       * create the requested context
22597 +       * get(), claim() and hash it                            */
22598 +
22599 +static struct nx_info *__create_nx_info(int id)
22600 +{
22601 +       struct nx_info *new, *nxi = NULL;
22602 +
22603 +       vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22604 +
22605 +       if (!(new = __alloc_nx_info(id)))
22606 +               return ERR_PTR(-ENOMEM);
22607 +
22608 +       /* required to make dynamic xids unique */
22609 +       spin_lock(&nx_info_hash_lock);
22610 +
22611 +       /* static context requested */
22612 +       if ((nxi = __lookup_nx_info(id))) {
22613 +               vxdprintk(VXD_CBIT(nid, 0),
22614 +                       "create_nx_info(%d) = %p (already there)", id, nxi);
22615 +               if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22616 +                       nxi = ERR_PTR(-EBUSY);
22617 +               else
22618 +                       nxi = ERR_PTR(-EEXIST);
22619 +               goto out_unlock;
22620 +       }
22621 +       /* new context */
22622 +       vxdprintk(VXD_CBIT(nid, 0),
22623 +               "create_nx_info(%d) = %p (new)", id, new);
22624 +       claim_nx_info(new, NULL);
22625 +       __nx_set_lback(new);
22626 +       __hash_nx_info(get_nx_info(new));
22627 +       nxi = new, new = NULL;
22628 +
22629 +out_unlock:
22630 +       spin_unlock(&nx_info_hash_lock);
22631 +       if (new)
22632 +               __dealloc_nx_info(new);
22633 +       return nxi;
22634 +}
22635 +
22636 +
22637 +
22638 +/*     exported stuff                                          */
22639 +
22640 +
22641 +void unhash_nx_info(struct nx_info *nxi)
22642 +{
22643 +       __shutdown_nx_info(nxi);
22644 +       spin_lock(&nx_info_hash_lock);
22645 +       __unhash_nx_info(nxi);
22646 +       spin_unlock(&nx_info_hash_lock);
22647 +}
22648 +
22649 +/*     lookup_nx_info()
22650 +
22651 +       * search for a nx_info and get() it
22652 +       * negative id means current                             */
22653 +
22654 +struct nx_info *lookup_nx_info(int id)
22655 +{
22656 +       struct nx_info *nxi = NULL;
22657 +
22658 +       if (id < 0) {
22659 +               nxi = get_nx_info(current_nx_info());
22660 +       } else if (id > 1) {
22661 +               spin_lock(&nx_info_hash_lock);
22662 +               nxi = get_nx_info(__lookup_nx_info(id));
22663 +               spin_unlock(&nx_info_hash_lock);
22664 +       }
22665 +       return nxi;
22666 +}
22667 +
22668 +/*     nid_is_hashed()
22669 +
22670 +       * verify that nid is still hashed                       */
22671 +
22672 +int nid_is_hashed(nid_t nid)
22673 +{
22674 +       int hashed;
22675 +
22676 +       spin_lock(&nx_info_hash_lock);
22677 +       hashed = (__lookup_nx_info(nid) != NULL);
22678 +       spin_unlock(&nx_info_hash_lock);
22679 +       return hashed;
22680 +}
22681 +
22682 +
22683 +#ifdef CONFIG_PROC_FS
22684 +
22685 +/*     get_nid_list()
22686 +
22687 +       * get a subset of hashed nids for proc
22688 +       * assumes size is at least one                          */
22689 +
22690 +int get_nid_list(int index, unsigned int *nids, int size)
22691 +{
22692 +       int hindex, nr_nids = 0;
22693 +
22694 +       /* only show current and children */
22695 +       if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22696 +               if (index > 0)
22697 +                       return 0;
22698 +               nids[nr_nids] = nx_current_nid();
22699 +               return 1;
22700 +       }
22701 +
22702 +       for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22703 +               struct hlist_head *head = &nx_info_hash[hindex];
22704 +               struct hlist_node *pos;
22705 +
22706 +               spin_lock(&nx_info_hash_lock);
22707 +               hlist_for_each(pos, head) {
22708 +                       struct nx_info *nxi;
22709 +
22710 +                       if (--index > 0)
22711 +                               continue;
22712 +
22713 +                       nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22714 +                       nids[nr_nids] = nxi->nx_id;
22715 +                       if (++nr_nids >= size) {
22716 +                               spin_unlock(&nx_info_hash_lock);
22717 +                               goto out;
22718 +                       }
22719 +               }
22720 +               /* keep the lock time short */
22721 +               spin_unlock(&nx_info_hash_lock);
22722 +       }
22723 +out:
22724 +       return nr_nids;
22725 +}
22726 +#endif
22727 +
22728 +
22729 +/*
22730 + *     migrate task to new network
22731 + *     gets nxi, puts old_nxi on change
22732 + */
22733 +
22734 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22735 +{
22736 +       struct nx_info *old_nxi;
22737 +       int ret = 0;
22738 +
22739 +       if (!p || !nxi)
22740 +               BUG();
22741 +
22742 +       vxdprintk(VXD_CBIT(nid, 5),
22743 +               "nx_migrate_task(%p,%p[#%d.%d.%d])",
22744 +               p, nxi, nxi->nx_id,
22745 +               atomic_read(&nxi->nx_usecnt),
22746 +               atomic_read(&nxi->nx_tasks));
22747 +
22748 +       if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22749 +               !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22750 +               return -EACCES;
22751 +
22752 +       if (nx_info_state(nxi, NXS_SHUTDOWN))
22753 +               return -EFAULT;
22754 +
22755 +       /* maybe disallow this completely? */
22756 +       old_nxi = task_get_nx_info(p);
22757 +       if (old_nxi == nxi)
22758 +               goto out;
22759 +
22760 +       task_lock(p);
22761 +       if (old_nxi)
22762 +               clr_nx_info(&p->nx_info);
22763 +       claim_nx_info(nxi, p);
22764 +       set_nx_info(&p->nx_info, nxi);
22765 +       p->nid = nxi->nx_id;
22766 +       task_unlock(p);
22767 +
22768 +       vxdprintk(VXD_CBIT(nid, 5),
22769 +               "moved task %p into nxi:%p[#%d]",
22770 +               p, nxi, nxi->nx_id);
22771 +
22772 +       if (old_nxi)
22773 +               release_nx_info(old_nxi, p);
22774 +       ret = 0;
22775 +out:
22776 +       put_nx_info(old_nxi);
22777 +       return ret;
22778 +}
22779 +
22780 +
22781 +void nx_set_persistent(struct nx_info *nxi)
22782 +{
22783 +       vxdprintk(VXD_CBIT(nid, 6),
22784 +               "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22785 +
22786 +       get_nx_info(nxi);
22787 +       claim_nx_info(nxi, NULL);
22788 +}
22789 +
22790 +void nx_clear_persistent(struct nx_info *nxi)
22791 +{
22792 +       vxdprintk(VXD_CBIT(nid, 6),
22793 +               "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22794 +
22795 +       release_nx_info(nxi, NULL);
22796 +       put_nx_info(nxi);
22797 +}
22798 +
22799 +void nx_update_persistent(struct nx_info *nxi)
22800 +{
22801 +       if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22802 +               nx_set_persistent(nxi);
22803 +       else
22804 +               nx_clear_persistent(nxi);
22805 +}
22806 +
22807 +/* vserver syscall commands below here */
22808 +
22809 +/* taks nid and nx_info functions */
22810 +
22811 +#include <asm/uaccess.h>
22812 +
22813 +
22814 +int vc_task_nid(uint32_t id)
22815 +{
22816 +       nid_t nid;
22817 +
22818 +       if (id) {
22819 +               struct task_struct *tsk;
22820 +
22821 +               read_lock(&tasklist_lock);
22822 +               tsk = find_task_by_real_pid(id);
22823 +               nid = (tsk) ? tsk->nid : -ESRCH;
22824 +               read_unlock(&tasklist_lock);
22825 +       } else
22826 +               nid = nx_current_nid();
22827 +       return nid;
22828 +}
22829 +
22830 +
22831 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22832 +{
22833 +       struct vcmd_nx_info_v0 vc_data;
22834 +
22835 +       vc_data.nid = nxi->nx_id;
22836 +
22837 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22838 +               return -EFAULT;
22839 +       return 0;
22840 +}
22841 +
22842 +
22843 +/* network functions */
22844 +
22845 +int vc_net_create(uint32_t nid, void __user *data)
22846 +{
22847 +       struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22848 +       struct nx_info *new_nxi;
22849 +       int ret;
22850 +
22851 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22852 +               return -EFAULT;
22853 +
22854 +       if ((nid > MAX_S_CONTEXT) || (nid < 2))
22855 +               return -EINVAL;
22856 +
22857 +       new_nxi = __create_nx_info(nid);
22858 +       if (IS_ERR(new_nxi))
22859 +               return PTR_ERR(new_nxi);
22860 +
22861 +       /* initial flags */
22862 +       new_nxi->nx_flags = vc_data.flagword;
22863 +
22864 +       ret = -ENOEXEC;
22865 +       if (vs_net_change(new_nxi, VSC_NETUP))
22866 +               goto out;
22867 +
22868 +       ret = nx_migrate_task(current, new_nxi);
22869 +       if (ret)
22870 +               goto out;
22871 +
22872 +       /* return context id on success */
22873 +       ret = new_nxi->nx_id;
22874 +
22875 +       /* get a reference for persistent contexts */
22876 +       if ((vc_data.flagword & NXF_PERSISTENT))
22877 +               nx_set_persistent(new_nxi);
22878 +out:
22879 +       release_nx_info(new_nxi, NULL);
22880 +       put_nx_info(new_nxi);
22881 +       return ret;
22882 +}
22883 +
22884 +
22885 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22886 +{
22887 +       return nx_migrate_task(current, nxi);
22888 +}
22889 +
22890 +
22891 +
22892 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22893 +       uint16_t type, uint16_t flags)
22894 +{
22895 +       struct nx_addr_v4 *nxa = &nxi->v4;
22896 +
22897 +       if (NX_IPV4(nxi)) {
22898 +               /* locate last entry */
22899 +               for (; nxa->next; nxa = nxa->next);
22900 +               nxa->next = __alloc_nx_addr_v4();
22901 +               nxa = nxa->next;
22902 +
22903 +               if (IS_ERR(nxa))
22904 +                       return PTR_ERR(nxa);
22905 +       }
22906 +
22907 +       if (nxi->v4.next)
22908 +               /* remove single ip for ip list */
22909 +               nxi->nx_flags &= ~NXF_SINGLE_IP;
22910 +
22911 +       nxa->ip[0].s_addr = ip;
22912 +       nxa->ip[1].s_addr = ip2;
22913 +       nxa->mask.s_addr = mask;
22914 +       nxa->type = type;
22915 +       nxa->flags = flags;
22916 +       return 0;
22917 +}
22918 +
22919 +
22920 +int vc_net_add(struct nx_info *nxi, void __user *data)
22921 +{
22922 +       struct vcmd_net_addr_v0 vc_data;
22923 +       int index, ret = 0;
22924 +
22925 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22926 +               return -EFAULT;
22927 +
22928 +       switch (vc_data.type) {
22929 +       case NXA_TYPE_IPV4:
22930 +               if ((vc_data.count < 1) || (vc_data.count > 4))
22931 +                       return -EINVAL;
22932 +
22933 +               index = 0;
22934 +               while (index < vc_data.count) {
22935 +                       ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22936 +                               vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22937 +                       if (ret)
22938 +                               return ret;
22939 +                       index++;
22940 +               }
22941 +               ret = index;
22942 +               break;
22943 +
22944 +       case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22945 +               nxi->v4_bcast = vc_data.ip[0];
22946 +               ret = 1;
22947 +               break;
22948 +
22949 +       case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22950 +               nxi->v4_lback = vc_data.ip[0];
22951 +               ret = 1;
22952 +               break;
22953 +
22954 +       default:
22955 +               ret = -EINVAL;
22956 +               break;
22957 +       }
22958 +       return ret;
22959 +}
22960 +
22961 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22962 +{
22963 +       struct vcmd_net_addr_v0 vc_data;
22964 +
22965 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22966 +               return -EFAULT;
22967 +
22968 +       switch (vc_data.type) {
22969 +       case NXA_TYPE_ANY:
22970 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22971 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
22972 +               break;
22973 +
22974 +       default:
22975 +               return -EINVAL;
22976 +       }
22977 +       return 0;
22978 +}
22979 +
22980 +
22981 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
22982 +{
22983 +       struct vcmd_net_addr_ipv4_v1 vc_data;
22984 +
22985 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22986 +               return -EFAULT;
22987 +
22988 +       switch (vc_data.type) {
22989 +       case NXA_TYPE_ADDR:
22990 +       case NXA_TYPE_RANGE:
22991 +       case NXA_TYPE_MASK:
22992 +               return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22993 +                       vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22994 +
22995 +       case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22996 +               nxi->v4_bcast = vc_data.ip;
22997 +               break;
22998 +
22999 +       case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23000 +               nxi->v4_lback = vc_data.ip;
23001 +               break;
23002 +
23003 +       default:
23004 +               return -EINVAL;
23005 +       }
23006 +       return 0;
23007 +}
23008 +
23009 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
23010 +{
23011 +       struct vcmd_net_addr_ipv4_v1 vc_data;
23012 +
23013 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23014 +               return -EFAULT;
23015 +
23016 +       switch (vc_data.type) {
23017 +/*     case NXA_TYPE_ADDR:
23018 +               break;          */
23019 +
23020 +       case NXA_TYPE_ANY:
23021 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23022 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
23023 +               break;
23024 +
23025 +       default:
23026 +               return -EINVAL;
23027 +       }
23028 +       return 0;
23029 +}
23030 +
23031 +
23032 +#ifdef CONFIG_IPV6
23033 +
23034 +int do_add_v6_addr(struct nx_info *nxi,
23035 +       struct in6_addr *ip, struct in6_addr *mask,
23036 +       uint32_t prefix, uint16_t type, uint16_t flags)
23037 +{
23038 +       struct nx_addr_v6 *nxa = &nxi->v6;
23039 +
23040 +       if (NX_IPV6(nxi)) {
23041 +               /* locate last entry */
23042 +               for (; nxa->next; nxa = nxa->next);
23043 +               nxa->next = __alloc_nx_addr_v6();
23044 +               nxa = nxa->next;
23045 +
23046 +               if (IS_ERR(nxa))
23047 +                       return PTR_ERR(nxa);
23048 +       }
23049 +
23050 +       nxa->ip = *ip;
23051 +       nxa->mask = *mask;
23052 +       nxa->prefix = prefix;
23053 +       nxa->type = type;
23054 +       nxa->flags = flags;
23055 +       return 0;
23056 +}
23057 +
23058 +
23059 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23060 +{
23061 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23062 +
23063 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23064 +               return -EFAULT;
23065 +
23066 +       switch (vc_data.type) {
23067 +       case NXA_TYPE_ADDR:
23068 +       case NXA_TYPE_MASK:
23069 +               return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23070 +                       vc_data.prefix, vc_data.type, vc_data.flags);
23071 +       default:
23072 +               return -EINVAL;
23073 +       }
23074 +       return 0;
23075 +}
23076 +
23077 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23078 +{
23079 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23080 +
23081 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23082 +               return -EFAULT;
23083 +
23084 +       switch (vc_data.type) {
23085 +       case NXA_TYPE_ANY:
23086 +               __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23087 +               memset(&nxi->v6, 0, sizeof(nxi->v6));
23088 +               break;
23089 +
23090 +       default:
23091 +               return -EINVAL;
23092 +       }
23093 +       return 0;
23094 +}
23095 +
23096 +#endif /* CONFIG_IPV6 */
23097 +
23098 +
23099 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23100 +{
23101 +       struct vcmd_net_flags_v0 vc_data;
23102 +
23103 +       vc_data.flagword = nxi->nx_flags;
23104 +
23105 +       /* special STATE flag handling */
23106 +       vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23107 +
23108 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23109 +               return -EFAULT;
23110 +       return 0;
23111 +}
23112 +
23113 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23114 +{
23115 +       struct vcmd_net_flags_v0 vc_data;
23116 +       uint64_t mask, trigger;
23117 +
23118 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23119 +               return -EFAULT;
23120 +
23121 +       /* special STATE flag handling */
23122 +       mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23123 +       trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23124 +
23125 +       nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23126 +               vc_data.flagword, mask);
23127 +       if (trigger & NXF_PERSISTENT)
23128 +               nx_update_persistent(nxi);
23129 +
23130 +       return 0;
23131 +}
23132 +
23133 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23134 +{
23135 +       struct vcmd_net_caps_v0 vc_data;
23136 +
23137 +       vc_data.ncaps = nxi->nx_ncaps;
23138 +       vc_data.cmask = ~0ULL;
23139 +
23140 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23141 +               return -EFAULT;
23142 +       return 0;
23143 +}
23144 +
23145 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23146 +{
23147 +       struct vcmd_net_caps_v0 vc_data;
23148 +
23149 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23150 +               return -EFAULT;
23151 +
23152 +       nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23153 +               vc_data.ncaps, vc_data.cmask);
23154 +       return 0;
23155 +}
23156 +
23157 +
23158 +#include <linux/module.h>
23159 +
23160 +module_init(init_network);
23161 +
23162 +EXPORT_SYMBOL_GPL(free_nx_info);
23163 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23164 +
23165 diff -NurpP --minimal linux-2.6.35/kernel/vserver/proc.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/proc.c
23166 --- linux-2.6.35/kernel/vserver/proc.c  1970-01-01 01:00:00.000000000 +0100
23167 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/proc.c    2010-08-02 17:05:06.000000000 +0200
23168 @@ -0,0 +1,1098 @@
23169 +/*
23170 + *  linux/kernel/vserver/proc.c
23171 + *
23172 + *  Virtual Context Support
23173 + *
23174 + *  Copyright (C) 2003-2007  Herbert Pötzl
23175 + *
23176 + *  V0.01  basic structure
23177 + *  V0.02  adaptation vs1.3.0
23178 + *  V0.03  proc permissions
23179 + *  V0.04  locking/generic
23180 + *  V0.05  next generation procfs
23181 + *  V0.06  inode validation
23182 + *  V0.07  generic rewrite vid
23183 + *  V0.08  remove inode type
23184 + *
23185 + */
23186 +
23187 +#include <linux/proc_fs.h>
23188 +#include <linux/fs_struct.h>
23189 +#include <linux/mount.h>
23190 +#include <asm/unistd.h>
23191 +
23192 +#include <linux/vs_context.h>
23193 +#include <linux/vs_network.h>
23194 +#include <linux/vs_cvirt.h>
23195 +
23196 +#include <linux/in.h>
23197 +#include <linux/inetdevice.h>
23198 +#include <linux/vs_inet.h>
23199 +#include <linux/vs_inet6.h>
23200 +
23201 +#include <linux/vserver/global.h>
23202 +
23203 +#include "cvirt_proc.h"
23204 +#include "cacct_proc.h"
23205 +#include "limit_proc.h"
23206 +#include "sched_proc.h"
23207 +#include "vci_config.h"
23208 +
23209 +
23210 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23211 +{
23212 +       unsigned __capi;
23213 +
23214 +       CAP_FOR_EACH_U32(__capi) {
23215 +               buffer += sprintf(buffer, "%08x",
23216 +                       c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23217 +       }
23218 +       return buffer;
23219 +}
23220 +
23221 +
23222 +static struct proc_dir_entry *proc_virtual;
23223 +
23224 +static struct proc_dir_entry *proc_virtnet;
23225 +
23226 +
23227 +/* first the actual feeds */
23228 +
23229 +
23230 +static int proc_vci(char *buffer)
23231 +{
23232 +       return sprintf(buffer,
23233 +               "VCIVersion:\t%04x:%04x\n"
23234 +               "VCISyscall:\t%d\n"
23235 +               "VCIKernel:\t%08x\n",
23236 +               VCI_VERSION >> 16,
23237 +               VCI_VERSION & 0xFFFF,
23238 +               __NR_vserver,
23239 +               vci_kernel_config());
23240 +}
23241 +
23242 +static int proc_virtual_info(char *buffer)
23243 +{
23244 +       return proc_vci(buffer);
23245 +}
23246 +
23247 +static int proc_virtual_status(char *buffer)
23248 +{
23249 +       return sprintf(buffer,
23250 +               "#CTotal:\t%d\n"
23251 +               "#CActive:\t%d\n"
23252 +               "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23253 +               "#InitTask:\t%d\t%d %d\n",
23254 +               atomic_read(&vx_global_ctotal),
23255 +               atomic_read(&vx_global_cactive),
23256 +               atomic_read(&vs_global_nsproxy),
23257 +               atomic_read(&vs_global_fs),
23258 +               atomic_read(&vs_global_mnt_ns),
23259 +               atomic_read(&vs_global_uts_ns),
23260 +               atomic_read(&nr_ipc_ns),
23261 +               atomic_read(&vs_global_user_ns),
23262 +               atomic_read(&vs_global_pid_ns),
23263 +               atomic_read(&init_task.usage),
23264 +               atomic_read(&init_task.nsproxy->count),
23265 +               init_task.fs->users);
23266 +}
23267 +
23268 +
23269 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23270 +{
23271 +       int length;
23272 +
23273 +       length = sprintf(buffer,
23274 +               "ID:\t%d\n"
23275 +               "Info:\t%p\n"
23276 +               "Init:\t%d\n"
23277 +               "OOM:\t%lld\n",
23278 +               vxi->vx_id,
23279 +               vxi,
23280 +               vxi->vx_initpid,
23281 +               vxi->vx_badness_bias);
23282 +       return length;
23283 +}
23284 +
23285 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23286 +{
23287 +       char *orig = buffer;
23288 +
23289 +       buffer += sprintf(buffer,
23290 +               "UseCnt:\t%d\n"
23291 +               "Tasks:\t%d\n"
23292 +               "Flags:\t%016llx\n",
23293 +               atomic_read(&vxi->vx_usecnt),
23294 +               atomic_read(&vxi->vx_tasks),
23295 +               (unsigned long long)vxi->vx_flags);
23296 +
23297 +       buffer += sprintf(buffer, "BCaps:\t");
23298 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23299 +       buffer += sprintf(buffer, "\n");
23300 +
23301 +       buffer += sprintf(buffer,
23302 +               "CCaps:\t%016llx\n"
23303 +               "Spaces:\t%08lx %08lx\n",
23304 +               (unsigned long long)vxi->vx_ccaps,
23305 +               vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
23306 +       return buffer - orig;
23307 +}
23308 +
23309 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23310 +{
23311 +       return vx_info_proc_limit(&vxi->limit, buffer);
23312 +}
23313 +
23314 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23315 +{
23316 +       int cpu, length;
23317 +
23318 +       length = vx_info_proc_sched(&vxi->sched, buffer);
23319 +       for_each_online_cpu(cpu) {
23320 +               length += vx_info_proc_sched_pc(
23321 +                       &vx_per_cpu(vxi, sched_pc, cpu),
23322 +                       buffer + length, cpu);
23323 +       }
23324 +       return length;
23325 +}
23326 +
23327 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23328 +{
23329 +       return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
23330 +}
23331 +
23332 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23333 +{
23334 +       return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
23335 +}
23336 +
23337 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23338 +{
23339 +       int cpu, length;
23340 +
23341 +       vx_update_load(vxi);
23342 +       length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23343 +       for_each_online_cpu(cpu) {
23344 +               length += vx_info_proc_cvirt_pc(
23345 +                       &vx_per_cpu(vxi, cvirt_pc, cpu),
23346 +                       buffer + length, cpu);
23347 +       }
23348 +       return length;
23349 +}
23350 +
23351 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23352 +{
23353 +       return vx_info_proc_cacct(&vxi->cacct, buffer);
23354 +}
23355 +
23356 +
23357 +static int proc_virtnet_info(char *buffer)
23358 +{
23359 +       return proc_vci(buffer);
23360 +}
23361 +
23362 +static int proc_virtnet_status(char *buffer)
23363 +{
23364 +       return sprintf(buffer,
23365 +               "#CTotal:\t%d\n"
23366 +               "#CActive:\t%d\n",
23367 +               atomic_read(&nx_global_ctotal),
23368 +               atomic_read(&nx_global_cactive));
23369 +}
23370 +
23371 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23372 +{
23373 +       struct nx_addr_v4 *v4a;
23374 +#ifdef CONFIG_IPV6
23375 +       struct nx_addr_v6 *v6a;
23376 +#endif
23377 +       int length, i;
23378 +
23379 +       length = sprintf(buffer,
23380 +               "ID:\t%d\n"
23381 +               "Info:\t%p\n"
23382 +               "Bcast:\t" NIPQUAD_FMT "\n"
23383 +               "Lback:\t" NIPQUAD_FMT "\n",
23384 +               nxi->nx_id,
23385 +               nxi,
23386 +               NIPQUAD(nxi->v4_bcast.s_addr),
23387 +               NIPQUAD(nxi->v4_lback.s_addr));
23388 +
23389 +       if (!NX_IPV4(nxi))
23390 +               goto skip_v4;
23391 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23392 +               length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23393 +                       i, NXAV4(v4a));
23394 +skip_v4:
23395 +#ifdef CONFIG_IPV6
23396 +       if (!NX_IPV6(nxi))
23397 +               goto skip_v6;
23398 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23399 +               length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23400 +                       i, NXAV6(v6a));
23401 +skip_v6:
23402 +#endif
23403 +       return length;
23404 +}
23405 +
23406 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23407 +{
23408 +       int length;
23409 +
23410 +       length = sprintf(buffer,
23411 +               "UseCnt:\t%d\n"
23412 +               "Tasks:\t%d\n"
23413 +               "Flags:\t%016llx\n"
23414 +               "NCaps:\t%016llx\n",
23415 +               atomic_read(&nxi->nx_usecnt),
23416 +               atomic_read(&nxi->nx_tasks),
23417 +               (unsigned long long)nxi->nx_flags,
23418 +               (unsigned long long)nxi->nx_ncaps);
23419 +       return length;
23420 +}
23421 +
23422 +
23423 +
23424 +/* here the inode helpers */
23425 +
23426 +struct vs_entry {
23427 +       int len;
23428 +       char *name;
23429 +       mode_t mode;
23430 +       struct inode_operations *iop;
23431 +       struct file_operations *fop;
23432 +       union proc_op op;
23433 +};
23434 +
23435 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23436 +{
23437 +       struct inode *inode = new_inode(sb);
23438 +
23439 +       if (!inode)
23440 +               goto out;
23441 +
23442 +       inode->i_mode = p->mode;
23443 +       if (p->iop)
23444 +               inode->i_op = p->iop;
23445 +       if (p->fop)
23446 +               inode->i_fop = p->fop;
23447 +
23448 +       inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23449 +       inode->i_flags |= S_IMMUTABLE;
23450 +
23451 +       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23452 +
23453 +       inode->i_uid = 0;
23454 +       inode->i_gid = 0;
23455 +       inode->i_tag = 0;
23456 +out:
23457 +       return inode;
23458 +}
23459 +
23460 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23461 +       struct dentry *dentry, int id, void *ptr)
23462 +{
23463 +       struct vs_entry *p = ptr;
23464 +       struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23465 +       struct dentry *error = ERR_PTR(-EINVAL);
23466 +
23467 +       if (!inode)
23468 +               goto out;
23469 +
23470 +       PROC_I(inode)->op = p->op;
23471 +       PROC_I(inode)->fd = id;
23472 +       d_add(dentry, inode);
23473 +       error = NULL;
23474 +out:
23475 +       return error;
23476 +}
23477 +
23478 +/* Lookups */
23479 +
23480 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23481 +
23482 +/*
23483 + * Fill a directory entry.
23484 + *
23485 + * If possible create the dcache entry and derive our inode number and
23486 + * file type from dcache entry.
23487 + *
23488 + * Since all of the proc inode numbers are dynamically generated, the inode
23489 + * numbers do not exist until the inode is cache.  This means creating the
23490 + * the dcache entry in readdir is necessary to keep the inode numbers
23491 + * reported by readdir in sync with the inode numbers reported
23492 + * by stat.
23493 + */
23494 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23495 +       char *name, int len, instantiate_t instantiate, int id, void *ptr)
23496 +{
23497 +       struct dentry *child, *dir = filp->f_dentry;
23498 +       struct inode *inode;
23499 +       struct qstr qname;
23500 +       ino_t ino = 0;
23501 +       unsigned type = DT_UNKNOWN;
23502 +
23503 +       qname.name = name;
23504 +       qname.len  = len;
23505 +       qname.hash = full_name_hash(name, len);
23506 +
23507 +       child = d_lookup(dir, &qname);
23508 +       if (!child) {
23509 +               struct dentry *new;
23510 +               new = d_alloc(dir, &qname);
23511 +               if (new) {
23512 +                       child = instantiate(dir->d_inode, new, id, ptr);
23513 +                       if (child)
23514 +                               dput(new);
23515 +                       else
23516 +                               child = new;
23517 +               }
23518 +       }
23519 +       if (!child || IS_ERR(child) || !child->d_inode)
23520 +               goto end_instantiate;
23521 +       inode = child->d_inode;
23522 +       if (inode) {
23523 +               ino = inode->i_ino;
23524 +               type = inode->i_mode >> 12;
23525 +       }
23526 +       dput(child);
23527 +end_instantiate:
23528 +       if (!ino)
23529 +               ino = find_inode_number(dir, &qname);
23530 +       if (!ino)
23531 +               ino = 1;
23532 +       return filldir(dirent, name, len, filp->f_pos, ino, type);
23533 +}
23534 +
23535 +
23536 +
23537 +/* get and revalidate vx_info/xid */
23538 +
23539 +static inline
23540 +struct vx_info *get_proc_vx_info(struct inode *inode)
23541 +{
23542 +       return lookup_vx_info(PROC_I(inode)->fd);
23543 +}
23544 +
23545 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23546 +{
23547 +       struct inode *inode = dentry->d_inode;
23548 +       xid_t xid = PROC_I(inode)->fd;
23549 +
23550 +       if (!xid || xid_is_hashed(xid))
23551 +               return 1;
23552 +       d_drop(dentry);
23553 +       return 0;
23554 +}
23555 +
23556 +
23557 +/* get and revalidate nx_info/nid */
23558 +
23559 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23560 +{
23561 +       struct inode *inode = dentry->d_inode;
23562 +       nid_t nid = PROC_I(inode)->fd;
23563 +
23564 +       if (!nid || nid_is_hashed(nid))
23565 +               return 1;
23566 +       d_drop(dentry);
23567 +       return 0;
23568 +}
23569 +
23570 +
23571 +
23572 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23573 +
23574 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23575 +                         size_t count, loff_t *ppos)
23576 +{
23577 +       struct inode *inode = file->f_dentry->d_inode;
23578 +       unsigned long page;
23579 +       ssize_t length = 0;
23580 +
23581 +       if (count > PROC_BLOCK_SIZE)
23582 +               count = PROC_BLOCK_SIZE;
23583 +
23584 +       /* fade that out as soon as stable */
23585 +       WARN_ON(PROC_I(inode)->fd);
23586 +
23587 +       if (!(page = __get_free_page(GFP_KERNEL)))
23588 +               return -ENOMEM;
23589 +
23590 +       BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23591 +       length = PROC_I(inode)->op.proc_vs_read((char *)page);
23592 +
23593 +       if (length >= 0)
23594 +               length = simple_read_from_buffer(buf, count, ppos,
23595 +                       (char *)page, length);
23596 +
23597 +       free_page(page);
23598 +       return length;
23599 +}
23600 +
23601 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23602 +                         size_t count, loff_t *ppos)
23603 +{
23604 +       struct inode *inode = file->f_dentry->d_inode;
23605 +       struct vx_info *vxi = NULL;
23606 +       xid_t xid = PROC_I(inode)->fd;
23607 +       unsigned long page;
23608 +       ssize_t length = 0;
23609 +
23610 +       if (count > PROC_BLOCK_SIZE)
23611 +               count = PROC_BLOCK_SIZE;
23612 +
23613 +       /* fade that out as soon as stable */
23614 +       WARN_ON(!xid);
23615 +       vxi = lookup_vx_info(xid);
23616 +       if (!vxi)
23617 +               goto out;
23618 +
23619 +       length = -ENOMEM;
23620 +       if (!(page = __get_free_page(GFP_KERNEL)))
23621 +               goto out_put;
23622 +
23623 +       BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23624 +       length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23625 +
23626 +       if (length >= 0)
23627 +               length = simple_read_from_buffer(buf, count, ppos,
23628 +                       (char *)page, length);
23629 +
23630 +       free_page(page);
23631 +out_put:
23632 +       put_vx_info(vxi);
23633 +out:
23634 +       return length;
23635 +}
23636 +
23637 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23638 +                         size_t count, loff_t *ppos)
23639 +{
23640 +       struct inode *inode = file->f_dentry->d_inode;
23641 +       struct nx_info *nxi = NULL;
23642 +       nid_t nid = PROC_I(inode)->fd;
23643 +       unsigned long page;
23644 +       ssize_t length = 0;
23645 +
23646 +       if (count > PROC_BLOCK_SIZE)
23647 +               count = PROC_BLOCK_SIZE;
23648 +
23649 +       /* fade that out as soon as stable */
23650 +       WARN_ON(!nid);
23651 +       nxi = lookup_nx_info(nid);
23652 +       if (!nxi)
23653 +               goto out;
23654 +
23655 +       length = -ENOMEM;
23656 +       if (!(page = __get_free_page(GFP_KERNEL)))
23657 +               goto out_put;
23658 +
23659 +       BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23660 +       length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23661 +
23662 +       if (length >= 0)
23663 +               length = simple_read_from_buffer(buf, count, ppos,
23664 +                       (char *)page, length);
23665 +
23666 +       free_page(page);
23667 +out_put:
23668 +       put_nx_info(nxi);
23669 +out:
23670 +       return length;
23671 +}
23672 +
23673 +
23674 +
23675 +/* here comes the lower level */
23676 +
23677 +
23678 +#define NOD(NAME, MODE, IOP, FOP, OP) {        \
23679 +       .len  = sizeof(NAME) - 1,       \
23680 +       .name = (NAME),                 \
23681 +       .mode = MODE,                   \
23682 +       .iop  = IOP,                    \
23683 +       .fop  = FOP,                    \
23684 +       .op   = OP,                     \
23685 +}
23686 +
23687 +
23688 +#define DIR(NAME, MODE, OTYPE)                         \
23689 +       NOD(NAME, (S_IFDIR | (MODE)),                   \
23690 +               &proc_ ## OTYPE ## _inode_operations,   \
23691 +               &proc_ ## OTYPE ## _file_operations, { } )
23692 +
23693 +#define INF(NAME, MODE, OTYPE)                         \
23694 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23695 +               &proc_vs_info_file_operations,          \
23696 +               { .proc_vs_read = &proc_##OTYPE } )
23697 +
23698 +#define VINF(NAME, MODE, OTYPE)                                \
23699 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23700 +               &proc_vx_info_file_operations,          \
23701 +               { .proc_vxi_read = &proc_##OTYPE } )
23702 +
23703 +#define NINF(NAME, MODE, OTYPE)                                \
23704 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23705 +               &proc_nx_info_file_operations,          \
23706 +               { .proc_nxi_read = &proc_##OTYPE } )
23707 +
23708 +
23709 +static struct file_operations proc_vs_info_file_operations = {
23710 +       .read =         proc_vs_info_read,
23711 +};
23712 +
23713 +static struct file_operations proc_vx_info_file_operations = {
23714 +       .read =         proc_vx_info_read,
23715 +};
23716 +
23717 +static struct dentry_operations proc_xid_dentry_operations = {
23718 +       .d_revalidate = proc_xid_revalidate,
23719 +};
23720 +
23721 +static struct vs_entry vx_base_stuff[] = {
23722 +       VINF("info",    S_IRUGO, vxi_info),
23723 +       VINF("status",  S_IRUGO, vxi_status),
23724 +       VINF("limit",   S_IRUGO, vxi_limit),
23725 +       VINF("sched",   S_IRUGO, vxi_sched),
23726 +       VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23727 +       VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23728 +       VINF("cvirt",   S_IRUGO, vxi_cvirt),
23729 +       VINF("cacct",   S_IRUGO, vxi_cacct),
23730 +       {}
23731 +};
23732 +
23733 +
23734 +
23735 +
23736 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23737 +       struct dentry *dentry, int id, void *ptr)
23738 +{
23739 +       dentry->d_op = &proc_xid_dentry_operations;
23740 +       return vs_proc_instantiate(dir, dentry, id, ptr);
23741 +}
23742 +
23743 +static struct dentry *proc_xid_lookup(struct inode *dir,
23744 +       struct dentry *dentry, struct nameidata *nd)
23745 +{
23746 +       struct vs_entry *p = vx_base_stuff;
23747 +       struct dentry *error = ERR_PTR(-ENOENT);
23748 +
23749 +       for (; p->name; p++) {
23750 +               if (p->len != dentry->d_name.len)
23751 +                       continue;
23752 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23753 +                       break;
23754 +       }
23755 +       if (!p->name)
23756 +               goto out;
23757 +
23758 +       error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23759 +out:
23760 +       return error;
23761 +}
23762 +
23763 +static int proc_xid_readdir(struct file *filp,
23764 +       void *dirent, filldir_t filldir)
23765 +{
23766 +       struct dentry *dentry = filp->f_dentry;
23767 +       struct inode *inode = dentry->d_inode;
23768 +       struct vs_entry *p = vx_base_stuff;
23769 +       int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23770 +       int pos, index;
23771 +       u64 ino;
23772 +
23773 +       pos = filp->f_pos;
23774 +       switch (pos) {
23775 +       case 0:
23776 +               ino = inode->i_ino;
23777 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23778 +                       goto out;
23779 +               pos++;
23780 +               /* fall through */
23781 +       case 1:
23782 +               ino = parent_ino(dentry);
23783 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23784 +                       goto out;
23785 +               pos++;
23786 +               /* fall through */
23787 +       default:
23788 +               index = pos - 2;
23789 +               if (index >= size)
23790 +                       goto out;
23791 +               for (p += index; p->name; p++) {
23792 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23793 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
23794 +                               goto out;
23795 +                       pos++;
23796 +               }
23797 +       }
23798 +out:
23799 +       filp->f_pos = pos;
23800 +       return 1;
23801 +}
23802 +
23803 +
23804 +
23805 +static struct file_operations proc_nx_info_file_operations = {
23806 +       .read =         proc_nx_info_read,
23807 +};
23808 +
23809 +static struct dentry_operations proc_nid_dentry_operations = {
23810 +       .d_revalidate = proc_nid_revalidate,
23811 +};
23812 +
23813 +static struct vs_entry nx_base_stuff[] = {
23814 +       NINF("info",    S_IRUGO, nxi_info),
23815 +       NINF("status",  S_IRUGO, nxi_status),
23816 +       {}
23817 +};
23818 +
23819 +
23820 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23821 +       struct dentry *dentry, int id, void *ptr)
23822 +{
23823 +       dentry->d_op = &proc_nid_dentry_operations;
23824 +       return vs_proc_instantiate(dir, dentry, id, ptr);
23825 +}
23826 +
23827 +static struct dentry *proc_nid_lookup(struct inode *dir,
23828 +       struct dentry *dentry, struct nameidata *nd)
23829 +{
23830 +       struct vs_entry *p = nx_base_stuff;
23831 +       struct dentry *error = ERR_PTR(-ENOENT);
23832 +
23833 +       for (; p->name; p++) {
23834 +               if (p->len != dentry->d_name.len)
23835 +                       continue;
23836 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23837 +                       break;
23838 +       }
23839 +       if (!p->name)
23840 +               goto out;
23841 +
23842 +       error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23843 +out:
23844 +       return error;
23845 +}
23846 +
23847 +static int proc_nid_readdir(struct file *filp,
23848 +       void *dirent, filldir_t filldir)
23849 +{
23850 +       struct dentry *dentry = filp->f_dentry;
23851 +       struct inode *inode = dentry->d_inode;
23852 +       struct vs_entry *p = nx_base_stuff;
23853 +       int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23854 +       int pos, index;
23855 +       u64 ino;
23856 +
23857 +       pos = filp->f_pos;
23858 +       switch (pos) {
23859 +       case 0:
23860 +               ino = inode->i_ino;
23861 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23862 +                       goto out;
23863 +               pos++;
23864 +               /* fall through */
23865 +       case 1:
23866 +               ino = parent_ino(dentry);
23867 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23868 +                       goto out;
23869 +               pos++;
23870 +               /* fall through */
23871 +       default:
23872 +               index = pos - 2;
23873 +               if (index >= size)
23874 +                       goto out;
23875 +               for (p += index; p->name; p++) {
23876 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23877 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
23878 +                               goto out;
23879 +                       pos++;
23880 +               }
23881 +       }
23882 +out:
23883 +       filp->f_pos = pos;
23884 +       return 1;
23885 +}
23886 +
23887 +
23888 +#define MAX_MULBY10    ((~0U - 9) / 10)
23889 +
23890 +static inline int atovid(const char *str, int len)
23891 +{
23892 +       int vid, c;
23893 +
23894 +       vid = 0;
23895 +       while (len-- > 0) {
23896 +               c = *str - '0';
23897 +               str++;
23898 +               if (c > 9)
23899 +                       return -1;
23900 +               if (vid >= MAX_MULBY10)
23901 +                       return -1;
23902 +               vid *= 10;
23903 +               vid += c;
23904 +               if (!vid)
23905 +                       return -1;
23906 +       }
23907 +       return vid;
23908 +}
23909 +
23910 +/* now the upper level (virtual) */
23911 +
23912 +
23913 +static struct file_operations proc_xid_file_operations = {
23914 +       .read =         generic_read_dir,
23915 +       .readdir =      proc_xid_readdir,
23916 +};
23917 +
23918 +static struct inode_operations proc_xid_inode_operations = {
23919 +       .lookup =       proc_xid_lookup,
23920 +};
23921 +
23922 +static struct vs_entry vx_virtual_stuff[] = {
23923 +       INF("info",     S_IRUGO, virtual_info),
23924 +       INF("status",   S_IRUGO, virtual_status),
23925 +       DIR(NULL,       S_IRUGO | S_IXUGO, xid),
23926 +};
23927 +
23928 +
23929 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23930 +       struct dentry *dentry, struct nameidata *nd)
23931 +{
23932 +       struct vs_entry *p = vx_virtual_stuff;
23933 +       struct dentry *error = ERR_PTR(-ENOENT);
23934 +       int id = 0;
23935 +
23936 +       for (; p->name; p++) {
23937 +               if (p->len != dentry->d_name.len)
23938 +                       continue;
23939 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23940 +                       break;
23941 +       }
23942 +       if (p->name)
23943 +               goto instantiate;
23944 +
23945 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
23946 +       if ((id < 0) || !xid_is_hashed(id))
23947 +               goto out;
23948 +
23949 +instantiate:
23950 +       error = proc_xid_instantiate(dir, dentry, id, p);
23951 +out:
23952 +       return error;
23953 +}
23954 +
23955 +static struct file_operations proc_nid_file_operations = {
23956 +       .read =         generic_read_dir,
23957 +       .readdir =      proc_nid_readdir,
23958 +};
23959 +
23960 +static struct inode_operations proc_nid_inode_operations = {
23961 +       .lookup =       proc_nid_lookup,
23962 +};
23963 +
23964 +static struct vs_entry nx_virtnet_stuff[] = {
23965 +       INF("info",     S_IRUGO, virtnet_info),
23966 +       INF("status",   S_IRUGO, virtnet_status),
23967 +       DIR(NULL,       S_IRUGO | S_IXUGO, nid),
23968 +};
23969 +
23970 +
23971 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23972 +       struct dentry *dentry, struct nameidata *nd)
23973 +{
23974 +       struct vs_entry *p = nx_virtnet_stuff;
23975 +       struct dentry *error = ERR_PTR(-ENOENT);
23976 +       int id = 0;
23977 +
23978 +       for (; p->name; p++) {
23979 +               if (p->len != dentry->d_name.len)
23980 +                       continue;
23981 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23982 +                       break;
23983 +       }
23984 +       if (p->name)
23985 +               goto instantiate;
23986 +
23987 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
23988 +       if ((id < 0) || !nid_is_hashed(id))
23989 +               goto out;
23990 +
23991 +instantiate:
23992 +       error = proc_nid_instantiate(dir, dentry, id, p);
23993 +out:
23994 +       return error;
23995 +}
23996 +
23997 +
23998 +#define PROC_MAXVIDS 32
23999 +
24000 +int proc_virtual_readdir(struct file *filp,
24001 +       void *dirent, filldir_t filldir)
24002 +{
24003 +       struct dentry *dentry = filp->f_dentry;
24004 +       struct inode *inode = dentry->d_inode;
24005 +       struct vs_entry *p = vx_virtual_stuff;
24006 +       int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24007 +       int pos, index;
24008 +       unsigned int xid_array[PROC_MAXVIDS];
24009 +       char buf[PROC_NUMBUF];
24010 +       unsigned int nr_xids, i;
24011 +       u64 ino;
24012 +
24013 +       pos = filp->f_pos;
24014 +       switch (pos) {
24015 +       case 0:
24016 +               ino = inode->i_ino;
24017 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24018 +                       goto out;
24019 +               pos++;
24020 +               /* fall through */
24021 +       case 1:
24022 +               ino = parent_ino(dentry);
24023 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24024 +                       goto out;
24025 +               pos++;
24026 +               /* fall through */
24027 +       default:
24028 +               index = pos - 2;
24029 +               if (index >= size)
24030 +                       goto entries;
24031 +               for (p += index; p->name; p++) {
24032 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24033 +                               vs_proc_instantiate, 0, p))
24034 +                               goto out;
24035 +                       pos++;
24036 +               }
24037 +       entries:
24038 +               index = pos - size;
24039 +               p = &vx_virtual_stuff[size - 1];
24040 +               nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24041 +               for (i = 0; i < nr_xids; i++) {
24042 +                       int n, xid = xid_array[i];
24043 +                       unsigned int j = PROC_NUMBUF;
24044 +
24045 +                       n = xid;
24046 +                       do
24047 +                               buf[--j] = '0' + (n % 10);
24048 +                       while (n /= 10);
24049 +
24050 +                       if (proc_fill_cache(filp, dirent, filldir,
24051 +                               buf + j, PROC_NUMBUF - j,
24052 +                               vs_proc_instantiate, xid, p))
24053 +                               goto out;
24054 +                       pos++;
24055 +               }
24056 +       }
24057 +out:
24058 +       filp->f_pos = pos;
24059 +       return 0;
24060 +}
24061 +
24062 +static int proc_virtual_getattr(struct vfsmount *mnt,
24063 +       struct dentry *dentry, struct kstat *stat)
24064 +{
24065 +       struct inode *inode = dentry->d_inode;
24066 +
24067 +       generic_fillattr(inode, stat);
24068 +       stat->nlink = 2 + atomic_read(&vx_global_cactive);
24069 +       return 0;
24070 +}
24071 +
24072 +static struct file_operations proc_virtual_dir_operations = {
24073 +       .read =         generic_read_dir,
24074 +       .readdir =      proc_virtual_readdir,
24075 +};
24076 +
24077 +static struct inode_operations proc_virtual_dir_inode_operations = {
24078 +       .getattr =      proc_virtual_getattr,
24079 +       .lookup =       proc_virtual_lookup,
24080 +};
24081 +
24082 +
24083 +
24084 +
24085 +
24086 +int proc_virtnet_readdir(struct file *filp,
24087 +       void *dirent, filldir_t filldir)
24088 +{
24089 +       struct dentry *dentry = filp->f_dentry;
24090 +       struct inode *inode = dentry->d_inode;
24091 +       struct vs_entry *p = nx_virtnet_stuff;
24092 +       int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24093 +       int pos, index;
24094 +       unsigned int nid_array[PROC_MAXVIDS];
24095 +       char buf[PROC_NUMBUF];
24096 +       unsigned int nr_nids, i;
24097 +       u64 ino;
24098 +
24099 +       pos = filp->f_pos;
24100 +       switch (pos) {
24101 +       case 0:
24102 +               ino = inode->i_ino;
24103 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24104 +                       goto out;
24105 +               pos++;
24106 +               /* fall through */
24107 +       case 1:
24108 +               ino = parent_ino(dentry);
24109 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24110 +                       goto out;
24111 +               pos++;
24112 +               /* fall through */
24113 +       default:
24114 +               index = pos - 2;
24115 +               if (index >= size)
24116 +                       goto entries;
24117 +               for (p += index; p->name; p++) {
24118 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24119 +                               vs_proc_instantiate, 0, p))
24120 +                               goto out;
24121 +                       pos++;
24122 +               }
24123 +       entries:
24124 +               index = pos - size;
24125 +               p = &nx_virtnet_stuff[size - 1];
24126 +               nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24127 +               for (i = 0; i < nr_nids; i++) {
24128 +                       int n, nid = nid_array[i];
24129 +                       unsigned int j = PROC_NUMBUF;
24130 +
24131 +                       n = nid;
24132 +                       do
24133 +                               buf[--j] = '0' + (n % 10);
24134 +                       while (n /= 10);
24135 +
24136 +                       if (proc_fill_cache(filp, dirent, filldir,
24137 +                               buf + j, PROC_NUMBUF - j,
24138 +                               vs_proc_instantiate, nid, p))
24139 +                               goto out;
24140 +                       pos++;
24141 +               }
24142 +       }
24143 +out:
24144 +       filp->f_pos = pos;
24145 +       return 0;
24146 +}
24147 +
24148 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24149 +       struct dentry *dentry, struct kstat *stat)
24150 +{
24151 +       struct inode *inode = dentry->d_inode;
24152 +
24153 +       generic_fillattr(inode, stat);
24154 +       stat->nlink = 2 + atomic_read(&nx_global_cactive);
24155 +       return 0;
24156 +}
24157 +
24158 +static struct file_operations proc_virtnet_dir_operations = {
24159 +       .read =         generic_read_dir,
24160 +       .readdir =      proc_virtnet_readdir,
24161 +};
24162 +
24163 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24164 +       .getattr =      proc_virtnet_getattr,
24165 +       .lookup =       proc_virtnet_lookup,
24166 +};
24167 +
24168 +
24169 +
24170 +void proc_vx_init(void)
24171 +{
24172 +       struct proc_dir_entry *ent;
24173 +
24174 +       ent = proc_mkdir("virtual", 0);
24175 +       if (ent) {
24176 +               ent->proc_fops = &proc_virtual_dir_operations;
24177 +               ent->proc_iops = &proc_virtual_dir_inode_operations;
24178 +       }
24179 +       proc_virtual = ent;
24180 +
24181 +       ent = proc_mkdir("virtnet", 0);
24182 +       if (ent) {
24183 +               ent->proc_fops = &proc_virtnet_dir_operations;
24184 +               ent->proc_iops = &proc_virtnet_dir_inode_operations;
24185 +       }
24186 +       proc_virtnet = ent;
24187 +}
24188 +
24189 +
24190 +
24191 +
24192 +/* per pid info */
24193 +
24194 +
24195 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24196 +{
24197 +       struct vx_info *vxi;
24198 +       char *orig = buffer;
24199 +
24200 +       buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24201 +
24202 +       vxi = task_get_vx_info(p);
24203 +       if (!vxi)
24204 +               goto out;
24205 +
24206 +       buffer += sprintf(buffer, "BCaps:\t");
24207 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24208 +       buffer += sprintf(buffer, "\n");
24209 +       buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24210 +               (unsigned long long)vxi->vx_ccaps);
24211 +       buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24212 +               (unsigned long long)vxi->vx_flags);
24213 +       buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24214 +
24215 +       put_vx_info(vxi);
24216 +out:
24217 +       return buffer - orig;
24218 +}
24219 +
24220 +
24221 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24222 +{
24223 +       struct nx_info *nxi;
24224 +       struct nx_addr_v4 *v4a;
24225 +#ifdef CONFIG_IPV6
24226 +       struct nx_addr_v6 *v6a;
24227 +#endif
24228 +       char *orig = buffer;
24229 +       int i;
24230 +
24231 +       buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24232 +
24233 +       nxi = task_get_nx_info(p);
24234 +       if (!nxi)
24235 +               goto out;
24236 +
24237 +       buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24238 +               (unsigned long long)nxi->nx_ncaps);
24239 +       buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24240 +               (unsigned long long)nxi->nx_flags);
24241 +
24242 +       buffer += sprintf(buffer,
24243 +               "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24244 +               NIPQUAD(nxi->v4_bcast.s_addr));
24245 +       buffer += sprintf (buffer,
24246 +               "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24247 +               NIPQUAD(nxi->v4_lback.s_addr));
24248 +       if (!NX_IPV4(nxi))
24249 +               goto skip_v4;
24250 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24251 +               buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24252 +                       i, NXAV4(v4a));
24253 +skip_v4:
24254 +#ifdef CONFIG_IPV6
24255 +       if (!NX_IPV6(nxi))
24256 +               goto skip_v6;
24257 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24258 +               buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24259 +                       i, NXAV6(v6a));
24260 +skip_v6:
24261 +#endif
24262 +       put_nx_info(nxi);
24263 +out:
24264 +       return buffer - orig;
24265 +}
24266 +
24267 diff -NurpP --minimal linux-2.6.35/kernel/vserver/sched.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched.c
24268 --- linux-2.6.35/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
24269 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched.c   2010-08-02 17:05:06.000000000 +0200
24270 @@ -0,0 +1,414 @@
24271 +/*
24272 + *  linux/kernel/vserver/sched.c
24273 + *
24274 + *  Virtual Server: Scheduler Support
24275 + *
24276 + *  Copyright (C) 2004-2007  Herbert Pötzl
24277 + *
24278 + *  V0.01  adapted Sam Vilains version to 2.6.3
24279 + *  V0.02  removed legacy interface
24280 + *  V0.03  changed vcmds to vxi arg
24281 + *  V0.04  removed older and legacy interfaces
24282 + *
24283 + */
24284 +
24285 +#include <linux/vs_context.h>
24286 +#include <linux/vs_sched.h>
24287 +#include <linux/vserver/sched_cmd.h>
24288 +
24289 +#include <asm/uaccess.h>
24290 +
24291 +
24292 +#define vxd_check_range(val, min, max) do {            \
24293 +       vxlprintk((val < min) || (val > max),           \
24294 +               "check_range(%ld,%ld,%ld)",             \
24295 +               (long)val, (long)min, (long)max,        \
24296 +               __FILE__, __LINE__);                    \
24297 +       } while (0)
24298 +
24299 +
24300 +void vx_update_sched_param(struct _vx_sched *sched,
24301 +       struct _vx_sched_pc *sched_pc)
24302 +{
24303 +       unsigned int set_mask = sched->update_mask;
24304 +
24305 +       if (set_mask & VXSM_FILL_RATE)
24306 +               sched_pc->fill_rate[0] = sched->fill_rate[0];
24307 +       if (set_mask & VXSM_INTERVAL)
24308 +               sched_pc->interval[0] = sched->interval[0];
24309 +       if (set_mask & VXSM_FILL_RATE2)
24310 +               sched_pc->fill_rate[1] = sched->fill_rate[1];
24311 +       if (set_mask & VXSM_INTERVAL2)
24312 +               sched_pc->interval[1] = sched->interval[1];
24313 +       if (set_mask & VXSM_TOKENS)
24314 +               sched_pc->tokens = sched->tokens;
24315 +       if (set_mask & VXSM_TOKENS_MIN)
24316 +               sched_pc->tokens_min = sched->tokens_min;
24317 +       if (set_mask & VXSM_TOKENS_MAX)
24318 +               sched_pc->tokens_max = sched->tokens_max;
24319 +       if (set_mask & VXSM_PRIO_BIAS)
24320 +               sched_pc->prio_bias = sched->prio_bias;
24321 +
24322 +       if (set_mask & VXSM_IDLE_TIME)
24323 +               sched_pc->flags |= VXSF_IDLE_TIME;
24324 +       else
24325 +               sched_pc->flags &= ~VXSF_IDLE_TIME;
24326 +
24327 +       /* reset time */
24328 +       sched_pc->norm_time = jiffies;
24329 +}
24330 +
24331 +
24332 +/*
24333 + * recalculate the context's scheduling tokens
24334 + *
24335 + * ret > 0 : number of tokens available
24336 + * ret < 0 : on hold, check delta_min[]
24337 + *          -1 only jiffies
24338 + *          -2 also idle time
24339 + *
24340 + */
24341 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24342 +       unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24343 +{
24344 +       long delta;
24345 +       long tokens = 0;
24346 +       int flags = sched_pc->flags;
24347 +
24348 +       /* how much time did pass? */
24349 +       delta = *norm_time - sched_pc->norm_time;
24350 +       // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
24351 +       vxd_check_range(delta, 0, INT_MAX);
24352 +
24353 +       if (delta >= sched_pc->interval[0]) {
24354 +               long tokens, integral;
24355 +
24356 +               /* calc integral token part */
24357 +               tokens = delta / sched_pc->interval[0];
24358 +               integral = tokens * sched_pc->interval[0];
24359 +               tokens *= sched_pc->fill_rate[0];
24360 +#ifdef CONFIG_VSERVER_HARDCPU
24361 +               delta_min[0] = delta - integral;
24362 +               vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24363 +#endif
24364 +               /* advance time */
24365 +               sched_pc->norm_time += delta;
24366 +
24367 +               /* add tokens */
24368 +               sched_pc->tokens += tokens;
24369 +               sched_pc->token_time += tokens;
24370 +       } else
24371 +               delta_min[0] = delta;
24372 +
24373 +#ifdef CONFIG_VSERVER_IDLETIME
24374 +       if (!(flags & VXSF_IDLE_TIME))
24375 +               goto skip_idle;
24376 +
24377 +       /* how much was the idle skip? */
24378 +       delta = *idle_time - sched_pc->idle_time;
24379 +       vxd_check_range(delta, 0, INT_MAX);
24380 +
24381 +       if (delta >= sched_pc->interval[1]) {
24382 +               long tokens, integral;
24383 +
24384 +               /* calc fair share token part */
24385 +               tokens = delta / sched_pc->interval[1];
24386 +               integral = tokens * sched_pc->interval[1];
24387 +               tokens *= sched_pc->fill_rate[1];
24388 +               delta_min[1] = delta - integral;
24389 +               vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24390 +
24391 +               /* advance idle time */
24392 +               sched_pc->idle_time += integral;
24393 +
24394 +               /* add tokens */
24395 +               sched_pc->tokens += tokens;
24396 +               sched_pc->token_time += tokens;
24397 +       } else
24398 +               delta_min[1] = delta;
24399 +skip_idle:
24400 +#endif
24401 +
24402 +       /* clip at maximum */
24403 +       if (sched_pc->tokens > sched_pc->tokens_max)
24404 +               sched_pc->tokens = sched_pc->tokens_max;
24405 +       tokens = sched_pc->tokens;
24406 +
24407 +       if ((flags & VXSF_ONHOLD)) {
24408 +               /* can we unhold? */
24409 +               if (tokens >= sched_pc->tokens_min) {
24410 +                       flags &= ~VXSF_ONHOLD;
24411 +                       sched_pc->hold_ticks +=
24412 +                               *norm_time - sched_pc->onhold;
24413 +               } else
24414 +                       goto on_hold;
24415 +       } else {
24416 +               /* put on hold? */
24417 +               if (tokens <= 0) {
24418 +                       flags |= VXSF_ONHOLD;
24419 +                       sched_pc->onhold = *norm_time;
24420 +                       goto on_hold;
24421 +               }
24422 +       }
24423 +       sched_pc->flags = flags;
24424 +       return tokens;
24425 +
24426 +on_hold:
24427 +       tokens = sched_pc->tokens_min - tokens;
24428 +       sched_pc->flags = flags;
24429 +       // BUG_ON(tokens < 0); probably doesn't hold anymore
24430 +
24431 +#ifdef CONFIG_VSERVER_HARDCPU
24432 +       /* next interval? */
24433 +       if (!sched_pc->fill_rate[0])
24434 +               delta_min[0] = HZ;
24435 +       else if (tokens > sched_pc->fill_rate[0])
24436 +               delta_min[0] += sched_pc->interval[0] *
24437 +                       tokens / sched_pc->fill_rate[0];
24438 +       else
24439 +               delta_min[0] = sched_pc->interval[0] - delta_min[0];
24440 +       vxd_check_range(delta_min[0], 0, INT_MAX);
24441 +
24442 +#ifdef CONFIG_VSERVER_IDLETIME
24443 +       if (!(flags & VXSF_IDLE_TIME))
24444 +               return -1;
24445 +
24446 +       /* next interval? */
24447 +       if (!sched_pc->fill_rate[1])
24448 +               delta_min[1] = HZ;
24449 +       else if (tokens > sched_pc->fill_rate[1])
24450 +               delta_min[1] += sched_pc->interval[1] *
24451 +                       tokens / sched_pc->fill_rate[1];
24452 +       else
24453 +               delta_min[1] = sched_pc->interval[1] - delta_min[1];
24454 +       vxd_check_range(delta_min[1], 0, INT_MAX);
24455 +
24456 +       return -2;
24457 +#else
24458 +       return -1;
24459 +#endif /* CONFIG_VSERVER_IDLETIME */
24460 +#else
24461 +       return 0;
24462 +#endif /* CONFIG_VSERVER_HARDCPU */
24463 +}
24464 +
24465 +static inline unsigned long msec_to_ticks(unsigned long msec)
24466 +{
24467 +       return msecs_to_jiffies(msec);
24468 +}
24469 +
24470 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24471 +{
24472 +       return jiffies_to_msecs(ticks);
24473 +}
24474 +
24475 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24476 +{
24477 +       return jiffies_to_usecs(ticks);
24478 +}
24479 +
24480 +
24481 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24482 +{
24483 +       unsigned int set_mask = data->mask;
24484 +       unsigned int update_mask;
24485 +       int i, cpu;
24486 +
24487 +       /* Sanity check data values */
24488 +       if (data->tokens_max <= 0)
24489 +               data->tokens_max = HZ;
24490 +       if (data->tokens_min < 0)
24491 +               data->tokens_min = HZ / 3;
24492 +       if (data->tokens_min >= data->tokens_max)
24493 +               data->tokens_min = data->tokens_max;
24494 +
24495 +       if (data->prio_bias > MAX_PRIO_BIAS)
24496 +               data->prio_bias = MAX_PRIO_BIAS;
24497 +       if (data->prio_bias < MIN_PRIO_BIAS)
24498 +               data->prio_bias = MIN_PRIO_BIAS;
24499 +
24500 +       spin_lock(&vxi->sched.tokens_lock);
24501 +
24502 +       /* sync up on delayed updates */
24503 +       for_each_cpu_mask(cpu, vxi->sched.update)
24504 +               vx_update_sched_param(&vxi->sched,
24505 +                       &vx_per_cpu(vxi, sched_pc, cpu));
24506 +
24507 +       if (set_mask & VXSM_FILL_RATE)
24508 +               vxi->sched.fill_rate[0] = data->fill_rate[0];
24509 +       if (set_mask & VXSM_FILL_RATE2)
24510 +               vxi->sched.fill_rate[1] = data->fill_rate[1];
24511 +       if (set_mask & VXSM_INTERVAL)
24512 +               vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24513 +                       msec_to_ticks(data->interval[0]) : data->interval[0];
24514 +       if (set_mask & VXSM_INTERVAL2)
24515 +               vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24516 +                       msec_to_ticks(data->interval[1]) : data->interval[1];
24517 +       if (set_mask & VXSM_TOKENS)
24518 +               vxi->sched.tokens = data->tokens;
24519 +       if (set_mask & VXSM_TOKENS_MIN)
24520 +               vxi->sched.tokens_min = data->tokens_min;
24521 +       if (set_mask & VXSM_TOKENS_MAX)
24522 +               vxi->sched.tokens_max = data->tokens_max;
24523 +       if (set_mask & VXSM_PRIO_BIAS)
24524 +               vxi->sched.prio_bias = data->prio_bias;
24525 +
24526 +       /* Sanity check rate/interval */
24527 +       for (i = 0; i < 2; i++) {
24528 +               if (data->fill_rate[i] < 0)
24529 +                       data->fill_rate[i] = 0;
24530 +               if (data->interval[i] <= 0)
24531 +                       data->interval[i] = HZ;
24532 +       }
24533 +
24534 +       update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24535 +       update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24536 +       vxi->sched.update_mask = update_mask;
24537 +
24538 +#ifdef CONFIG_SMP
24539 +       rmb();
24540 +       if (set_mask & VXSM_CPU_ID) {
24541 +               vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24542 +               cpus_and(vxi->sched.update, cpu_online_map,
24543 +                       vxi->sched.update);
24544 +       } else
24545 +               vxi->sched.update = cpu_online_map;
24546 +
24547 +       /* forced reload? */
24548 +       if (set_mask & VXSM_FORCE) {
24549 +               for_each_cpu_mask(cpu, vxi->sched.update)
24550 +                       vx_update_sched_param(&vxi->sched,
24551 +                               &vx_per_cpu(vxi, sched_pc, cpu));
24552 +               vxi->sched.update = CPU_MASK_NONE;
24553 +       }
24554 +#else
24555 +       /* on UP we update immediately */
24556 +       vx_update_sched_param(&vxi->sched,
24557 +               &vx_per_cpu(vxi, sched_pc, 0));
24558 +#endif
24559 +
24560 +       spin_unlock(&vxi->sched.tokens_lock);
24561 +       return 0;
24562 +}
24563 +
24564 +
24565 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24566 +#define COPY_PRI(C) C(prio_bias)
24567 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24568 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]);   \
24569 +                   C(fill_rate[1]); C(interval[1]);
24570 +
24571 +#define COPY_VALUE(name) vc_data.name = data->name
24572 +
24573 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24574 +{
24575 +       struct vcmd_sched_v5 vc_data;
24576 +
24577 +       vc_data.mask = data->set_mask;
24578 +       COPY_IDS(COPY_VALUE);
24579 +       COPY_PRI(COPY_VALUE);
24580 +       COPY_TOK(COPY_VALUE);
24581 +       vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24582 +       vc_data.interval[0] = vc_data.interval[1] = data->interval;
24583 +       return do_set_sched(vxi, &vc_data);
24584 +}
24585 +
24586 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24587 +{
24588 +       struct vcmd_set_sched_v4 vc_data;
24589 +
24590 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24591 +               return -EFAULT;
24592 +
24593 +       return do_set_sched_v4(vxi, &vc_data);
24594 +}
24595 +
24596 +       /* latest interface is v5 */
24597 +
24598 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24599 +{
24600 +       struct vcmd_sched_v5 vc_data;
24601 +
24602 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24603 +               return -EFAULT;
24604 +
24605 +       return do_set_sched(vxi, &vc_data);
24606 +}
24607 +
24608 +
24609 +#define COPY_PRI(C) C(prio_bias)
24610 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24611 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]);    \
24612 +                   C(fill_rate[1]); C(interval[1]);
24613 +
24614 +#define COPY_VALUE(name) vc_data.name = data->name
24615 +
24616 +
24617 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24618 +{
24619 +       struct vcmd_sched_v5 vc_data;
24620 +
24621 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24622 +               return -EFAULT;
24623 +
24624 +       if (vc_data.mask & VXSM_CPU_ID) {
24625 +               int cpu = vc_data.cpu_id;
24626 +               struct _vx_sched_pc *data;
24627 +
24628 +               if (!cpu_possible(cpu))
24629 +                       return -EINVAL;
24630 +
24631 +               data = &vx_per_cpu(vxi, sched_pc, cpu);
24632 +               COPY_TOK(COPY_VALUE);
24633 +               COPY_PRI(COPY_VALUE);
24634 +               COPY_FRI(COPY_VALUE);
24635 +
24636 +               if (data->flags & VXSF_IDLE_TIME)
24637 +                       vc_data.mask |= VXSM_IDLE_TIME;
24638 +       } else {
24639 +               struct _vx_sched *data = &vxi->sched;
24640 +
24641 +               COPY_TOK(COPY_VALUE);
24642 +               COPY_PRI(COPY_VALUE);
24643 +               COPY_FRI(COPY_VALUE);
24644 +       }
24645 +
24646 +       if (vc_data.mask & VXSM_MSEC) {
24647 +               vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24648 +               vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24649 +       }
24650 +
24651 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24652 +               return -EFAULT;
24653 +       return 0;
24654 +}
24655 +
24656 +
24657 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24658 +{
24659 +       struct vcmd_sched_info vc_data;
24660 +       int cpu;
24661 +
24662 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24663 +               return -EFAULT;
24664 +
24665 +       cpu = vc_data.cpu_id;
24666 +       if (!cpu_possible(cpu))
24667 +               return -EINVAL;
24668 +
24669 +       if (vxi) {
24670 +               struct _vx_sched_pc *sched_pc =
24671 +                       &vx_per_cpu(vxi, sched_pc, cpu);
24672 +
24673 +               vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24674 +               vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24675 +               vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24676 +               vc_data.vavavoom = sched_pc->vavavoom;
24677 +       }
24678 +       vc_data.token_usec = ticks_to_usec(1);
24679 +
24680 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24681 +               return -EFAULT;
24682 +       return 0;
24683 +}
24684 +
24685 diff -NurpP --minimal linux-2.6.35/kernel/vserver/sched_init.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched_init.h
24686 --- linux-2.6.35/kernel/vserver/sched_init.h    1970-01-01 01:00:00.000000000 +0100
24687 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched_init.h      2010-08-02 17:05:06.000000000 +0200
24688 @@ -0,0 +1,50 @@
24689 +
24690 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24691 +{
24692 +       static struct lock_class_key tokens_lock_key;
24693 +
24694 +       /* scheduling; hard code starting values as constants */
24695 +       sched->fill_rate[0]     = 1;
24696 +       sched->interval[0]      = 4;
24697 +       sched->fill_rate[1]     = 1;
24698 +       sched->interval[1]      = 8;
24699 +       sched->tokens           = HZ >> 2;
24700 +       sched->tokens_min       = HZ >> 4;
24701 +       sched->tokens_max       = HZ >> 1;
24702 +       sched->tokens_lock      = SPIN_LOCK_UNLOCKED;
24703 +       sched->prio_bias        = 0;
24704 +
24705 +       lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24706 +}
24707 +
24708 +static inline
24709 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24710 +{
24711 +       sched_pc->fill_rate[0]  = 1;
24712 +       sched_pc->interval[0]   = 4;
24713 +       sched_pc->fill_rate[1]  = 1;
24714 +       sched_pc->interval[1]   = 8;
24715 +       sched_pc->tokens        = HZ >> 2;
24716 +       sched_pc->tokens_min    = HZ >> 4;
24717 +       sched_pc->tokens_max    = HZ >> 1;
24718 +       sched_pc->prio_bias     = 0;
24719 +       sched_pc->vavavoom      = 0;
24720 +       sched_pc->token_time    = 0;
24721 +       sched_pc->idle_time     = 0;
24722 +       sched_pc->norm_time     = jiffies;
24723 +
24724 +       sched_pc->user_ticks = 0;
24725 +       sched_pc->sys_ticks = 0;
24726 +       sched_pc->hold_ticks = 0;
24727 +}
24728 +
24729 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24730 +{
24731 +       return;
24732 +}
24733 +
24734 +static inline
24735 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24736 +{
24737 +       return;
24738 +}
24739 diff -NurpP --minimal linux-2.6.35/kernel/vserver/sched_proc.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched_proc.h
24740 --- linux-2.6.35/kernel/vserver/sched_proc.h    1970-01-01 01:00:00.000000000 +0100
24741 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sched_proc.h      2010-08-02 17:05:06.000000000 +0200
24742 @@ -0,0 +1,57 @@
24743 +#ifndef _VX_SCHED_PROC_H
24744 +#define _VX_SCHED_PROC_H
24745 +
24746 +
24747 +static inline
24748 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24749 +{
24750 +       int length = 0;
24751 +
24752 +       length += sprintf(buffer,
24753 +               "FillRate:\t%8d,%d\n"
24754 +               "Interval:\t%8d,%d\n"
24755 +               "TokensMin:\t%8d\n"
24756 +               "TokensMax:\t%8d\n"
24757 +               "PrioBias:\t%8d\n",
24758 +               sched->fill_rate[0],
24759 +               sched->fill_rate[1],
24760 +               sched->interval[0],
24761 +               sched->interval[1],
24762 +               sched->tokens_min,
24763 +               sched->tokens_max,
24764 +               sched->prio_bias);
24765 +       return length;
24766 +}
24767 +
24768 +static inline
24769 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24770 +       char *buffer, int cpu)
24771 +{
24772 +       int length = 0;
24773 +
24774 +       length += sprintf(buffer + length,
24775 +               "cpu %d: %lld %lld %lld %ld %ld", cpu,
24776 +               (unsigned long long)sched_pc->user_ticks,
24777 +               (unsigned long long)sched_pc->sys_ticks,
24778 +               (unsigned long long)sched_pc->hold_ticks,
24779 +               sched_pc->token_time,
24780 +               sched_pc->idle_time);
24781 +       length += sprintf(buffer + length,
24782 +               " %c%c %d %d %d %d/%d %d/%d",
24783 +               (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24784 +               (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24785 +               sched_pc->tokens,
24786 +               sched_pc->tokens_min,
24787 +               sched_pc->tokens_max,
24788 +               sched_pc->fill_rate[0],
24789 +               sched_pc->interval[0],
24790 +               sched_pc->fill_rate[1],
24791 +               sched_pc->interval[1]);
24792 +       length += sprintf(buffer + length,
24793 +               " %d %d\n",
24794 +               sched_pc->prio_bias,
24795 +               sched_pc->vavavoom);
24796 +       return length;
24797 +}
24798 +
24799 +#endif /* _VX_SCHED_PROC_H */
24800 diff -NurpP --minimal linux-2.6.35/kernel/vserver/signal.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/signal.c
24801 --- linux-2.6.35/kernel/vserver/signal.c        1970-01-01 01:00:00.000000000 +0100
24802 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/signal.c  2010-08-02 17:05:06.000000000 +0200
24803 @@ -0,0 +1,132 @@
24804 +/*
24805 + *  linux/kernel/vserver/signal.c
24806 + *
24807 + *  Virtual Server: Signal Support
24808 + *
24809 + *  Copyright (C) 2003-2007  Herbert Pötzl
24810 + *
24811 + *  V0.01  broken out from vcontext V0.05
24812 + *  V0.02  changed vcmds to vxi arg
24813 + *  V0.03  adjusted siginfo for kill
24814 + *
24815 + */
24816 +
24817 +#include <asm/uaccess.h>
24818 +
24819 +#include <linux/vs_context.h>
24820 +#include <linux/vs_pid.h>
24821 +#include <linux/vserver/signal_cmd.h>
24822 +
24823 +
24824 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24825 +{
24826 +       int retval, count = 0;
24827 +       struct task_struct *p;
24828 +       struct siginfo *sip = SEND_SIG_PRIV;
24829 +
24830 +       retval = -ESRCH;
24831 +       vxdprintk(VXD_CBIT(misc, 4),
24832 +               "vx_info_kill(%p[#%d],%d,%d)*",
24833 +               vxi, vxi->vx_id, pid, sig);
24834 +       read_lock(&tasklist_lock);
24835 +       switch (pid) {
24836 +       case  0:
24837 +       case -1:
24838 +               for_each_process(p) {
24839 +                       int err = 0;
24840 +
24841 +                       if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24842 +                               (pid && vxi->vx_initpid == p->pid))
24843 +                               continue;
24844 +
24845 +                       err = group_send_sig_info(sig, sip, p);
24846 +                       ++count;
24847 +                       if (err != -EPERM)
24848 +                               retval = err;
24849 +               }
24850 +               break;
24851 +
24852 +       case 1:
24853 +               if (vxi->vx_initpid) {
24854 +                       pid = vxi->vx_initpid;
24855 +                       /* for now, only SIGINT to private init ... */
24856 +                       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24857 +                               /* ... as long as there are tasks left */
24858 +                               (atomic_read(&vxi->vx_tasks) > 1))
24859 +                               sig = SIGINT;
24860 +               }
24861 +               /* fallthrough */
24862 +       default:
24863 +               p = find_task_by_real_pid(pid);
24864 +               if (p) {
24865 +                       if (vx_task_xid(p) == vxi->vx_id)
24866 +                               retval = group_send_sig_info(sig, sip, p);
24867 +               }
24868 +               break;
24869 +       }
24870 +       read_unlock(&tasklist_lock);
24871 +       vxdprintk(VXD_CBIT(misc, 4),
24872 +               "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24873 +               vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24874 +       return retval;
24875 +}
24876 +
24877 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24878 +{
24879 +       struct vcmd_ctx_kill_v0 vc_data;
24880 +
24881 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24882 +               return -EFAULT;
24883 +
24884 +       /* special check to allow guest shutdown */
24885 +       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24886 +               /* forbid killall pid=0 when init is present */
24887 +               (((vc_data.pid < 1) && vxi->vx_initpid) ||
24888 +               (vc_data.pid > 1)))
24889 +               return -EACCES;
24890 +
24891 +       return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24892 +}
24893 +
24894 +
24895 +static int __wait_exit(struct vx_info *vxi)
24896 +{
24897 +       DECLARE_WAITQUEUE(wait, current);
24898 +       int ret = 0;
24899 +
24900 +       add_wait_queue(&vxi->vx_wait, &wait);
24901 +       set_current_state(TASK_INTERRUPTIBLE);
24902 +
24903 +wait:
24904 +       if (vx_info_state(vxi,
24905 +               VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24906 +               goto out;
24907 +       if (signal_pending(current)) {
24908 +               ret = -ERESTARTSYS;
24909 +               goto out;
24910 +       }
24911 +       schedule();
24912 +       goto wait;
24913 +
24914 +out:
24915 +       set_current_state(TASK_RUNNING);
24916 +       remove_wait_queue(&vxi->vx_wait, &wait);
24917 +       return ret;
24918 +}
24919 +
24920 +
24921 +
24922 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24923 +{
24924 +       struct vcmd_wait_exit_v0 vc_data;
24925 +       int ret;
24926 +
24927 +       ret = __wait_exit(vxi);
24928 +       vc_data.reboot_cmd = vxi->reboot_cmd;
24929 +       vc_data.exit_code = vxi->exit_code;
24930 +
24931 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24932 +               ret = -EFAULT;
24933 +       return ret;
24934 +}
24935 +
24936 diff -NurpP --minimal linux-2.6.35/kernel/vserver/space.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/space.c
24937 --- linux-2.6.35/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24938 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/space.c   2010-08-02 17:05:06.000000000 +0200
24939 @@ -0,0 +1,375 @@
24940 +/*
24941 + *  linux/kernel/vserver/space.c
24942 + *
24943 + *  Virtual Server: Context Space Support
24944 + *
24945 + *  Copyright (C) 2003-2007  Herbert Pötzl
24946 + *
24947 + *  V0.01  broken out from context.c 0.07
24948 + *  V0.02  added task locking for namespace
24949 + *  V0.03  broken out vx_enter_namespace
24950 + *  V0.04  added *space support and commands
24951 + *
24952 + */
24953 +
24954 +#include <linux/utsname.h>
24955 +#include <linux/nsproxy.h>
24956 +#include <linux/err.h>
24957 +#include <linux/fs_struct.h>
24958 +#include <asm/uaccess.h>
24959 +
24960 +#include <linux/vs_context.h>
24961 +#include <linux/vserver/space.h>
24962 +#include <linux/vserver/space_cmd.h>
24963 +
24964 +atomic_t vs_global_nsproxy     = ATOMIC_INIT(0);
24965 +atomic_t vs_global_fs          = ATOMIC_INIT(0);
24966 +atomic_t vs_global_mnt_ns      = ATOMIC_INIT(0);
24967 +atomic_t vs_global_uts_ns      = ATOMIC_INIT(0);
24968 +atomic_t vs_global_user_ns     = ATOMIC_INIT(0);
24969 +atomic_t vs_global_pid_ns      = ATOMIC_INIT(0);
24970 +
24971 +
24972 +/* namespace functions */
24973 +
24974 +#include <linux/mnt_namespace.h>
24975 +#include <linux/user_namespace.h>
24976 +#include <linux/pid_namespace.h>
24977 +#include <linux/ipc_namespace.h>
24978 +#include <net/net_namespace.h>
24979 +
24980 +
24981 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24982 +       .mask = CLONE_FS |
24983 +               CLONE_NEWNS |
24984 +               CLONE_NEWUTS |
24985 +               CLONE_NEWIPC |
24986 +               CLONE_NEWUSER |
24987 +               0
24988 +};
24989 +
24990 +static const struct vcmd_space_mask_v1 space_mask = {
24991 +       .mask = CLONE_FS |
24992 +               CLONE_NEWNS |
24993 +               CLONE_NEWUTS |
24994 +               CLONE_NEWIPC |
24995 +               CLONE_NEWUSER |
24996 +#ifdef CONFIG_PID_NS
24997 +               CLONE_NEWPID |
24998 +#endif
24999 +#ifdef CONFIG_NET_NS
25000 +               CLONE_NEWNET |
25001 +#endif
25002 +               0
25003 +};
25004 +
25005 +static const struct vcmd_space_mask_v1 default_space_mask = {
25006 +       .mask = CLONE_FS |
25007 +               CLONE_NEWNS |
25008 +               CLONE_NEWUTS |
25009 +               CLONE_NEWIPC |
25010 +               CLONE_NEWUSER |
25011 +#ifdef CONFIG_PID_NS
25012 +//             CLONE_NEWPID |
25013 +#endif
25014 +               0
25015 +};
25016 +
25017 +/*
25018 + *     build a new nsproxy mix
25019 + *      assumes that both proxies are 'const'
25020 + *     does not touch nsproxy refcounts
25021 + *     will hold a reference on the result.
25022 + */
25023 +
25024 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
25025 +       struct nsproxy *new_nsproxy, unsigned long mask)
25026 +{
25027 +       struct mnt_namespace *old_ns;
25028 +       struct uts_namespace *old_uts;
25029 +       struct ipc_namespace *old_ipc;
25030 +#ifdef CONFIG_PID_NS
25031 +       struct pid_namespace *old_pid;
25032 +#endif
25033 +#ifdef CONFIG_NET_NS
25034 +       struct net *old_net;
25035 +#endif
25036 +       struct nsproxy *nsproxy;
25037 +
25038 +       nsproxy = copy_nsproxy(old_nsproxy);
25039 +       if (!nsproxy)
25040 +               goto out;
25041 +
25042 +       if (mask & CLONE_NEWNS) {
25043 +               old_ns = nsproxy->mnt_ns;
25044 +               nsproxy->mnt_ns = new_nsproxy->mnt_ns;
25045 +               if (nsproxy->mnt_ns)
25046 +                       get_mnt_ns(nsproxy->mnt_ns);
25047 +       } else
25048 +               old_ns = NULL;
25049 +
25050 +       if (mask & CLONE_NEWUTS) {
25051 +               old_uts = nsproxy->uts_ns;
25052 +               nsproxy->uts_ns = new_nsproxy->uts_ns;
25053 +               if (nsproxy->uts_ns)
25054 +                       get_uts_ns(nsproxy->uts_ns);
25055 +       } else
25056 +               old_uts = NULL;
25057 +
25058 +       if (mask & CLONE_NEWIPC) {
25059 +               old_ipc = nsproxy->ipc_ns;
25060 +               nsproxy->ipc_ns = new_nsproxy->ipc_ns;
25061 +               if (nsproxy->ipc_ns)
25062 +                       get_ipc_ns(nsproxy->ipc_ns);
25063 +       } else
25064 +               old_ipc = NULL;
25065 +
25066 +#ifdef CONFIG_PID_NS
25067 +       if (mask & CLONE_NEWPID) {
25068 +               old_pid = nsproxy->pid_ns;
25069 +               nsproxy->pid_ns = new_nsproxy->pid_ns;
25070 +               if (nsproxy->pid_ns)
25071 +                       get_pid_ns(nsproxy->pid_ns);
25072 +       } else
25073 +               old_pid = NULL;
25074 +#endif
25075 +#ifdef CONFIG_NET_NS
25076 +       if (mask & CLONE_NEWNET) {
25077 +               old_net = nsproxy->net_ns;
25078 +               nsproxy->net_ns = new_nsproxy->net_ns;
25079 +               if (nsproxy->net_ns)
25080 +                       get_net(nsproxy->net_ns);
25081 +       } else
25082 +               old_net = NULL;
25083 +#endif
25084 +       if (old_ns)
25085 +               put_mnt_ns(old_ns);
25086 +       if (old_uts)
25087 +               put_uts_ns(old_uts);
25088 +       if (old_ipc)
25089 +               put_ipc_ns(old_ipc);
25090 +#ifdef CONFIG_PID_NS
25091 +       if (old_pid)
25092 +               put_pid_ns(old_pid);
25093 +#endif
25094 +#ifdef CONFIG_NET_NS
25095 +       if (old_net)
25096 +               put_net(old_net);
25097 +#endif
25098 +out:
25099 +       return nsproxy;
25100 +}
25101 +
25102 +
25103 +/*
25104 + *     merge two nsproxy structs into a new one.
25105 + *     will hold a reference on the result.
25106 + */
25107 +
25108 +static inline
25109 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
25110 +       struct nsproxy *proxy, unsigned long mask)
25111 +{
25112 +       struct nsproxy null_proxy = { .mnt_ns = NULL };
25113 +
25114 +       if (!proxy)
25115 +               return NULL;
25116 +
25117 +       if (mask) {
25118 +               /* vs_mix_nsproxy returns with reference */
25119 +               return vs_mix_nsproxy(old ? old : &null_proxy,
25120 +                       proxy, mask);
25121 +       }
25122 +       get_nsproxy(proxy);
25123 +       return proxy;
25124 +}
25125 +
25126 +
25127 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25128 +{
25129 +       struct nsproxy *proxy, *proxy_cur, *proxy_new;
25130 +       struct fs_struct *fs_cur, *fs = NULL;
25131 +       int ret, kill = 0;
25132 +
25133 +       vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
25134 +               vxi, vxi->vx_id, mask, index);
25135 +
25136 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
25137 +               return -EACCES;
25138 +
25139 +       if (!mask)
25140 +               mask = vxi->vx_nsmask[index];
25141 +
25142 +       if ((mask & vxi->vx_nsmask[index]) != mask)
25143 +               return -EINVAL;
25144 +
25145 +       if (mask & CLONE_FS) {
25146 +               fs = copy_fs_struct(vxi->vx_fs[index]);
25147 +               if (!fs)
25148 +                       return -ENOMEM;
25149 +       }
25150 +       proxy = vxi->vx_nsproxy[index];
25151 +
25152 +       vxdprintk(VXD_CBIT(space, 9),
25153 +               "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
25154 +               vxi, vxi->vx_id, mask, index, proxy, fs);
25155 +
25156 +       task_lock(current);
25157 +       fs_cur = current->fs;
25158 +
25159 +       if (mask & CLONE_FS) {
25160 +               write_lock(&fs_cur->lock);
25161 +               current->fs = fs;
25162 +               kill = !--fs_cur->users;
25163 +               write_unlock(&fs_cur->lock);
25164 +       }
25165 +
25166 +       proxy_cur = current->nsproxy;
25167 +       get_nsproxy(proxy_cur);
25168 +       task_unlock(current);
25169 +
25170 +       if (kill)
25171 +               free_fs_struct(fs_cur);
25172 +
25173 +       proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
25174 +       if (IS_ERR(proxy_new)) {
25175 +               ret = PTR_ERR(proxy_new);
25176 +               goto out_put;
25177 +       }
25178 +
25179 +       proxy_new = xchg(&current->nsproxy, proxy_new);
25180 +       ret = 0;
25181 +
25182 +       if (proxy_new)
25183 +               put_nsproxy(proxy_new);
25184 +out_put:
25185 +       if (proxy_cur)
25186 +               put_nsproxy(proxy_cur);
25187 +       return ret;
25188 +}
25189 +
25190 +
25191 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25192 +{
25193 +       struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25194 +       struct fs_struct *fs_vxi, *fs;
25195 +       int ret, kill = 0;
25196 +
25197 +       vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
25198 +               vxi, vxi->vx_id, mask, index);
25199 +#if 0
25200 +       if (!mask)
25201 +               mask = default_space_mask.mask;
25202 +#endif
25203 +       if ((mask & space_mask.mask) != mask)
25204 +               return -EINVAL;
25205 +
25206 +       proxy_vxi = vxi->vx_nsproxy[index];
25207 +       fs_vxi = vxi->vx_fs[index];
25208 +
25209 +       if (mask & CLONE_FS) {
25210 +               fs = copy_fs_struct(current->fs);
25211 +               if (!fs)
25212 +                       return -ENOMEM;
25213 +       }
25214 +
25215 +       task_lock(current);
25216 +
25217 +       if (mask & CLONE_FS) {
25218 +               write_lock(&fs_vxi->lock);
25219 +               vxi->vx_fs[index] = fs;
25220 +               kill = !--fs_vxi->users;
25221 +               write_unlock(&fs_vxi->lock);
25222 +       }
25223 +
25224 +       proxy_cur = current->nsproxy;
25225 +       get_nsproxy(proxy_cur);
25226 +       task_unlock(current);
25227 +
25228 +       if (kill)
25229 +               free_fs_struct(fs_vxi);
25230 +
25231 +       proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25232 +       if (IS_ERR(proxy_new)) {
25233 +               ret = PTR_ERR(proxy_new);
25234 +               goto out_put;
25235 +       }
25236 +
25237 +       proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
25238 +       vxi->vx_nsmask[index] |= mask;
25239 +       ret = 0;
25240 +
25241 +       if (proxy_new)
25242 +               put_nsproxy(proxy_new);
25243 +out_put:
25244 +       if (proxy_cur)
25245 +               put_nsproxy(proxy_cur);
25246 +       return ret;
25247 +}
25248 +
25249 +
25250 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25251 +{
25252 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25253 +
25254 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25255 +               return -EFAULT;
25256 +
25257 +       return vx_enter_space(vxi, vc_data.mask, 0);
25258 +}
25259 +
25260 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25261 +{
25262 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25263 +
25264 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25265 +               return -EFAULT;
25266 +
25267 +       if (vc_data.index >= VX_SPACES)
25268 +               return -EINVAL;
25269 +
25270 +       return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25271 +}
25272 +
25273 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25274 +{
25275 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25276 +
25277 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25278 +               return -EFAULT;
25279 +
25280 +       return vx_set_space(vxi, vc_data.mask, 0);
25281 +}
25282 +
25283 +int vc_set_space(struct vx_info *vxi, void __user *data)
25284 +{
25285 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25286 +
25287 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25288 +               return -EFAULT;
25289 +
25290 +       if (vc_data.index >= VX_SPACES)
25291 +               return -EINVAL;
25292 +
25293 +       return vx_set_space(vxi, vc_data.mask, vc_data.index);
25294 +}
25295 +
25296 +int vc_get_space_mask(void __user *data, int type)
25297 +{
25298 +       const struct vcmd_space_mask_v1 *mask;
25299 +
25300 +       if (type == 0)
25301 +               mask = &space_mask_v0;
25302 +       else if (type == 1)
25303 +               mask = &space_mask;
25304 +       else
25305 +               mask = &default_space_mask;
25306 +
25307 +       vxdprintk(VXD_CBIT(space, 10),
25308 +               "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25309 +
25310 +       if (copy_to_user(data, mask, sizeof(*mask)))
25311 +               return -EFAULT;
25312 +       return 0;
25313 +}
25314 +
25315 diff -NurpP --minimal linux-2.6.35/kernel/vserver/switch.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/switch.c
25316 --- linux-2.6.35/kernel/vserver/switch.c        1970-01-01 01:00:00.000000000 +0100
25317 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/switch.c  2010-08-02 17:05:06.000000000 +0200
25318 @@ -0,0 +1,546 @@
25319 +/*
25320 + *  linux/kernel/vserver/switch.c
25321 + *
25322 + *  Virtual Server: Syscall Switch
25323 + *
25324 + *  Copyright (C) 2003-2007  Herbert Pötzl
25325 + *
25326 + *  V0.01  syscall switch
25327 + *  V0.02  added signal to context
25328 + *  V0.03  added rlimit functions
25329 + *  V0.04  added iattr, task/xid functions
25330 + *  V0.05  added debug/history stuff
25331 + *  V0.06  added compat32 layer
25332 + *  V0.07  vcmd args and perms
25333 + *  V0.08  added status commands
25334 + *  V0.09  added tag commands
25335 + *  V0.10  added oom bias
25336 + *  V0.11  added device commands
25337 + *
25338 + */
25339 +
25340 +#include <linux/vs_context.h>
25341 +#include <linux/vs_network.h>
25342 +#include <linux/vserver/switch.h>
25343 +
25344 +#include "vci_config.h"
25345 +
25346 +
25347 +static inline
25348 +int vc_get_version(uint32_t id)
25349 +{
25350 +       return VCI_VERSION;
25351 +}
25352 +
25353 +static inline
25354 +int vc_get_vci(uint32_t id)
25355 +{
25356 +       return vci_kernel_config();
25357 +}
25358 +
25359 +#include <linux/vserver/context_cmd.h>
25360 +#include <linux/vserver/cvirt_cmd.h>
25361 +#include <linux/vserver/cacct_cmd.h>
25362 +#include <linux/vserver/limit_cmd.h>
25363 +#include <linux/vserver/network_cmd.h>
25364 +#include <linux/vserver/sched_cmd.h>
25365 +#include <linux/vserver/debug_cmd.h>
25366 +#include <linux/vserver/inode_cmd.h>
25367 +#include <linux/vserver/dlimit_cmd.h>
25368 +#include <linux/vserver/signal_cmd.h>
25369 +#include <linux/vserver/space_cmd.h>
25370 +#include <linux/vserver/tag_cmd.h>
25371 +#include <linux/vserver/device_cmd.h>
25372 +
25373 +#include <linux/vserver/inode.h>
25374 +#include <linux/vserver/dlimit.h>
25375 +
25376 +
25377 +#ifdef CONFIG_COMPAT
25378 +#define __COMPAT(name, id, data, compat)       \
25379 +       (compat) ? name ## _x32(id, data) : name(id, data)
25380 +#define __COMPAT_NO_ID(name, data, compat)     \
25381 +       (compat) ? name ## _x32(data) : name(data)
25382 +#else
25383 +#define __COMPAT(name, id, data, compat)       \
25384 +       name(id, data)
25385 +#define __COMPAT_NO_ID(name, data, compat)     \
25386 +       name(data)
25387 +#endif
25388 +
25389 +
25390 +static inline
25391 +long do_vcmd(uint32_t cmd, uint32_t id,
25392 +       struct vx_info *vxi, struct nx_info *nxi,
25393 +       void __user *data, int compat)
25394 +{
25395 +       switch (cmd) {
25396 +
25397 +       case VCMD_get_version:
25398 +               return vc_get_version(id);
25399 +       case VCMD_get_vci:
25400 +               return vc_get_vci(id);
25401 +
25402 +       case VCMD_task_xid:
25403 +               return vc_task_xid(id);
25404 +       case VCMD_vx_info:
25405 +               return vc_vx_info(vxi, data);
25406 +
25407 +       case VCMD_task_nid:
25408 +               return vc_task_nid(id);
25409 +       case VCMD_nx_info:
25410 +               return vc_nx_info(nxi, data);
25411 +
25412 +       case VCMD_task_tag:
25413 +               return vc_task_tag(id);
25414 +
25415 +       case VCMD_set_space_v1:
25416 +               return vc_set_space_v1(vxi, data);
25417 +       /* this is version 2 */
25418 +       case VCMD_set_space:
25419 +               return vc_set_space(vxi, data);
25420 +
25421 +       case VCMD_get_space_mask_v0:
25422 +               return vc_get_space_mask(data, 0);
25423 +       /* this is version 1 */
25424 +       case VCMD_get_space_mask:
25425 +               return vc_get_space_mask(data, 1);
25426 +
25427 +       case VCMD_get_space_default:
25428 +               return vc_get_space_mask(data, -1);
25429 +
25430 +#ifdef CONFIG_IA32_EMULATION
25431 +       case VCMD_get_rlimit:
25432 +               return __COMPAT(vc_get_rlimit, vxi, data, compat);
25433 +       case VCMD_set_rlimit:
25434 +               return __COMPAT(vc_set_rlimit, vxi, data, compat);
25435 +#else
25436 +       case VCMD_get_rlimit:
25437 +               return vc_get_rlimit(vxi, data);
25438 +       case VCMD_set_rlimit:
25439 +               return vc_set_rlimit(vxi, data);
25440 +#endif
25441 +       case VCMD_get_rlimit_mask:
25442 +               return vc_get_rlimit_mask(id, data);
25443 +       case VCMD_reset_hits:
25444 +               return vc_reset_hits(vxi, data);
25445 +       case VCMD_reset_minmax:
25446 +               return vc_reset_minmax(vxi, data);
25447 +
25448 +       case VCMD_get_vhi_name:
25449 +               return vc_get_vhi_name(vxi, data);
25450 +       case VCMD_set_vhi_name:
25451 +               return vc_set_vhi_name(vxi, data);
25452 +
25453 +       case VCMD_ctx_stat:
25454 +               return vc_ctx_stat(vxi, data);
25455 +       case VCMD_virt_stat:
25456 +               return vc_virt_stat(vxi, data);
25457 +       case VCMD_sock_stat:
25458 +               return vc_sock_stat(vxi, data);
25459 +       case VCMD_rlimit_stat:
25460 +               return vc_rlimit_stat(vxi, data);
25461 +
25462 +       case VCMD_set_cflags:
25463 +               return vc_set_cflags(vxi, data);
25464 +       case VCMD_get_cflags:
25465 +               return vc_get_cflags(vxi, data);
25466 +
25467 +       /* this is version 1 */
25468 +       case VCMD_set_ccaps:
25469 +               return vc_set_ccaps(vxi, data);
25470 +       /* this is version 1 */
25471 +       case VCMD_get_ccaps:
25472 +               return vc_get_ccaps(vxi, data);
25473 +       case VCMD_set_bcaps:
25474 +               return vc_set_bcaps(vxi, data);
25475 +       case VCMD_get_bcaps:
25476 +               return vc_get_bcaps(vxi, data);
25477 +
25478 +       case VCMD_set_badness:
25479 +               return vc_set_badness(vxi, data);
25480 +       case VCMD_get_badness:
25481 +               return vc_get_badness(vxi, data);
25482 +
25483 +       case VCMD_set_nflags:
25484 +               return vc_set_nflags(nxi, data);
25485 +       case VCMD_get_nflags:
25486 +               return vc_get_nflags(nxi, data);
25487 +
25488 +       case VCMD_set_ncaps:
25489 +               return vc_set_ncaps(nxi, data);
25490 +       case VCMD_get_ncaps:
25491 +               return vc_get_ncaps(nxi, data);
25492 +
25493 +       case VCMD_set_sched_v4:
25494 +               return vc_set_sched_v4(vxi, data);
25495 +       /* this is version 5 */
25496 +       case VCMD_set_sched:
25497 +               return vc_set_sched(vxi, data);
25498 +       case VCMD_get_sched:
25499 +               return vc_get_sched(vxi, data);
25500 +       case VCMD_sched_info:
25501 +               return vc_sched_info(vxi, data);
25502 +
25503 +       case VCMD_add_dlimit:
25504 +               return __COMPAT(vc_add_dlimit, id, data, compat);
25505 +       case VCMD_rem_dlimit:
25506 +               return __COMPAT(vc_rem_dlimit, id, data, compat);
25507 +       case VCMD_set_dlimit:
25508 +               return __COMPAT(vc_set_dlimit, id, data, compat);
25509 +       case VCMD_get_dlimit:
25510 +               return __COMPAT(vc_get_dlimit, id, data, compat);
25511 +
25512 +       case VCMD_ctx_kill:
25513 +               return vc_ctx_kill(vxi, data);
25514 +
25515 +       case VCMD_wait_exit:
25516 +               return vc_wait_exit(vxi, data);
25517 +
25518 +       case VCMD_get_iattr:
25519 +               return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25520 +       case VCMD_set_iattr:
25521 +               return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25522 +
25523 +       case VCMD_fget_iattr:
25524 +               return vc_fget_iattr(id, data);
25525 +       case VCMD_fset_iattr:
25526 +               return vc_fset_iattr(id, data);
25527 +
25528 +       case VCMD_enter_space_v0:
25529 +               return vc_enter_space_v1(vxi, NULL);
25530 +       case VCMD_enter_space_v1:
25531 +               return vc_enter_space_v1(vxi, data);
25532 +       /* this is version 2 */
25533 +       case VCMD_enter_space:
25534 +               return vc_enter_space(vxi, data);
25535 +
25536 +       case VCMD_ctx_create_v0:
25537 +               return vc_ctx_create(id, NULL);
25538 +       case VCMD_ctx_create:
25539 +               return vc_ctx_create(id, data);
25540 +       case VCMD_ctx_migrate_v0:
25541 +               return vc_ctx_migrate(vxi, NULL);
25542 +       case VCMD_ctx_migrate:
25543 +               return vc_ctx_migrate(vxi, data);
25544 +
25545 +       case VCMD_net_create_v0:
25546 +               return vc_net_create(id, NULL);
25547 +       case VCMD_net_create:
25548 +               return vc_net_create(id, data);
25549 +       case VCMD_net_migrate:
25550 +               return vc_net_migrate(nxi, data);
25551 +
25552 +       case VCMD_tag_migrate:
25553 +               return vc_tag_migrate(id);
25554 +
25555 +       case VCMD_net_add:
25556 +               return vc_net_add(nxi, data);
25557 +       case VCMD_net_remove:
25558 +               return vc_net_remove(nxi, data);
25559 +
25560 +       case VCMD_net_add_ipv4:
25561 +               return vc_net_add_ipv4(nxi, data);
25562 +       case VCMD_net_remove_ipv4:
25563 +               return vc_net_remove_ipv4(nxi, data);
25564 +#ifdef CONFIG_IPV6
25565 +       case VCMD_net_add_ipv6:
25566 +               return vc_net_add_ipv6(nxi, data);
25567 +       case VCMD_net_remove_ipv6:
25568 +               return vc_net_remove_ipv6(nxi, data);
25569 +#endif
25570 +/*     case VCMD_add_match_ipv4:
25571 +               return vc_add_match_ipv4(nxi, data);
25572 +       case VCMD_get_match_ipv4:
25573 +               return vc_get_match_ipv4(nxi, data);
25574 +#ifdef CONFIG_IPV6
25575 +       case VCMD_add_match_ipv6:
25576 +               return vc_add_match_ipv6(nxi, data);
25577 +       case VCMD_get_match_ipv6:
25578 +               return vc_get_match_ipv6(nxi, data);
25579 +#endif */
25580 +
25581 +#ifdef CONFIG_VSERVER_DEVICE
25582 +       case VCMD_set_mapping:
25583 +               return __COMPAT(vc_set_mapping, vxi, data, compat);
25584 +       case VCMD_unset_mapping:
25585 +               return __COMPAT(vc_unset_mapping, vxi, data, compat);
25586 +#endif
25587 +#ifdef CONFIG_VSERVER_HISTORY
25588 +       case VCMD_dump_history:
25589 +               return vc_dump_history(id);
25590 +       case VCMD_read_history:
25591 +               return __COMPAT(vc_read_history, id, data, compat);
25592 +#endif
25593 +#ifdef CONFIG_VSERVER_MONITOR
25594 +       case VCMD_read_monitor:
25595 +               return __COMPAT(vc_read_monitor, id, data, compat);
25596 +#endif
25597 +       default:
25598 +               vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25599 +                       VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25600 +       }
25601 +       return -ENOSYS;
25602 +}
25603 +
25604 +
25605 +#define        __VCMD(vcmd, _perm, _args, _flags)              \
25606 +       case VCMD_ ## vcmd: perm = _perm;               \
25607 +               args = _args; flags = _flags; break
25608 +
25609 +
25610 +#define VCA_NONE       0x00
25611 +#define VCA_VXI                0x01
25612 +#define VCA_NXI                0x02
25613 +
25614 +#define VCF_NONE       0x00
25615 +#define VCF_INFO       0x01
25616 +#define VCF_ADMIN      0x02
25617 +#define VCF_ARES       0x06    /* includes admin */
25618 +#define VCF_SETUP      0x08
25619 +
25620 +#define VCF_ZIDOK      0x10    /* zero id okay */
25621 +
25622 +
25623 +static inline
25624 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25625 +{
25626 +       long ret;
25627 +       int permit = -1, state = 0;
25628 +       int perm = -1, args = 0, flags = 0;
25629 +       struct vx_info *vxi = NULL;
25630 +       struct nx_info *nxi = NULL;
25631 +
25632 +       switch (cmd) {
25633 +       /* unpriviledged commands */
25634 +       __VCMD(get_version,      0, VCA_NONE,   0);
25635 +       __VCMD(get_vci,          0, VCA_NONE,   0);
25636 +       __VCMD(get_rlimit_mask,  0, VCA_NONE,   0);
25637 +       __VCMD(get_space_mask_v0,0, VCA_NONE,   0);
25638 +       __VCMD(get_space_mask,   0, VCA_NONE,   0);
25639 +       __VCMD(get_space_default,0, VCA_NONE,   0);
25640 +
25641 +       /* info commands */
25642 +       __VCMD(task_xid,         2, VCA_NONE,   0);
25643 +       __VCMD(reset_hits,       2, VCA_VXI,    0);
25644 +       __VCMD(reset_minmax,     2, VCA_VXI,    0);
25645 +       __VCMD(vx_info,          3, VCA_VXI,    VCF_INFO);
25646 +       __VCMD(get_bcaps,        3, VCA_VXI,    VCF_INFO);
25647 +       __VCMD(get_ccaps,        3, VCA_VXI,    VCF_INFO);
25648 +       __VCMD(get_cflags,       3, VCA_VXI,    VCF_INFO);
25649 +       __VCMD(get_badness,      3, VCA_VXI,    VCF_INFO);
25650 +       __VCMD(get_vhi_name,     3, VCA_VXI,    VCF_INFO);
25651 +       __VCMD(get_rlimit,       3, VCA_VXI,    VCF_INFO);
25652 +
25653 +       __VCMD(ctx_stat,         3, VCA_VXI,    VCF_INFO);
25654 +       __VCMD(virt_stat,        3, VCA_VXI,    VCF_INFO);
25655 +       __VCMD(sock_stat,        3, VCA_VXI,    VCF_INFO);
25656 +       __VCMD(rlimit_stat,      3, VCA_VXI,    VCF_INFO);
25657 +
25658 +       __VCMD(task_nid,         2, VCA_NONE,   0);
25659 +       __VCMD(nx_info,          3, VCA_NXI,    VCF_INFO);
25660 +       __VCMD(get_ncaps,        3, VCA_NXI,    VCF_INFO);
25661 +       __VCMD(get_nflags,       3, VCA_NXI,    VCF_INFO);
25662 +
25663 +       __VCMD(task_tag,         2, VCA_NONE,   0);
25664 +
25665 +       __VCMD(get_iattr,        2, VCA_NONE,   0);
25666 +       __VCMD(fget_iattr,       2, VCA_NONE,   0);
25667 +       __VCMD(get_dlimit,       3, VCA_NONE,   VCF_INFO);
25668 +       __VCMD(get_sched,        3, VCA_VXI,    VCF_INFO);
25669 +       __VCMD(sched_info,       3, VCA_VXI,    VCF_INFO | VCF_ZIDOK);
25670 +
25671 +       /* lower admin commands */
25672 +       __VCMD(wait_exit,        4, VCA_VXI,    VCF_INFO);
25673 +       __VCMD(ctx_create_v0,    5, VCA_NONE,   0);
25674 +       __VCMD(ctx_create,       5, VCA_NONE,   0);
25675 +       __VCMD(ctx_migrate_v0,   5, VCA_VXI,    VCF_ADMIN);
25676 +       __VCMD(ctx_migrate,      5, VCA_VXI,    VCF_ADMIN);
25677 +       __VCMD(enter_space_v0,   5, VCA_VXI,    VCF_ADMIN);
25678 +       __VCMD(enter_space_v1,   5, VCA_VXI,    VCF_ADMIN);
25679 +       __VCMD(enter_space,      5, VCA_VXI,    VCF_ADMIN);
25680 +
25681 +       __VCMD(net_create_v0,    5, VCA_NONE,   0);
25682 +       __VCMD(net_create,       5, VCA_NONE,   0);
25683 +       __VCMD(net_migrate,      5, VCA_NXI,    VCF_ADMIN);
25684 +
25685 +       __VCMD(tag_migrate,      5, VCA_NONE,   VCF_ADMIN);
25686 +
25687 +       /* higher admin commands */
25688 +       __VCMD(ctx_kill,         6, VCA_VXI,    VCF_ARES);
25689 +       __VCMD(set_space_v1,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25690 +       __VCMD(set_space,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25691 +
25692 +       __VCMD(set_ccaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25693 +       __VCMD(set_bcaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25694 +       __VCMD(set_cflags,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25695 +       __VCMD(set_badness,      7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25696 +
25697 +       __VCMD(set_vhi_name,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25698 +       __VCMD(set_rlimit,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25699 +       __VCMD(set_sched,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25700 +       __VCMD(set_sched_v4,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25701 +
25702 +       __VCMD(set_ncaps,        7, VCA_NXI,    VCF_ARES | VCF_SETUP);
25703 +       __VCMD(set_nflags,       7, VCA_NXI,    VCF_ARES | VCF_SETUP);
25704 +       __VCMD(net_add,          8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25705 +       __VCMD(net_remove,       8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25706 +       __VCMD(net_add_ipv4,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25707 +       __VCMD(net_remove_ipv4,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25708 +#ifdef CONFIG_IPV6
25709 +       __VCMD(net_add_ipv6,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25710 +       __VCMD(net_remove_ipv6,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25711 +#endif
25712 +       __VCMD(set_iattr,        7, VCA_NONE,   0);
25713 +       __VCMD(fset_iattr,       7, VCA_NONE,   0);
25714 +       __VCMD(set_dlimit,       7, VCA_NONE,   VCF_ARES);
25715 +       __VCMD(add_dlimit,       8, VCA_NONE,   VCF_ARES);
25716 +       __VCMD(rem_dlimit,       8, VCA_NONE,   VCF_ARES);
25717 +
25718 +#ifdef CONFIG_VSERVER_DEVICE
25719 +       __VCMD(set_mapping,      8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
25720 +       __VCMD(unset_mapping,    8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
25721 +#endif
25722 +       /* debug level admin commands */
25723 +#ifdef CONFIG_VSERVER_HISTORY
25724 +       __VCMD(dump_history,     9, VCA_NONE,   0);
25725 +       __VCMD(read_history,     9, VCA_NONE,   0);
25726 +#endif
25727 +#ifdef CONFIG_VSERVER_MONITOR
25728 +       __VCMD(read_monitor,     9, VCA_NONE,   0);
25729 +#endif
25730 +
25731 +       default:
25732 +               perm = -1;
25733 +       }
25734 +
25735 +       vxdprintk(VXD_CBIT(switch, 0),
25736 +               "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25737 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
25738 +               VC_VERSION(cmd), id, data, compat,
25739 +               perm, args, flags);
25740 +
25741 +       ret = -ENOSYS;
25742 +       if (perm < 0)
25743 +               goto out;
25744 +
25745 +       state = 1;
25746 +       if (!capable(CAP_CONTEXT))
25747 +               goto out;
25748 +
25749 +       state = 2;
25750 +       /* moved here from the individual commands */
25751 +       ret = -EPERM;
25752 +       if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25753 +               goto out;
25754 +
25755 +       state = 3;
25756 +       /* vcmd involves resource management  */
25757 +       ret = -EPERM;
25758 +       if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25759 +               goto out;
25760 +
25761 +       state = 4;
25762 +       /* various legacy exceptions */
25763 +       switch (cmd) {
25764 +       /* will go away when spectator is a cap */
25765 +       case VCMD_ctx_migrate_v0:
25766 +       case VCMD_ctx_migrate:
25767 +               if (id == 1) {
25768 +                       current->xid = 1;
25769 +                       ret = 1;
25770 +                       goto out;
25771 +               }
25772 +               break;
25773 +
25774 +       /* will go away when spectator is a cap */
25775 +       case VCMD_net_migrate:
25776 +               if (id == 1) {
25777 +                       current->nid = 1;
25778 +                       ret = 1;
25779 +                       goto out;
25780 +               }
25781 +               break;
25782 +       }
25783 +
25784 +       /* vcmds are fine by default */
25785 +       permit = 1;
25786 +
25787 +       /* admin type vcmds require admin ... */
25788 +       if (flags & VCF_ADMIN)
25789 +               permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25790 +
25791 +       /* ... but setup type vcmds override that */
25792 +       if (!permit && (flags & VCF_SETUP))
25793 +               permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25794 +
25795 +       state = 5;
25796 +       ret = -EPERM;
25797 +       if (!permit)
25798 +               goto out;
25799 +
25800 +       state = 6;
25801 +       if (!id && (flags & VCF_ZIDOK))
25802 +               goto skip_id;
25803 +
25804 +       ret = -ESRCH;
25805 +       if (args & VCA_VXI) {
25806 +               vxi = lookup_vx_info(id);
25807 +               if (!vxi)
25808 +                       goto out;
25809 +
25810 +               if ((flags & VCF_ADMIN) &&
25811 +                       /* special case kill for shutdown */
25812 +                       (cmd != VCMD_ctx_kill) &&
25813 +                       /* can context be administrated? */
25814 +                       !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25815 +                       ret = -EACCES;
25816 +                       goto out_vxi;
25817 +               }
25818 +       }
25819 +       state = 7;
25820 +       if (args & VCA_NXI) {
25821 +               nxi = lookup_nx_info(id);
25822 +               if (!nxi)
25823 +                       goto out_vxi;
25824 +
25825 +               if ((flags & VCF_ADMIN) &&
25826 +                       /* can context be administrated? */
25827 +                       !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25828 +                       ret = -EACCES;
25829 +                       goto out_nxi;
25830 +               }
25831 +       }
25832 +skip_id:
25833 +       state = 8;
25834 +       ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25835 +
25836 +out_nxi:
25837 +       if ((args & VCA_NXI) && nxi)
25838 +               put_nx_info(nxi);
25839 +out_vxi:
25840 +       if ((args & VCA_VXI) && vxi)
25841 +               put_vx_info(vxi);
25842 +out:
25843 +       vxdprintk(VXD_CBIT(switch, 1),
25844 +               "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25845 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
25846 +               VC_VERSION(cmd), ret, ret, state, permit);
25847 +       return ret;
25848 +}
25849 +
25850 +asmlinkage long
25851 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25852 +{
25853 +       return do_vserver(cmd, id, data, 0);
25854 +}
25855 +
25856 +#ifdef CONFIG_COMPAT
25857 +
25858 +asmlinkage long
25859 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25860 +{
25861 +       return do_vserver(cmd, id, data, 1);
25862 +}
25863 +
25864 +#endif /* CONFIG_COMPAT */
25865 diff -NurpP --minimal linux-2.6.35/kernel/vserver/sysctl.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sysctl.c
25866 --- linux-2.6.35/kernel/vserver/sysctl.c        1970-01-01 01:00:00.000000000 +0100
25867 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/sysctl.c  2010-08-02 17:05:06.000000000 +0200
25868 @@ -0,0 +1,241 @@
25869 +/*
25870 + *  kernel/vserver/sysctl.c
25871 + *
25872 + *  Virtual Context Support
25873 + *
25874 + *  Copyright (C) 2004-2007  Herbert Pötzl
25875 + *
25876 + *  V0.01  basic structure
25877 + *
25878 + */
25879 +
25880 +#include <linux/module.h>
25881 +#include <linux/ctype.h>
25882 +#include <linux/sysctl.h>
25883 +#include <linux/parser.h>
25884 +#include <asm/uaccess.h>
25885 +
25886 +enum {
25887 +       CTL_DEBUG_ERROR         = 0,
25888 +       CTL_DEBUG_SWITCH        = 1,
25889 +       CTL_DEBUG_XID,
25890 +       CTL_DEBUG_NID,
25891 +       CTL_DEBUG_TAG,
25892 +       CTL_DEBUG_NET,
25893 +       CTL_DEBUG_LIMIT,
25894 +       CTL_DEBUG_CRES,
25895 +       CTL_DEBUG_DLIM,
25896 +       CTL_DEBUG_QUOTA,
25897 +       CTL_DEBUG_CVIRT,
25898 +       CTL_DEBUG_SPACE,
25899 +       CTL_DEBUG_MISC,
25900 +};
25901 +
25902 +
25903 +unsigned int vx_debug_switch   = 0;
25904 +unsigned int vx_debug_xid      = 0;
25905 +unsigned int vx_debug_nid      = 0;
25906 +unsigned int vx_debug_tag      = 0;
25907 +unsigned int vx_debug_net      = 0;
25908 +unsigned int vx_debug_limit    = 0;
25909 +unsigned int vx_debug_cres     = 0;
25910 +unsigned int vx_debug_dlim     = 0;
25911 +unsigned int vx_debug_quota    = 0;
25912 +unsigned int vx_debug_cvirt    = 0;
25913 +unsigned int vx_debug_space    = 0;
25914 +unsigned int vx_debug_misc     = 0;
25915 +
25916 +
25917 +static struct ctl_table_header *vserver_table_header;
25918 +static ctl_table vserver_root_table[];
25919 +
25920 +
25921 +void vserver_register_sysctl(void)
25922 +{
25923 +       if (!vserver_table_header) {
25924 +               vserver_table_header = register_sysctl_table(vserver_root_table);
25925 +       }
25926 +
25927 +}
25928 +
25929 +void vserver_unregister_sysctl(void)
25930 +{
25931 +       if (vserver_table_header) {
25932 +               unregister_sysctl_table(vserver_table_header);
25933 +               vserver_table_header = NULL;
25934 +       }
25935 +}
25936 +
25937 +
25938 +static int proc_dodebug(ctl_table *table, int write,
25939 +       void __user *buffer, size_t *lenp, loff_t *ppos)
25940 +{
25941 +       char            tmpbuf[20], *p, c;
25942 +       unsigned int    value;
25943 +       size_t          left, len;
25944 +
25945 +       if ((*ppos && !write) || !*lenp) {
25946 +               *lenp = 0;
25947 +               return 0;
25948 +       }
25949 +
25950 +       left = *lenp;
25951 +
25952 +       if (write) {
25953 +               if (!access_ok(VERIFY_READ, buffer, left))
25954 +                       return -EFAULT;
25955 +               p = (char *)buffer;
25956 +               while (left && __get_user(c, p) >= 0 && isspace(c))
25957 +                       left--, p++;
25958 +               if (!left)
25959 +                       goto done;
25960 +
25961 +               if (left > sizeof(tmpbuf) - 1)
25962 +                       return -EINVAL;
25963 +               if (copy_from_user(tmpbuf, p, left))
25964 +                       return -EFAULT;
25965 +               tmpbuf[left] = '\0';
25966 +
25967 +               for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25968 +                       value = 10 * value + (*p - '0');
25969 +               if (*p && !isspace(*p))
25970 +                       return -EINVAL;
25971 +               while (left && isspace(*p))
25972 +                       left--, p++;
25973 +               *(unsigned int *)table->data = value;
25974 +       } else {
25975 +               if (!access_ok(VERIFY_WRITE, buffer, left))
25976 +                       return -EFAULT;
25977 +               len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25978 +               if (len > left)
25979 +                       len = left;
25980 +               if (__copy_to_user(buffer, tmpbuf, len))
25981 +                       return -EFAULT;
25982 +               if ((left -= len) > 0) {
25983 +                       if (put_user('\n', (char *)buffer + len))
25984 +                               return -EFAULT;
25985 +                       left--;
25986 +               }
25987 +       }
25988 +
25989 +done:
25990 +       *lenp -= left;
25991 +       *ppos += *lenp;
25992 +       return 0;
25993 +}
25994 +
25995 +static int zero;
25996 +
25997 +#define        CTL_ENTRY(ctl, name)                            \
25998 +       {                                               \
25999 +               .procname       = #name,                \
26000 +               .data           = &vx_ ## name,         \
26001 +               .maxlen         = sizeof(int),          \
26002 +               .mode           = 0644,                 \
26003 +               .proc_handler   = &proc_dodebug,        \
26004 +               .extra1         = &zero,                \
26005 +               .extra2         = &zero,                \
26006 +       }
26007 +
26008 +static ctl_table vserver_debug_table[] = {
26009 +       CTL_ENTRY(CTL_DEBUG_SWITCH,     debug_switch),
26010 +       CTL_ENTRY(CTL_DEBUG_XID,        debug_xid),
26011 +       CTL_ENTRY(CTL_DEBUG_NID,        debug_nid),
26012 +       CTL_ENTRY(CTL_DEBUG_TAG,        debug_tag),
26013 +       CTL_ENTRY(CTL_DEBUG_NET,        debug_net),
26014 +       CTL_ENTRY(CTL_DEBUG_LIMIT,      debug_limit),
26015 +       CTL_ENTRY(CTL_DEBUG_CRES,       debug_cres),
26016 +       CTL_ENTRY(CTL_DEBUG_DLIM,       debug_dlim),
26017 +       CTL_ENTRY(CTL_DEBUG_QUOTA,      debug_quota),
26018 +       CTL_ENTRY(CTL_DEBUG_CVIRT,      debug_cvirt),
26019 +       CTL_ENTRY(CTL_DEBUG_SPACE,      debug_space),
26020 +       CTL_ENTRY(CTL_DEBUG_MISC,       debug_misc),
26021 +       { 0 }
26022 +};
26023 +
26024 +static ctl_table vserver_root_table[] = {
26025 +       {
26026 +               .procname       = "vserver",
26027 +               .mode           = 0555,
26028 +               .child          = vserver_debug_table
26029 +       },
26030 +       { 0 }
26031 +};
26032 +
26033 +
26034 +static match_table_t tokens = {
26035 +       { CTL_DEBUG_SWITCH,     "switch=%x"     },
26036 +       { CTL_DEBUG_XID,        "xid=%x"        },
26037 +       { CTL_DEBUG_NID,        "nid=%x"        },
26038 +       { CTL_DEBUG_TAG,        "tag=%x"        },
26039 +       { CTL_DEBUG_NET,        "net=%x"        },
26040 +       { CTL_DEBUG_LIMIT,      "limit=%x"      },
26041 +       { CTL_DEBUG_CRES,       "cres=%x"       },
26042 +       { CTL_DEBUG_DLIM,       "dlim=%x"       },
26043 +       { CTL_DEBUG_QUOTA,      "quota=%x"      },
26044 +       { CTL_DEBUG_CVIRT,      "cvirt=%x"      },
26045 +       { CTL_DEBUG_SPACE,      "space=%x"      },
26046 +       { CTL_DEBUG_MISC,       "misc=%x"       },
26047 +       { CTL_DEBUG_ERROR,      NULL            }
26048 +};
26049 +
26050 +#define        HANDLE_CASE(id, name, val)                              \
26051 +       case CTL_DEBUG_ ## id:                                  \
26052 +               vx_debug_ ## name = val;                        \
26053 +               printk("vs_debug_" #name "=0x%x\n", val);       \
26054 +               break
26055 +
26056 +
26057 +static int __init vs_debug_setup(char *str)
26058 +{
26059 +       char *p;
26060 +       int token;
26061 +
26062 +       printk("vs_debug_setup(%s)\n", str);
26063 +       while ((p = strsep(&str, ",")) != NULL) {
26064 +               substring_t args[MAX_OPT_ARGS];
26065 +               unsigned int value;
26066 +
26067 +               if (!*p)
26068 +                       continue;
26069 +
26070 +               token = match_token(p, tokens, args);
26071 +               value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
26072 +
26073 +               switch (token) {
26074 +               HANDLE_CASE(SWITCH, switch, value);
26075 +               HANDLE_CASE(XID,    xid,    value);
26076 +               HANDLE_CASE(NID,    nid,    value);
26077 +               HANDLE_CASE(TAG,    tag,    value);
26078 +               HANDLE_CASE(NET,    net,    value);
26079 +               HANDLE_CASE(LIMIT,  limit,  value);
26080 +               HANDLE_CASE(CRES,   cres,   value);
26081 +               HANDLE_CASE(DLIM,   dlim,   value);
26082 +               HANDLE_CASE(QUOTA,  quota,  value);
26083 +               HANDLE_CASE(CVIRT,  cvirt,  value);
26084 +               HANDLE_CASE(SPACE,  space,  value);
26085 +               HANDLE_CASE(MISC,   misc,   value);
26086 +               default:
26087 +                       return -EINVAL;
26088 +                       break;
26089 +               }
26090 +       }
26091 +       return 1;
26092 +}
26093 +
26094 +__setup("vsdebug=", vs_debug_setup);
26095 +
26096 +
26097 +
26098 +EXPORT_SYMBOL_GPL(vx_debug_switch);
26099 +EXPORT_SYMBOL_GPL(vx_debug_xid);
26100 +EXPORT_SYMBOL_GPL(vx_debug_nid);
26101 +EXPORT_SYMBOL_GPL(vx_debug_net);
26102 +EXPORT_SYMBOL_GPL(vx_debug_limit);
26103 +EXPORT_SYMBOL_GPL(vx_debug_cres);
26104 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
26105 +EXPORT_SYMBOL_GPL(vx_debug_quota);
26106 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
26107 +EXPORT_SYMBOL_GPL(vx_debug_space);
26108 +EXPORT_SYMBOL_GPL(vx_debug_misc);
26109 +
26110 diff -NurpP --minimal linux-2.6.35/kernel/vserver/tag.c linux-2.6.35-vs2.3.0.36.31/kernel/vserver/tag.c
26111 --- linux-2.6.35/kernel/vserver/tag.c   1970-01-01 01:00:00.000000000 +0100
26112 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/tag.c     2010-08-02 17:05:06.000000000 +0200
26113 @@ -0,0 +1,63 @@
26114 +/*
26115 + *  linux/kernel/vserver/tag.c
26116 + *
26117 + *  Virtual Server: Shallow Tag Space
26118 + *
26119 + *  Copyright (C) 2007  Herbert Pötzl
26120 + *
26121 + *  V0.01  basic implementation
26122 + *
26123 + */
26124 +
26125 +#include <linux/sched.h>
26126 +#include <linux/vserver/debug.h>
26127 +#include <linux/vs_pid.h>
26128 +#include <linux/vs_tag.h>
26129 +
26130 +#include <linux/vserver/tag_cmd.h>
26131 +
26132 +
26133 +int dx_migrate_task(struct task_struct *p, tag_t tag)
26134 +{
26135 +       if (!p)
26136 +               BUG();
26137 +
26138 +       vxdprintk(VXD_CBIT(tag, 5),
26139 +               "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
26140 +
26141 +       task_lock(p);
26142 +       p->tag = tag;
26143 +       task_unlock(p);
26144 +
26145 +       vxdprintk(VXD_CBIT(tag, 5),
26146 +               "moved task %p into [#%d]", p, tag);
26147 +       return 0;
26148 +}
26149 +
26150 +/* vserver syscall commands below here */
26151 +
26152 +/* taks xid and vx_info functions */
26153 +
26154 +
26155 +int vc_task_tag(uint32_t id)
26156 +{
26157 +       tag_t tag;
26158 +
26159 +       if (id) {
26160 +               struct task_struct *tsk;
26161 +               read_lock(&tasklist_lock);
26162 +               tsk = find_task_by_real_pid(id);
26163 +               tag = (tsk) ? tsk->tag : -ESRCH;
26164 +               read_unlock(&tasklist_lock);
26165 +       } else
26166 +               tag = dx_current_tag();
26167 +       return tag;
26168 +}
26169 +
26170 +
26171 +int vc_tag_migrate(uint32_t tag)
26172 +{
26173 +       return dx_migrate_task(current, tag & 0xFFFF);
26174 +}
26175 +
26176 +
26177 diff -NurpP --minimal linux-2.6.35/kernel/vserver/vci_config.h linux-2.6.35-vs2.3.0.36.31/kernel/vserver/vci_config.h
26178 --- linux-2.6.35/kernel/vserver/vci_config.h    1970-01-01 01:00:00.000000000 +0100
26179 +++ linux-2.6.35-vs2.3.0.36.31/kernel/vserver/vci_config.h      2010-08-02 17:05:06.000000000 +0200
26180 @@ -0,0 +1,85 @@
26181 +
26182 +/*  interface version */
26183 +
26184 +#define VCI_VERSION            0x00020306
26185 +
26186 +
26187 +enum {
26188 +       VCI_KCBIT_NO_DYNAMIC = 0,
26189 +
26190 +       VCI_KCBIT_PROC_SECURE = 4,
26191 +       VCI_KCBIT_HARDCPU = 5,
26192 +       VCI_KCBIT_IDLELIMIT = 6,
26193 +       VCI_KCBIT_IDLETIME = 7,
26194 +
26195 +       VCI_KCBIT_COWBL = 8,
26196 +       VCI_KCBIT_FULLCOWBL = 9,
26197 +       VCI_KCBIT_SPACES = 10,
26198 +       VCI_KCBIT_NETV2 = 11,
26199 +       VCI_KCBIT_MEMCG = 12,
26200 +
26201 +       VCI_KCBIT_DEBUG = 16,
26202 +       VCI_KCBIT_HISTORY = 20,
26203 +       VCI_KCBIT_TAGGED = 24,
26204 +       VCI_KCBIT_PPTAG = 28,
26205 +
26206 +       VCI_KCBIT_MORE = 31,
26207 +};
26208 +
26209 +
26210 +static inline uint32_t vci_kernel_config(void)
26211 +{
26212 +       return
26213 +       (1 << VCI_KCBIT_NO_DYNAMIC) |
26214 +
26215 +       /* configured features */
26216 +#ifdef CONFIG_VSERVER_PROC_SECURE
26217 +       (1 << VCI_KCBIT_PROC_SECURE) |
26218 +#endif
26219 +#ifdef CONFIG_VSERVER_HARDCPU
26220 +       (1 << VCI_KCBIT_HARDCPU) |
26221 +#endif
26222 +#ifdef CONFIG_VSERVER_IDLELIMIT
26223 +       (1 << VCI_KCBIT_IDLELIMIT) |
26224 +#endif
26225 +#ifdef CONFIG_VSERVER_IDLETIME
26226 +       (1 << VCI_KCBIT_IDLETIME) |
26227 +#endif
26228 +#ifdef CONFIG_VSERVER_COWBL
26229 +       (1 << VCI_KCBIT_COWBL) |
26230 +       (1 << VCI_KCBIT_FULLCOWBL) |
26231 +#endif
26232 +       (1 << VCI_KCBIT_SPACES) |
26233 +       (1 << VCI_KCBIT_NETV2) |
26234 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
26235 +       (1 << VCI_KCBIT_MEMCG) |
26236 +#endif
26237 +
26238 +       /* debug options */
26239 +#ifdef CONFIG_VSERVER_DEBUG
26240 +       (1 << VCI_KCBIT_DEBUG) |
26241 +#endif
26242 +#ifdef CONFIG_VSERVER_HISTORY
26243 +       (1 << VCI_KCBIT_HISTORY) |
26244 +#endif
26245 +
26246 +       /* inode context tagging */
26247 +#if    defined(CONFIG_TAGGING_NONE)
26248 +       (0 << VCI_KCBIT_TAGGED) |
26249 +#elif  defined(CONFIG_TAGGING_UID16)
26250 +       (1 << VCI_KCBIT_TAGGED) |
26251 +#elif  defined(CONFIG_TAGGING_GID16)
26252 +       (2 << VCI_KCBIT_TAGGED) |
26253 +#elif  defined(CONFIG_TAGGING_ID24)
26254 +       (3 << VCI_KCBIT_TAGGED) |
26255 +#elif  defined(CONFIG_TAGGING_INTERN)
26256 +       (4 << VCI_KCBIT_TAGGED) |
26257 +#elif  defined(CONFIG_TAGGING_RUNTIME)
26258 +       (5 << VCI_KCBIT_TAGGED) |
26259 +#else
26260 +       (7 << VCI_KCBIT_TAGGED) |
26261 +#endif
26262 +       (1 << VCI_KCBIT_PPTAG) |
26263 +       0;
26264 +}
26265 +
26266 diff -NurpP --minimal linux-2.6.35/mm/filemap_xip.c linux-2.6.35-vs2.3.0.36.31/mm/filemap_xip.c
26267 --- linux-2.6.35/mm/filemap_xip.c       2010-07-07 18:31:58.000000000 +0200
26268 +++ linux-2.6.35-vs2.3.0.36.31/mm/filemap_xip.c 2010-08-02 17:05:06.000000000 +0200
26269 @@ -18,6 +18,7 @@
26270  #include <linux/seqlock.h>
26271  #include <linux/mutex.h>
26272  #include <linux/gfp.h>
26273 +#include <linux/vs_memory.h>
26274  #include <asm/tlbflush.h>
26275  #include <asm/io.h>
26276  
26277 diff -NurpP --minimal linux-2.6.35/mm/fremap.c linux-2.6.35-vs2.3.0.36.31/mm/fremap.c
26278 --- linux-2.6.35/mm/fremap.c    2010-07-07 18:31:58.000000000 +0200
26279 +++ linux-2.6.35-vs2.3.0.36.31/mm/fremap.c      2010-08-02 17:05:06.000000000 +0200
26280 @@ -16,6 +16,7 @@
26281  #include <linux/module.h>
26282  #include <linux/syscalls.h>
26283  #include <linux/mmu_notifier.h>
26284 +#include <linux/vs_memory.h>
26285  
26286  #include <asm/mmu_context.h>
26287  #include <asm/cacheflush.h>
26288 diff -NurpP --minimal linux-2.6.35/mm/hugetlb.c linux-2.6.35-vs2.3.0.36.31/mm/hugetlb.c
26289 --- linux-2.6.35/mm/hugetlb.c   2010-08-02 16:52:58.000000000 +0200
26290 +++ linux-2.6.35-vs2.3.0.36.31/mm/hugetlb.c     2010-08-02 17:05:06.000000000 +0200
26291 @@ -25,6 +25,7 @@
26292  
26293  #include <linux/hugetlb.h>
26294  #include <linux/node.h>
26295 +#include <linux/vs_memory.h>
26296  #include "internal.h"
26297  
26298  const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26299 diff -NurpP --minimal linux-2.6.35/mm/memcontrol.c linux-2.6.35-vs2.3.0.36.31/mm/memcontrol.c
26300 --- linux-2.6.35/mm/memcontrol.c        2010-08-02 16:52:58.000000000 +0200
26301 +++ linux-2.6.35-vs2.3.0.36.31/mm/memcontrol.c  2010-08-02 17:05:06.000000000 +0200
26302 @@ -635,6 +635,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26303                                 struct mem_cgroup, css);
26304  }
26305  
26306 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26307 +{
26308 +       return res_counter_read_u64(&mem->res, member);
26309 +}
26310 +
26311 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26312 +{
26313 +       return res_counter_read_u64(&mem->memsw, member);
26314 +}
26315 +
26316 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26317 +{
26318 +       return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
26319 +}
26320 +
26321 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26322 +{
26323 +       return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
26324 +}
26325 +
26326 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26327 +{
26328 +       return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
26329 +}
26330 +
26331  static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26332  {
26333         struct mem_cgroup *mem = NULL;
26334 diff -NurpP --minimal linux-2.6.35/mm/memory.c linux-2.6.35-vs2.3.0.36.31/mm/memory.c
26335 --- linux-2.6.35/mm/memory.c    2010-08-02 16:52:58.000000000 +0200
26336 +++ linux-2.6.35-vs2.3.0.36.31/mm/memory.c      2010-08-02 17:05:06.000000000 +0200
26337 @@ -3076,6 +3076,7 @@ static inline int handle_pte_fault(struc
26338  {
26339         pte_t entry;
26340         spinlock_t *ptl;
26341 +       int ret = 0, type = VXPT_UNKNOWN;
26342  
26343         entry = *pte;
26344         if (!pte_present(entry)) {
26345 @@ -3100,9 +3101,12 @@ static inline int handle_pte_fault(struc
26346         if (unlikely(!pte_same(*pte, entry)))
26347                 goto unlock;
26348         if (flags & FAULT_FLAG_WRITE) {
26349 -               if (!pte_write(entry))
26350 -                       return do_wp_page(mm, vma, address,
26351 +               if (!pte_write(entry)) {
26352 +                       ret = do_wp_page(mm, vma, address,
26353                                         pte, pmd, ptl, entry);
26354 +                       type = VXPT_WRITE;
26355 +                       goto out;
26356 +               }
26357                 entry = pte_mkdirty(entry);
26358         }
26359         entry = pte_mkyoung(entry);
26360 @@ -3120,7 +3124,10 @@ static inline int handle_pte_fault(struc
26361         }
26362  unlock:
26363         pte_unmap_unlock(pte, ptl);
26364 -       return 0;
26365 +       ret = 0;
26366 +out:
26367 +       vx_page_fault(mm, vma, type, ret);
26368 +       return ret;
26369  }
26370  
26371  /*
26372 diff -NurpP --minimal linux-2.6.35/mm/mlock.c linux-2.6.35-vs2.3.0.36.31/mm/mlock.c
26373 --- linux-2.6.35/mm/mlock.c     2010-08-02 16:52:58.000000000 +0200
26374 +++ linux-2.6.35-vs2.3.0.36.31/mm/mlock.c       2010-08-02 17:05:06.000000000 +0200
26375 @@ -18,6 +18,7 @@
26376  #include <linux/rmap.h>
26377  #include <linux/mmzone.h>
26378  #include <linux/hugetlb.h>
26379 +#include <linux/vs_memory.h>
26380  
26381  #include "internal.h"
26382  
26383 @@ -471,7 +472,7 @@ static int do_mlock(unsigned long start,
26384  
26385  SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
26386  {
26387 -       unsigned long locked;
26388 +       unsigned long locked, grow;
26389         unsigned long lock_limit;
26390         int error = -ENOMEM;
26391  
26392 @@ -493,6 +494,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26393         /* check against resource limits */
26394         if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26395                 error = do_mlock(start, len, 1);
26396 +out:
26397         up_write(&current->mm->mmap_sem);
26398         return error;
26399  }
26400 diff -NurpP --minimal linux-2.6.35/mm/mremap.c linux-2.6.35-vs2.3.0.36.31/mm/mremap.c
26401 --- linux-2.6.35/mm/mremap.c    2010-07-07 18:31:58.000000000 +0200
26402 +++ linux-2.6.35-vs2.3.0.36.31/mm/mremap.c      2010-08-02 17:05:06.000000000 +0200
26403 @@ -19,6 +19,7 @@
26404  #include <linux/security.h>
26405  #include <linux/syscalls.h>
26406  #include <linux/mmu_notifier.h>
26407 +#include <linux/vs_memory.h>
26408  
26409  #include <asm/uaccess.h>
26410  #include <asm/cacheflush.h>
26411 diff -NurpP --minimal linux-2.6.35/mm/oom_kill.c linux-2.6.35-vs2.3.0.36.31/mm/oom_kill.c
26412 --- linux-2.6.35/mm/oom_kill.c  2010-08-02 16:52:58.000000000 +0200
26413 +++ linux-2.6.35-vs2.3.0.36.31/mm/oom_kill.c    2010-08-02 17:05:06.000000000 +0200
26414 @@ -28,6 +28,9 @@
26415  #include <linux/notifier.h>
26416  #include <linux/memcontrol.h>
26417  #include <linux/security.h>
26418 +#include <linux/reboot.h>
26419 +#include <linux/vs_memory.h>
26420 +#include <linux/vs_context.h>
26421  
26422  int sysctl_panic_on_oom;
26423  int sysctl_oom_kill_allocating_task;
26424 @@ -187,9 +190,21 @@ unsigned long badness(struct task_struct
26425                         points >>= -(oom_adj);
26426         }
26427  
26428 +       /*
26429 +        * add points for context badness and
26430 +        * reduce badness for processes belonging to
26431 +        * a different context
26432 +        */
26433 +
26434 +       points += vx_badness(p, mm);
26435 +
26436 +       if ((vx_current_xid() > 1) &&
26437 +               vx_current_xid() != vx_task_xid(p))
26438 +               points /= 16;
26439 +
26440  #ifdef DEBUG
26441 -       printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26442 -       p->pid, p->comm, points);
26443 +       printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26444 +               task_pid_nr(p), p->xid, p->comm, points);
26445  #endif
26446         return points;
26447  }
26448 @@ -250,6 +265,7 @@ static struct task_struct *select_bad_pr
26449         struct task_struct *p;
26450         struct task_struct *chosen = NULL;
26451         struct timespec uptime;
26452 +       unsigned xid = vx_current_xid();
26453         *ppoints = 0;
26454  
26455         do_posix_clock_monotonic_gettime(&uptime);
26456 @@ -262,11 +278,14 @@ static struct task_struct *select_bad_pr
26457                  */
26458                 if (!p->mm)
26459                         continue;
26460 -               /* skip the init task */
26461 -               if (is_global_init(p))
26462 +               /* skip the init task, global and per guest */
26463 +               if (task_is_init(p))
26464                         continue;
26465                 if (mem && !task_in_mem_cgroup(p, mem))
26466                         continue;
26467 +               /* skip other guest and host processes if oom in guest */
26468 +               if (xid && vx_task_xid(p) != xid)
26469 +                       continue;
26470  
26471                 /*
26472                  * This task already has access to memory reserves and is
26473 @@ -398,9 +417,9 @@ static void __oom_kill_task(struct task_
26474         }
26475  
26476         if (verbose)
26477 -               printk(KERN_ERR "Killed process %d (%s) "
26478 +               printk(KERN_ERR "Killed process %s(%d:#%u) "
26479                        "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
26480 -                      task_pid_nr(p), p->comm,
26481 +                      p->comm, task_pid_nr(p), p->xid,
26482                        K(p->mm->total_vm),
26483                        K(get_mm_counter(p->mm, MM_ANONPAGES)),
26484                        K(get_mm_counter(p->mm, MM_FILEPAGES)));
26485 @@ -453,8 +472,8 @@ static int oom_kill_process(struct task_
26486                 return 0;
26487         }
26488  
26489 -       printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26490 -                                       message, task_pid_nr(p), p->comm, points);
26491 +       printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
26492 +               message, p->comm, task_pid_nr(p), p->xid, points);
26493  
26494         /* Try to kill a child first */
26495         list_for_each_entry(c, &p->children, sibling) {
26496 @@ -554,6 +573,8 @@ void clear_zonelist_oom(struct zonelist 
26497         spin_unlock(&zone_scan_lock);
26498  }
26499  
26500 +long vs_oom_action(unsigned int);
26501 +
26502  /*
26503   * Must be called with tasklist_lock held for read.
26504   */
26505 @@ -580,7 +601,11 @@ retry:
26506         if (!p) {
26507                 read_unlock(&tasklist_lock);
26508                 dump_header(NULL, gfp_mask, order, NULL);
26509 -               panic("Out of memory and no killable processes...\n");
26510 +               /* avoid panic for guest OOM */
26511 +               if (current->xid)
26512 +                       vs_oom_action(LINUX_REBOOT_CMD_OOM);
26513 +               else
26514 +                       panic("Out of memory and no killable processes...\n");
26515         }
26516  
26517         if (oom_kill_process(p, gfp_mask, order, points, NULL,
26518 diff -NurpP --minimal linux-2.6.35/mm/page_alloc.c linux-2.6.35-vs2.3.0.36.31/mm/page_alloc.c
26519 --- linux-2.6.35/mm/page_alloc.c        2010-08-02 16:52:58.000000000 +0200
26520 +++ linux-2.6.35-vs2.3.0.36.31/mm/page_alloc.c  2010-08-02 17:46:11.000000000 +0200
26521 @@ -52,6 +52,8 @@
26522  #include <linux/compaction.h>
26523  #include <trace/events/kmem.h>
26524  #include <linux/ftrace_event.h>
26525 +#include <linux/vs_base.h>
26526 +#include <linux/vs_limit.h>
26527  
26528  #include <asm/tlbflush.h>
26529  #include <asm/div64.h>
26530 @@ -2305,6 +2307,9 @@ void si_meminfo(struct sysinfo *val)
26531         val->totalhigh = totalhigh_pages;
26532         val->freehigh = nr_free_highpages();
26533         val->mem_unit = PAGE_SIZE;
26534 +
26535 +       if (vx_flags(VXF_VIRT_MEM, 0))
26536 +               vx_vsi_meminfo(val);
26537  }
26538  
26539  EXPORT_SYMBOL(si_meminfo);
26540 @@ -2325,6 +2330,9 @@ void si_meminfo_node(struct sysinfo *val
26541         val->freehigh = 0;
26542  #endif
26543         val->mem_unit = PAGE_SIZE;
26544 +
26545 +       if (vx_flags(VXF_VIRT_MEM, 0))
26546 +               vx_vsi_meminfo(val);
26547  }
26548  #endif
26549  
26550 diff -NurpP --minimal linux-2.6.35/mm/rmap.c linux-2.6.35-vs2.3.0.36.31/mm/rmap.c
26551 --- linux-2.6.35/mm/rmap.c      2010-08-02 16:52:58.000000000 +0200
26552 +++ linux-2.6.35-vs2.3.0.36.31/mm/rmap.c        2010-08-02 17:05:06.000000000 +0200
26553 @@ -56,6 +56,7 @@
26554  #include <linux/memcontrol.h>
26555  #include <linux/mmu_notifier.h>
26556  #include <linux/migrate.h>
26557 +#include <linux/vs_memory.h>
26558  
26559  #include <asm/tlbflush.h>
26560  
26561 diff -NurpP --minimal linux-2.6.35/mm/shmem.c linux-2.6.35-vs2.3.0.36.31/mm/shmem.c
26562 --- linux-2.6.35/mm/shmem.c     2010-08-02 16:52:58.000000000 +0200
26563 +++ linux-2.6.35-vs2.3.0.36.31/mm/shmem.c       2010-08-02 17:05:06.000000000 +0200
26564 @@ -1788,7 +1788,7 @@ static int shmem_statfs(struct dentry *d
26565  {
26566         struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26567  
26568 -       buf->f_type = TMPFS_MAGIC;
26569 +       buf->f_type = TMPFS_SUPER_MAGIC;
26570         buf->f_bsize = PAGE_CACHE_SIZE;
26571         buf->f_namelen = NAME_MAX;
26572         spin_lock(&sbinfo->stat_lock);
26573 @@ -2350,7 +2350,7 @@ int shmem_fill_super(struct super_block 
26574         sb->s_maxbytes = SHMEM_MAX_BYTES;
26575         sb->s_blocksize = PAGE_CACHE_SIZE;
26576         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26577 -       sb->s_magic = TMPFS_MAGIC;
26578 +       sb->s_magic = TMPFS_SUPER_MAGIC;
26579         sb->s_op = &shmem_ops;
26580         sb->s_time_gran = 1;
26581  #ifdef CONFIG_TMPFS_POSIX_ACL
26582 diff -NurpP --minimal linux-2.6.35/mm/slab.c linux-2.6.35-vs2.3.0.36.31/mm/slab.c
26583 --- linux-2.6.35/mm/slab.c      2010-08-02 16:52:58.000000000 +0200
26584 +++ linux-2.6.35-vs2.3.0.36.31/mm/slab.c        2010-08-02 17:05:06.000000000 +0200
26585 @@ -408,6 +408,8 @@ static void kmem_list3_init(struct kmem_
26586  #define STATS_INC_FREEMISS(x)  do { } while (0)
26587  #endif
26588  
26589 +#include "slab_vs.h"
26590 +
26591  #if DEBUG
26592  
26593  /*
26594 @@ -3347,6 +3349,7 @@ retry:
26595  
26596         obj = slab_get_obj(cachep, slabp, nodeid);
26597         check_slabp(cachep, slabp);
26598 +       vx_slab_alloc(cachep, flags);
26599         l3->free_objects--;
26600         /* move slabp to correct slabp list: */
26601         list_del(&slabp->list);
26602 @@ -3424,6 +3427,7 @@ __cache_alloc_node(struct kmem_cache *ca
26603         /* ___cache_alloc_node can fall back to other nodes */
26604         ptr = ____cache_alloc_node(cachep, flags, nodeid);
26605    out:
26606 +       vx_slab_alloc(cachep, flags);
26607         local_irq_restore(save_flags);
26608         ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26609         kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
26610 @@ -3610,6 +3614,7 @@ static inline void __cache_free(struct k
26611         check_irq_off();
26612         kmemleak_free_recursive(objp, cachep->flags);
26613         objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26614 +       vx_slab_free(cachep);
26615  
26616         kmemcheck_slab_free(cachep, objp, obj_size(cachep));
26617  
26618 diff -NurpP --minimal linux-2.6.35/mm/slab_vs.h linux-2.6.35-vs2.3.0.36.31/mm/slab_vs.h
26619 --- linux-2.6.35/mm/slab_vs.h   1970-01-01 01:00:00.000000000 +0100
26620 +++ linux-2.6.35-vs2.3.0.36.31/mm/slab_vs.h     2010-08-02 17:05:06.000000000 +0200
26621 @@ -0,0 +1,29 @@
26622 +
26623 +#include <linux/vserver/context.h>
26624 +
26625 +#include <linux/vs_context.h>
26626 +
26627 +static inline
26628 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26629 +{
26630 +       int what = gfp_zone(cachep->gfpflags);
26631 +       struct vx_info *vxi = current_vx_info();
26632 +
26633 +       if (!vxi)
26634 +               return;
26635 +
26636 +       atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
26637 +}
26638 +
26639 +static inline
26640 +void vx_slab_free(struct kmem_cache *cachep)
26641 +{
26642 +       int what = gfp_zone(cachep->gfpflags);
26643 +       struct vx_info *vxi = current_vx_info();
26644 +
26645 +       if (!vxi)
26646 +               return;
26647 +
26648 +       atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
26649 +}
26650 +
26651 diff -NurpP --minimal linux-2.6.35/mm/swapfile.c linux-2.6.35-vs2.3.0.36.31/mm/swapfile.c
26652 --- linux-2.6.35/mm/swapfile.c  2010-08-02 16:52:58.000000000 +0200
26653 +++ linux-2.6.35-vs2.3.0.36.31/mm/swapfile.c    2010-08-02 17:05:06.000000000 +0200
26654 @@ -35,6 +35,8 @@
26655  #include <asm/tlbflush.h>
26656  #include <linux/swapops.h>
26657  #include <linux/page_cgroup.h>
26658 +#include <linux/vs_base.h>
26659 +#include <linux/vs_memory.h>
26660  
26661  static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
26662                                  unsigned char);
26663 @@ -1732,6 +1734,16 @@ static int swap_show(struct seq_file *sw
26664  
26665         if (si == SEQ_START_TOKEN) {
26666                 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
26667 +               if (vx_flags(VXF_VIRT_MEM, 0)) {
26668 +                       struct sysinfo si;
26669 +
26670 +                       vx_vsi_swapinfo(&si);
26671 +                       if (si.totalswap < (1 << 10))
26672 +                               return 0;
26673 +                       seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
26674 +                               "hdv0", "partition", si.totalswap >> 10,
26675 +                               (si.totalswap - si.freeswap) >> 10, -1);
26676 +               }
26677                 return 0;
26678         }
26679  
26680 @@ -2116,6 +2128,8 @@ void si_swapinfo(struct sysinfo *val)
26681         val->freeswap = nr_swap_pages + nr_to_be_unused;
26682         val->totalswap = total_swap_pages + nr_to_be_unused;
26683         spin_unlock(&swap_lock);
26684 +       if (vx_flags(VXF_VIRT_MEM, 0))
26685 +               vx_vsi_swapinfo(val);
26686  }
26687  
26688  /*
26689 diff -NurpP --minimal linux-2.6.35/net/core/dev.c linux-2.6.35-vs2.3.0.36.31/net/core/dev.c
26690 --- linux-2.6.35/net/core/dev.c 2010-08-02 16:52:59.000000000 +0200
26691 +++ linux-2.6.35-vs2.3.0.36.31/net/core/dev.c   2010-08-02 17:05:06.000000000 +0200
26692 @@ -129,6 +129,7 @@
26693  #include <linux/in.h>
26694  #include <linux/jhash.h>
26695  #include <linux/random.h>
26696 +#include <linux/vs_inet.h>
26697  #include <trace/events/napi.h>
26698  #include <linux/pci.h>
26699  
26700 @@ -609,7 +610,8 @@ struct net_device *__dev_get_by_name(str
26701         struct hlist_head *head = dev_name_hash(net, name);
26702  
26703         hlist_for_each_entry(dev, p, head, name_hlist)
26704 -               if (!strncmp(dev->name, name, IFNAMSIZ))
26705 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
26706 +                   nx_dev_visible(current_nx_info(), dev))
26707                         return dev;
26708  
26709         return NULL;
26710 @@ -635,7 +637,8 @@ struct net_device *dev_get_by_name_rcu(s
26711         struct hlist_head *head = dev_name_hash(net, name);
26712  
26713         hlist_for_each_entry_rcu(dev, p, head, name_hlist)
26714 -               if (!strncmp(dev->name, name, IFNAMSIZ))
26715 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
26716 +                   nx_dev_visible(current_nx_info(), dev))
26717                         return dev;
26718  
26719         return NULL;
26720 @@ -686,7 +689,8 @@ struct net_device *__dev_get_by_index(st
26721         struct hlist_head *head = dev_index_hash(net, ifindex);
26722  
26723         hlist_for_each_entry(dev, p, head, index_hlist)
26724 -               if (dev->ifindex == ifindex)
26725 +               if ((dev->ifindex == ifindex) &&
26726 +                   nx_dev_visible(current_nx_info(), dev))
26727                         return dev;
26728  
26729         return NULL;
26730 @@ -711,7 +715,8 @@ struct net_device *dev_get_by_index_rcu(
26731         struct hlist_head *head = dev_index_hash(net, ifindex);
26732  
26733         hlist_for_each_entry_rcu(dev, p, head, index_hlist)
26734 -               if (dev->ifindex == ifindex)
26735 +               if ((dev->ifindex == ifindex) &&
26736 +                   nx_dev_visible(current_nx_info(), dev))
26737                         return dev;
26738  
26739         return NULL;
26740 @@ -764,10 +769,12 @@ struct net_device *dev_getbyhwaddr(struc
26741  
26742         ASSERT_RTNL();
26743  
26744 -       for_each_netdev(net, dev)
26745 +       for_each_netdev(net, dev) {
26746                 if (dev->type == type &&
26747 -                   !memcmp(dev->dev_addr, ha, dev->addr_len))
26748 +                   !memcmp(dev->dev_addr, ha, dev->addr_len) &&
26749 +                   nx_dev_visible(current_nx_info(), dev))
26750                         return dev;
26751 +       }
26752  
26753         return NULL;
26754  }
26755 @@ -778,9 +785,11 @@ struct net_device *__dev_getfirstbyhwtyp
26756         struct net_device *dev;
26757  
26758         ASSERT_RTNL();
26759 -       for_each_netdev(net, dev)
26760 -               if (dev->type == type)
26761 +       for_each_netdev(net, dev) {
26762 +               if ((dev->type == type) &&
26763 +                   nx_dev_visible(current_nx_info(), dev))
26764                         return dev;
26765 +       }
26766  
26767         return NULL;
26768  }
26769 @@ -902,6 +911,8 @@ static int __dev_alloc_name(struct net *
26770                                 continue;
26771                         if (i < 0 || i >= max_netdevices)
26772                                 continue;
26773 +                       if (!nx_dev_visible(current_nx_info(), d))
26774 +                               continue;
26775  
26776                         /*  avoid cases where sscanf is not exact inverse of printf */
26777                         snprintf(buf, IFNAMSIZ, name, i);
26778 @@ -3651,6 +3662,8 @@ static int dev_ifconf(struct net *net, c
26779  
26780         total = 0;
26781         for_each_netdev(net, dev) {
26782 +               if (!nx_dev_visible(current_nx_info(), dev))
26783 +                       continue;
26784                 for (i = 0; i < NPROTO; i++) {
26785                         if (gifconf_list[i]) {
26786                                 int done;
26787 @@ -3721,6 +3734,9 @@ static void dev_seq_printf_stats(struct 
26788  {
26789         const struct net_device_stats *stats = dev_get_stats(dev);
26790  
26791 +       if (!nx_dev_visible(current_nx_info(), dev))
26792 +               return;
26793 +
26794         seq_printf(seq, "%6s: %7lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26795                    "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26796                    dev->name, stats->rx_bytes, stats->rx_packets,
26797 diff -NurpP --minimal linux-2.6.35/net/core/rtnetlink.c linux-2.6.35-vs2.3.0.36.31/net/core/rtnetlink.c
26798 --- linux-2.6.35/net/core/rtnetlink.c   2010-08-02 16:52:59.000000000 +0200
26799 +++ linux-2.6.35-vs2.3.0.36.31/net/core/rtnetlink.c     2010-08-02 17:05:06.000000000 +0200
26800 @@ -926,6 +926,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26801                 hlist_for_each_entry(dev, node, head, index_hlist) {
26802                         if (idx < s_idx)
26803                                 goto cont;
26804 +                       if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26805 +                               continue;
26806                         if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26807                                              NETLINK_CB(cb->skb).pid,
26808                                              cb->nlh->nlmsg_seq, 0,
26809 @@ -1642,6 +1644,9 @@ void rtmsg_ifinfo(int type, struct net_d
26810         struct sk_buff *skb;
26811         int err = -ENOBUFS;
26812  
26813 +       if (!nx_dev_visible(current_nx_info(), dev))
26814 +               return;
26815 +
26816         skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26817         if (skb == NULL)
26818                 goto errout;
26819 diff -NurpP --minimal linux-2.6.35/net/core/sock.c linux-2.6.35-vs2.3.0.36.31/net/core/sock.c
26820 --- linux-2.6.35/net/core/sock.c        2010-08-02 16:52:59.000000000 +0200
26821 +++ linux-2.6.35-vs2.3.0.36.31/net/core/sock.c  2010-08-02 17:05:06.000000000 +0200
26822 @@ -126,6 +126,10 @@
26823  #include <net/cls_cgroup.h>
26824  
26825  #include <linux/filter.h>
26826 +#include <linux/vs_socket.h>
26827 +#include <linux/vs_limit.h>
26828 +#include <linux/vs_context.h>
26829 +#include <linux/vs_network.h>
26830  
26831  #ifdef CONFIG_INET
26832  #include <net/tcp.h>
26833 @@ -1027,6 +1031,8 @@ static struct sock *sk_prot_alloc(struct
26834                         goto out_free_sec;
26835                 sk_tx_queue_clear(sk);
26836         }
26837 +               sock_vx_init(sk);
26838 +               sock_nx_init(sk);
26839  
26840         return sk;
26841  
26842 @@ -1120,6 +1126,11 @@ static void __sk_free(struct sock *sk)
26843                        __func__, atomic_read(&sk->sk_omem_alloc));
26844  
26845         put_net(sock_net(sk));
26846 +       vx_sock_dec(sk);
26847 +       clr_vx_info(&sk->sk_vx_info);
26848 +       sk->sk_xid = -1;
26849 +       clr_nx_info(&sk->sk_nx_info);
26850 +       sk->sk_nid = -1;
26851         sk_prot_free(sk->sk_prot_creator, sk);
26852  }
26853  
26854 @@ -1167,6 +1178,8 @@ struct sock *sk_clone(const struct sock 
26855  
26856                 /* SANITY */
26857                 get_net(sock_net(newsk));
26858 +               sock_vx_init(newsk);
26859 +               sock_nx_init(newsk);
26860                 sk_node_init(&newsk->sk_node);
26861                 sock_lock_init(newsk);
26862                 bh_lock_sock(newsk);
26863 @@ -1222,6 +1235,12 @@ struct sock *sk_clone(const struct sock 
26864                 smp_wmb();
26865                 atomic_set(&newsk->sk_refcnt, 2);
26866  
26867 +               set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26868 +               newsk->sk_xid = sk->sk_xid;
26869 +               vx_sock_inc(newsk);
26870 +               set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26871 +               newsk->sk_nid = sk->sk_nid;
26872 +
26873                 /*
26874                  * Increment the counter in the same struct proto as the master
26875                  * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26876 @@ -1964,6 +1983,12 @@ void sock_init_data(struct socket *sock,
26877  
26878         sk->sk_stamp = ktime_set(-1L, 0);
26879  
26880 +       set_vx_info(&sk->sk_vx_info, current_vx_info());
26881 +       sk->sk_xid = vx_current_xid();
26882 +       vx_sock_inc(sk);
26883 +       set_nx_info(&sk->sk_nx_info, current_nx_info());
26884 +       sk->sk_nid = nx_current_nid();
26885 +
26886         /*
26887          * Before updating sk_refcnt, we must commit prior changes to memory
26888          * (Documentation/RCU/rculist_nulls.txt for details)
26889 diff -NurpP --minimal linux-2.6.35/net/ipv4/af_inet.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/af_inet.c
26890 --- linux-2.6.35/net/ipv4/af_inet.c     2010-08-02 16:52:59.000000000 +0200
26891 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/af_inet.c       2010-08-02 17:05:06.000000000 +0200
26892 @@ -116,6 +116,7 @@
26893  #ifdef CONFIG_IP_MROUTE
26894  #include <linux/mroute.h>
26895  #endif
26896 +#include <linux/vs_limit.h>
26897  
26898  
26899  /* The inetsw table contains everything that inet_create needs to
26900 @@ -327,9 +328,13 @@ lookup_protocol:
26901         }
26902  
26903         err = -EPERM;
26904 +       if ((protocol == IPPROTO_ICMP) &&
26905 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
26906 +               goto override;
26907 +
26908         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
26909                 goto out_rcu_unlock;
26910 -
26911 +override:
26912         err = -EAFNOSUPPORT;
26913         if (!inet_netns_ok(net, protocol))
26914                 goto out_rcu_unlock;
26915 @@ -451,6 +456,7 @@ int inet_bind(struct socket *sock, struc
26916         struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26917         struct sock *sk = sock->sk;
26918         struct inet_sock *inet = inet_sk(sk);
26919 +       struct nx_v4_sock_addr nsa;
26920         unsigned short snum;
26921         int chk_addr_ret;
26922         int err;
26923 @@ -464,7 +470,11 @@ int inet_bind(struct socket *sock, struc
26924         if (addr_len < sizeof(struct sockaddr_in))
26925                 goto out;
26926  
26927 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26928 +       err = v4_map_sock_addr(inet, addr, &nsa);
26929 +       if (err)
26930 +               goto out;
26931 +
26932 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26933  
26934         /* Not specified by any standard per-se, however it breaks too
26935          * many applications when removed.  It is unfortunate since
26936 @@ -476,7 +486,7 @@ int inet_bind(struct socket *sock, struc
26937         err = -EADDRNOTAVAIL;
26938         if (!sysctl_ip_nonlocal_bind &&
26939             !(inet->freebind || inet->transparent) &&
26940 -           addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26941 +           nsa.saddr != htonl(INADDR_ANY) &&
26942             chk_addr_ret != RTN_LOCAL &&
26943             chk_addr_ret != RTN_MULTICAST &&
26944             chk_addr_ret != RTN_BROADCAST)
26945 @@ -501,7 +511,7 @@ int inet_bind(struct socket *sock, struc
26946         if (sk->sk_state != TCP_CLOSE || inet->inet_num)
26947                 goto out_release_sock;
26948  
26949 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26950 +       v4_set_sock_addr(inet, &nsa);
26951         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26952                 inet->inet_saddr = 0;  /* Use device */
26953  
26954 @@ -703,11 +713,13 @@ int inet_getname(struct socket *sock, st
26955                      peer == 1))
26956                         return -ENOTCONN;
26957                 sin->sin_port = inet->inet_dport;
26958 -               sin->sin_addr.s_addr = inet->inet_daddr;
26959 +               sin->sin_addr.s_addr =
26960 +                       nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
26961         } else {
26962                 __be32 addr = inet->inet_rcv_saddr;
26963                 if (!addr)
26964                         addr = inet->inet_saddr;
26965 +               addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26966                 sin->sin_port = inet->inet_sport;
26967                 sin->sin_addr.s_addr = addr;
26968         }
26969 diff -NurpP --minimal linux-2.6.35/net/ipv4/devinet.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/devinet.c
26970 --- linux-2.6.35/net/ipv4/devinet.c     2010-08-02 16:52:59.000000000 +0200
26971 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/devinet.c       2010-08-02 17:05:06.000000000 +0200
26972 @@ -417,6 +417,7 @@ struct in_device *inetdev_by_index(struc
26973  }
26974  EXPORT_SYMBOL(inetdev_by_index);
26975  
26976 +
26977  /* Called only from RTNL semaphored context. No locks. */
26978  
26979  struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26980 @@ -659,6 +660,8 @@ int devinet_ioctl(struct net *net, unsig
26981  
26982         in_dev = __in_dev_get_rtnl(dev);
26983         if (in_dev) {
26984 +               struct nx_info *nxi = current_nx_info();
26985 +
26986                 if (tryaddrmatch) {
26987                         /* Matthias Andree */
26988                         /* compare label and address (4.4BSD style) */
26989 @@ -667,6 +670,8 @@ int devinet_ioctl(struct net *net, unsig
26990                            This is checked above. */
26991                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26992                              ifap = &ifa->ifa_next) {
26993 +                               if (!nx_v4_ifa_visible(nxi, ifa))
26994 +                                       continue;
26995                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26996                                     sin_orig.sin_addr.s_addr ==
26997                                                         ifa->ifa_address) {
26998 @@ -679,9 +684,12 @@ int devinet_ioctl(struct net *net, unsig
26999                    comparing just the label */
27000                 if (!ifa) {
27001                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27002 -                            ifap = &ifa->ifa_next)
27003 +                            ifap = &ifa->ifa_next) {
27004 +                               if (!nx_v4_ifa_visible(nxi, ifa))
27005 +                                       continue;
27006                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
27007                                         break;
27008 +                       }
27009                 }
27010         }
27011  
27012 @@ -833,6 +841,8 @@ static int inet_gifconf(struct net_devic
27013                 goto out;
27014  
27015         for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
27016 +               if (!nx_v4_ifa_visible(current_nx_info(), ifa))
27017 +                       continue;
27018                 if (!buf) {
27019                         done += sizeof(ifr);
27020                         continue;
27021 @@ -1181,6 +1191,7 @@ static int inet_dump_ifaddr(struct sk_bu
27022         struct net_device *dev;
27023         struct in_device *in_dev;
27024         struct in_ifaddr *ifa;
27025 +       struct sock *sk = skb->sk;
27026         struct hlist_head *head;
27027         struct hlist_node *node;
27028  
27029 @@ -1203,6 +1214,8 @@ static int inet_dump_ifaddr(struct sk_bu
27030  
27031                         for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
27032                              ifa = ifa->ifa_next, ip_idx++) {
27033 +                       if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
27034 +                               continue;
27035                                 if (ip_idx < s_ip_idx)
27036                                         continue;
27037                                 if (inet_fill_ifaddr(skb, ifa,
27038 diff -NurpP --minimal linux-2.6.35/net/ipv4/fib_hash.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/fib_hash.c
27039 --- linux-2.6.35/net/ipv4/fib_hash.c    2010-07-07 18:31:59.000000000 +0200
27040 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/fib_hash.c      2010-08-02 17:05:06.000000000 +0200
27041 @@ -1017,7 +1017,7 @@ static int fib_seq_show(struct seq_file 
27042         prefix  = f->fn_key;
27043         mask    = FZ_MASK(iter->zone);
27044         flags   = fib_flag_trans(fa->fa_type, mask, fi);
27045 -       if (fi)
27046 +       if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
27047                 seq_printf(seq,
27048                          "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
27049                          fi->fib_dev ? fi->fib_dev->name : "*", prefix,
27050 diff -NurpP --minimal linux-2.6.35/net/ipv4/inet_connection_sock.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_connection_sock.c
27051 --- linux-2.6.35/net/ipv4/inet_connection_sock.c        2010-08-02 16:52:59.000000000 +0200
27052 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_connection_sock.c  2010-08-02 17:05:06.000000000 +0200
27053 @@ -52,10 +52,40 @@ void inet_get_local_port_range(int *low,
27054  }
27055  EXPORT_SYMBOL(inet_get_local_port_range);
27056  
27057 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27058 +{
27059 +       __be32  sk1_rcv_saddr = inet_rcv_saddr(sk1),
27060 +               sk2_rcv_saddr = inet_rcv_saddr(sk2);
27061 +
27062 +       if (inet_v6_ipv6only(sk2))
27063 +               return 0;
27064 +
27065 +       if (sk1_rcv_saddr &&
27066 +           sk2_rcv_saddr &&
27067 +           sk1_rcv_saddr == sk2_rcv_saddr)
27068 +               return 1;
27069 +
27070 +       if (sk1_rcv_saddr &&
27071 +           !sk2_rcv_saddr &&
27072 +           v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
27073 +               return 1;
27074 +
27075 +       if (sk2_rcv_saddr &&
27076 +           !sk1_rcv_saddr &&
27077 +           v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
27078 +               return 1;
27079 +
27080 +       if (!sk1_rcv_saddr &&
27081 +           !sk2_rcv_saddr &&
27082 +           nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
27083 +               return 1;
27084 +
27085 +       return 0;
27086 +}
27087 +
27088  int inet_csk_bind_conflict(const struct sock *sk,
27089                            const struct inet_bind_bucket *tb)
27090  {
27091 -       const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27092         struct sock *sk2;
27093         struct hlist_node *node;
27094         int reuse = sk->sk_reuse;
27095 @@ -75,9 +105,7 @@ int inet_csk_bind_conflict(const struct 
27096                      sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27097                         if (!reuse || !sk2->sk_reuse ||
27098                             sk2->sk_state == TCP_LISTEN) {
27099 -                               const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27100 -                               if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27101 -                                   sk2_rcv_saddr == sk_rcv_saddr)
27102 +                               if (ipv4_rcv_saddr_equal(sk, sk2))
27103                                         break;
27104                         }
27105                 }
27106 diff -NurpP --minimal linux-2.6.35/net/ipv4/inet_diag.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_diag.c
27107 --- linux-2.6.35/net/ipv4/inet_diag.c   2010-07-07 18:31:59.000000000 +0200
27108 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_diag.c     2010-08-02 17:05:06.000000000 +0200
27109 @@ -33,6 +33,8 @@
27110  #include <linux/stddef.h>
27111  
27112  #include <linux/inet_diag.h>
27113 +#include <linux/vs_network.h>
27114 +#include <linux/vs_inet.h>
27115  
27116  static const struct inet_diag_handler **inet_diag_table;
27117  
27118 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
27119  
27120         r->id.idiag_sport = inet->inet_sport;
27121         r->id.idiag_dport = inet->inet_dport;
27122 -       r->id.idiag_src[0] = inet->inet_rcv_saddr;
27123 -       r->id.idiag_dst[0] = inet->inet_daddr;
27124 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
27125 +               inet->inet_rcv_saddr);
27126 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
27127 +               inet->inet_daddr);
27128  
27129  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27130         if (r->idiag_family == AF_INET6) {
27131 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
27132         r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
27133         r->id.idiag_sport     = tw->tw_sport;
27134         r->id.idiag_dport     = tw->tw_dport;
27135 -       r->id.idiag_src[0]    = tw->tw_rcv_saddr;
27136 -       r->id.idiag_dst[0]    = tw->tw_daddr;
27137 +       r->id.idiag_src[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
27138 +       r->id.idiag_dst[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
27139         r->idiag_state        = tw->tw_substate;
27140         r->idiag_timer        = 3;
27141         r->idiag_expires      = DIV_ROUND_UP(tmo * 1000, HZ);
27142 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
27143         err = -EINVAL;
27144  
27145         if (req->idiag_family == AF_INET) {
27146 +               /* TODO: lback */
27147                 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
27148                                  req->id.idiag_dport, req->id.idiag_src[0],
27149                                  req->id.idiag_sport, req->id.idiag_if);
27150 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
27151                 } else
27152  #endif
27153                 {
27154 +                       /* TODO: lback */
27155                         entry.saddr = &inet->inet_rcv_saddr;
27156                         entry.daddr = &inet->inet_daddr;
27157                 }
27158 @@ -541,6 +547,7 @@ static int inet_twsk_diag_dump(struct in
27159                 } else
27160  #endif
27161                 {
27162 +                       /* TODO: lback */
27163                         entry.saddr = &tw->tw_rcv_saddr;
27164                         entry.daddr = &tw->tw_daddr;
27165                 }
27166 @@ -587,8 +594,8 @@ static int inet_diag_fill_req(struct sk_
27167  
27168         r->id.idiag_sport = inet->inet_sport;
27169         r->id.idiag_dport = ireq->rmt_port;
27170 -       r->id.idiag_src[0] = ireq->loc_addr;
27171 -       r->id.idiag_dst[0] = ireq->rmt_addr;
27172 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
27173 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
27174         r->idiag_expires = jiffies_to_msecs(tmo);
27175         r->idiag_rqueue = 0;
27176         r->idiag_wqueue = 0;
27177 @@ -658,6 +665,7 @@ static int inet_diag_dump_reqs(struct sk
27178                                 continue;
27179  
27180                         if (bc) {
27181 +                               /* TODO: lback */
27182                                 entry.saddr =
27183  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27184                                         (entry.family == AF_INET6) ?
27185 @@ -728,6 +736,8 @@ static int inet_diag_dump(struct sk_buff
27186                         sk_nulls_for_each(sk, node, &ilb->head) {
27187                                 struct inet_sock *inet = inet_sk(sk);
27188  
27189 +                               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27190 +                                       continue;
27191                                 if (num < s_num) {
27192                                         num++;
27193                                         continue;
27194 @@ -794,6 +804,8 @@ skip_listen_ht:
27195                 sk_nulls_for_each(sk, node, &head->chain) {
27196                         struct inet_sock *inet = inet_sk(sk);
27197  
27198 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27199 +                               continue;
27200                         if (num < s_num)
27201                                 goto next_normal;
27202                         if (!(r->idiag_states & (1 << sk->sk_state)))
27203 @@ -818,6 +830,8 @@ next_normal:
27204                         inet_twsk_for_each(tw, node,
27205                                     &head->twchain) {
27206  
27207 +                               if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27208 +                                       continue;
27209                                 if (num < s_num)
27210                                         goto next_dying;
27211                                 if (r->id.idiag_sport != tw->tw_sport &&
27212 diff -NurpP --minimal linux-2.6.35/net/ipv4/inet_hashtables.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_hashtables.c
27213 --- linux-2.6.35/net/ipv4/inet_hashtables.c     2010-08-02 16:52:59.000000000 +0200
27214 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/inet_hashtables.c       2010-08-02 17:05:06.000000000 +0200
27215 @@ -21,6 +21,7 @@
27216  
27217  #include <net/inet_connection_sock.h>
27218  #include <net/inet_hashtables.h>
27219 +#include <net/route.h>
27220  #include <net/ip.h>
27221  
27222  /*
27223 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
27224                         if (rcv_saddr != daddr)
27225                                 return -1;
27226                         score += 2;
27227 +               } else {
27228 +                       /* block non nx_info ips */
27229 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
27230 +                               daddr, NXA_MASK_BIND))
27231 +                               return -1;
27232                 }
27233                 if (sk->sk_bound_dev_if) {
27234                         if (sk->sk_bound_dev_if != dif)
27235 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
27236   * wildcarded during the search since they can never be otherwise.
27237   */
27238  
27239 -
27240  struct sock *__inet_lookup_listener(struct net *net,
27241                                     struct inet_hashinfo *hashinfo,
27242                                     const __be32 daddr, const unsigned short hnum,
27243 @@ -174,6 +179,7 @@ begin:
27244                         hiscore = score;
27245                 }
27246         }
27247 +
27248         /*
27249          * if the nulls value we got at the end of this lookup is
27250          * not the expected one, we must restart lookup.
27251 diff -NurpP --minimal linux-2.6.35/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/netfilter/nf_nat_helper.c
27252 --- linux-2.6.35/net/ipv4/netfilter/nf_nat_helper.c     2010-07-07 18:31:59.000000000 +0200
27253 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/netfilter/nf_nat_helper.c       2010-08-02 17:05:06.000000000 +0200
27254 @@ -20,6 +20,7 @@
27255  #include <net/route.h>
27256  
27257  #include <linux/netfilter_ipv4.h>
27258 +#include <net/route.h>
27259  #include <net/netfilter/nf_conntrack.h>
27260  #include <net/netfilter/nf_conntrack_helper.h>
27261  #include <net/netfilter/nf_conntrack_ecache.h>
27262 diff -NurpP --minimal linux-2.6.35/net/ipv4/netfilter.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/netfilter.c
27263 --- linux-2.6.35/net/ipv4/netfilter.c   2010-08-02 16:52:59.000000000 +0200
27264 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/netfilter.c     2010-08-02 17:05:06.000000000 +0200
27265 @@ -5,7 +5,7 @@
27266  #include <linux/ip.h>
27267  #include <linux/skbuff.h>
27268  #include <linux/gfp.h>
27269 -#include <net/route.h>
27270 +// #include <net/route.h>
27271  #include <net/xfrm.h>
27272  #include <net/ip.h>
27273  #include <net/netfilter/nf_queue.h>
27274 diff -NurpP --minimal linux-2.6.35/net/ipv4/raw.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/raw.c
27275 --- linux-2.6.35/net/ipv4/raw.c 2010-08-02 16:52:59.000000000 +0200
27276 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/raw.c   2010-08-02 18:19:23.000000000 +0200
27277 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
27278  
27279                 if (net_eq(sock_net(sk), net) && inet->inet_num == num  &&
27280                     !(inet->inet_daddr && inet->inet_daddr != raddr)    &&
27281 -                   !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
27282 +                   v4_sock_addr_match(sk->sk_nx_info, inet, laddr)     &&
27283                     !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27284                         goto found; /* gotcha */
27285         }
27286 @@ -381,6 +381,12 @@ static int raw_send_hdrinc(struct sock *
27287                 icmp_out_count(net, ((struct icmphdr *)
27288                         skb_transport_header(skb))->type);
27289  
27290 +       err = -EPERM;
27291 +       if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27292 +               sk->sk_nx_info &&
27293 +               !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27294 +               goto error_free;
27295 +
27296         err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
27297                       rt->u.dst.dev, dst_output);
27298         if (err > 0)
27299 @@ -561,6 +567,13 @@ static int raw_sendmsg(struct kiocb *ioc
27300                 }
27301  
27302                 security_sk_classify_flow(sk, &fl);
27303 +               if (sk->sk_nx_info) {
27304 +                       err = ip_v4_find_src(sock_net(sk),
27305 +                               sk->sk_nx_info, &rt, &fl);
27306 +
27307 +                       if (err)
27308 +                               goto done;
27309 +               }
27310                 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
27311         }
27312         if (err)
27313 @@ -633,17 +646,19 @@ static int raw_bind(struct sock *sk, str
27314  {
27315         struct inet_sock *inet = inet_sk(sk);
27316         struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27317 +       struct nx_v4_sock_addr nsa = { 0 };
27318         int ret = -EINVAL;
27319         int chk_addr_ret;
27320  
27321         if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27322                 goto out;
27323 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27324 +       v4_map_sock_addr(inet, addr, &nsa);
27325 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27326         ret = -EADDRNOTAVAIL;
27327 -       if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27328 +       if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27329             chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27330                 goto out;
27331 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
27332 +       v4_set_sock_addr(inet, &nsa);
27333         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27334                 inet->inet_saddr = 0;  /* Use device */
27335         sk_dst_reset(sk);
27336 @@ -695,7 +710,8 @@ static int raw_recvmsg(struct kiocb *ioc
27337         /* Copy the address. */
27338         if (sin) {
27339                 sin->sin_family = AF_INET;
27340 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27341 +               sin->sin_addr.s_addr =
27342 +                       nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27343                 sin->sin_port = 0;
27344                 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27345         }
27346 @@ -873,7 +889,8 @@ static struct sock *raw_get_first(struct
27347                 struct hlist_node *node;
27348  
27349                 sk_for_each(sk, node, &state->h->ht[state->bucket])
27350 -                       if (sock_net(sk) == seq_file_net(seq))
27351 +                       if ((sock_net(sk) == seq_file_net(seq)) &&
27352 +                               nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27353                                 goto found;
27354         }
27355         sk = NULL;
27356 @@ -889,7 +906,8 @@ static struct sock *raw_get_next(struct 
27357                 sk = sk_next(sk);
27358  try_again:
27359                 ;
27360 -       } while (sk && sock_net(sk) != seq_file_net(seq));
27361 +       } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27362 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27363  
27364         if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27365                 sk = sk_head(&state->h->ht[state->bucket]);
27366 @@ -948,7 +966,10 @@ static void raw_sock_seq_show(struct seq
27367  
27368         seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
27369                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
27370 -               i, src, srcp, dest, destp, sp->sk_state,
27371 +               i,
27372 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27373 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27374 +               sp->sk_state,
27375                 sk_wmem_alloc_get(sp),
27376                 sk_rmem_alloc_get(sp),
27377                 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27378 diff -NurpP --minimal linux-2.6.35/net/ipv4/tcp.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp.c
27379 --- linux-2.6.35/net/ipv4/tcp.c 2010-08-02 16:52:59.000000000 +0200
27380 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp.c   2010-08-02 17:05:06.000000000 +0200
27381 @@ -266,6 +266,7 @@
27382  #include <linux/crypto.h>
27383  #include <linux/time.h>
27384  #include <linux/slab.h>
27385 +#include <linux/in.h>
27386  
27387  #include <net/icmp.h>
27388  #include <net/tcp.h>
27389 diff -NurpP --minimal linux-2.6.35/net/ipv4/tcp_ipv4.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp_ipv4.c
27390 --- linux-2.6.35/net/ipv4/tcp_ipv4.c    2010-08-02 16:52:59.000000000 +0200
27391 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp_ipv4.c      2010-08-02 17:05:06.000000000 +0200
27392 @@ -2004,6 +2004,12 @@ static void *listening_get_next(struct s
27393                 req = req->dl_next;
27394                 while (1) {
27395                         while (req) {
27396 +                               vxdprintk(VXD_CBIT(net, 6),
27397 +                                       "sk,req: %p [#%d] (from %d)", req->sk,
27398 +                                       (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27399 +                               if (req->sk &&
27400 +                                       !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27401 +                                       continue;
27402                                 if (req->rsk_ops->family == st->family) {
27403                                         cur = req;
27404                                         goto out;
27405 @@ -2028,6 +2034,10 @@ get_req:
27406         }
27407  get_sk:
27408         sk_nulls_for_each_from(sk, node) {
27409 +               vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27410 +                       sk, sk->sk_nid, nx_current_nid());
27411 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27412 +                       continue;
27413                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
27414                         cur = sk;
27415                         goto out;
27416 @@ -2091,6 +2101,11 @@ static void *established_get_first(struc
27417  
27418                 spin_lock_bh(lock);
27419                 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27420 +                       vxdprintk(VXD_CBIT(net, 6),
27421 +                               "sk,egf: %p [#%d] (from %d)",
27422 +                               sk, sk->sk_nid, nx_current_nid());
27423 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27424 +                               continue;
27425                         if (sk->sk_family != st->family ||
27426                             !net_eq(sock_net(sk), net)) {
27427                                 continue;
27428 @@ -2101,6 +2116,11 @@ static void *established_get_first(struc
27429                 st->state = TCP_SEQ_STATE_TIME_WAIT;
27430                 inet_twsk_for_each(tw, node,
27431                                    &tcp_hashinfo.ehash[st->bucket].twchain) {
27432 +                       vxdprintk(VXD_CBIT(net, 6),
27433 +                               "tw: %p [#%d] (from %d)",
27434 +                               tw, tw->tw_nid, nx_current_nid());
27435 +                       if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27436 +                               continue;
27437                         if (tw->tw_family != st->family ||
27438                             !net_eq(twsk_net(tw), net)) {
27439                                 continue;
27440 @@ -2129,7 +2149,9 @@ static void *established_get_next(struct
27441                 tw = cur;
27442                 tw = tw_next(tw);
27443  get_tw:
27444 -               while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27445 +               while (tw && (tw->tw_family != st->family ||
27446 +                       !net_eq(twsk_net(tw), net) ||
27447 +                       !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27448                         tw = tw_next(tw);
27449                 }
27450                 if (tw) {
27451 @@ -2152,6 +2174,11 @@ get_tw:
27452                 sk = sk_nulls_next(sk);
27453  
27454         sk_nulls_for_each_from(sk, node) {
27455 +               vxdprintk(VXD_CBIT(net, 6),
27456 +                       "sk,egn: %p [#%d] (from %d)",
27457 +                       sk, sk->sk_nid, nx_current_nid());
27458 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27459 +                       continue;
27460                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27461                         goto found;
27462         }
27463 @@ -2303,9 +2330,9 @@ static void get_openreq4(struct sock *sk
27464         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27465                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
27466                 i,
27467 -               ireq->loc_addr,
27468 +               nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27469                 ntohs(inet_sk(sk)->inet_sport),
27470 -               ireq->rmt_addr,
27471 +               nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27472                 ntohs(ireq->rmt_port),
27473                 TCP_SYN_RECV,
27474                 0, 0, /* could print option size, but that is af dependent. */
27475 @@ -2357,7 +2384,10 @@ static void get_tcp4_sock(struct sock *s
27476  
27477         seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
27478                         "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
27479 -               i, src, srcp, dest, destp, sk->sk_state,
27480 +               i,
27481 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27482 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27483 +               sk->sk_state,
27484                 tp->write_seq - tp->snd_una,
27485                 rx_queue,
27486                 timer_active,
27487 @@ -2392,7 +2422,10 @@ static void get_timewait4_sock(struct in
27488  
27489         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27490                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
27491 -               i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
27492 +               i,
27493 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27494 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27495 +               tw->tw_substate, 0, 0,
27496                 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
27497                 atomic_read(&tw->tw_refcnt), tw, len);
27498  }
27499 diff -NurpP --minimal linux-2.6.35/net/ipv4/tcp_minisocks.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp_minisocks.c
27500 --- linux-2.6.35/net/ipv4/tcp_minisocks.c       2010-08-02 16:52:59.000000000 +0200
27501 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/tcp_minisocks.c 2010-08-02 17:05:06.000000000 +0200
27502 @@ -23,6 +23,9 @@
27503  #include <linux/slab.h>
27504  #include <linux/sysctl.h>
27505  #include <linux/workqueue.h>
27506 +#include <linux/vs_limit.h>
27507 +#include <linux/vs_socket.h>
27508 +#include <linux/vs_context.h>
27509  #include <net/tcp.h>
27510  #include <net/inet_common.h>
27511  #include <net/xfrm.h>
27512 @@ -290,6 +293,11 @@ void tcp_time_wait(struct sock *sk, int 
27513                 tcptw->tw_ts_recent     = tp->rx_opt.ts_recent;
27514                 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27515  
27516 +               tw->tw_xid              = sk->sk_xid;
27517 +               tw->tw_vx_info          = NULL;
27518 +               tw->tw_nid              = sk->sk_nid;
27519 +               tw->tw_nx_info          = NULL;
27520 +
27521  #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27522                 if (tw->tw_family == PF_INET6) {
27523                         struct ipv6_pinfo *np = inet6_sk(sk);
27524 diff -NurpP --minimal linux-2.6.35/net/ipv4/udp.c linux-2.6.35-vs2.3.0.36.31/net/ipv4/udp.c
27525 --- linux-2.6.35/net/ipv4/udp.c 2010-08-02 16:52:59.000000000 +0200
27526 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv4/udp.c   2010-08-02 17:05:06.000000000 +0200
27527 @@ -296,14 +296,7 @@ fail:
27528  }
27529  EXPORT_SYMBOL(udp_lib_get_port);
27530  
27531 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27532 -{
27533 -       struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27534 -
27535 -       return  (!ipv6_only_sock(sk2)  &&
27536 -                (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
27537 -                  inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
27538 -}
27539 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27540  
27541  static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
27542                                        unsigned int port)
27543 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
27544                         if (inet->inet_rcv_saddr != daddr)
27545                                 return -1;
27546                         score += 2;
27547 +               } else {
27548 +                       /* block non nx_info ips */
27549 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
27550 +                               daddr, NXA_MASK_BIND))
27551 +                               return -1;
27552                 }
27553                 if (inet->inet_daddr) {
27554                         if (inet->inet_daddr != saddr)
27555 @@ -441,6 +439,7 @@ exact_match:
27556         return result;
27557  }
27558  
27559 +
27560  /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27561   * harder than this. -DaveM
27562   */
27563 @@ -486,6 +485,11 @@ begin:
27564         sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27565                 score = compute_score(sk, net, saddr, hnum, sport,
27566                                       daddr, dport, dif);
27567 +               /* FIXME: disabled?
27568 +               if (score == 9) {
27569 +                       result = sk;
27570 +                       break;
27571 +               } else */
27572                 if (score > badness) {
27573                         result = sk;
27574                         badness = score;
27575 @@ -499,6 +503,7 @@ begin:
27576         if (get_nulls_value(node) != slot)
27577                 goto begin;
27578  
27579 +
27580         if (result) {
27581                 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
27582                         result = NULL;
27583 @@ -508,6 +513,7 @@ begin:
27584                         goto begin;
27585                 }
27586         }
27587 +
27588         rcu_read_unlock();
27589         return result;
27590  }
27591 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
27592                     udp_sk(s)->udp_port_hash != hnum ||
27593                     (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
27594                     (inet->inet_dport != rmt_port && inet->inet_dport) ||
27595 -                   (inet->inet_rcv_saddr &&
27596 -                    inet->inet_rcv_saddr != loc_addr) ||
27597 +                   !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27598                     ipv6_only_sock(s) ||
27599                     (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27600                         continue;
27601 @@ -900,8 +905,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27602                                                { .sport = inet->inet_sport,
27603                                                  .dport = dport } } };
27604                 struct net *net = sock_net(sk);
27605 +               struct nx_info *nxi = sk->sk_nx_info;
27606  
27607                 security_sk_classify_flow(sk, &fl);
27608 +               err = ip_v4_find_src(net, nxi, &rt, &fl);
27609 +               if (err)
27610 +                       goto out;
27611 +
27612                 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27613                 if (err) {
27614                         if (err == -ENETUNREACH)
27615 @@ -1183,7 +1193,8 @@ try_again:
27616         if (sin) {
27617                 sin->sin_family = AF_INET;
27618                 sin->sin_port = udp_hdr(skb)->source;
27619 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27620 +               sin->sin_addr.s_addr = nx_map_sock_lback(
27621 +                       skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27622                 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27623         }
27624         if (inet->cmsg_flags)
27625 @@ -1879,6 +1890,8 @@ static struct sock *udp_get_first(struct
27626                 sk_nulls_for_each(sk, node, &hslot->head) {
27627                         if (!net_eq(sock_net(sk), net))
27628                                 continue;
27629 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27630 +                               continue;
27631                         if (sk->sk_family == state->family)
27632                                 goto found;
27633                 }
27634 @@ -1896,7 +1909,9 @@ static struct sock *udp_get_next(struct 
27635  
27636         do {
27637                 sk = sk_nulls_next(sk);
27638 -       } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27639 +       } while (sk && (!net_eq(sock_net(sk), net) ||
27640 +               sk->sk_family != state->family ||
27641 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27642  
27643         if (!sk) {
27644                 if (state->bucket <= state->udp_table->mask)
27645 @@ -2003,7 +2018,10 @@ static void udp4_format_sock(struct sock
27646  
27647         seq_printf(f, "%5d: %08X:%04X %08X:%04X"
27648                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27649 -               bucket, src, srcp, dest, destp, sp->sk_state,
27650 +               bucket,
27651 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27652 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27653 +               sp->sk_state,
27654                 sk_wmem_alloc_get(sp),
27655                 sk_rmem_alloc_get(sp),
27656                 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27657 diff -NurpP --minimal linux-2.6.35/net/ipv6/addrconf.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/addrconf.c
27658 --- linux-2.6.35/net/ipv6/addrconf.c    2010-08-02 16:52:59.000000000 +0200
27659 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/addrconf.c      2010-08-02 17:05:06.000000000 +0200
27660 @@ -87,6 +87,8 @@
27661  
27662  #include <linux/proc_fs.h>
27663  #include <linux/seq_file.h>
27664 +#include <linux/vs_network.h>
27665 +#include <linux/vs_inet6.h>
27666  
27667  /* Set to 3 to get tracing... */
27668  #define ACONF_DEBUG 2
27669 @@ -1117,7 +1119,7 @@ out:
27670  
27671  int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27672                        const struct in6_addr *daddr, unsigned int prefs,
27673 -                      struct in6_addr *saddr)
27674 +                      struct in6_addr *saddr, struct nx_info *nxi)
27675  {
27676         struct ipv6_saddr_score scores[2],
27677                                 *score = &scores[0], *hiscore = &scores[1];
27678 @@ -1189,6 +1191,8 @@ int ipv6_dev_get_saddr(struct net *net, 
27679                                                dev->name);
27680                                 continue;
27681                         }
27682 +                       if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27683 +                               continue;
27684  
27685                         score->rule = -1;
27686                         bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27687 @@ -3074,7 +3078,10 @@ static void if6_seq_stop(struct seq_file
27688  static int if6_seq_show(struct seq_file *seq, void *v)
27689  {
27690         struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27691 -       seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27692 +
27693 +       if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27694 +           v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27695 +               seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27696                    &ifp->addr,
27697                    ifp->idev->dev->ifindex,
27698                    ifp->prefix_len,
27699 @@ -3578,6 +3585,11 @@ static int in6_dump_addrs(struct inet6_d
27700         struct ifacaddr6 *ifaca;
27701         int err = 1;
27702         int ip_idx = *p_ip_idx;
27703 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27704 +
27705 +       /* disable ipv6 on non v6 guests */
27706 +       if (nxi && !nx_info_has_v6(nxi))
27707 +               return skb->len;
27708  
27709         read_lock_bh(&idev->lock);
27710         switch (type) {
27711 @@ -3588,6 +3600,8 @@ static int in6_dump_addrs(struct inet6_d
27712                 list_for_each_entry(ifa, &idev->addr_list, if_list) {
27713                         if (++ip_idx < s_ip_idx)
27714                                 continue;
27715 +                               if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27716 +                                       continue;
27717                         err = inet6_fill_ifaddr(skb, ifa,
27718                                                 NETLINK_CB(cb->skb).pid,
27719                                                 cb->nlh->nlmsg_seq,
27720 @@ -3604,6 +3618,8 @@ static int in6_dump_addrs(struct inet6_d
27721                      ifmca = ifmca->next, ip_idx++) {
27722                         if (ip_idx < s_ip_idx)
27723                                 continue;
27724 +                               if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27725 +                                       continue;
27726                         err = inet6_fill_ifmcaddr(skb, ifmca,
27727                                                   NETLINK_CB(cb->skb).pid,
27728                                                   cb->nlh->nlmsg_seq,
27729 @@ -3619,6 +3635,8 @@ static int in6_dump_addrs(struct inet6_d
27730                      ifaca = ifaca->aca_next, ip_idx++) {
27731                         if (ip_idx < s_ip_idx)
27732                                 continue;
27733 +                               if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27734 +                                       continue;
27735                         err = inet6_fill_ifacaddr(skb, ifaca,
27736                                                   NETLINK_CB(cb->skb).pid,
27737                                                   cb->nlh->nlmsg_seq,
27738 @@ -3950,6 +3968,11 @@ static int inet6_dump_ifinfo(struct sk_b
27739         struct inet6_dev *idev;
27740         struct hlist_head *head;
27741         struct hlist_node *node;
27742 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27743 +
27744 +       /* FIXME: maybe disable ipv6 on non v6 guests?
27745 +       if (skb->sk && skb->sk->sk_vx_info)
27746 +               return skb->len; */
27747  
27748         s_h = cb->args[0];
27749         s_idx = cb->args[1];
27750 @@ -3961,6 +3984,8 @@ static int inet6_dump_ifinfo(struct sk_b
27751                 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
27752                         if (idx < s_idx)
27753                                 goto cont;
27754 +                       if (!v6_dev_in_nx_info(dev, nxi))
27755 +                               goto cont;
27756                         idev = __in6_dev_get(dev);
27757                         if (!idev)
27758                                 goto cont;
27759 diff -NurpP --minimal linux-2.6.35/net/ipv6/af_inet6.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/af_inet6.c
27760 --- linux-2.6.35/net/ipv6/af_inet6.c    2010-08-02 16:52:59.000000000 +0200
27761 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/af_inet6.c      2010-08-02 17:05:06.000000000 +0200
27762 @@ -42,6 +42,8 @@
27763  #include <linux/netdevice.h>
27764  #include <linux/icmpv6.h>
27765  #include <linux/netfilter_ipv6.h>
27766 +#include <linux/vs_inet.h>
27767 +#include <linux/vs_inet6.h>
27768  
27769  #include <net/ip.h>
27770  #include <net/ipv6.h>
27771 @@ -160,9 +162,12 @@ lookup_protocol:
27772         }
27773  
27774         err = -EPERM;
27775 +       if ((protocol == IPPROTO_ICMPV6) &&
27776 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
27777 +               goto override;
27778         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
27779                 goto out_rcu_unlock;
27780 -
27781 +override:
27782         sock->ops = answer->ops;
27783         answer_prot = answer->prot;
27784         answer_no_check = answer->no_check;
27785 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
27786         struct inet_sock *inet = inet_sk(sk);
27787         struct ipv6_pinfo *np = inet6_sk(sk);
27788         struct net *net = sock_net(sk);
27789 +       struct nx_v6_sock_addr nsa;
27790         __be32 v4addr = 0;
27791         unsigned short snum;
27792         int addr_type = 0;
27793 @@ -272,6 +278,11 @@ int inet6_bind(struct socket *sock, stru
27794  
27795         if (addr_len < SIN6_LEN_RFC2133)
27796                 return -EINVAL;
27797 +
27798 +       err = v6_map_sock_addr(inet, addr, &nsa);
27799 +       if (err)
27800 +               return err;
27801 +
27802         addr_type = ipv6_addr_type(&addr->sin6_addr);
27803         if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27804                 return -EINVAL;
27805 @@ -303,6 +314,7 @@ int inet6_bind(struct socket *sock, stru
27806                 /* Reproduce AF_INET checks to make the bindings consitant */
27807                 v4addr = addr->sin6_addr.s6_addr32[3];
27808                 chk_addr_ret = inet_addr_type(net, v4addr);
27809 +
27810                 if (!sysctl_ip_nonlocal_bind &&
27811                     !(inet->freebind || inet->transparent) &&
27812                     v4addr != htonl(INADDR_ANY) &&
27813 @@ -312,6 +324,10 @@ int inet6_bind(struct socket *sock, stru
27814                         err = -EADDRNOTAVAIL;
27815                         goto out;
27816                 }
27817 +               if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27818 +                       err = -EADDRNOTAVAIL;
27819 +                       goto out;
27820 +               }
27821         } else {
27822                 if (addr_type != IPV6_ADDR_ANY) {
27823                         struct net_device *dev = NULL;
27824 @@ -338,6 +354,11 @@ int inet6_bind(struct socket *sock, stru
27825                                 }
27826                         }
27827  
27828 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27829 +                               err = -EADDRNOTAVAIL;
27830 +                               goto out;
27831 +                       }
27832 +
27833                         /* ipv4 addr of the socket is invalid.  Only the
27834                          * unspecified and mapped address have a v4 equivalent.
27835                          */
27836 @@ -353,6 +374,9 @@ int inet6_bind(struct socket *sock, stru
27837                 }
27838         }
27839  
27840 +       /* what's that for? */
27841 +       v6_set_sock_addr(inet, &nsa);
27842 +
27843         inet->inet_rcv_saddr = v4addr;
27844         inet->inet_saddr = v4addr;
27845  
27846 @@ -454,9 +478,11 @@ int inet6_getname(struct socket *sock, s
27847                         return -ENOTCONN;
27848                 sin->sin6_port = inet->inet_dport;
27849                 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27850 +               /* FIXME: remap lback? */
27851                 if (np->sndflow)
27852                         sin->sin6_flowinfo = np->flow_label;
27853         } else {
27854 +               /* FIXME: remap lback? */
27855                 if (ipv6_addr_any(&np->rcv_saddr))
27856                         ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27857                 else
27858 diff -NurpP --minimal linux-2.6.35/net/ipv6/fib6_rules.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/fib6_rules.c
27859 --- linux-2.6.35/net/ipv6/fib6_rules.c  2010-08-02 16:52:59.000000000 +0200
27860 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/fib6_rules.c    2010-08-02 17:05:06.000000000 +0200
27861 @@ -89,7 +89,7 @@ static int fib6_rule_action(struct fib_r
27862                                                ip6_dst_idev(&rt->u.dst)->dev,
27863                                                &flp->fl6_dst,
27864                                                rt6_flags2srcprefs(flags),
27865 -                                              &saddr))
27866 +                                              &saddr, NULL))
27867                                 goto again;
27868                         if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27869                                                r->src.plen))
27870 diff -NurpP --minimal linux-2.6.35/net/ipv6/inet6_hashtables.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/inet6_hashtables.c
27871 --- linux-2.6.35/net/ipv6/inet6_hashtables.c    2010-02-25 11:52:10.000000000 +0100
27872 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/inet6_hashtables.c      2010-08-02 17:05:06.000000000 +0200
27873 @@ -16,6 +16,7 @@
27874  
27875  #include <linux/module.h>
27876  #include <linux/random.h>
27877 +#include <linux/vs_inet6.h>
27878  
27879  #include <net/inet_connection_sock.h>
27880  #include <net/inet_hashtables.h>
27881 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
27882         unsigned int slot = hash & hashinfo->ehash_mask;
27883         struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
27884  
27885 -
27886         rcu_read_lock();
27887  begin:
27888         sk_nulls_for_each_rcu(sk, node, &head->chain) {
27889 @@ -94,7 +94,7 @@ begin:
27890                                 sock_put(sk);
27891                                 goto begin;
27892                         }
27893 -               goto out;
27894 +                       goto out;
27895                 }
27896         }
27897         if (get_nulls_value(node) != slot)
27898 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
27899                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27900                                 return -1;
27901                         score++;
27902 +               } else {
27903 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27904 +                               return -1;
27905                 }
27906                 if (sk->sk_bound_dev_if) {
27907                         if (sk->sk_bound_dev_if != dif)
27908 diff -NurpP --minimal linux-2.6.35/net/ipv6/ip6_output.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/ip6_output.c
27909 --- linux-2.6.35/net/ipv6/ip6_output.c  2010-08-02 16:52:59.000000000 +0200
27910 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/ip6_output.c    2010-08-02 17:05:06.000000000 +0200
27911 @@ -930,7 +930,7 @@ static int ip6_dst_lookup_tail(struct so
27912                 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
27913                                          &fl->fl6_dst,
27914                                          sk ? inet6_sk(sk)->srcprefs : 0,
27915 -                                        &fl->fl6_src);
27916 +                                        &fl->fl6_src, sk->sk_nx_info);
27917                 if (err)
27918                         goto out_err_release;
27919         }
27920 diff -NurpP --minimal linux-2.6.35/net/ipv6/Kconfig linux-2.6.35-vs2.3.0.36.31/net/ipv6/Kconfig
27921 --- linux-2.6.35/net/ipv6/Kconfig       2010-08-02 16:52:59.000000000 +0200
27922 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/Kconfig 2010-08-02 17:05:06.000000000 +0200
27923 @@ -4,8 +4,8 @@
27924  
27925  #   IPv6 as module will cause a CRASH if you try to unload it
27926  menuconfig IPV6
27927 -       tristate "The IPv6 protocol"
27928 -       default m
27929 +       bool "The IPv6 protocol"
27930 +       default n
27931         ---help---
27932           This is complemental support for the IP version 6.
27933           You will still be able to do traditional IPv4 networking as well.
27934 diff -NurpP --minimal linux-2.6.35/net/ipv6/ndisc.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/ndisc.c
27935 --- linux-2.6.35/net/ipv6/ndisc.c       2010-08-02 16:53:00.000000000 +0200
27936 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/ndisc.c 2010-08-02 17:05:06.000000000 +0200
27937 @@ -591,7 +591,7 @@ static void ndisc_send_na(struct net_dev
27938         } else {
27939                 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27940                                        inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27941 -                                      &tmpaddr))
27942 +                                      &tmpaddr, NULL /* FIXME: ? */ ))
27943                         return;
27944                 src_addr = &tmpaddr;
27945         }
27946 diff -NurpP --minimal linux-2.6.35/net/ipv6/raw.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/raw.c
27947 --- linux-2.6.35/net/ipv6/raw.c 2010-08-02 16:53:00.000000000 +0200
27948 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/raw.c   2010-08-02 17:05:06.000000000 +0200
27949 @@ -30,6 +30,7 @@
27950  #include <linux/icmpv6.h>
27951  #include <linux/netfilter.h>
27952  #include <linux/netfilter_ipv6.h>
27953 +#include <linux/vs_inet6.h>
27954  #include <linux/skbuff.h>
27955  #include <asm/uaccess.h>
27956  #include <asm/ioctls.h>
27957 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
27958                                 goto out_unlock;
27959                 }
27960  
27961 +               if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27962 +                       err = -EADDRNOTAVAIL;
27963 +                       if (dev)
27964 +                               dev_put(dev);
27965 +                       goto out;
27966 +               }
27967 +
27968                 /* ipv4 addr of the socket is invalid.  Only the
27969                  * unspecified and mapped address have a v4 equivalent.
27970                  */
27971 diff -NurpP --minimal linux-2.6.35/net/ipv6/route.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/route.c
27972 --- linux-2.6.35/net/ipv6/route.c       2010-08-02 16:53:00.000000000 +0200
27973 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/route.c 2010-08-02 17:05:06.000000000 +0200
27974 @@ -2255,7 +2255,8 @@ static int rt6_fill_node(struct net *net
27975                 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
27976                 struct in6_addr saddr_buf;
27977                 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27978 -                                      dst, 0, &saddr_buf) == 0)
27979 +                       dst, 0, &saddr_buf,
27980 +                       (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27981                         NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27982         }
27983  
27984 diff -NurpP --minimal linux-2.6.35/net/ipv6/tcp_ipv6.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/tcp_ipv6.c
27985 --- linux-2.6.35/net/ipv6/tcp_ipv6.c    2010-08-02 16:53:00.000000000 +0200
27986 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/tcp_ipv6.c      2010-08-02 17:05:06.000000000 +0200
27987 @@ -69,6 +69,7 @@
27988  
27989  #include <linux/crypto.h>
27990  #include <linux/scatterlist.h>
27991 +#include <linux/vs_inet6.h>
27992  
27993  static void    tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27994  static void    tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27995 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
27996          *      connect() to INADDR_ANY means loopback (BSD'ism).
27997          */
27998  
27999 -       if(ipv6_addr_any(&usin->sin6_addr))
28000 -               usin->sin6_addr.s6_addr[15] = 0x1;
28001 +       if(ipv6_addr_any(&usin->sin6_addr)) {
28002 +               struct nx_info *nxi =  sk->sk_nx_info;
28003 +
28004 +               if (nxi && nx_info_has_v6(nxi))
28005 +                       /* FIXME: remap lback? */
28006 +                       usin->sin6_addr = nxi->v6.ip;
28007 +               else
28008 +                       usin->sin6_addr.s6_addr[15] = 0x1;
28009 +       }
28010  
28011         addr_type = ipv6_addr_type(&usin->sin6_addr);
28012  
28013 diff -NurpP --minimal linux-2.6.35/net/ipv6/udp.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/udp.c
28014 --- linux-2.6.35/net/ipv6/udp.c 2010-08-02 16:53:00.000000000 +0200
28015 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/udp.c   2010-08-02 17:05:06.000000000 +0200
28016 @@ -48,13 +48,14 @@
28017  
28018  #include <linux/proc_fs.h>
28019  #include <linux/seq_file.h>
28020 +#include <linux/vs_inet6.h>
28021  #include "udp_impl.h"
28022  
28023  int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
28024  {
28025         const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
28026         const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
28027 -       __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28028 +       __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28029         __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28030         int sk_ipv6only = ipv6_only_sock(sk);
28031         int sk2_ipv6only = inet_v6_ipv6only(sk2);
28032 @@ -62,24 +63,49 @@ int ipv6_rcv_saddr_equal(const struct so
28033         int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
28034  
28035         /* if both are mapped, treat as IPv4 */
28036 -       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
28037 -               return (!sk2_ipv6only &&
28038 -                       (!sk1_rcv_saddr || !sk2_rcv_saddr ||
28039 -                         sk1_rcv_saddr == sk2_rcv_saddr));
28040 +       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
28041 +               if (!sk2_ipv6only &&
28042 +                       (!sk_rcv_saddr || !sk2_rcv_saddr ||
28043 +                         sk_rcv_saddr == sk2_rcv_saddr))
28044 +                       goto vs_v4;
28045 +               else
28046 +                       return 0;
28047 +       }
28048  
28049         if (addr_type2 == IPV6_ADDR_ANY &&
28050             !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
28051 -               return 1;
28052 +               goto vs;
28053  
28054         if (addr_type == IPV6_ADDR_ANY &&
28055             !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
28056 -               return 1;
28057 +               goto vs;
28058  
28059         if (sk2_rcv_saddr6 &&
28060             ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
28061 -               return 1;
28062 +               goto vs;
28063  
28064         return 0;
28065 +
28066 +vs_v4:
28067 +       if (!sk_rcv_saddr && !sk2_rcv_saddr)
28068 +               return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28069 +       if (!sk2_rcv_saddr)
28070 +               return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
28071 +       if (!sk_rcv_saddr)
28072 +               return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
28073 +       return 1;
28074 +vs:
28075 +       if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
28076 +               return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28077 +       else if (addr_type2 == IPV6_ADDR_ANY)
28078 +               return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
28079 +       else if (addr_type == IPV6_ADDR_ANY) {
28080 +               if (addr_type2 == IPV6_ADDR_MAPPED)
28081 +                       return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28082 +               else
28083 +                       return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
28084 +       }
28085 +       return 1;
28086  }
28087  
28088  static unsigned int udp6_portaddr_hash(struct net *net,
28089 @@ -134,6 +160,10 @@ static inline int compute_score(struct s
28090                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28091                                 return -1;
28092                         score++;
28093 +               } else {
28094 +                       /* block non nx_info ips */
28095 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28096 +                               return -1;
28097                 }
28098                 if (!ipv6_addr_any(&np->daddr)) {
28099                         if (!ipv6_addr_equal(&np->daddr, saddr))
28100 diff -NurpP --minimal linux-2.6.35/net/ipv6/xfrm6_policy.c linux-2.6.35-vs2.3.0.36.31/net/ipv6/xfrm6_policy.c
28101 --- linux-2.6.35/net/ipv6/xfrm6_policy.c        2010-08-02 16:53:00.000000000 +0200
28102 +++ linux-2.6.35-vs2.3.0.36.31/net/ipv6/xfrm6_policy.c  2010-08-02 17:05:06.000000000 +0200
28103 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
28104         dev = ip6_dst_idev(dst)->dev;
28105         ipv6_dev_get_saddr(dev_net(dev), dev,
28106                            (struct in6_addr *)&daddr->a6, 0,
28107 -                          (struct in6_addr *)&saddr->a6);
28108 +                          (struct in6_addr *)&saddr->a6, NULL);
28109         dst_release(dst);
28110         return 0;
28111  }
28112 diff -NurpP --minimal linux-2.6.35/net/netlink/af_netlink.c linux-2.6.35-vs2.3.0.36.31/net/netlink/af_netlink.c
28113 --- linux-2.6.35/net/netlink/af_netlink.c       2010-08-02 16:53:01.000000000 +0200
28114 +++ linux-2.6.35-vs2.3.0.36.31/net/netlink/af_netlink.c 2010-08-02 17:05:06.000000000 +0200
28115 @@ -55,6 +55,9 @@
28116  #include <linux/types.h>
28117  #include <linux/audit.h>
28118  #include <linux/mutex.h>
28119 +#include <linux/vs_context.h>
28120 +#include <linux/vs_network.h>
28121 +#include <linux/vs_limit.h>
28122  
28123  #include <net/net_namespace.h>
28124  #include <net/sock.h>
28125 @@ -1936,6 +1939,8 @@ static struct sock *netlink_seq_socket_i
28126                         sk_for_each(s, node, &hash->table[j]) {
28127                                 if (sock_net(s) != seq_file_net(seq))
28128                                         continue;
28129 +                               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28130 +                                       continue;
28131                                 if (off == pos) {
28132                                         iter->link = i;
28133                                         iter->hash_idx = j;
28134 @@ -1970,7 +1975,8 @@ static void *netlink_seq_next(struct seq
28135         s = v;
28136         do {
28137                 s = sk_next(s);
28138 -       } while (s && sock_net(s) != seq_file_net(seq));
28139 +       } while (s && (sock_net(s) != seq_file_net(seq) ||
28140 +               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28141         if (s)
28142                 return s;
28143  
28144 @@ -1982,7 +1988,8 @@ static void *netlink_seq_next(struct seq
28145  
28146                 for (; j <= hash->mask; j++) {
28147                         s = sk_head(&hash->table[j]);
28148 -                       while (s && sock_net(s) != seq_file_net(seq))
28149 +                       while (s && (sock_net(s) != seq_file_net(seq) ||
28150 +                               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28151                                 s = sk_next(s);
28152                         if (s) {
28153                                 iter->link = i;
28154 diff -NurpP --minimal linux-2.6.35/net/sctp/ipv6.c linux-2.6.35-vs2.3.0.36.31/net/sctp/ipv6.c
28155 --- linux-2.6.35/net/sctp/ipv6.c        2010-08-02 16:53:01.000000000 +0200
28156 +++ linux-2.6.35-vs2.3.0.36.31/net/sctp/ipv6.c  2010-08-02 17:05:06.000000000 +0200
28157 @@ -304,7 +304,8 @@ static void sctp_v6_get_saddr(struct sct
28158                                    dst ? ip6_dst_idev(dst)->dev : NULL,
28159                                    &daddr->v6.sin6_addr,
28160                                    inet6_sk(&sk->inet.sk)->srcprefs,
28161 -                                  &saddr->v6.sin6_addr);
28162 +                                  &saddr->v6.sin6_addr,
28163 +                                  asoc->base.sk->sk_nx_info);
28164                 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
28165                                   &saddr->v6.sin6_addr);
28166                 return;
28167 diff -NurpP --minimal linux-2.6.35/net/socket.c linux-2.6.35-vs2.3.0.36.31/net/socket.c
28168 --- linux-2.6.35/net/socket.c   2010-08-02 16:53:02.000000000 +0200
28169 +++ linux-2.6.35-vs2.3.0.36.31/net/socket.c     2010-08-02 17:05:06.000000000 +0200
28170 @@ -98,6 +98,10 @@
28171  
28172  #include <net/sock.h>
28173  #include <linux/netfilter.h>
28174 +#include <linux/vs_base.h>
28175 +#include <linux/vs_socket.h>
28176 +#include <linux/vs_inet.h>
28177 +#include <linux/vs_inet6.h>
28178  
28179  #include <linux/if_tun.h>
28180  #include <linux/ipv6_route.h>
28181 @@ -557,7 +561,7 @@ static inline int __sock_sendmsg(struct 
28182                                  struct msghdr *msg, size_t size)
28183  {
28184         struct sock_iocb *si = kiocb_to_siocb(iocb);
28185 -       int err;
28186 +       int err, len;
28187  
28188         sock_update_classid(sock->sk);
28189  
28190 @@ -570,7 +574,22 @@ static inline int __sock_sendmsg(struct 
28191         if (err)
28192                 return err;
28193  
28194 -       return sock->ops->sendmsg(iocb, sock, msg, size);
28195 +       len = sock->ops->sendmsg(iocb, sock, msg, size);
28196 +       if (sock->sk) {
28197 +               if (len == size)
28198 +                       vx_sock_send(sock->sk, size);
28199 +               else
28200 +                       vx_sock_fail(sock->sk, size);
28201 +       }
28202 +       vxdprintk(VXD_CBIT(net, 7),
28203 +               "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28204 +               sock, sock->sk,
28205 +               (sock->sk)?sock->sk->sk_nx_info:0,
28206 +               (sock->sk)?sock->sk->sk_vx_info:0,
28207 +               (sock->sk)?sock->sk->sk_xid:0,
28208 +               (sock->sk)?sock->sk->sk_nid:0,
28209 +               (unsigned int)size, len);
28210 +       return len;
28211  }
28212  
28213  int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
28214 @@ -686,6 +705,7 @@ static inline int __sock_recvmsg_nosec(s
28215                                        struct msghdr *msg, size_t size, int flags)
28216  {
28217         struct sock_iocb *si = kiocb_to_siocb(iocb);
28218 +       int len;
28219  
28220         sock_update_classid(sock->sk);
28221  
28222 @@ -695,7 +715,18 @@ static inline int __sock_recvmsg_nosec(s
28223         si->size = size;
28224         si->flags = flags;
28225  
28226 -       return sock->ops->recvmsg(iocb, sock, msg, size, flags);
28227 +       len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
28228 +       if ((len >= 0) && sock->sk)
28229 +               vx_sock_recv(sock->sk, len);
28230 +       vxdprintk(VXD_CBIT(net, 7),
28231 +               "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28232 +               sock, sock->sk,
28233 +               (sock->sk)?sock->sk->sk_nx_info:0,
28234 +               (sock->sk)?sock->sk->sk_vx_info:0,
28235 +               (sock->sk)?sock->sk->sk_xid:0,
28236 +               (sock->sk)?sock->sk->sk_nid:0,
28237 +               (unsigned int)size, len);
28238 +       return len;
28239  }
28240  
28241  static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
28242 @@ -1163,6 +1194,13 @@ static int __sock_create(struct net *net
28243         if (type < 0 || type >= SOCK_MAX)
28244                 return -EINVAL;
28245  
28246 +       if (!nx_check(0, VS_ADMIN)) {
28247 +               if (family == PF_INET && !current_nx_info_has_v4())
28248 +                       return -EAFNOSUPPORT;
28249 +               if (family == PF_INET6 && !current_nx_info_has_v6())
28250 +                       return -EAFNOSUPPORT;
28251 +       }
28252 +
28253         /* Compatibility.
28254  
28255            This uglymoron is moved from INET layer to here to avoid
28256 @@ -1295,6 +1333,7 @@ SYSCALL_DEFINE3(socket, int, family, int
28257         if (retval < 0)
28258                 goto out;
28259  
28260 +       set_bit(SOCK_USER_SOCKET, &sock->flags);
28261         retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
28262         if (retval < 0)
28263                 goto out_release;
28264 @@ -1336,10 +1375,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
28265         err = sock_create(family, type, protocol, &sock1);
28266         if (err < 0)
28267                 goto out;
28268 +       set_bit(SOCK_USER_SOCKET, &sock1->flags);
28269  
28270         err = sock_create(family, type, protocol, &sock2);
28271         if (err < 0)
28272                 goto out_release_1;
28273 +       set_bit(SOCK_USER_SOCKET, &sock2->flags);
28274  
28275         err = sock1->ops->socketpair(sock1, sock2);
28276         if (err < 0)
28277 diff -NurpP --minimal linux-2.6.35/net/sunrpc/auth.c linux-2.6.35-vs2.3.0.36.31/net/sunrpc/auth.c
28278 --- linux-2.6.35/net/sunrpc/auth.c      2010-08-02 16:53:02.000000000 +0200
28279 +++ linux-2.6.35-vs2.3.0.36.31/net/sunrpc/auth.c        2010-08-02 17:05:06.000000000 +0200
28280 @@ -14,6 +14,7 @@
28281  #include <linux/hash.h>
28282  #include <linux/sunrpc/clnt.h>
28283  #include <linux/spinlock.h>
28284 +#include <linux/vs_tag.h>
28285  
28286  #ifdef RPC_DEBUG
28287  # define RPCDBG_FACILITY       RPCDBG_AUTH
28288 @@ -366,6 +367,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
28289         memset(&acred, 0, sizeof(acred));
28290         acred.uid = cred->fsuid;
28291         acred.gid = cred->fsgid;
28292 +       acred.tag = dx_current_tag();
28293         acred.group_info = get_group_info(((struct cred *)cred)->group_info);
28294  
28295         ret = auth->au_ops->lookup_cred(auth, &acred, flags);
28296 @@ -406,6 +408,7 @@ rpcauth_bind_root_cred(struct rpc_task *
28297         struct auth_cred acred = {
28298                 .uid = 0,
28299                 .gid = 0,
28300 +               .tag = dx_current_tag(),
28301         };
28302         struct rpc_cred *ret;
28303  
28304 diff -NurpP --minimal linux-2.6.35/net/sunrpc/auth_unix.c linux-2.6.35-vs2.3.0.36.31/net/sunrpc/auth_unix.c
28305 --- linux-2.6.35/net/sunrpc/auth_unix.c 2010-07-07 18:32:01.000000000 +0200
28306 +++ linux-2.6.35-vs2.3.0.36.31/net/sunrpc/auth_unix.c   2010-08-02 17:05:06.000000000 +0200
28307 @@ -12,12 +12,14 @@
28308  #include <linux/module.h>
28309  #include <linux/sunrpc/clnt.h>
28310  #include <linux/sunrpc/auth.h>
28311 +#include <linux/vs_tag.h>
28312  
28313  #define NFS_NGROUPS    16
28314  
28315  struct unx_cred {
28316         struct rpc_cred         uc_base;
28317         gid_t                   uc_gid;
28318 +       tag_t                   uc_tag;
28319         gid_t                   uc_gids[NFS_NGROUPS];
28320  };
28321  #define uc_uid                 uc_base.cr_uid
28322 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
28323                 groups = NFS_NGROUPS;
28324  
28325         cred->uc_gid = acred->gid;
28326 +       cred->uc_tag = acred->tag;
28327         for (i = 0; i < groups; i++)
28328                 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28329         if (i < NFS_NGROUPS)
28330 @@ -120,7 +123,9 @@ unx_match(struct auth_cred *acred, struc
28331         unsigned int i;
28332  
28333  
28334 -       if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28335 +       if (cred->uc_uid != acred->uid ||
28336 +               cred->uc_gid != acred->gid ||
28337 +               cred->uc_tag != acred->tag)
28338                 return 0;
28339  
28340         if (acred->group_info != NULL)
28341 @@ -143,7 +148,7 @@ unx_marshal(struct rpc_task *task, __be3
28342         struct rpc_clnt *clnt = task->tk_client;
28343         struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
28344         __be32          *base, *hold;
28345 -       int             i;
28346 +       int             i, tag;
28347  
28348         *p++ = htonl(RPC_AUTH_UNIX);
28349         base = p++;
28350 @@ -153,9 +158,12 @@ unx_marshal(struct rpc_task *task, __be3
28351          * Copy the UTS nodename captured when the client was created.
28352          */
28353         p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28354 +       tag = task->tk_client->cl_tag;
28355  
28356 -       *p++ = htonl((u32) cred->uc_uid);
28357 -       *p++ = htonl((u32) cred->uc_gid);
28358 +       *p++ = htonl((u32) TAGINO_UID(tag,
28359 +               cred->uc_uid, cred->uc_tag));
28360 +       *p++ = htonl((u32) TAGINO_GID(tag,
28361 +               cred->uc_gid, cred->uc_tag));
28362         hold = p++;
28363         for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28364                 *p++ = htonl((u32) cred->uc_gids[i]);
28365 diff -NurpP --minimal linux-2.6.35/net/sunrpc/clnt.c linux-2.6.35-vs2.3.0.36.31/net/sunrpc/clnt.c
28366 --- linux-2.6.35/net/sunrpc/clnt.c      2010-08-02 16:53:02.000000000 +0200
28367 +++ linux-2.6.35-vs2.3.0.36.31/net/sunrpc/clnt.c        2010-08-02 17:05:06.000000000 +0200
28368 @@ -33,6 +33,7 @@
28369  #include <linux/utsname.h>
28370  #include <linux/workqueue.h>
28371  #include <linux/in6.h>
28372 +#include <linux/vs_cvirt.h>
28373  
28374  #include <linux/sunrpc/clnt.h>
28375  #include <linux/sunrpc/rpc_pipe_fs.h>
28376 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28377         if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28378                 clnt->cl_chatty = 1;
28379  
28380 +       /* TODO: handle RPC_CLNT_CREATE_TAGGED
28381 +       if (args->flags & RPC_CLNT_CREATE_TAGGED)
28382 +               clnt->cl_tag = 1; */
28383         return clnt;
28384  }
28385  EXPORT_SYMBOL_GPL(rpc_create);
28386 diff -NurpP --minimal linux-2.6.35/net/unix/af_unix.c linux-2.6.35-vs2.3.0.36.31/net/unix/af_unix.c
28387 --- linux-2.6.35/net/unix/af_unix.c     2010-08-02 16:53:02.000000000 +0200
28388 +++ linux-2.6.35-vs2.3.0.36.31/net/unix/af_unix.c       2010-08-02 17:05:06.000000000 +0200
28389 @@ -114,6 +114,8 @@
28390  #include <linux/mount.h>
28391  #include <net/checksum.h>
28392  #include <linux/security.h>
28393 +#include <linux/vs_context.h>
28394 +#include <linux/vs_limit.h>
28395  
28396  static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28397  static DEFINE_SPINLOCK(unix_table_lock);
28398 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28399                 if (!net_eq(sock_net(s), net))
28400                         continue;
28401  
28402 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28403 +                       continue;
28404                 if (u->addr->len == len &&
28405                     !memcmp(u->addr->name, sunname, len))
28406                         goto found;
28407 @@ -2114,6 +2118,8 @@ static struct sock *unix_seq_idx(struct 
28408         for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28409                 if (sock_net(s) != seq_file_net(seq))
28410                         continue;
28411 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28412 +                       continue;
28413                 if (off == pos)
28414                         return s;
28415                 ++off;
28416 @@ -2138,7 +2144,8 @@ static void *unix_seq_next(struct seq_fi
28417                 sk = first_unix_socket(&iter->i);
28418         else
28419                 sk = next_unix_socket(&iter->i, sk);
28420 -       while (sk && (sock_net(sk) != seq_file_net(seq)))
28421 +       while (sk && (sock_net(sk) != seq_file_net(seq) ||
28422 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28423                 sk = next_unix_socket(&iter->i, sk);
28424         return sk;
28425  }
28426 diff -NurpP --minimal linux-2.6.35/net/x25/af_x25.c linux-2.6.35-vs2.3.0.36.31/net/x25/af_x25.c
28427 --- linux-2.6.35/net/x25/af_x25.c       2010-08-02 16:53:02.000000000 +0200
28428 +++ linux-2.6.35-vs2.3.0.36.31/net/x25/af_x25.c 2010-08-02 17:05:06.000000000 +0200
28429 @@ -568,7 +568,10 @@ static int x25_create(struct net *net, s
28430  
28431         x25 = x25_sk(sk);
28432  
28433 -       sock_init_data(sock, sk);
28434 +       sk->sk_socket = sock;
28435 +       sk->sk_type = sock->type;
28436 +       sk->sk_sleep = &sock->wait;
28437 +       sock->sk = sk;
28438  
28439         x25_init_timers(sk);
28440  
28441 diff -NurpP --minimal linux-2.6.35/scripts/checksyscalls.sh linux-2.6.35-vs2.3.0.36.31/scripts/checksyscalls.sh
28442 --- linux-2.6.35/scripts/checksyscalls.sh       2009-09-10 15:26:31.000000000 +0200
28443 +++ linux-2.6.35-vs2.3.0.36.31/scripts/checksyscalls.sh 2010-08-02 17:05:06.000000000 +0200
28444 @@ -194,7 +194,6 @@ cat << EOF
28445  #define __IGNORE_afs_syscall
28446  #define __IGNORE_getpmsg
28447  #define __IGNORE_putpmsg
28448 -#define __IGNORE_vserver
28449  EOF
28450  }
28451  
28452 diff -NurpP --minimal linux-2.6.35/security/commoncap.c linux-2.6.35-vs2.3.0.36.31/security/commoncap.c
28453 --- linux-2.6.35/security/commoncap.c   2010-08-02 16:53:03.000000000 +0200
28454 +++ linux-2.6.35-vs2.3.0.36.31/security/commoncap.c     2010-08-02 17:05:06.000000000 +0200
28455 @@ -28,6 +28,7 @@
28456  #include <linux/prctl.h>
28457  #include <linux/securebits.h>
28458  #include <linux/syslog.h>
28459 +#include <linux/vs_context.h>
28460  
28461  /*
28462   * If a non-root user executes a setuid-root binary in
28463 @@ -53,7 +54,7 @@ static void warn_setuid_and_fcaps_mixed(
28464  
28465  int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
28466  {
28467 -       NETLINK_CB(skb).eff_cap = current_cap();
28468 +       NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
28469         return 0;
28470  }
28471  
28472 @@ -63,6 +64,7 @@ int cap_netlink_recv(struct sk_buff *skb
28473                 return -EPERM;
28474         return 0;
28475  }
28476 +
28477  EXPORT_SYMBOL(cap_netlink_recv);
28478  
28479  /**
28480 @@ -83,7 +85,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
28481  int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
28482                 int audit)
28483  {
28484 -       return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
28485 +       struct vx_info *vxi = tsk->vx_info;
28486 +
28487 +#if 0
28488 +       printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
28489 +               vx_info_flags(vxi, VXF_STATE_SETUP, 0),
28490 +               cap_raised(tsk->cap_effective, cap),
28491 +               tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
28492 +#endif
28493 +
28494 +       /* special case SETUP */
28495 +       if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28496 +               /* FIXME: maybe use cred instead? */
28497 +               cap_raised(tsk->cred->cap_effective, cap))
28498 +               return 0;
28499 +
28500 +       return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
28501  }
28502  
28503  /**
28504 @@ -571,7 +588,7 @@ int cap_inode_setxattr(struct dentry *de
28505  
28506         if (!strncmp(name, XATTR_SECURITY_PREFIX,
28507                      sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28508 -           !capable(CAP_SYS_ADMIN))
28509 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28510                 return -EPERM;
28511         return 0;
28512  }
28513 @@ -597,7 +614,7 @@ int cap_inode_removexattr(struct dentry 
28514  
28515         if (!strncmp(name, XATTR_SECURITY_PREFIX,
28516                      sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28517 -           !capable(CAP_SYS_ADMIN))
28518 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28519                 return -EPERM;
28520         return 0;
28521  }
28522 @@ -899,7 +916,8 @@ int cap_syslog(int type, bool from_file)
28523         if (type != SYSLOG_ACTION_OPEN && from_file)
28524                 return 0;
28525         if ((type != SYSLOG_ACTION_READ_ALL &&
28526 -            type != SYSLOG_ACTION_SIZE_BUFFER) && !capable(CAP_SYS_ADMIN))
28527 +            type != SYSLOG_ACTION_SIZE_BUFFER) &&
28528 +               !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
28529                 return -EPERM;
28530         return 0;
28531  }
28532 @@ -951,3 +969,4 @@ int cap_file_mmap(struct file *file, uns
28533         }
28534         return ret;
28535  }
28536 +
28537 diff -NurpP --minimal linux-2.6.35/security/selinux/av_permissions.h linux-2.6.35-vs2.3.0.36.31/security/selinux/av_permissions.h
28538 --- linux-2.6.35/security/selinux/av_permissions.h      1970-01-01 01:00:00.000000000 +0100
28539 +++ linux-2.6.35-vs2.3.0.36.31/security/selinux/av_permissions.h        2010-08-02 17:05:06.000000000 +0200
28540 @@ -0,0 +1,827 @@
28541 +/* This file is automatically generated.  Do not edit. */
28542 +#ifndef _SELINUX_AV_PERMISSIONS_H_
28543 +#define _SELINUX_AV_PERMISSIONS_H_
28544 +
28545 +#define SECURITY__COMPUTE_AV                      0x00000001UL
28546 +#define SECURITY__COMPUTE_CREATE                  0x00000002UL
28547 +#define SECURITY__COMPUTE_MEMBER                  0x00000004UL
28548 +#define SECURITY__CHECK_CONTEXT                   0x00000008UL
28549 +#define SECURITY__LOAD_POLICY                     0x00000010UL
28550 +#define SECURITY__COMPUTE_RELABEL                 0x00000020UL
28551 +#define SECURITY__COMPUTE_USER                    0x00000040UL
28552 +#define SECURITY__SETENFORCE                      0x00000080UL
28553 +#define SECURITY__SETBOOL                         0x00000100UL
28554 +#define SECURITY__SETSECPARAM                     0x00000200UL
28555 +#define SECURITY__SETCHECKREQPROT                 0x00000400UL
28556 +#define PROCESS__FORK                             0x00000001UL
28557 +#define PROCESS__TRANSITION                       0x00000002UL
28558 +#define PROCESS__SIGCHLD                          0x00000004UL
28559 +#define PROCESS__SIGKILL                          0x00000008UL
28560 +#define PROCESS__SIGSTOP                          0x00000010UL
28561 +#define PROCESS__SIGNULL                          0x00000020UL
28562 +#define PROCESS__SIGNAL                           0x00000040UL
28563 +#define PROCESS__PTRACE                           0x00000080UL
28564 +#define PROCESS__GETSCHED                         0x00000100UL
28565 +#define PROCESS__SETSCHED                         0x00000200UL
28566 +#define PROCESS__GETSESSION                       0x00000400UL
28567 +#define PROCESS__GETPGID                          0x00000800UL
28568 +#define PROCESS__SETPGID                          0x00001000UL
28569 +#define PROCESS__GETCAP                           0x00002000UL
28570 +#define PROCESS__SETCAP                           0x00004000UL
28571 +#define PROCESS__SHARE                            0x00008000UL
28572 +#define PROCESS__GETATTR                          0x00010000UL
28573 +#define PROCESS__SETEXEC                          0x00020000UL
28574 +#define PROCESS__SETFSCREATE                      0x00040000UL
28575 +#define PROCESS__NOATSECURE                       0x00080000UL
28576 +#define PROCESS__SIGINH                           0x00100000UL
28577 +#define PROCESS__SETRLIMIT                        0x00200000UL
28578 +#define PROCESS__RLIMITINH                        0x00400000UL
28579 +#define PROCESS__DYNTRANSITION                    0x00800000UL
28580 +#define PROCESS__SETCURRENT                       0x01000000UL
28581 +#define PROCESS__EXECMEM                          0x02000000UL
28582 +#define PROCESS__EXECSTACK                        0x04000000UL
28583 +#define PROCESS__EXECHEAP                         0x08000000UL
28584 +#define PROCESS__SETKEYCREATE                     0x10000000UL
28585 +#define PROCESS__SETSOCKCREATE                    0x20000000UL
28586 +#define SYSTEM__IPC_INFO                          0x00000001UL
28587 +#define SYSTEM__SYSLOG_READ                       0x00000002UL
28588 +#define SYSTEM__SYSLOG_MOD                        0x00000004UL
28589 +#define SYSTEM__SYSLOG_CONSOLE                    0x00000008UL
28590 +#define SYSTEM__MODULE_REQUEST                    0x00000010UL
28591 +#define CAPABILITY__CHOWN                         0x00000001UL
28592 +#define CAPABILITY__DAC_OVERRIDE                  0x00000002UL
28593 +#define CAPABILITY__DAC_READ_SEARCH               0x00000004UL
28594 +#define CAPABILITY__FOWNER                        0x00000008UL
28595 +#define CAPABILITY__FSETID                        0x00000010UL
28596 +#define CAPABILITY__KILL                          0x00000020UL
28597 +#define CAPABILITY__SETGID                        0x00000040UL
28598 +#define CAPABILITY__SETUID                        0x00000080UL
28599 +#define CAPABILITY__SETPCAP                       0x00000100UL
28600 +#define CAPABILITY__LINUX_IMMUTABLE               0x00000200UL
28601 +#define CAPABILITY__NET_BIND_SERVICE              0x00000400UL
28602 +#define CAPABILITY__NET_BROADCAST                 0x00000800UL
28603 +#define CAPABILITY__NET_ADMIN                     0x00001000UL
28604 +#define CAPABILITY__NET_RAW                       0x00002000UL
28605 +#define CAPABILITY__IPC_LOCK                      0x00004000UL
28606 +#define CAPABILITY__IPC_OWNER                     0x00008000UL
28607 +#define CAPABILITY__SYS_MODULE                    0x00010000UL
28608 +#define CAPABILITY__SYS_RAWIO                     0x00020000UL
28609 +#define CAPABILITY__SYS_CHROOT                    0x00040000UL
28610 +#define CAPABILITY__SYS_PTRACE                    0x00080000UL
28611 +#define CAPABILITY__SYS_PACCT                     0x00100000UL
28612 +#define CAPABILITY__SYS_ADMIN                     0x00200000UL
28613 +#define CAPABILITY__SYS_BOOT                      0x00400000UL
28614 +#define CAPABILITY__SYS_NICE                      0x00800000UL
28615 +#define CAPABILITY__SYS_RESOURCE                  0x01000000UL
28616 +#define CAPABILITY__SYS_TIME                      0x02000000UL
28617 +#define CAPABILITY__SYS_TTY_CONFIG                0x04000000UL
28618 +#define CAPABILITY__MKNOD                         0x08000000UL
28619 +#define CAPABILITY__LEASE                         0x10000000UL
28620 +#define CAPABILITY__AUDIT_WRITE                   0x20000000UL
28621 +#define CAPABILITY__AUDIT_CONTROL                 0x40000000UL
28622 +#define CAPABILITY__SETFCAP                       0x80000000UL
28623 +#define FILESYSTEM__MOUNT                         0x00000001UL
28624 +#define FILESYSTEM__REMOUNT                       0x00000002UL
28625 +#define FILESYSTEM__UNMOUNT                       0x00000004UL
28626 +#define FILESYSTEM__GETATTR                       0x00000008UL
28627 +#define FILESYSTEM__RELABELFROM                   0x00000010UL
28628 +#define FILESYSTEM__RELABELTO                     0x00000020UL
28629 +#define FILESYSTEM__TRANSITION                    0x00000040UL
28630 +#define FILESYSTEM__ASSOCIATE                     0x00000080UL
28631 +#define FILESYSTEM__QUOTAMOD                      0x00000100UL
28632 +#define FILESYSTEM__QUOTAGET                      0x00000200UL
28633 +#define FILE__IOCTL                               0x00000001UL
28634 +#define FILE__READ                                0x00000002UL
28635 +#define FILE__WRITE                               0x00000004UL
28636 +#define FILE__CREATE                              0x00000008UL
28637 +#define FILE__GETATTR                             0x00000010UL
28638 +#define FILE__SETATTR                             0x00000020UL
28639 +#define FILE__LOCK                                0x00000040UL
28640 +#define FILE__RELABELFROM                         0x00000080UL
28641 +#define FILE__RELABELTO                           0x00000100UL
28642 +#define FILE__APPEND                              0x00000200UL
28643 +#define FILE__UNLINK                              0x00000400UL
28644 +#define FILE__LINK                                0x00000800UL
28645 +#define FILE__RENAME                              0x00001000UL
28646 +#define FILE__EXECUTE                             0x00002000UL
28647 +#define FILE__SWAPON                              0x00004000UL
28648 +#define FILE__QUOTAON                             0x00008000UL
28649 +#define FILE__MOUNTON                             0x00010000UL
28650 +#define FILE__EXECUTE_NO_TRANS                    0x00020000UL
28651 +#define FILE__ENTRYPOINT                          0x00040000UL
28652 +#define FILE__EXECMOD                             0x00080000UL
28653 +#define FILE__OPEN                                0x00100000UL
28654 +#define DIR__IOCTL                                0x00000001UL
28655 +#define DIR__READ                                 0x00000002UL
28656 +#define DIR__WRITE                                0x00000004UL
28657 +#define DIR__CREATE                               0x00000008UL
28658 +#define DIR__GETATTR                              0x00000010UL
28659 +#define DIR__SETATTR                              0x00000020UL
28660 +#define DIR__LOCK                                 0x00000040UL
28661 +#define DIR__RELABELFROM                          0x00000080UL
28662 +#define DIR__RELABELTO                            0x00000100UL
28663 +#define DIR__APPEND                               0x00000200UL
28664 +#define DIR__UNLINK                               0x00000400UL
28665 +#define DIR__LINK                                 0x00000800UL
28666 +#define DIR__RENAME                               0x00001000UL
28667 +#define DIR__EXECUTE                              0x00002000UL
28668 +#define DIR__SWAPON                               0x00004000UL
28669 +#define DIR__QUOTAON                              0x00008000UL
28670 +#define DIR__MOUNTON                              0x00010000UL
28671 +#define DIR__ADD_NAME                             0x00020000UL
28672 +#define DIR__REMOVE_NAME                          0x00040000UL
28673 +#define DIR__REPARENT                             0x00080000UL
28674 +#define DIR__SEARCH                               0x00100000UL
28675 +#define DIR__RMDIR                                0x00200000UL
28676 +#define DIR__OPEN                                 0x00400000UL
28677 +#define FD__USE                                   0x00000001UL
28678 +#define LNK_FILE__IOCTL                           0x00000001UL
28679 +#define LNK_FILE__READ                            0x00000002UL
28680 +#define LNK_FILE__WRITE                           0x00000004UL
28681 +#define LNK_FILE__CREATE                          0x00000008UL
28682 +#define LNK_FILE__GETATTR                         0x00000010UL
28683 +#define LNK_FILE__SETATTR                         0x00000020UL
28684 +#define LNK_FILE__LOCK                            0x00000040UL
28685 +#define LNK_FILE__RELABELFROM                     0x00000080UL
28686 +#define LNK_FILE__RELABELTO                       0x00000100UL
28687 +#define LNK_FILE__APPEND                          0x00000200UL
28688 +#define LNK_FILE__UNLINK                          0x00000400UL
28689 +#define LNK_FILE__LINK                            0x00000800UL
28690 +#define LNK_FILE__RENAME                          0x00001000UL
28691 +#define LNK_FILE__EXECUTE                         0x00002000UL
28692 +#define LNK_FILE__SWAPON                          0x00004000UL
28693 +#define LNK_FILE__QUOTAON                         0x00008000UL
28694 +#define LNK_FILE__MOUNTON                         0x00010000UL
28695 +#define CHR_FILE__IOCTL                           0x00000001UL
28696 +#define CHR_FILE__READ                            0x00000002UL
28697 +#define CHR_FILE__WRITE                           0x00000004UL
28698 +#define CHR_FILE__CREATE                          0x00000008UL
28699 +#define CHR_FILE__GETATTR                         0x00000010UL
28700 +#define CHR_FILE__SETATTR                         0x00000020UL
28701 +#define CHR_FILE__LOCK                            0x00000040UL
28702 +#define CHR_FILE__RELABELFROM                     0x00000080UL
28703 +#define CHR_FILE__RELABELTO                       0x00000100UL
28704 +#define CHR_FILE__APPEND                          0x00000200UL
28705 +#define CHR_FILE__UNLINK                          0x00000400UL
28706 +#define CHR_FILE__LINK                            0x00000800UL
28707 +#define CHR_FILE__RENAME                          0x00001000UL
28708 +#define CHR_FILE__EXECUTE                         0x00002000UL
28709 +#define CHR_FILE__SWAPON                          0x00004000UL
28710 +#define CHR_FILE__QUOTAON                         0x00008000UL
28711 +#define CHR_FILE__MOUNTON                         0x00010000UL
28712 +#define CHR_FILE__EXECUTE_NO_TRANS                0x00020000UL
28713 +#define CHR_FILE__ENTRYPOINT                      0x00040000UL
28714 +#define CHR_FILE__EXECMOD                         0x00080000UL
28715 +#define CHR_FILE__OPEN                            0x00100000UL
28716 +#define BLK_FILE__IOCTL                           0x00000001UL
28717 +#define BLK_FILE__READ                            0x00000002UL
28718 +#define BLK_FILE__WRITE                           0x00000004UL
28719 +#define BLK_FILE__CREATE                          0x00000008UL
28720 +#define BLK_FILE__GETATTR                         0x00000010UL
28721 +#define BLK_FILE__SETATTR                         0x00000020UL
28722 +#define BLK_FILE__LOCK                            0x00000040UL
28723 +#define BLK_FILE__RELABELFROM                     0x00000080UL
28724 +#define BLK_FILE__RELABELTO                       0x00000100UL
28725 +#define BLK_FILE__APPEND                          0x00000200UL
28726 +#define BLK_FILE__UNLINK                          0x00000400UL
28727 +#define BLK_FILE__LINK                            0x00000800UL
28728 +#define BLK_FILE__RENAME                          0x00001000UL
28729 +#define BLK_FILE__EXECUTE                         0x00002000UL
28730 +#define BLK_FILE__SWAPON                          0x00004000UL
28731 +#define BLK_FILE__QUOTAON                         0x00008000UL
28732 +#define BLK_FILE__MOUNTON                         0x00010000UL
28733 +#define BLK_FILE__OPEN                            0x00020000UL
28734 +#define SOCK_FILE__IOCTL                          0x00000001UL
28735 +#define SOCK_FILE__READ                           0x00000002UL
28736 +#define SOCK_FILE__WRITE                          0x00000004UL
28737 +#define SOCK_FILE__CREATE                         0x00000008UL
28738 +#define SOCK_FILE__GETATTR                        0x00000010UL
28739 +#define SOCK_FILE__SETATTR                        0x00000020UL
28740 +#define SOCK_FILE__LOCK                           0x00000040UL
28741 +#define SOCK_FILE__RELABELFROM                    0x00000080UL
28742 +#define SOCK_FILE__RELABELTO                      0x00000100UL
28743 +#define SOCK_FILE__APPEND                         0x00000200UL
28744 +#define SOCK_FILE__UNLINK                         0x00000400UL
28745 +#define SOCK_FILE__LINK                           0x00000800UL
28746 +#define SOCK_FILE__RENAME                         0x00001000UL
28747 +#define SOCK_FILE__EXECUTE                        0x00002000UL
28748 +#define SOCK_FILE__SWAPON                         0x00004000UL
28749 +#define SOCK_FILE__QUOTAON                        0x00008000UL
28750 +#define SOCK_FILE__MOUNTON                        0x00010000UL
28751 +#define SOCK_FILE__OPEN                           0x00020000UL
28752 +#define FIFO_FILE__IOCTL                          0x00000001UL
28753 +#define FIFO_FILE__READ                           0x00000002UL
28754 +#define FIFO_FILE__WRITE                          0x00000004UL
28755 +#define FIFO_FILE__CREATE                         0x00000008UL
28756 +#define FIFO_FILE__GETATTR                        0x00000010UL
28757 +#define FIFO_FILE__SETATTR                        0x00000020UL
28758 +#define FIFO_FILE__LOCK                           0x00000040UL
28759 +#define FIFO_FILE__RELABELFROM                    0x00000080UL
28760 +#define FIFO_FILE__RELABELTO                      0x00000100UL
28761 +#define FIFO_FILE__APPEND                         0x00000200UL
28762 +#define FIFO_FILE__UNLINK                         0x00000400UL
28763 +#define FIFO_FILE__LINK                           0x00000800UL
28764 +#define FIFO_FILE__RENAME                         0x00001000UL
28765 +#define FIFO_FILE__EXECUTE                        0x00002000UL
28766 +#define FIFO_FILE__SWAPON                         0x00004000UL
28767 +#define FIFO_FILE__QUOTAON                        0x00008000UL
28768 +#define FIFO_FILE__MOUNTON                        0x00010000UL
28769 +#define FIFO_FILE__OPEN                           0x00020000UL
28770 +#define SOCKET__IOCTL                             0x00000001UL
28771 +#define SOCKET__READ                              0x00000002UL
28772 +#define SOCKET__WRITE                             0x00000004UL
28773 +#define SOCKET__CREATE                            0x00000008UL
28774 +#define SOCKET__GETATTR                           0x00000010UL
28775 +#define SOCKET__SETATTR                           0x00000020UL
28776 +#define SOCKET__LOCK                              0x00000040UL
28777 +#define SOCKET__RELABELFROM                       0x00000080UL
28778 +#define SOCKET__RELABELTO                         0x00000100UL
28779 +#define SOCKET__APPEND                            0x00000200UL
28780 +#define SOCKET__BIND                              0x00000400UL
28781 +#define SOCKET__CONNECT                           0x00000800UL
28782 +#define SOCKET__LISTEN                            0x00001000UL
28783 +#define SOCKET__ACCEPT                            0x00002000UL
28784 +#define SOCKET__GETOPT                            0x00004000UL
28785 +#define SOCKET__SETOPT                            0x00008000UL
28786 +#define SOCKET__SHUTDOWN                          0x00010000UL
28787 +#define SOCKET__RECVFROM                          0x00020000UL
28788 +#define SOCKET__SENDTO                            0x00040000UL
28789 +#define SOCKET__RECV_MSG                          0x00080000UL
28790 +#define SOCKET__SEND_MSG                          0x00100000UL
28791 +#define SOCKET__NAME_BIND                         0x00200000UL
28792 +#define TCP_SOCKET__IOCTL                         0x00000001UL
28793 +#define TCP_SOCKET__READ                          0x00000002UL
28794 +#define TCP_SOCKET__WRITE                         0x00000004UL
28795 +#define TCP_SOCKET__CREATE                        0x00000008UL
28796 +#define TCP_SOCKET__GETATTR                       0x00000010UL
28797 +#define TCP_SOCKET__SETATTR                       0x00000020UL
28798 +#define TCP_SOCKET__LOCK                          0x00000040UL
28799 +#define TCP_SOCKET__RELABELFROM                   0x00000080UL
28800 +#define TCP_SOCKET__RELABELTO                     0x00000100UL
28801 +#define TCP_SOCKET__APPEND                        0x00000200UL
28802 +#define TCP_SOCKET__BIND                          0x00000400UL
28803 +#define TCP_SOCKET__CONNECT                       0x00000800UL
28804 +#define TCP_SOCKET__LISTEN                        0x00001000UL
28805 +#define TCP_SOCKET__ACCEPT                        0x00002000UL
28806 +#define TCP_SOCKET__GETOPT                        0x00004000UL
28807 +#define TCP_SOCKET__SETOPT                        0x00008000UL
28808 +#define TCP_SOCKET__SHUTDOWN                      0x00010000UL
28809 +#define TCP_SOCKET__RECVFROM                      0x00020000UL
28810 +#define TCP_SOCKET__SENDTO                        0x00040000UL
28811 +#define TCP_SOCKET__RECV_MSG                      0x00080000UL
28812 +#define TCP_SOCKET__SEND_MSG                      0x00100000UL
28813 +#define TCP_SOCKET__NAME_BIND                     0x00200000UL
28814 +#define TCP_SOCKET__CONNECTTO                     0x00400000UL
28815 +#define TCP_SOCKET__NEWCONN                       0x00800000UL
28816 +#define TCP_SOCKET__ACCEPTFROM                    0x01000000UL
28817 +#define TCP_SOCKET__NODE_BIND                     0x02000000UL
28818 +#define TCP_SOCKET__NAME_CONNECT                  0x04000000UL
28819 +#define UDP_SOCKET__IOCTL                         0x00000001UL
28820 +#define UDP_SOCKET__READ                          0x00000002UL
28821 +#define UDP_SOCKET__WRITE                         0x00000004UL
28822 +#define UDP_SOCKET__CREATE                        0x00000008UL
28823 +#define UDP_SOCKET__GETATTR                       0x00000010UL
28824 +#define UDP_SOCKET__SETATTR                       0x00000020UL
28825 +#define UDP_SOCKET__LOCK                          0x00000040UL
28826 +#define UDP_SOCKET__RELABELFROM                   0x00000080UL
28827 +#define UDP_SOCKET__RELABELTO                     0x00000100UL
28828 +#define UDP_SOCKET__APPEND                        0x00000200UL
28829 +#define UDP_SOCKET__BIND                          0x00000400UL
28830 +#define UDP_SOCKET__CONNECT                       0x00000800UL
28831 +#define UDP_SOCKET__LISTEN                        0x00001000UL
28832 +#define UDP_SOCKET__ACCEPT                        0x00002000UL
28833 +#define UDP_SOCKET__GETOPT                        0x00004000UL
28834 +#define UDP_SOCKET__SETOPT                        0x00008000UL
28835 +#define UDP_SOCKET__SHUTDOWN                      0x00010000UL
28836 +#define UDP_SOCKET__RECVFROM                      0x00020000UL
28837 +#define UDP_SOCKET__SENDTO                        0x00040000UL
28838 +#define UDP_SOCKET__RECV_MSG                      0x00080000UL
28839 +#define UDP_SOCKET__SEND_MSG                      0x00100000UL
28840 +#define UDP_SOCKET__NAME_BIND                     0x00200000UL
28841 +#define UDP_SOCKET__NODE_BIND                     0x00400000UL
28842 +#define RAWIP_SOCKET__IOCTL                       0x00000001UL
28843 +#define RAWIP_SOCKET__READ                        0x00000002UL
28844 +#define RAWIP_SOCKET__WRITE                       0x00000004UL
28845 +#define RAWIP_SOCKET__CREATE                      0x00000008UL
28846 +#define RAWIP_SOCKET__GETATTR                     0x00000010UL
28847 +#define RAWIP_SOCKET__SETATTR                     0x00000020UL
28848 +#define RAWIP_SOCKET__LOCK                        0x00000040UL
28849 +#define RAWIP_SOCKET__RELABELFROM                 0x00000080UL
28850 +#define RAWIP_SOCKET__RELABELTO                   0x00000100UL
28851 +#define RAWIP_SOCKET__APPEND                      0x00000200UL
28852 +#define RAWIP_SOCKET__BIND                        0x00000400UL
28853 +#define RAWIP_SOCKET__CONNECT                     0x00000800UL
28854 +#define RAWIP_SOCKET__LISTEN                      0x00001000UL
28855 +#define RAWIP_SOCKET__ACCEPT                      0x00002000UL
28856 +#define RAWIP_SOCKET__GETOPT                      0x00004000UL
28857 +#define RAWIP_SOCKET__SETOPT                      0x00008000UL
28858 +#define RAWIP_SOCKET__SHUTDOWN                    0x00010000UL
28859 +#define RAWIP_SOCKET__RECVFROM                    0x00020000UL
28860 +#define RAWIP_SOCKET__SENDTO                      0x00040000UL
28861 +#define RAWIP_SOCKET__RECV_MSG                    0x00080000UL
28862 +#define RAWIP_SOCKET__SEND_MSG                    0x00100000UL
28863 +#define RAWIP_SOCKET__NAME_BIND                   0x00200000UL
28864 +#define RAWIP_SOCKET__NODE_BIND                   0x00400000UL
28865 +#define NODE__TCP_RECV                            0x00000001UL
28866 +#define NODE__TCP_SEND                            0x00000002UL
28867 +#define NODE__UDP_RECV                            0x00000004UL
28868 +#define NODE__UDP_SEND                            0x00000008UL
28869 +#define NODE__RAWIP_RECV                          0x00000010UL
28870 +#define NODE__RAWIP_SEND                          0x00000020UL
28871 +#define NODE__ENFORCE_DEST                        0x00000040UL
28872 +#define NODE__DCCP_RECV                           0x00000080UL
28873 +#define NODE__DCCP_SEND                           0x00000100UL
28874 +#define NODE__RECVFROM                            0x00000200UL
28875 +#define NODE__SENDTO                              0x00000400UL
28876 +#define NETIF__TCP_RECV                           0x00000001UL
28877 +#define NETIF__TCP_SEND                           0x00000002UL
28878 +#define NETIF__UDP_RECV                           0x00000004UL
28879 +#define NETIF__UDP_SEND                           0x00000008UL
28880 +#define NETIF__RAWIP_RECV                         0x00000010UL
28881 +#define NETIF__RAWIP_SEND                         0x00000020UL
28882 +#define NETIF__DCCP_RECV                          0x00000040UL
28883 +#define NETIF__DCCP_SEND                          0x00000080UL
28884 +#define NETIF__INGRESS                            0x00000100UL
28885 +#define NETIF__EGRESS                             0x00000200UL
28886 +#define NETLINK_SOCKET__IOCTL                     0x00000001UL
28887 +#define NETLINK_SOCKET__READ                      0x00000002UL
28888 +#define NETLINK_SOCKET__WRITE                     0x00000004UL
28889 +#define NETLINK_SOCKET__CREATE                    0x00000008UL
28890 +#define NETLINK_SOCKET__GETATTR                   0x00000010UL
28891 +#define NETLINK_SOCKET__SETATTR                   0x00000020UL
28892 +#define NETLINK_SOCKET__LOCK                      0x00000040UL
28893 +#define NETLINK_SOCKET__RELABELFROM               0x00000080UL
28894 +#define NETLINK_SOCKET__RELABELTO                 0x00000100UL
28895 +#define NETLINK_SOCKET__APPEND                    0x00000200UL
28896 +#define NETLINK_SOCKET__BIND                      0x00000400UL
28897 +#define NETLINK_SOCKET__CONNECT                   0x00000800UL
28898 +#define NETLINK_SOCKET__LISTEN                    0x00001000UL
28899 +#define NETLINK_SOCKET__ACCEPT                    0x00002000UL
28900 +#define NETLINK_SOCKET__GETOPT                    0x00004000UL
28901 +#define NETLINK_SOCKET__SETOPT                    0x00008000UL
28902 +#define NETLINK_SOCKET__SHUTDOWN                  0x00010000UL
28903 +#define NETLINK_SOCKET__RECVFROM                  0x00020000UL
28904 +#define NETLINK_SOCKET__SENDTO                    0x00040000UL
28905 +#define NETLINK_SOCKET__RECV_MSG                  0x00080000UL
28906 +#define NETLINK_SOCKET__SEND_MSG                  0x00100000UL
28907 +#define NETLINK_SOCKET__NAME_BIND                 0x00200000UL
28908 +#define PACKET_SOCKET__IOCTL                      0x00000001UL
28909 +#define PACKET_SOCKET__READ                       0x00000002UL
28910 +#define PACKET_SOCKET__WRITE                      0x00000004UL
28911 +#define PACKET_SOCKET__CREATE                     0x00000008UL
28912 +#define PACKET_SOCKET__GETATTR                    0x00000010UL
28913 +#define PACKET_SOCKET__SETATTR                    0x00000020UL
28914 +#define PACKET_SOCKET__LOCK                       0x00000040UL
28915 +#define PACKET_SOCKET__RELABELFROM                0x00000080UL
28916 +#define PACKET_SOCKET__RELABELTO                  0x00000100UL
28917 +#define PACKET_SOCKET__APPEND                     0x00000200UL
28918 +#define PACKET_SOCKET__BIND                       0x00000400UL
28919 +#define PACKET_SOCKET__CONNECT                    0x00000800UL
28920 +#define PACKET_SOCKET__LISTEN                     0x00001000UL
28921 +#define PACKET_SOCKET__ACCEPT                     0x00002000UL
28922 +#define PACKET_SOCKET__GETOPT                     0x00004000UL
28923 +#define PACKET_SOCKET__SETOPT                     0x00008000UL
28924 +#define PACKET_SOCKET__SHUTDOWN                   0x00010000UL
28925 +#define PACKET_SOCKET__RECVFROM                   0x00020000UL
28926 +#define PACKET_SOCKET__SENDTO                     0x00040000UL
28927 +#define PACKET_SOCKET__RECV_MSG                   0x00080000UL
28928 +#define PACKET_SOCKET__SEND_MSG                   0x00100000UL
28929 +#define PACKET_SOCKET__NAME_BIND                  0x00200000UL
28930 +#define KEY_SOCKET__IOCTL                         0x00000001UL
28931 +#define KEY_SOCKET__READ                          0x00000002UL
28932 +#define KEY_SOCKET__WRITE                         0x00000004UL
28933 +#define KEY_SOCKET__CREATE                        0x00000008UL
28934 +#define KEY_SOCKET__GETATTR                       0x00000010UL
28935 +#define KEY_SOCKET__SETATTR                       0x00000020UL
28936 +#define KEY_SOCKET__LOCK                          0x00000040UL
28937 +#define KEY_SOCKET__RELABELFROM                   0x00000080UL
28938 +#define KEY_SOCKET__RELABELTO                     0x00000100UL
28939 +#define KEY_SOCKET__APPEND                        0x00000200UL
28940 +#define KEY_SOCKET__BIND                          0x00000400UL
28941 +#define KEY_SOCKET__CONNECT                       0x00000800UL
28942 +#define KEY_SOCKET__LISTEN                        0x00001000UL
28943 +#define KEY_SOCKET__ACCEPT                        0x00002000UL
28944 +#define KEY_SOCKET__GETOPT                        0x00004000UL
28945 +#define KEY_SOCKET__SETOPT                        0x00008000UL
28946 +#define KEY_SOCKET__SHUTDOWN                      0x00010000UL
28947 +#define KEY_SOCKET__RECVFROM                      0x00020000UL
28948 +#define KEY_SOCKET__SENDTO                        0x00040000UL
28949 +#define KEY_SOCKET__RECV_MSG                      0x00080000UL
28950 +#define KEY_SOCKET__SEND_MSG                      0x00100000UL
28951 +#define KEY_SOCKET__NAME_BIND                     0x00200000UL
28952 +#define UNIX_STREAM_SOCKET__IOCTL                 0x00000001UL
28953 +#define UNIX_STREAM_SOCKET__READ                  0x00000002UL
28954 +#define UNIX_STREAM_SOCKET__WRITE                 0x00000004UL
28955 +#define UNIX_STREAM_SOCKET__CREATE                0x00000008UL
28956 +#define UNIX_STREAM_SOCKET__GETATTR               0x00000010UL
28957 +#define UNIX_STREAM_SOCKET__SETATTR               0x00000020UL
28958 +#define UNIX_STREAM_SOCKET__LOCK                  0x00000040UL
28959 +#define UNIX_STREAM_SOCKET__RELABELFROM           0x00000080UL
28960 +#define UNIX_STREAM_SOCKET__RELABELTO             0x00000100UL
28961 +#define UNIX_STREAM_SOCKET__APPEND                0x00000200UL
28962 +#define UNIX_STREAM_SOCKET__BIND                  0x00000400UL
28963 +#define UNIX_STREAM_SOCKET__CONNECT               0x00000800UL
28964 +#define UNIX_STREAM_SOCKET__LISTEN                0x00001000UL
28965 +#define UNIX_STREAM_SOCKET__ACCEPT                0x00002000UL
28966 +#define UNIX_STREAM_SOCKET__GETOPT                0x00004000UL
28967 +#define UNIX_STREAM_SOCKET__SETOPT                0x00008000UL
28968 +#define UNIX_STREAM_SOCKET__SHUTDOWN              0x00010000UL
28969 +#define UNIX_STREAM_SOCKET__RECVFROM              0x00020000UL
28970 +#define UNIX_STREAM_SOCKET__SENDTO                0x00040000UL
28971 +#define UNIX_STREAM_SOCKET__RECV_MSG              0x00080000UL
28972 +#define UNIX_STREAM_SOCKET__SEND_MSG              0x00100000UL
28973 +#define UNIX_STREAM_SOCKET__NAME_BIND             0x00200000UL
28974 +#define UNIX_STREAM_SOCKET__CONNECTTO             0x00400000UL
28975 +#define UNIX_STREAM_SOCKET__NEWCONN               0x00800000UL
28976 +#define UNIX_STREAM_SOCKET__ACCEPTFROM            0x01000000UL
28977 +#define UNIX_DGRAM_SOCKET__IOCTL                  0x00000001UL
28978 +#define UNIX_DGRAM_SOCKET__READ                   0x00000002UL
28979 +#define UNIX_DGRAM_SOCKET__WRITE                  0x00000004UL
28980 +#define UNIX_DGRAM_SOCKET__CREATE                 0x00000008UL
28981 +#define UNIX_DGRAM_SOCKET__GETATTR                0x00000010UL
28982 +#define UNIX_DGRAM_SOCKET__SETATTR                0x00000020UL
28983 +#define UNIX_DGRAM_SOCKET__LOCK                   0x00000040UL
28984 +#define UNIX_DGRAM_SOCKET__RELABELFROM            0x00000080UL
28985 +#define UNIX_DGRAM_SOCKET__RELABELTO              0x00000100UL
28986 +#define UNIX_DGRAM_SOCKET__APPEND                 0x00000200UL
28987 +#define UNIX_DGRAM_SOCKET__BIND                   0x00000400UL
28988 +#define UNIX_DGRAM_SOCKET__CONNECT                0x00000800UL
28989 +#define UNIX_DGRAM_SOCKET__LISTEN                 0x00001000UL
28990 +#define UNIX_DGRAM_SOCKET__ACCEPT                 0x00002000UL
28991 +#define UNIX_DGRAM_SOCKET__GETOPT                 0x00004000UL
28992 +#define UNIX_DGRAM_SOCKET__SETOPT                 0x00008000UL
28993 +#define UNIX_DGRAM_SOCKET__SHUTDOWN               0x00010000UL
28994 +#define UNIX_DGRAM_SOCKET__RECVFROM               0x00020000UL
28995 +#define UNIX_DGRAM_SOCKET__SENDTO                 0x00040000UL
28996 +#define UNIX_DGRAM_SOCKET__RECV_MSG               0x00080000UL
28997 +#define UNIX_DGRAM_SOCKET__SEND_MSG               0x00100000UL
28998 +#define UNIX_DGRAM_SOCKET__NAME_BIND              0x00200000UL
28999 +#define SEM__CREATE                               0x00000001UL
29000 +#define SEM__DESTROY                              0x00000002UL
29001 +#define SEM__GETATTR                              0x00000004UL
29002 +#define SEM__SETATTR                              0x00000008UL
29003 +#define SEM__READ                                 0x00000010UL
29004 +#define SEM__WRITE                                0x00000020UL
29005 +#define SEM__ASSOCIATE                            0x00000040UL
29006 +#define SEM__UNIX_READ                            0x00000080UL
29007 +#define SEM__UNIX_WRITE                           0x00000100UL
29008 +#define MSG__SEND                                 0x00000001UL
29009 +#define MSG__RECEIVE                              0x00000002UL
29010 +#define MSGQ__CREATE                              0x00000001UL
29011 +#define MSGQ__DESTROY                             0x00000002UL
29012 +#define MSGQ__GETATTR                             0x00000004UL
29013 +#define MSGQ__SETATTR                             0x00000008UL
29014 +#define MSGQ__READ                                0x00000010UL
29015 +#define MSGQ__WRITE                               0x00000020UL
29016 +#define MSGQ__ASSOCIATE                           0x00000040UL
29017 +#define MSGQ__UNIX_READ                           0x00000080UL
29018 +#define MSGQ__UNIX_WRITE                          0x00000100UL
29019 +#define MSGQ__ENQUEUE                             0x00000200UL
29020 +#define SHM__CREATE                               0x00000001UL
29021 +#define SHM__DESTROY                              0x00000002UL
29022 +#define SHM__GETATTR                              0x00000004UL
29023 +#define SHM__SETATTR                              0x00000008UL
29024 +#define SHM__READ                                 0x00000010UL
29025 +#define SHM__WRITE                                0x00000020UL
29026 +#define SHM__ASSOCIATE                            0x00000040UL
29027 +#define SHM__UNIX_READ                            0x00000080UL
29028 +#define SHM__UNIX_WRITE                           0x00000100UL
29029 +#define SHM__LOCK                                 0x00000200UL
29030 +#define IPC__CREATE                               0x00000001UL
29031 +#define IPC__DESTROY                              0x00000002UL
29032 +#define IPC__GETATTR                              0x00000004UL
29033 +#define IPC__SETATTR                              0x00000008UL
29034 +#define IPC__READ                                 0x00000010UL
29035 +#define IPC__WRITE                                0x00000020UL
29036 +#define IPC__ASSOCIATE                            0x00000040UL
29037 +#define IPC__UNIX_READ                            0x00000080UL
29038 +#define IPC__UNIX_WRITE                           0x00000100UL
29039 +#define NETLINK_ROUTE_SOCKET__IOCTL               0x00000001UL
29040 +#define NETLINK_ROUTE_SOCKET__READ                0x00000002UL
29041 +#define NETLINK_ROUTE_SOCKET__WRITE               0x00000004UL
29042 +#define NETLINK_ROUTE_SOCKET__CREATE              0x00000008UL
29043 +#define NETLINK_ROUTE_SOCKET__GETATTR             0x00000010UL
29044 +#define NETLINK_ROUTE_SOCKET__SETATTR             0x00000020UL
29045 +#define NETLINK_ROUTE_SOCKET__LOCK                0x00000040UL
29046 +#define NETLINK_ROUTE_SOCKET__RELABELFROM         0x00000080UL
29047 +#define NETLINK_ROUTE_SOCKET__RELABELTO           0x00000100UL
29048 +#define NETLINK_ROUTE_SOCKET__APPEND              0x00000200UL
29049 +#define NETLINK_ROUTE_SOCKET__BIND                0x00000400UL
29050 +#define NETLINK_ROUTE_SOCKET__CONNECT             0x00000800UL
29051 +#define NETLINK_ROUTE_SOCKET__LISTEN              0x00001000UL
29052 +#define NETLINK_ROUTE_SOCKET__ACCEPT              0x00002000UL
29053 +#define NETLINK_ROUTE_SOCKET__GETOPT              0x00004000UL
29054 +#define NETLINK_ROUTE_SOCKET__SETOPT              0x00008000UL
29055 +#define NETLINK_ROUTE_SOCKET__SHUTDOWN            0x00010000UL
29056 +#define NETLINK_ROUTE_SOCKET__RECVFROM            0x00020000UL
29057 +#define NETLINK_ROUTE_SOCKET__SENDTO              0x00040000UL
29058 +#define NETLINK_ROUTE_SOCKET__RECV_MSG            0x00080000UL
29059 +#define NETLINK_ROUTE_SOCKET__SEND_MSG            0x00100000UL
29060 +#define NETLINK_ROUTE_SOCKET__NAME_BIND           0x00200000UL
29061 +#define NETLINK_ROUTE_SOCKET__NLMSG_READ          0x00400000UL
29062 +#define NETLINK_ROUTE_SOCKET__NLMSG_WRITE         0x00800000UL
29063 +#define NETLINK_FIREWALL_SOCKET__IOCTL            0x00000001UL
29064 +#define NETLINK_FIREWALL_SOCKET__READ             0x00000002UL
29065 +#define NETLINK_FIREWALL_SOCKET__WRITE            0x00000004UL
29066 +#define NETLINK_FIREWALL_SOCKET__CREATE           0x00000008UL
29067 +#define NETLINK_FIREWALL_SOCKET__GETATTR          0x00000010UL
29068 +#define NETLINK_FIREWALL_SOCKET__SETATTR          0x00000020UL
29069 +#define NETLINK_FIREWALL_SOCKET__LOCK             0x00000040UL
29070 +#define NETLINK_FIREWALL_SOCKET__RELABELFROM      0x00000080UL
29071 +#define NETLINK_FIREWALL_SOCKET__RELABELTO        0x00000100UL
29072 +#define NETLINK_FIREWALL_SOCKET__APPEND           0x00000200UL
29073 +#define NETLINK_FIREWALL_SOCKET__BIND             0x00000400UL
29074 +#define NETLINK_FIREWALL_SOCKET__CONNECT          0x00000800UL
29075 +#define NETLINK_FIREWALL_SOCKET__LISTEN           0x00001000UL
29076 +#define NETLINK_FIREWALL_SOCKET__ACCEPT           0x00002000UL
29077 +#define NETLINK_FIREWALL_SOCKET__GETOPT           0x00004000UL
29078 +#define NETLINK_FIREWALL_SOCKET__SETOPT           0x00008000UL
29079 +#define NETLINK_FIREWALL_SOCKET__SHUTDOWN         0x00010000UL
29080 +#define NETLINK_FIREWALL_SOCKET__RECVFROM         0x00020000UL
29081 +#define NETLINK_FIREWALL_SOCKET__SENDTO           0x00040000UL
29082 +#define NETLINK_FIREWALL_SOCKET__RECV_MSG         0x00080000UL
29083 +#define NETLINK_FIREWALL_SOCKET__SEND_MSG         0x00100000UL
29084 +#define NETLINK_FIREWALL_SOCKET__NAME_BIND        0x00200000UL
29085 +#define NETLINK_FIREWALL_SOCKET__NLMSG_READ       0x00400000UL
29086 +#define NETLINK_FIREWALL_SOCKET__NLMSG_WRITE      0x00800000UL
29087 +#define NETLINK_TCPDIAG_SOCKET__IOCTL             0x00000001UL
29088 +#define NETLINK_TCPDIAG_SOCKET__READ              0x00000002UL
29089 +#define NETLINK_TCPDIAG_SOCKET__WRITE             0x00000004UL
29090 +#define NETLINK_TCPDIAG_SOCKET__CREATE            0x00000008UL
29091 +#define NETLINK_TCPDIAG_SOCKET__GETATTR           0x00000010UL
29092 +#define NETLINK_TCPDIAG_SOCKET__SETATTR           0x00000020UL
29093 +#define NETLINK_TCPDIAG_SOCKET__LOCK              0x00000040UL
29094 +#define NETLINK_TCPDIAG_SOCKET__RELABELFROM       0x00000080UL
29095 +#define NETLINK_TCPDIAG_SOCKET__RELABELTO         0x00000100UL
29096 +#define NETLINK_TCPDIAG_SOCKET__APPEND            0x00000200UL
29097 +#define NETLINK_TCPDIAG_SOCKET__BIND              0x00000400UL
29098 +#define NETLINK_TCPDIAG_SOCKET__CONNECT           0x00000800UL
29099 +#define NETLINK_TCPDIAG_SOCKET__LISTEN            0x00001000UL
29100 +#define NETLINK_TCPDIAG_SOCKET__ACCEPT            0x00002000UL
29101 +#define NETLINK_TCPDIAG_SOCKET__GETOPT            0x00004000UL
29102 +#define NETLINK_TCPDIAG_SOCKET__SETOPT            0x00008000UL
29103 +#define NETLINK_TCPDIAG_SOCKET__SHUTDOWN          0x00010000UL
29104 +#define NETLINK_TCPDIAG_SOCKET__RECVFROM          0x00020000UL
29105 +#define NETLINK_TCPDIAG_SOCKET__SENDTO            0x00040000UL
29106 +#define NETLINK_TCPDIAG_SOCKET__RECV_MSG          0x00080000UL
29107 +#define NETLINK_TCPDIAG_SOCKET__SEND_MSG          0x00100000UL
29108 +#define NETLINK_TCPDIAG_SOCKET__NAME_BIND         0x00200000UL
29109 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_READ        0x00400000UL
29110 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_WRITE       0x00800000UL
29111 +#define NETLINK_NFLOG_SOCKET__IOCTL               0x00000001UL
29112 +#define NETLINK_NFLOG_SOCKET__READ                0x00000002UL
29113 +#define NETLINK_NFLOG_SOCKET__WRITE               0x00000004UL
29114 +#define NETLINK_NFLOG_SOCKET__CREATE              0x00000008UL
29115 +#define NETLINK_NFLOG_SOCKET__GETATTR             0x00000010UL
29116 +#define NETLINK_NFLOG_SOCKET__SETATTR             0x00000020UL
29117 +#define NETLINK_NFLOG_SOCKET__LOCK                0x00000040UL
29118 +#define NETLINK_NFLOG_SOCKET__RELABELFROM         0x00000080UL
29119 +#define NETLINK_NFLOG_SOCKET__RELABELTO           0x00000100UL
29120 +#define NETLINK_NFLOG_SOCKET__APPEND              0x00000200UL
29121 +#define NETLINK_NFLOG_SOCKET__BIND                0x00000400UL
29122 +#define NETLINK_NFLOG_SOCKET__CONNECT             0x00000800UL
29123 +#define NETLINK_NFLOG_SOCKET__LISTEN              0x00001000UL
29124 +#define NETLINK_NFLOG_SOCKET__ACCEPT              0x00002000UL
29125 +#define NETLINK_NFLOG_SOCKET__GETOPT              0x00004000UL
29126 +#define NETLINK_NFLOG_SOCKET__SETOPT              0x00008000UL
29127 +#define NETLINK_NFLOG_SOCKET__SHUTDOWN            0x00010000UL
29128 +#define NETLINK_NFLOG_SOCKET__RECVFROM            0x00020000UL
29129 +#define NETLINK_NFLOG_SOCKET__SENDTO              0x00040000UL
29130 +#define NETLINK_NFLOG_SOCKET__RECV_MSG            0x00080000UL
29131 +#define NETLINK_NFLOG_SOCKET__SEND_MSG            0x00100000UL
29132 +#define NETLINK_NFLOG_SOCKET__NAME_BIND           0x00200000UL
29133 +#define NETLINK_XFRM_SOCKET__IOCTL                0x00000001UL
29134 +#define NETLINK_XFRM_SOCKET__READ                 0x00000002UL
29135 +#define NETLINK_XFRM_SOCKET__WRITE                0x00000004UL
29136 +#define NETLINK_XFRM_SOCKET__CREATE               0x00000008UL
29137 +#define NETLINK_XFRM_SOCKET__GETATTR              0x00000010UL
29138 +#define NETLINK_XFRM_SOCKET__SETATTR              0x00000020UL
29139 +#define NETLINK_XFRM_SOCKET__LOCK                 0x00000040UL
29140 +#define NETLINK_XFRM_SOCKET__RELABELFROM          0x00000080UL
29141 +#define NETLINK_XFRM_SOCKET__RELABELTO            0x00000100UL
29142 +#define NETLINK_XFRM_SOCKET__APPEND               0x00000200UL
29143 +#define NETLINK_XFRM_SOCKET__BIND                 0x00000400UL
29144 +#define NETLINK_XFRM_SOCKET__CONNECT              0x00000800UL
29145 +#define NETLINK_XFRM_SOCKET__LISTEN               0x00001000UL
29146 +#define NETLINK_XFRM_SOCKET__ACCEPT               0x00002000UL
29147 +#define NETLINK_XFRM_SOCKET__GETOPT               0x00004000UL
29148 +#define NETLINK_XFRM_SOCKET__SETOPT               0x00008000UL
29149 +#define NETLINK_XFRM_SOCKET__SHUTDOWN             0x00010000UL
29150 +#define NETLINK_XFRM_SOCKET__RECVFROM             0x00020000UL
29151 +#define NETLINK_XFRM_SOCKET__SENDTO               0x00040000UL
29152 +#define NETLINK_XFRM_SOCKET__RECV_MSG             0x00080000UL
29153 +#define NETLINK_XFRM_SOCKET__SEND_MSG             0x00100000UL
29154 +#define NETLINK_XFRM_SOCKET__NAME_BIND            0x00200000UL
29155 +#define NETLINK_XFRM_SOCKET__NLMSG_READ           0x00400000UL
29156 +#define NETLINK_XFRM_SOCKET__NLMSG_WRITE          0x00800000UL
29157 +#define NETLINK_SELINUX_SOCKET__IOCTL             0x00000001UL
29158 +#define NETLINK_SELINUX_SOCKET__READ              0x00000002UL
29159 +#define NETLINK_SELINUX_SOCKET__WRITE             0x00000004UL
29160 +#define NETLINK_SELINUX_SOCKET__CREATE            0x00000008UL
29161 +#define NETLINK_SELINUX_SOCKET__GETATTR           0x00000010UL
29162 +#define NETLINK_SELINUX_SOCKET__SETATTR           0x00000020UL
29163 +#define NETLINK_SELINUX_SOCKET__LOCK              0x00000040UL
29164 +#define NETLINK_SELINUX_SOCKET__RELABELFROM       0x00000080UL
29165 +#define NETLINK_SELINUX_SOCKET__RELABELTO         0x00000100UL
29166 +#define NETLINK_SELINUX_SOCKET__APPEND            0x00000200UL
29167 +#define NETLINK_SELINUX_SOCKET__BIND              0x00000400UL
29168 +#define NETLINK_SELINUX_SOCKET__CONNECT           0x00000800UL
29169 +#define NETLINK_SELINUX_SOCKET__LISTEN            0x00001000UL
29170 +#define NETLINK_SELINUX_SOCKET__ACCEPT            0x00002000UL
29171 +#define NETLINK_SELINUX_SOCKET__GETOPT            0x00004000UL
29172 +#define NETLINK_SELINUX_SOCKET__SETOPT            0x00008000UL
29173 +#define NETLINK_SELINUX_SOCKET__SHUTDOWN          0x00010000UL
29174 +#define NETLINK_SELINUX_SOCKET__RECVFROM          0x00020000UL
29175 +#define NETLINK_SELINUX_SOCKET__SENDTO            0x00040000UL
29176 +#define NETLINK_SELINUX_SOCKET__RECV_MSG          0x00080000UL
29177 +#define NETLINK_SELINUX_SOCKET__SEND_MSG          0x00100000UL
29178 +#define NETLINK_SELINUX_SOCKET__NAME_BIND         0x00200000UL
29179 +#define NETLINK_AUDIT_SOCKET__IOCTL               0x00000001UL
29180 +#define NETLINK_AUDIT_SOCKET__READ                0x00000002UL
29181 +#define NETLINK_AUDIT_SOCKET__WRITE               0x00000004UL
29182 +#define NETLINK_AUDIT_SOCKET__CREATE              0x00000008UL
29183 +#define NETLINK_AUDIT_SOCKET__GETATTR             0x00000010UL
29184 +#define NETLINK_AUDIT_SOCKET__SETATTR             0x00000020UL
29185 +#define NETLINK_AUDIT_SOCKET__LOCK                0x00000040UL
29186 +#define NETLINK_AUDIT_SOCKET__RELABELFROM         0x00000080UL
29187 +#define NETLINK_AUDIT_SOCKET__RELABELTO           0x00000100UL
29188 +#define NETLINK_AUDIT_SOCKET__APPEND              0x00000200UL
29189 +#define NETLINK_AUDIT_SOCKET__BIND                0x00000400UL
29190 +#define NETLINK_AUDIT_SOCKET__CONNECT             0x00000800UL
29191 +#define NETLINK_AUDIT_SOCKET__LISTEN              0x00001000UL
29192 +#define NETLINK_AUDIT_SOCKET__ACCEPT              0x00002000UL
29193 +#define NETLINK_AUDIT_SOCKET__GETOPT              0x00004000UL
29194 +#define NETLINK_AUDIT_SOCKET__SETOPT              0x00008000UL
29195 +#define NETLINK_AUDIT_SOCKET__SHUTDOWN            0x00010000UL
29196 +#define NETLINK_AUDIT_SOCKET__RECVFROM            0x00020000UL
29197 +#define NETLINK_AUDIT_SOCKET__SENDTO              0x00040000UL
29198 +#define NETLINK_AUDIT_SOCKET__RECV_MSG            0x00080000UL
29199 +#define NETLINK_AUDIT_SOCKET__SEND_MSG            0x00100000UL
29200 +#define NETLINK_AUDIT_SOCKET__NAME_BIND           0x00200000UL
29201 +#define NETLINK_AUDIT_SOCKET__NLMSG_READ          0x00400000UL
29202 +#define NETLINK_AUDIT_SOCKET__NLMSG_WRITE         0x00800000UL
29203 +#define NETLINK_AUDIT_SOCKET__NLMSG_RELAY         0x01000000UL
29204 +#define NETLINK_AUDIT_SOCKET__NLMSG_READPRIV      0x02000000UL
29205 +#define NETLINK_AUDIT_SOCKET__NLMSG_TTY_AUDIT     0x04000000UL
29206 +#define NETLINK_IP6FW_SOCKET__IOCTL               0x00000001UL
29207 +#define NETLINK_IP6FW_SOCKET__READ                0x00000002UL
29208 +#define NETLINK_IP6FW_SOCKET__WRITE               0x00000004UL
29209 +#define NETLINK_IP6FW_SOCKET__CREATE              0x00000008UL
29210 +#define NETLINK_IP6FW_SOCKET__GETATTR             0x00000010UL
29211 +#define NETLINK_IP6FW_SOCKET__SETATTR             0x00000020UL
29212 +#define NETLINK_IP6FW_SOCKET__LOCK                0x00000040UL
29213 +#define NETLINK_IP6FW_SOCKET__RELABELFROM         0x00000080UL
29214 +#define NETLINK_IP6FW_SOCKET__RELABELTO           0x00000100UL
29215 +#define NETLINK_IP6FW_SOCKET__APPEND              0x00000200UL
29216 +#define NETLINK_IP6FW_SOCKET__BIND                0x00000400UL
29217 +#define NETLINK_IP6FW_SOCKET__CONNECT             0x00000800UL
29218 +#define NETLINK_IP6FW_SOCKET__LISTEN              0x00001000UL
29219 +#define NETLINK_IP6FW_SOCKET__ACCEPT              0x00002000UL
29220 +#define NETLINK_IP6FW_SOCKET__GETOPT              0x00004000UL
29221 +#define NETLINK_IP6FW_SOCKET__SETOPT              0x00008000UL
29222 +#define NETLINK_IP6FW_SOCKET__SHUTDOWN            0x00010000UL
29223 +#define NETLINK_IP6FW_SOCKET__RECVFROM            0x00020000UL
29224 +#define NETLINK_IP6FW_SOCKET__SENDTO              0x00040000UL
29225 +#define NETLINK_IP6FW_SOCKET__RECV_MSG            0x00080000UL
29226 +#define NETLINK_IP6FW_SOCKET__SEND_MSG            0x00100000UL
29227 +#define NETLINK_IP6FW_SOCKET__NAME_BIND           0x00200000UL
29228 +#define NETLINK_IP6FW_SOCKET__NLMSG_READ          0x00400000UL
29229 +#define NETLINK_IP6FW_SOCKET__NLMSG_WRITE         0x00800000UL
29230 +#define NETLINK_DNRT_SOCKET__IOCTL                0x00000001UL
29231 +#define NETLINK_DNRT_SOCKET__READ                 0x00000002UL
29232 +#define NETLINK_DNRT_SOCKET__WRITE                0x00000004UL
29233 +#define NETLINK_DNRT_SOCKET__CREATE               0x00000008UL
29234 +#define NETLINK_DNRT_SOCKET__GETATTR              0x00000010UL
29235 +#define NETLINK_DNRT_SOCKET__SETATTR              0x00000020UL
29236 +#define NETLINK_DNRT_SOCKET__LOCK                 0x00000040UL
29237 +#define NETLINK_DNRT_SOCKET__RELABELFROM          0x00000080UL
29238 +#define NETLINK_DNRT_SOCKET__RELABELTO            0x00000100UL
29239 +#define NETLINK_DNRT_SOCKET__APPEND               0x00000200UL
29240 +#define NETLINK_DNRT_SOCKET__BIND                 0x00000400UL
29241 +#define NETLINK_DNRT_SOCKET__CONNECT              0x00000800UL
29242 +#define NETLINK_DNRT_SOCKET__LISTEN               0x00001000UL
29243 +#define NETLINK_DNRT_SOCKET__ACCEPT               0x00002000UL
29244 +#define NETLINK_DNRT_SOCKET__GETOPT               0x00004000UL
29245 +#define NETLINK_DNRT_SOCKET__SETOPT               0x00008000UL
29246 +#define NETLINK_DNRT_SOCKET__SHUTDOWN             0x00010000UL
29247 +#define NETLINK_DNRT_SOCKET__RECVFROM             0x00020000UL
29248 +#define NETLINK_DNRT_SOCKET__SENDTO               0x00040000UL
29249 +#define NETLINK_DNRT_SOCKET__RECV_MSG             0x00080000UL
29250 +#define NETLINK_DNRT_SOCKET__SEND_MSG             0x00100000UL
29251 +#define NETLINK_DNRT_SOCKET__NAME_BIND            0x00200000UL
29252 +#define ASSOCIATION__SENDTO                       0x00000001UL
29253 +#define ASSOCIATION__RECVFROM                     0x00000002UL
29254 +#define ASSOCIATION__SETCONTEXT                   0x00000004UL
29255 +#define ASSOCIATION__POLMATCH                     0x00000008UL
29256 +#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL      0x00000001UL
29257 +#define NETLINK_KOBJECT_UEVENT_SOCKET__READ       0x00000002UL
29258 +#define NETLINK_KOBJECT_UEVENT_SOCKET__WRITE      0x00000004UL
29259 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CREATE     0x00000008UL
29260 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETATTR    0x00000010UL
29261 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETATTR    0x00000020UL
29262 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LOCK       0x00000040UL
29263 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELFROM 0x00000080UL
29264 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELTO  0x00000100UL
29265 +#define NETLINK_KOBJECT_UEVENT_SOCKET__APPEND     0x00000200UL
29266 +#define NETLINK_KOBJECT_UEVENT_SOCKET__BIND       0x00000400UL
29267 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CONNECT    0x00000800UL
29268 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LISTEN     0x00001000UL
29269 +#define NETLINK_KOBJECT_UEVENT_SOCKET__ACCEPT     0x00002000UL
29270 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETOPT     0x00004000UL
29271 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETOPT     0x00008000UL
29272 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SHUTDOWN   0x00010000UL
29273 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECVFROM   0x00020000UL
29274 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SENDTO     0x00040000UL
29275 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECV_MSG   0x00080000UL
29276 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SEND_MSG   0x00100000UL
29277 +#define NETLINK_KOBJECT_UEVENT_SOCKET__NAME_BIND  0x00200000UL
29278 +#define APPLETALK_SOCKET__IOCTL                   0x00000001UL
29279 +#define APPLETALK_SOCKET__READ                    0x00000002UL
29280 +#define APPLETALK_SOCKET__WRITE                   0x00000004UL
29281 +#define APPLETALK_SOCKET__CREATE                  0x00000008UL
29282 +#define APPLETALK_SOCKET__GETATTR                 0x00000010UL
29283 +#define APPLETALK_SOCKET__SETATTR                 0x00000020UL
29284 +#define APPLETALK_SOCKET__LOCK                    0x00000040UL
29285 +#define APPLETALK_SOCKET__RELABELFROM             0x00000080UL
29286 +#define APPLETALK_SOCKET__RELABELTO               0x00000100UL
29287 +#define APPLETALK_SOCKET__APPEND                  0x00000200UL
29288 +#define APPLETALK_SOCKET__BIND                    0x00000400UL
29289 +#define APPLETALK_SOCKET__CONNECT                 0x00000800UL
29290 +#define APPLETALK_SOCKET__LISTEN                  0x00001000UL
29291 +#define APPLETALK_SOCKET__ACCEPT                  0x00002000UL
29292 +#define APPLETALK_SOCKET__GETOPT                  0x00004000UL
29293 +#define APPLETALK_SOCKET__SETOPT                  0x00008000UL
29294 +#define APPLETALK_SOCKET__SHUTDOWN                0x00010000UL
29295 +#define APPLETALK_SOCKET__RECVFROM                0x00020000UL
29296 +#define APPLETALK_SOCKET__SENDTO                  0x00040000UL
29297 +#define APPLETALK_SOCKET__RECV_MSG                0x00080000UL
29298 +#define APPLETALK_SOCKET__SEND_MSG                0x00100000UL
29299 +#define APPLETALK_SOCKET__NAME_BIND               0x00200000UL
29300 +#define PACKET__SEND                              0x00000001UL
29301 +#define PACKET__RECV                              0x00000002UL
29302 +#define PACKET__RELABELTO                         0x00000004UL
29303 +#define PACKET__FLOW_IN                           0x00000008UL
29304 +#define PACKET__FLOW_OUT                          0x00000010UL
29305 +#define PACKET__FORWARD_IN                        0x00000020UL
29306 +#define PACKET__FORWARD_OUT                       0x00000040UL
29307 +#define KEY__VIEW                                 0x00000001UL
29308 +#define KEY__READ                                 0x00000002UL
29309 +#define KEY__WRITE                                0x00000004UL
29310 +#define KEY__SEARCH                               0x00000008UL
29311 +#define KEY__LINK                                 0x00000010UL
29312 +#define KEY__SETATTR                              0x00000020UL
29313 +#define KEY__CREATE                               0x00000040UL
29314 +#define DCCP_SOCKET__IOCTL                        0x00000001UL
29315 +#define DCCP_SOCKET__READ                         0x00000002UL
29316 +#define DCCP_SOCKET__WRITE                        0x00000004UL
29317 +#define DCCP_SOCKET__CREATE                       0x00000008UL
29318 +#define DCCP_SOCKET__GETATTR                      0x00000010UL
29319 +#define DCCP_SOCKET__SETATTR                      0x00000020UL
29320 +#define DCCP_SOCKET__LOCK                         0x00000040UL
29321 +#define DCCP_SOCKET__RELABELFROM                  0x00000080UL
29322 +#define DCCP_SOCKET__RELABELTO                    0x00000100UL
29323 +#define DCCP_SOCKET__APPEND                       0x00000200UL
29324 +#define DCCP_SOCKET__BIND                         0x00000400UL
29325 +#define DCCP_SOCKET__CONNECT                      0x00000800UL
29326 +#define DCCP_SOCKET__LISTEN                       0x00001000UL
29327 +#define DCCP_SOCKET__ACCEPT                       0x00002000UL
29328 +#define DCCP_SOCKET__GETOPT                       0x00004000UL
29329 +#define DCCP_SOCKET__SETOPT                       0x00008000UL
29330 +#define DCCP_SOCKET__SHUTDOWN                     0x00010000UL
29331 +#define DCCP_SOCKET__RECVFROM                     0x00020000UL
29332 +#define DCCP_SOCKET__SENDTO                       0x00040000UL
29333 +#define DCCP_SOCKET__RECV_MSG                     0x00080000UL
29334 +#define DCCP_SOCKET__SEND_MSG                     0x00100000UL
29335 +#define DCCP_SOCKET__NAME_BIND                    0x00200000UL
29336 +#define DCCP_SOCKET__NODE_BIND                    0x00400000UL
29337 +#define DCCP_SOCKET__NAME_CONNECT                 0x00800000UL
29338 +#define MEMPROTECT__MMAP_ZERO                     0x00000001UL
29339 +#define PEER__RECV                                0x00000001UL
29340 +#define CAPABILITY2__MAC_OVERRIDE                 0x00000001UL
29341 +#define CAPABILITY2__MAC_ADMIN                    0x00000002UL
29342 +#define KERNEL_SERVICE__USE_AS_OVERRIDE           0x00000001UL
29343 +#define KERNEL_SERVICE__CREATE_FILES_AS           0x00000002UL
29344 +#define TUN_SOCKET__IOCTL                         0x00000001UL
29345 +#define TUN_SOCKET__READ                          0x00000002UL
29346 +#define TUN_SOCKET__WRITE                         0x00000004UL
29347 +#define TUN_SOCKET__CREATE                        0x00000008UL
29348 +#define TUN_SOCKET__GETATTR                       0x00000010UL
29349 +#define TUN_SOCKET__SETATTR                       0x00000020UL
29350 +#define TUN_SOCKET__LOCK                          0x00000040UL
29351 +#define TUN_SOCKET__RELABELFROM                   0x00000080UL
29352 +#define TUN_SOCKET__RELABELTO                     0x00000100UL
29353 +#define TUN_SOCKET__APPEND                        0x00000200UL
29354 +#define TUN_SOCKET__BIND                          0x00000400UL
29355 +#define TUN_SOCKET__CONNECT                       0x00000800UL
29356 +#define TUN_SOCKET__LISTEN                        0x00001000UL
29357 +#define TUN_SOCKET__ACCEPT                        0x00002000UL
29358 +#define TUN_SOCKET__GETOPT                        0x00004000UL
29359 +#define TUN_SOCKET__SETOPT                        0x00008000UL
29360 +#define TUN_SOCKET__SHUTDOWN                      0x00010000UL
29361 +#define TUN_SOCKET__RECVFROM                      0x00020000UL
29362 +#define TUN_SOCKET__SENDTO                        0x00040000UL
29363 +#define TUN_SOCKET__RECV_MSG                      0x00080000UL
29364 +#define TUN_SOCKET__SEND_MSG                      0x00100000UL
29365 +#define TUN_SOCKET__NAME_BIND                     0x00200000UL
29366 +
29367 +#endif
29368 diff -NurpP --minimal linux-2.6.35/security/selinux/hooks.c linux-2.6.35-vs2.3.0.36.31/security/selinux/hooks.c
29369 --- linux-2.6.35/security/selinux/hooks.c       2010-08-02 16:53:03.000000000 +0200
29370 +++ linux-2.6.35-vs2.3.0.36.31/security/selinux/hooks.c 2010-08-02 17:05:06.000000000 +0200
29371 @@ -64,7 +64,6 @@
29372  #include <linux/dccp.h>
29373  #include <linux/quota.h>
29374  #include <linux/un.h>          /* for Unix socket types */
29375 -#include <net/af_unix.h>       /* for Unix socket types */
29376  #include <linux/parser.h>
29377  #include <linux/nfs_mount.h>
29378  #include <net/ipv6.h>
This page took 2.357764 seconds and 3 git commands to generate.