]> git.pld-linux.org Git - packages/kernel.git/blob - kernel-vserver-2.3.patch
- http://vserver.13thfloor.at/Experimental/patch-2.6.35.2-vs2.3.0.36.31.diff
[packages/kernel.git] / kernel-vserver-2.3.patch
1 diff -NurpP --minimal linux-2.6.35.2/arch/alpha/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/alpha/Kconfig
2 --- linux-2.6.35.2/arch/alpha/Kconfig   2010-08-02 16:51:53.000000000 +0200
3 +++ linux-2.6.35.2-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.2/arch/alpha/kernel/entry.S linux-2.6.35.2-vs2.3.0.36.31/arch/alpha/kernel/entry.S
14 --- linux-2.6.35.2/arch/alpha/kernel/entry.S    2009-06-11 17:11:46.000000000 +0200
15 +++ linux-2.6.35.2-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.2/arch/alpha/kernel/osf_sys.c linux-2.6.35.2-vs2.3.0.36.31/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.35.2/arch/alpha/kernel/osf_sys.c  2010-07-07 18:30:51.000000000 +0200
50 +++ linux-2.6.35.2-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.2/arch/alpha/kernel/ptrace.c linux-2.6.35.2-vs2.3.0.36.31/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.35.2/arch/alpha/kernel/ptrace.c   2010-07-07 18:30:51.000000000 +0200
62 +++ linux-2.6.35.2-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.2/arch/alpha/kernel/systbls.S linux-2.6.35.2-vs2.3.0.36.31/arch/alpha/kernel/systbls.S
72 --- linux-2.6.35.2/arch/alpha/kernel/systbls.S  2010-02-25 11:51:19.000000000 +0100
73 +++ linux-2.6.35.2-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.2/arch/alpha/kernel/traps.c linux-2.6.35.2-vs2.3.0.36.31/arch/alpha/kernel/traps.c
84 --- linux-2.6.35.2/arch/alpha/kernel/traps.c    2010-07-07 18:30:51.000000000 +0200
85 +++ linux-2.6.35.2-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.2/arch/arm/include/asm/tlb.h linux-2.6.35.2-vs2.3.0.36.31/arch/arm/include/asm/tlb.h
97 --- linux-2.6.35.2/arch/arm/include/asm/tlb.h   2009-09-10 15:25:15.000000000 +0200
98 +++ linux-2.6.35.2-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.2/arch/arm/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/arm/Kconfig
108 --- linux-2.6.35.2/arch/arm/Kconfig     2010-08-14 18:16:58.000000000 +0200
109 +++ linux-2.6.35.2-vs2.3.0.36.31/arch/arm/Kconfig       2010-08-14 18:19:32.000000000 +0200
110 @@ -1685,6 +1685,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.2/arch/arm/kernel/calls.S linux-2.6.35.2-vs2.3.0.36.31/arch/arm/kernel/calls.S
120 --- linux-2.6.35.2/arch/arm/kernel/calls.S      2010-07-07 18:30:52.000000000 +0200
121 +++ linux-2.6.35.2-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.2/arch/arm/kernel/process.c linux-2.6.35.2-vs2.3.0.36.31/arch/arm/kernel/process.c
132 --- linux-2.6.35.2/arch/arm/kernel/process.c    2010-08-02 16:51:55.000000000 +0200
133 +++ linux-2.6.35.2-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.2/arch/arm/kernel/traps.c linux-2.6.35.2-vs2.3.0.36.31/arch/arm/kernel/traps.c
145 --- linux-2.6.35.2/arch/arm/kernel/traps.c      2010-07-07 18:30:52.000000000 +0200
146 +++ linux-2.6.35.2-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.2/arch/avr32/mm/fault.c linux-2.6.35.2-vs2.3.0.36.31/arch/avr32/mm/fault.c
159 --- linux-2.6.35.2/arch/avr32/mm/fault.c        2009-09-10 15:25:20.000000000 +0200
160 +++ linux-2.6.35.2-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.2/arch/cris/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/cris/Kconfig
172 --- linux-2.6.35.2/arch/cris/Kconfig    2010-08-02 16:52:03.000000000 +0200
173 +++ linux-2.6.35.2-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.2/arch/cris/mm/fault.c linux-2.6.35.2-vs2.3.0.36.31/arch/cris/mm/fault.c
184 --- linux-2.6.35.2/arch/cris/mm/fault.c 2010-02-25 11:51:26.000000000 +0100
185 +++ linux-2.6.35.2-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.2/arch/frv/kernel/kernel_thread.S linux-2.6.35.2-vs2.3.0.36.31/arch/frv/kernel/kernel_thread.S
197 --- linux-2.6.35.2/arch/frv/kernel/kernel_thread.S      2008-12-25 00:26:37.000000000 +0100
198 +++ linux-2.6.35.2-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.2/arch/h8300/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/h8300/Kconfig
209 --- linux-2.6.35.2/arch/h8300/Kconfig   2010-02-25 11:51:26.000000000 +0100
210 +++ linux-2.6.35.2-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.2/arch/ia64/include/asm/tlb.h linux-2.6.35.2-vs2.3.0.36.31/arch/ia64/include/asm/tlb.h
221 --- linux-2.6.35.2/arch/ia64/include/asm/tlb.h  2010-02-25 11:51:26.000000000 +0100
222 +++ linux-2.6.35.2-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.2/arch/ia64/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/ia64/Kconfig
232 --- linux-2.6.35.2/arch/ia64/Kconfig    2010-08-02 16:52:03.000000000 +0200
233 +++ linux-2.6.35.2-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.2/arch/ia64/kernel/entry.S linux-2.6.35.2-vs2.3.0.36.31/arch/ia64/kernel/entry.S
244 --- linux-2.6.35.2/arch/ia64/kernel/entry.S     2010-07-07 18:31:01.000000000 +0200
245 +++ linux-2.6.35.2-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.2/arch/ia64/kernel/perfmon.c linux-2.6.35.2-vs2.3.0.36.31/arch/ia64/kernel/perfmon.c
256 --- linux-2.6.35.2/arch/ia64/kernel/perfmon.c   2010-07-07 18:31:01.000000000 +0200
257 +++ linux-2.6.35.2-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.2/arch/ia64/kernel/process.c linux-2.6.35.2-vs2.3.0.36.31/arch/ia64/kernel/process.c
267 --- linux-2.6.35.2/arch/ia64/kernel/process.c   2010-07-07 18:31:01.000000000 +0200
268 +++ linux-2.6.35.2-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.2/arch/ia64/kernel/ptrace.c linux-2.6.35.2-vs2.3.0.36.31/arch/ia64/kernel/ptrace.c
281 --- linux-2.6.35.2/arch/ia64/kernel/ptrace.c    2010-08-02 16:52:04.000000000 +0200
282 +++ linux-2.6.35.2-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.2/arch/ia64/kernel/traps.c linux-2.6.35.2-vs2.3.0.36.31/arch/ia64/kernel/traps.c
292 --- linux-2.6.35.2/arch/ia64/kernel/traps.c     2010-07-07 18:31:01.000000000 +0200
293 +++ linux-2.6.35.2-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.2/arch/ia64/mm/fault.c linux-2.6.35.2-vs2.3.0.36.31/arch/ia64/mm/fault.c
319 --- linux-2.6.35.2/arch/ia64/mm/fault.c 2010-08-02 16:52:04.000000000 +0200
320 +++ linux-2.6.35.2-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.2/arch/m32r/kernel/traps.c linux-2.6.35.2-vs2.3.0.36.31/arch/m32r/kernel/traps.c
330 --- linux-2.6.35.2/arch/m32r/kernel/traps.c     2009-12-03 20:01:57.000000000 +0100
331 +++ linux-2.6.35.2-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.2/arch/m68k/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/m68k/Kconfig
345 --- linux-2.6.35.2/arch/m68k/Kconfig    2010-08-02 16:52:04.000000000 +0200
346 +++ linux-2.6.35.2-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.2/arch/m68k/kernel/ptrace.c linux-2.6.35.2-vs2.3.0.36.31/arch/m68k/kernel/ptrace.c
357 --- linux-2.6.35.2/arch/m68k/kernel/ptrace.c    2010-07-07 18:31:02.000000000 +0200
358 +++ linux-2.6.35.2-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.2/arch/m68k/kernel/traps.c linux-2.6.35.2-vs2.3.0.36.31/arch/m68k/kernel/traps.c
377 --- linux-2.6.35.2/arch/m68k/kernel/traps.c     2010-08-02 16:52:04.000000000 +0200
378 +++ linux-2.6.35.2-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.2/arch/m68knommu/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/m68knommu/Kconfig
391 --- linux-2.6.35.2/arch/m68knommu/Kconfig       2010-08-02 16:52:04.000000000 +0200
392 +++ linux-2.6.35.2-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.2/arch/m68knommu/kernel/traps.c linux-2.6.35.2-vs2.3.0.36.31/arch/m68knommu/kernel/traps.c
403 --- linux-2.6.35.2/arch/m68knommu/kernel/traps.c        2009-09-10 15:25:23.000000000 +0200
404 +++ linux-2.6.35.2-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.2/arch/mips/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/mips/Kconfig
418 --- linux-2.6.35.2/arch/mips/Kconfig    2010-08-02 16:52:05.000000000 +0200
419 +++ linux-2.6.35.2-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.2/arch/mips/kernel/ptrace.c linux-2.6.35.2-vs2.3.0.36.31/arch/mips/kernel/ptrace.c
430 --- linux-2.6.35.2/arch/mips/kernel/ptrace.c    2010-07-07 18:31:04.000000000 +0200
431 +++ linux-2.6.35.2-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.2/arch/mips/kernel/scall32-o32.S linux-2.6.35.2-vs2.3.0.36.31/arch/mips/kernel/scall32-o32.S
451 --- linux-2.6.35.2/arch/mips/kernel/scall32-o32.S       2010-02-25 11:51:28.000000000 +0100
452 +++ linux-2.6.35.2-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.2/arch/mips/kernel/scall64-64.S linux-2.6.35.2-vs2.3.0.36.31/arch/mips/kernel/scall64-64.S
463 --- linux-2.6.35.2/arch/mips/kernel/scall64-64.S        2010-02-25 11:51:28.000000000 +0100
464 +++ linux-2.6.35.2-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.2/arch/mips/kernel/scall64-n32.S linux-2.6.35.2-vs2.3.0.36.31/arch/mips/kernel/scall64-n32.S
475 --- linux-2.6.35.2/arch/mips/kernel/scall64-n32.S       2010-08-02 16:52:05.000000000 +0200
476 +++ linux-2.6.35.2-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.2/arch/mips/kernel/scall64-o32.S linux-2.6.35.2-vs2.3.0.36.31/arch/mips/kernel/scall64-o32.S
487 --- linux-2.6.35.2/arch/mips/kernel/scall64-o32.S       2010-07-07 18:31:04.000000000 +0200
488 +++ linux-2.6.35.2-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.2/arch/mips/kernel/traps.c linux-2.6.35.2-vs2.3.0.36.31/arch/mips/kernel/traps.c
499 --- linux-2.6.35.2/arch/mips/kernel/traps.c     2010-08-02 16:52:05.000000000 +0200
500 +++ linux-2.6.35.2-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.2/arch/parisc/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/parisc/Kconfig
516 --- linux-2.6.35.2/arch/parisc/Kconfig  2010-08-02 16:52:06.000000000 +0200
517 +++ linux-2.6.35.2-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.2/arch/parisc/kernel/syscall_table.S linux-2.6.35.2-vs2.3.0.36.31/arch/parisc/kernel/syscall_table.S
528 --- linux-2.6.35.2/arch/parisc/kernel/syscall_table.S   2010-07-07 18:31:04.000000000 +0200
529 +++ linux-2.6.35.2-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.2/arch/parisc/kernel/traps.c linux-2.6.35.2-vs2.3.0.36.31/arch/parisc/kernel/traps.c
540 --- linux-2.6.35.2/arch/parisc/kernel/traps.c   2009-09-10 15:25:40.000000000 +0200
541 +++ linux-2.6.35.2-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.2/arch/parisc/mm/fault.c linux-2.6.35.2-vs2.3.0.36.31/arch/parisc/mm/fault.c
566 --- linux-2.6.35.2/arch/parisc/mm/fault.c       2010-08-02 16:52:06.000000000 +0200
567 +++ linux-2.6.35.2-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.2/arch/powerpc/include/asm/unistd.h linux-2.6.35.2-vs2.3.0.36.31/arch/powerpc/include/asm/unistd.h
581 --- linux-2.6.35.2/arch/powerpc/include/asm/unistd.h    2010-07-07 18:31:05.000000000 +0200
582 +++ linux-2.6.35.2-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.2/arch/powerpc/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/powerpc/Kconfig
593 --- linux-2.6.35.2/arch/powerpc/Kconfig 2010-08-02 16:52:06.000000000 +0200
594 +++ linux-2.6.35.2-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.2/arch/powerpc/kernel/process.c linux-2.6.35.2-vs2.3.0.36.31/arch/powerpc/kernel/process.c
605 --- linux-2.6.35.2/arch/powerpc/kernel/process.c        2010-08-02 16:52:07.000000000 +0200
606 +++ linux-2.6.35.2-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.2/arch/powerpc/kernel/traps.c linux-2.6.35.2-vs2.3.0.36.31/arch/powerpc/kernel/traps.c
620 --- linux-2.6.35.2/arch/powerpc/kernel/traps.c  2010-08-02 16:52:07.000000000 +0200
621 +++ linux-2.6.35.2-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.2/arch/powerpc/kernel/vdso.c linux-2.6.35.2-vs2.3.0.36.31/arch/powerpc/kernel/vdso.c
635 --- linux-2.6.35.2/arch/powerpc/kernel/vdso.c   2010-08-02 16:52:07.000000000 +0200
636 +++ linux-2.6.35.2-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.2/arch/s390/include/asm/tlb.h linux-2.6.35.2-vs2.3.0.36.31/arch/s390/include/asm/tlb.h
646 --- linux-2.6.35.2/arch/s390/include/asm/tlb.h  2009-09-10 15:25:43.000000000 +0200
647 +++ linux-2.6.35.2-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.2/arch/s390/include/asm/unistd.h linux-2.6.35.2-vs2.3.0.36.31/arch/s390/include/asm/unistd.h
658 --- linux-2.6.35.2/arch/s390/include/asm/unistd.h       2010-07-07 18:31:06.000000000 +0200
659 +++ linux-2.6.35.2-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.2/arch/s390/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/s390/Kconfig
670 --- linux-2.6.35.2/arch/s390/Kconfig    2010-08-02 16:52:08.000000000 +0200
671 +++ linux-2.6.35.2-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.2/arch/s390/kernel/ptrace.c linux-2.6.35.2-vs2.3.0.36.31/arch/s390/kernel/ptrace.c
682 --- linux-2.6.35.2/arch/s390/kernel/ptrace.c    2010-08-02 16:52:09.000000000 +0200
683 +++ linux-2.6.35.2-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.2/arch/s390/kernel/syscalls.S linux-2.6.35.2-vs2.3.0.36.31/arch/s390/kernel/syscalls.S
693 --- linux-2.6.35.2/arch/s390/kernel/syscalls.S  2010-07-07 18:31:07.000000000 +0200
694 +++ linux-2.6.35.2-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.2/arch/sh/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/sh/Kconfig
705 --- linux-2.6.35.2/arch/sh/Kconfig      2010-08-02 16:52:09.000000000 +0200
706 +++ linux-2.6.35.2-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.2/arch/sh/kernel/irq.c linux-2.6.35.2-vs2.3.0.36.31/arch/sh/kernel/irq.c
717 --- linux-2.6.35.2/arch/sh/kernel/irq.c 2010-08-02 16:52:10.000000000 +0200
718 +++ linux-2.6.35.2-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.2/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.35.2-vs2.3.0.36.31/arch/sh/kernel/vsyscall/vsyscall.c
728 --- linux-2.6.35.2/arch/sh/kernel/vsyscall/vsyscall.c   2010-07-07 18:31:10.000000000 +0200
729 +++ linux-2.6.35.2-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.2/arch/sparc/include/asm/tlb_64.h linux-2.6.35.2-vs2.3.0.36.31/arch/sparc/include/asm/tlb_64.h
739 --- linux-2.6.35.2/arch/sparc/include/asm/tlb_64.h      2009-09-10 15:25:45.000000000 +0200
740 +++ linux-2.6.35.2-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.2/arch/sparc/include/asm/unistd.h linux-2.6.35.2-vs2.3.0.36.31/arch/sparc/include/asm/unistd.h
750 --- linux-2.6.35.2/arch/sparc/include/asm/unistd.h      2010-07-07 18:31:10.000000000 +0200
751 +++ linux-2.6.35.2-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.2/arch/sparc/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/sparc/Kconfig
762 --- linux-2.6.35.2/arch/sparc/Kconfig   2010-08-02 16:52:10.000000000 +0200
763 +++ linux-2.6.35.2-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.2/arch/sparc/kernel/systbls_32.S linux-2.6.35.2-vs2.3.0.36.31/arch/sparc/kernel/systbls_32.S
774 --- linux-2.6.35.2/arch/sparc/kernel/systbls_32.S       2010-02-25 11:51:34.000000000 +0100
775 +++ linux-2.6.35.2-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.2/arch/sparc/kernel/systbls_64.S linux-2.6.35.2-vs2.3.0.36.31/arch/sparc/kernel/systbls_64.S
786 --- linux-2.6.35.2/arch/sparc/kernel/systbls_64.S       2010-07-07 18:31:10.000000000 +0200
787 +++ linux-2.6.35.2-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.2/arch/um/include/asm/tlb.h linux-2.6.35.2-vs2.3.0.36.31/arch/um/include/asm/tlb.h
807 --- linux-2.6.35.2/arch/um/include/asm/tlb.h    2009-09-10 15:25:46.000000000 +0200
808 +++ linux-2.6.35.2-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.2/arch/um/include/shared/kern_constants.h linux-2.6.35.2-vs2.3.0.36.31/arch/um/include/shared/kern_constants.h
818 --- linux-2.6.35.2/arch/um/include/shared/kern_constants.h      1970-01-01 01:00:00.000000000 +0100
819 +++ linux-2.6.35.2-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.2/arch/um/include/shared/user_constants.h linux-2.6.35.2-vs2.3.0.36.31/arch/um/include/shared/user_constants.h
823 --- linux-2.6.35.2/arch/um/include/shared/user_constants.h      1970-01-01 01:00:00.000000000 +0100
824 +++ linux-2.6.35.2-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.2/arch/um/Kconfig.rest linux-2.6.35.2-vs2.3.0.36.31/arch/um/Kconfig.rest
867 --- linux-2.6.35.2/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
868 +++ linux-2.6.35.2-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.2/arch/um/kernel/config.c linux-2.6.35.2-vs2.3.0.36.31/arch/um/kernel/config.c
879 --- linux-2.6.35.2/arch/um/kernel/config.c      1970-01-01 01:00:00.000000000 +0100
880 +++ linux-2.6.35.2-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.2/arch/um/kernel/config.tmp linux-2.6.35.2-vs2.3.0.36.31/arch/um/kernel/config.tmp
1300 --- linux-2.6.35.2/arch/um/kernel/config.tmp    1970-01-01 01:00:00.000000000 +0100
1301 +++ linux-2.6.35.2-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.2/arch/um/kernel/vmlinux.lds linux-2.6.35.2-vs2.3.0.36.31/arch/um/kernel/vmlinux.lds
1694 --- linux-2.6.35.2/arch/um/kernel/vmlinux.lds   1970-01-01 01:00:00.000000000 +0100
1695 +++ linux-2.6.35.2-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.2/arch/x86/ia32/ia32entry.S linux-2.6.35.2-vs2.3.0.36.31/arch/x86/ia32/ia32entry.S
2245 --- linux-2.6.35.2/arch/x86/ia32/ia32entry.S    2010-07-07 18:31:11.000000000 +0200
2246 +++ linux-2.6.35.2-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.2/arch/x86/include/asm/unistd_64.h linux-2.6.35.2-vs2.3.0.36.31/arch/x86/include/asm/unistd_64.h
2257 --- linux-2.6.35.2/arch/x86/include/asm/unistd_64.h     2010-07-07 18:31:11.000000000 +0200
2258 +++ linux-2.6.35.2-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.2/arch/x86/Kconfig linux-2.6.35.2-vs2.3.0.36.31/arch/x86/Kconfig
2269 --- linux-2.6.35.2/arch/x86/Kconfig     2010-08-02 16:52:11.000000000 +0200
2270 +++ linux-2.6.35.2-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.2/arch/x86/kernel/syscall_table_32.S linux-2.6.35.2-vs2.3.0.36.31/arch/x86/kernel/syscall_table_32.S
2281 --- linux-2.6.35.2/arch/x86/kernel/syscall_table_32.S   2010-07-07 18:31:12.000000000 +0200
2282 +++ linux-2.6.35.2-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.2/Documentation/vserver/debug.txt linux-2.6.35.2-vs2.3.0.36.31/Documentation/vserver/debug.txt
2293 --- linux-2.6.35.2/Documentation/vserver/debug.txt      1970-01-01 01:00:00.000000000 +0100
2294 +++ linux-2.6.35.2-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.2/drivers/block/Kconfig linux-2.6.35.2-vs2.3.0.36.31/drivers/block/Kconfig
2451 --- linux-2.6.35.2/drivers/block/Kconfig        2010-08-02 16:52:14.000000000 +0200
2452 +++ linux-2.6.35.2-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.2/drivers/block/loop.c linux-2.6.35.2-vs2.3.0.36.31/drivers/block/loop.c
2468 --- linux-2.6.35.2/drivers/block/loop.c 2010-08-02 16:52:14.000000000 +0200
2469 +++ linux-2.6.35.2-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.2/drivers/block/Makefile linux-2.6.35.2-vs2.3.0.36.31/drivers/block/Makefile
2524 --- linux-2.6.35.2/drivers/block/Makefile       2010-02-25 11:51:36.000000000 +0100
2525 +++ linux-2.6.35.2-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.2/drivers/block/vroot.c linux-2.6.35.2-vs2.3.0.36.31/drivers/block/vroot.c
2535 --- linux-2.6.35.2/drivers/block/vroot.c        1970-01-01 01:00:00.000000000 +0100
2536 +++ linux-2.6.35.2-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.2/drivers/char/sysrq.c linux-2.6.35.2-vs2.3.0.36.31/drivers/char/sysrq.c
2821 --- linux-2.6.35.2/drivers/char/sysrq.c 2010-08-02 16:52:15.000000000 +0200
2822 +++ linux-2.6.35.2-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.2/drivers/char/tty_io.c linux-2.6.35.2-vs2.3.0.36.31/drivers/char/tty_io.c
2875 --- linux-2.6.35.2/drivers/char/tty_io.c        2010-07-07 18:31:15.000000000 +0200
2876 +++ linux-2.6.35.2-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.2/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.35.2-vs2.3.0.36.31/drivers/gpu/drm/radeon/r100_reg_safe.h
2904 --- linux-2.6.35.2/drivers/gpu/drm/radeon/r100_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
2905 +++ linux-2.6.35.2-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.2/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.35.2-vs2.3.0.36.31/drivers/gpu/drm/radeon/r200_reg_safe.h
2936 --- linux-2.6.35.2/drivers/gpu/drm/radeon/r200_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
2937 +++ linux-2.6.35.2-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.2/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.35.2-vs2.3.0.36.31/drivers/gpu/drm/radeon/r300_reg_safe.h
2968 --- linux-2.6.35.2/drivers/gpu/drm/radeon/r300_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
2969 +++ linux-2.6.35.2-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.2/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.35.2-vs2.3.0.36.31/drivers/gpu/drm/radeon/r420_reg_safe.h
3014 --- linux-2.6.35.2/drivers/gpu/drm/radeon/r420_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3015 +++ linux-2.6.35.2-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.2/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.35.2-vs2.3.0.36.31/drivers/gpu/drm/radeon/rn50_reg_safe.h
3060 --- linux-2.6.35.2/drivers/gpu/drm/radeon/rn50_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3061 +++ linux-2.6.35.2-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.2/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.35.2-vs2.3.0.36.31/drivers/gpu/drm/radeon/rs600_reg_safe.h
3092 --- linux-2.6.35.2/drivers/gpu/drm/radeon/rs600_reg_safe.h      1970-01-01 01:00:00.000000000 +0100
3093 +++ linux-2.6.35.2-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.2/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.35.2-vs2.3.0.36.31/drivers/gpu/drm/radeon/rv515_reg_safe.h
3153 --- linux-2.6.35.2/drivers/gpu/drm/radeon/rv515_reg_safe.h      1970-01-01 01:00:00.000000000 +0100
3154 +++ linux-2.6.35.2-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.2/drivers/infiniband/core/addr.c linux-2.6.35.2-vs2.3.0.36.31/drivers/infiniband/core/addr.c
3214 --- linux-2.6.35.2/drivers/infiniband/core/addr.c       2010-07-07 18:31:18.000000000 +0200
3215 +++ linux-2.6.35.2-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.2/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.35.2-vs2.3.0.36.31/drivers/infiniband/hw/ipath/ipath_user_pages.c
3226 --- linux-2.6.35.2/drivers/infiniband/hw/ipath/ipath_user_pages.c       2010-07-07 18:31:19.000000000 +0200
3227 +++ linux-2.6.35.2-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.2/drivers/md/dm.c linux-2.6.35.2-vs2.3.0.36.31/drivers/md/dm.c
3237 --- linux-2.6.35.2/drivers/md/dm.c      2010-07-07 18:31:21.000000000 +0200
3238 +++ linux-2.6.35.2-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.2/drivers/md/dm.h linux-2.6.35.2-vs2.3.0.36.31/drivers/md/dm.h
3313 --- linux-2.6.35.2/drivers/md/dm.h      2010-07-07 18:31:21.000000000 +0200
3314 +++ linux-2.6.35.2-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.2/drivers/md/dm-ioctl.c linux-2.6.35.2-vs2.3.0.36.31/drivers/md/dm-ioctl.c
3325 --- linux-2.6.35.2/drivers/md/dm-ioctl.c        2010-07-07 18:31:21.000000000 +0200
3326 +++ linux-2.6.35.2-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.2/drivers/net/tun.c linux-2.6.35.2-vs2.3.0.36.31/drivers/net/tun.c
3409 --- linux-2.6.35.2/drivers/net/tun.c    2010-08-02 16:52:27.000000000 +0200
3410 +++ linux-2.6.35.2-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.2/fs/attr.c linux-2.6.35.2-vs2.3.0.36.31/fs/attr.c
3481 --- linux-2.6.35.2/fs/attr.c    2010-08-02 16:52:47.000000000 +0200
3482 +++ linux-2.6.35.2-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.2/fs/binfmt_aout.c linux-2.6.35.2-vs2.3.0.36.31/fs/binfmt_aout.c
3524 --- linux-2.6.35.2/fs/binfmt_aout.c     2010-07-07 18:31:50.000000000 +0200
3525 +++ linux-2.6.35.2-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.2/fs/binfmt_elf.c linux-2.6.35.2-vs2.3.0.36.31/fs/binfmt_elf.c
3535 --- linux-2.6.35.2/fs/binfmt_elf.c      2010-07-07 18:31:50.000000000 +0200
3536 +++ linux-2.6.35.2-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.2/fs/binfmt_flat.c linux-2.6.35.2-vs2.3.0.36.31/fs/binfmt_flat.c
3546 --- linux-2.6.35.2/fs/binfmt_flat.c     2010-08-02 16:52:47.000000000 +0200
3547 +++ linux-2.6.35.2-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.2/fs/binfmt_som.c linux-2.6.35.2-vs2.3.0.36.31/fs/binfmt_som.c
3557 --- linux-2.6.35.2/fs/binfmt_som.c      2010-02-25 11:52:04.000000000 +0100
3558 +++ linux-2.6.35.2-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.2/fs/block_dev.c linux-2.6.35.2-vs2.3.0.36.31/fs/block_dev.c
3568 --- linux-2.6.35.2/fs/block_dev.c       2010-08-14 18:16:59.000000000 +0200
3569 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/block_dev.c 2010-08-14 18:19:32.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.2/fs/btrfs/ctree.h linux-2.6.35.2-vs2.3.0.36.31/fs/btrfs/ctree.h
3608 --- linux-2.6.35.2/fs/btrfs/ctree.h     2010-08-02 16:52:47.000000000 +0200
3609 +++ linux-2.6.35.2-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.2/fs/btrfs/disk-io.c linux-2.6.35.2-vs2.3.0.36.31/fs/btrfs/disk-io.c
3663 --- linux-2.6.35.2/fs/btrfs/disk-io.c   2010-08-02 16:52:47.000000000 +0200
3664 +++ linux-2.6.35.2-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.2/fs/btrfs/inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/btrfs/inode.c
3676 --- linux-2.6.35.2/fs/btrfs/inode.c     2010-08-02 16:52:47.000000000 +0200
3677 +++ linux-2.6.35.2-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.2/fs/btrfs/ioctl.c linux-2.6.35.2-vs2.3.0.36.31/fs/btrfs/ioctl.c
3747 --- linux-2.6.35.2/fs/btrfs/ioctl.c     2010-08-02 16:52:47.000000000 +0200
3748 +++ linux-2.6.35.2-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.2/fs/btrfs/super.c linux-2.6.35.2-vs2.3.0.36.31/fs/btrfs/super.c
3931 --- linux-2.6.35.2/fs/btrfs/super.c     2010-08-02 16:52:47.000000000 +0200
3932 +++ linux-2.6.35.2-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.2/fs/char_dev.c linux-2.6.35.2-vs2.3.0.36.31/fs/char_dev.c
3989 --- linux-2.6.35.2/fs/char_dev.c        2009-12-03 20:02:51.000000000 +0100
3990 +++ linux-2.6.35.2-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.2/fs/dcache.c linux-2.6.35.2-vs2.3.0.36.31/fs/dcache.c
4024 --- linux-2.6.35.2/fs/dcache.c  2010-08-02 16:52:48.000000000 +0200
4025 +++ linux-2.6.35.2-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.2/fs/devpts/inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/devpts/inode.c
4078 --- linux-2.6.35.2/fs/devpts/inode.c    2010-08-02 16:52:48.000000000 +0200
4079 +++ linux-2.6.35.2-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.2/fs/exec.c linux-2.6.35.2-vs2.3.0.36.31/fs/exec.c
4163 --- linux-2.6.35.2/fs/exec.c    2010-08-02 16:52:48.000000000 +0200
4164 +++ linux-2.6.35.2-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.2/fs/ext2/balloc.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext2/balloc.c
4175 --- linux-2.6.35.2/fs/ext2/balloc.c     2010-08-02 16:52:48.000000000 +0200
4176 +++ linux-2.6.35.2-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.2/fs/ext2/ext2.h linux-2.6.35.2-vs2.3.0.36.31/fs/ext2/ext2.h
4186 --- linux-2.6.35.2/fs/ext2/ext2.h       2010-08-02 16:52:48.000000000 +0200
4187 +++ linux-2.6.35.2-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.2/fs/ext2/file.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext2/file.c
4197 --- linux-2.6.35.2/fs/ext2/file.c       2010-08-02 16:52:48.000000000 +0200
4198 +++ linux-2.6.35.2-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.2/fs/ext2/ialloc.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext2/ialloc.c
4206 --- linux-2.6.35.2/fs/ext2/ialloc.c     2010-08-02 16:52:48.000000000 +0200
4207 +++ linux-2.6.35.2-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.2/fs/ext2/inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext2/inode.c
4225 --- linux-2.6.35.2/fs/ext2/inode.c      2010-08-02 16:52:48.000000000 +0200
4226 +++ linux-2.6.35.2-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.2/fs/ext2/ioctl.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext2/ioctl.c
4376 --- linux-2.6.35.2/fs/ext2/ioctl.c      2009-09-10 15:26:21.000000000 +0200
4377 +++ linux-2.6.35.2-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.2/fs/ext2/namei.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext2/namei.c
4428 --- linux-2.6.35.2/fs/ext2/namei.c      2010-07-07 18:31:51.000000000 +0200
4429 +++ linux-2.6.35.2-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.2/fs/ext2/super.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext2/super.c
4455 --- linux-2.6.35.2/fs/ext2/super.c      2010-08-02 16:52:48.000000000 +0200
4456 +++ linux-2.6.35.2-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.2/fs/ext3/file.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext3/file.c
4523 --- linux-2.6.35.2/fs/ext3/file.c       2010-07-07 18:31:51.000000000 +0200
4524 +++ linux-2.6.35.2-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.2/fs/ext3/ialloc.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext3/ialloc.c
4533 --- linux-2.6.35.2/fs/ext3/ialloc.c     2010-08-02 16:52:48.000000000 +0200
4534 +++ linux-2.6.35.2-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.2/fs/ext3/inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext3/inode.c
4552 --- linux-2.6.35.2/fs/ext3/inode.c      2010-08-02 16:52:48.000000000 +0200
4553 +++ linux-2.6.35.2-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.2/fs/ext3/ioctl.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext3/ioctl.c
4738 --- linux-2.6.35.2/fs/ext3/ioctl.c      2009-06-11 17:13:03.000000000 +0200
4739 +++ linux-2.6.35.2-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.2/fs/ext3/namei.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext3/namei.c
4816 --- linux-2.6.35.2/fs/ext3/namei.c      2010-07-07 18:31:51.000000000 +0200
4817 +++ linux-2.6.35.2-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.2/fs/ext3/super.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext3/super.c
4843 --- linux-2.6.35.2/fs/ext3/super.c      2010-08-02 16:52:48.000000000 +0200
4844 +++ linux-2.6.35.2-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.2/fs/ext4/ext4.h linux-2.6.35.2-vs2.3.0.36.31/fs/ext4/ext4.h
4912 --- linux-2.6.35.2/fs/ext4/ext4.h       2010-08-02 16:52:48.000000000 +0200
4913 +++ linux-2.6.35.2-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.2/fs/ext4/file.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext4/file.c
4962 --- linux-2.6.35.2/fs/ext4/file.c       2010-08-02 16:52:48.000000000 +0200
4963 +++ linux-2.6.35.2-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.2/fs/ext4/ialloc.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext4/ialloc.c
4972 --- linux-2.6.35.2/fs/ext4/ialloc.c     2010-08-02 16:52:48.000000000 +0200
4973 +++ linux-2.6.35.2-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.2/fs/ext4/inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext4/inode.c
4991 --- linux-2.6.35.2/fs/ext4/inode.c      2010-08-02 16:52:48.000000000 +0200
4992 +++ linux-2.6.35.2-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.2/fs/ext4/ioctl.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext4/ioctl.c
5180 --- linux-2.6.35.2/fs/ext4/ioctl.c      2010-08-02 16:52:48.000000000 +0200
5181 +++ linux-2.6.35.2-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.2/fs/ext4/namei.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext4/namei.c
5246 --- linux-2.6.35.2/fs/ext4/namei.c      2010-08-02 16:52:48.000000000 +0200
5247 +++ linux-2.6.35.2-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.2/fs/ext4/super.c linux-2.6.35.2-vs2.3.0.36.31/fs/ext4/super.c
5273 --- linux-2.6.35.2/fs/ext4/super.c      2010-08-14 18:16:59.000000000 +0200
5274 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ext4/super.c        2010-08-14 18:19:32.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.2/fs/fcntl.c linux-2.6.35.2-vs2.3.0.36.31/fs/fcntl.c
5340 --- linux-2.6.35.2/fs/fcntl.c   2010-08-02 16:52:49.000000000 +0200
5341 +++ linux-2.6.35.2-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.2/fs/file.c linux-2.6.35.2-vs2.3.0.36.31/fs/file.c
5369 --- linux-2.6.35.2/fs/file.c    2010-07-07 18:31:51.000000000 +0200
5370 +++ linux-2.6.35.2-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.2/fs/file_table.c linux-2.6.35.2-vs2.3.0.36.31/fs/file_table.c
5397 --- linux-2.6.35.2/fs/file_table.c      2010-08-02 16:52:49.000000000 +0200
5398 +++ linux-2.6.35.2-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.2/fs/fs_struct.c linux-2.6.35.2-vs2.3.0.36.31/fs/fs_struct.c
5436 --- linux-2.6.35.2/fs/fs_struct.c       2009-06-11 17:13:04.000000000 +0200
5437 +++ linux-2.6.35.2-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.2/fs/gfs2/file.c linux-2.6.35.2-vs2.3.0.36.31/fs/gfs2/file.c
5463 --- linux-2.6.35.2/fs/gfs2/file.c       2010-08-02 16:52:49.000000000 +0200
5464 +++ linux-2.6.35.2-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.2/fs/gfs2/inode.h linux-2.6.35.2-vs2.3.0.36.31/fs/gfs2/inode.h
5586 --- linux-2.6.35.2/fs/gfs2/inode.h      2010-08-02 16:52:49.000000000 +0200
5587 +++ linux-2.6.35.2-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.2/fs/gfs2/ops_inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/gfs2/ops_inode.c
5597 --- linux-2.6.35.2/fs/gfs2/ops_inode.c  2010-08-02 16:52:49.000000000 +0200
5598 +++ linux-2.6.35.2-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.2/fs/hfsplus/ioctl.c linux-2.6.35.2-vs2.3.0.36.31/fs/hfsplus/ioctl.c
5616 --- linux-2.6.35.2/fs/hfsplus/ioctl.c   2010-08-02 16:52:49.000000000 +0200
5617 +++ linux-2.6.35.2-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.2/fs/inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/inode.c
5627 --- linux-2.6.35.2/fs/inode.c   2010-08-02 16:52:49.000000000 +0200
5628 +++ linux-2.6.35.2-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.2/fs/ioctl.c linux-2.6.35.2-vs2.3.0.36.31/fs/ioctl.c
5684 --- linux-2.6.35.2/fs/ioctl.c   2010-08-02 16:52:49.000000000 +0200
5685 +++ linux-2.6.35.2-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.2/fs/ioprio.c linux-2.6.35.2-vs2.3.0.36.31/fs/ioprio.c
5697 --- linux-2.6.35.2/fs/ioprio.c  2010-07-07 18:31:52.000000000 +0200
5698 +++ linux-2.6.35.2-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.2/fs/jfs/file.c linux-2.6.35.2-vs2.3.0.36.31/fs/jfs/file.c
5726 --- linux-2.6.35.2/fs/jfs/file.c        2010-08-02 16:52:49.000000000 +0200
5727 +++ linux-2.6.35.2-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.2/fs/jfs/ioctl.c linux-2.6.35.2-vs2.3.0.36.31/fs/jfs/ioctl.c
5747 --- linux-2.6.35.2/fs/jfs/ioctl.c       2008-12-25 00:26:37.000000000 +0100
5748 +++ linux-2.6.35.2-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.2/fs/jfs/jfs_dinode.h linux-2.6.35.2-vs2.3.0.36.31/fs/jfs/jfs_dinode.h
5807 --- linux-2.6.35.2/fs/jfs/jfs_dinode.h  2008-12-25 00:26:37.000000000 +0100
5808 +++ linux-2.6.35.2-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.2/fs/jfs/jfs_filsys.h linux-2.6.35.2-vs2.3.0.36.31/fs/jfs/jfs_filsys.h
5826 --- linux-2.6.35.2/fs/jfs/jfs_filsys.h  2008-12-25 00:26:37.000000000 +0100
5827 +++ linux-2.6.35.2-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.2/fs/jfs/jfs_imap.c linux-2.6.35.2-vs2.3.0.36.31/fs/jfs/jfs_imap.c
5837 --- linux-2.6.35.2/fs/jfs/jfs_imap.c    2010-07-07 18:31:52.000000000 +0200
5838 +++ linux-2.6.35.2-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.2/fs/jfs/jfs_inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/jfs/jfs_inode.c
5899 --- linux-2.6.35.2/fs/jfs/jfs_inode.c   2010-08-02 16:52:49.000000000 +0200
5900 +++ linux-2.6.35.2-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.2/fs/jfs/jfs_inode.h linux-2.6.35.2-vs2.3.0.36.31/fs/jfs/jfs_inode.h
5975 --- linux-2.6.35.2/fs/jfs/jfs_inode.h   2010-08-02 16:52:49.000000000 +0200
5976 +++ linux-2.6.35.2-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.2/fs/jfs/namei.c linux-2.6.35.2-vs2.3.0.36.31/fs/jfs/namei.c
5986 --- linux-2.6.35.2/fs/jfs/namei.c       2010-07-07 18:31:52.000000000 +0200
5987 +++ linux-2.6.35.2-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.2/fs/jfs/super.c linux-2.6.35.2-vs2.3.0.36.31/fs/jfs/super.c
6013 --- linux-2.6.35.2/fs/jfs/super.c       2010-08-02 16:52:49.000000000 +0200
6014 +++ linux-2.6.35.2-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.2/fs/libfs.c linux-2.6.35.2-vs2.3.0.36.31/fs/libfs.c
6081 --- linux-2.6.35.2/fs/libfs.c   2010-08-02 16:52:49.000000000 +0200
6082 +++ linux-2.6.35.2-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.2/fs/locks.c linux-2.6.35.2-vs2.3.0.36.31/fs/locks.c
6130 --- linux-2.6.35.2/fs/locks.c   2010-07-07 18:31:52.000000000 +0200
6131 +++ linux-2.6.35.2-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.2/fs/namei.c linux-2.6.35.2-vs2.3.0.36.31/fs/namei.c
6318 --- linux-2.6.35.2/fs/namei.c   2010-08-02 16:52:50.000000000 +0200
6319 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/namei.c     2010-08-14 17:03:20.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,14 @@ int may_open(struct path *path, int acc_
6495                 break;
6496         }
6497  
6498 +#ifdef CONFIG_VSERVER_COWBL
6499 +       if (IS_COW(inode) && (flag & FMODE_WRITE)) {
6500 +               if (IS_COW_LINK(inode))
6501 +                       return -EMLINK;
6502 +               inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
6503 +               mark_inode_dirty(inode);
6504 +       }
6505 +#endif
6506         error = inode_permission(inode, acc_mode);
6507         if (error)
6508                 return error;
6509 @@ -1558,7 +1667,8 @@ static int open_will_truncate(int flag, 
6510  }
6511  
6512  static struct file *finish_open(struct nameidata *nd,
6513 -                               int open_flag, int acc_mode)
6514 +                               int open_flag, int acc_mode,
6515 +                               const char *pathname)
6516  {
6517         struct file *filp;
6518         int will_truncate;
6519 @@ -1571,6 +1681,23 @@ static struct file *finish_open(struct n
6520                         goto exit;
6521         }
6522         error = may_open(&nd->path, acc_mode, open_flag);
6523 +#ifdef CONFIG_VSERVER_COWBL
6524 +       if (error == -EMLINK) {
6525 +               struct dentry *dentry;
6526 +               dentry = cow_break_link(pathname);
6527 +               if (IS_ERR(dentry)) {
6528 +                       error = PTR_ERR(dentry);
6529 +                       goto exit_cow;
6530 +               }
6531 +               dput(dentry);
6532 +               if (will_truncate)
6533 +                       mnt_drop_write(nd->path.mnt);
6534 +               release_open_intent(nd);
6535 +               path_put(&nd->path);
6536 +               return ERR_PTR(-EMLINK);
6537 +       }
6538 +exit_cow:
6539 +#endif
6540         if (error) {
6541                 if (will_truncate)
6542                         mnt_drop_write(nd->path.mnt);
6543 @@ -1739,7 +1866,7 @@ static struct file *do_last(struct namei
6544         if (S_ISDIR(path->dentry->d_inode->i_mode))
6545                 goto exit;
6546  ok:
6547 -       filp = finish_open(nd, open_flag, acc_mode);
6548 +       filp = finish_open(nd, open_flag, acc_mode, pathname);
6549         return filp;
6550  
6551  exit_mutex_unlock:
6552 @@ -1768,7 +1895,11 @@ struct file *do_filp_open(int dfd, const
6553         int count = 0;
6554         int flag = open_to_namei_flags(open_flag);
6555         int force_reval = 0;
6556 -
6557 +#ifdef CONFIG_VSERVER_COWBL
6558 +       int rflag = flag;
6559 +       int rmode = mode;
6560 +restart:
6561 +#endif
6562         if (!(open_flag & O_CREAT))
6563                 mode = 0;
6564  
6565 @@ -1834,6 +1965,13 @@ reval:
6566         if (!(open_flag & O_NOFOLLOW))
6567                 nd.flags |= LOOKUP_FOLLOW;
6568         filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
6569 +#ifdef CONFIG_VSERVER_COWBL
6570 +       if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
6571 +               flag = rflag;
6572 +               mode = rmode;
6573 +               goto restart;
6574 +       }
6575 +#endif
6576         while (unlikely(!filp)) { /* trailing symlink */
6577                 struct path holder;
6578                 struct inode *inode = path.dentry->d_inode;
6579 @@ -1872,6 +2010,13 @@ reval:
6580                 holder = path;
6581                 nd.flags &= ~LOOKUP_PARENT;
6582                 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
6583 +#ifdef CONFIG_VSERVER_COWBL
6584 +               if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
6585 +                       flag = rflag;
6586 +                       mode = rmode;
6587 +                       goto restart;
6588 +               }
6589 +#endif
6590                 if (inode->i_op->put_link)
6591                         inode->i_op->put_link(holder.dentry, &nd, cookie);
6592                 path_put(&holder);
6593 @@ -1972,9 +2117,17 @@ int vfs_mknod(struct inode *dir, struct 
6594         if (error)
6595                 return error;
6596  
6597 -       if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
6598 +       if (!(S_ISCHR(mode) || S_ISBLK(mode)))
6599 +               goto okay;
6600 +
6601 +       if (!capable(CAP_MKNOD))
6602                 return -EPERM;
6603  
6604 +       if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
6605 +               return -EPERM;
6606 +       if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
6607 +               return -EPERM;
6608 +okay:
6609         if (!dir->i_op->mknod)
6610                 return -EPERM;
6611  
6612 @@ -2439,7 +2592,7 @@ int vfs_link(struct dentry *old_dentry, 
6613         /*
6614          * A link to an append-only or immutable file cannot be created.
6615          */
6616 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6617 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6618                 return -EPERM;
6619         if (!dir->i_op->link)
6620                 return -EPERM;
6621 @@ -2811,6 +2964,219 @@ int vfs_follow_link(struct nameidata *nd
6622         return __vfs_follow_link(nd, link);
6623  }
6624  
6625 +
6626 +#ifdef CONFIG_VSERVER_COWBL
6627 +
6628 +#include <linux/file.h>
6629 +
6630 +static inline
6631 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6632 +{
6633 +       loff_t ppos = 0;
6634 +
6635 +       return do_splice_direct(in, &ppos, out, len, 0);
6636 +}
6637 +
6638 +struct dentry *cow_break_link(const char *pathname)
6639 +{
6640 +       int ret, mode, pathlen, redo = 0;
6641 +       struct nameidata old_nd, dir_nd;
6642 +       struct path old_path, new_path;
6643 +       struct dentry *dir, *res = NULL;
6644 +       struct file *old_file;
6645 +       struct file *new_file;
6646 +       char *to, *path, pad='\251';
6647 +       loff_t size;
6648 +
6649 +       vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6650 +       path = kmalloc(PATH_MAX, GFP_KERNEL);
6651 +       ret = -ENOMEM;
6652 +       if (!path)
6653 +               goto out;
6654 +
6655 +       /* old_nd will have refs to dentry and mnt */
6656 +       ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6657 +       vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6658 +       if (ret < 0)
6659 +               goto out_free_path;
6660 +
6661 +       old_path = old_nd.path;
6662 +       mode = old_path.dentry->d_inode->i_mode;
6663 +
6664 +       to = d_path(&old_path, path, PATH_MAX-2);
6665 +       pathlen = strlen(to);
6666 +       vxdprintk(VXD_CBIT(misc, 2), "old path Â»%s« [»%.*s«:%d]", to,
6667 +               old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6668 +               old_path.dentry->d_name.len);
6669 +
6670 +       to[pathlen + 1] = 0;
6671 +retry:
6672 +       to[pathlen] = pad--;
6673 +       ret = -EMLINK;
6674 +       if (pad <= '\240')
6675 +               goto out_rel_old;
6676 +
6677 +       vxdprintk(VXD_CBIT(misc, 1), "temp copy Â»%s«", to);
6678 +       /* dir_nd will have refs to dentry and mnt */
6679 +       ret = path_lookup(to,
6680 +               LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6681 +       vxdprintk(VXD_CBIT(misc, 2),
6682 +               "path_lookup(new): %d", ret);
6683 +       if (ret < 0)
6684 +               goto retry;
6685 +
6686 +       /* this puppy downs the inode mutex */
6687 +       new_path.dentry = lookup_create(&dir_nd, 0);
6688 +       if (!new_path.dentry || IS_ERR(new_path.dentry)) {
6689 +               vxdprintk(VXD_CBIT(misc, 2),
6690 +                       "lookup_create(new): %p", new_path.dentry);
6691 +               mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
6692 +               path_put(&dir_nd.path);
6693 +               goto retry;
6694 +       }
6695 +       vxdprintk(VXD_CBIT(misc, 2),
6696 +               "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
6697 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6698 +               new_path.dentry->d_name.len);
6699 +       dir = dir_nd.path.dentry;
6700 +
6701 +       ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
6702 +       vxdprintk(VXD_CBIT(misc, 2),
6703 +               "vfs_create(new): %d", ret);
6704 +       if (ret == -EEXIST) {
6705 +               mutex_unlock(&dir->d_inode->i_mutex);
6706 +               dput(new_path.dentry);
6707 +               path_put(&dir_nd.path);
6708 +               goto retry;
6709 +       }
6710 +       else if (ret < 0)
6711 +               goto out_unlock_new;
6712 +
6713 +       /* drop out early, ret passes ENOENT */
6714 +       ret = -ENOENT;
6715 +       if ((redo = d_unhashed(old_path.dentry)))
6716 +               goto out_unlock_new;
6717 +
6718 +       new_path.mnt = dir_nd.path.mnt;
6719 +       dget(old_path.dentry);
6720 +       mntget(old_path.mnt);
6721 +       /* this one cleans up the dentry/mnt in case of failure */
6722 +       old_file = dentry_open(old_path.dentry, old_path.mnt,
6723 +               O_RDONLY, current_cred());
6724 +       vxdprintk(VXD_CBIT(misc, 2),
6725 +               "dentry_open(old): %p", old_file);
6726 +       if (!old_file || IS_ERR(old_file)) {
6727 +               res = IS_ERR(old_file) ? (void *) old_file : res;
6728 +               goto out_unlock_new;
6729 +       }
6730 +
6731 +       dget(new_path.dentry);
6732 +       mntget(new_path.mnt);
6733 +       /* this one cleans up the dentry/mnt in case of failure */
6734 +       new_file = dentry_open(new_path.dentry, new_path.mnt,
6735 +               O_WRONLY, current_cred());
6736 +       vxdprintk(VXD_CBIT(misc, 2),
6737 +               "dentry_open(new): %p", new_file);
6738 +
6739 +       ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
6740 +       if (!new_file || IS_ERR(new_file))
6741 +               goto out_fput_old;
6742 +
6743 +       size = i_size_read(old_file->f_dentry->d_inode);
6744 +       ret = do_cow_splice(old_file, new_file, size);
6745 +       vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
6746 +       if (ret < 0) {
6747 +               goto out_fput_both;
6748 +       } else if (ret < size) {
6749 +               ret = -ENOSPC;
6750 +               goto out_fput_both;
6751 +       } else {
6752 +               struct inode *old_inode = old_path.dentry->d_inode;
6753 +               struct inode *new_inode = new_path.dentry->d_inode;
6754 +               struct iattr attr = {
6755 +                       .ia_uid = old_inode->i_uid,
6756 +                       .ia_gid = old_inode->i_gid,
6757 +                       .ia_valid = ATTR_UID | ATTR_GID
6758 +                       };
6759 +
6760 +               ret = inode_setattr(new_inode, &attr);
6761 +               if (ret)
6762 +                       goto out_fput_both;
6763 +       }
6764 +
6765 +       mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6766 +
6767 +       /* drop out late */
6768 +       ret = -ENOENT;
6769 +       if ((redo = d_unhashed(old_path.dentry)))
6770 +               goto out_unlock;
6771 +
6772 +       vxdprintk(VXD_CBIT(misc, 2),
6773 +               "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
6774 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6775 +               new_path.dentry->d_name.len,
6776 +               old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6777 +               old_path.dentry->d_name.len);
6778 +       ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
6779 +               old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
6780 +       vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
6781 +       res = new_path.dentry;
6782 +
6783 +out_unlock:
6784 +       mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6785 +
6786 +out_fput_both:
6787 +       vxdprintk(VXD_CBIT(misc, 3),
6788 +               "fput(new_file=%p[#%ld])", new_file,
6789 +               atomic_long_read(&new_file->f_count));
6790 +       fput(new_file);
6791 +
6792 +out_fput_old:
6793 +       vxdprintk(VXD_CBIT(misc, 3),
6794 +               "fput(old_file=%p[#%ld])", old_file,
6795 +               atomic_long_read(&old_file->f_count));
6796 +       fput(old_file);
6797 +
6798 +out_unlock_new:
6799 +       mutex_unlock(&dir->d_inode->i_mutex);
6800 +       if (!ret)
6801 +               goto out_redo;
6802 +
6803 +       /* error path cleanup */
6804 +       vfs_unlink(dir->d_inode, new_path.dentry);
6805 +       dput(new_path.dentry);
6806 +
6807 +out_redo:
6808 +       if (!redo)
6809 +               goto out_rel_both;
6810 +       /* lookup dentry once again */
6811 +       path_put(&old_nd.path);
6812 +       ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6813 +       if (ret)
6814 +               goto out_rel_both;
6815 +
6816 +       new_path.dentry = old_nd.path.dentry;
6817 +       vxdprintk(VXD_CBIT(misc, 2),
6818 +               "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
6819 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6820 +               new_path.dentry->d_name.len);
6821 +       dget(new_path.dentry);
6822 +       res = new_path.dentry;
6823 +
6824 +out_rel_both:
6825 +       path_put(&dir_nd.path);
6826 +out_rel_old:
6827 +       path_put(&old_nd.path);
6828 +out_free_path:
6829 +       kfree(path);
6830 +out:
6831 +       if (ret)
6832 +               res = ERR_PTR(ret);
6833 +       return res;
6834 +}
6835 +
6836 +#endif
6837 +
6838  /* get the link contents into pagecache */
6839  static char *page_getlink(struct dentry * dentry, struct page **ppage)
6840  {
6841 diff -NurpP --minimal linux-2.6.35.2/fs/namespace.c linux-2.6.35.2-vs2.3.0.36.31/fs/namespace.c
6842 --- linux-2.6.35.2/fs/namespace.c       2010-08-14 18:16:59.000000000 +0200
6843 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/namespace.c 2010-08-14 18:21:13.000000000 +0200
6844 @@ -29,6 +29,11 @@
6845  #include <linux/log2.h>
6846  #include <linux/idr.h>
6847  #include <linux/fs_struct.h>
6848 +#include <linux/vs_base.h>
6849 +#include <linux/vs_context.h>
6850 +#include <linux/vs_tag.h>
6851 +#include <linux/vserver/space.h>
6852 +#include <linux/vserver/global.h>
6853  #include <asm/uaccess.h>
6854  #include <asm/unistd.h>
6855  #include "pnode.h"
6856 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
6857                 mnt->mnt_root = dget(root);
6858                 mnt->mnt_mountpoint = mnt->mnt_root;
6859                 mnt->mnt_parent = mnt;
6860 +               mnt->mnt_tag = old->mnt_tag;
6861  
6862                 if (flag & CL_SLAVE) {
6863                         list_add(&mnt->mnt_slave, &old->mnt_slave_list);
6864 @@ -660,6 +666,31 @@ static inline void mangle(struct seq_fil
6865         seq_escape(m, s, " \t\n\\");
6866  }
6867  
6868 +static int mnt_is_reachable(struct vfsmount *mnt)
6869 +{
6870 +       struct path root;
6871 +       struct dentry *point;
6872 +       int ret;
6873 +
6874 +       if (mnt == mnt->mnt_ns->root)
6875 +               return 1;
6876 +
6877 +       spin_lock(&vfsmount_lock);
6878 +       root = current->fs->root;
6879 +       point = root.dentry;
6880 +
6881 +       while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
6882 +               point = mnt->mnt_mountpoint;
6883 +               mnt = mnt->mnt_parent;
6884 +       }
6885 +
6886 +       ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
6887 +
6888 +       spin_unlock(&vfsmount_lock);
6889 +
6890 +       return ret;
6891 +}
6892 +
6893  /*
6894   * Simple .show_options callback for filesystems which don't want to
6895   * implement more complex mount option showing.
6896 @@ -762,6 +793,8 @@ static int show_sb_opts(struct seq_file 
6897                 { MS_SYNCHRONOUS, ",sync" },
6898                 { MS_DIRSYNC, ",dirsync" },
6899                 { MS_MANDLOCK, ",mand" },
6900 +               { MS_TAGGED, ",tag" },
6901 +               { MS_NOTAGCHECK, ",notagcheck" },
6902                 { 0, NULL }
6903         };
6904         const struct proc_fs_info *fs_infop;
6905 @@ -809,10 +842,20 @@ static int show_vfsmnt(struct seq_file *
6906         int err = 0;
6907         struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6908  
6909 -       mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6910 -       seq_putc(m, ' ');
6911 -       seq_path(m, &mnt_path, " \t\n\\");
6912 -       seq_putc(m, ' ');
6913 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
6914 +               return SEQ_SKIP;
6915 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6916 +               return SEQ_SKIP;
6917 +
6918 +       if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6919 +               mnt == current->fs->root.mnt) {
6920 +               seq_puts(m, "/dev/root / ");
6921 +       } else {
6922 +               mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6923 +               seq_putc(m, ' ');
6924 +               seq_path(m, &mnt_path, " \t\n\\");
6925 +               seq_putc(m, ' ');
6926 +       }
6927         show_type(m, mnt->mnt_sb);
6928         seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6929         err = show_sb_opts(m, mnt->mnt_sb);
6930 @@ -842,6 +885,11 @@ static int show_mountinfo(struct seq_fil
6931         struct path root = p->root;
6932         int err = 0;
6933  
6934 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
6935 +               return SEQ_SKIP;
6936 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6937 +               return SEQ_SKIP;
6938 +
6939         seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
6940                    MAJOR(sb->s_dev), MINOR(sb->s_dev));
6941         seq_dentry(m, mnt->mnt_root, " \t\n\\");
6942 @@ -900,17 +948,27 @@ static int show_vfsstat(struct seq_file 
6943         struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6944         int err = 0;
6945  
6946 -       /* device */
6947 -       if (mnt->mnt_devname) {
6948 -               seq_puts(m, "device ");
6949 -               mangle(m, mnt->mnt_devname);
6950 -       } else
6951 -               seq_puts(m, "no device");
6952 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
6953 +               return SEQ_SKIP;
6954 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6955 +               return SEQ_SKIP;
6956  
6957 -       /* mount point */
6958 -       seq_puts(m, " mounted on ");
6959 -       seq_path(m, &mnt_path, " \t\n\\");
6960 -       seq_putc(m, ' ');
6961 +       if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6962 +               mnt == current->fs->root.mnt) {
6963 +               seq_puts(m, "device /dev/root mounted on / ");
6964 +       } else {
6965 +               /* device */
6966 +               if (mnt->mnt_devname) {
6967 +                       seq_puts(m, "device ");
6968 +                       mangle(m, mnt->mnt_devname);
6969 +               } else
6970 +                       seq_puts(m, "no device");
6971 +
6972 +               /* mount point */
6973 +               seq_puts(m, " mounted on ");
6974 +               seq_path(m, &mnt_path, " \t\n\\");
6975 +               seq_putc(m, ' ');
6976 +       }
6977  
6978         /* file system type */
6979         seq_puts(m, "with fstype ");
6980 @@ -1151,7 +1209,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
6981                 goto dput_and_out;
6982  
6983         retval = -EPERM;
6984 -       if (!capable(CAP_SYS_ADMIN))
6985 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6986                 goto dput_and_out;
6987  
6988         retval = do_umount(path.mnt, flags);
6989 @@ -1177,7 +1235,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
6990  
6991  static int mount_is_safe(struct path *path)
6992  {
6993 -       if (capable(CAP_SYS_ADMIN))
6994 +       if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6995                 return 0;
6996         return -EPERM;
6997  #ifdef notyet
6998 @@ -1449,7 +1507,7 @@ static int do_change_type(struct path *p
6999         int type = flag & ~MS_REC;
7000         int err = 0;
7001  
7002 -       if (!capable(CAP_SYS_ADMIN))
7003 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
7004                 return -EPERM;
7005  
7006         if (path->dentry != path->mnt->mnt_root)
7007 @@ -1476,11 +1534,13 @@ static int do_change_type(struct path *p
7008   * do loopback mount.
7009   */
7010  static int do_loopback(struct path *path, char *old_name,
7011 -                               int recurse)
7012 +       tag_t tag, unsigned long flags, int mnt_flags)
7013  {
7014         struct path old_path;
7015         struct vfsmount *mnt = NULL;
7016         int err = mount_is_safe(path);
7017 +       int recurse = flags & MS_REC;
7018 +
7019         if (err)
7020                 return err;
7021         if (!old_name || !*old_name)
7022 @@ -1514,6 +1574,7 @@ static int do_loopback(struct path *path
7023                 spin_unlock(&vfsmount_lock);
7024                 release_mounts(&umount_list);
7025         }
7026 +       mnt->mnt_flags = mnt_flags;
7027  
7028  out:
7029         up_write(&namespace_sem);
7030 @@ -1544,12 +1605,12 @@ static int change_mount_flags(struct vfs
7031   * on it - tough luck.
7032   */
7033  static int do_remount(struct path *path, int flags, int mnt_flags,
7034 -                     void *data)
7035 +       void *data, xid_t xid)
7036  {
7037         int err;
7038         struct super_block *sb = path->mnt->mnt_sb;
7039  
7040 -       if (!capable(CAP_SYS_ADMIN))
7041 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7042                 return -EPERM;
7043  
7044         if (!check_mnt(path->mnt))
7045 @@ -1593,7 +1654,7 @@ static int do_move_mount(struct path *pa
7046         struct path old_path, parent_path;
7047         struct vfsmount *p;
7048         int err = 0;
7049 -       if (!capable(CAP_SYS_ADMIN))
7050 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7051                 return -EPERM;
7052         if (!old_name || !*old_name)
7053                 return -EINVAL;
7054 @@ -1675,7 +1736,7 @@ static int do_new_mount(struct path *pat
7055                 return -EINVAL;
7056  
7057         /* we need capabilities... */
7058 -       if (!capable(CAP_SYS_ADMIN))
7059 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7060                 return -EPERM;
7061  
7062         lock_kernel();
7063 @@ -1941,6 +2002,7 @@ long do_mount(char *dev_name, char *dir_
7064         struct path path;
7065         int retval = 0;
7066         int mnt_flags = 0;
7067 +       tag_t tag = 0;
7068  
7069         /* Discard magic */
7070         if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7071 @@ -1968,6 +2030,12 @@ long do_mount(char *dev_name, char *dir_
7072         if (!(flags & MS_NOATIME))
7073                 mnt_flags |= MNT_RELATIME;
7074  
7075 +       if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
7076 +               /* FIXME: bind and re-mounts get the tag flag? */
7077 +               if (flags & (MS_BIND|MS_REMOUNT))
7078 +                       flags |= MS_TAGID;
7079 +       }
7080 +
7081         /* Separate the per-mountpoint flags */
7082         if (flags & MS_NOSUID)
7083                 mnt_flags |= MNT_NOSUID;
7084 @@ -1984,15 +2052,17 @@ long do_mount(char *dev_name, char *dir_
7085         if (flags & MS_RDONLY)
7086                 mnt_flags |= MNT_READONLY;
7087  
7088 +       if (!capable(CAP_SYS_ADMIN))
7089 +               mnt_flags |= MNT_NODEV;
7090         flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
7091                    MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
7092                    MS_STRICTATIME);
7093  
7094         if (flags & MS_REMOUNT)
7095                 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
7096 -                                   data_page);
7097 +                                   data_page, tag);
7098         else if (flags & MS_BIND)
7099 -               retval = do_loopback(&path, dev_name, flags & MS_REC);
7100 +               retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
7101         else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7102                 retval = do_change_type(&path, flags);
7103         else if (flags & MS_MOVE)
7104 @@ -2071,6 +2141,7 @@ static struct mnt_namespace *dup_mnt_ns(
7105                 q = next_mnt(q, new_ns->root);
7106         }
7107         up_write(&namespace_sem);
7108 +       atomic_inc(&vs_global_mnt_ns);
7109  
7110         if (rootmnt)
7111                 mntput(rootmnt);
7112 @@ -2215,9 +2286,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
7113         down_write(&namespace_sem);
7114         mutex_lock(&old.dentry->d_inode->i_mutex);
7115         error = -EINVAL;
7116 -       if (IS_MNT_SHARED(old.mnt) ||
7117 +       if ((IS_MNT_SHARED(old.mnt) ||
7118                 IS_MNT_SHARED(new.mnt->mnt_parent) ||
7119 -               IS_MNT_SHARED(root.mnt->mnt_parent))
7120 +               IS_MNT_SHARED(root.mnt->mnt_parent)) &&
7121 +               !vx_flags(VXF_STATE_SETUP, 0))
7122                 goto out2;
7123         if (!check_mnt(root.mnt))
7124                 goto out2;
7125 @@ -2348,6 +2420,7 @@ void put_mnt_ns(struct mnt_namespace *ns
7126         spin_unlock(&vfsmount_lock);
7127         up_write(&namespace_sem);
7128         release_mounts(&umount_list);
7129 +       atomic_dec(&vs_global_mnt_ns);
7130         kfree(ns);
7131  }
7132  EXPORT_SYMBOL(put_mnt_ns);
7133 diff -NurpP --minimal linux-2.6.35.2/fs/nfs/client.c linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/client.c
7134 --- linux-2.6.35.2/fs/nfs/client.c      2010-08-02 16:52:50.000000000 +0200
7135 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/client.c        2010-08-02 17:05:06.000000000 +0200
7136 @@ -739,6 +739,9 @@ static int nfs_init_server_rpcclient(str
7137         if (server->flags & NFS_MOUNT_SOFT)
7138                 server->client->cl_softrtry = 1;
7139  
7140 +       server->client->cl_tag = 0;
7141 +       if (server->flags & NFS_MOUNT_TAGGED)
7142 +               server->client->cl_tag = 1;
7143         return 0;
7144  }
7145  
7146 @@ -910,6 +913,10 @@ static void nfs_server_set_fsinfo(struct
7147                 server->acdirmin = server->acdirmax = 0;
7148         }
7149  
7150 +       /* FIXME: needs fsinfo
7151 +       if (server->flags & NFS_MOUNT_TAGGED)
7152 +               sb->s_flags |= MS_TAGGED;       */
7153 +
7154         server->maxfilesize = fsinfo->maxfilesize;
7155  
7156         /* We're airborne Set socket buffersize */
7157 diff -NurpP --minimal linux-2.6.35.2/fs/nfs/dir.c linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/dir.c
7158 --- linux-2.6.35.2/fs/nfs/dir.c 2010-08-02 16:52:50.000000000 +0200
7159 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/dir.c   2010-08-02 17:05:06.000000000 +0200
7160 @@ -33,6 +33,7 @@
7161  #include <linux/namei.h>
7162  #include <linux/mount.h>
7163  #include <linux/sched.h>
7164 +#include <linux/vs_tag.h>
7165  
7166  #include "nfs4_fs.h"
7167  #include "delegation.h"
7168 @@ -979,6 +980,7 @@ static struct dentry *nfs_lookup(struct 
7169         if (IS_ERR(res))
7170                 goto out_unblock_sillyrename;
7171  
7172 +       dx_propagate_tag(nd, inode);
7173  no_entry:
7174         res = d_materialise_unique(dentry, inode);
7175         if (res != NULL) {
7176 diff -NurpP --minimal linux-2.6.35.2/fs/nfs/inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/inode.c
7177 --- linux-2.6.35.2/fs/nfs/inode.c       2010-08-02 16:52:50.000000000 +0200
7178 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/inode.c 2010-08-02 17:05:06.000000000 +0200
7179 @@ -37,6 +37,7 @@
7180  #include <linux/inet.h>
7181  #include <linux/nfs_xdr.h>
7182  #include <linux/slab.h>
7183 +#include <linux/vs_tag.h>
7184  
7185  #include <asm/system.h>
7186  #include <asm/uaccess.h>
7187 @@ -260,6 +261,8 @@ nfs_fhget(struct super_block *sb, struct
7188         if (inode->i_state & I_NEW) {
7189                 struct nfs_inode *nfsi = NFS_I(inode);
7190                 unsigned long now = jiffies;
7191 +               uid_t uid;
7192 +               gid_t gid;
7193  
7194                 /* We set i_ino for the few things that still rely on it,
7195                  * such as stat(2) */
7196 @@ -308,8 +311,8 @@ nfs_fhget(struct super_block *sb, struct
7197                 nfsi->change_attr = 0;
7198                 inode->i_size = 0;
7199                 inode->i_nlink = 0;
7200 -               inode->i_uid = -2;
7201 -               inode->i_gid = -2;
7202 +               uid = -2;
7203 +               gid = -2;
7204                 inode->i_blocks = 0;
7205                 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
7206  
7207 @@ -346,13 +349,13 @@ nfs_fhget(struct super_block *sb, struct
7208                 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
7209                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
7210                 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
7211 -                       inode->i_uid = fattr->uid;
7212 +                       uid = fattr->uid;
7213                 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
7214                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7215                                 | NFS_INO_INVALID_ACCESS
7216                                 | NFS_INO_INVALID_ACL;
7217                 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
7218 -                       inode->i_gid = fattr->gid;
7219 +                       gid = fattr->gid;
7220                 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
7221                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7222                                 | NFS_INO_INVALID_ACCESS
7223 @@ -365,6 +368,11 @@ nfs_fhget(struct super_block *sb, struct
7224                          */
7225                         inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
7226                 }
7227 +               inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7228 +               inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7229 +               inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7230 +                               /* maybe fattr->xid someday */
7231 +
7232                 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
7233                 nfsi->attrtimeo_timestamp = now;
7234                 nfsi->access_cache = RB_ROOT;
7235 @@ -483,6 +491,8 @@ void nfs_setattr_update_inode(struct ino
7236                         inode->i_uid = attr->ia_uid;
7237                 if ((attr->ia_valid & ATTR_GID) != 0)
7238                         inode->i_gid = attr->ia_gid;
7239 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7240 +                       inode->i_tag = attr->ia_tag;
7241                 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7242                 spin_unlock(&inode->i_lock);
7243         }
7244 @@ -856,6 +866,9 @@ static int nfs_check_inode_attributes(st
7245         struct nfs_inode *nfsi = NFS_I(inode);
7246         loff_t cur_size, new_isize;
7247         unsigned long invalid = 0;
7248 +       uid_t uid;
7249 +       gid_t gid;
7250 +       tag_t tag;
7251  
7252  
7253         /* Has the inode gone and changed behind our back? */
7254 @@ -879,13 +892,18 @@ static int nfs_check_inode_attributes(st
7255                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7256         }
7257  
7258 +       uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7259 +       gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7260 +       tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7261 +
7262         /* Have any file permissions changed? */
7263         if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
7264                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7265 -       if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
7266 +       if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
7267                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7268 -       if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
7269 +       if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
7270                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7271 +               /* maybe check for tag too? */
7272  
7273         /* Has the link count changed? */
7274         if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
7275 @@ -1120,6 +1138,9 @@ static int nfs_update_inode(struct inode
7276         unsigned long invalid = 0;
7277         unsigned long now = jiffies;
7278         unsigned long save_cache_validity;
7279 +       uid_t uid;
7280 +       gid_t gid;
7281 +       tag_t tag;
7282  
7283         dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7284                         __func__, inode->i_sb->s_id, inode->i_ino,
7285 @@ -1222,6 +1243,9 @@ static int nfs_update_inode(struct inode
7286                                 | NFS_INO_REVAL_PAGECACHE
7287                                 | NFS_INO_REVAL_FORCED);
7288  
7289 +       uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7290 +       gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7291 +       tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7292  
7293         if (fattr->valid & NFS_ATTR_FATTR_ATIME)
7294                 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7295 @@ -1243,9 +1267,9 @@ static int nfs_update_inode(struct inode
7296                                 | NFS_INO_REVAL_FORCED);
7297  
7298         if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
7299 -               if (inode->i_uid != fattr->uid) {
7300 +               if (uid != fattr->uid) {
7301                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7302 -                       inode->i_uid = fattr->uid;
7303 +                       uid = fattr->uid;
7304                 }
7305         } else if (server->caps & NFS_CAP_OWNER)
7306                 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7307 @@ -1254,9 +1278,9 @@ static int nfs_update_inode(struct inode
7308                                 | NFS_INO_REVAL_FORCED);
7309  
7310         if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
7311 -               if (inode->i_gid != fattr->gid) {
7312 +               if (gid != fattr->gid) {
7313                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7314 -                       inode->i_gid = fattr->gid;
7315 +                       gid = fattr->gid;
7316                 }
7317         } else if (server->caps & NFS_CAP_OWNER_GROUP)
7318                 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7319 @@ -1264,6 +1288,10 @@ static int nfs_update_inode(struct inode
7320                                 | NFS_INO_INVALID_ACL
7321                                 | NFS_INO_REVAL_FORCED);
7322  
7323 +       inode->i_uid = uid;
7324 +       inode->i_gid = gid;
7325 +       inode->i_tag = tag;
7326 +
7327         if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
7328                 if (inode->i_nlink != fattr->nlink) {
7329                         invalid |= NFS_INO_INVALID_ATTR;
7330 diff -NurpP --minimal linux-2.6.35.2/fs/nfs/nfs3xdr.c linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/nfs3xdr.c
7331 --- linux-2.6.35.2/fs/nfs/nfs3xdr.c     2010-08-02 16:52:50.000000000 +0200
7332 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/nfs3xdr.c       2010-08-02 17:05:06.000000000 +0200
7333 @@ -20,6 +20,7 @@
7334  #include <linux/nfs3.h>
7335  #include <linux/nfs_fs.h>
7336  #include <linux/nfsacl.h>
7337 +#include <linux/vs_tag.h>
7338  #include "internal.h"
7339  
7340  #define NFSDBG_FACILITY                NFSDBG_XDR
7341 @@ -175,7 +176,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7342  }
7343  
7344  static inline __be32 *
7345 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7346 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7347  {
7348         if (attr->ia_valid & ATTR_MODE) {
7349                 *p++ = xdr_one;
7350 @@ -183,15 +184,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7351         } else {
7352                 *p++ = xdr_zero;
7353         }
7354 -       if (attr->ia_valid & ATTR_UID) {
7355 +       if (attr->ia_valid & ATTR_UID ||
7356 +               (tag && (attr->ia_valid & ATTR_TAG))) {
7357                 *p++ = xdr_one;
7358 -               *p++ = htonl(attr->ia_uid);
7359 +               *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7360         } else {
7361                 *p++ = xdr_zero;
7362         }
7363 -       if (attr->ia_valid & ATTR_GID) {
7364 +       if (attr->ia_valid & ATTR_GID ||
7365 +               (tag && (attr->ia_valid & ATTR_TAG))) {
7366                 *p++ = xdr_one;
7367 -               *p++ = htonl(attr->ia_gid);
7368 +               *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7369         } else {
7370                 *p++ = xdr_zero;
7371         }
7372 @@ -278,7 +281,8 @@ static int
7373  nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7374  {
7375         p = xdr_encode_fhandle(p, args->fh);
7376 -       p = xdr_encode_sattr(p, args->sattr);
7377 +       p = xdr_encode_sattr(p, args->sattr,
7378 +               req->rq_task->tk_client->cl_tag);
7379         *p++ = htonl(args->guard);
7380         if (args->guard)
7381                 p = xdr_encode_time3(p, &args->guardtime);
7382 @@ -383,7 +387,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7383                 *p++ = args->verifier[0];
7384                 *p++ = args->verifier[1];
7385         } else
7386 -               p = xdr_encode_sattr(p, args->sattr);
7387 +               p = xdr_encode_sattr(p, args->sattr,
7388 +                       req->rq_task->tk_client->cl_tag);
7389  
7390         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7391         return 0;
7392 @@ -397,7 +402,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7393  {
7394         p = xdr_encode_fhandle(p, args->fh);
7395         p = xdr_encode_array(p, args->name, args->len);
7396 -       p = xdr_encode_sattr(p, args->sattr);
7397 +       p = xdr_encode_sattr(p, args->sattr,
7398 +               req->rq_task->tk_client->cl_tag);
7399         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7400         return 0;
7401  }
7402 @@ -410,7 +416,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7403  {
7404         p = xdr_encode_fhandle(p, args->fromfh);
7405         p = xdr_encode_array(p, args->fromname, args->fromlen);
7406 -       p = xdr_encode_sattr(p, args->sattr);
7407 +       p = xdr_encode_sattr(p, args->sattr,
7408 +               req->rq_task->tk_client->cl_tag);
7409         *p++ = htonl(args->pathlen);
7410         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7411  
7412 @@ -428,7 +435,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7413         p = xdr_encode_fhandle(p, args->fh);
7414         p = xdr_encode_array(p, args->name, args->len);
7415         *p++ = htonl(args->type);
7416 -       p = xdr_encode_sattr(p, args->sattr);
7417 +       p = xdr_encode_sattr(p, args->sattr,
7418 +               req->rq_task->tk_client->cl_tag);
7419         if (args->type == NF3CHR || args->type == NF3BLK) {
7420                 *p++ = htonl(MAJOR(args->rdev));
7421                 *p++ = htonl(MINOR(args->rdev));
7422 diff -NurpP --minimal linux-2.6.35.2/fs/nfs/nfsroot.c linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/nfsroot.c
7423 --- linux-2.6.35.2/fs/nfs/nfsroot.c     2010-08-02 16:52:50.000000000 +0200
7424 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/nfsroot.c       2010-08-02 17:05:06.000000000 +0200
7425 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0;             /
7426  enum {
7427         /* Options that take integer arguments */
7428         Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7429 -       Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7430 +       Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7431         /* Options that take no arguments */
7432         Opt_soft, Opt_hard, Opt_intr,
7433         Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac, 
7434         Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7435 -       Opt_acl, Opt_noacl,
7436 +       Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7437         /* Error token */
7438         Opt_err
7439  };
7440 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
7441         {Opt_tcp, "tcp"},
7442         {Opt_acl, "acl"},
7443         {Opt_noacl, "noacl"},
7444 +       {Opt_tag, "tag"},
7445 +       {Opt_notag, "notag"},
7446 +       {Opt_tagid, "tagid=%u"},
7447         {Opt_err, NULL}
7448         
7449  };
7450 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
7451                         case Opt_noacl:
7452                                 nfs_data.flags |= NFS_MOUNT_NOACL;
7453                                 break;
7454 +#ifndef CONFIG_TAGGING_NONE
7455 +                       case Opt_tag:
7456 +                               nfs_data.flags |= NFS_MOUNT_TAGGED;
7457 +                               break;
7458 +                       case Opt_notag:
7459 +                               nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7460 +                               break;
7461 +#endif
7462 +#ifdef CONFIG_PROPAGATE
7463 +                       case Opt_tagid:
7464 +                               /* use args[0] */
7465 +                               nfs_data.flags |= NFS_MOUNT_TAGGED;
7466 +                               break;
7467 +#endif
7468                         default:
7469                                 printk(KERN_WARNING "Root-NFS: unknown "
7470                                         "option: %s\n", p);
7471 diff -NurpP --minimal linux-2.6.35.2/fs/nfs/super.c linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/super.c
7472 --- linux-2.6.35.2/fs/nfs/super.c       2010-08-02 16:52:50.000000000 +0200
7473 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/nfs/super.c 2010-08-02 17:05:06.000000000 +0200
7474 @@ -54,6 +54,7 @@
7475  #include <linux/nfs_xdr.h>
7476  #include <linux/magic.h>
7477  #include <linux/parser.h>
7478 +#include <linux/vs_tag.h>
7479  
7480  #include <asm/system.h>
7481  #include <asm/uaccess.h>
7482 @@ -606,6 +607,7 @@ static void nfs_show_mount_options(struc
7483                 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7484                 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
7485                 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
7486 +               { NFS_MOUNT_TAGGED, ",tag", "" },
7487                 { 0, NULL, NULL }
7488         };
7489         const struct proc_nfs_info *nfs_infop;
7490 diff -NurpP --minimal linux-2.6.35.2/fs/nfsd/auth.c linux-2.6.35.2-vs2.3.0.36.31/fs/nfsd/auth.c
7491 --- linux-2.6.35.2/fs/nfsd/auth.c       2010-02-25 11:52:05.000000000 +0100
7492 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/nfsd/auth.c 2010-08-02 17:05:06.000000000 +0200
7493 @@ -1,6 +1,7 @@
7494  /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
7495  
7496  #include <linux/sched.h>
7497 +#include <linux/vs_tag.h>
7498  #include "nfsd.h"
7499  #include "auth.h"
7500  
7501 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7502  
7503         new->fsuid = rqstp->rq_cred.cr_uid;
7504         new->fsgid = rqstp->rq_cred.cr_gid;
7505 +       /* FIXME: this desperately needs a tag :)
7506 +       new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7507 +                       */
7508  
7509         rqgi = rqstp->rq_cred.cr_group_info;
7510  
7511 diff -NurpP --minimal linux-2.6.35.2/fs/nfsd/nfs3xdr.c linux-2.6.35.2-vs2.3.0.36.31/fs/nfsd/nfs3xdr.c
7512 --- linux-2.6.35.2/fs/nfsd/nfs3xdr.c    2010-02-25 11:52:05.000000000 +0100
7513 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/nfsd/nfs3xdr.c      2010-08-02 17:05:06.000000000 +0200
7514 @@ -7,6 +7,7 @@
7515   */
7516  
7517  #include <linux/namei.h>
7518 +#include <linux/vs_tag.h>
7519  #include "xdr3.h"
7520  #include "auth.h"
7521  
7522 @@ -95,6 +96,8 @@ static __be32 *
7523  decode_sattr3(__be32 *p, struct iattr *iap)
7524  {
7525         u32     tmp;
7526 +       uid_t   uid = 0;
7527 +       gid_t   gid = 0;
7528  
7529         iap->ia_valid = 0;
7530  
7531 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7532         }
7533         if (*p++) {
7534                 iap->ia_valid |= ATTR_UID;
7535 -               iap->ia_uid = ntohl(*p++);
7536 +               uid = ntohl(*p++);
7537         }
7538         if (*p++) {
7539                 iap->ia_valid |= ATTR_GID;
7540 -               iap->ia_gid = ntohl(*p++);
7541 +               gid = ntohl(*p++);
7542         }
7543 +       iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7544 +       iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7545 +       iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7546         if (*p++) {
7547                 u64     newsize;
7548  
7549 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
7550         *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7551         *p++ = htonl((u32) stat->mode);
7552         *p++ = htonl((u32) stat->nlink);
7553 -       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7554 -       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7555 +       *p++ = htonl((u32) nfsd_ruid(rqstp,
7556 +               TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7557 +               stat->uid, stat->tag)));
7558 +       *p++ = htonl((u32) nfsd_rgid(rqstp,
7559 +               TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7560 +               stat->gid, stat->tag)));
7561         if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7562                 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7563         } else {
7564 diff -NurpP --minimal linux-2.6.35.2/fs/nfsd/nfs4xdr.c linux-2.6.35.2-vs2.3.0.36.31/fs/nfsd/nfs4xdr.c
7565 --- linux-2.6.35.2/fs/nfsd/nfs4xdr.c    2010-08-02 16:52:50.000000000 +0200
7566 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/nfsd/nfs4xdr.c      2010-08-02 17:05:06.000000000 +0200
7567 @@ -47,6 +47,7 @@
7568  #include <linux/nfsd_idmap.h>
7569  #include <linux/nfs4_acl.h>
7570  #include <linux/sunrpc/svcauth_gss.h>
7571 +#include <linux/vs_tag.h>
7572  
7573  #include "xdr4.h"
7574  #include "vfs.h"
7575 @@ -2053,14 +2054,18 @@ out_acl:
7576                 WRITE32(stat.nlink);
7577         }
7578         if (bmval1 & FATTR4_WORD1_OWNER) {
7579 -               status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7580 +               status = nfsd4_encode_user(rqstp,
7581 +                       TAGINO_UID(DX_TAG(dentry->d_inode),
7582 +                       stat.uid, stat.tag), &p, &buflen);
7583                 if (status == nfserr_resource)
7584                         goto out_resource;
7585                 if (status)
7586                         goto out;
7587         }
7588         if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7589 -               status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7590 +               status = nfsd4_encode_group(rqstp,
7591 +                       TAGINO_GID(DX_TAG(dentry->d_inode),
7592 +                       stat.gid, stat.tag), &p, &buflen);
7593                 if (status == nfserr_resource)
7594                         goto out_resource;
7595                 if (status)
7596 diff -NurpP --minimal linux-2.6.35.2/fs/nfsd/nfsxdr.c linux-2.6.35.2-vs2.3.0.36.31/fs/nfsd/nfsxdr.c
7597 --- linux-2.6.35.2/fs/nfsd/nfsxdr.c     2010-02-25 11:52:05.000000000 +0100
7598 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/nfsd/nfsxdr.c       2010-08-02 17:05:06.000000000 +0200
7599 @@ -6,6 +6,7 @@
7600  
7601  #include "xdr.h"
7602  #include "auth.h"
7603 +#include <linux/vs_tag.h>
7604  
7605  #define NFSDDBG_FACILITY               NFSDDBG_XDR
7606  
7607 @@ -88,6 +89,8 @@ static __be32 *
7608  decode_sattr(__be32 *p, struct iattr *iap)
7609  {
7610         u32     tmp, tmp1;
7611 +       uid_t   uid = 0;
7612 +       gid_t   gid = 0;
7613  
7614         iap->ia_valid = 0;
7615  
7616 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7617         }
7618         if ((tmp = ntohl(*p++)) != (u32)-1) {
7619                 iap->ia_valid |= ATTR_UID;
7620 -               iap->ia_uid = tmp;
7621 +               uid = tmp;
7622         }
7623         if ((tmp = ntohl(*p++)) != (u32)-1) {
7624                 iap->ia_valid |= ATTR_GID;
7625 -               iap->ia_gid = tmp;
7626 +               gid = tmp;
7627         }
7628 +       iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7629 +       iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7630 +       iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7631         if ((tmp = ntohl(*p++)) != (u32)-1) {
7632                 iap->ia_valid |= ATTR_SIZE;
7633                 iap->ia_size = tmp;
7634 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7635         *p++ = htonl(nfs_ftypes[type >> 12]);
7636         *p++ = htonl((u32) stat->mode);
7637         *p++ = htonl((u32) stat->nlink);
7638 -       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7639 -       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7640 +       *p++ = htonl((u32) nfsd_ruid(rqstp,
7641 +               TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7642 +       *p++ = htonl((u32) nfsd_rgid(rqstp,
7643 +               TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7644  
7645         if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7646                 *p++ = htonl(NFS_MAXPATHLEN);
7647 diff -NurpP --minimal linux-2.6.35.2/fs/ocfs2/dlmglue.c linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/dlmglue.c
7648 --- linux-2.6.35.2/fs/ocfs2/dlmglue.c   2010-08-02 16:52:51.000000000 +0200
7649 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/dlmglue.c     2010-08-02 17:05:06.000000000 +0200
7650 @@ -2114,6 +2114,7 @@ static void __ocfs2_stuff_meta_lvb(struc
7651         lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
7652         lvb->lvb_iuid      = cpu_to_be32(inode->i_uid);
7653         lvb->lvb_igid      = cpu_to_be32(inode->i_gid);
7654 +       lvb->lvb_itag      = cpu_to_be16(inode->i_tag);
7655         lvb->lvb_imode     = cpu_to_be16(inode->i_mode);
7656         lvb->lvb_inlink    = cpu_to_be16(inode->i_nlink);
7657         lvb->lvb_iatime_packed  =
7658 @@ -2168,6 +2169,7 @@ static void ocfs2_refresh_inode_from_lvb
7659  
7660         inode->i_uid     = be32_to_cpu(lvb->lvb_iuid);
7661         inode->i_gid     = be32_to_cpu(lvb->lvb_igid);
7662 +       inode->i_tag     = be16_to_cpu(lvb->lvb_itag);
7663         inode->i_mode    = be16_to_cpu(lvb->lvb_imode);
7664         inode->i_nlink   = be16_to_cpu(lvb->lvb_inlink);
7665         ocfs2_unpack_timespec(&inode->i_atime,
7666 diff -NurpP --minimal linux-2.6.35.2/fs/ocfs2/dlmglue.h linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/dlmglue.h
7667 --- linux-2.6.35.2/fs/ocfs2/dlmglue.h   2009-12-03 20:02:53.000000000 +0100
7668 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/dlmglue.h     2010-08-02 17:05:06.000000000 +0200
7669 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
7670         __be16       lvb_inlink;
7671         __be32       lvb_iattr;
7672         __be32       lvb_igeneration;
7673 -       __be32       lvb_reserved2;
7674 +       __be16       lvb_itag;
7675 +       __be16       lvb_reserved2;
7676  };
7677  
7678  #define OCFS2_QINFO_LVB_VERSION 1
7679 diff -NurpP --minimal linux-2.6.35.2/fs/ocfs2/file.c linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/file.c
7680 --- linux-2.6.35.2/fs/ocfs2/file.c      2010-08-02 16:52:51.000000000 +0200
7681 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/file.c        2010-08-02 17:05:06.000000000 +0200
7682 @@ -1129,13 +1129,15 @@ int ocfs2_setattr(struct dentry *dentry,
7683                 mlog(0, "uid change: %d\n", attr->ia_uid);
7684         if (attr->ia_valid & ATTR_GID)
7685                 mlog(0, "gid change: %d\n", attr->ia_gid);
7686 +       if (attr->ia_valid & ATTR_TAG)
7687 +               mlog(0, "tag change: %d\n", attr->ia_tag);
7688         if (attr->ia_valid & ATTR_SIZE)
7689                 mlog(0, "size change...\n");
7690         if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
7691                 mlog(0, "time change...\n");
7692  
7693  #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
7694 -                          | ATTR_GID | ATTR_UID | ATTR_MODE)
7695 +                          | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
7696         if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
7697                 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
7698                 return 0;
7699 diff -NurpP --minimal linux-2.6.35.2/fs/ocfs2/inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/inode.c
7700 --- linux-2.6.35.2/fs/ocfs2/inode.c     2010-08-02 16:52:51.000000000 +0200
7701 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/inode.c       2010-08-02 17:05:06.000000000 +0200
7702 @@ -28,6 +28,7 @@
7703  #include <linux/highmem.h>
7704  #include <linux/pagemap.h>
7705  #include <linux/quotaops.h>
7706 +#include <linux/vs_tag.h>
7707  
7708  #include <asm/byteorder.h>
7709  
7710 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode 
7711  {
7712         unsigned int flags = OCFS2_I(inode)->ip_attr;
7713  
7714 -       inode->i_flags &= ~(S_IMMUTABLE |
7715 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
7716                 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
7717  
7718         if (flags & OCFS2_IMMUTABLE_FL)
7719                 inode->i_flags |= S_IMMUTABLE;
7720 +       if (flags & OCFS2_IXUNLINK_FL)
7721 +               inode->i_flags |= S_IXUNLINK;
7722  
7723         if (flags & OCFS2_SYNC_FL)
7724                 inode->i_flags |= S_SYNC;
7725 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode 
7726                 inode->i_flags |= S_NOATIME;
7727         if (flags & OCFS2_DIRSYNC_FL)
7728                 inode->i_flags |= S_DIRSYNC;
7729 +
7730 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
7731 +
7732 +       if (flags & OCFS2_BARRIER_FL)
7733 +               inode->i_vflags |= V_BARRIER;
7734 +       if (flags & OCFS2_COW_FL)
7735 +               inode->i_vflags |= V_COW;
7736  }
7737  
7738  /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
7739  void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
7740  {
7741         unsigned int flags = oi->vfs_inode.i_flags;
7742 +       unsigned int vflags = oi->vfs_inode.i_vflags;
7743 +
7744 +       oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
7745 +                       OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
7746 +                       OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
7747 +                       OCFS2_BARRIER_FL | OCFS2_COW_FL);
7748 +
7749 +       if (flags & S_IMMUTABLE)
7750 +               oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7751 +       if (flags & S_IXUNLINK)
7752 +               oi->ip_attr |= OCFS2_IXUNLINK_FL;
7753  
7754 -       oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
7755 -                       OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
7756         if (flags & S_SYNC)
7757                 oi->ip_attr |= OCFS2_SYNC_FL;
7758         if (flags & S_APPEND)
7759                 oi->ip_attr |= OCFS2_APPEND_FL;
7760 -       if (flags & S_IMMUTABLE)
7761 -               oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7762         if (flags & S_NOATIME)
7763                 oi->ip_attr |= OCFS2_NOATIME_FL;
7764         if (flags & S_DIRSYNC)
7765                 oi->ip_attr |= OCFS2_DIRSYNC_FL;
7766 +
7767 +       if (vflags & V_BARRIER)
7768 +               oi->ip_attr |= OCFS2_BARRIER_FL;
7769 +       if (vflags & V_COW)
7770 +               oi->ip_attr |= OCFS2_COW_FL;
7771  }
7772  
7773  struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
7774 @@ -245,6 +267,8 @@ void ocfs2_populate_inode(struct inode *
7775         struct super_block *sb;
7776         struct ocfs2_super *osb;
7777         int use_plocks = 1;
7778 +       uid_t uid;
7779 +       gid_t gid;
7780  
7781         mlog_entry("(0x%p, size:%llu)\n", inode,
7782                    (unsigned long long)le64_to_cpu(fe->i_size));
7783 @@ -276,8 +300,12 @@ void ocfs2_populate_inode(struct inode *
7784         inode->i_generation = le32_to_cpu(fe->i_generation);
7785         inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
7786         inode->i_mode = le16_to_cpu(fe->i_mode);
7787 -       inode->i_uid = le32_to_cpu(fe->i_uid);
7788 -       inode->i_gid = le32_to_cpu(fe->i_gid);
7789 +       uid = le32_to_cpu(fe->i_uid);
7790 +       gid = le32_to_cpu(fe->i_gid);
7791 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7792 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7793 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7794 +               /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7795  
7796         /* Fast symlinks will have i_size but no allocated clusters. */
7797         if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
7798 diff -NurpP --minimal linux-2.6.35.2/fs/ocfs2/inode.h linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/inode.h
7799 --- linux-2.6.35.2/fs/ocfs2/inode.h     2010-08-02 16:52:51.000000000 +0200
7800 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/inode.h       2010-08-02 17:05:06.000000000 +0200
7801 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
7802  
7803  void ocfs2_set_inode_flags(struct inode *inode);
7804  void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
7805 +int ocfs2_sync_flags(struct inode *inode, int, int);
7806  
7807  static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
7808  {
7809 diff -NurpP --minimal linux-2.6.35.2/fs/ocfs2/ioctl.c linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/ioctl.c
7810 --- linux-2.6.35.2/fs/ocfs2/ioctl.c     2010-02-25 11:52:06.000000000 +0100
7811 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/ioctl.c       2010-08-02 17:05:06.000000000 +0200
7812 @@ -43,7 +43,41 @@ static int ocfs2_get_inode_attr(struct i
7813         return status;
7814  }
7815  
7816 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7817 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
7818 +{
7819 +       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7820 +       struct buffer_head *bh = NULL;
7821 +       handle_t *handle = NULL;
7822 +       int status;
7823 +
7824 +       status = ocfs2_inode_lock(inode, &bh, 1);
7825 +       if (status < 0) {
7826 +               mlog_errno(status);
7827 +               return status;
7828 +       }
7829 +       handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7830 +       if (IS_ERR(handle)) {
7831 +               status = PTR_ERR(handle);
7832 +               mlog_errno(status);
7833 +               goto bail_unlock;
7834 +       }
7835 +
7836 +       inode->i_flags = flags;
7837 +       inode->i_vflags = vflags;
7838 +       ocfs2_get_inode_flags(OCFS2_I(inode));
7839 +
7840 +       status = ocfs2_mark_inode_dirty(handle, inode, bh);
7841 +       if (status < 0)
7842 +               mlog_errno(status);
7843 +
7844 +       ocfs2_commit_trans(osb, handle);
7845 +bail_unlock:
7846 +       ocfs2_inode_unlock(inode, 1);
7847 +       brelse(bh);
7848 +       return status;
7849 +}
7850 +
7851 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7852                                 unsigned mask)
7853  {
7854         struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
7855 @@ -68,6 +102,11 @@ static int ocfs2_set_inode_attr(struct i
7856         if (!S_ISDIR(inode->i_mode))
7857                 flags &= ~OCFS2_DIRSYNC_FL;
7858  
7859 +       if (IS_BARRIER(inode)) {
7860 +               vxwprintk_task(1, "messing with the barrier.");
7861 +               goto bail_unlock;
7862 +       }
7863 +
7864         handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7865         if (IS_ERR(handle)) {
7866                 status = PTR_ERR(handle);
7867 @@ -109,6 +148,7 @@ bail:
7868         return status;
7869  }
7870  
7871 +
7872  long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7873  {
7874         struct inode *inode = filp->f_path.dentry->d_inode;
7875 diff -NurpP --minimal linux-2.6.35.2/fs/ocfs2/namei.c linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/namei.c
7876 --- linux-2.6.35.2/fs/ocfs2/namei.c     2010-08-02 16:52:51.000000000 +0200
7877 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/namei.c       2010-08-02 17:05:06.000000000 +0200
7878 @@ -41,6 +41,7 @@
7879  #include <linux/slab.h>
7880  #include <linux/highmem.h>
7881  #include <linux/quotaops.h>
7882 +#include <linux/vs_tag.h>
7883  
7884  #define MLOG_MASK_PREFIX ML_NAMEI
7885  #include <cluster/masklog.h>
7886 @@ -487,6 +488,7 @@ static int ocfs2_mknod_locked(struct ocf
7887         u64 suballoc_loc, fe_blkno = 0;
7888         u16 suballoc_bit;
7889         u16 feat;
7890 +       tag_t tag;
7891  
7892         *new_fe_bh = NULL;
7893  
7894 @@ -532,8 +534,11 @@ static int ocfs2_mknod_locked(struct ocf
7895         fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
7896         fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
7897         fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
7898 -       fe->i_uid = cpu_to_le32(inode->i_uid);
7899 -       fe->i_gid = cpu_to_le32(inode->i_gid);
7900 +
7901 +       tag = dx_current_fstag(osb->sb);
7902 +       fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
7903 +       fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
7904 +       inode->i_tag = tag;
7905         fe->i_mode = cpu_to_le16(inode->i_mode);
7906         if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
7907                 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
7908 diff -NurpP --minimal linux-2.6.35.2/fs/ocfs2/ocfs2_fs.h linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/ocfs2_fs.h
7909 --- linux-2.6.35.2/fs/ocfs2/ocfs2_fs.h  2010-08-02 16:52:51.000000000 +0200
7910 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/ocfs2_fs.h    2010-08-02 17:05:06.000000000 +0200
7911 @@ -235,18 +235,23 @@
7912  #define OCFS2_HAS_REFCOUNT_FL   (0x0010)
7913  
7914  /* Inode attributes, keep in sync with EXT2 */
7915 -#define OCFS2_SECRM_FL         (0x00000001)    /* Secure deletion */
7916 -#define OCFS2_UNRM_FL          (0x00000002)    /* Undelete */
7917 -#define OCFS2_COMPR_FL         (0x00000004)    /* Compress file */
7918 -#define OCFS2_SYNC_FL          (0x00000008)    /* Synchronous updates */
7919 -#define OCFS2_IMMUTABLE_FL     (0x00000010)    /* Immutable file */
7920 -#define OCFS2_APPEND_FL                (0x00000020)    /* writes to file may only append */
7921 -#define OCFS2_NODUMP_FL                (0x00000040)    /* do not dump file */
7922 -#define OCFS2_NOATIME_FL       (0x00000080)    /* do not update atime */
7923 -#define OCFS2_DIRSYNC_FL       (0x00010000)    /* dirsync behaviour (directories only) */
7924 +#define OCFS2_SECRM_FL         FS_SECRM_FL     /* Secure deletion */
7925 +#define OCFS2_UNRM_FL          FS_UNRM_FL      /* Undelete */
7926 +#define OCFS2_COMPR_FL         FS_COMPR_FL     /* Compress file */
7927 +#define OCFS2_SYNC_FL          FS_SYNC_FL      /* Synchronous updates */
7928 +#define OCFS2_IMMUTABLE_FL     FS_IMMUTABLE_FL /* Immutable file */
7929 +#define OCFS2_APPEND_FL                FS_APPEND_FL    /* writes to file may only append */
7930 +#define OCFS2_NODUMP_FL                FS_NODUMP_FL    /* do not dump file */
7931 +#define OCFS2_NOATIME_FL       FS_NOATIME_FL   /* do not update atime */
7932  
7933 -#define OCFS2_FL_VISIBLE       (0x000100FF)    /* User visible flags */
7934 -#define OCFS2_FL_MODIFIABLE    (0x000100FF)    /* User modifiable flags */
7935 +#define OCFS2_DIRSYNC_FL       FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
7936 +#define OCFS2_IXUNLINK_FL      FS_IXUNLINK_FL  /* Immutable invert on unlink */
7937 +
7938 +#define OCFS2_BARRIER_FL       FS_BARRIER_FL   /* Barrier for chroot() */
7939 +#define OCFS2_COW_FL           FS_COW_FL       /* Copy on Write marker */
7940 +
7941 +#define OCFS2_FL_VISIBLE       (0x010300FF)    /* User visible flags */
7942 +#define OCFS2_FL_MODIFIABLE    (0x010300FF)    /* User modifiable flags */
7943  
7944  /*
7945   * Extent record flags (e_node.leaf.flags)
7946 diff -NurpP --minimal linux-2.6.35.2/fs/ocfs2/ocfs2.h linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/ocfs2.h
7947 --- linux-2.6.35.2/fs/ocfs2/ocfs2.h     2010-08-02 16:52:51.000000000 +0200
7948 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/ocfs2.h       2010-08-02 17:05:06.000000000 +0200
7949 @@ -256,6 +256,7 @@ enum ocfs2_mount_options
7950                                                    control lists */
7951         OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
7952         OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
7953 +       OCFS2_MOUNT_TAGGED = 1 << 12, /* use tagging */
7954  };
7955  
7956  #define OCFS2_OSB_SOFT_RO                      0x0001
7957 diff -NurpP --minimal linux-2.6.35.2/fs/ocfs2/super.c linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/super.c
7958 --- linux-2.6.35.2/fs/ocfs2/super.c     2010-08-02 16:52:51.000000000 +0200
7959 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/ocfs2/super.c       2010-08-02 18:00:11.000000000 +0200
7960 @@ -180,6 +180,7 @@ enum {
7961         Opt_grpquota,
7962         Opt_resv_level,
7963         Opt_dir_resv_level,
7964 +       Opt_tag, Opt_notag, Opt_tagid,
7965         Opt_err,
7966  };
7967  
7968 @@ -208,6 +209,9 @@ static const match_table_t tokens = {
7969         {Opt_grpquota, "grpquota"},
7970         {Opt_resv_level, "resv_level=%u"},
7971         {Opt_dir_resv_level, "dir_resv_level=%u"},
7972 +       {Opt_tag, "tag"},
7973 +       {Opt_notag, "notag"},
7974 +       {Opt_tagid, "tagid=%u"},
7975         {Opt_err, NULL}
7976  };
7977  
7978 @@ -618,6 +622,13 @@ static int ocfs2_remount(struct super_bl
7979                 goto out;
7980         }
7981  
7982 +       if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
7983 +           (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
7984 +               ret = -EINVAL;
7985 +               mlog(ML_ERROR, "Cannot change tagging on remount\n");
7986 +               goto out;
7987 +       }
7988 +
7989         if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
7990             (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
7991                 ret = -EINVAL;
7992 @@ -1154,6 +1165,9 @@ static int ocfs2_fill_super(struct super
7993  
7994         ocfs2_complete_mount_recovery(osb);
7995  
7996 +       if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
7997 +               sb->s_flags |= MS_TAGGED;
7998 +
7999         if (ocfs2_mount_local(osb))
8000                 snprintf(nodestr, sizeof(nodestr), "local");
8001         else
8002 @@ -1469,6 +1483,20 @@ static int ocfs2_parse_options(struct su
8003                             option < OCFS2_MAX_RESV_LEVEL)
8004                                 mopt->dir_resv_level = option;
8005                         break;
8006 +#ifndef CONFIG_TAGGING_NONE
8007 +               case Opt_tag:
8008 +                       mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8009 +                       break;
8010 +               case Opt_notag:
8011 +                       mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
8012 +                       break;
8013 +#endif
8014 +#ifdef CONFIG_PROPAGATE
8015 +               case Opt_tagid:
8016 +                       /* use args[0] */
8017 +                       mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8018 +                       break;
8019 +#endif
8020                 default:
8021                         mlog(ML_ERROR,
8022                              "Unrecognized mount option \"%s\" "
8023 diff -NurpP --minimal linux-2.6.35.2/fs/open.c linux-2.6.35.2-vs2.3.0.36.31/fs/open.c
8024 --- linux-2.6.35.2/fs/open.c    2010-08-02 16:52:51.000000000 +0200
8025 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/open.c      2010-08-02 21:36:22.000000000 +0200
8026 @@ -29,6 +29,11 @@
8027  #include <linux/falloc.h>
8028  #include <linux/fs_struct.h>
8029  #include <linux/ima.h>
8030 +#include <linux/vs_base.h>
8031 +#include <linux/vs_limit.h>
8032 +#include <linux/vs_tag.h>
8033 +#include <linux/vs_cowbl.h>
8034 +#include <linux/vserver/dlimit.h>
8035  
8036  #include "internal.h"
8037  
8038 @@ -481,6 +486,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
8039         error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
8040         if (error)
8041                 goto out;
8042 +
8043 +#ifdef CONFIG_VSERVER_COWBL
8044 +       error = cow_check_and_break(&path);
8045 +       if (error)
8046 +               goto dput_and_out;
8047 +#endif
8048         inode = path.dentry->d_inode;
8049  
8050         error = mnt_want_write(path.mnt);
8051 @@ -518,11 +529,11 @@ static int chown_common(struct path *pat
8052         newattrs.ia_valid =  ATTR_CTIME;
8053         if (user != (uid_t) -1) {
8054                 newattrs.ia_valid |= ATTR_UID;
8055 -               newattrs.ia_uid = user;
8056 +               newattrs.ia_uid = dx_map_uid(user);
8057         }
8058         if (group != (gid_t) -1) {
8059                 newattrs.ia_valid |= ATTR_GID;
8060 -               newattrs.ia_gid = group;
8061 +               newattrs.ia_gid = dx_map_gid(group);
8062         }
8063         if (!S_ISDIR(inode->i_mode))
8064                 newattrs.ia_valid |=
8065 @@ -547,6 +558,10 @@ SYSCALL_DEFINE3(chown, const char __user
8066         error = mnt_want_write(path.mnt);
8067         if (error)
8068                 goto out_release;
8069 +#ifdef CONFIG_VSERVER_COWBL
8070 +       error = cow_check_and_break(&path);
8071 +       if (!error)
8072 +#endif
8073         error = chown_common(&path, user, group);
8074         mnt_drop_write(path.mnt);
8075  out_release:
8076 @@ -572,6 +587,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
8077         error = mnt_want_write(path.mnt);
8078         if (error)
8079                 goto out_release;
8080 +#ifdef CONFIG_VSERVER_COWBL
8081 +       error = cow_check_and_break(&path);
8082 +       if (!error)
8083 +#endif
8084         error = chown_common(&path, user, group);
8085         mnt_drop_write(path.mnt);
8086  out_release:
8087 @@ -591,6 +610,10 @@ SYSCALL_DEFINE3(lchown, const char __use
8088         error = mnt_want_write(path.mnt);
8089         if (error)
8090                 goto out_release;
8091 +#ifdef CONFIG_VSERVER_COWBL
8092 +       error = cow_check_and_break(&path);
8093 +       if (!error)
8094 +#endif
8095         error = chown_common(&path, user, group);
8096         mnt_drop_write(path.mnt);
8097  out_release:
8098 @@ -837,6 +860,7 @@ static void __put_unused_fd(struct files
8099         __FD_CLR(fd, fdt->open_fds);
8100         if (fd < files->next_fd)
8101                 files->next_fd = fd;
8102 +       vx_openfd_dec(fd);
8103  }
8104  
8105  void put_unused_fd(unsigned int fd)
8106 diff -NurpP --minimal linux-2.6.35.2/fs/proc/array.c linux-2.6.35.2-vs2.3.0.36.31/fs/proc/array.c
8107 --- linux-2.6.35.2/fs/proc/array.c      2010-08-02 16:52:51.000000000 +0200
8108 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/proc/array.c        2010-08-02 17:05:06.000000000 +0200
8109 @@ -81,6 +81,8 @@
8110  #include <linux/pid_namespace.h>
8111  #include <linux/ptrace.h>
8112  #include <linux/tracehook.h>
8113 +#include <linux/vs_context.h>
8114 +#include <linux/vs_network.h>
8115  
8116  #include <asm/pgtable.h>
8117  #include <asm/processor.h>
8118 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
8119         rcu_read_lock();
8120         ppid = pid_alive(p) ?
8121                 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
8122 +       if (unlikely(vx_current_initpid(p->pid)))
8123 +               ppid = 0;
8124 +
8125         tpid = 0;
8126         if (pid_alive(p)) {
8127                 struct task_struct *tracer = tracehook_tracer_task(p);
8128 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
8129  }
8130  
8131  static void render_cap_t(struct seq_file *m, const char *header,
8132 -                       kernel_cap_t *a)
8133 +                       struct vx_info *vxi, kernel_cap_t *a)
8134  {
8135         unsigned __capi;
8136  
8137 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
8138         cap_bset        = cred->cap_bset;
8139         rcu_read_unlock();
8140  
8141 -       render_cap_t(m, "CapInh:\t", &cap_inheritable);
8142 -       render_cap_t(m, "CapPrm:\t", &cap_permitted);
8143 -       render_cap_t(m, "CapEff:\t", &cap_effective);
8144 -       render_cap_t(m, "CapBnd:\t", &cap_bset);
8145 +       /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
8146 +       render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
8147 +       render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
8148 +       render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
8149 +       render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
8150  }
8151  
8152  static inline void task_context_switch_counts(struct seq_file *m,
8153 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
8154         seq_printf(m, "\n");
8155  }
8156  
8157 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8158 +                       struct pid *pid, struct task_struct *task)
8159 +{
8160 +       seq_printf(m,   "Proxy:\t%p(%c)\n"
8161 +                       "Count:\t%u\n"
8162 +                       "uts:\t%p(%c)\n"
8163 +                       "ipc:\t%p(%c)\n"
8164 +                       "mnt:\t%p(%c)\n"
8165 +                       "pid:\t%p(%c)\n"
8166 +                       "net:\t%p(%c)\n",
8167 +                       task->nsproxy,
8168 +                       (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
8169 +                       atomic_read(&task->nsproxy->count),
8170 +                       task->nsproxy->uts_ns,
8171 +                       (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
8172 +                       task->nsproxy->ipc_ns,
8173 +                       (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
8174 +                       task->nsproxy->mnt_ns,
8175 +                       (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
8176 +                       task->nsproxy->pid_ns,
8177 +                       (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
8178 +                       task->nsproxy->net_ns,
8179 +                       (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
8180 +       return 0;
8181 +}
8182 +
8183 +void task_vs_id(struct seq_file *m, struct task_struct *task)
8184 +{
8185 +       if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8186 +               return;
8187 +
8188 +       seq_printf(m, "VxID: %d\n", vx_task_xid(task));
8189 +       seq_printf(m, "NxID: %d\n", nx_task_nid(task));
8190 +}
8191 +
8192 +
8193  int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
8194                         struct pid *pid, struct task_struct *task)
8195  {
8196 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m, 
8197         task_cap(m, task);
8198         task_cpus_allowed(m, task);
8199         cpuset_task_status_allowed(m, task);
8200 +       task_vs_id(m, task);
8201  #if defined(CONFIG_S390)
8202         task_show_regs(m, task);
8203  #endif
8204 @@ -465,6 +508,17 @@ static int do_task_stat(struct seq_file 
8205         /* convert nsec -> ticks */
8206         start_time = nsec_to_clock_t(start_time);
8207  
8208 +       /* fixup start time for virt uptime */
8209 +       if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8210 +               unsigned long long bias =
8211 +                       current->vx_info->cvirt.bias_clock;
8212 +
8213 +               if (start_time > bias)
8214 +                       start_time -= bias;
8215 +               else
8216 +                       start_time = 0;
8217 +       }
8218 +
8219         seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
8220  %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8221  %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
8222 diff -NurpP --minimal linux-2.6.35.2/fs/proc/base.c linux-2.6.35.2-vs2.3.0.36.31/fs/proc/base.c
8223 --- linux-2.6.35.2/fs/proc/base.c       2010-08-02 16:52:51.000000000 +0200
8224 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/proc/base.c 2010-08-02 17:05:06.000000000 +0200
8225 @@ -82,6 +82,8 @@
8226  #include <linux/pid_namespace.h>
8227  #include <linux/fs_struct.h>
8228  #include <linux/slab.h>
8229 +#include <linux/vs_context.h>
8230 +#include <linux/vs_network.h>
8231  #include "internal.h"
8232  
8233  /* NOTE:
8234 @@ -1033,12 +1035,17 @@ static ssize_t oom_adjust_write(struct f
8235                 return -ESRCH;
8236         }
8237  
8238 -       if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
8239 +       if (oom_adjust < task->signal->oom_adj &&
8240 +               !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
8241                 unlock_task_sighand(task, &flags);
8242                 put_task_struct(task);
8243                 return -EACCES;
8244         }
8245  
8246 +       /* prevent guest processes from circumventing the oom killer */
8247 +       if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
8248 +               oom_adjust = OOM_ADJUST_MIN;
8249 +
8250         task->signal->oom_adj = oom_adjust;
8251  
8252         unlock_task_sighand(task, &flags);
8253 @@ -1079,7 +1086,7 @@ static ssize_t proc_loginuid_write(struc
8254         ssize_t length;
8255         uid_t loginuid;
8256  
8257 -       if (!capable(CAP_AUDIT_CONTROL))
8258 +       if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
8259                 return -EPERM;
8260  
8261         rcu_read_lock();
8262 @@ -1517,6 +1524,8 @@ static struct inode *proc_pid_make_inode
8263                 inode->i_gid = cred->egid;
8264                 rcu_read_unlock();
8265         }
8266 +       /* procfs is xid tagged */
8267 +       inode->i_tag = (tag_t)vx_task_xid(task);
8268         security_task_to_inode(task, inode);
8269  
8270  out:
8271 @@ -2067,6 +2076,13 @@ static struct dentry *proc_pident_lookup
8272         if (!task)
8273                 goto out_no_task;
8274  
8275 +       /* TODO: maybe we can come up with a generic approach? */
8276 +       if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8277 +               (dentry->d_name.len == 5) &&
8278 +               (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8279 +               !memcmp(dentry->d_name.name, "ninfo", 5)))
8280 +               goto out;
8281 +
8282         /*
8283          * Yes, it does not scale. And it should not. Don't add
8284          * new entries into /proc/<tgid>/ without very good reasons.
8285 @@ -2474,7 +2490,7 @@ out_iput:
8286  static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8287  {
8288         struct dentry *error;
8289 -       struct task_struct *task = get_proc_task(dir);
8290 +       struct task_struct *task = get_proc_task_real(dir);
8291         const struct pid_entry *p, *last;
8292  
8293         error = ERR_PTR(-ENOENT);
8294 @@ -2564,6 +2580,9 @@ static int proc_pid_personality(struct s
8295  static const struct file_operations proc_task_operations;
8296  static const struct inode_operations proc_task_inode_operations;
8297  
8298 +extern int proc_pid_vx_info(struct task_struct *, char *);
8299 +extern int proc_pid_nx_info(struct task_struct *, char *);
8300 +
8301  static const struct pid_entry tgid_base_stuff[] = {
8302         DIR("task",       S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
8303         DIR("fd",         S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
8304 @@ -2623,6 +2642,8 @@ static const struct pid_entry tgid_base_
8305  #ifdef CONFIG_CGROUPS
8306         REG("cgroup",  S_IRUGO, proc_cgroup_operations),
8307  #endif
8308 +       INF("vinfo",      S_IRUGO, proc_pid_vx_info),
8309 +       INF("ninfo",      S_IRUGO, proc_pid_nx_info),
8310         INF("oom_score",  S_IRUGO, proc_oom_score),
8311         REG("oom_adj",    S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
8312  #ifdef CONFIG_AUDITSYSCALL
8313 @@ -2638,6 +2659,7 @@ static const struct pid_entry tgid_base_
8314  #ifdef CONFIG_TASK_IO_ACCOUNTING
8315         INF("io",       S_IRUGO, proc_tgid_io_accounting),
8316  #endif
8317 +       ONE("nsproxy",  S_IRUGO, proc_pid_nsproxy),
8318  };
8319  
8320  static int proc_tgid_base_readdir(struct file * filp,
8321 @@ -2829,7 +2851,7 @@ retry:
8322         iter.task = NULL;
8323         pid = find_ge_pid(iter.tgid, ns);
8324         if (pid) {
8325 -               iter.tgid = pid_nr_ns(pid, ns);
8326 +               iter.tgid = pid_unmapped_nr_ns(pid, ns);
8327                 iter.task = pid_task(pid, PIDTYPE_PID);
8328                 /* What we to know is if the pid we have find is the
8329                  * pid of a thread_group_leader.  Testing for task
8330 @@ -2859,7 +2881,7 @@ static int proc_pid_fill_cache(struct fi
8331         struct tgid_iter iter)
8332  {
8333         char name[PROC_NUMBUF];
8334 -       int len = snprintf(name, sizeof(name), "%d", iter.tgid);
8335 +       int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
8336         return proc_fill_cache(filp, dirent, filldir, name, len,
8337                                 proc_pid_instantiate, iter.task, NULL);
8338  }
8339 @@ -2868,7 +2890,7 @@ static int proc_pid_fill_cache(struct fi
8340  int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8341  {
8342         unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8343 -       struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8344 +       struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8345         struct tgid_iter iter;
8346         struct pid_namespace *ns;
8347  
8348 @@ -2888,6 +2910,8 @@ int proc_pid_readdir(struct file * filp,
8349              iter.task;
8350              iter.tgid += 1, iter = next_tgid(ns, iter)) {
8351                 filp->f_pos = iter.tgid + TGID_OFFSET;
8352 +               if (!vx_proc_task_visible(iter.task))
8353 +                       continue;
8354                 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
8355                         put_task_struct(iter.task);
8356                         goto out;
8357 @@ -3035,6 +3059,8 @@ static struct dentry *proc_task_lookup(s
8358         tid = name_to_int(dentry);
8359         if (tid == ~0U)
8360                 goto out;
8361 +       if (vx_current_initpid(tid))
8362 +               goto out;
8363  
8364         ns = dentry->d_sb->s_fs_info;
8365         rcu_read_lock();
8366 diff -NurpP --minimal linux-2.6.35.2/fs/proc/generic.c linux-2.6.35.2-vs2.3.0.36.31/fs/proc/generic.c
8367 --- linux-2.6.35.2/fs/proc/generic.c    2010-08-02 16:52:51.000000000 +0200
8368 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/proc/generic.c      2010-08-02 17:05:06.000000000 +0200
8369 @@ -21,6 +21,7 @@
8370  #include <linux/bitops.h>
8371  #include <linux/spinlock.h>
8372  #include <linux/completion.h>
8373 +#include <linux/vserver/inode.h>
8374  #include <asm/uaccess.h>
8375  
8376  #include "internal.h"
8377 @@ -418,6 +419,8 @@ struct dentry *proc_lookup_de(struct pro
8378         for (de = de->subdir; de ; de = de->next) {
8379                 if (de->namelen != dentry->d_name.len)
8380                         continue;
8381 +                       if (!vx_hide_check(0, de->vx_flags))
8382 +                               continue;
8383                 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8384                         unsigned int ino;
8385  
8386 @@ -426,6 +429,8 @@ struct dentry *proc_lookup_de(struct pro
8387                         spin_unlock(&proc_subdir_lock);
8388                         error = -EINVAL;
8389                         inode = proc_get_inode(dir->i_sb, ino, de);
8390 +                               /* generic proc entries belong to the host */
8391 +                               inode->i_tag = 0;
8392                         goto out_unlock;
8393                 }
8394         }
8395 @@ -503,6 +508,8 @@ int proc_readdir_de(struct proc_dir_entr
8396  
8397                                 /* filldir passes info to user space */
8398                                 pde_get(de);
8399 +                               if (!vx_hide_check(0, de->vx_flags))
8400 +                                       goto skip;
8401                                 spin_unlock(&proc_subdir_lock);
8402                                 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8403                                             de->low_ino, de->mode >> 12) < 0) {
8404 @@ -510,6 +517,7 @@ int proc_readdir_de(struct proc_dir_entr
8405                                         goto out;
8406                                 }
8407                                 spin_lock(&proc_subdir_lock);
8408 +                       skip:
8409                                 filp->f_pos++;
8410                                 next = de->next;
8411                                 pde_put(de);
8412 @@ -624,6 +632,7 @@ static struct proc_dir_entry *__proc_cre
8413         ent->nlink = nlink;
8414         atomic_set(&ent->count, 1);
8415         ent->pde_users = 0;
8416 +       ent->vx_flags = IATTR_PROC_DEFAULT;
8417         spin_lock_init(&ent->pde_unload_lock);
8418         ent->pde_unload_completion = NULL;
8419         INIT_LIST_HEAD(&ent->pde_openers);
8420 @@ -647,7 +656,8 @@ struct proc_dir_entry *proc_symlink(cons
8421                                 kfree(ent->data);
8422                                 kfree(ent);
8423                                 ent = NULL;
8424 -                       }
8425 +                       } else
8426 +                               ent->vx_flags = IATTR_PROC_SYMLINK;
8427                 } else {
8428                         kfree(ent);
8429                         ent = NULL;
8430 diff -NurpP --minimal linux-2.6.35.2/fs/proc/inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/proc/inode.c
8431 --- linux-2.6.35.2/fs/proc/inode.c      2010-08-02 16:52:51.000000000 +0200
8432 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/proc/inode.c        2010-08-02 17:05:06.000000000 +0200
8433 @@ -437,6 +437,8 @@ struct inode *proc_get_inode(struct supe
8434                         inode->i_uid = de->uid;
8435                         inode->i_gid = de->gid;
8436                 }
8437 +               if (de->vx_flags)
8438 +                       PROC_I(inode)->vx_flags = de->vx_flags;
8439                 if (de->size)
8440                         inode->i_size = de->size;
8441                 if (de->nlink)
8442 diff -NurpP --minimal linux-2.6.35.2/fs/proc/internal.h linux-2.6.35.2-vs2.3.0.36.31/fs/proc/internal.h
8443 --- linux-2.6.35.2/fs/proc/internal.h   2010-02-25 11:52:06.000000000 +0100
8444 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/proc/internal.h     2010-08-02 17:05:06.000000000 +0200
8445 @@ -10,6 +10,7 @@
8446   */
8447  
8448  #include <linux/proc_fs.h>
8449 +#include <linux/vs_pid.h>
8450  
8451  extern struct proc_dir_entry proc_root;
8452  #ifdef CONFIG_PROC_SYSCTL
8453 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
8454                                 struct pid *pid, struct task_struct *task);
8455  extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
8456                                 struct pid *pid, struct task_struct *task);
8457 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8458 +                               struct pid *pid, struct task_struct *task);
8459 +
8460  extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
8461  
8462  extern const struct file_operations proc_maps_operations;
8463 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
8464         return PROC_I(inode)->pid;
8465  }
8466  
8467 -static inline struct task_struct *get_proc_task(struct inode *inode)
8468 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
8469  {
8470         return get_pid_task(proc_pid(inode), PIDTYPE_PID);
8471  }
8472  
8473 +static inline struct task_struct *get_proc_task(struct inode *inode)
8474 +{
8475 +       return vx_get_proc_task(inode, proc_pid(inode));
8476 +}
8477 +
8478  static inline int proc_fd(struct inode *inode)
8479  {
8480         return PROC_I(inode)->fd;
8481 diff -NurpP --minimal linux-2.6.35.2/fs/proc/loadavg.c linux-2.6.35.2-vs2.3.0.36.31/fs/proc/loadavg.c
8482 --- linux-2.6.35.2/fs/proc/loadavg.c    2009-09-10 15:26:23.000000000 +0200
8483 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/proc/loadavg.c      2010-08-02 17:05:06.000000000 +0200
8484 @@ -12,15 +12,27 @@
8485  
8486  static int loadavg_proc_show(struct seq_file *m, void *v)
8487  {
8488 +       unsigned long running;
8489 +       unsigned int threads;
8490         unsigned long avnrun[3];
8491  
8492         get_avenrun(avnrun, FIXED_1/200, 0);
8493  
8494 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
8495 +               struct vx_info *vxi = current_vx_info();
8496 +
8497 +               running = atomic_read(&vxi->cvirt.nr_running);
8498 +               threads = atomic_read(&vxi->cvirt.nr_threads);
8499 +       } else {
8500 +               running = nr_running();
8501 +               threads = nr_threads;
8502 +       }
8503 +
8504         seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
8505                 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
8506                 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
8507                 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
8508 -               nr_running(), nr_threads,
8509 +               running, threads,
8510                 task_active_pid_ns(current)->last_pid);
8511         return 0;
8512  }
8513 diff -NurpP --minimal linux-2.6.35.2/fs/proc/meminfo.c linux-2.6.35.2-vs2.3.0.36.31/fs/proc/meminfo.c
8514 --- linux-2.6.35.2/fs/proc/meminfo.c    2009-12-03 20:02:53.000000000 +0100
8515 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/proc/meminfo.c      2010-08-02 17:05:06.000000000 +0200
8516 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
8517         allowed = ((totalram_pages - hugetlb_total_pages())
8518                 * sysctl_overcommit_ratio / 100) + total_swap_pages;
8519  
8520 -       cached = global_page_state(NR_FILE_PAGES) -
8521 +       cached = vx_flags(VXF_VIRT_MEM, 0) ?
8522 +               vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
8523                         total_swapcache_pages - i.bufferram;
8524         if (cached < 0)
8525                 cached = 0;
8526 diff -NurpP --minimal linux-2.6.35.2/fs/proc/root.c linux-2.6.35.2-vs2.3.0.36.31/fs/proc/root.c
8527 --- linux-2.6.35.2/fs/proc/root.c       2010-08-02 16:52:51.000000000 +0200
8528 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/proc/root.c 2010-08-02 17:05:06.000000000 +0200
8529 @@ -18,9 +18,14 @@
8530  #include <linux/bitops.h>
8531  #include <linux/mount.h>
8532  #include <linux/pid_namespace.h>
8533 +#include <linux/vserver/inode.h>
8534  
8535  #include "internal.h"
8536  
8537 +struct proc_dir_entry *proc_virtual;
8538 +
8539 +extern void proc_vx_init(void);
8540 +
8541  static int proc_test_super(struct super_block *sb, void *data)
8542  {
8543         return sb->s_fs_info == data;
8544 @@ -135,6 +140,7 @@ void __init proc_root_init(void)
8545  #endif
8546         proc_mkdir("bus", NULL);
8547         proc_sys_init();
8548 +       proc_vx_init();
8549  }
8550  
8551  static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
8552 @@ -202,6 +208,7 @@ struct proc_dir_entry proc_root = {
8553         .proc_iops      = &proc_root_inode_operations, 
8554         .proc_fops      = &proc_root_operations,
8555         .parent         = &proc_root,
8556 +       .vx_flags       = IATTR_ADMIN | IATTR_WATCH,
8557  };
8558  
8559  int pid_ns_prepare_proc(struct pid_namespace *ns)
8560 diff -NurpP --minimal linux-2.6.35.2/fs/proc/uptime.c linux-2.6.35.2-vs2.3.0.36.31/fs/proc/uptime.c
8561 --- linux-2.6.35.2/fs/proc/uptime.c     2009-12-03 20:02:53.000000000 +0100
8562 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/proc/uptime.c       2010-08-02 17:05:06.000000000 +0200
8563 @@ -4,22 +4,22 @@
8564  #include <linux/sched.h>
8565  #include <linux/seq_file.h>
8566  #include <linux/time.h>
8567 -#include <linux/kernel_stat.h>
8568 +#include <linux/vserver/cvirt.h>
8569  #include <asm/cputime.h>
8570  
8571  static int uptime_proc_show(struct seq_file *m, void *v)
8572  {
8573         struct timespec uptime;
8574         struct timespec idle;
8575 -       int i;
8576 -       cputime_t idletime = cputime_zero;
8577 -
8578 -       for_each_possible_cpu(i)
8579 -               idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
8580 +       cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
8581  
8582         do_posix_clock_monotonic_gettime(&uptime);
8583         monotonic_to_bootbased(&uptime);
8584         cputime_to_timespec(idletime, &idle);
8585 +
8586 +       if (vx_flags(VXF_VIRT_UPTIME, 0))
8587 +               vx_vsi_uptime(&uptime, &idle);
8588 +
8589         seq_printf(m, "%lu.%02lu %lu.%02lu\n",
8590                         (unsigned long) uptime.tv_sec,
8591                         (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
8592 diff -NurpP --minimal linux-2.6.35.2/fs/quota/dquot.c linux-2.6.35.2-vs2.3.0.36.31/fs/quota/dquot.c
8593 --- linux-2.6.35.2/fs/quota/dquot.c     2010-08-02 16:52:51.000000000 +0200
8594 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/quota/dquot.c       2010-08-02 22:36:48.000000000 +0200
8595 @@ -1503,6 +1503,9 @@ int __dquot_alloc_space(struct inode *in
8596         int reserve = flags & DQUOT_SPACE_RESERVE;
8597         int nofail = flags & DQUOT_SPACE_NOFAIL;
8598  
8599 +       if ((ret = dl_alloc_space(inode, number)))
8600 +               return ret;
8601 +
8602         /*
8603          * First test before acquiring mutex - solves deadlocks when we
8604          * re-enter the quota code and are already holding the mutex
8605 @@ -1557,6 +1560,9 @@ int dquot_alloc_inode(const struct inode
8606         int cnt, ret = 0;
8607         char warntype[MAXQUOTAS];
8608  
8609 +       if ((ret = dl_alloc_inode(inode)))
8610 +               return ret;
8611 +
8612         /* First test before acquiring mutex - solves deadlocks when we
8613           * re-enter the quota code and are already holding the mutex */
8614         if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
8615 @@ -1627,6 +1633,8 @@ void __dquot_free_space(struct inode *in
8616         char warntype[MAXQUOTAS];
8617         int reserve = flags & DQUOT_SPACE_RESERVE;
8618  
8619 +       dl_free_space(inode, number);
8620 +
8621         /* First test before acquiring mutex - solves deadlocks when we
8622           * re-enter the quota code and are already holding the mutex */
8623         if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode)) {
8624 @@ -1665,6 +1673,8 @@ void dquot_free_inode(const struct inode
8625         unsigned int cnt;
8626         char warntype[MAXQUOTAS];
8627  
8628 +       dl_free_inode(inode);
8629 +
8630         /* First test before acquiring mutex - solves deadlocks when we
8631           * re-enter the quota code and are already holding the mutex */
8632         if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
8633 diff -NurpP --minimal linux-2.6.35.2/fs/quota/quota.c linux-2.6.35.2-vs2.3.0.36.31/fs/quota/quota.c
8634 --- linux-2.6.35.2/fs/quota/quota.c     2010-08-02 16:52:51.000000000 +0200
8635 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/quota/quota.c       2010-08-02 17:05:06.000000000 +0200
8636 @@ -8,6 +8,7 @@
8637  #include <linux/fs.h>
8638  #include <linux/namei.h>
8639  #include <linux/slab.h>
8640 +#include <linux/vs_context.h>
8641  #include <asm/current.h>
8642  #include <asm/uaccess.h>
8643  #include <linux/kernel.h>
8644 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
8645                         break;
8646                 /*FALLTHROUGH*/
8647         default:
8648 -               if (!capable(CAP_SYS_ADMIN))
8649 +               if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8650                         return -EPERM;
8651         }
8652  
8653 @@ -296,6 +297,46 @@ static int do_quotactl(struct super_bloc
8654         }
8655  }
8656  
8657 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8658 +
8659 +#include <linux/vroot.h>
8660 +#include <linux/major.h>
8661 +#include <linux/module.h>
8662 +#include <linux/kallsyms.h>
8663 +#include <linux/vserver/debug.h>
8664 +
8665 +static vroot_grb_func *vroot_get_real_bdev = NULL;
8666 +
8667 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
8668 +
8669 +int register_vroot_grb(vroot_grb_func *func) {
8670 +       int ret = -EBUSY;
8671 +
8672 +       spin_lock(&vroot_grb_lock);
8673 +       if (!vroot_get_real_bdev) {
8674 +               vroot_get_real_bdev = func;
8675 +               ret = 0;
8676 +       }
8677 +       spin_unlock(&vroot_grb_lock);
8678 +       return ret;
8679 +}
8680 +EXPORT_SYMBOL(register_vroot_grb);
8681 +
8682 +int unregister_vroot_grb(vroot_grb_func *func) {
8683 +       int ret = -EINVAL;
8684 +
8685 +       spin_lock(&vroot_grb_lock);
8686 +       if (vroot_get_real_bdev) {
8687 +               vroot_get_real_bdev = NULL;
8688 +               ret = 0;
8689 +       }
8690 +       spin_unlock(&vroot_grb_lock);
8691 +       return ret;
8692 +}
8693 +EXPORT_SYMBOL(unregister_vroot_grb);
8694 +
8695 +#endif
8696 +
8697  /*
8698   * look up a superblock on which quota ops will be performed
8699   * - use the name of a block device to find the superblock thereon
8700 @@ -313,6 +354,22 @@ static struct super_block *quotactl_bloc
8701         putname(tmp);
8702         if (IS_ERR(bdev))
8703                 return ERR_CAST(bdev);
8704 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8705 +       if (bdev && bdev->bd_inode &&
8706 +                       imajor(bdev->bd_inode) == VROOT_MAJOR) {
8707 +               struct block_device *bdnew = (void *)-EINVAL;
8708 +
8709 +               if (vroot_get_real_bdev)
8710 +                       bdnew = vroot_get_real_bdev(bdev);
8711 +               else
8712 +                       vxdprintk(VXD_CBIT(misc, 0),
8713 +                                       "vroot_get_real_bdev not set");
8714 +               bdput(bdev);
8715 +               if (IS_ERR(bdnew))
8716 +                       return ERR_PTR(PTR_ERR(bdnew));
8717 +               bdev = bdnew;
8718 +       }
8719 +#endif
8720         sb = get_super(bdev);
8721         bdput(bdev);
8722         if (!sb)
8723 diff -NurpP --minimal linux-2.6.35.2/fs/reiserfs/file.c linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/file.c
8724 --- linux-2.6.35.2/fs/reiserfs/file.c   2010-08-02 16:52:52.000000000 +0200
8725 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/file.c     2010-08-02 17:05:06.000000000 +0200
8726 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
8727         .listxattr = reiserfs_listxattr,
8728         .removexattr = reiserfs_removexattr,
8729         .permission = reiserfs_permission,
8730 +       .sync_flags = reiserfs_sync_flags,
8731  };
8732 diff -NurpP --minimal linux-2.6.35.2/fs/reiserfs/inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/inode.c
8733 --- linux-2.6.35.2/fs/reiserfs/inode.c  2010-08-02 16:52:52.000000000 +0200
8734 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/inode.c    2010-08-02 17:05:06.000000000 +0200
8735 @@ -19,6 +19,7 @@
8736  #include <linux/writeback.h>
8737  #include <linux/quotaops.h>
8738  #include <linux/swap.h>
8739 +#include <linux/vs_tag.h>
8740  
8741  int reiserfs_commit_write(struct file *f, struct page *page,
8742                           unsigned from, unsigned to);
8743 @@ -1125,6 +1126,8 @@ static void init_inode(struct inode *ino
8744         struct buffer_head *bh;
8745         struct item_head *ih;
8746         __u32 rdev;
8747 +       uid_t uid;
8748 +       gid_t gid;
8749         //int version = ITEM_VERSION_1;
8750  
8751         bh = PATH_PLAST_BUFFER(path);
8752 @@ -1146,12 +1149,13 @@ static void init_inode(struct inode *ino
8753                     (struct stat_data_v1 *)B_I_PITEM(bh, ih);
8754                 unsigned long blocks;
8755  
8756 +               uid = sd_v1_uid(sd);
8757 +               gid = sd_v1_gid(sd);
8758 +
8759                 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
8760                 set_inode_sd_version(inode, STAT_DATA_V1);
8761                 inode->i_mode = sd_v1_mode(sd);
8762                 inode->i_nlink = sd_v1_nlink(sd);
8763 -               inode->i_uid = sd_v1_uid(sd);
8764 -               inode->i_gid = sd_v1_gid(sd);
8765                 inode->i_size = sd_v1_size(sd);
8766                 inode->i_atime.tv_sec = sd_v1_atime(sd);
8767                 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
8768 @@ -1193,11 +1197,12 @@ static void init_inode(struct inode *ino
8769                 // (directories and symlinks)
8770                 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
8771  
8772 +               uid    = sd_v2_uid(sd);
8773 +               gid    = sd_v2_gid(sd);
8774 +
8775                 inode->i_mode = sd_v2_mode(sd);
8776                 inode->i_nlink = sd_v2_nlink(sd);
8777 -               inode->i_uid = sd_v2_uid(sd);
8778                 inode->i_size = sd_v2_size(sd);
8779 -               inode->i_gid = sd_v2_gid(sd);
8780                 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
8781                 inode->i_atime.tv_sec = sd_v2_atime(sd);
8782                 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
8783 @@ -1227,6 +1232,10 @@ static void init_inode(struct inode *ino
8784                 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
8785         }
8786  
8787 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8788 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8789 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
8790 +
8791         pathrelse(path);
8792         if (S_ISREG(inode->i_mode)) {
8793                 inode->i_op = &reiserfs_file_inode_operations;
8794 @@ -1249,13 +1258,15 @@ static void init_inode(struct inode *ino
8795  static void inode2sd(void *sd, struct inode *inode, loff_t size)
8796  {
8797         struct stat_data *sd_v2 = (struct stat_data *)sd;
8798 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
8799 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
8800         __u16 flags;
8801  
8802 +       set_sd_v2_uid(sd_v2, uid);
8803 +       set_sd_v2_gid(sd_v2, gid);
8804         set_sd_v2_mode(sd_v2, inode->i_mode);
8805         set_sd_v2_nlink(sd_v2, inode->i_nlink);
8806 -       set_sd_v2_uid(sd_v2, inode->i_uid);
8807         set_sd_v2_size(sd_v2, size);
8808 -       set_sd_v2_gid(sd_v2, inode->i_gid);
8809         set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
8810         set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
8811         set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
8812 @@ -2856,14 +2867,19 @@ int reiserfs_commit_write(struct file *f
8813  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
8814  {
8815         if (reiserfs_attrs(inode->i_sb)) {
8816 -               if (sd_attrs & REISERFS_SYNC_FL)
8817 -                       inode->i_flags |= S_SYNC;
8818 -               else
8819 -                       inode->i_flags &= ~S_SYNC;
8820                 if (sd_attrs & REISERFS_IMMUTABLE_FL)
8821                         inode->i_flags |= S_IMMUTABLE;
8822                 else
8823                         inode->i_flags &= ~S_IMMUTABLE;
8824 +               if (sd_attrs & REISERFS_IXUNLINK_FL)
8825 +                       inode->i_flags |= S_IXUNLINK;
8826 +               else
8827 +                       inode->i_flags &= ~S_IXUNLINK;
8828 +
8829 +               if (sd_attrs & REISERFS_SYNC_FL)
8830 +                       inode->i_flags |= S_SYNC;
8831 +               else
8832 +                       inode->i_flags &= ~S_SYNC;
8833                 if (sd_attrs & REISERFS_APPEND_FL)
8834                         inode->i_flags |= S_APPEND;
8835                 else
8836 @@ -2876,6 +2892,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
8837                         REISERFS_I(inode)->i_flags |= i_nopack_mask;
8838                 else
8839                         REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
8840 +
8841 +               if (sd_attrs & REISERFS_BARRIER_FL)
8842 +                       inode->i_vflags |= V_BARRIER;
8843 +               else
8844 +                       inode->i_vflags &= ~V_BARRIER;
8845 +               if (sd_attrs & REISERFS_COW_FL)
8846 +                       inode->i_vflags |= V_COW;
8847 +               else
8848 +                       inode->i_vflags &= ~V_COW;
8849         }
8850  }
8851  
8852 @@ -2886,6 +2911,11 @@ void i_attrs_to_sd_attrs(struct inode *i
8853                         *sd_attrs |= REISERFS_IMMUTABLE_FL;
8854                 else
8855                         *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
8856 +               if (inode->i_flags & S_IXUNLINK)
8857 +                       *sd_attrs |= REISERFS_IXUNLINK_FL;
8858 +               else
8859 +                       *sd_attrs &= ~REISERFS_IXUNLINK_FL;
8860 +
8861                 if (inode->i_flags & S_SYNC)
8862                         *sd_attrs |= REISERFS_SYNC_FL;
8863                 else
8864 @@ -2898,6 +2928,15 @@ void i_attrs_to_sd_attrs(struct inode *i
8865                         *sd_attrs |= REISERFS_NOTAIL_FL;
8866                 else
8867                         *sd_attrs &= ~REISERFS_NOTAIL_FL;
8868 +
8869 +               if (inode->i_vflags & V_BARRIER)
8870 +                       *sd_attrs |= REISERFS_BARRIER_FL;
8871 +               else
8872 +                       *sd_attrs &= ~REISERFS_BARRIER_FL;
8873 +               if (inode->i_vflags & V_COW)
8874 +                       *sd_attrs |= REISERFS_COW_FL;
8875 +               else
8876 +                       *sd_attrs &= ~REISERFS_COW_FL;
8877         }
8878  }
8879  
8880 @@ -3122,9 +3161,11 @@ int reiserfs_setattr(struct dentry *dent
8881         }
8882  
8883         error = inode_change_ok(inode, attr);
8884 +
8885         if (!error) {
8886                 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
8887 -                   (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
8888 +                   (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
8889 +                   (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
8890                         error = reiserfs_chown_xattrs(inode, attr);
8891  
8892                         if (!error) {
8893 @@ -3153,6 +3194,9 @@ int reiserfs_setattr(struct dentry *dent
8894                                         inode->i_uid = attr->ia_uid;
8895                                 if (attr->ia_valid & ATTR_GID)
8896                                         inode->i_gid = attr->ia_gid;
8897 +                               if ((attr->ia_valid & ATTR_TAG) &&
8898 +                                       IS_TAGGED(inode))
8899 +                                       inode->i_tag = attr->ia_tag;
8900                                 mark_inode_dirty(inode);
8901                                 error =
8902                                     journal_end(&th, inode->i_sb, jbegin_count);
8903 diff -NurpP --minimal linux-2.6.35.2/fs/reiserfs/ioctl.c linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/ioctl.c
8904 --- linux-2.6.35.2/fs/reiserfs/ioctl.c  2010-02-25 11:52:06.000000000 +0100
8905 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/ioctl.c    2010-08-02 17:05:06.000000000 +0200
8906 @@ -7,11 +7,27 @@
8907  #include <linux/mount.h>
8908  #include <linux/reiserfs_fs.h>
8909  #include <linux/time.h>
8910 +#include <linux/mount.h>
8911  #include <asm/uaccess.h>
8912  #include <linux/pagemap.h>
8913  #include <linux/smp_lock.h>
8914  #include <linux/compat.h>
8915  
8916 +
8917 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
8918 +{
8919 +       __u16 sd_attrs = 0;
8920 +
8921 +       inode->i_flags = flags;
8922 +       inode->i_vflags = vflags;
8923 +
8924 +       i_attrs_to_sd_attrs(inode, &sd_attrs);
8925 +       REISERFS_I(inode)->i_attrs = sd_attrs;
8926 +       inode->i_ctime = CURRENT_TIME_SEC;
8927 +       mark_inode_dirty(inode);
8928 +       return 0;
8929 +}
8930 +
8931  /*
8932   * reiserfs_ioctl - handler for ioctl for inode
8933   * supported commands:
8934 @@ -23,7 +39,7 @@
8935  long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
8936  {
8937         struct inode *inode = filp->f_path.dentry->d_inode;
8938 -       unsigned int flags;
8939 +       unsigned int flags, oldflags;
8940         int err = 0;
8941  
8942         reiserfs_write_lock(inode->i_sb);
8943 @@ -48,6 +64,7 @@ long reiserfs_ioctl(struct file *filp, u
8944  
8945                 flags = REISERFS_I(inode)->i_attrs;
8946                 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
8947 +               flags &= REISERFS_FL_USER_VISIBLE;
8948                 err = put_user(flags, (int __user *)arg);
8949                 break;
8950         case REISERFS_IOC_SETFLAGS:{
8951 @@ -68,6 +85,10 @@ long reiserfs_ioctl(struct file *filp, u
8952                                 err = -EFAULT;
8953                                 goto setflags_out;
8954                         }
8955 +                       if (IS_BARRIER(inode)) {
8956 +                               vxwprintk_task(1, "messing with the barrier.");
8957 +                               return -EACCES;
8958 +                       }
8959                         /*
8960                          * Is it quota file? Do not allow user to mess with it
8961                          */
8962 @@ -92,6 +113,10 @@ long reiserfs_ioctl(struct file *filp, u
8963                                         goto setflags_out;
8964                                 }
8965                         }
8966 +
8967 +                       oldflags = REISERFS_I(inode)->i_attrs;
8968 +                       flags &= REISERFS_FL_USER_MODIFIABLE;
8969 +                       flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
8970                         sd_attrs_to_i_attrs(flags, inode);
8971                         REISERFS_I(inode)->i_attrs = flags;
8972                         inode->i_ctime = CURRENT_TIME_SEC;
8973 diff -NurpP --minimal linux-2.6.35.2/fs/reiserfs/namei.c linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/namei.c
8974 --- linux-2.6.35.2/fs/reiserfs/namei.c  2010-08-02 16:52:52.000000000 +0200
8975 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/namei.c    2010-08-02 17:05:06.000000000 +0200
8976 @@ -18,6 +18,7 @@
8977  #include <linux/reiserfs_acl.h>
8978  #include <linux/reiserfs_xattr.h>
8979  #include <linux/quotaops.h>
8980 +#include <linux/vs_tag.h>
8981  
8982  #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; }
8983  #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
8984 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
8985         if (retval == IO_ERROR) {
8986                 return ERR_PTR(-EIO);
8987         }
8988 +               dx_propagate_tag(nd, inode);
8989  
8990         return d_splice_alias(inode, dentry);
8991  }
8992 @@ -1532,6 +1534,7 @@ const struct inode_operations reiserfs_d
8993         .listxattr = reiserfs_listxattr,
8994         .removexattr = reiserfs_removexattr,
8995         .permission = reiserfs_permission,
8996 +       .sync_flags = reiserfs_sync_flags,
8997  };
8998  
8999  /*
9000 diff -NurpP --minimal linux-2.6.35.2/fs/reiserfs/super.c linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/super.c
9001 --- linux-2.6.35.2/fs/reiserfs/super.c  2010-08-02 16:52:52.000000000 +0200
9002 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/super.c    2010-08-02 17:05:06.000000000 +0200
9003 @@ -897,6 +897,14 @@ static int reiserfs_parse_options(struct
9004                 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9005                 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9006  #endif
9007 +#ifndef CONFIG_TAGGING_NONE
9008 +               {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9009 +               {"tag",.setmask = 1 << REISERFS_TAGGED},
9010 +               {"notag",.clrmask = 1 << REISERFS_TAGGED},
9011 +#endif
9012 +#ifdef CONFIG_PROPAGATE
9013 +               {"tag",.arg_required = 'T',.values = NULL},
9014 +#endif
9015  #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9016                 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9017                 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9018 @@ -1206,6 +1214,14 @@ static int reiserfs_remount(struct super
9019         handle_quota_files(s, qf_names, &qfmt);
9020  #endif
9021  
9022 +       if ((mount_options & (1 << REISERFS_TAGGED)) &&
9023 +               !(s->s_flags & MS_TAGGED)) {
9024 +               reiserfs_warning(s, "super-vs01",
9025 +                       "reiserfs: tagging not permitted on remount.");
9026 +               err = -EINVAL;
9027 +               goto out_err;
9028 +       }
9029 +
9030         handle_attrs(s);
9031  
9032         /* Add options that are safe here */
9033 @@ -1688,6 +1704,10 @@ static int reiserfs_fill_super(struct su
9034                 goto error;
9035         }
9036  
9037 +       /* map mount option tagxid */
9038 +       if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9039 +               s->s_flags |= MS_TAGGED;
9040 +
9041         rs = SB_DISK_SUPER_BLOCK(s);
9042         /* Let's do basic sanity check to verify that underlying device is not
9043            smaller than the filesystem. If the check fails then abort and scream,
9044 diff -NurpP --minimal linux-2.6.35.2/fs/reiserfs/xattr.c linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/xattr.c
9045 --- linux-2.6.35.2/fs/reiserfs/xattr.c  2010-08-02 16:52:52.000000000 +0200
9046 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/reiserfs/xattr.c    2010-08-02 17:05:06.000000000 +0200
9047 @@ -40,6 +40,7 @@
9048  #include <linux/errno.h>
9049  #include <linux/gfp.h>
9050  #include <linux/fs.h>
9051 +#include <linux/mount.h>
9052  #include <linux/file.h>
9053  #include <linux/pagemap.h>
9054  #include <linux/xattr.h>
9055 diff -NurpP --minimal linux-2.6.35.2/fs/stat.c linux-2.6.35.2-vs2.3.0.36.31/fs/stat.c
9056 --- linux-2.6.35.2/fs/stat.c    2010-02-25 11:52:06.000000000 +0100
9057 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/stat.c      2010-08-02 17:05:06.000000000 +0200
9058 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9059         stat->nlink = inode->i_nlink;
9060         stat->uid = inode->i_uid;
9061         stat->gid = inode->i_gid;
9062 +       stat->tag = inode->i_tag;
9063         stat->rdev = inode->i_rdev;
9064         stat->atime = inode->i_atime;
9065         stat->mtime = inode->i_mtime;
9066 diff -NurpP --minimal linux-2.6.35.2/fs/statfs.c linux-2.6.35.2-vs2.3.0.36.31/fs/statfs.c
9067 --- linux-2.6.35.2/fs/statfs.c  2010-08-02 16:52:52.000000000 +0200
9068 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/statfs.c    2010-08-02 19:10:27.000000000 +0200
9069 @@ -6,22 +6,28 @@
9070  #include <linux/statfs.h>
9071  #include <linux/security.h>
9072  #include <linux/uaccess.h>
9073 +#include <linux/vs_base.h>
9074 +#include <linux/vs_dlimit.h>
9075  
9076  int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
9077  {
9078         int retval = -ENODEV;
9079  
9080         if (dentry) {
9081 +               struct super_block *sb = dentry->d_sb;
9082 +
9083                 retval = -ENOSYS;
9084 -               if (dentry->d_sb->s_op->statfs) {
9085 +               if (sb->s_op->statfs) {
9086                         memset(buf, 0, sizeof(*buf));
9087                         retval = security_sb_statfs(dentry);
9088                         if (retval)
9089                                 return retval;
9090 -                       retval = dentry->d_sb->s_op->statfs(dentry, buf);
9091 +                       retval = sb->s_op->statfs(dentry, buf);
9092                         if (retval == 0 && buf->f_frsize == 0)
9093                                 buf->f_frsize = buf->f_bsize;
9094                 }
9095 +               if (!vx_check(0, VS_ADMIN|VS_WATCH))
9096 +                       vx_vsi_statfs(sb, buf);
9097         }
9098         return retval;
9099  }
9100 diff -NurpP --minimal linux-2.6.35.2/fs/super.c linux-2.6.35.2-vs2.3.0.36.31/fs/super.c
9101 --- linux-2.6.35.2/fs/super.c   2010-08-14 18:16:59.000000000 +0200
9102 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/super.c     2010-08-14 18:20:34.000000000 +0200
9103 @@ -30,6 +30,9 @@
9104  #include <linux/idr.h>
9105  #include <linux/mutex.h>
9106  #include <linux/backing-dev.h>
9107 +#include <linux/devpts_fs.h>
9108 +#include <linux/proc_fs.h>
9109 +#include <linux/vs_context.h>
9110  #include "internal.h"
9111  
9112  
9113 @@ -885,12 +888,18 @@ struct vfsmount *
9114  vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9115  {
9116         struct vfsmount *mnt;
9117 +       struct super_block *sb;
9118         char *secdata = NULL;
9119         int error;
9120  
9121         if (!type)
9122                 return ERR_PTR(-ENODEV);
9123  
9124 +       error = -EPERM;
9125 +       if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9126 +               !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9127 +               goto out;
9128 +
9129         error = -ENOMEM;
9130         mnt = alloc_vfsmnt(name);
9131         if (!mnt)
9132 @@ -912,11 +921,19 @@ vfs_kern_mount(struct file_system_type *
9133         error = type->get_sb(type, flags, name, data, mnt);
9134         if (error < 0)
9135                 goto out_free_secdata;
9136 -       BUG_ON(!mnt->mnt_sb);
9137 -       WARN_ON(!mnt->mnt_sb->s_bdi);
9138 +
9139 +       sb = mnt->mnt_sb;
9140 +       BUG_ON(!sb);
9141 +       WARN_ON(!sb->s_bdi);
9142         mnt->mnt_sb->s_flags |= MS_BORN;
9143  
9144 -       error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
9145 +       error = -EPERM;
9146 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9147 +               (sb->s_magic != PROC_SUPER_MAGIC) &&
9148 +               (sb->s_magic != DEVPTS_SUPER_MAGIC))
9149 +               goto out_sb;
9150 +
9151 +       error = security_sb_kern_mount(sb, flags, secdata);
9152         if (error)
9153                 goto out_sb;
9154  
9155 diff -NurpP --minimal linux-2.6.35.2/fs/sysfs/mount.c linux-2.6.35.2-vs2.3.0.36.31/fs/sysfs/mount.c
9156 --- linux-2.6.35.2/fs/sysfs/mount.c     2010-08-02 16:52:52.000000000 +0200
9157 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/sysfs/mount.c       2010-08-02 17:05:06.000000000 +0200
9158 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
9159  
9160         sb->s_blocksize = PAGE_CACHE_SIZE;
9161         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9162 -       sb->s_magic = SYSFS_MAGIC;
9163 +       sb->s_magic = SYSFS_SUPER_MAGIC;
9164         sb->s_op = &sysfs_ops;
9165         sb->s_time_gran = 1;
9166  
9167 diff -NurpP --minimal linux-2.6.35.2/fs/utimes.c linux-2.6.35.2-vs2.3.0.36.31/fs/utimes.c
9168 --- linux-2.6.35.2/fs/utimes.c  2009-03-24 14:22:37.000000000 +0100
9169 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/utimes.c    2010-08-02 22:52:28.000000000 +0200
9170 @@ -8,6 +8,8 @@
9171  #include <linux/stat.h>
9172  #include <linux/utime.h>
9173  #include <linux/syscalls.h>
9174 +#include <linux/mount.h>
9175 +#include <linux/vs_cowbl.h>
9176  #include <asm/uaccess.h>
9177  #include <asm/unistd.h>
9178  
9179 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
9180  {
9181         int error;
9182         struct iattr newattrs;
9183 -       struct inode *inode = path->dentry->d_inode;
9184 +       struct inode *inode;
9185  
9186         error = mnt_want_write(path->mnt);
9187         if (error)
9188                 goto out;
9189  
9190 +       error = cow_check_and_break(path);
9191 +       if (error)
9192 +               goto mnt_drop_write_and_out;
9193 +
9194 +       inode = path->dentry->d_inode;
9195 +
9196         if (times && times[0].tv_nsec == UTIME_NOW &&
9197                      times[1].tv_nsec == UTIME_NOW)
9198                 times = NULL;
9199 diff -NurpP --minimal linux-2.6.35.2/fs/xattr.c linux-2.6.35.2-vs2.3.0.36.31/fs/xattr.c
9200 --- linux-2.6.35.2/fs/xattr.c   2010-08-02 16:52:52.000000000 +0200
9201 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xattr.c     2010-08-02 17:05:06.000000000 +0200
9202 @@ -18,6 +18,7 @@
9203  #include <linux/module.h>
9204  #include <linux/fsnotify.h>
9205  #include <linux/audit.h>
9206 +#include <linux/mount.h>
9207  #include <asm/uaccess.h>
9208  
9209  
9210 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
9211          * The trusted.* namespace can only be accessed by a privileged user.
9212          */
9213         if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
9214 -               return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
9215 +               return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
9216  
9217         /* In user.* namespace, only regular files and directories can have
9218          * extended attributes. For sticky directories, only the owner and
9219 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.c
9220 --- linux-2.6.35.2/fs/xfs/linux-2.6/xfs_ioctl.c 2010-08-02 16:52:52.000000000 +0200
9221 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.c   2010-08-02 17:05:06.000000000 +0200
9222 @@ -34,7 +34,6 @@
9223  #include "xfs_dir2_sf.h"
9224  #include "xfs_dinode.h"
9225  #include "xfs_inode.h"
9226 -#include "xfs_ioctl.h"
9227  #include "xfs_btree.h"
9228  #include "xfs_ialloc.h"
9229  #include "xfs_rtalloc.h"
9230 @@ -747,6 +746,10 @@ xfs_merge_ioc_xflags(
9231                 xflags |= XFS_XFLAG_IMMUTABLE;
9232         else
9233                 xflags &= ~XFS_XFLAG_IMMUTABLE;
9234 +       if (flags & FS_IXUNLINK_FL)
9235 +               xflags |= XFS_XFLAG_IXUNLINK;
9236 +       else
9237 +               xflags &= ~XFS_XFLAG_IXUNLINK;
9238         if (flags & FS_APPEND_FL)
9239                 xflags |= XFS_XFLAG_APPEND;
9240         else
9241 @@ -775,6 +778,8 @@ xfs_di2lxflags(
9242  
9243         if (di_flags & XFS_DIFLAG_IMMUTABLE)
9244                 flags |= FS_IMMUTABLE_FL;
9245 +       if (di_flags & XFS_DIFLAG_IXUNLINK)
9246 +               flags |= FS_IXUNLINK_FL;
9247         if (di_flags & XFS_DIFLAG_APPEND)
9248                 flags |= FS_APPEND_FL;
9249         if (di_flags & XFS_DIFLAG_SYNC)
9250 @@ -833,6 +838,8 @@ xfs_set_diflags(
9251         di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
9252         if (xflags & XFS_XFLAG_IMMUTABLE)
9253                 di_flags |= XFS_DIFLAG_IMMUTABLE;
9254 +       if (xflags & XFS_XFLAG_IXUNLINK)
9255 +               di_flags |= XFS_DIFLAG_IXUNLINK;
9256         if (xflags & XFS_XFLAG_APPEND)
9257                 di_flags |= XFS_DIFLAG_APPEND;
9258         if (xflags & XFS_XFLAG_SYNC)
9259 @@ -875,6 +882,10 @@ xfs_diflags_to_linux(
9260                 inode->i_flags |= S_IMMUTABLE;
9261         else
9262                 inode->i_flags &= ~S_IMMUTABLE;
9263 +       if (xflags & XFS_XFLAG_IXUNLINK)
9264 +               inode->i_flags |= S_IXUNLINK;
9265 +       else
9266 +               inode->i_flags &= ~S_IXUNLINK;
9267         if (xflags & XFS_XFLAG_APPEND)
9268                 inode->i_flags |= S_APPEND;
9269         else
9270 @@ -1351,10 +1362,18 @@ xfs_file_ioctl(
9271         case XFS_IOC_FSGETXATTRA:
9272                 return xfs_ioc_fsgetxattr(ip, 1, arg);
9273         case XFS_IOC_FSSETXATTR:
9274 +               if (IS_BARRIER(inode)) {
9275 +                       vxwprintk_task(1, "messing with the barrier.");
9276 +                       return -XFS_ERROR(EACCES);
9277 +               }
9278                 return xfs_ioc_fssetxattr(ip, filp, arg);
9279         case XFS_IOC_GETXFLAGS:
9280                 return xfs_ioc_getxflags(ip, arg);
9281         case XFS_IOC_SETXFLAGS:
9282 +               if (IS_BARRIER(inode)) {
9283 +                       vxwprintk_task(1, "messing with the barrier.");
9284 +                       return -XFS_ERROR(EACCES);
9285 +               }
9286                 return xfs_ioc_setxflags(ip, filp, arg);
9287  
9288         case XFS_IOC_FSSETDM: {
9289 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.h
9290 --- linux-2.6.35.2/fs/xfs/linux-2.6/xfs_ioctl.h 2010-07-07 18:31:54.000000000 +0200
9291 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_ioctl.h   2010-08-02 17:05:06.000000000 +0200
9292 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
9293         void __user             *uhandle,
9294         u32                     hlen);
9295  
9296 +extern int
9297 +xfs_sync_flags(
9298 +       struct inode            *inode,
9299 +       int                     flags,
9300 +       int                     vflags);
9301 +
9302  extern long
9303  xfs_file_ioctl(
9304         struct file             *filp,
9305 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_iops.c
9306 --- linux-2.6.35.2/fs/xfs/linux-2.6/xfs_iops.c  2010-08-02 16:52:52.000000000 +0200
9307 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_iops.c    2010-08-02 17:05:06.000000000 +0200
9308 @@ -36,6 +36,7 @@
9309  #include "xfs_attr_sf.h"
9310  #include "xfs_dinode.h"
9311  #include "xfs_inode.h"
9312 +#include "xfs_ioctl.h"
9313  #include "xfs_bmap.h"
9314  #include "xfs_btree.h"
9315  #include "xfs_ialloc.h"
9316 @@ -57,6 +58,7 @@
9317  #include <linux/falloc.h>
9318  #include <linux/fiemap.h>
9319  #include <linux/slab.h>
9320 +#include <linux/vs_tag.h>
9321  
9322  /*
9323   * Bring the timestamps in the XFS inode uptodate.
9324 @@ -507,6 +509,7 @@ xfs_vn_getattr(
9325         stat->nlink = ip->i_d.di_nlink;
9326         stat->uid = ip->i_d.di_uid;
9327         stat->gid = ip->i_d.di_gid;
9328 +       stat->tag = ip->i_d.di_tag;
9329         stat->ino = ip->i_ino;
9330         stat->atime = inode->i_atime;
9331         stat->mtime = inode->i_mtime;
9332 @@ -711,6 +714,7 @@ static const struct inode_operations xfs
9333         .listxattr              = xfs_vn_listxattr,
9334         .fallocate              = xfs_vn_fallocate,
9335         .fiemap                 = xfs_vn_fiemap,
9336 +       .sync_flags             = xfs_sync_flags,
9337  };
9338  
9339  static const struct inode_operations xfs_dir_inode_operations = {
9340 @@ -736,6 +740,7 @@ static const struct inode_operations xfs
9341         .getxattr               = generic_getxattr,
9342         .removexattr            = generic_removexattr,
9343         .listxattr              = xfs_vn_listxattr,
9344 +       .sync_flags             = xfs_sync_flags,
9345  };
9346  
9347  static const struct inode_operations xfs_dir_ci_inode_operations = {
9348 @@ -785,6 +790,10 @@ xfs_diflags_to_iflags(
9349                 inode->i_flags |= S_IMMUTABLE;
9350         else
9351                 inode->i_flags &= ~S_IMMUTABLE;
9352 +       if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
9353 +               inode->i_flags |= S_IXUNLINK;
9354 +       else
9355 +               inode->i_flags &= ~S_IXUNLINK;
9356         if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
9357                 inode->i_flags |= S_APPEND;
9358         else
9359 @@ -797,6 +806,15 @@ xfs_diflags_to_iflags(
9360                 inode->i_flags |= S_NOATIME;
9361         else
9362                 inode->i_flags &= ~S_NOATIME;
9363 +
9364 +       if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
9365 +               inode->i_vflags |= V_BARRIER;
9366 +       else
9367 +               inode->i_vflags &= ~V_BARRIER;
9368 +       if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
9369 +               inode->i_vflags |= V_COW;
9370 +       else
9371 +               inode->i_vflags &= ~V_COW;
9372  }
9373  
9374  /*
9375 @@ -825,6 +843,7 @@ xfs_setup_inode(
9376         inode->i_nlink  = ip->i_d.di_nlink;
9377         inode->i_uid    = ip->i_d.di_uid;
9378         inode->i_gid    = ip->i_d.di_gid;
9379 +       inode->i_tag    = ip->i_d.di_tag;
9380  
9381         switch (inode->i_mode & S_IFMT) {
9382         case S_IFBLK:
9383 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_linux.h
9384 --- linux-2.6.35.2/fs/xfs/linux-2.6/xfs_linux.h 2010-07-07 18:31:54.000000000 +0200
9385 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_linux.h   2010-08-02 17:05:06.000000000 +0200
9386 @@ -117,6 +117,7 @@
9387  
9388  #define current_cpu()          (raw_smp_processor_id())
9389  #define current_pid()          (current->pid)
9390 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
9391  #define current_test_flags(f)  (current->flags & (f))
9392  #define current_set_flags_nested(sp, f)                \
9393                 (*(sp) = current->flags, current->flags |= (f))
9394 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/linux-2.6/xfs_super.c linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_super.c
9395 --- linux-2.6.35.2/fs/xfs/linux-2.6/xfs_super.c 2010-08-02 16:52:52.000000000 +0200
9396 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/linux-2.6/xfs_super.c   2010-08-02 18:00:35.000000000 +0200
9397 @@ -121,6 +121,9 @@ mempool_t *xfs_ioend_pool;
9398  #define MNTOPT_DMI     "dmi"           /* DMI enabled (DMAPI / XDSM) */
9399  #define MNTOPT_DELAYLOG   "delaylog"   /* Delayed loging enabled */
9400  #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed loging disabled */
9401 +#define MNTOPT_TAGXID  "tagxid"        /* context tagging for inodes */
9402 +#define MNTOPT_TAGGED  "tag"           /* context tagging for inodes */
9403 +#define MNTOPT_NOTAGTAG        "notag"         /* do not use context tagging */
9404  
9405  /*
9406   * Table driven mount option parser.
9407 @@ -129,10 +132,14 @@ mempool_t *xfs_ioend_pool;
9408   * in the future, too.
9409   */
9410  enum {
9411 +       Opt_tag, Opt_notag,
9412         Opt_barrier, Opt_nobarrier, Opt_err
9413  };
9414  
9415  static const match_table_t tokens = {
9416 +       {Opt_tag, "tagxid"},
9417 +       {Opt_tag, "tag"},
9418 +       {Opt_notag, "notag"},
9419         {Opt_barrier, "barrier"},
9420         {Opt_nobarrier, "nobarrier"},
9421         {Opt_err, NULL}
9422 @@ -393,6 +400,19 @@ xfs_parseargs(
9423                 } else if (!strcmp(this_char, "irixsgid")) {
9424                         cmn_err(CE_WARN,
9425         "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
9426 +#ifndef CONFIG_TAGGING_NONE
9427 +               } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9428 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9429 +               } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
9430 +                       mp->m_flags &= ~XFS_MOUNT_TAGGED;
9431 +               } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
9432 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9433 +#endif
9434 +#ifdef CONFIG_PROPAGATE
9435 +               } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9436 +                       /* use value */
9437 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9438 +#endif
9439                 } else {
9440                         cmn_err(CE_WARN,
9441                                 "XFS: unknown mount option [%s].", this_char);
9442 @@ -1376,6 +1396,16 @@ xfs_fs_remount(
9443                 case Opt_nobarrier:
9444                         mp->m_flags &= ~XFS_MOUNT_BARRIER;
9445                         break;
9446 +               case Opt_tag:
9447 +                       if (!(sb->s_flags & MS_TAGGED)) {
9448 +                               printk(KERN_INFO
9449 +                                       "XFS: %s: tagging not permitted on remount.\n",
9450 +                                       sb->s_id);
9451 +                               return -EINVAL;
9452 +                       }
9453 +                       break;
9454 +               case Opt_notag:
9455 +                       break;
9456                 default:
9457                         /*
9458                          * Logically we would return an error here to prevent
9459 @@ -1610,6 +1640,9 @@ xfs_fs_fill_super(
9460  
9461         XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
9462  
9463 +       if (mp->m_flags & XFS_MOUNT_TAGGED)
9464 +               sb->s_flags |= MS_TAGGED;
9465 +
9466         sb->s_magic = XFS_SB_MAGIC;
9467         sb->s_blocksize = mp->m_sb.sb_blocksize;
9468         sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
9469 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/xfs_dinode.h linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_dinode.h
9470 --- linux-2.6.35.2/fs/xfs/xfs_dinode.h  2009-06-11 17:13:09.000000000 +0200
9471 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_dinode.h    2010-08-02 17:05:06.000000000 +0200
9472 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
9473         __be32          di_gid;         /* owner's group id */
9474         __be32          di_nlink;       /* number of links to file */
9475         __be16          di_projid;      /* owner's project id */
9476 -       __u8            di_pad[8];      /* unused, zeroed space */
9477 +       __be16          di_tag;         /* context tagging */
9478 +       __be16          di_vflags;      /* vserver specific flags */
9479 +       __u8            di_pad[4];      /* unused, zeroed space */
9480         __be16          di_flushiter;   /* incremented on flush */
9481         xfs_timestamp_t di_atime;       /* time last accessed */
9482         xfs_timestamp_t di_mtime;       /* time last modified */
9483 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
9484  #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
9485  #define XFS_DIFLAG_NODEFRAG_BIT     13 /* do not reorganize/defragment */
9486  #define XFS_DIFLAG_FILESTREAM_BIT   14  /* use filestream allocator */
9487 +#define XFS_DIFLAG_IXUNLINK_BIT     15 /* Immutable inver on unlink */
9488 +
9489  #define XFS_DIFLAG_REALTIME      (1 << XFS_DIFLAG_REALTIME_BIT)
9490  #define XFS_DIFLAG_PREALLOC      (1 << XFS_DIFLAG_PREALLOC_BIT)
9491  #define XFS_DIFLAG_NEWRTBM       (1 << XFS_DIFLAG_NEWRTBM_BIT)
9492 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
9493  #define XFS_DIFLAG_EXTSZINHERIT  (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
9494  #define XFS_DIFLAG_NODEFRAG      (1 << XFS_DIFLAG_NODEFRAG_BIT)
9495  #define XFS_DIFLAG_FILESTREAM    (1 << XFS_DIFLAG_FILESTREAM_BIT)
9496 +#define XFS_DIFLAG_IXUNLINK      (1 << XFS_DIFLAG_IXUNLINK_BIT)
9497  
9498  #ifdef CONFIG_XFS_RT
9499  #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
9500 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
9501          XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
9502          XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
9503          XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
9504 -        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
9505 +        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
9506 +        XFS_DIFLAG_IXUNLINK)
9507 +
9508 +#define XFS_DIVFLAG_BARRIER    0x01
9509 +#define XFS_DIVFLAG_COW                0x02
9510  
9511  #endif /* __XFS_DINODE_H__ */
9512 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/xfs_fs.h linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_fs.h
9513 --- linux-2.6.35.2/fs/xfs/xfs_fs.h      2010-07-07 18:31:54.000000000 +0200
9514 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_fs.h        2010-08-02 17:05:06.000000000 +0200
9515 @@ -67,6 +67,9 @@ struct fsxattr {
9516  #define XFS_XFLAG_EXTSZINHERIT 0x00001000      /* inherit inode extent size */
9517  #define XFS_XFLAG_NODEFRAG     0x00002000      /* do not defragment */
9518  #define XFS_XFLAG_FILESTREAM   0x00004000      /* use filestream allocator */
9519 +#define XFS_XFLAG_IXUNLINK     0x00008000      /* immutable invert on unlink */
9520 +#define XFS_XFLAG_BARRIER      0x10000000      /* chroot() barrier */
9521 +#define XFS_XFLAG_COW          0x20000000      /* copy on write mark */
9522  #define XFS_XFLAG_HASATTR      0x80000000      /* no DIFLAG for this   */
9523  
9524  /*
9525 @@ -293,7 +296,8 @@ typedef struct xfs_bstat {
9526         __u32           bs_gen;         /* generation count             */
9527         __u16           bs_projid;      /* project id                   */
9528         __u16           bs_forkoff;     /* inode fork offset in bytes   */
9529 -       unsigned char   bs_pad[12];     /* pad space, unused            */
9530 +       __u16           bs_tag;         /* context tagging              */
9531 +       unsigned char   bs_pad[10];     /* pad space, unused            */
9532         __u32           bs_dmevmask;    /* DMIG event mask              */
9533         __u16           bs_dmstate;     /* DMIG state info              */
9534         __u16           bs_aextents;    /* attribute number of extents  */
9535 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/xfs_ialloc.c linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_ialloc.c
9536 --- linux-2.6.35.2/fs/xfs/xfs_ialloc.c  2010-08-02 16:52:53.000000000 +0200
9537 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_ialloc.c    2010-08-02 17:05:06.000000000 +0200
9538 @@ -41,7 +41,6 @@
9539  #include "xfs_error.h"
9540  #include "xfs_bmap.h"
9541  
9542 -
9543  /*
9544   * Allocation group level functions.
9545   */
9546 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/xfs_inode.c linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_inode.c
9547 --- linux-2.6.35.2/fs/xfs/xfs_inode.c   2010-08-02 16:52:53.000000000 +0200
9548 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_inode.c     2010-08-02 17:05:06.000000000 +0200
9549 @@ -249,6 +249,7 @@ xfs_inotobp(
9550         return 0;
9551  }
9552  
9553 +#include <linux/vs_tag.h>
9554  
9555  /*
9556   * This routine is called to map an inode to the buffer containing
9557 @@ -654,15 +655,25 @@ xfs_iformat_btree(
9558  STATIC void
9559  xfs_dinode_from_disk(
9560         xfs_icdinode_t          *to,
9561 -       xfs_dinode_t            *from)
9562 +       xfs_dinode_t            *from,
9563 +       int tagged)
9564  {
9565 +       uint32_t uid, gid, tag;
9566 +
9567         to->di_magic = be16_to_cpu(from->di_magic);
9568         to->di_mode = be16_to_cpu(from->di_mode);
9569         to->di_version = from ->di_version;
9570         to->di_format = from->di_format;
9571         to->di_onlink = be16_to_cpu(from->di_onlink);
9572 -       to->di_uid = be32_to_cpu(from->di_uid);
9573 -       to->di_gid = be32_to_cpu(from->di_gid);
9574 +
9575 +       uid = be32_to_cpu(from->di_uid);
9576 +       gid = be32_to_cpu(from->di_gid);
9577 +       tag = be16_to_cpu(from->di_tag);
9578 +
9579 +       to->di_uid = INOTAG_UID(tagged, uid, gid);
9580 +       to->di_gid = INOTAG_GID(tagged, uid, gid);
9581 +       to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
9582 +
9583         to->di_nlink = be32_to_cpu(from->di_nlink);
9584         to->di_projid = be16_to_cpu(from->di_projid);
9585         memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
9586 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
9587         to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
9588         to->di_dmstate  = be16_to_cpu(from->di_dmstate);
9589         to->di_flags    = be16_to_cpu(from->di_flags);
9590 +       to->di_vflags   = be16_to_cpu(from->di_vflags);
9591         to->di_gen      = be32_to_cpu(from->di_gen);
9592  }
9593  
9594  void
9595  xfs_dinode_to_disk(
9596         xfs_dinode_t            *to,
9597 -       xfs_icdinode_t          *from)
9598 +       xfs_icdinode_t          *from,
9599 +       int tagged)
9600  {
9601         to->di_magic = cpu_to_be16(from->di_magic);
9602         to->di_mode = cpu_to_be16(from->di_mode);
9603         to->di_version = from ->di_version;
9604         to->di_format = from->di_format;
9605         to->di_onlink = cpu_to_be16(from->di_onlink);
9606 -       to->di_uid = cpu_to_be32(from->di_uid);
9607 -       to->di_gid = cpu_to_be32(from->di_gid);
9608 +
9609 +       to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
9610 +       to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
9611 +       to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
9612 +
9613         to->di_nlink = cpu_to_be32(from->di_nlink);
9614         to->di_projid = cpu_to_be16(from->di_projid);
9615         memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
9616 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
9617         to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
9618         to->di_dmstate = cpu_to_be16(from->di_dmstate);
9619         to->di_flags = cpu_to_be16(from->di_flags);
9620 +       to->di_vflags = cpu_to_be16(from->di_vflags);
9621         to->di_gen = cpu_to_be32(from->di_gen);
9622  }
9623  
9624  STATIC uint
9625  _xfs_dic2xflags(
9626 -       __uint16_t              di_flags)
9627 +       __uint16_t              di_flags,
9628 +       __uint16_t              di_vflags)
9629  {
9630         uint                    flags = 0;
9631  
9632 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
9633                         flags |= XFS_XFLAG_PREALLOC;
9634                 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9635                         flags |= XFS_XFLAG_IMMUTABLE;
9636 +               if (di_flags & XFS_DIFLAG_IXUNLINK)
9637 +                       flags |= XFS_XFLAG_IXUNLINK;
9638                 if (di_flags & XFS_DIFLAG_APPEND)
9639                         flags |= XFS_XFLAG_APPEND;
9640                 if (di_flags & XFS_DIFLAG_SYNC)
9641 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
9642                         flags |= XFS_XFLAG_FILESTREAM;
9643         }
9644  
9645 +       if (di_vflags & XFS_DIVFLAG_BARRIER)
9646 +               flags |= FS_BARRIER_FL;
9647 +       if (di_vflags & XFS_DIVFLAG_COW)
9648 +               flags |= FS_COW_FL;
9649         return flags;
9650  }
9651  
9652 @@ -767,7 +791,7 @@ xfs_ip2xflags(
9653  {
9654         xfs_icdinode_t          *dic = &ip->i_d;
9655  
9656 -       return _xfs_dic2xflags(dic->di_flags) |
9657 +       return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
9658                                 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
9659  }
9660  
9661 @@ -775,7 +799,8 @@ uint
9662  xfs_dic2xflags(
9663         xfs_dinode_t            *dip)
9664  {
9665 -       return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
9666 +       return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
9667 +                               be16_to_cpu(dip->di_vflags)) |
9668                                 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
9669  }
9670  
9671 @@ -808,7 +833,6 @@ xfs_iread(
9672         if (error)
9673                 return error;
9674         dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
9675 -
9676         /*
9677          * If we got something that isn't an inode it means someone
9678          * (nfs or dmi) has a stale handle.
9679 @@ -833,7 +857,8 @@ xfs_iread(
9680          * Otherwise, just get the truly permanent information.
9681          */
9682         if (dip->di_mode) {
9683 -               xfs_dinode_from_disk(&ip->i_d, dip);
9684 +               xfs_dinode_from_disk(&ip->i_d, dip,
9685 +                       mp->m_flags & XFS_MOUNT_TAGGED);
9686                 error = xfs_iformat(ip, dip);
9687                 if (error)  {
9688  #ifdef DEBUG
9689 @@ -1033,6 +1058,7 @@ xfs_ialloc(
9690         ASSERT(ip->i_d.di_nlink == nlink);
9691         ip->i_d.di_uid = current_fsuid();
9692         ip->i_d.di_gid = current_fsgid();
9693 +       ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
9694         ip->i_d.di_projid = prid;
9695         memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
9696  
9697 @@ -1093,6 +1119,7 @@ xfs_ialloc(
9698         ip->i_d.di_dmevmask = 0;
9699         ip->i_d.di_dmstate = 0;
9700         ip->i_d.di_flags = 0;
9701 +       ip->i_d.di_vflags = 0;
9702         flags = XFS_ILOG_CORE;
9703         switch (mode & S_IFMT) {
9704         case S_IFIFO:
9705 @@ -2116,6 +2143,7 @@ xfs_ifree(
9706         }
9707         ip->i_d.di_mode = 0;            /* mark incore inode as free */
9708         ip->i_d.di_flags = 0;
9709 +       ip->i_d.di_vflags = 0;
9710         ip->i_d.di_dmevmask = 0;
9711         ip->i_d.di_forkoff = 0;         /* mark the attr fork not in use */
9712         ip->i_df.if_ext_max =
9713 @@ -2985,7 +3013,8 @@ xfs_iflush_int(
9714          * because if the inode is dirty at all the core must
9715          * be.
9716          */
9717 -       xfs_dinode_to_disk(dip, &ip->i_d);
9718 +       xfs_dinode_to_disk(dip, &ip->i_d,
9719 +               mp->m_flags & XFS_MOUNT_TAGGED);
9720  
9721         /* Wrap, we never let the log put out DI_MAX_FLUSH */
9722         if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
9723 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/xfs_inode.h linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_inode.h
9724 --- linux-2.6.35.2/fs/xfs/xfs_inode.h   2010-08-02 16:52:53.000000000 +0200
9725 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_inode.h     2010-08-02 17:05:06.000000000 +0200
9726 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
9727         __uint32_t      di_gid;         /* owner's group id */
9728         __uint32_t      di_nlink;       /* number of links to file */
9729         __uint16_t      di_projid;      /* owner's project id */
9730 -       __uint8_t       di_pad[8];      /* unused, zeroed space */
9731 +       __uint16_t      di_tag;         /* context tagging */
9732 +       __uint16_t      di_vflags;      /* vserver specific flags */
9733 +       __uint8_t       di_pad[4];      /* unused, zeroed space */
9734         __uint16_t      di_flushiter;   /* incremented on flush */
9735         xfs_ictimestamp_t di_atime;     /* time last accessed */
9736         xfs_ictimestamp_t di_mtime;     /* time last modified */
9737 @@ -511,7 +513,7 @@ int         xfs_itobp(struct xfs_mount *, struc
9738  int            xfs_iread(struct xfs_mount *, struct xfs_trans *,
9739                           struct xfs_inode *, uint);
9740  void           xfs_dinode_to_disk(struct xfs_dinode *,
9741 -                                  struct xfs_icdinode *);
9742 +                                  struct xfs_icdinode *, int);
9743  void           xfs_idestroy_fork(struct xfs_inode *, int);
9744  void           xfs_idata_realloc(struct xfs_inode *, int, int);
9745  void           xfs_iroot_realloc(struct xfs_inode *, int, int);
9746 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/xfs_itable.c linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_itable.c
9747 --- linux-2.6.35.2/fs/xfs/xfs_itable.c  2010-08-02 16:52:53.000000000 +0200
9748 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_itable.c    2010-08-02 17:05:06.000000000 +0200
9749 @@ -100,6 +100,7 @@ xfs_bulkstat_one_int(
9750         buf->bs_mode = dic->di_mode;
9751         buf->bs_uid = dic->di_uid;
9752         buf->bs_gid = dic->di_gid;
9753 +       buf->bs_tag = dic->di_tag;
9754         buf->bs_size = dic->di_size;
9755  
9756         /*
9757 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/xfs_log_recover.c linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_log_recover.c
9758 --- linux-2.6.35.2/fs/xfs/xfs_log_recover.c     2010-08-02 16:52:53.000000000 +0200
9759 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_log_recover.c       2010-08-02 17:05:06.000000000 +0200
9760 @@ -2461,7 +2461,8 @@ xlog_recover_do_inode_trans(
9761         }
9762  
9763         /* The core is in in-core format */
9764 -       xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
9765 +       xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
9766 +               mp->m_flags & XFS_MOUNT_TAGGED);
9767  
9768         /* the rest is in on-disk format */
9769         if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
9770 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/xfs_mount.h linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_mount.h
9771 --- linux-2.6.35.2/fs/xfs/xfs_mount.h   2010-08-02 16:52:53.000000000 +0200
9772 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_mount.h     2010-08-02 17:05:06.000000000 +0200
9773 @@ -302,6 +302,7 @@ typedef struct xfs_mount {
9774                                                    allocator */
9775  #define XFS_MOUNT_NOATTR2      (1ULL << 25)    /* disable use of attr2 format */
9776  
9777 +#define XFS_MOUNT_TAGGED       (1ULL << 31)    /* context tagging */
9778  
9779  /*
9780   * Default minimum read and write sizes.
9781 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/xfs_vnodeops.c linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.c
9782 --- linux-2.6.35.2/fs/xfs/xfs_vnodeops.c        2010-08-02 16:52:53.000000000 +0200
9783 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.c  2010-08-02 17:05:06.000000000 +0200
9784 @@ -55,6 +55,80 @@
9785  #include "xfs_vnodeops.h"
9786  #include "xfs_trace.h"
9787  
9788 +
9789 +STATIC void
9790 +xfs_get_inode_flags(
9791 +       xfs_inode_t     *ip)
9792 +{
9793 +       struct inode    *inode = VFS_I(ip);
9794 +       unsigned int    flags = inode->i_flags;
9795 +       unsigned int    vflags = inode->i_vflags;
9796 +
9797 +       if (flags & S_IMMUTABLE)
9798 +               ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
9799 +       else
9800 +               ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
9801 +       if (flags & S_IXUNLINK)
9802 +               ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
9803 +       else
9804 +               ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
9805 +
9806 +       if (vflags & V_BARRIER)
9807 +               ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
9808 +       else
9809 +               ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
9810 +       if (vflags & V_COW)
9811 +               ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
9812 +       else
9813 +               ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
9814 +}
9815 +
9816 +int
9817 +xfs_sync_flags(
9818 +       struct inode            *inode,
9819 +       int                     flags,
9820 +       int                     vflags)
9821 +{
9822 +       struct xfs_inode        *ip = XFS_I(inode);
9823 +       struct xfs_mount        *mp = ip->i_mount;
9824 +       struct xfs_trans        *tp;
9825 +       unsigned int            lock_flags = 0;
9826 +       int                     code;
9827 +
9828 +       tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
9829 +       code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
9830 +       if (code)
9831 +               goto error_out;
9832 +
9833 +       lock_flags = XFS_ILOCK_EXCL;
9834 +       xfs_ilock(ip, lock_flags);
9835 +
9836 +       xfs_trans_ijoin(tp, ip, lock_flags);
9837 +       xfs_trans_ihold(tp, ip);
9838 +
9839 +       inode->i_flags = flags;
9840 +       inode->i_vflags = vflags;
9841 +       xfs_get_inode_flags(ip);
9842 +
9843 +       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
9844 +       xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
9845 +
9846 +       XFS_STATS_INC(xs_ig_attrchg);
9847 +
9848 +       if (mp->m_flags & XFS_MOUNT_WSYNC)
9849 +               xfs_trans_set_sync(tp);
9850 +       code = xfs_trans_commit(tp, 0);
9851 +       xfs_iunlock(ip, lock_flags);
9852 +       return code;
9853 +
9854 +error_out:
9855 +       xfs_trans_cancel(tp, 0);
9856 +       if (lock_flags)
9857 +               xfs_iunlock(ip, lock_flags);
9858 +       return code;
9859 +}
9860 +
9861 +
9862  int
9863  xfs_setattr(
9864         struct xfs_inode        *ip,
9865 @@ -70,6 +144,7 @@ xfs_setattr(
9866         uint                    commit_flags=0;
9867         uid_t                   uid=0, iuid=0;
9868         gid_t                   gid=0, igid=0;
9869 +       tag_t                   tag=0, itag=0;
9870         struct xfs_dquot        *udqp, *gdqp, *olddquot1, *olddquot2;
9871         int                     need_iolock = 1;
9872  
9873 @@ -162,7 +237,7 @@ xfs_setattr(
9874         /*
9875          * Change file ownership.  Must be the owner or privileged.
9876          */
9877 -       if (mask & (ATTR_UID|ATTR_GID)) {
9878 +       if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9879                 /*
9880                  * These IDs could have changed since we last looked at them.
9881                  * But, we're assured that if the ownership did change
9882 @@ -171,8 +246,10 @@ xfs_setattr(
9883                  */
9884                 iuid = ip->i_d.di_uid;
9885                 igid = ip->i_d.di_gid;
9886 +               itag = ip->i_d.di_tag;
9887                 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
9888                 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
9889 +               tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
9890  
9891                 /*
9892                  * Do a quota reservation only if uid/gid is actually
9893 @@ -180,7 +257,8 @@ xfs_setattr(
9894                  */
9895                 if (XFS_IS_QUOTA_RUNNING(mp) &&
9896                     ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
9897 -                    (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
9898 +                    (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
9899 +                    (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
9900                         ASSERT(tp);
9901                         code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
9902                                                 capable(CAP_FOWNER) ?
9903 @@ -341,7 +419,7 @@ xfs_setattr(
9904         /*
9905          * Change file ownership.  Must be the owner or privileged.
9906          */
9907 -       if (mask & (ATTR_UID|ATTR_GID)) {
9908 +       if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9909                 /*
9910                  * CAP_FSETID overrides the following restrictions:
9911                  *
9912 @@ -357,6 +435,10 @@ xfs_setattr(
9913                  * Change the ownerships and register quota modifications
9914                  * in the transaction.
9915                  */
9916 +               if (itag != tag) {
9917 +                       ip->i_d.di_tag = tag;
9918 +                       inode->i_tag = tag;
9919 +               }
9920                 if (iuid != uid) {
9921                         if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
9922                                 ASSERT(mask & ATTR_UID);
9923 diff -NurpP --minimal linux-2.6.35.2/fs/xfs/xfs_vnodeops.h linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.h
9924 --- linux-2.6.35.2/fs/xfs/xfs_vnodeops.h        2010-07-07 18:31:54.000000000 +0200
9925 +++ linux-2.6.35.2-vs2.3.0.36.31/fs/xfs/xfs_vnodeops.h  2010-08-02 17:05:06.000000000 +0200
9926 @@ -14,6 +14,7 @@ struct xfs_inode;
9927  struct xfs_iomap;
9928  
9929  
9930 +int xfs_sync_xflags(struct xfs_inode *ip);
9931  int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
9932  #define        XFS_ATTR_DMI            0x01    /* invocation from a DMI function */
9933  #define        XFS_ATTR_NONBLOCK       0x02    /* return EAGAIN if operation would block */
9934 diff -NurpP --minimal linux-2.6.35.2/include/asm-generic/tlb.h linux-2.6.35.2-vs2.3.0.36.31/include/asm-generic/tlb.h
9935 --- linux-2.6.35.2/include/asm-generic/tlb.h    2009-09-10 15:26:24.000000000 +0200
9936 +++ linux-2.6.35.2-vs2.3.0.36.31/include/asm-generic/tlb.h      2010-08-02 17:05:06.000000000 +0200
9937 @@ -14,6 +14,7 @@
9938  #define _ASM_GENERIC__TLB_H
9939  
9940  #include <linux/swap.h>
9941 +#include <linux/vs_memory.h>
9942  #include <asm/pgalloc.h>
9943  #include <asm/tlbflush.h>
9944  
9945 diff -NurpP --minimal linux-2.6.35.2/include/linux/capability.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/capability.h
9946 --- linux-2.6.35.2/include/linux/capability.h   2010-02-25 11:52:07.000000000 +0100
9947 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/capability.h     2010-08-02 17:05:06.000000000 +0200
9948 @@ -283,6 +283,7 @@ struct cpu_vfs_cap_data {
9949     arbitrary SCSI commands */
9950  /* Allow setting encryption key on loopback filesystem */
9951  /* Allow setting zone reclaim policy */
9952 +/* Allow the selection of a security context */
9953  
9954  #define CAP_SYS_ADMIN        21
9955  
9956 @@ -355,7 +356,13 @@ struct cpu_vfs_cap_data {
9957  
9958  #define CAP_MAC_ADMIN        33
9959  
9960 -#define CAP_LAST_CAP         CAP_MAC_ADMIN
9961 +/* Allow context manipulations */
9962 +/* Allow changing context info on files */
9963 +
9964 +#define CAP_CONTEXT         34
9965 +
9966 +
9967 +#define CAP_LAST_CAP         CAP_CONTEXT
9968  
9969  #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
9970  
9971 diff -NurpP --minimal linux-2.6.35.2/include/linux/devpts_fs.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/devpts_fs.h
9972 --- linux-2.6.35.2/include/linux/devpts_fs.h    2008-12-25 00:26:37.000000000 +0100
9973 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/devpts_fs.h      2010-08-02 17:05:06.000000000 +0200
9974 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
9975  
9976  #endif
9977  
9978 -
9979  #endif /* _LINUX_DEVPTS_FS_H */
9980 diff -NurpP --minimal linux-2.6.35.2/include/linux/ext2_fs.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/ext2_fs.h
9981 --- linux-2.6.35.2/include/linux/ext2_fs.h      2010-02-25 11:52:07.000000000 +0100
9982 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/ext2_fs.h        2010-08-02 17:05:06.000000000 +0200
9983 @@ -189,8 +189,12 @@ struct ext2_group_desc
9984  #define EXT2_NOTAIL_FL                 FS_NOTAIL_FL    /* file tail should not be merged */
9985  #define EXT2_DIRSYNC_FL                        FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
9986  #define EXT2_TOPDIR_FL                 FS_TOPDIR_FL    /* Top of directory hierarchies*/
9987 +#define EXT2_IXUNLINK_FL               FS_IXUNLINK_FL  /* Immutable invert on unlink */
9988  #define EXT2_RESERVED_FL               FS_RESERVED_FL  /* reserved for ext2 lib */
9989  
9990 +#define EXT2_BARRIER_FL                        FS_BARRIER_FL   /* Barrier for chroot() */
9991 +#define EXT2_COW_FL                    FS_COW_FL       /* Copy on Write marker */
9992 +
9993  #define EXT2_FL_USER_VISIBLE           FS_FL_USER_VISIBLE      /* User visible flags */
9994  #define EXT2_FL_USER_MODIFIABLE                FS_FL_USER_MODIFIABLE   /* User modifiable flags */
9995  
9996 @@ -274,7 +278,8 @@ struct ext2_inode {
9997                         __u16   i_pad1;
9998                         __le16  l_i_uid_high;   /* these 2 fields    */
9999                         __le16  l_i_gid_high;   /* were reserved2[0] */
10000 -                       __u32   l_i_reserved2;
10001 +                       __le16  l_i_tag;        /* Context Tag */
10002 +                       __u16   l_i_reserved2;
10003                 } linux2;
10004                 struct {
10005                         __u8    h_i_frag;       /* Fragment number */
10006 @@ -303,6 +308,7 @@ struct ext2_inode {
10007  #define i_gid_low      i_gid
10008  #define i_uid_high     osd2.linux2.l_i_uid_high
10009  #define i_gid_high     osd2.linux2.l_i_gid_high
10010 +#define i_raw_tag      osd2.linux2.l_i_tag
10011  #define i_reserved2    osd2.linux2.l_i_reserved2
10012  #endif
10013  
10014 @@ -347,6 +353,7 @@ struct ext2_inode {
10015  #define EXT2_MOUNT_USRQUOTA            0x020000  /* user quota */
10016  #define EXT2_MOUNT_GRPQUOTA            0x040000  /* group quota */
10017  #define EXT2_MOUNT_RESERVATION         0x080000  /* Preallocation */
10018 +#define EXT2_MOUNT_TAGGED              (1<<24)   /* Enable Context Tags */
10019  
10020  
10021  #define clear_opt(o, opt)              o &= ~EXT2_MOUNT_##opt
10022 diff -NurpP --minimal linux-2.6.35.2/include/linux/ext3_fs.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/ext3_fs.h
10023 --- linux-2.6.35.2/include/linux/ext3_fs.h      2010-08-02 16:52:54.000000000 +0200
10024 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/ext3_fs.h        2010-08-02 17:05:06.000000000 +0200
10025 @@ -173,10 +173,14 @@ struct ext3_group_desc
10026  #define EXT3_NOTAIL_FL                 0x00008000 /* file tail should not be merged */
10027  #define EXT3_DIRSYNC_FL                        0x00010000 /* dirsync behaviour (directories only) */
10028  #define EXT3_TOPDIR_FL                 0x00020000 /* Top of directory hierarchies*/
10029 +#define EXT3_IXUNLINK_FL               0x08000000 /* Immutable invert on unlink */
10030  #define EXT3_RESERVED_FL               0x80000000 /* reserved for ext3 lib */
10031  
10032 -#define EXT3_FL_USER_VISIBLE           0x0003DFFF /* User visible flags */
10033 -#define EXT3_FL_USER_MODIFIABLE                0x000380FF /* User modifiable flags */
10034 +#define EXT3_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
10035 +#define EXT3_COW_FL                    0x20000000 /* Copy on Write marker */
10036 +
10037 +#define EXT3_FL_USER_VISIBLE           0x0103DFFF /* User visible flags */
10038 +#define EXT3_FL_USER_MODIFIABLE                0x010380FF /* User modifiable flags */
10039  
10040  /* Flags that should be inherited by new inodes from their parent. */
10041  #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
10042 @@ -312,7 +316,8 @@ struct ext3_inode {
10043                         __u16   i_pad1;
10044                         __le16  l_i_uid_high;   /* these 2 fields    */
10045                         __le16  l_i_gid_high;   /* were reserved2[0] */
10046 -                       __u32   l_i_reserved2;
10047 +                       __le16  l_i_tag;        /* Context Tag */
10048 +                       __u16   l_i_reserved2;
10049                 } linux2;
10050                 struct {
10051                         __u8    h_i_frag;       /* Fragment number */
10052 @@ -343,6 +348,7 @@ struct ext3_inode {
10053  #define i_gid_low      i_gid
10054  #define i_uid_high     osd2.linux2.l_i_uid_high
10055  #define i_gid_high     osd2.linux2.l_i_gid_high
10056 +#define i_raw_tag      osd2.linux2.l_i_tag
10057  #define i_reserved2    osd2.linux2.l_i_reserved2
10058  
10059  #elif defined(__GNU__)
10060 @@ -406,6 +412,7 @@ struct ext3_inode {
10061  #define EXT3_MOUNT_GRPQUOTA            0x200000 /* "old" group quota */
10062  #define EXT3_MOUNT_DATA_ERR_ABORT      0x400000 /* Abort on file data write
10063                                                   * error in ordered mode */
10064 +#define EXT3_MOUNT_TAGGED              (1<<24) /* Enable Context Tags */
10065  
10066  /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
10067  #ifndef _LINUX_EXT2_FS_H
10068 @@ -909,6 +916,7 @@ extern void ext3_get_inode_flags(struct 
10069  extern void ext3_set_aops(struct inode *inode);
10070  extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
10071                        u64 start, u64 len);
10072 +extern int ext3_sync_flags(struct inode *, int, int);
10073  
10074  /* ioctl.c */
10075  extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
10076 diff -NurpP --minimal linux-2.6.35.2/include/linux/fs.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/fs.h
10077 --- linux-2.6.35.2/include/linux/fs.h   2010-08-14 18:16:59.000000000 +0200
10078 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/fs.h     2010-08-14 18:21:44.000000000 +0200
10079 @@ -209,6 +209,9 @@ struct inodes_stat_t {
10080  #define MS_KERNMOUNT   (1<<22) /* this is a kern_mount call */
10081  #define MS_I_VERSION   (1<<23) /* Update inode I_version field */
10082  #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
10083 +#define MS_TAGGED      (1<<25) /* use generic inode tagging */
10084 +#define MS_TAGID       (1<<26) /* use specific tag for this mount */
10085 +#define MS_NOTAGCHECK  (1<<27) /* don't check tags */
10086  #define MS_BORN                (1<<29)
10087  #define MS_ACTIVE      (1<<30)
10088  #define MS_NOUSER      (1<<31)
10089 @@ -236,6 +239,14 @@ struct inodes_stat_t {
10090  #define S_NOCMTIME     128     /* Do not update file c/mtime */
10091  #define S_SWAPFILE     256     /* Do not truncate: swapon got its bmaps */
10092  #define S_PRIVATE      512     /* Inode is fs-internal */
10093 +#define S_IXUNLINK     1024    /* Immutable Invert on unlink */
10094 +
10095 +/* Linux-VServer related Inode flags */
10096 +
10097 +#define V_VALID                1
10098 +#define V_XATTR                2
10099 +#define V_BARRIER      4       /* Barrier for chroot() */
10100 +#define V_COW          8       /* Copy on Write */
10101  
10102  /*
10103   * Note that nosuid etc flags are inode-specific: setting some file-system
10104 @@ -258,12 +269,15 @@ struct inodes_stat_t {
10105  #define IS_DIRSYNC(inode)      (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
10106                                         ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
10107  #define IS_MANDLOCK(inode)     __IS_FLG(inode, MS_MANDLOCK)
10108 -#define IS_NOATIME(inode)   __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10109 -#define IS_I_VERSION(inode)   __IS_FLG(inode, MS_I_VERSION)
10110 +#define IS_NOATIME(inode)      __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10111 +#define IS_I_VERSION(inode)    __IS_FLG(inode, MS_I_VERSION)
10112 +#define IS_TAGGED(inode)       __IS_FLG(inode, MS_TAGGED)
10113  
10114  #define IS_NOQUOTA(inode)      ((inode)->i_flags & S_NOQUOTA)
10115  #define IS_APPEND(inode)       ((inode)->i_flags & S_APPEND)
10116  #define IS_IMMUTABLE(inode)    ((inode)->i_flags & S_IMMUTABLE)
10117 +#define IS_IXUNLINK(inode)     ((inode)->i_flags & S_IXUNLINK)
10118 +#define IS_IXORUNLINK(inode)   ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
10119  #define IS_POSIXACL(inode)     __IS_FLG(inode, MS_POSIXACL)
10120  
10121  #define IS_DEADDIR(inode)      ((inode)->i_flags & S_DEAD)
10122 @@ -271,6 +285,16 @@ struct inodes_stat_t {
10123  #define IS_SWAPFILE(inode)     ((inode)->i_flags & S_SWAPFILE)
10124  #define IS_PRIVATE(inode)      ((inode)->i_flags & S_PRIVATE)
10125  
10126 +#define IS_BARRIER(inode)      (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
10127 +
10128 +#ifdef CONFIG_VSERVER_COWBL
10129 +#  define IS_COW(inode)                (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
10130 +#  define IS_COW_LINK(inode)   (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
10131 +#else
10132 +#  define IS_COW(inode)                (0)
10133 +#  define IS_COW_LINK(inode)   (0)
10134 +#endif
10135 +
10136  /* the read-only stuff doesn't really belong here, but any other place is
10137     probably as bad and I don't want to create yet another include file. */
10138  
10139 @@ -353,11 +377,14 @@ struct inodes_stat_t {
10140  #define FS_TOPDIR_FL                   0x00020000 /* Top of directory hierarchies*/
10141  #define FS_EXTENT_FL                   0x00080000 /* Extents */
10142  #define FS_DIRECTIO_FL                 0x00100000 /* Use direct i/o */
10143 +#define FS_IXUNLINK_FL                 0x08000000 /* Immutable invert on unlink */
10144  #define FS_RESERVED_FL                 0x80000000 /* reserved for ext2 lib */
10145  
10146 -#define FS_FL_USER_VISIBLE             0x0003DFFF /* User visible flags */
10147 -#define FS_FL_USER_MODIFIABLE          0x000380FF /* User modifiable flags */
10148 +#define FS_BARRIER_FL                  0x04000000 /* Barrier for chroot() */
10149 +#define FS_COW_FL                      0x20000000 /* Copy on Write marker */
10150  
10151 +#define FS_FL_USER_VISIBLE             0x0103DFFF /* User visible flags */
10152 +#define FS_FL_USER_MODIFIABLE          0x010380FF /* User modifiable flags */
10153  
10154  #define SYNC_FILE_RANGE_WAIT_BEFORE    1
10155  #define SYNC_FILE_RANGE_WRITE          2
10156 @@ -439,6 +466,7 @@ typedef void (dio_iodone_t)(struct kiocb
10157  #define ATTR_KILL_PRIV (1 << 14)
10158  #define ATTR_OPEN      (1 << 15) /* Truncating from open(O_TRUNC) */
10159  #define ATTR_TIMES_SET (1 << 16)
10160 +#define ATTR_TAG       (1 << 17)
10161  
10162  /*
10163   * This is the Inode Attributes structure, used for notify_change().  It
10164 @@ -454,6 +482,7 @@ struct iattr {
10165         umode_t         ia_mode;
10166         uid_t           ia_uid;
10167         gid_t           ia_gid;
10168 +       tag_t           ia_tag;
10169         loff_t          ia_size;
10170         struct timespec ia_atime;
10171         struct timespec ia_mtime;
10172 @@ -467,6 +496,9 @@ struct iattr {
10173         struct file     *ia_file;
10174  };
10175  
10176 +#define ATTR_FLAG_BARRIER      512     /* Barrier for chroot() */
10177 +#define ATTR_FLAG_IXUNLINK     1024    /* Immutable invert on unlink */
10178 +
10179  /*
10180   * Includes for diskquotas.
10181   */
10182 @@ -733,7 +765,9 @@ struct inode {
10183         unsigned int            i_nlink;
10184         uid_t                   i_uid;
10185         gid_t                   i_gid;
10186 +       tag_t                   i_tag;
10187         dev_t                   i_rdev;
10188 +       dev_t                   i_mdev;
10189         unsigned int            i_blkbits;
10190         u64                     i_version;
10191         loff_t                  i_size;
10192 @@ -780,7 +814,8 @@ struct inode {
10193         unsigned long           i_state;
10194         unsigned long           dirtied_when;   /* jiffies of first dirtying */
10195  
10196 -       unsigned int            i_flags;
10197 +       unsigned short          i_flags;
10198 +       unsigned short          i_vflags;
10199  
10200         atomic_t                i_writecount;
10201  #ifdef CONFIG_SECURITY
10202 @@ -868,12 +903,12 @@ static inline void i_size_write(struct i
10203  
10204  static inline unsigned iminor(const struct inode *inode)
10205  {
10206 -       return MINOR(inode->i_rdev);
10207 +       return MINOR(inode->i_mdev);
10208  }
10209  
10210  static inline unsigned imajor(const struct inode *inode)
10211  {
10212 -       return MAJOR(inode->i_rdev);
10213 +       return MAJOR(inode->i_mdev);
10214  }
10215  
10216  extern struct block_device *I_BDEV(struct inode *inode);
10217 @@ -932,6 +967,7 @@ struct file {
10218         loff_t                  f_pos;
10219         struct fown_struct      f_owner;
10220         const struct cred       *f_cred;
10221 +       xid_t                   f_xid;
10222         struct file_ra_state    f_ra;
10223  
10224         u64                     f_version;
10225 @@ -1074,6 +1110,7 @@ struct file_lock {
10226         struct file *fl_file;
10227         loff_t fl_start;
10228         loff_t fl_end;
10229 +       xid_t fl_xid;
10230  
10231         struct fasync_struct *  fl_fasync; /* for lease break notifications */
10232         unsigned long fl_break_time;    /* for nonblocking lease breaks */
10233 @@ -1535,6 +1572,7 @@ struct inode_operations {
10234         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
10235         ssize_t (*listxattr) (struct dentry *, char *, size_t);
10236         int (*removexattr) (struct dentry *, const char *);
10237 +       int (*sync_flags) (struct inode *, int, int);
10238         void (*truncate_range)(struct inode *, loff_t, loff_t);
10239         long (*fallocate)(struct inode *inode, int mode, loff_t offset,
10240                           loff_t len);
10241 @@ -1555,6 +1593,7 @@ extern ssize_t vfs_readv(struct file *, 
10242                 unsigned long, loff_t *);
10243  extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
10244                 unsigned long, loff_t *);
10245 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
10246  
10247  struct super_operations {
10248         struct inode *(*alloc_inode)(struct super_block *sb);
10249 @@ -2378,6 +2417,7 @@ extern int dcache_dir_open(struct inode 
10250  extern int dcache_dir_close(struct inode *, struct file *);
10251  extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
10252  extern int dcache_readdir(struct file *, void *, filldir_t);
10253 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
10254  extern int simple_setattr(struct dentry *, struct iattr *);
10255  extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
10256  extern int simple_statfs(struct dentry *, struct kstatfs *);
10257 diff -NurpP --minimal linux-2.6.35.2/include/linux/gfs2_ondisk.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/gfs2_ondisk.h
10258 --- linux-2.6.35.2/include/linux/gfs2_ondisk.h  2010-07-07 18:31:55.000000000 +0200
10259 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/gfs2_ondisk.h    2010-08-02 17:05:06.000000000 +0200
10260 @@ -211,6 +211,9 @@ enum {
10261         gfs2fl_NoAtime          = 7,
10262         gfs2fl_Sync             = 8,
10263         gfs2fl_System           = 9,
10264 +       gfs2fl_IXUnlink         = 16,
10265 +       gfs2fl_Barrier          = 17,
10266 +       gfs2fl_Cow              = 18,
10267         gfs2fl_TruncInProg      = 29,
10268         gfs2fl_InheritDirectio  = 30,
10269         gfs2fl_InheritJdata     = 31,
10270 @@ -227,6 +230,9 @@ enum {
10271  #define GFS2_DIF_NOATIME               0x00000080
10272  #define GFS2_DIF_SYNC                  0x00000100
10273  #define GFS2_DIF_SYSTEM                        0x00000200 /* New in gfs2 */
10274 +#define GFS2_DIF_IXUNLINK              0x00010000
10275 +#define GFS2_DIF_BARRIER               0x00020000
10276 +#define GFS2_DIF_COW                   0x00040000
10277  #define GFS2_DIF_TRUNC_IN_PROG         0x20000000 /* New in gfs2 */
10278  #define GFS2_DIF_INHERIT_DIRECTIO      0x40000000
10279  #define GFS2_DIF_INHERIT_JDATA         0x80000000
10280 diff -NurpP --minimal linux-2.6.35.2/include/linux/if_tun.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/if_tun.h
10281 --- linux-2.6.35.2/include/linux/if_tun.h       2010-08-02 16:52:54.000000000 +0200
10282 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/if_tun.h 2010-08-02 18:17:46.000000000 +0200
10283 @@ -53,6 +53,7 @@
10284  #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
10285  #define TUNGETVNETHDRSZ _IOR('T', 215, int)
10286  #define TUNSETVNETHDRSZ _IOW('T', 216, int)
10287 +#define TUNSETNID     _IOW('T', 217, int)
10288  
10289  /* TUNSETIFF ifr flags */
10290  #define IFF_TUN                0x0001
10291 diff -NurpP --minimal linux-2.6.35.2/include/linux/init_task.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/init_task.h
10292 --- linux-2.6.35.2/include/linux/init_task.h    2010-08-02 16:52:54.000000000 +0200
10293 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/init_task.h      2010-08-02 17:05:06.000000000 +0200
10294 @@ -172,6 +172,10 @@ extern struct cred init_cred;
10295         INIT_FTRACE_GRAPH                                               \
10296         INIT_TRACE_RECURSION                                            \
10297         INIT_TASK_RCU_PREEMPT(tsk)                                      \
10298 +       .xid            = 0,                                            \
10299 +       .vx_info        = NULL,                                         \
10300 +       .nid            = 0,                                            \
10301 +       .nx_info        = NULL,                                         \
10302  }
10303  
10304  
10305 diff -NurpP --minimal linux-2.6.35.2/include/linux/ipc.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/ipc.h
10306 --- linux-2.6.35.2/include/linux/ipc.h  2009-12-03 20:02:55.000000000 +0100
10307 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/ipc.h    2010-08-02 17:05:06.000000000 +0200
10308 @@ -91,6 +91,7 @@ struct kern_ipc_perm
10309         key_t           key;
10310         uid_t           uid;
10311         gid_t           gid;
10312 +       xid_t           xid;
10313         uid_t           cuid;
10314         gid_t           cgid;
10315         mode_t          mode; 
10316 diff -NurpP --minimal linux-2.6.35.2/include/linux/Kbuild linux-2.6.35.2-vs2.3.0.36.31/include/linux/Kbuild
10317 --- linux-2.6.35.2/include/linux/Kbuild 2010-08-14 18:16:59.000000000 +0200
10318 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/Kbuild   2010-08-14 18:19:32.000000000 +0200
10319 @@ -388,5 +388,8 @@ unifdef-y += xattr.h
10320  unifdef-y += xfrm.h
10321  
10322  objhdr-y += version.h
10323 +
10324 +header-y += vserver/
10325  header-y += wimax.h
10326  header-y += wimax/
10327 +
10328 diff -NurpP --minimal linux-2.6.35.2/include/linux/loop.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/loop.h
10329 --- linux-2.6.35.2/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
10330 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/loop.h   2010-08-02 17:05:06.000000000 +0200
10331 @@ -45,6 +45,7 @@ struct loop_device {
10332         struct loop_func_table *lo_encryption;
10333         __u32           lo_init[2];
10334         uid_t           lo_key_owner;   /* Who set the key */
10335 +       xid_t           lo_xid;
10336         int             (*ioctl)(struct loop_device *, int cmd, 
10337                                  unsigned long arg); 
10338  
10339 diff -NurpP --minimal linux-2.6.35.2/include/linux/magic.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/magic.h
10340 --- linux-2.6.35.2/include/linux/magic.h        2010-07-07 18:31:55.000000000 +0200
10341 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/magic.h  2010-08-02 17:05:06.000000000 +0200
10342 @@ -3,7 +3,7 @@
10343  
10344  #define ADFS_SUPER_MAGIC       0xadf5
10345  #define AFFS_SUPER_MAGIC       0xadff
10346 -#define AFS_SUPER_MAGIC                0x5346414F
10347 +#define AFS_SUPER_MAGIC                0x5346414F
10348  #define AUTOFS_SUPER_MAGIC     0x0187
10349  #define CODA_SUPER_MAGIC       0x73757245
10350  #define CRAMFS_MAGIC           0x28cd3d45      /* some random number */
10351 @@ -38,6 +38,7 @@
10352  #define NFS_SUPER_MAGIC                0x6969
10353  #define OPENPROM_SUPER_MAGIC   0x9fa1
10354  #define PROC_SUPER_MAGIC       0x9fa0
10355 +#define DEVPTS_SUPER_MAGIC     0x1cd1
10356  #define QNX4_SUPER_MAGIC       0x002f          /* qnx4 fs detection */
10357  
10358  #define REISERFS_SUPER_MAGIC   0x52654973      /* used by gcc */
10359 diff -NurpP --minimal linux-2.6.35.2/include/linux/major.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/major.h
10360 --- linux-2.6.35.2/include/linux/major.h        2009-09-10 15:26:25.000000000 +0200
10361 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/major.h  2010-08-02 17:05:06.000000000 +0200
10362 @@ -15,6 +15,7 @@
10363  #define HD_MAJOR               IDE0_MAJOR
10364  #define PTY_SLAVE_MAJOR                3
10365  #define TTY_MAJOR              4
10366 +#define VROOT_MAJOR            4
10367  #define TTYAUX_MAJOR           5
10368  #define LP_MAJOR               6
10369  #define VCS_MAJOR              7
10370 diff -NurpP --minimal linux-2.6.35.2/include/linux/memcontrol.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/memcontrol.h
10371 --- linux-2.6.35.2/include/linux/memcontrol.h   2010-08-02 16:52:54.000000000 +0200
10372 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/memcontrol.h     2010-08-02 17:05:06.000000000 +0200
10373 @@ -77,6 +77,13 @@ int task_in_mem_cgroup(struct task_struc
10374  extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
10375  extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
10376  
10377 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
10378 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
10379 +
10380 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
10381 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
10382 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
10383 +
10384  static inline
10385  int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
10386  {
10387 diff -NurpP --minimal linux-2.6.35.2/include/linux/mm_types.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/mm_types.h
10388 --- linux-2.6.35.2/include/linux/mm_types.h     2010-07-07 18:31:55.000000000 +0200
10389 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/mm_types.h       2010-08-02 17:05:06.000000000 +0200
10390 @@ -269,6 +269,7 @@ struct mm_struct {
10391  
10392         /* Architecture-specific MM context */
10393         mm_context_t context;
10394 +       struct vx_info *mm_vx_info;
10395  
10396         /* Swap token stuff */
10397         /*
10398 diff -NurpP --minimal linux-2.6.35.2/include/linux/mount.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/mount.h
10399 --- linux-2.6.35.2/include/linux/mount.h        2010-07-07 18:31:56.000000000 +0200
10400 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/mount.h  2010-08-02 17:05:06.000000000 +0200
10401 @@ -47,6 +47,9 @@ struct mnt_namespace;
10402  
10403  #define MNT_INTERNAL   0x4000
10404  
10405 +#define MNT_TAGID      0x10000
10406 +#define MNT_NOTAG      0x20000
10407 +
10408  struct vfsmount {
10409         struct list_head mnt_hash;
10410         struct vfsmount *mnt_parent;    /* fs we are mounted on */
10411 @@ -81,6 +84,7 @@ struct vfsmount {
10412  #else
10413         int mnt_writers;
10414  #endif
10415 +       tag_t mnt_tag;                  /* tagging used for vfsmount */
10416  };
10417  
10418  static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
10419 diff -NurpP --minimal linux-2.6.35.2/include/linux/net.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/net.h
10420 --- linux-2.6.35.2/include/linux/net.h  2010-08-02 16:52:55.000000000 +0200
10421 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/net.h    2010-08-02 17:05:06.000000000 +0200
10422 @@ -71,6 +71,7 @@ struct net;
10423  #define SOCK_NOSPACE           2
10424  #define SOCK_PASSCRED          3
10425  #define SOCK_PASSSEC           4
10426 +#define SOCK_USER_SOCKET       5
10427  
10428  #ifndef ARCH_HAS_SOCKET_TYPES
10429  /**
10430 diff -NurpP --minimal linux-2.6.35.2/include/linux/nfs_mount.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/nfs_mount.h
10431 --- linux-2.6.35.2/include/linux/nfs_mount.h    2009-03-24 14:22:43.000000000 +0100
10432 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/nfs_mount.h      2010-08-02 17:05:06.000000000 +0200
10433 @@ -63,7 +63,8 @@ struct nfs_mount_data {
10434  #define NFS_MOUNT_SECFLAVOUR   0x2000  /* 5 */
10435  #define NFS_MOUNT_NORDIRPLUS   0x4000  /* 5 */
10436  #define NFS_MOUNT_UNSHARED     0x8000  /* 5 */
10437 -#define NFS_MOUNT_FLAGMASK     0xFFFF
10438 +#define NFS_MOUNT_TAGGED       0x10000 /* context tagging */
10439 +#define NFS_MOUNT_FLAGMASK     0x1FFFF
10440  
10441  /* The following are for internal use only */
10442  #define NFS_MOUNT_LOOKUP_CACHE_NONEG   0x10000
10443 diff -NurpP --minimal linux-2.6.35.2/include/linux/nsproxy.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/nsproxy.h
10444 --- linux-2.6.35.2/include/linux/nsproxy.h      2009-06-11 17:13:17.000000000 +0200
10445 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/nsproxy.h        2010-08-02 17:05:06.000000000 +0200
10446 @@ -3,6 +3,7 @@
10447  
10448  #include <linux/spinlock.h>
10449  #include <linux/sched.h>
10450 +#include <linux/vserver/debug.h>
10451  
10452  struct mnt_namespace;
10453  struct uts_namespace;
10454 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
10455  }
10456  
10457  int copy_namespaces(unsigned long flags, struct task_struct *tsk);
10458 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
10459  void exit_task_namespaces(struct task_struct *tsk);
10460  void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
10461  void free_nsproxy(struct nsproxy *ns);
10462  int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
10463         struct fs_struct *);
10464  
10465 -static inline void put_nsproxy(struct nsproxy *ns)
10466 +#define        get_nsproxy(n)  __get_nsproxy(n, __FILE__, __LINE__)
10467 +
10468 +static inline void __get_nsproxy(struct nsproxy *ns,
10469 +       const char *_file, int _line)
10470  {
10471 -       if (atomic_dec_and_test(&ns->count)) {
10472 -               free_nsproxy(ns);
10473 -       }
10474 +       vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
10475 +               ns, atomic_read(&ns->count), _file, _line);
10476 +       atomic_inc(&ns->count);
10477  }
10478  
10479 -static inline void get_nsproxy(struct nsproxy *ns)
10480 +#define        put_nsproxy(n)  __put_nsproxy(n, __FILE__, __LINE__)
10481 +
10482 +static inline void __put_nsproxy(struct nsproxy *ns,
10483 +       const char *_file, int _line)
10484  {
10485 -       atomic_inc(&ns->count);
10486 +       vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
10487 +               ns, atomic_read(&ns->count), _file, _line);
10488 +       if (atomic_dec_and_test(&ns->count)) {
10489 +               free_nsproxy(ns);
10490 +       }
10491  }
10492  
10493  #ifdef CONFIG_CGROUP_NS
10494 diff -NurpP --minimal linux-2.6.35.2/include/linux/pid.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/pid.h
10495 --- linux-2.6.35.2/include/linux/pid.h  2009-03-24 14:22:43.000000000 +0100
10496 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/pid.h    2010-08-02 17:05:06.000000000 +0200
10497 @@ -8,7 +8,8 @@ enum pid_type
10498         PIDTYPE_PID,
10499         PIDTYPE_PGID,
10500         PIDTYPE_SID,
10501 -       PIDTYPE_MAX
10502 +       PIDTYPE_MAX,
10503 +       PIDTYPE_REALPID
10504  };
10505  
10506  /*
10507 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
10508  }
10509  
10510  pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
10511 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
10512  pid_t pid_vnr(struct pid *pid);
10513  
10514  #define do_each_pid_task(pid, type, task)                              \
10515 diff -NurpP --minimal linux-2.6.35.2/include/linux/proc_fs.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/proc_fs.h
10516 --- linux-2.6.35.2/include/linux/proc_fs.h      2009-12-03 20:02:56.000000000 +0100
10517 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/proc_fs.h        2010-08-02 17:05:06.000000000 +0200
10518 @@ -56,6 +56,7 @@ struct proc_dir_entry {
10519         nlink_t nlink;
10520         uid_t uid;
10521         gid_t gid;
10522 +       int vx_flags;
10523         loff_t size;
10524         const struct inode_operations *proc_iops;
10525         /*
10526 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void 
10527  extern void kclist_add(struct kcore_list *, void *, size_t, int type);
10528  #endif
10529  
10530 +struct vx_info;
10531 +struct nx_info;
10532 +
10533  union proc_op {
10534         int (*proc_get_link)(struct inode *, struct path *);
10535         int (*proc_read)(struct task_struct *task, char *page);
10536         int (*proc_show)(struct seq_file *m,
10537                 struct pid_namespace *ns, struct pid *pid,
10538                 struct task_struct *task);
10539 +       int (*proc_vs_read)(char *page);
10540 +       int (*proc_vxi_read)(struct vx_info *vxi, char *page);
10541 +       int (*proc_nxi_read)(struct nx_info *nxi, char *page);
10542  };
10543  
10544  struct ctl_table_header;
10545 @@ -263,6 +270,7 @@ struct ctl_table;
10546  
10547  struct proc_inode {
10548         struct pid *pid;
10549 +       int vx_flags;
10550         int fd;
10551         union proc_op op;
10552         struct proc_dir_entry *pde;
10553 diff -NurpP --minimal linux-2.6.35.2/include/linux/quotaops.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/quotaops.h
10554 --- linux-2.6.35.2/include/linux/quotaops.h     2010-08-02 16:52:55.000000000 +0200
10555 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/quotaops.h       2010-08-02 22:35:47.000000000 +0200
10556 @@ -8,6 +8,7 @@
10557  #define _LINUX_QUOTAOPS_
10558  
10559  #include <linux/fs.h>
10560 +#include <linux/vs_dlimit.h>
10561  
10562  #define DQUOT_SPACE_WARN       0x1
10563  #define DQUOT_SPACE_RESERVE    0x2
10564 @@ -209,11 +210,12 @@ static inline void dquot_drop(struct ino
10565  
10566  static inline int dquot_alloc_inode(const struct inode *inode)
10567  {
10568 -       return 0;
10569 +       return dl_alloc_inode(inode);
10570  }
10571  
10572  static inline void dquot_free_inode(const struct inode *inode)
10573  {
10574 +       dl_free_inode(inode);
10575  }
10576  
10577  static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
10578 @@ -224,6 +226,10 @@ static inline int dquot_transfer(struct 
10579  static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
10580                 int flags)
10581  {
10582 +       int ret = 0;
10583 +
10584 +       if ((ret = dl_alloc_space(inode, number)))
10585 +               return ret;
10586         if (!(flags & DQUOT_SPACE_RESERVE))
10587                 inode_add_bytes(inode, number);
10588         return 0;
10589 @@ -234,6 +240,7 @@ static inline void __dquot_free_space(st
10590  {
10591         if (!(flags & DQUOT_SPACE_RESERVE))
10592                 inode_sub_bytes(inode, number);
10593 +       dl_free_space(inode, number);
10594  }
10595  
10596  static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
10597 diff -NurpP --minimal linux-2.6.35.2/include/linux/reboot.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/reboot.h
10598 --- linux-2.6.35.2/include/linux/reboot.h       2010-07-07 18:31:56.000000000 +0200
10599 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/reboot.h 2010-08-02 17:05:06.000000000 +0200
10600 @@ -33,6 +33,7 @@
10601  #define        LINUX_REBOOT_CMD_RESTART2       0xA1B2C3D4
10602  #define        LINUX_REBOOT_CMD_SW_SUSPEND     0xD000FCE2
10603  #define        LINUX_REBOOT_CMD_KEXEC          0x45584543
10604 +#define        LINUX_REBOOT_CMD_OOM            0xDEADBEEF
10605  
10606  
10607  #ifdef __KERNEL__
10608 diff -NurpP --minimal linux-2.6.35.2/include/linux/reiserfs_fs.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/reiserfs_fs.h
10609 --- linux-2.6.35.2/include/linux/reiserfs_fs.h  2010-07-07 18:31:56.000000000 +0200
10610 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/reiserfs_fs.h    2010-08-02 17:05:06.000000000 +0200
10611 @@ -977,6 +977,11 @@ struct stat_data_v1 {
10612  #define REISERFS_COMPR_FL     FS_COMPR_FL
10613  #define REISERFS_NOTAIL_FL    FS_NOTAIL_FL
10614  
10615 +/* unfortunately reiserfs sdattr is only 16 bit */
10616 +#define REISERFS_IXUNLINK_FL  (FS_IXUNLINK_FL >> 16)
10617 +#define REISERFS_BARRIER_FL   (FS_BARRIER_FL >> 16)
10618 +#define REISERFS_COW_FL       (FS_COW_FL >> 16)
10619 +
10620  /* persistent flags that file inherits from the parent directory */
10621  #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL |        \
10622                                 REISERFS_SYNC_FL |      \
10623 @@ -986,6 +991,9 @@ struct stat_data_v1 {
10624                                 REISERFS_COMPR_FL |     \
10625                                 REISERFS_NOTAIL_FL )
10626  
10627 +#define REISERFS_FL_USER_VISIBLE       0x80FF
10628 +#define REISERFS_FL_USER_MODIFIABLE    0x80FF
10629 +
10630  /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10631     address blocks) */
10632  struct stat_data {
10633 @@ -2071,6 +2079,7 @@ static inline void reiserfs_update_sd(st
10634  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10635  void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10636  int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10637 +int reiserfs_sync_flags(struct inode *inode, int, int);
10638  
10639  /* namei.c */
10640  void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
10641 diff -NurpP --minimal linux-2.6.35.2/include/linux/reiserfs_fs_sb.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/reiserfs_fs_sb.h
10642 --- linux-2.6.35.2/include/linux/reiserfs_fs_sb.h       2010-02-25 11:52:07.000000000 +0100
10643 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/reiserfs_fs_sb.h 2010-08-02 17:05:06.000000000 +0200
10644 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
10645         REISERFS_EXPOSE_PRIVROOT,
10646         REISERFS_BARRIER_NONE,
10647         REISERFS_BARRIER_FLUSH,
10648 +       REISERFS_TAGGED,
10649  
10650         /* Actions on error */
10651         REISERFS_ERROR_PANIC,
10652 diff -NurpP --minimal linux-2.6.35.2/include/linux/sched.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/sched.h
10653 --- linux-2.6.35.2/include/linux/sched.h        2010-08-14 18:16:59.000000000 +0200
10654 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/sched.h  2010-08-14 18:19:32.000000000 +0200
10655 @@ -1343,6 +1343,14 @@ struct task_struct {
10656  #endif
10657         seccomp_t seccomp;
10658  
10659 +/* vserver context data */
10660 +       struct vx_info *vx_info;
10661 +       struct nx_info *nx_info;
10662 +
10663 +       xid_t xid;
10664 +       nid_t nid;
10665 +       tag_t tag;
10666 +
10667  /* Thread group tracking */
10668         u32 parent_exec_id;
10669         u32 self_exec_id;
10670 @@ -1577,6 +1585,11 @@ struct pid_namespace;
10671  pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
10672                         struct pid_namespace *ns);
10673  
10674 +#include <linux/vserver/base.h>
10675 +#include <linux/vserver/context.h>
10676 +#include <linux/vserver/debug.h>
10677 +#include <linux/vserver/pid.h>
10678 +
10679  static inline pid_t task_pid_nr(struct task_struct *tsk)
10680  {
10681         return tsk->pid;
10682 @@ -1590,7 +1603,8 @@ static inline pid_t task_pid_nr_ns(struc
10683  
10684  static inline pid_t task_pid_vnr(struct task_struct *tsk)
10685  {
10686 -       return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10687 +       // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10688 +       return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
10689  }
10690  
10691  
10692 @@ -1603,7 +1617,7 @@ pid_t task_tgid_nr_ns(struct task_struct
10693  
10694  static inline pid_t task_tgid_vnr(struct task_struct *tsk)
10695  {
10696 -       return pid_vnr(task_tgid(tsk));
10697 +       return vx_map_tgid(pid_vnr(task_tgid(tsk)));
10698  }
10699  
10700  
10701 diff -NurpP --minimal linux-2.6.35.2/include/linux/shmem_fs.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/shmem_fs.h
10702 --- linux-2.6.35.2/include/linux/shmem_fs.h     2010-02-25 11:52:08.000000000 +0100
10703 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/shmem_fs.h       2010-08-02 17:05:06.000000000 +0200
10704 @@ -8,6 +8,9 @@
10705  
10706  #define SHMEM_NR_DIRECT 16
10707  
10708 +#define TMPFS_SUPER_MAGIC      0x01021994
10709 +
10710 +
10711  struct shmem_inode_info {
10712         spinlock_t              lock;
10713         unsigned long           flags;
10714 diff -NurpP --minimal linux-2.6.35.2/include/linux/stat.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/stat.h
10715 --- linux-2.6.35.2/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
10716 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/stat.h   2010-08-02 17:05:06.000000000 +0200
10717 @@ -66,6 +66,7 @@ struct kstat {
10718         unsigned int    nlink;
10719         uid_t           uid;
10720         gid_t           gid;
10721 +       tag_t           tag;
10722         dev_t           rdev;
10723         loff_t          size;
10724         struct timespec  atime;
10725 diff -NurpP --minimal linux-2.6.35.2/include/linux/sunrpc/auth.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/sunrpc/auth.h
10726 --- linux-2.6.35.2/include/linux/sunrpc/auth.h  2010-08-02 16:52:56.000000000 +0200
10727 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/sunrpc/auth.h    2010-08-02 17:05:06.000000000 +0200
10728 @@ -25,6 +25,7 @@
10729  struct auth_cred {
10730         uid_t   uid;
10731         gid_t   gid;
10732 +       tag_t   tag;
10733         struct group_info *group_info;
10734         unsigned char machine_cred : 1;
10735  };
10736 diff -NurpP --minimal linux-2.6.35.2/include/linux/sunrpc/clnt.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/sunrpc/clnt.h
10737 --- linux-2.6.35.2/include/linux/sunrpc/clnt.h  2009-12-03 20:02:56.000000000 +0100
10738 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/sunrpc/clnt.h    2010-08-02 17:05:06.000000000 +0200
10739 @@ -49,7 +49,8 @@ struct rpc_clnt {
10740         unsigned int            cl_softrtry : 1,/* soft timeouts */
10741                                 cl_discrtry : 1,/* disconnect before retry */
10742                                 cl_autobind : 1,/* use getport() */
10743 -                               cl_chatty   : 1;/* be verbose */
10744 +                               cl_chatty   : 1,/* be verbose */
10745 +                               cl_tag      : 1;/* context tagging */
10746  
10747         struct rpc_rtt *        cl_rtt;         /* RTO estimator data */
10748         const struct rpc_timeout *cl_timeout;   /* Timeout strategy */
10749 diff -NurpP --minimal linux-2.6.35.2/include/linux/syscalls.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/syscalls.h
10750 --- linux-2.6.35.2/include/linux/syscalls.h     2010-08-02 16:52:56.000000000 +0200
10751 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/syscalls.h       2010-08-02 17:05:06.000000000 +0200
10752 @@ -479,6 +479,8 @@ asmlinkage long sys_symlink(const char _
10753  asmlinkage long sys_unlink(const char __user *pathname);
10754  asmlinkage long sys_rename(const char __user *oldname,
10755                                 const char __user *newname);
10756 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
10757 +                               umode_t mode);
10758  asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
10759  asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
10760  
10761 diff -NurpP --minimal linux-2.6.35.2/include/linux/sysctl.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/sysctl.h
10762 --- linux-2.6.35.2/include/linux/sysctl.h       2010-08-02 16:52:56.000000000 +0200
10763 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/sysctl.h 2010-08-02 17:05:06.000000000 +0200
10764 @@ -60,6 +60,7 @@ enum
10765         CTL_ABI=9,              /* Binary emulation */
10766         CTL_CPU=10,             /* CPU stuff (speed scaling, etc) */
10767         CTL_ARLAN=254,          /* arlan wireless driver */
10768 +       CTL_VSERVER=4242,       /* Linux-VServer debug */
10769         CTL_S390DBF=5677,       /* s390 debug */
10770         CTL_SUNRPC=7249,        /* sunrpc debug */
10771         CTL_PM=9899,            /* frv power management */
10772 @@ -94,6 +95,7 @@ enum
10773  
10774         KERN_PANIC=15,          /* int: panic timeout */
10775         KERN_REALROOTDEV=16,    /* real root device to mount after initrd */
10776 +       KERN_VSHELPER=17,       /* string: path to vshelper policy agent */
10777  
10778         KERN_SPARC_REBOOT=21,   /* reboot command on Sparc */
10779         KERN_CTLALTDEL=22,      /* int: allow ctl-alt-del to reboot */
10780 diff -NurpP --minimal linux-2.6.35.2/include/linux/sysfs.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/sysfs.h
10781 --- linux-2.6.35.2/include/linux/sysfs.h        2010-08-02 16:52:56.000000000 +0200
10782 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/sysfs.h  2010-08-02 17:05:06.000000000 +0200
10783 @@ -18,6 +18,8 @@
10784  #include <linux/lockdep.h>
10785  #include <asm/atomic.h>
10786  
10787 +#define SYSFS_SUPER_MAGIC      0x62656572
10788 +
10789  struct kobject;
10790  struct module;
10791  enum kobj_ns_type;
10792 diff -NurpP --minimal linux-2.6.35.2/include/linux/time.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/time.h
10793 --- linux-2.6.35.2/include/linux/time.h 2010-08-02 16:52:56.000000000 +0200
10794 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/time.h   2010-08-02 17:05:06.000000000 +0200
10795 @@ -237,6 +237,9 @@ static __always_inline void timespec_add
10796         a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
10797         a->tv_nsec = ns;
10798  }
10799 +
10800 +#include <linux/vs_time.h>
10801 +
10802  #endif /* __KERNEL__ */
10803  
10804  #define NFDBITS                        __NFDBITS
10805 diff -NurpP --minimal linux-2.6.35.2/include/linux/types.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/types.h
10806 --- linux-2.6.35.2/include/linux/types.h        2010-08-02 16:52:56.000000000 +0200
10807 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/types.h  2010-08-02 17:05:06.000000000 +0200
10808 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t      uid_t;
10809  typedef __kernel_gid32_t       gid_t;
10810  typedef __kernel_uid16_t        uid16_t;
10811  typedef __kernel_gid16_t        gid16_t;
10812 +typedef unsigned int           xid_t;
10813 +typedef unsigned int           nid_t;
10814 +typedef unsigned int           tag_t;
10815  
10816  typedef unsigned long          uintptr_t;
10817  
10818 diff -NurpP --minimal linux-2.6.35.2/include/linux/vroot.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vroot.h
10819 --- linux-2.6.35.2/include/linux/vroot.h        1970-01-01 01:00:00.000000000 +0100
10820 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vroot.h  2010-08-02 17:05:06.000000000 +0200
10821 @@ -0,0 +1,51 @@
10822 +
10823 +/*
10824 + * include/linux/vroot.h
10825 + *
10826 + * written by Herbert Pötzl, 9/11/2002
10827 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
10828 + *
10829 + * Copyright (C) 2002-2007 by Herbert Pötzl.
10830 + * Redistribution of this file is permitted under the
10831 + * GNU General Public License.
10832 + */
10833 +
10834 +#ifndef _LINUX_VROOT_H
10835 +#define _LINUX_VROOT_H
10836 +
10837 +
10838 +#ifdef __KERNEL__
10839 +
10840 +/* Possible states of device */
10841 +enum {
10842 +       Vr_unbound,
10843 +       Vr_bound,
10844 +};
10845 +
10846 +struct vroot_device {
10847 +       int             vr_number;
10848 +       int             vr_refcnt;
10849 +
10850 +       struct semaphore        vr_ctl_mutex;
10851 +       struct block_device    *vr_device;
10852 +       int                     vr_state;
10853 +};
10854 +
10855 +
10856 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
10857 +
10858 +extern int register_vroot_grb(vroot_grb_func *);
10859 +extern int unregister_vroot_grb(vroot_grb_func *);
10860 +
10861 +#endif /* __KERNEL__ */
10862 +
10863 +#define MAX_VROOT_DEFAULT      8
10864 +
10865 +/*
10866 + * IOCTL commands --- we will commandeer 0x56 ('V')
10867 + */
10868 +
10869 +#define VROOT_SET_DEV          0x5600
10870 +#define VROOT_CLR_DEV          0x5601
10871 +
10872 +#endif /* _LINUX_VROOT_H */
10873 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_base.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_base.h
10874 --- linux-2.6.35.2/include/linux/vs_base.h      1970-01-01 01:00:00.000000000 +0100
10875 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_base.h        2010-08-02 17:05:06.000000000 +0200
10876 @@ -0,0 +1,10 @@
10877 +#ifndef _VS_BASE_H
10878 +#define _VS_BASE_H
10879 +
10880 +#include "vserver/base.h"
10881 +#include "vserver/check.h"
10882 +#include "vserver/debug.h"
10883 +
10884 +#else
10885 +#warning duplicate inclusion
10886 +#endif
10887 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_context.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_context.h
10888 --- linux-2.6.35.2/include/linux/vs_context.h   1970-01-01 01:00:00.000000000 +0100
10889 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_context.h     2010-08-02 17:05:06.000000000 +0200
10890 @@ -0,0 +1,242 @@
10891 +#ifndef _VS_CONTEXT_H
10892 +#define _VS_CONTEXT_H
10893 +
10894 +#include "vserver/base.h"
10895 +#include "vserver/check.h"
10896 +#include "vserver/context.h"
10897 +#include "vserver/history.h"
10898 +#include "vserver/debug.h"
10899 +
10900 +#include <linux/sched.h>
10901 +
10902 +
10903 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
10904 +
10905 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
10906 +       const char *_file, int _line, void *_here)
10907 +{
10908 +       if (!vxi)
10909 +               return NULL;
10910 +
10911 +       vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
10912 +               vxi, vxi ? vxi->vx_id : 0,
10913 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10914 +               _file, _line);
10915 +       __vxh_get_vx_info(vxi, _here);
10916 +
10917 +       atomic_inc(&vxi->vx_usecnt);
10918 +       return vxi;
10919 +}
10920 +
10921 +
10922 +extern void free_vx_info(struct vx_info *);
10923 +
10924 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
10925 +
10926 +static inline void __put_vx_info(struct vx_info *vxi,
10927 +       const char *_file, int _line, void *_here)
10928 +{
10929 +       if (!vxi)
10930 +               return;
10931 +
10932 +       vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
10933 +               vxi, vxi ? vxi->vx_id : 0,
10934 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10935 +               _file, _line);
10936 +       __vxh_put_vx_info(vxi, _here);
10937 +
10938 +       if (atomic_dec_and_test(&vxi->vx_usecnt))
10939 +               free_vx_info(vxi);
10940 +}
10941 +
10942 +
10943 +#define init_vx_info(p, i) \
10944 +       __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10945 +
10946 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10947 +       const char *_file, int _line, void *_here)
10948 +{
10949 +       if (vxi) {
10950 +               vxlprintk(VXD_CBIT(xid, 3),
10951 +                       "init_vx_info(%p[#%d.%d])",
10952 +                       vxi, vxi ? vxi->vx_id : 0,
10953 +                       vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10954 +                       _file, _line);
10955 +               __vxh_init_vx_info(vxi, vxp, _here);
10956 +
10957 +               atomic_inc(&vxi->vx_usecnt);
10958 +       }
10959 +       *vxp = vxi;
10960 +}
10961 +
10962 +
10963 +#define set_vx_info(p, i) \
10964 +       __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10965 +
10966 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10967 +       const char *_file, int _line, void *_here)
10968 +{
10969 +       struct vx_info *vxo;
10970 +
10971 +       if (!vxi)
10972 +               return;
10973 +
10974 +       vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
10975 +               vxi, vxi ? vxi->vx_id : 0,
10976 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10977 +               _file, _line);
10978 +       __vxh_set_vx_info(vxi, vxp, _here);
10979 +
10980 +       atomic_inc(&vxi->vx_usecnt);
10981 +       vxo = xchg(vxp, vxi);
10982 +       BUG_ON(vxo);
10983 +}
10984 +
10985 +
10986 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
10987 +
10988 +static inline void __clr_vx_info(struct vx_info **vxp,
10989 +       const char *_file, int _line, void *_here)
10990 +{
10991 +       struct vx_info *vxo;
10992 +
10993 +       vxo = xchg(vxp, NULL);
10994 +       if (!vxo)
10995 +               return;
10996 +
10997 +       vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
10998 +               vxo, vxo ? vxo->vx_id : 0,
10999 +               vxo ? atomic_read(&vxo->vx_usecnt) : 0,
11000 +               _file, _line);
11001 +       __vxh_clr_vx_info(vxo, vxp, _here);
11002 +
11003 +       if (atomic_dec_and_test(&vxo->vx_usecnt))
11004 +               free_vx_info(vxo);
11005 +}
11006 +
11007 +
11008 +#define claim_vx_info(v, p) \
11009 +       __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11010 +
11011 +static inline void __claim_vx_info(struct vx_info *vxi,
11012 +       struct task_struct *task,
11013 +       const char *_file, int _line, void *_here)
11014 +{
11015 +       vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
11016 +               vxi, vxi ? vxi->vx_id : 0,
11017 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11018 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11019 +               task, _file, _line);
11020 +       __vxh_claim_vx_info(vxi, task, _here);
11021 +
11022 +       atomic_inc(&vxi->vx_tasks);
11023 +}
11024 +
11025 +
11026 +extern void unhash_vx_info(struct vx_info *);
11027 +
11028 +#define release_vx_info(v, p) \
11029 +       __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11030 +
11031 +static inline void __release_vx_info(struct vx_info *vxi,
11032 +       struct task_struct *task,
11033 +       const char *_file, int _line, void *_here)
11034 +{
11035 +       vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
11036 +               vxi, vxi ? vxi->vx_id : 0,
11037 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11038 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11039 +               task, _file, _line);
11040 +       __vxh_release_vx_info(vxi, task, _here);
11041 +
11042 +       might_sleep();
11043 +
11044 +       if (atomic_dec_and_test(&vxi->vx_tasks))
11045 +               unhash_vx_info(vxi);
11046 +}
11047 +
11048 +
11049 +#define task_get_vx_info(p) \
11050 +       __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
11051 +
11052 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
11053 +       const char *_file, int _line, void *_here)
11054 +{
11055 +       struct vx_info *vxi;
11056 +
11057 +       task_lock(p);
11058 +       vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
11059 +               p, _file, _line);
11060 +       vxi = __get_vx_info(p->vx_info, _file, _line, _here);
11061 +       task_unlock(p);
11062 +       return vxi;
11063 +}
11064 +
11065 +
11066 +static inline void __wakeup_vx_info(struct vx_info *vxi)
11067 +{
11068 +       if (waitqueue_active(&vxi->vx_wait))
11069 +               wake_up_interruptible(&vxi->vx_wait);
11070 +}
11071 +
11072 +
11073 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
11074 +
11075 +static inline void __enter_vx_info(struct vx_info *vxi,
11076 +       struct vx_info_save *vxis, const char *_file, int _line)
11077 +{
11078 +       vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
11079 +               vxi, vxi ? vxi->vx_id : 0, vxis, current,
11080 +               current->xid, current->vx_info, _file, _line);
11081 +       vxis->vxi = xchg(&current->vx_info, vxi);
11082 +       vxis->xid = current->xid;
11083 +       current->xid = vxi ? vxi->vx_id : 0;
11084 +}
11085 +
11086 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
11087 +
11088 +static inline void __leave_vx_info(struct vx_info_save *vxis,
11089 +       const char *_file, int _line)
11090 +{
11091 +       vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
11092 +               vxis, vxis->xid, vxis->vxi, current,
11093 +               current->xid, current->vx_info, _file, _line);
11094 +       (void)xchg(&current->vx_info, vxis->vxi);
11095 +       current->xid = vxis->xid;
11096 +}
11097 +
11098 +
11099 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
11100 +{
11101 +       vxis->vxi = xchg(&current->vx_info, NULL);
11102 +       vxis->xid = xchg(&current->xid, (xid_t)0);
11103 +}
11104 +
11105 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
11106 +{
11107 +       (void)xchg(&current->xid, vxis->xid);
11108 +       (void)xchg(&current->vx_info, vxis->vxi);
11109 +}
11110 +
11111 +#define task_is_init(p) \
11112 +       __task_is_init(p, __FILE__, __LINE__, __HERE__)
11113 +
11114 +static inline int __task_is_init(struct task_struct *p,
11115 +       const char *_file, int _line, void *_here)
11116 +{
11117 +       int is_init = is_global_init(p);
11118 +
11119 +       task_lock(p);
11120 +       if (p->vx_info)
11121 +               is_init = p->vx_info->vx_initpid == p->pid;
11122 +       task_unlock(p);
11123 +       return is_init;
11124 +}
11125 +
11126 +extern void exit_vx_info(struct task_struct *, int);
11127 +extern void exit_vx_info_early(struct task_struct *, int);
11128 +
11129 +
11130 +#else
11131 +#warning duplicate inclusion
11132 +#endif
11133 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_cowbl.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_cowbl.h
11134 --- linux-2.6.35.2/include/linux/vs_cowbl.h     1970-01-01 01:00:00.000000000 +0100
11135 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_cowbl.h       2010-08-02 21:01:17.000000000 +0200
11136 @@ -0,0 +1,48 @@
11137 +#ifndef _VS_COWBL_H
11138 +#define _VS_COWBL_H
11139 +
11140 +#include <linux/fs.h>
11141 +#include <linux/dcache.h>
11142 +#include <linux/namei.h>
11143 +#include <linux/slab.h>
11144 +
11145 +extern struct dentry *cow_break_link(const char *pathname);
11146 +
11147 +static inline int cow_check_and_break(struct path *path)
11148 +{
11149 +       struct inode *inode = path->dentry->d_inode;
11150 +       int error = 0;
11151 +
11152 +       /* do we need this check? */
11153 +       if (IS_RDONLY(inode))
11154 +               return -EROFS;
11155 +
11156 +       if (IS_COW(inode)) {
11157 +               if (IS_COW_LINK(inode)) {
11158 +                       struct dentry *new_dentry, *old_dentry = path->dentry;
11159 +                       char *pp, *buf;
11160 +
11161 +                       buf = kmalloc(PATH_MAX, GFP_KERNEL);
11162 +                       if (!buf) {
11163 +                               return -ENOMEM;
11164 +                       }
11165 +                       pp = d_path(path, buf, PATH_MAX);
11166 +                       new_dentry = cow_break_link(pp);
11167 +                       kfree(buf);
11168 +                       if (!IS_ERR(new_dentry)) {
11169 +                               path->dentry = new_dentry;
11170 +                               dput(old_dentry);
11171 +                       } else
11172 +                               error = PTR_ERR(new_dentry);
11173 +               } else {
11174 +                       inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
11175 +                       inode->i_ctime = CURRENT_TIME;
11176 +                       mark_inode_dirty(inode);
11177 +               }
11178 +       }
11179 +       return error;
11180 +}
11181 +
11182 +#else
11183 +#warning duplicate inclusion
11184 +#endif
11185 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_cvirt.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_cvirt.h
11186 --- linux-2.6.35.2/include/linux/vs_cvirt.h     1970-01-01 01:00:00.000000000 +0100
11187 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_cvirt.h       2010-08-02 17:05:06.000000000 +0200
11188 @@ -0,0 +1,50 @@
11189 +#ifndef _VS_CVIRT_H
11190 +#define _VS_CVIRT_H
11191 +
11192 +#include "vserver/cvirt.h"
11193 +#include "vserver/context.h"
11194 +#include "vserver/base.h"
11195 +#include "vserver/check.h"
11196 +#include "vserver/debug.h"
11197 +
11198 +
11199 +static inline void vx_activate_task(struct task_struct *p)
11200 +{
11201 +       struct vx_info *vxi;
11202 +
11203 +       if ((vxi = p->vx_info)) {
11204 +               vx_update_load(vxi);
11205 +               atomic_inc(&vxi->cvirt.nr_running);
11206 +       }
11207 +}
11208 +
11209 +static inline void vx_deactivate_task(struct task_struct *p)
11210 +{
11211 +       struct vx_info *vxi;
11212 +
11213 +       if ((vxi = p->vx_info)) {
11214 +               vx_update_load(vxi);
11215 +               atomic_dec(&vxi->cvirt.nr_running);
11216 +       }
11217 +}
11218 +
11219 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11220 +{
11221 +       struct vx_info *vxi;
11222 +
11223 +       if ((vxi = p->vx_info))
11224 +               atomic_inc(&vxi->cvirt.nr_uninterruptible);
11225 +}
11226 +
11227 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11228 +{
11229 +       struct vx_info *vxi;
11230 +
11231 +       if ((vxi = p->vx_info))
11232 +               atomic_dec(&vxi->cvirt.nr_uninterruptible);
11233 +}
11234 +
11235 +
11236 +#else
11237 +#warning duplicate inclusion
11238 +#endif
11239 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_device.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_device.h
11240 --- linux-2.6.35.2/include/linux/vs_device.h    1970-01-01 01:00:00.000000000 +0100
11241 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_device.h      2010-08-02 17:05:06.000000000 +0200
11242 @@ -0,0 +1,45 @@
11243 +#ifndef _VS_DEVICE_H
11244 +#define _VS_DEVICE_H
11245 +
11246 +#include "vserver/base.h"
11247 +#include "vserver/device.h"
11248 +#include "vserver/debug.h"
11249 +
11250 +
11251 +#ifdef CONFIG_VSERVER_DEVICE
11252 +
11253 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
11254 +
11255 +#define vs_device_perm(v, d, m, p) \
11256 +       ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
11257 +
11258 +#else
11259 +
11260 +static inline
11261 +int vs_map_device(struct vx_info *vxi,
11262 +       dev_t device, dev_t *target, umode_t mode)
11263 +{
11264 +       if (target)
11265 +               *target = device;
11266 +       return ~0;
11267 +}
11268 +
11269 +#define vs_device_perm(v, d, m, p) ((p) == (p))
11270 +
11271 +#endif
11272 +
11273 +
11274 +#define vs_map_chrdev(d, t, p) \
11275 +       ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
11276 +#define vs_map_blkdev(d, t, p) \
11277 +       ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
11278 +
11279 +#define vs_chrdev_perm(d, p) \
11280 +       vs_device_perm(current_vx_info(), d, S_IFCHR, p)
11281 +#define vs_blkdev_perm(d, p) \
11282 +       vs_device_perm(current_vx_info(), d, S_IFBLK, p)
11283 +
11284 +
11285 +#else
11286 +#warning duplicate inclusion
11287 +#endif
11288 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_dlimit.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_dlimit.h
11289 --- linux-2.6.35.2/include/linux/vs_dlimit.h    1970-01-01 01:00:00.000000000 +0100
11290 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_dlimit.h      2010-08-02 22:21:17.000000000 +0200
11291 @@ -0,0 +1,215 @@
11292 +#ifndef _VS_DLIMIT_H
11293 +#define _VS_DLIMIT_H
11294 +
11295 +#include <linux/fs.h>
11296 +
11297 +#include "vserver/dlimit.h"
11298 +#include "vserver/base.h"
11299 +#include "vserver/debug.h"
11300 +
11301 +
11302 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11303 +
11304 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11305 +       const char *_file, int _line)
11306 +{
11307 +       if (!dli)
11308 +               return NULL;
11309 +       vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11310 +               dli, dli ? dli->dl_tag : 0,
11311 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11312 +               _file, _line);
11313 +       atomic_inc(&dli->dl_usecnt);
11314 +       return dli;
11315 +}
11316 +
11317 +
11318 +#define free_dl_info(i) \
11319 +       call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11320 +
11321 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11322 +
11323 +static inline void __put_dl_info(struct dl_info *dli,
11324 +       const char *_file, int _line)
11325 +{
11326 +       if (!dli)
11327 +               return;
11328 +       vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11329 +               dli, dli ? dli->dl_tag : 0,
11330 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11331 +               _file, _line);
11332 +       if (atomic_dec_and_test(&dli->dl_usecnt))
11333 +               free_dl_info(dli);
11334 +}
11335 +
11336 +
11337 +#define __dlimit_char(d)       ((d) ? '*' : ' ')
11338 +
11339 +static inline int __dl_alloc_space(struct super_block *sb,
11340 +       tag_t tag, dlsize_t nr, const char *file, int line)
11341 +{
11342 +       struct dl_info *dli = NULL;
11343 +       int ret = 0;
11344 +
11345 +       if (nr == 0)
11346 +               goto out;
11347 +       dli = locate_dl_info(sb, tag);
11348 +       if (!dli)
11349 +               goto out;
11350 +
11351 +       spin_lock(&dli->dl_lock);
11352 +       ret = (dli->dl_space_used + nr > dli->dl_space_total);
11353 +       if (!ret)
11354 +               dli->dl_space_used += nr;
11355 +       spin_unlock(&dli->dl_lock);
11356 +       put_dl_info(dli);
11357 +out:
11358 +       vxlprintk(VXD_CBIT(dlim, 1),
11359 +               "ALLOC (%p,#%d)%c %lld bytes (%d)",
11360 +               sb, tag, __dlimit_char(dli), (long long)nr,
11361 +               ret, file, line);
11362 +       return ret ? -ENOSPC : 0;
11363 +}
11364 +
11365 +static inline void __dl_free_space(struct super_block *sb,
11366 +       tag_t tag, dlsize_t nr, const char *_file, int _line)
11367 +{
11368 +       struct dl_info *dli = NULL;
11369 +
11370 +       if (nr == 0)
11371 +               goto out;
11372 +       dli = locate_dl_info(sb, tag);
11373 +       if (!dli)
11374 +               goto out;
11375 +
11376 +       spin_lock(&dli->dl_lock);
11377 +       if (dli->dl_space_used > nr)
11378 +               dli->dl_space_used -= nr;
11379 +       else
11380 +               dli->dl_space_used = 0;
11381 +       spin_unlock(&dli->dl_lock);
11382 +       put_dl_info(dli);
11383 +out:
11384 +       vxlprintk(VXD_CBIT(dlim, 1),
11385 +               "FREE  (%p,#%d)%c %lld bytes",
11386 +               sb, tag, __dlimit_char(dli), (long long)nr,
11387 +               _file, _line);
11388 +}
11389 +
11390 +static inline int __dl_alloc_inode(struct super_block *sb,
11391 +       tag_t tag, const char *_file, int _line)
11392 +{
11393 +       struct dl_info *dli;
11394 +       int ret = 0;
11395 +
11396 +       dli = locate_dl_info(sb, tag);
11397 +       if (!dli)
11398 +               goto out;
11399 +
11400 +       spin_lock(&dli->dl_lock);
11401 +       dli->dl_inodes_used++;
11402 +       ret = (dli->dl_inodes_used > dli->dl_inodes_total);
11403 +       spin_unlock(&dli->dl_lock);
11404 +       put_dl_info(dli);
11405 +out:
11406 +       vxlprintk(VXD_CBIT(dlim, 0),
11407 +               "ALLOC (%p,#%d)%c inode (%d)",
11408 +               sb, tag, __dlimit_char(dli), ret, _file, _line);
11409 +       return ret ? -ENOSPC : 0;
11410 +}
11411 +
11412 +static inline void __dl_free_inode(struct super_block *sb,
11413 +       tag_t tag, const char *_file, int _line)
11414 +{
11415 +       struct dl_info *dli;
11416 +
11417 +       dli = locate_dl_info(sb, tag);
11418 +       if (!dli)
11419 +               goto out;
11420 +
11421 +       spin_lock(&dli->dl_lock);
11422 +       if (dli->dl_inodes_used > 1)
11423 +               dli->dl_inodes_used--;
11424 +       else
11425 +               dli->dl_inodes_used = 0;
11426 +       spin_unlock(&dli->dl_lock);
11427 +       put_dl_info(dli);
11428 +out:
11429 +       vxlprintk(VXD_CBIT(dlim, 0),
11430 +               "FREE  (%p,#%d)%c inode",
11431 +               sb, tag, __dlimit_char(dli), _file, _line);
11432 +}
11433 +
11434 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11435 +       unsigned long long *free_blocks, unsigned long long *root_blocks,
11436 +       const char *_file, int _line)
11437 +{
11438 +       struct dl_info *dli;
11439 +       uint64_t broot, bfree;
11440 +
11441 +       dli = locate_dl_info(sb, tag);
11442 +       if (!dli)
11443 +               return;
11444 +
11445 +       spin_lock(&dli->dl_lock);
11446 +       broot = (dli->dl_space_total -
11447 +               (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11448 +               >> sb->s_blocksize_bits;
11449 +       bfree = (dli->dl_space_total - dli->dl_space_used)
11450 +                       >> sb->s_blocksize_bits;
11451 +       spin_unlock(&dli->dl_lock);
11452 +
11453 +       vxlprintk(VXD_CBIT(dlim, 2),
11454 +               "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11455 +               (long long)bfree, (long long)broot,
11456 +               *free_blocks, *root_blocks, dli->dl_nrlmult,
11457 +               _file, _line);
11458 +       if (free_blocks) {
11459 +               if (*free_blocks > bfree)
11460 +                       *free_blocks = bfree;
11461 +       }
11462 +       if (root_blocks) {
11463 +               if (*root_blocks > broot)
11464 +                       *root_blocks = broot;
11465 +       }
11466 +       put_dl_info(dli);
11467 +}
11468 +
11469 +#define dl_prealloc_space(in, bytes) \
11470 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11471 +               __FILE__, __LINE__ )
11472 +
11473 +#define dl_alloc_space(in, bytes) \
11474 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11475 +               __FILE__, __LINE__ )
11476 +
11477 +#define dl_reserve_space(in, bytes) \
11478 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11479 +               __FILE__, __LINE__ )
11480 +
11481 +#define dl_claim_space(in, bytes) (0)
11482 +
11483 +#define dl_release_space(in, bytes) \
11484 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11485 +               __FILE__, __LINE__ )
11486 +
11487 +#define dl_free_space(in, bytes) \
11488 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11489 +               __FILE__, __LINE__ )
11490 +
11491 +
11492 +
11493 +#define dl_alloc_inode(in) \
11494 +       __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11495 +
11496 +#define dl_free_inode(in) \
11497 +       __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11498 +
11499 +
11500 +#define dl_adjust_block(sb, tag, fb, rb) \
11501 +       __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11502 +
11503 +
11504 +#else
11505 +#warning duplicate inclusion
11506 +#endif
11507 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/base.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/base.h
11508 --- linux-2.6.35.2/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11509 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/base.h   2010-08-02 17:05:06.000000000 +0200
11510 @@ -0,0 +1,170 @@
11511 +#ifndef _VX_BASE_H
11512 +#define _VX_BASE_H
11513 +
11514 +
11515 +/* context state changes */
11516 +
11517 +enum {
11518 +       VSC_STARTUP = 1,
11519 +       VSC_SHUTDOWN,
11520 +
11521 +       VSC_NETUP,
11522 +       VSC_NETDOWN,
11523 +};
11524 +
11525 +
11526 +
11527 +#define vx_task_xid(t) ((t)->xid)
11528 +
11529 +#define vx_current_xid() vx_task_xid(current)
11530 +
11531 +#define current_vx_info() (current->vx_info)
11532 +
11533 +
11534 +#define nx_task_nid(t) ((t)->nid)
11535 +
11536 +#define nx_current_nid() nx_task_nid(current)
11537 +
11538 +#define current_nx_info() (current->nx_info)
11539 +
11540 +
11541 +/* generic flag merging */
11542 +
11543 +#define vs_check_flags(v, m, f)        (((v) & (m)) ^ (f))
11544 +
11545 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11546 +
11547 +#define vs_mask_mask(v, f, m)  (((v) & ~(m)) | ((v) & (f) & (m)))
11548 +
11549 +#define vs_check_bit(v, n)     ((v) & (1LL << (n)))
11550 +
11551 +
11552 +/* context flags */
11553 +
11554 +#define __vx_flags(v)  ((v) ? (v)->vx_flags : 0)
11555 +
11556 +#define vx_current_flags()     __vx_flags(current_vx_info())
11557 +
11558 +#define vx_info_flags(v, m, f) \
11559 +       vs_check_flags(__vx_flags(v), m, f)
11560 +
11561 +#define task_vx_flags(t, m, f) \
11562 +       ((t) && vx_info_flags((t)->vx_info, m, f))
11563 +
11564 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11565 +
11566 +
11567 +/* context caps */
11568 +
11569 +#define __vx_ccaps(v)  ((v) ? (v)->vx_ccaps : 0)
11570 +
11571 +#define vx_current_ccaps()     __vx_ccaps(current_vx_info())
11572 +
11573 +#define vx_info_ccaps(v, c)    (__vx_ccaps(v) & (c))
11574 +
11575 +#define vx_ccaps(c)    vx_info_ccaps(current_vx_info(), (c))
11576 +
11577 +
11578 +
11579 +/* network flags */
11580 +
11581 +#define __nx_flags(n)  ((n) ? (n)->nx_flags : 0)
11582 +
11583 +#define nx_current_flags()     __nx_flags(current_nx_info())
11584 +
11585 +#define nx_info_flags(n, m, f) \
11586 +       vs_check_flags(__nx_flags(n), m, f)
11587 +
11588 +#define task_nx_flags(t, m, f) \
11589 +       ((t) && nx_info_flags((t)->nx_info, m, f))
11590 +
11591 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11592 +
11593 +
11594 +/* network caps */
11595 +
11596 +#define __nx_ncaps(n)  ((n) ? (n)->nx_ncaps : 0)
11597 +
11598 +#define nx_current_ncaps()     __nx_ncaps(current_nx_info())
11599 +
11600 +#define nx_info_ncaps(n, c)    (__nx_ncaps(n) & (c))
11601 +
11602 +#define nx_ncaps(c)    nx_info_ncaps(current_nx_info(), c)
11603 +
11604 +
11605 +/* context mask capabilities */
11606 +
11607 +#define __vx_mcaps(v)  ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11608 +
11609 +#define vx_info_mcaps(v, c)    (__vx_mcaps(v) & (c))
11610 +
11611 +#define vx_mcaps(c)    vx_info_mcaps(current_vx_info(), c)
11612 +
11613 +
11614 +/* context bcap mask */
11615 +
11616 +#define __vx_bcaps(v)          ((v)->vx_bcaps)
11617 +
11618 +#define vx_current_bcaps()     __vx_bcaps(current_vx_info())
11619 +
11620 +
11621 +/* mask given bcaps */
11622 +
11623 +#define vx_info_mbcaps(v, c)   ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11624 +
11625 +#define vx_mbcaps(c)           vx_info_mbcaps(current_vx_info(), c)
11626 +
11627 +
11628 +/* masked cap_bset */
11629 +
11630 +#define vx_info_cap_bset(v)    vx_info_mbcaps(v, current->cap_bset)
11631 +
11632 +#define vx_current_cap_bset()  vx_info_cap_bset(current_vx_info())
11633 +
11634 +#if 0
11635 +#define vx_info_mbcap(v, b) \
11636 +       (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11637 +       vx_info_bcaps(v, b) : (b))
11638 +
11639 +#define task_vx_mbcap(t, b) \
11640 +       vx_info_mbcap((t)->vx_info, (t)->b)
11641 +
11642 +#define vx_mbcap(b)    task_vx_mbcap(current, b)
11643 +#endif
11644 +
11645 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11646 +
11647 +#define vx_capable(b, c) (capable(b) || \
11648 +       (cap_raised(current_cap(), b) && vx_ccaps(c)))
11649 +
11650 +#define nx_capable(b, c) (capable(b) || \
11651 +       (cap_raised(current_cap(), b) && nx_ncaps(c)))
11652 +
11653 +#define vx_task_initpid(t, n) \
11654 +       ((t)->vx_info && \
11655 +       ((t)->vx_info->vx_initpid == (n)))
11656 +
11657 +#define vx_current_initpid(n)  vx_task_initpid(current, n)
11658 +
11659 +
11660 +/* context unshare mask */
11661 +
11662 +#define __vx_umask(v)          ((v)->vx_umask)
11663 +
11664 +#define vx_current_umask()     __vx_umask(current_vx_info())
11665 +
11666 +#define vx_can_unshare(b, f) (capable(b) || \
11667 +       (cap_raised(current_cap(), b) && \
11668 +       !((f) & ~vx_current_umask())))
11669 +
11670 +
11671 +#define __vx_state(v)  ((v) ? ((v)->vx_state) : 0)
11672 +
11673 +#define vx_info_state(v, m)    (__vx_state(v) & (m))
11674 +
11675 +
11676 +#define __nx_state(n)  ((n) ? ((n)->nx_state) : 0)
11677 +
11678 +#define nx_info_state(n, m)    (__nx_state(n) & (m))
11679 +
11680 +#endif
11681 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/cacct_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cacct_cmd.h
11682 --- linux-2.6.35.2/include/linux/vserver/cacct_cmd.h    1970-01-01 01:00:00.000000000 +0100
11683 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cacct_cmd.h      2010-08-02 17:05:06.000000000 +0200
11684 @@ -0,0 +1,23 @@
11685 +#ifndef _VX_CACCT_CMD_H
11686 +#define _VX_CACCT_CMD_H
11687 +
11688 +
11689 +/* virtual host info name commands */
11690 +
11691 +#define VCMD_sock_stat         VC_CMD(VSTAT, 5, 0)
11692 +
11693 +struct vcmd_sock_stat_v0 {
11694 +       uint32_t field;
11695 +       uint32_t count[3];
11696 +       uint64_t total[3];
11697 +};
11698 +
11699 +
11700 +#ifdef __KERNEL__
11701 +
11702 +#include <linux/compiler.h>
11703 +
11704 +extern int vc_sock_stat(struct vx_info *, void __user *);
11705 +
11706 +#endif /* __KERNEL__ */
11707 +#endif /* _VX_CACCT_CMD_H */
11708 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/cacct_def.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cacct_def.h
11709 --- linux-2.6.35.2/include/linux/vserver/cacct_def.h    1970-01-01 01:00:00.000000000 +0100
11710 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cacct_def.h      2010-08-02 17:05:06.000000000 +0200
11711 @@ -0,0 +1,43 @@
11712 +#ifndef _VX_CACCT_DEF_H
11713 +#define _VX_CACCT_DEF_H
11714 +
11715 +#include <asm/atomic.h>
11716 +#include <linux/vserver/cacct.h>
11717 +
11718 +
11719 +struct _vx_sock_acc {
11720 +       atomic_long_t count;
11721 +       atomic_long_t total;
11722 +};
11723 +
11724 +/* context sub struct */
11725 +
11726 +struct _vx_cacct {
11727 +       struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11728 +       atomic_t slab[8];
11729 +       atomic_t page[6][8];
11730 +};
11731 +
11732 +#ifdef CONFIG_VSERVER_DEBUG
11733 +
11734 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11735 +{
11736 +       int i, j;
11737 +
11738 +       printk("\t_vx_cacct:");
11739 +       for (i = 0; i < 6; i++) {
11740 +               struct _vx_sock_acc *ptr = cacct->sock[i];
11741 +
11742 +               printk("\t [%d] =", i);
11743 +               for (j = 0; j < 3; j++) {
11744 +                       printk(" [%d] = %8lu, %8lu", j,
11745 +                               atomic_long_read(&ptr[j].count),
11746 +                               atomic_long_read(&ptr[j].total));
11747 +               }
11748 +               printk("\n");
11749 +       }
11750 +}
11751 +
11752 +#endif
11753 +
11754 +#endif /* _VX_CACCT_DEF_H */
11755 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/cacct.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cacct.h
11756 --- linux-2.6.35.2/include/linux/vserver/cacct.h        1970-01-01 01:00:00.000000000 +0100
11757 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cacct.h  2010-08-02 17:05:06.000000000 +0200
11758 @@ -0,0 +1,15 @@
11759 +#ifndef _VX_CACCT_H
11760 +#define _VX_CACCT_H
11761 +
11762 +
11763 +enum sock_acc_field {
11764 +       VXA_SOCK_UNSPEC = 0,
11765 +       VXA_SOCK_UNIX,
11766 +       VXA_SOCK_INET,
11767 +       VXA_SOCK_INET6,
11768 +       VXA_SOCK_PACKET,
11769 +       VXA_SOCK_OTHER,
11770 +       VXA_SOCK_SIZE   /* array size */
11771 +};
11772 +
11773 +#endif /* _VX_CACCT_H */
11774 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/cacct_int.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cacct_int.h
11775 --- linux-2.6.35.2/include/linux/vserver/cacct_int.h    1970-01-01 01:00:00.000000000 +0100
11776 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cacct_int.h      2010-08-02 17:05:06.000000000 +0200
11777 @@ -0,0 +1,21 @@
11778 +#ifndef _VX_CACCT_INT_H
11779 +#define _VX_CACCT_INT_H
11780 +
11781 +
11782 +#ifdef __KERNEL__
11783 +
11784 +static inline
11785 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11786 +{
11787 +       return atomic_long_read(&cacct->sock[type][pos].count);
11788 +}
11789 +
11790 +
11791 +static inline
11792 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11793 +{
11794 +       return atomic_long_read(&cacct->sock[type][pos].total);
11795 +}
11796 +
11797 +#endif /* __KERNEL__ */
11798 +#endif /* _VX_CACCT_INT_H */
11799 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/check.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/check.h
11800 --- linux-2.6.35.2/include/linux/vserver/check.h        1970-01-01 01:00:00.000000000 +0100
11801 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/check.h  2010-08-02 17:05:06.000000000 +0200
11802 @@ -0,0 +1,89 @@
11803 +#ifndef _VS_CHECK_H
11804 +#define _VS_CHECK_H
11805 +
11806 +
11807 +#define MAX_S_CONTEXT  65535   /* Arbitrary limit */
11808 +
11809 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11810 +#define MIN_D_CONTEXT  49152   /* dynamic contexts start here */
11811 +#else
11812 +#define MIN_D_CONTEXT  65536
11813 +#endif
11814 +
11815 +/* check conditions */
11816 +
11817 +#define VS_ADMIN       0x0001
11818 +#define VS_WATCH       0x0002
11819 +#define VS_HIDE                0x0004
11820 +#define VS_HOSTID      0x0008
11821 +
11822 +#define VS_IDENT       0x0010
11823 +#define VS_EQUIV       0x0020
11824 +#define VS_PARENT      0x0040
11825 +#define VS_CHILD       0x0080
11826 +
11827 +#define VS_ARG_MASK    0x00F0
11828 +
11829 +#define VS_DYNAMIC     0x0100
11830 +#define VS_STATIC      0x0200
11831 +
11832 +#define VS_ATR_MASK    0x0F00
11833 +
11834 +#ifdef CONFIG_VSERVER_PRIVACY
11835 +#define VS_ADMIN_P     (0)
11836 +#define VS_WATCH_P     (0)
11837 +#else
11838 +#define VS_ADMIN_P     VS_ADMIN
11839 +#define VS_WATCH_P     VS_WATCH
11840 +#endif
11841 +
11842 +#define VS_HARDIRQ     0x1000
11843 +#define VS_SOFTIRQ     0x2000
11844 +#define VS_IRQ         0x4000
11845 +
11846 +#define VS_IRQ_MASK    0xF000
11847 +
11848 +#include <linux/hardirq.h>
11849 +
11850 +/*
11851 + * check current context for ADMIN/WATCH and
11852 + * optionally against supplied argument
11853 + */
11854 +static inline int __vs_check(int cid, int id, unsigned int mode)
11855 +{
11856 +       if (mode & VS_ARG_MASK) {
11857 +               if ((mode & VS_IDENT) && (id == cid))
11858 +                       return 1;
11859 +       }
11860 +       if (mode & VS_ATR_MASK) {
11861 +               if ((mode & VS_DYNAMIC) &&
11862 +                       (id >= MIN_D_CONTEXT) &&
11863 +                       (id <= MAX_S_CONTEXT))
11864 +                       return 1;
11865 +               if ((mode & VS_STATIC) &&
11866 +                       (id > 1) && (id < MIN_D_CONTEXT))
11867 +                       return 1;
11868 +       }
11869 +       if (mode & VS_IRQ_MASK) {
11870 +               if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11871 +                       return 1;
11872 +               if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11873 +                       return 1;
11874 +               if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11875 +                       return 1;
11876 +       }
11877 +       return (((mode & VS_ADMIN) && (cid == 0)) ||
11878 +               ((mode & VS_WATCH) && (cid == 1)) ||
11879 +               ((mode & VS_HOSTID) && (id == 0)));
11880 +}
11881 +
11882 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11883 +
11884 +#define vx_weak_check(c, m)    ((m) ? vx_check(c, m) : 1)
11885 +
11886 +
11887 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11888 +
11889 +#define nx_weak_check(c, m)    ((m) ? nx_check(c, m) : 1)
11890 +
11891 +#endif
11892 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/context_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/context_cmd.h
11893 --- linux-2.6.35.2/include/linux/vserver/context_cmd.h  1970-01-01 01:00:00.000000000 +0100
11894 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/context_cmd.h    2010-08-02 17:05:06.000000000 +0200
11895 @@ -0,0 +1,145 @@
11896 +#ifndef _VX_CONTEXT_CMD_H
11897 +#define _VX_CONTEXT_CMD_H
11898 +
11899 +
11900 +/* vinfo commands */
11901 +
11902 +#define VCMD_task_xid          VC_CMD(VINFO, 1, 0)
11903 +
11904 +#ifdef __KERNEL__
11905 +extern int vc_task_xid(uint32_t);
11906 +
11907 +#endif /* __KERNEL__ */
11908 +
11909 +#define VCMD_vx_info           VC_CMD(VINFO, 5, 0)
11910 +
11911 +struct vcmd_vx_info_v0 {
11912 +       uint32_t xid;
11913 +       uint32_t initpid;
11914 +       /* more to come */
11915 +};
11916 +
11917 +#ifdef __KERNEL__
11918 +extern int vc_vx_info(struct vx_info *, void __user *);
11919 +
11920 +#endif /* __KERNEL__ */
11921 +
11922 +#define VCMD_ctx_stat          VC_CMD(VSTAT, 0, 0)
11923 +
11924 +struct vcmd_ctx_stat_v0 {
11925 +       uint32_t usecnt;
11926 +       uint32_t tasks;
11927 +       /* more to come */
11928 +};
11929 +
11930 +#ifdef __KERNEL__
11931 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11932 +
11933 +#endif /* __KERNEL__ */
11934 +
11935 +/* context commands */
11936 +
11937 +#define VCMD_ctx_create_v0     VC_CMD(VPROC, 1, 0)
11938 +#define VCMD_ctx_create                VC_CMD(VPROC, 1, 1)
11939 +
11940 +struct vcmd_ctx_create {
11941 +       uint64_t flagword;
11942 +};
11943 +
11944 +#define VCMD_ctx_migrate_v0    VC_CMD(PROCMIG, 1, 0)
11945 +#define VCMD_ctx_migrate       VC_CMD(PROCMIG, 1, 1)
11946 +
11947 +struct vcmd_ctx_migrate {
11948 +       uint64_t flagword;
11949 +};
11950 +
11951 +#ifdef __KERNEL__
11952 +extern int vc_ctx_create(uint32_t, void __user *);
11953 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11954 +
11955 +#endif /* __KERNEL__ */
11956 +
11957 +
11958 +/* flag commands */
11959 +
11960 +#define VCMD_get_cflags                VC_CMD(FLAGS, 1, 0)
11961 +#define VCMD_set_cflags                VC_CMD(FLAGS, 2, 0)
11962 +
11963 +struct vcmd_ctx_flags_v0 {
11964 +       uint64_t flagword;
11965 +       uint64_t mask;
11966 +};
11967 +
11968 +#ifdef __KERNEL__
11969 +extern int vc_get_cflags(struct vx_info *, void __user *);
11970 +extern int vc_set_cflags(struct vx_info *, void __user *);
11971 +
11972 +#endif /* __KERNEL__ */
11973 +
11974 +
11975 +/* context caps commands */
11976 +
11977 +#define VCMD_get_ccaps         VC_CMD(FLAGS, 3, 1)
11978 +#define VCMD_set_ccaps         VC_CMD(FLAGS, 4, 1)
11979 +
11980 +struct vcmd_ctx_caps_v1 {
11981 +       uint64_t ccaps;
11982 +       uint64_t cmask;
11983 +};
11984 +
11985 +#ifdef __KERNEL__
11986 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11987 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11988 +
11989 +#endif /* __KERNEL__ */
11990 +
11991 +
11992 +/* bcaps commands */
11993 +
11994 +#define VCMD_get_bcaps         VC_CMD(FLAGS, 9, 0)
11995 +#define VCMD_set_bcaps         VC_CMD(FLAGS, 10, 0)
11996 +
11997 +struct vcmd_bcaps {
11998 +       uint64_t bcaps;
11999 +       uint64_t bmask;
12000 +};
12001 +
12002 +#ifdef __KERNEL__
12003 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12004 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12005 +
12006 +#endif /* __KERNEL__ */
12007 +
12008 +
12009 +/* umask commands */
12010 +
12011 +#define VCMD_get_umask         VC_CMD(FLAGS, 13, 0)
12012 +#define VCMD_set_umask         VC_CMD(FLAGS, 14, 0)
12013 +
12014 +struct vcmd_umask {
12015 +       uint64_t umask;
12016 +       uint64_t mask;
12017 +};
12018 +
12019 +#ifdef __KERNEL__
12020 +extern int vc_get_umask(struct vx_info *, void __user *);
12021 +extern int vc_set_umask(struct vx_info *, void __user *);
12022 +
12023 +#endif /* __KERNEL__ */
12024 +
12025 +
12026 +/* OOM badness */
12027 +
12028 +#define VCMD_get_badness       VC_CMD(MEMCTRL, 5, 0)
12029 +#define VCMD_set_badness       VC_CMD(MEMCTRL, 6, 0)
12030 +
12031 +struct vcmd_badness_v0 {
12032 +       int64_t bias;
12033 +};
12034 +
12035 +#ifdef __KERNEL__
12036 +extern int vc_get_badness(struct vx_info *, void __user *);
12037 +extern int vc_set_badness(struct vx_info *, void __user *);
12038 +
12039 +#endif /* __KERNEL__ */
12040 +#endif /* _VX_CONTEXT_CMD_H */
12041 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/context.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/context.h
12042 --- linux-2.6.35.2/include/linux/vserver/context.h      1970-01-01 01:00:00.000000000 +0100
12043 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/context.h        2010-08-02 17:05:06.000000000 +0200
12044 @@ -0,0 +1,184 @@
12045 +#ifndef _VX_CONTEXT_H
12046 +#define _VX_CONTEXT_H
12047 +
12048 +#include <linux/types.h>
12049 +#include <linux/capability.h>
12050 +
12051 +
12052 +/* context flags */
12053 +
12054 +#define VXF_INFO_SCHED         0x00000002
12055 +#define VXF_INFO_NPROC         0x00000004
12056 +#define VXF_INFO_PRIVATE       0x00000008
12057 +
12058 +#define VXF_INFO_INIT          0x00000010
12059 +#define VXF_INFO_HIDE          0x00000020
12060 +#define VXF_INFO_ULIMIT                0x00000040
12061 +#define VXF_INFO_NSPACE                0x00000080
12062 +
12063 +#define VXF_SCHED_HARD         0x00000100
12064 +#define VXF_SCHED_PRIO         0x00000200
12065 +#define VXF_SCHED_PAUSE                0x00000400
12066 +
12067 +#define VXF_VIRT_MEM           0x00010000
12068 +#define VXF_VIRT_UPTIME                0x00020000
12069 +#define VXF_VIRT_CPU           0x00040000
12070 +#define VXF_VIRT_LOAD          0x00080000
12071 +#define VXF_VIRT_TIME          0x00100000
12072 +
12073 +#define VXF_HIDE_MOUNT         0x01000000
12074 +/* was VXF_HIDE_NETIF          0x02000000 */
12075 +#define VXF_HIDE_VINFO         0x04000000
12076 +
12077 +#define VXF_STATE_SETUP                (1ULL << 32)
12078 +#define VXF_STATE_INIT         (1ULL << 33)
12079 +#define VXF_STATE_ADMIN                (1ULL << 34)
12080 +
12081 +#define VXF_SC_HELPER          (1ULL << 36)
12082 +#define VXF_REBOOT_KILL                (1ULL << 37)
12083 +#define VXF_PERSISTENT         (1ULL << 38)
12084 +
12085 +#define VXF_FORK_RSS           (1ULL << 48)
12086 +#define VXF_PROLIFIC           (1ULL << 49)
12087 +
12088 +#define VXF_IGNEG_NICE         (1ULL << 52)
12089 +
12090 +#define VXF_ONE_TIME           (0x0007ULL << 32)
12091 +
12092 +#define VXF_INIT_SET           (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12093 +
12094 +
12095 +/* context migration */
12096 +
12097 +#define VXM_SET_INIT           0x00000001
12098 +#define VXM_SET_REAPER         0x00000002
12099 +
12100 +/* context caps */
12101 +
12102 +#define VXC_CAP_MASK           0x00000000
12103 +
12104 +#define VXC_SET_UTSNAME                0x00000001
12105 +#define VXC_SET_RLIMIT         0x00000002
12106 +#define VXC_FS_SECURITY                0x00000004
12107 +#define VXC_FS_TRUSTED         0x00000008
12108 +#define VXC_TIOCSTI            0x00000010
12109 +
12110 +/* was VXC_RAW_ICMP            0x00000100 */
12111 +#define VXC_SYSLOG             0x00001000
12112 +#define VXC_OOM_ADJUST         0x00002000
12113 +#define VXC_AUDIT_CONTROL      0x00004000
12114 +
12115 +#define VXC_SECURE_MOUNT       0x00010000
12116 +#define VXC_SECURE_REMOUNT     0x00020000
12117 +#define VXC_BINARY_MOUNT       0x00040000
12118 +
12119 +#define VXC_QUOTA_CTL          0x00100000
12120 +#define VXC_ADMIN_MAPPER       0x00200000
12121 +#define VXC_ADMIN_CLOOP                0x00400000
12122 +
12123 +#define VXC_KTHREAD            0x01000000
12124 +#define VXC_NAMESPACE          0x02000000
12125 +
12126 +
12127 +#ifdef __KERNEL__
12128 +
12129 +#include <linux/list.h>
12130 +#include <linux/spinlock.h>
12131 +#include <linux/rcupdate.h>
12132 +
12133 +#include "limit_def.h"
12134 +#include "sched_def.h"
12135 +#include "cvirt_def.h"
12136 +#include "cacct_def.h"
12137 +#include "device_def.h"
12138 +
12139 +#define VX_SPACES      2
12140 +
12141 +struct _vx_info_pc {
12142 +       struct _vx_sched_pc sched_pc;
12143 +       struct _vx_cvirt_pc cvirt_pc;
12144 +};
12145 +
12146 +struct vx_info {
12147 +       struct hlist_node vx_hlist;             /* linked list of contexts */
12148 +       xid_t vx_id;                            /* context id */
12149 +       atomic_t vx_usecnt;                     /* usage count */
12150 +       atomic_t vx_tasks;                      /* tasks count */
12151 +       struct vx_info *vx_parent;              /* parent context */
12152 +       int vx_state;                           /* context state */
12153 +
12154 +       unsigned long vx_nsmask[VX_SPACES];     /* assignment mask */
12155 +       struct nsproxy *vx_nsproxy[VX_SPACES];  /* private namespaces */
12156 +       struct fs_struct *vx_fs[VX_SPACES];     /* private namespace fs */
12157 +
12158 +       uint64_t vx_flags;                      /* context flags */
12159 +       uint64_t vx_ccaps;                      /* context caps (vserver) */
12160 +       kernel_cap_t vx_bcaps;                  /* bounding caps (system) */
12161 +       unsigned long vx_umask;                 /* unshare mask (guest) */
12162 +
12163 +       struct task_struct *vx_reaper;          /* guest reaper process */
12164 +       pid_t vx_initpid;                       /* PID of guest init */
12165 +       int64_t vx_badness_bias;                /* OOM points bias */
12166 +
12167 +       struct _vx_limit limit;                 /* vserver limits */
12168 +       struct _vx_sched sched;                 /* vserver scheduler */
12169 +       struct _vx_cvirt cvirt;                 /* virtual/bias stuff */
12170 +       struct _vx_cacct cacct;                 /* context accounting */
12171 +
12172 +       struct _vx_device dmap;                 /* default device map targets */
12173 +
12174 +#ifndef CONFIG_SMP
12175 +       struct _vx_info_pc info_pc;             /* per cpu data */
12176 +#else
12177 +       struct _vx_info_pc *ptr_pc;             /* per cpu array */
12178 +#endif
12179 +
12180 +       wait_queue_head_t vx_wait;              /* context exit waitqueue */
12181 +       int reboot_cmd;                         /* last sys_reboot() cmd */
12182 +       int exit_code;                          /* last process exit code */
12183 +
12184 +       char vx_name[65];                       /* vserver name */
12185 +};
12186 +
12187 +#ifndef CONFIG_SMP
12188 +#define        vx_ptr_pc(vxi)          (&(vxi)->info_pc)
12189 +#define        vx_per_cpu(vxi, v, id)  vx_ptr_pc(vxi)->v
12190 +#else
12191 +#define        vx_ptr_pc(vxi)          ((vxi)->ptr_pc)
12192 +#define        vx_per_cpu(vxi, v, id)  per_cpu_ptr(vx_ptr_pc(vxi), id)->v
12193 +#endif
12194 +
12195 +#define        vx_cpu(vxi, v)          vx_per_cpu(vxi, v, smp_processor_id())
12196 +
12197 +
12198 +struct vx_info_save {
12199 +       struct vx_info *vxi;
12200 +       xid_t xid;
12201 +};
12202 +
12203 +
12204 +/* status flags */
12205 +
12206 +#define VXS_HASHED     0x0001
12207 +#define VXS_PAUSED     0x0010
12208 +#define VXS_SHUTDOWN   0x0100
12209 +#define VXS_HELPER     0x1000
12210 +#define VXS_RELEASED   0x8000
12211 +
12212 +
12213 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
12214 +extern void release_vx_info(struct vx_info *, struct task_struct *);
12215 +
12216 +extern struct vx_info *lookup_vx_info(int);
12217 +extern struct vx_info *lookup_or_create_vx_info(int);
12218 +
12219 +extern int get_xid_list(int, unsigned int *, int);
12220 +extern int xid_is_hashed(xid_t);
12221 +
12222 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
12223 +
12224 +extern long vs_state_change(struct vx_info *, unsigned int);
12225 +
12226 +
12227 +#endif /* __KERNEL__ */
12228 +#endif /* _VX_CONTEXT_H */
12229 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/cvirt_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cvirt_cmd.h
12230 --- linux-2.6.35.2/include/linux/vserver/cvirt_cmd.h    1970-01-01 01:00:00.000000000 +0100
12231 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cvirt_cmd.h      2010-08-02 17:05:06.000000000 +0200
12232 @@ -0,0 +1,53 @@
12233 +#ifndef _VX_CVIRT_CMD_H
12234 +#define _VX_CVIRT_CMD_H
12235 +
12236 +
12237 +/* virtual host info name commands */
12238 +
12239 +#define VCMD_set_vhi_name      VC_CMD(VHOST, 1, 0)
12240 +#define VCMD_get_vhi_name      VC_CMD(VHOST, 2, 0)
12241 +
12242 +struct vcmd_vhi_name_v0 {
12243 +       uint32_t field;
12244 +       char name[65];
12245 +};
12246 +
12247 +
12248 +enum vhi_name_field {
12249 +       VHIN_CONTEXT = 0,
12250 +       VHIN_SYSNAME,
12251 +       VHIN_NODENAME,
12252 +       VHIN_RELEASE,
12253 +       VHIN_VERSION,
12254 +       VHIN_MACHINE,
12255 +       VHIN_DOMAINNAME,
12256 +};
12257 +
12258 +
12259 +#ifdef __KERNEL__
12260 +
12261 +#include <linux/compiler.h>
12262 +
12263 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12264 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12265 +
12266 +#endif /* __KERNEL__ */
12267 +
12268 +#define VCMD_virt_stat         VC_CMD(VSTAT, 3, 0)
12269 +
12270 +struct vcmd_virt_stat_v0 {
12271 +       uint64_t offset;
12272 +       uint64_t uptime;
12273 +       uint32_t nr_threads;
12274 +       uint32_t nr_running;
12275 +       uint32_t nr_uninterruptible;
12276 +       uint32_t nr_onhold;
12277 +       uint32_t nr_forks;
12278 +       uint32_t load[3];
12279 +};
12280 +
12281 +#ifdef __KERNEL__
12282 +extern int vc_virt_stat(struct vx_info *, void __user *);
12283 +
12284 +#endif /* __KERNEL__ */
12285 +#endif /* _VX_CVIRT_CMD_H */
12286 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/cvirt_def.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cvirt_def.h
12287 --- linux-2.6.35.2/include/linux/vserver/cvirt_def.h    1970-01-01 01:00:00.000000000 +0100
12288 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cvirt_def.h      2010-08-02 17:05:06.000000000 +0200
12289 @@ -0,0 +1,80 @@
12290 +#ifndef _VX_CVIRT_DEF_H
12291 +#define _VX_CVIRT_DEF_H
12292 +
12293 +#include <linux/jiffies.h>
12294 +#include <linux/spinlock.h>
12295 +#include <linux/wait.h>
12296 +#include <linux/time.h>
12297 +#include <asm/atomic.h>
12298 +
12299 +
12300 +struct _vx_usage_stat {
12301 +       uint64_t user;
12302 +       uint64_t nice;
12303 +       uint64_t system;
12304 +       uint64_t softirq;
12305 +       uint64_t irq;
12306 +       uint64_t idle;
12307 +       uint64_t iowait;
12308 +};
12309 +
12310 +struct _vx_syslog {
12311 +       wait_queue_head_t log_wait;
12312 +       spinlock_t logbuf_lock;         /* lock for the log buffer */
12313 +
12314 +       unsigned long log_start;        /* next char to be read by syslog() */
12315 +       unsigned long con_start;        /* next char to be sent to consoles */
12316 +       unsigned long log_end;  /* most-recently-written-char + 1 */
12317 +       unsigned long logged_chars;     /* #chars since last read+clear operation */
12318 +
12319 +       char log_buf[1024];
12320 +};
12321 +
12322 +
12323 +/* context sub struct */
12324 +
12325 +struct _vx_cvirt {
12326 +       atomic_t nr_threads;            /* number of current threads */
12327 +       atomic_t nr_running;            /* number of running threads */
12328 +       atomic_t nr_uninterruptible;    /* number of uninterruptible threads */
12329 +
12330 +       atomic_t nr_onhold;             /* processes on hold */
12331 +       uint32_t onhold_last;           /* jiffies when put on hold */
12332 +
12333 +       struct timeval bias_tv;         /* time offset to the host */
12334 +       struct timespec bias_idle;
12335 +       struct timespec bias_uptime;    /* context creation point */
12336 +       uint64_t bias_clock;            /* offset in clock_t */
12337 +
12338 +       spinlock_t load_lock;           /* lock for the load averages */
12339 +       atomic_t load_updates;          /* nr of load updates done so far */
12340 +       uint32_t load_last;             /* last time load was calculated */
12341 +       uint32_t load[3];               /* load averages 1,5,15 */
12342 +
12343 +       atomic_t total_forks;           /* number of forks so far */
12344 +
12345 +       struct _vx_syslog syslog;
12346 +};
12347 +
12348 +struct _vx_cvirt_pc {
12349 +       struct _vx_usage_stat cpustat;
12350 +};
12351 +
12352 +
12353 +#ifdef CONFIG_VSERVER_DEBUG
12354 +
12355 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12356 +{
12357 +       printk("\t_vx_cvirt:\n");
12358 +       printk("\t threads: %4d, %4d, %4d, %4d\n",
12359 +               atomic_read(&cvirt->nr_threads),
12360 +               atomic_read(&cvirt->nr_running),
12361 +               atomic_read(&cvirt->nr_uninterruptible),
12362 +               atomic_read(&cvirt->nr_onhold));
12363 +       /* add rest here */
12364 +       printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12365 +}
12366 +
12367 +#endif
12368 +
12369 +#endif /* _VX_CVIRT_DEF_H */
12370 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/cvirt.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cvirt.h
12371 --- linux-2.6.35.2/include/linux/vserver/cvirt.h        1970-01-01 01:00:00.000000000 +0100
12372 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/cvirt.h  2010-08-02 17:05:06.000000000 +0200
12373 @@ -0,0 +1,20 @@
12374 +#ifndef _VX_CVIRT_H
12375 +#define _VX_CVIRT_H
12376 +
12377 +
12378 +#ifdef __KERNEL__
12379 +
12380 +struct timespec;
12381 +
12382 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12383 +
12384 +
12385 +struct vx_info;
12386 +
12387 +void vx_update_load(struct vx_info *);
12388 +
12389 +
12390 +int vx_do_syslog(int, char __user *, int);
12391 +
12392 +#endif /* __KERNEL__ */
12393 +#endif /* _VX_CVIRT_H */
12394 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/debug_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/debug_cmd.h
12395 --- linux-2.6.35.2/include/linux/vserver/debug_cmd.h    1970-01-01 01:00:00.000000000 +0100
12396 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/debug_cmd.h      2010-08-02 17:05:06.000000000 +0200
12397 @@ -0,0 +1,58 @@
12398 +#ifndef _VX_DEBUG_CMD_H
12399 +#define _VX_DEBUG_CMD_H
12400 +
12401 +
12402 +/* debug commands */
12403 +
12404 +#define VCMD_dump_history      VC_CMD(DEBUG, 1, 0)
12405 +
12406 +#define VCMD_read_history      VC_CMD(DEBUG, 5, 0)
12407 +#define VCMD_read_monitor      VC_CMD(DEBUG, 6, 0)
12408 +
12409 +struct  vcmd_read_history_v0 {
12410 +       uint32_t index;
12411 +       uint32_t count;
12412 +       char __user *data;
12413 +};
12414 +
12415 +struct  vcmd_read_monitor_v0 {
12416 +       uint32_t index;
12417 +       uint32_t count;
12418 +       char __user *data;
12419 +};
12420 +
12421 +
12422 +#ifdef __KERNEL__
12423 +
12424 +#ifdef CONFIG_COMPAT
12425 +
12426 +#include <asm/compat.h>
12427 +
12428 +struct vcmd_read_history_v0_x32 {
12429 +       uint32_t index;
12430 +       uint32_t count;
12431 +       compat_uptr_t data_ptr;
12432 +};
12433 +
12434 +struct vcmd_read_monitor_v0_x32 {
12435 +       uint32_t index;
12436 +       uint32_t count;
12437 +       compat_uptr_t data_ptr;
12438 +};
12439 +
12440 +#endif  /* CONFIG_COMPAT */
12441 +
12442 +extern int vc_dump_history(uint32_t);
12443 +
12444 +extern int vc_read_history(uint32_t, void __user *);
12445 +extern int vc_read_monitor(uint32_t, void __user *);
12446 +
12447 +#ifdef CONFIG_COMPAT
12448 +
12449 +extern int vc_read_history_x32(uint32_t, void __user *);
12450 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12451 +
12452 +#endif  /* CONFIG_COMPAT */
12453 +
12454 +#endif /* __KERNEL__ */
12455 +#endif /* _VX_DEBUG_CMD_H */
12456 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/debug.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/debug.h
12457 --- linux-2.6.35.2/include/linux/vserver/debug.h        1970-01-01 01:00:00.000000000 +0100
12458 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/debug.h  2010-08-02 17:05:06.000000000 +0200
12459 @@ -0,0 +1,127 @@
12460 +#ifndef _VX_DEBUG_H
12461 +#define _VX_DEBUG_H
12462 +
12463 +
12464 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12465 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12466 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12467 +
12468 +#define VXD_DEV(d)     (d), (d)->bd_inode->i_ino,              \
12469 +                       imajor((d)->bd_inode), iminor((d)->bd_inode)
12470 +#define VXF_DEV                "%p[%lu,%d:%d]"
12471 +
12472 +
12473 +#define vxd_path(p)                                            \
12474 +       ({ static char _buffer[PATH_MAX];                       \
12475 +          d_path(p, _buffer, sizeof(_buffer)); })
12476 +
12477 +#define vxd_cond_path(n)                                       \
12478 +       ((n) ? vxd_path(&(n)->path) : "<null>" )
12479 +
12480 +
12481 +#ifdef CONFIG_VSERVER_DEBUG
12482 +
12483 +extern unsigned int vx_debug_switch;
12484 +extern unsigned int vx_debug_xid;
12485 +extern unsigned int vx_debug_nid;
12486 +extern unsigned int vx_debug_tag;
12487 +extern unsigned int vx_debug_net;
12488 +extern unsigned int vx_debug_limit;
12489 +extern unsigned int vx_debug_cres;
12490 +extern unsigned int vx_debug_dlim;
12491 +extern unsigned int vx_debug_quota;
12492 +extern unsigned int vx_debug_cvirt;
12493 +extern unsigned int vx_debug_space;
12494 +extern unsigned int vx_debug_misc;
12495 +
12496 +
12497 +#define VX_LOGLEVEL    "vxD: "
12498 +#define VX_PROC_FMT    "%p: "
12499 +#define VX_PROCESS     current
12500 +
12501 +#define vxdprintk(c, f, x...)                                  \
12502 +       do {                                                    \
12503 +               if (c)                                          \
12504 +                       printk(VX_LOGLEVEL VX_PROC_FMT f "\n",  \
12505 +                               VX_PROCESS , ##x);              \
12506 +       } while (0)
12507 +
12508 +#define vxlprintk(c, f, x...)                                  \
12509 +       do {                                                    \
12510 +               if (c)                                          \
12511 +                       printk(VX_LOGLEVEL f " @%s:%d\n", x);   \
12512 +       } while (0)
12513 +
12514 +#define vxfprintk(c, f, x...)                                  \
12515 +       do {                                                    \
12516 +               if (c)                                          \
12517 +                       printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12518 +       } while (0)
12519 +
12520 +
12521 +struct vx_info;
12522 +
12523 +void dump_vx_info(struct vx_info *, int);
12524 +void dump_vx_info_inactive(int);
12525 +
12526 +#else  /* CONFIG_VSERVER_DEBUG */
12527 +
12528 +#define vx_debug_switch 0
12529 +#define vx_debug_xid   0
12530 +#define vx_debug_nid   0
12531 +#define vx_debug_tag   0
12532 +#define vx_debug_net   0
12533 +#define vx_debug_limit 0
12534 +#define vx_debug_cres  0
12535 +#define vx_debug_dlim  0
12536 +#define vx_debug_cvirt 0
12537 +
12538 +#define vxdprintk(x...) do { } while (0)
12539 +#define vxlprintk(x...) do { } while (0)
12540 +#define vxfprintk(x...) do { } while (0)
12541 +
12542 +#endif /* CONFIG_VSERVER_DEBUG */
12543 +
12544 +
12545 +#ifdef CONFIG_VSERVER_WARN
12546 +
12547 +#define VX_WARNLEVEL   KERN_WARNING "vxW: "
12548 +#define VX_WARN_TASK   "[»%s«,%u:#%u|%u|%u] "
12549 +#define VX_WARN_XID    "[xid #%u] "
12550 +#define VX_WARN_NID    "[nid #%u] "
12551 +#define VX_WARN_TAG    "[tag #%u] "
12552 +
12553 +#define vxwprintk(c, f, x...)                                  \
12554 +       do {                                                    \
12555 +               if (c)                                          \
12556 +                       printk(VX_WARNLEVEL f "\n", ##x);       \
12557 +       } while (0)
12558 +
12559 +#else  /* CONFIG_VSERVER_WARN */
12560 +
12561 +#define vxwprintk(x...) do { } while (0)
12562 +
12563 +#endif /* CONFIG_VSERVER_WARN */
12564 +
12565 +#define vxwprintk_task(c, f, x...)                             \
12566 +       vxwprintk(c, VX_WARN_TASK f,                            \
12567 +               current->comm, current->pid,                    \
12568 +               current->xid, current->nid, current->tag, ##x)
12569 +#define vxwprintk_xid(c, f, x...)                              \
12570 +       vxwprintk(c, VX_WARN_XID f, current->xid, x)
12571 +#define vxwprintk_nid(c, f, x...)                              \
12572 +       vxwprintk(c, VX_WARN_NID f, current->nid, x)
12573 +#define vxwprintk_tag(c, f, x...)                              \
12574 +       vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12575 +
12576 +#ifdef CONFIG_VSERVER_DEBUG
12577 +#define vxd_assert_lock(l)     assert_spin_locked(l)
12578 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12579 +       "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12580 +#else
12581 +#define vxd_assert_lock(l)     do { } while (0)
12582 +#define vxd_assert(c, f, x...) do { } while (0)
12583 +#endif
12584 +
12585 +
12586 +#endif /* _VX_DEBUG_H */
12587 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/device_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/device_cmd.h
12588 --- linux-2.6.35.2/include/linux/vserver/device_cmd.h   1970-01-01 01:00:00.000000000 +0100
12589 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/device_cmd.h     2010-08-02 17:05:06.000000000 +0200
12590 @@ -0,0 +1,44 @@
12591 +#ifndef _VX_DEVICE_CMD_H
12592 +#define _VX_DEVICE_CMD_H
12593 +
12594 +
12595 +/*  device vserver commands */
12596 +
12597 +#define VCMD_set_mapping       VC_CMD(DEVICE, 1, 0)
12598 +#define VCMD_unset_mapping     VC_CMD(DEVICE, 2, 0)
12599 +
12600 +struct vcmd_set_mapping_v0 {
12601 +       const char __user *device;
12602 +       const char __user *target;
12603 +       uint32_t flags;
12604 +};
12605 +
12606 +
12607 +#ifdef __KERNEL__
12608 +
12609 +#ifdef CONFIG_COMPAT
12610 +
12611 +#include <asm/compat.h>
12612 +
12613 +struct vcmd_set_mapping_v0_x32 {
12614 +       compat_uptr_t device_ptr;
12615 +       compat_uptr_t target_ptr;
12616 +       uint32_t flags;
12617 +};
12618 +
12619 +#endif /* CONFIG_COMPAT */
12620 +
12621 +#include <linux/compiler.h>
12622 +
12623 +extern int vc_set_mapping(struct vx_info *, void __user *);
12624 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12625 +
12626 +#ifdef CONFIG_COMPAT
12627 +
12628 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12629 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12630 +
12631 +#endif /* CONFIG_COMPAT */
12632 +
12633 +#endif /* __KERNEL__ */
12634 +#endif /* _VX_DEVICE_CMD_H */
12635 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/device_def.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/device_def.h
12636 --- linux-2.6.35.2/include/linux/vserver/device_def.h   1970-01-01 01:00:00.000000000 +0100
12637 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/device_def.h     2010-08-02 17:05:06.000000000 +0200
12638 @@ -0,0 +1,17 @@
12639 +#ifndef _VX_DEVICE_DEF_H
12640 +#define _VX_DEVICE_DEF_H
12641 +
12642 +#include <linux/types.h>
12643 +
12644 +struct vx_dmap_target {
12645 +       dev_t target;
12646 +       uint32_t flags;
12647 +};
12648 +
12649 +struct _vx_device {
12650 +#ifdef CONFIG_VSERVER_DEVICE
12651 +       struct vx_dmap_target targets[2];
12652 +#endif
12653 +};
12654 +
12655 +#endif /* _VX_DEVICE_DEF_H */
12656 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/device.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/device.h
12657 --- linux-2.6.35.2/include/linux/vserver/device.h       1970-01-01 01:00:00.000000000 +0100
12658 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/device.h 2010-08-02 17:05:06.000000000 +0200
12659 @@ -0,0 +1,15 @@
12660 +#ifndef _VX_DEVICE_H
12661 +#define _VX_DEVICE_H
12662 +
12663 +
12664 +#define DATTR_CREATE   0x00000001
12665 +#define DATTR_OPEN     0x00000002
12666 +
12667 +#define DATTR_REMAP    0x00000010
12668 +
12669 +#define DATTR_MASK     0x00000013
12670 +
12671 +
12672 +#else  /* _VX_DEVICE_H */
12673 +#warning duplicate inclusion
12674 +#endif /* _VX_DEVICE_H */
12675 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/dlimit_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/dlimit_cmd.h
12676 --- linux-2.6.35.2/include/linux/vserver/dlimit_cmd.h   1970-01-01 01:00:00.000000000 +0100
12677 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/dlimit_cmd.h     2010-08-02 17:05:06.000000000 +0200
12678 @@ -0,0 +1,109 @@
12679 +#ifndef _VX_DLIMIT_CMD_H
12680 +#define _VX_DLIMIT_CMD_H
12681 +
12682 +
12683 +/*  dlimit vserver commands */
12684 +
12685 +#define VCMD_add_dlimit                VC_CMD(DLIMIT, 1, 0)
12686 +#define VCMD_rem_dlimit                VC_CMD(DLIMIT, 2, 0)
12687 +
12688 +#define VCMD_set_dlimit                VC_CMD(DLIMIT, 5, 0)
12689 +#define VCMD_get_dlimit                VC_CMD(DLIMIT, 6, 0)
12690 +
12691 +struct vcmd_ctx_dlimit_base_v0 {
12692 +       const char __user *name;
12693 +       uint32_t flags;
12694 +};
12695 +
12696 +struct vcmd_ctx_dlimit_v0 {
12697 +       const char __user *name;
12698 +       uint32_t space_used;                    /* used space in kbytes */
12699 +       uint32_t space_total;                   /* maximum space in kbytes */
12700 +       uint32_t inodes_used;                   /* used inodes */
12701 +       uint32_t inodes_total;                  /* maximum inodes */
12702 +       uint32_t reserved;                      /* reserved for root in % */
12703 +       uint32_t flags;
12704 +};
12705 +
12706 +#define CDLIM_UNSET            ((uint32_t)0UL)
12707 +#define CDLIM_INFINITY         ((uint32_t)~0UL)
12708 +#define CDLIM_KEEP             ((uint32_t)~1UL)
12709 +
12710 +#define DLIME_UNIT     0
12711 +#define DLIME_KILO     1
12712 +#define DLIME_MEGA     2
12713 +#define DLIME_GIGA     3
12714 +
12715 +#define DLIMF_SHIFT    0x10
12716 +
12717 +#define DLIMS_USED     0
12718 +#define DLIMS_TOTAL    2
12719 +
12720 +static inline
12721 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12722 +{
12723 +       int exp = (flags & DLIMF_SHIFT) ?
12724 +               (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12725 +       return ((uint64_t)val) << (10 * exp);
12726 +}
12727 +
12728 +static inline
12729 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12730 +{
12731 +       int exp = 0;
12732 +
12733 +       if (*flags & DLIMF_SHIFT) {
12734 +               while (val > (1LL << 32) && (exp < 3)) {
12735 +                       val >>= 10;
12736 +                       exp++;
12737 +               }
12738 +               *flags &= ~(DLIME_GIGA << shift);
12739 +               *flags |= exp << shift;
12740 +       } else
12741 +               val >>= 10;
12742 +       return val;
12743 +}
12744 +
12745 +#ifdef __KERNEL__
12746 +
12747 +#ifdef CONFIG_COMPAT
12748 +
12749 +#include <asm/compat.h>
12750 +
12751 +struct vcmd_ctx_dlimit_base_v0_x32 {
12752 +       compat_uptr_t name_ptr;
12753 +       uint32_t flags;
12754 +};
12755 +
12756 +struct vcmd_ctx_dlimit_v0_x32 {
12757 +       compat_uptr_t name_ptr;
12758 +       uint32_t space_used;                    /* used space in kbytes */
12759 +       uint32_t space_total;                   /* maximum space in kbytes */
12760 +       uint32_t inodes_used;                   /* used inodes */
12761 +       uint32_t inodes_total;                  /* maximum inodes */
12762 +       uint32_t reserved;                      /* reserved for root in % */
12763 +       uint32_t flags;
12764 +};
12765 +
12766 +#endif /* CONFIG_COMPAT */
12767 +
12768 +#include <linux/compiler.h>
12769 +
12770 +extern int vc_add_dlimit(uint32_t, void __user *);
12771 +extern int vc_rem_dlimit(uint32_t, void __user *);
12772 +
12773 +extern int vc_set_dlimit(uint32_t, void __user *);
12774 +extern int vc_get_dlimit(uint32_t, void __user *);
12775 +
12776 +#ifdef CONFIG_COMPAT
12777 +
12778 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12779 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12780 +
12781 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12782 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12783 +
12784 +#endif /* CONFIG_COMPAT */
12785 +
12786 +#endif /* __KERNEL__ */
12787 +#endif /* _VX_DLIMIT_CMD_H */
12788 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/dlimit.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/dlimit.h
12789 --- linux-2.6.35.2/include/linux/vserver/dlimit.h       1970-01-01 01:00:00.000000000 +0100
12790 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/dlimit.h 2010-08-02 17:05:06.000000000 +0200
12791 @@ -0,0 +1,54 @@
12792 +#ifndef _VX_DLIMIT_H
12793 +#define _VX_DLIMIT_H
12794 +
12795 +#include "switch.h"
12796 +
12797 +
12798 +#ifdef __KERNEL__
12799 +
12800 +/*      keep in sync with CDLIM_INFINITY       */
12801 +
12802 +#define DLIM_INFINITY          (~0ULL)
12803 +
12804 +#include <linux/spinlock.h>
12805 +#include <linux/rcupdate.h>
12806 +
12807 +struct super_block;
12808 +
12809 +struct dl_info {
12810 +       struct hlist_node dl_hlist;             /* linked list of contexts */
12811 +       struct rcu_head dl_rcu;                 /* the rcu head */
12812 +       tag_t dl_tag;                           /* context tag */
12813 +       atomic_t dl_usecnt;                     /* usage count */
12814 +       atomic_t dl_refcnt;                     /* reference count */
12815 +
12816 +       struct super_block *dl_sb;              /* associated superblock */
12817 +
12818 +       spinlock_t dl_lock;                     /* protect the values */
12819 +
12820 +       unsigned long long dl_space_used;       /* used space in bytes */
12821 +       unsigned long long dl_space_total;      /* maximum space in bytes */
12822 +       unsigned long dl_inodes_used;           /* used inodes */
12823 +       unsigned long dl_inodes_total;          /* maximum inodes */
12824 +
12825 +       unsigned int dl_nrlmult;                /* non root limit mult */
12826 +};
12827 +
12828 +struct rcu_head;
12829 +
12830 +extern void rcu_free_dl_info(struct rcu_head *);
12831 +extern void unhash_dl_info(struct dl_info *);
12832 +
12833 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12834 +
12835 +
12836 +struct kstatfs;
12837 +
12838 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12839 +
12840 +typedef uint64_t dlsize_t;
12841 +
12842 +#endif /* __KERNEL__ */
12843 +#else  /* _VX_DLIMIT_H */
12844 +#warning duplicate inclusion
12845 +#endif /* _VX_DLIMIT_H */
12846 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/global.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/global.h
12847 --- linux-2.6.35.2/include/linux/vserver/global.h       1970-01-01 01:00:00.000000000 +0100
12848 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/global.h 2010-08-02 17:05:06.000000000 +0200
12849 @@ -0,0 +1,19 @@
12850 +#ifndef _VX_GLOBAL_H
12851 +#define _VX_GLOBAL_H
12852 +
12853 +
12854 +extern atomic_t vx_global_ctotal;
12855 +extern atomic_t vx_global_cactive;
12856 +
12857 +extern atomic_t nx_global_ctotal;
12858 +extern atomic_t nx_global_cactive;
12859 +
12860 +extern atomic_t vs_global_nsproxy;
12861 +extern atomic_t vs_global_fs;
12862 +extern atomic_t vs_global_mnt_ns;
12863 +extern atomic_t vs_global_uts_ns;
12864 +extern atomic_t vs_global_user_ns;
12865 +extern atomic_t vs_global_pid_ns;
12866 +
12867 +
12868 +#endif /* _VX_GLOBAL_H */
12869 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/history.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/history.h
12870 --- linux-2.6.35.2/include/linux/vserver/history.h      1970-01-01 01:00:00.000000000 +0100
12871 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/history.h        2010-08-02 17:05:06.000000000 +0200
12872 @@ -0,0 +1,197 @@
12873 +#ifndef _VX_HISTORY_H
12874 +#define _VX_HISTORY_H
12875 +
12876 +
12877 +enum {
12878 +       VXH_UNUSED = 0,
12879 +       VXH_THROW_OOPS = 1,
12880 +
12881 +       VXH_GET_VX_INFO,
12882 +       VXH_PUT_VX_INFO,
12883 +       VXH_INIT_VX_INFO,
12884 +       VXH_SET_VX_INFO,
12885 +       VXH_CLR_VX_INFO,
12886 +       VXH_CLAIM_VX_INFO,
12887 +       VXH_RELEASE_VX_INFO,
12888 +       VXH_ALLOC_VX_INFO,
12889 +       VXH_DEALLOC_VX_INFO,
12890 +       VXH_HASH_VX_INFO,
12891 +       VXH_UNHASH_VX_INFO,
12892 +       VXH_LOC_VX_INFO,
12893 +       VXH_LOOKUP_VX_INFO,
12894 +       VXH_CREATE_VX_INFO,
12895 +};
12896 +
12897 +struct _vxhe_vxi {
12898 +       struct vx_info *ptr;
12899 +       unsigned xid;
12900 +       unsigned usecnt;
12901 +       unsigned tasks;
12902 +};
12903 +
12904 +struct _vxhe_set_clr {
12905 +       void *data;
12906 +};
12907 +
12908 +struct _vxhe_loc_lookup {
12909 +       unsigned arg;
12910 +};
12911 +
12912 +struct _vx_hist_entry {
12913 +       void *loc;
12914 +       unsigned short seq;
12915 +       unsigned short type;
12916 +       struct _vxhe_vxi vxi;
12917 +       union {
12918 +               struct _vxhe_set_clr sc;
12919 +               struct _vxhe_loc_lookup ll;
12920 +       };
12921 +};
12922 +
12923 +#ifdef CONFIG_VSERVER_HISTORY
12924 +
12925 +extern unsigned volatile int vxh_active;
12926 +
12927 +struct _vx_hist_entry *vxh_advance(void *loc);
12928 +
12929 +
12930 +static inline
12931 +void   __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12932 +{
12933 +       entry->vxi.ptr = vxi;
12934 +       if (vxi) {
12935 +               entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12936 +               entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12937 +               entry->vxi.xid = vxi->vx_id;
12938 +       }
12939 +}
12940 +
12941 +
12942 +#define        __HERE__ current_text_addr()
12943 +
12944 +#define __VXH_BODY(__type, __data, __here)     \
12945 +       struct _vx_hist_entry *entry;           \
12946 +                                               \
12947 +       preempt_disable();                      \
12948 +       entry = vxh_advance(__here);            \
12949 +       __data;                                 \
12950 +       entry->type = __type;                   \
12951 +       preempt_enable();
12952 +
12953 +
12954 +       /* pass vxi only */
12955 +
12956 +#define __VXH_SMPL                             \
12957 +       __vxh_copy_vxi(entry, vxi)
12958 +
12959 +static inline
12960 +void   __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12961 +{
12962 +       __VXH_BODY(__type, __VXH_SMPL, __here)
12963 +}
12964 +
12965 +       /* pass vxi and data (void *) */
12966 +
12967 +#define __VXH_DATA                             \
12968 +       __vxh_copy_vxi(entry, vxi);             \
12969 +       entry->sc.data = data
12970 +
12971 +static inline
12972 +void   __vxh_data(struct vx_info *vxi, void *data,
12973 +                       int __type, void *__here)
12974 +{
12975 +       __VXH_BODY(__type, __VXH_DATA, __here)
12976 +}
12977 +
12978 +       /* pass vxi and arg (long) */
12979 +
12980 +#define __VXH_LONG                             \
12981 +       __vxh_copy_vxi(entry, vxi);             \
12982 +       entry->ll.arg = arg
12983 +
12984 +static inline
12985 +void   __vxh_long(struct vx_info *vxi, long arg,
12986 +                       int __type, void *__here)
12987 +{
12988 +       __VXH_BODY(__type, __VXH_LONG, __here)
12989 +}
12990 +
12991 +
12992 +static inline
12993 +void   __vxh_throw_oops(void *__here)
12994 +{
12995 +       __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12996 +       /* prevent further acquisition */
12997 +       vxh_active = 0;
12998 +}
12999 +
13000 +
13001 +#define vxh_throw_oops()       __vxh_throw_oops(__HERE__);
13002 +
13003 +#define __vxh_get_vx_info(v, h)        __vxh_smpl(v, VXH_GET_VX_INFO, h);
13004 +#define __vxh_put_vx_info(v, h)        __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13005 +
13006 +#define __vxh_init_vx_info(v, d, h) \
13007 +       __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13008 +#define __vxh_set_vx_info(v, d, h) \
13009 +       __vxh_data(v, d, VXH_SET_VX_INFO, h);
13010 +#define __vxh_clr_vx_info(v, d, h) \
13011 +       __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13012 +
13013 +#define __vxh_claim_vx_info(v, d, h) \
13014 +       __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13015 +#define __vxh_release_vx_info(v, d, h) \
13016 +       __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13017 +
13018 +#define vxh_alloc_vx_info(v) \
13019 +       __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13020 +#define vxh_dealloc_vx_info(v) \
13021 +       __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13022 +
13023 +#define vxh_hash_vx_info(v) \
13024 +       __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13025 +#define vxh_unhash_vx_info(v) \
13026 +       __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13027 +
13028 +#define vxh_loc_vx_info(v, l) \
13029 +       __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13030 +#define vxh_lookup_vx_info(v, l) \
13031 +       __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13032 +#define vxh_create_vx_info(v, l) \
13033 +       __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13034 +
13035 +extern void vxh_dump_history(void);
13036 +
13037 +
13038 +#else  /* CONFIG_VSERVER_HISTORY */
13039 +
13040 +#define        __HERE__        0
13041 +
13042 +#define vxh_throw_oops()               do { } while (0)
13043 +
13044 +#define __vxh_get_vx_info(v, h)                do { } while (0)
13045 +#define __vxh_put_vx_info(v, h)                do { } while (0)
13046 +
13047 +#define __vxh_init_vx_info(v, d, h)    do { } while (0)
13048 +#define __vxh_set_vx_info(v, d, h)     do { } while (0)
13049 +#define __vxh_clr_vx_info(v, d, h)     do { } while (0)
13050 +
13051 +#define __vxh_claim_vx_info(v, d, h)   do { } while (0)
13052 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13053 +
13054 +#define vxh_alloc_vx_info(v)           do { } while (0)
13055 +#define vxh_dealloc_vx_info(v)         do { } while (0)
13056 +
13057 +#define vxh_hash_vx_info(v)            do { } while (0)
13058 +#define vxh_unhash_vx_info(v)          do { } while (0)
13059 +
13060 +#define vxh_loc_vx_info(v, l)          do { } while (0)
13061 +#define vxh_lookup_vx_info(v, l)       do { } while (0)
13062 +#define vxh_create_vx_info(v, l)       do { } while (0)
13063 +
13064 +#define vxh_dump_history()             do { } while (0)
13065 +
13066 +
13067 +#endif /* CONFIG_VSERVER_HISTORY */
13068 +
13069 +#endif /* _VX_HISTORY_H */
13070 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/inode_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/inode_cmd.h
13071 --- linux-2.6.35.2/include/linux/vserver/inode_cmd.h    1970-01-01 01:00:00.000000000 +0100
13072 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/inode_cmd.h      2010-08-02 17:05:06.000000000 +0200
13073 @@ -0,0 +1,59 @@
13074 +#ifndef _VX_INODE_CMD_H
13075 +#define _VX_INODE_CMD_H
13076 +
13077 +
13078 +/*  inode vserver commands */
13079 +
13080 +#define VCMD_get_iattr         VC_CMD(INODE, 1, 1)
13081 +#define VCMD_set_iattr         VC_CMD(INODE, 2, 1)
13082 +
13083 +#define VCMD_fget_iattr                VC_CMD(INODE, 3, 0)
13084 +#define VCMD_fset_iattr                VC_CMD(INODE, 4, 0)
13085 +
13086 +struct vcmd_ctx_iattr_v1 {
13087 +       const char __user *name;
13088 +       uint32_t tag;
13089 +       uint32_t flags;
13090 +       uint32_t mask;
13091 +};
13092 +
13093 +struct vcmd_ctx_fiattr_v0 {
13094 +       uint32_t tag;
13095 +       uint32_t flags;
13096 +       uint32_t mask;
13097 +};
13098 +
13099 +
13100 +#ifdef __KERNEL__
13101 +
13102 +
13103 +#ifdef CONFIG_COMPAT
13104 +
13105 +#include <asm/compat.h>
13106 +
13107 +struct vcmd_ctx_iattr_v1_x32 {
13108 +       compat_uptr_t name_ptr;
13109 +       uint32_t tag;
13110 +       uint32_t flags;
13111 +       uint32_t mask;
13112 +};
13113 +
13114 +#endif /* CONFIG_COMPAT */
13115 +
13116 +#include <linux/compiler.h>
13117 +
13118 +extern int vc_get_iattr(void __user *);
13119 +extern int vc_set_iattr(void __user *);
13120 +
13121 +extern int vc_fget_iattr(uint32_t, void __user *);
13122 +extern int vc_fset_iattr(uint32_t, void __user *);
13123 +
13124 +#ifdef CONFIG_COMPAT
13125 +
13126 +extern int vc_get_iattr_x32(void __user *);
13127 +extern int vc_set_iattr_x32(void __user *);
13128 +
13129 +#endif /* CONFIG_COMPAT */
13130 +
13131 +#endif /* __KERNEL__ */
13132 +#endif /* _VX_INODE_CMD_H */
13133 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/inode.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/inode.h
13134 --- linux-2.6.35.2/include/linux/vserver/inode.h        1970-01-01 01:00:00.000000000 +0100
13135 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/inode.h  2010-08-02 17:05:06.000000000 +0200
13136 @@ -0,0 +1,39 @@
13137 +#ifndef _VX_INODE_H
13138 +#define _VX_INODE_H
13139 +
13140 +
13141 +#define IATTR_TAG      0x01000000
13142 +
13143 +#define IATTR_ADMIN    0x00000001
13144 +#define IATTR_WATCH    0x00000002
13145 +#define IATTR_HIDE     0x00000004
13146 +#define IATTR_FLAGS    0x00000007
13147 +
13148 +#define IATTR_BARRIER  0x00010000
13149 +#define IATTR_IXUNLINK 0x00020000
13150 +#define IATTR_IMMUTABLE 0x00040000
13151 +#define IATTR_COW      0x00080000
13152 +
13153 +#ifdef __KERNEL__
13154 +
13155 +
13156 +#ifdef CONFIG_VSERVER_PROC_SECURE
13157 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN | IATTR_HIDE )
13158 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
13159 +#else
13160 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN )
13161 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
13162 +#endif
13163 +
13164 +#define vx_hide_check(c, m)    (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
13165 +
13166 +#endif /* __KERNEL__ */
13167 +
13168 +/* inode ioctls */
13169 +
13170 +#define FIOC_GETXFLG   _IOR('x', 5, long)
13171 +#define FIOC_SETXFLG   _IOW('x', 6, long)
13172 +
13173 +#else  /* _VX_INODE_H */
13174 +#warning duplicate inclusion
13175 +#endif /* _VX_INODE_H */
13176 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/Kbuild linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/Kbuild
13177 --- linux-2.6.35.2/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
13178 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/Kbuild   2010-08-02 17:05:06.000000000 +0200
13179 @@ -0,0 +1,8 @@
13180 +
13181 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
13182 +       cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
13183 +       inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
13184 +       debug_cmd.h device_cmd.h
13185 +
13186 +unifdef-y += switch.h network.h monitor.h inode.h device.h
13187 +
13188 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/limit_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/limit_cmd.h
13189 --- linux-2.6.35.2/include/linux/vserver/limit_cmd.h    1970-01-01 01:00:00.000000000 +0100
13190 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/limit_cmd.h      2010-08-02 17:05:06.000000000 +0200
13191 @@ -0,0 +1,71 @@
13192 +#ifndef _VX_LIMIT_CMD_H
13193 +#define _VX_LIMIT_CMD_H
13194 +
13195 +
13196 +/*  rlimit vserver commands */
13197 +
13198 +#define VCMD_get_rlimit                VC_CMD(RLIMIT, 1, 0)
13199 +#define VCMD_set_rlimit                VC_CMD(RLIMIT, 2, 0)
13200 +#define VCMD_get_rlimit_mask   VC_CMD(RLIMIT, 3, 0)
13201 +#define VCMD_reset_hits                VC_CMD(RLIMIT, 7, 0)
13202 +#define VCMD_reset_minmax      VC_CMD(RLIMIT, 9, 0)
13203 +
13204 +struct vcmd_ctx_rlimit_v0 {
13205 +       uint32_t id;
13206 +       uint64_t minimum;
13207 +       uint64_t softlimit;
13208 +       uint64_t maximum;
13209 +};
13210 +
13211 +struct vcmd_ctx_rlimit_mask_v0 {
13212 +       uint32_t minimum;
13213 +       uint32_t softlimit;
13214 +       uint32_t maximum;
13215 +};
13216 +
13217 +#define VCMD_rlimit_stat       VC_CMD(VSTAT, 1, 0)
13218 +
13219 +struct vcmd_rlimit_stat_v0 {
13220 +       uint32_t id;
13221 +       uint32_t hits;
13222 +       uint64_t value;
13223 +       uint64_t minimum;
13224 +       uint64_t maximum;
13225 +};
13226 +
13227 +#define CRLIM_UNSET            (0ULL)
13228 +#define CRLIM_INFINITY         (~0ULL)
13229 +#define CRLIM_KEEP             (~1ULL)
13230 +
13231 +#ifdef __KERNEL__
13232 +
13233 +#ifdef CONFIG_IA32_EMULATION
13234 +
13235 +struct vcmd_ctx_rlimit_v0_x32 {
13236 +       uint32_t id;
13237 +       uint64_t minimum;
13238 +       uint64_t softlimit;
13239 +       uint64_t maximum;
13240 +} __attribute__ ((packed));
13241 +
13242 +#endif /* CONFIG_IA32_EMULATION */
13243 +
13244 +#include <linux/compiler.h>
13245 +
13246 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13247 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13248 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13249 +extern int vc_reset_hits(struct vx_info *, void __user *);
13250 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13251 +
13252 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13253 +
13254 +#ifdef CONFIG_IA32_EMULATION
13255 +
13256 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13257 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13258 +
13259 +#endif /* CONFIG_IA32_EMULATION */
13260 +
13261 +#endif /* __KERNEL__ */
13262 +#endif /* _VX_LIMIT_CMD_H */
13263 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/limit_def.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/limit_def.h
13264 --- linux-2.6.35.2/include/linux/vserver/limit_def.h    1970-01-01 01:00:00.000000000 +0100
13265 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/limit_def.h      2010-08-02 17:05:06.000000000 +0200
13266 @@ -0,0 +1,47 @@
13267 +#ifndef _VX_LIMIT_DEF_H
13268 +#define _VX_LIMIT_DEF_H
13269 +
13270 +#include <asm/atomic.h>
13271 +#include <asm/resource.h>
13272 +
13273 +#include "limit.h"
13274 +
13275 +
13276 +struct _vx_res_limit {
13277 +       rlim_t soft;            /* Context soft limit */
13278 +       rlim_t hard;            /* Context hard limit */
13279 +
13280 +       rlim_atomic_t rcur;     /* Current value */
13281 +       rlim_t rmin;            /* Context minimum */
13282 +       rlim_t rmax;            /* Context maximum */
13283 +
13284 +       atomic_t lhit;          /* Limit hits */
13285 +};
13286 +
13287 +/* context sub struct */
13288 +
13289 +struct _vx_limit {
13290 +       struct _vx_res_limit res[NUM_LIMITS];
13291 +};
13292 +
13293 +#ifdef CONFIG_VSERVER_DEBUG
13294 +
13295 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13296 +{
13297 +       int i;
13298 +
13299 +       printk("\t_vx_limit:");
13300 +       for (i = 0; i < NUM_LIMITS; i++) {
13301 +               printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13302 +                       i, (unsigned long)__rlim_get(limit, i),
13303 +                       (unsigned long)__rlim_rmin(limit, i),
13304 +                       (unsigned long)__rlim_rmax(limit, i),
13305 +                       (long)__rlim_soft(limit, i),
13306 +                       (long)__rlim_hard(limit, i),
13307 +                       atomic_read(&__rlim_lhit(limit, i)));
13308 +       }
13309 +}
13310 +
13311 +#endif
13312 +
13313 +#endif /* _VX_LIMIT_DEF_H */
13314 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/limit.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/limit.h
13315 --- linux-2.6.35.2/include/linux/vserver/limit.h        1970-01-01 01:00:00.000000000 +0100
13316 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/limit.h  2010-08-02 17:05:06.000000000 +0200
13317 @@ -0,0 +1,71 @@
13318 +#ifndef _VX_LIMIT_H
13319 +#define _VX_LIMIT_H
13320 +
13321 +#define VLIMIT_NSOCK   16
13322 +#define VLIMIT_OPENFD  17
13323 +#define VLIMIT_ANON    18
13324 +#define VLIMIT_SHMEM   19
13325 +#define VLIMIT_SEMARY  20
13326 +#define VLIMIT_NSEMS   21
13327 +#define VLIMIT_DENTRY  22
13328 +#define VLIMIT_MAPPED  23
13329 +
13330 +
13331 +#ifdef __KERNEL__
13332 +
13333 +#define        VLIM_NOCHECK    ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13334 +
13335 +/*     keep in sync with CRLIM_INFINITY */
13336 +
13337 +#define        VLIM_INFINITY   (~0ULL)
13338 +
13339 +#include <asm/atomic.h>
13340 +#include <asm/resource.h>
13341 +
13342 +#ifndef RLIM_INFINITY
13343 +#warning RLIM_INFINITY is undefined
13344 +#endif
13345 +
13346 +#define __rlim_val(l, r, v)    ((l)->res[r].v)
13347 +
13348 +#define __rlim_soft(l, r)      __rlim_val(l, r, soft)
13349 +#define __rlim_hard(l, r)      __rlim_val(l, r, hard)
13350 +
13351 +#define __rlim_rcur(l, r)      __rlim_val(l, r, rcur)
13352 +#define __rlim_rmin(l, r)      __rlim_val(l, r, rmin)
13353 +#define __rlim_rmax(l, r)      __rlim_val(l, r, rmax)
13354 +
13355 +#define __rlim_lhit(l, r)      __rlim_val(l, r, lhit)
13356 +#define __rlim_hit(l, r)       atomic_inc(&__rlim_lhit(l, r))
13357 +
13358 +typedef atomic_long_t rlim_atomic_t;
13359 +typedef unsigned long rlim_t;
13360 +
13361 +#define __rlim_get(l, r)       atomic_long_read(&__rlim_rcur(l, r))
13362 +#define __rlim_set(l, r, v)    atomic_long_set(&__rlim_rcur(l, r), v)
13363 +#define __rlim_inc(l, r)       atomic_long_inc(&__rlim_rcur(l, r))
13364 +#define __rlim_dec(l, r)       atomic_long_dec(&__rlim_rcur(l, r))
13365 +#define __rlim_add(l, r, v)    atomic_long_add(v, &__rlim_rcur(l, r))
13366 +#define __rlim_sub(l, r, v)    atomic_long_sub(v, &__rlim_rcur(l, r))
13367 +
13368 +
13369 +#if    (RLIM_INFINITY == VLIM_INFINITY)
13370 +#define        VX_VLIM(r) ((long long)(long)(r))
13371 +#define        VX_RLIM(v) ((rlim_t)(v))
13372 +#else
13373 +#define        VX_VLIM(r) (((r) == RLIM_INFINITY) \
13374 +               ? VLIM_INFINITY : (long long)(r))
13375 +#define        VX_RLIM(v) (((v) == VLIM_INFINITY) \
13376 +               ? RLIM_INFINITY : (rlim_t)(v))
13377 +#endif
13378 +
13379 +struct sysinfo;
13380 +
13381 +void vx_vsi_meminfo(struct sysinfo *);
13382 +void vx_vsi_swapinfo(struct sysinfo *);
13383 +long vx_vsi_cached(struct sysinfo *);
13384 +
13385 +#define NUM_LIMITS     24
13386 +
13387 +#endif /* __KERNEL__ */
13388 +#endif /* _VX_LIMIT_H */
13389 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/limit_int.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/limit_int.h
13390 --- linux-2.6.35.2/include/linux/vserver/limit_int.h    1970-01-01 01:00:00.000000000 +0100
13391 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/limit_int.h      2010-08-02 17:05:06.000000000 +0200
13392 @@ -0,0 +1,198 @@
13393 +#ifndef _VX_LIMIT_INT_H
13394 +#define _VX_LIMIT_INT_H
13395 +
13396 +#include "context.h"
13397 +
13398 +#ifdef __KERNEL__
13399 +
13400 +#define VXD_RCRES_COND(r)      VXD_CBIT(cres, r)
13401 +#define VXD_RLIMIT_COND(r)     VXD_CBIT(limit, r)
13402 +
13403 +extern const char *vlimit_name[NUM_LIMITS];
13404 +
13405 +static inline void __vx_acc_cres(struct vx_info *vxi,
13406 +       int res, int dir, void *_data, char *_file, int _line)
13407 +{
13408 +       if (VXD_RCRES_COND(res))
13409 +               vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13410 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13411 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13412 +                       (dir > 0) ? "++" : "--", _data, _file, _line);
13413 +       if (!vxi)
13414 +               return;
13415 +
13416 +       if (dir > 0)
13417 +               __rlim_inc(&vxi->limit, res);
13418 +       else
13419 +               __rlim_dec(&vxi->limit, res);
13420 +}
13421 +
13422 +static inline void __vx_add_cres(struct vx_info *vxi,
13423 +       int res, int amount, void *_data, char *_file, int _line)
13424 +{
13425 +       if (VXD_RCRES_COND(res))
13426 +               vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13427 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13428 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13429 +                       amount, _data, _file, _line);
13430 +       if (amount == 0)
13431 +               return;
13432 +       if (!vxi)
13433 +               return;
13434 +       __rlim_add(&vxi->limit, res, amount);
13435 +}
13436 +
13437 +static inline
13438 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13439 +{
13440 +       int cond = (value > __rlim_rmax(limit, res));
13441 +
13442 +       if (cond)
13443 +               __rlim_rmax(limit, res) = value;
13444 +       return cond;
13445 +}
13446 +
13447 +static inline
13448 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13449 +{
13450 +       int cond = (value < __rlim_rmin(limit, res));
13451 +
13452 +       if (cond)
13453 +               __rlim_rmin(limit, res) = value;
13454 +       return cond;
13455 +}
13456 +
13457 +static inline
13458 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13459 +{
13460 +       if (!__vx_cres_adjust_max(limit, res, value))
13461 +               __vx_cres_adjust_min(limit, res, value);
13462 +}
13463 +
13464 +
13465 +/*     return values:
13466 +        +1 ... no limit hit
13467 +        -1 ... over soft limit
13468 +         0 ... over hard limit         */
13469 +
13470 +static inline int __vx_cres_avail(struct vx_info *vxi,
13471 +       int res, int num, char *_file, int _line)
13472 +{
13473 +       struct _vx_limit *limit;
13474 +       rlim_t value;
13475 +
13476 +       if (VXD_RLIMIT_COND(res))
13477 +               vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13478 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13479 +                       (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13480 +                       (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13481 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13482 +                       num, _file, _line);
13483 +       if (!vxi)
13484 +               return 1;
13485 +
13486 +       limit = &vxi->limit;
13487 +       value = __rlim_get(limit, res);
13488 +
13489 +       if (!__vx_cres_adjust_max(limit, res, value))
13490 +               __vx_cres_adjust_min(limit, res, value);
13491 +
13492 +       if (num == 0)
13493 +               return 1;
13494 +
13495 +       if (__rlim_soft(limit, res) == RLIM_INFINITY)
13496 +               return -1;
13497 +       if (value + num <= __rlim_soft(limit, res))
13498 +               return -1;
13499 +
13500 +       if (__rlim_hard(limit, res) == RLIM_INFINITY)
13501 +               return 1;
13502 +       if (value + num <= __rlim_hard(limit, res))
13503 +               return 1;
13504 +
13505 +       __rlim_hit(limit, res);
13506 +       return 0;
13507 +}
13508 +
13509 +
13510 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13511 +
13512 +static inline
13513 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13514 +{
13515 +       rlim_t value, sum = 0;
13516 +       int res;
13517 +
13518 +       while ((res = *array++)) {
13519 +               value = __rlim_get(limit, res);
13520 +               __vx_cres_fixup(limit, res, value);
13521 +               sum += value;
13522 +       }
13523 +       return sum;
13524 +}
13525 +
13526 +static inline
13527 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13528 +{
13529 +       rlim_t value = __vx_cres_array_sum(limit, array + 1);
13530 +       int res = *array;
13531 +
13532 +       if (value == __rlim_get(limit, res))
13533 +               return value;
13534 +
13535 +       __rlim_set(limit, res, value);
13536 +       /* now adjust min/max */
13537 +       if (!__vx_cres_adjust_max(limit, res, value))
13538 +               __vx_cres_adjust_min(limit, res, value);
13539 +
13540 +       return value;
13541 +}
13542 +
13543 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13544 +       const int *array, int num, char *_file, int _line)
13545 +{
13546 +       struct _vx_limit *limit;
13547 +       rlim_t value = 0;
13548 +       int res;
13549 +
13550 +       if (num == 0)
13551 +               return 1;
13552 +       if (!vxi)
13553 +               return 1;
13554 +
13555 +       limit = &vxi->limit;
13556 +       res = *array;
13557 +       value = __vx_cres_array_sum(limit, array + 1);
13558 +
13559 +       __rlim_set(limit, res, value);
13560 +       __vx_cres_fixup(limit, res, value);
13561 +
13562 +       return __vx_cres_avail(vxi, res, num, _file, _line);
13563 +}
13564 +
13565 +
13566 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13567 +{
13568 +       rlim_t value;
13569 +       int res;
13570 +
13571 +       /* complex resources first */
13572 +       if ((id < 0) || (id == RLIMIT_RSS))
13573 +               __vx_cres_array_fixup(limit, VLA_RSS);
13574 +
13575 +       for (res = 0; res < NUM_LIMITS; res++) {
13576 +               if ((id > 0) && (res != id))
13577 +                       continue;
13578 +
13579 +               value = __rlim_get(limit, res);
13580 +               __vx_cres_fixup(limit, res, value);
13581 +
13582 +               /* not supposed to happen, maybe warn? */
13583 +               if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13584 +                       __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13585 +       }
13586 +}
13587 +
13588 +
13589 +#endif /* __KERNEL__ */
13590 +#endif /* _VX_LIMIT_INT_H */
13591 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/monitor.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/monitor.h
13592 --- linux-2.6.35.2/include/linux/vserver/monitor.h      1970-01-01 01:00:00.000000000 +0100
13593 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/monitor.h        2010-08-02 17:05:06.000000000 +0200
13594 @@ -0,0 +1,96 @@
13595 +#ifndef _VX_MONITOR_H
13596 +#define _VX_MONITOR_H
13597 +
13598 +#include <linux/types.h>
13599 +
13600 +enum {
13601 +       VXM_UNUSED = 0,
13602 +
13603 +       VXM_SYNC = 0x10,
13604 +
13605 +       VXM_UPDATE = 0x20,
13606 +       VXM_UPDATE_1,
13607 +       VXM_UPDATE_2,
13608 +
13609 +       VXM_RQINFO_1 = 0x24,
13610 +       VXM_RQINFO_2,
13611 +
13612 +       VXM_ACTIVATE = 0x40,
13613 +       VXM_DEACTIVATE,
13614 +       VXM_IDLE,
13615 +
13616 +       VXM_HOLD = 0x44,
13617 +       VXM_UNHOLD,
13618 +
13619 +       VXM_MIGRATE = 0x48,
13620 +       VXM_RESCHED,
13621 +
13622 +       /* all other bits are flags */
13623 +       VXM_SCHED = 0x80,
13624 +};
13625 +
13626 +struct _vxm_update_1 {
13627 +       uint32_t tokens_max;
13628 +       uint32_t fill_rate;
13629 +       uint32_t interval;
13630 +};
13631 +
13632 +struct _vxm_update_2 {
13633 +       uint32_t tokens_min;
13634 +       uint32_t fill_rate;
13635 +       uint32_t interval;
13636 +};
13637 +
13638 +struct _vxm_rqinfo_1 {
13639 +       uint16_t running;
13640 +       uint16_t onhold;
13641 +       uint16_t iowait;
13642 +       uint16_t uintr;
13643 +       uint32_t idle_tokens;
13644 +};
13645 +
13646 +struct _vxm_rqinfo_2 {
13647 +       uint32_t norm_time;
13648 +       uint32_t idle_time;
13649 +       uint32_t idle_skip;
13650 +};
13651 +
13652 +struct _vxm_sched {
13653 +       uint32_t tokens;
13654 +       uint32_t norm_time;
13655 +       uint32_t idle_time;
13656 +};
13657 +
13658 +struct _vxm_task {
13659 +       uint16_t pid;
13660 +       uint16_t state;
13661 +};
13662 +
13663 +struct _vxm_event {
13664 +       uint32_t jif;
13665 +       union {
13666 +               uint32_t seq;
13667 +               uint32_t sec;
13668 +       };
13669 +       union {
13670 +               uint32_t tokens;
13671 +               uint32_t nsec;
13672 +               struct _vxm_task tsk;
13673 +       };
13674 +};
13675 +
13676 +struct _vx_mon_entry {
13677 +       uint16_t type;
13678 +       uint16_t xid;
13679 +       union {
13680 +               struct _vxm_event ev;
13681 +               struct _vxm_sched sd;
13682 +               struct _vxm_update_1 u1;
13683 +               struct _vxm_update_2 u2;
13684 +               struct _vxm_rqinfo_1 q1;
13685 +               struct _vxm_rqinfo_2 q2;
13686 +       };
13687 +};
13688 +
13689 +
13690 +#endif /* _VX_MONITOR_H */
13691 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/network_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/network_cmd.h
13692 --- linux-2.6.35.2/include/linux/vserver/network_cmd.h  1970-01-01 01:00:00.000000000 +0100
13693 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/network_cmd.h    2010-08-02 17:05:06.000000000 +0200
13694 @@ -0,0 +1,150 @@
13695 +#ifndef _VX_NETWORK_CMD_H
13696 +#define _VX_NETWORK_CMD_H
13697 +
13698 +
13699 +/* vinfo commands */
13700 +
13701 +#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
13702 +
13703 +#ifdef __KERNEL__
13704 +extern int vc_task_nid(uint32_t);
13705 +
13706 +#endif /* __KERNEL__ */
13707 +
13708 +#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
13709 +
13710 +struct vcmd_nx_info_v0 {
13711 +       uint32_t nid;
13712 +       /* more to come */
13713 +};
13714 +
13715 +#ifdef __KERNEL__
13716 +extern int vc_nx_info(struct nx_info *, void __user *);
13717 +
13718 +#endif /* __KERNEL__ */
13719 +
13720 +#include <linux/in.h>
13721 +#include <linux/in6.h>
13722 +
13723 +#define VCMD_net_create_v0     VC_CMD(VNET, 1, 0)
13724 +#define VCMD_net_create                VC_CMD(VNET, 1, 1)
13725 +
13726 +struct  vcmd_net_create {
13727 +       uint64_t flagword;
13728 +};
13729 +
13730 +#define VCMD_net_migrate       VC_CMD(NETMIG, 1, 0)
13731 +
13732 +#define VCMD_net_add           VC_CMD(NETALT, 1, 0)
13733 +#define VCMD_net_remove                VC_CMD(NETALT, 2, 0)
13734 +
13735 +struct vcmd_net_addr_v0 {
13736 +       uint16_t type;
13737 +       uint16_t count;
13738 +       struct in_addr ip[4];
13739 +       struct in_addr mask[4];
13740 +};
13741 +
13742 +#define VCMD_net_add_ipv4      VC_CMD(NETALT, 1, 1)
13743 +#define VCMD_net_remove_ipv4   VC_CMD(NETALT, 2, 1)
13744 +
13745 +struct vcmd_net_addr_ipv4_v1 {
13746 +       uint16_t type;
13747 +       uint16_t flags;
13748 +       struct in_addr ip;
13749 +       struct in_addr mask;
13750 +};
13751 +
13752 +#define VCMD_net_add_ipv6      VC_CMD(NETALT, 3, 1)
13753 +#define VCMD_net_remove_ipv6   VC_CMD(NETALT, 4, 1)
13754 +
13755 +struct vcmd_net_addr_ipv6_v1 {
13756 +       uint16_t type;
13757 +       uint16_t flags;
13758 +       uint32_t prefix;
13759 +       struct in6_addr ip;
13760 +       struct in6_addr mask;
13761 +};
13762 +
13763 +#define VCMD_add_match_ipv4    VC_CMD(NETALT, 5, 0)
13764 +#define VCMD_get_match_ipv4    VC_CMD(NETALT, 6, 0)
13765 +
13766 +struct vcmd_match_ipv4_v0 {
13767 +       uint16_t type;
13768 +       uint16_t flags;
13769 +       uint16_t parent;
13770 +       uint16_t prefix;
13771 +       struct in_addr ip;
13772 +       struct in_addr ip2;
13773 +       struct in_addr mask;
13774 +};
13775 +
13776 +#define VCMD_add_match_ipv6    VC_CMD(NETALT, 7, 0)
13777 +#define VCMD_get_match_ipv6    VC_CMD(NETALT, 8, 0)
13778 +
13779 +struct vcmd_match_ipv6_v0 {
13780 +       uint16_t type;
13781 +       uint16_t flags;
13782 +       uint16_t parent;
13783 +       uint16_t prefix;
13784 +       struct in6_addr ip;
13785 +       struct in6_addr ip2;
13786 +       struct in6_addr mask;
13787 +};
13788 +
13789 +
13790 +#ifdef __KERNEL__
13791 +extern int vc_net_create(uint32_t, void __user *);
13792 +extern int vc_net_migrate(struct nx_info *, void __user *);
13793 +
13794 +extern int vc_net_add(struct nx_info *, void __user *);
13795 +extern int vc_net_remove(struct nx_info *, void __user *);
13796 +
13797 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13798 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
13799 +
13800 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13801 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13802 +
13803 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13804 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13805 +
13806 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13807 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13808 +
13809 +#endif /* __KERNEL__ */
13810 +
13811 +
13812 +/* flag commands */
13813 +
13814 +#define VCMD_get_nflags                VC_CMD(FLAGS, 5, 0)
13815 +#define VCMD_set_nflags                VC_CMD(FLAGS, 6, 0)
13816 +
13817 +struct vcmd_net_flags_v0 {
13818 +       uint64_t flagword;
13819 +       uint64_t mask;
13820 +};
13821 +
13822 +#ifdef __KERNEL__
13823 +extern int vc_get_nflags(struct nx_info *, void __user *);
13824 +extern int vc_set_nflags(struct nx_info *, void __user *);
13825 +
13826 +#endif /* __KERNEL__ */
13827 +
13828 +
13829 +/* network caps commands */
13830 +
13831 +#define VCMD_get_ncaps         VC_CMD(FLAGS, 7, 0)
13832 +#define VCMD_set_ncaps         VC_CMD(FLAGS, 8, 0)
13833 +
13834 +struct vcmd_net_caps_v0 {
13835 +       uint64_t ncaps;
13836 +       uint64_t cmask;
13837 +};
13838 +
13839 +#ifdef __KERNEL__
13840 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13841 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13842 +
13843 +#endif /* __KERNEL__ */
13844 +#endif /* _VX_CONTEXT_CMD_H */
13845 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/network.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/network.h
13846 --- linux-2.6.35.2/include/linux/vserver/network.h      1970-01-01 01:00:00.000000000 +0100
13847 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/network.h        2010-08-02 17:05:06.000000000 +0200
13848 @@ -0,0 +1,146 @@
13849 +#ifndef _VX_NETWORK_H
13850 +#define _VX_NETWORK_H
13851 +
13852 +#include <linux/types.h>
13853 +
13854 +
13855 +#define MAX_N_CONTEXT  65535   /* Arbitrary limit */
13856 +
13857 +
13858 +/* network flags */
13859 +
13860 +#define NXF_INFO_PRIVATE       0x00000008
13861 +
13862 +#define NXF_SINGLE_IP          0x00000100
13863 +#define NXF_LBACK_REMAP                0x00000200
13864 +#define NXF_LBACK_ALLOW                0x00000400
13865 +
13866 +#define NXF_HIDE_NETIF         0x02000000
13867 +#define NXF_HIDE_LBACK         0x04000000
13868 +
13869 +#define NXF_STATE_SETUP                (1ULL << 32)
13870 +#define NXF_STATE_ADMIN                (1ULL << 34)
13871 +
13872 +#define NXF_SC_HELPER          (1ULL << 36)
13873 +#define NXF_PERSISTENT         (1ULL << 38)
13874 +
13875 +#define NXF_ONE_TIME           (0x0005ULL << 32)
13876 +
13877 +
13878 +#define        NXF_INIT_SET            (__nxf_init_set())
13879 +
13880 +static inline uint64_t __nxf_init_set(void) {
13881 +       return    NXF_STATE_ADMIN
13882 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13883 +               | NXF_LBACK_REMAP
13884 +               | NXF_HIDE_LBACK
13885 +#endif
13886 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13887 +               | NXF_SINGLE_IP
13888 +#endif
13889 +               | NXF_HIDE_NETIF;
13890 +}
13891 +
13892 +
13893 +/* network caps */
13894 +
13895 +#define NXC_TUN_CREATE         0x00000001
13896 +
13897 +#define NXC_RAW_ICMP           0x00000100
13898 +
13899 +
13900 +/* address types */
13901 +
13902 +#define NXA_TYPE_IPV4          0x0001
13903 +#define NXA_TYPE_IPV6          0x0002
13904 +
13905 +#define NXA_TYPE_NONE          0x0000
13906 +#define NXA_TYPE_ANY           0x00FF
13907 +
13908 +#define NXA_TYPE_ADDR          0x0010
13909 +#define NXA_TYPE_MASK          0x0020
13910 +#define NXA_TYPE_RANGE         0x0040
13911 +
13912 +#define NXA_MASK_ALL           (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13913 +
13914 +#define NXA_MOD_BCAST          0x0100
13915 +#define NXA_MOD_LBACK          0x0200
13916 +
13917 +#define NXA_LOOPBACK           0x1000
13918 +
13919 +#define NXA_MASK_BIND          (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13920 +#define NXA_MASK_SHOW          (NXA_MASK_ALL | NXA_LOOPBACK)
13921 +
13922 +#ifdef __KERNEL__
13923 +
13924 +#include <linux/list.h>
13925 +#include <linux/spinlock.h>
13926 +#include <linux/rcupdate.h>
13927 +#include <linux/in.h>
13928 +#include <linux/in6.h>
13929 +#include <asm/atomic.h>
13930 +
13931 +struct nx_addr_v4 {
13932 +       struct nx_addr_v4 *next;
13933 +       struct in_addr ip[2];
13934 +       struct in_addr mask;
13935 +       uint16_t type;
13936 +       uint16_t flags;
13937 +};
13938 +
13939 +struct nx_addr_v6 {
13940 +       struct nx_addr_v6 *next;
13941 +       struct in6_addr ip;
13942 +       struct in6_addr mask;
13943 +       uint32_t prefix;
13944 +       uint16_t type;
13945 +       uint16_t flags;
13946 +};
13947 +
13948 +struct nx_info {
13949 +       struct hlist_node nx_hlist;     /* linked list of nxinfos */
13950 +       nid_t nx_id;                    /* vnet id */
13951 +       atomic_t nx_usecnt;             /* usage count */
13952 +       atomic_t nx_tasks;              /* tasks count */
13953 +       int nx_state;                   /* context state */
13954 +
13955 +       uint64_t nx_flags;              /* network flag word */
13956 +       uint64_t nx_ncaps;              /* network capabilities */
13957 +
13958 +       struct in_addr v4_lback;        /* Loopback address */
13959 +       struct in_addr v4_bcast;        /* Broadcast address */
13960 +       struct nx_addr_v4 v4;           /* First/Single ipv4 address */
13961 +#ifdef CONFIG_IPV6
13962 +       struct nx_addr_v6 v6;           /* First/Single ipv6 address */
13963 +#endif
13964 +       char nx_name[65];               /* network context name */
13965 +};
13966 +
13967 +
13968 +/* status flags */
13969 +
13970 +#define NXS_HASHED      0x0001
13971 +#define NXS_SHUTDOWN    0x0100
13972 +#define NXS_RELEASED    0x8000
13973 +
13974 +extern struct nx_info *lookup_nx_info(int);
13975 +
13976 +extern int get_nid_list(int, unsigned int *, int);
13977 +extern int nid_is_hashed(nid_t);
13978 +
13979 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13980 +
13981 +extern long vs_net_change(struct nx_info *, unsigned int);
13982 +
13983 +struct sock;
13984 +
13985 +
13986 +#define NX_IPV4(n)     ((n)->v4.type != NXA_TYPE_NONE)
13987 +#ifdef  CONFIG_IPV6
13988 +#define NX_IPV6(n)     ((n)->v6.type != NXA_TYPE_NONE)
13989 +#else
13990 +#define NX_IPV6(n)     (0)
13991 +#endif
13992 +
13993 +#endif /* __KERNEL__ */
13994 +#endif /* _VX_NETWORK_H */
13995 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/percpu.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/percpu.h
13996 --- linux-2.6.35.2/include/linux/vserver/percpu.h       1970-01-01 01:00:00.000000000 +0100
13997 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/percpu.h 2010-08-02 17:05:06.000000000 +0200
13998 @@ -0,0 +1,14 @@
13999 +#ifndef _VX_PERCPU_H
14000 +#define _VX_PERCPU_H
14001 +
14002 +#include "cvirt_def.h"
14003 +#include "sched_def.h"
14004 +
14005 +struct _vx_percpu {
14006 +       struct _vx_cvirt_pc cvirt;
14007 +       struct _vx_sched_pc sched;
14008 +};
14009 +
14010 +#define        PERCPU_PERCTX   (sizeof(struct _vx_percpu))
14011 +
14012 +#endif /* _VX_PERCPU_H */
14013 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/pid.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/pid.h
14014 --- linux-2.6.35.2/include/linux/vserver/pid.h  1970-01-01 01:00:00.000000000 +0100
14015 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/pid.h    2010-08-02 17:05:06.000000000 +0200
14016 @@ -0,0 +1,51 @@
14017 +#ifndef _VSERVER_PID_H
14018 +#define _VSERVER_PID_H
14019 +
14020 +/* pid faking stuff */
14021 +
14022 +#define vx_info_map_pid(v, p) \
14023 +       __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
14024 +#define vx_info_map_tgid(v,p)  vx_info_map_pid(v,p)
14025 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
14026 +#define vx_map_tgid(p) vx_map_pid(p)
14027 +
14028 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
14029 +       const char *func, const char *file, int line)
14030 +{
14031 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14032 +               vxfprintk(VXD_CBIT(cvirt, 2),
14033 +                       "vx_map_tgid: %p/%llx: %d -> %d",
14034 +                       vxi, (long long)vxi->vx_flags, pid,
14035 +                       (pid && pid == vxi->vx_initpid) ? 1 : pid,
14036 +                       func, file, line);
14037 +               if (pid == 0)
14038 +                       return 0;
14039 +               if (pid == vxi->vx_initpid)
14040 +                       return 1;
14041 +       }
14042 +       return pid;
14043 +}
14044 +
14045 +#define vx_info_rmap_pid(v, p) \
14046 +       __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
14047 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
14048 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
14049 +
14050 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
14051 +       const char *func, const char *file, int line)
14052 +{
14053 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14054 +               vxfprintk(VXD_CBIT(cvirt, 2),
14055 +                       "vx_rmap_tgid: %p/%llx: %d -> %d",
14056 +                       vxi, (long long)vxi->vx_flags, pid,
14057 +                       (pid == 1) ? vxi->vx_initpid : pid,
14058 +                       func, file, line);
14059 +               if ((pid == 1) && vxi->vx_initpid)
14060 +                       return vxi->vx_initpid;
14061 +               if (pid == vxi->vx_initpid)
14062 +                       return ~0U;
14063 +       }
14064 +       return pid;
14065 +}
14066 +
14067 +#endif
14068 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/sched_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/sched_cmd.h
14069 --- linux-2.6.35.2/include/linux/vserver/sched_cmd.h    1970-01-01 01:00:00.000000000 +0100
14070 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/sched_cmd.h      2010-08-02 17:05:06.000000000 +0200
14071 @@ -0,0 +1,108 @@
14072 +#ifndef _VX_SCHED_CMD_H
14073 +#define _VX_SCHED_CMD_H
14074 +
14075 +
14076 +/*  sched vserver commands */
14077 +
14078 +#define VCMD_set_sched_v2      VC_CMD(SCHED, 1, 2)
14079 +#define VCMD_set_sched_v3      VC_CMD(SCHED, 1, 3)
14080 +#define VCMD_set_sched_v4      VC_CMD(SCHED, 1, 4)
14081 +
14082 +struct vcmd_set_sched_v2 {
14083 +       int32_t fill_rate;
14084 +       int32_t interval;
14085 +       int32_t tokens;
14086 +       int32_t tokens_min;
14087 +       int32_t tokens_max;
14088 +       uint64_t cpu_mask;
14089 +};
14090 +
14091 +struct vcmd_set_sched_v3 {
14092 +       uint32_t set_mask;
14093 +       int32_t fill_rate;
14094 +       int32_t interval;
14095 +       int32_t tokens;
14096 +       int32_t tokens_min;
14097 +       int32_t tokens_max;
14098 +       int32_t priority_bias;
14099 +};
14100 +
14101 +struct vcmd_set_sched_v4 {
14102 +       uint32_t set_mask;
14103 +       int32_t fill_rate;
14104 +       int32_t interval;
14105 +       int32_t tokens;
14106 +       int32_t tokens_min;
14107 +       int32_t tokens_max;
14108 +       int32_t prio_bias;
14109 +       int32_t cpu_id;
14110 +       int32_t bucket_id;
14111 +};
14112 +
14113 +#define VCMD_set_sched         VC_CMD(SCHED, 1, 5)
14114 +#define VCMD_get_sched         VC_CMD(SCHED, 2, 5)
14115 +
14116 +struct vcmd_sched_v5 {
14117 +       uint32_t mask;
14118 +       int32_t cpu_id;
14119 +       int32_t bucket_id;
14120 +       int32_t fill_rate[2];
14121 +       int32_t interval[2];
14122 +       int32_t tokens;
14123 +       int32_t tokens_min;
14124 +       int32_t tokens_max;
14125 +       int32_t prio_bias;
14126 +};
14127 +
14128 +#define VXSM_FILL_RATE         0x0001
14129 +#define VXSM_INTERVAL          0x0002
14130 +#define VXSM_FILL_RATE2                0x0004
14131 +#define VXSM_INTERVAL2         0x0008
14132 +#define VXSM_TOKENS            0x0010
14133 +#define VXSM_TOKENS_MIN                0x0020
14134 +#define VXSM_TOKENS_MAX                0x0040
14135 +#define VXSM_PRIO_BIAS         0x0100
14136 +
14137 +#define VXSM_IDLE_TIME         0x0200
14138 +#define VXSM_FORCE             0x0400
14139 +
14140 +#define        VXSM_V3_MASK            0x0173
14141 +#define        VXSM_SET_MASK           0x01FF
14142 +
14143 +#define VXSM_CPU_ID            0x1000
14144 +#define VXSM_BUCKET_ID         0x2000
14145 +
14146 +#define VXSM_MSEC              0x4000
14147 +
14148 +#define SCHED_KEEP             (-2)    /* only for v2 */
14149 +
14150 +#ifdef __KERNEL__
14151 +
14152 +#include <linux/compiler.h>
14153 +
14154 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
14155 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
14156 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
14157 +extern int vc_set_sched(struct vx_info *, void __user *);
14158 +extern int vc_get_sched(struct vx_info *, void __user *);
14159 +
14160 +#endif /* __KERNEL__ */
14161 +
14162 +#define VCMD_sched_info                VC_CMD(SCHED, 3, 0)
14163 +
14164 +struct vcmd_sched_info {
14165 +       int32_t cpu_id;
14166 +       int32_t bucket_id;
14167 +       uint64_t user_msec;
14168 +       uint64_t sys_msec;
14169 +       uint64_t hold_msec;
14170 +       uint32_t token_usec;
14171 +       int32_t vavavoom;
14172 +};
14173 +
14174 +#ifdef __KERNEL__
14175 +
14176 +extern int vc_sched_info(struct vx_info *, void __user *);
14177 +
14178 +#endif /* __KERNEL__ */
14179 +#endif /* _VX_SCHED_CMD_H */
14180 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/sched_def.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/sched_def.h
14181 --- linux-2.6.35.2/include/linux/vserver/sched_def.h    1970-01-01 01:00:00.000000000 +0100
14182 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/sched_def.h      2010-08-02 17:05:06.000000000 +0200
14183 @@ -0,0 +1,68 @@
14184 +#ifndef _VX_SCHED_DEF_H
14185 +#define _VX_SCHED_DEF_H
14186 +
14187 +#include <linux/spinlock.h>
14188 +#include <linux/jiffies.h>
14189 +#include <linux/cpumask.h>
14190 +#include <asm/atomic.h>
14191 +#include <asm/param.h>
14192 +
14193 +
14194 +/* context sub struct */
14195 +
14196 +struct _vx_sched {
14197 +       spinlock_t tokens_lock;         /* lock for token bucket */
14198 +
14199 +       int tokens;                     /* number of CPU tokens */
14200 +       int fill_rate[2];               /* Fill rate: add X tokens... */
14201 +       int interval[2];                /* Divisor:   per Y jiffies   */
14202 +       int tokens_min;                 /* Limit:     minimum for unhold */
14203 +       int tokens_max;                 /* Limit:     no more than N tokens */
14204 +
14205 +       int prio_bias;                  /* bias offset for priority */
14206 +
14207 +       unsigned update_mask;           /* which features should be updated */
14208 +       cpumask_t update;               /* CPUs which should update */
14209 +};
14210 +
14211 +struct _vx_sched_pc {
14212 +       int tokens;                     /* number of CPU tokens */
14213 +       int flags;                      /* bucket flags */
14214 +
14215 +       int fill_rate[2];               /* Fill rate: add X tokens... */
14216 +       int interval[2];                /* Divisor:   per Y jiffies   */
14217 +       int tokens_min;                 /* Limit:     minimum for unhold */
14218 +       int tokens_max;                 /* Limit:     no more than N tokens */
14219 +
14220 +       int prio_bias;                  /* bias offset for priority */
14221 +       int vavavoom;                   /* last calculated vavavoom */
14222 +
14223 +       unsigned long norm_time;        /* last time accounted */
14224 +       unsigned long idle_time;        /* non linear time for fair sched */
14225 +       unsigned long token_time;       /* token time for accounting */
14226 +       unsigned long onhold;           /* jiffies when put on hold */
14227 +
14228 +       uint64_t user_ticks;            /* token tick events */
14229 +       uint64_t sys_ticks;             /* token tick events */
14230 +       uint64_t hold_ticks;            /* token ticks paused */
14231 +};
14232 +
14233 +
14234 +#define VXSF_ONHOLD    0x0001
14235 +#define VXSF_IDLE_TIME 0x0100
14236 +
14237 +#ifdef CONFIG_VSERVER_DEBUG
14238 +
14239 +static inline void __dump_vx_sched(struct _vx_sched *sched)
14240 +{
14241 +       printk("\t_vx_sched:\n");
14242 +       printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
14243 +               sched->fill_rate[0], sched->interval[0],
14244 +               sched->fill_rate[1], sched->interval[1],
14245 +               sched->tokens_min, sched->tokens_max);
14246 +       printk("\t priority = %4d\n", sched->prio_bias);
14247 +}
14248 +
14249 +#endif
14250 +
14251 +#endif /* _VX_SCHED_DEF_H */
14252 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/sched.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/sched.h
14253 --- linux-2.6.35.2/include/linux/vserver/sched.h        1970-01-01 01:00:00.000000000 +0100
14254 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/sched.h  2010-08-02 17:05:06.000000000 +0200
14255 @@ -0,0 +1,26 @@
14256 +#ifndef _VX_SCHED_H
14257 +#define _VX_SCHED_H
14258 +
14259 +
14260 +#ifdef __KERNEL__
14261 +
14262 +struct timespec;
14263 +
14264 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14265 +
14266 +
14267 +struct vx_info;
14268 +
14269 +void vx_update_load(struct vx_info *);
14270 +
14271 +
14272 +int vx_tokens_recalc(struct _vx_sched_pc *,
14273 +       unsigned long *, unsigned long *, int [2]);
14274 +
14275 +void vx_update_sched_param(struct _vx_sched *sched,
14276 +       struct _vx_sched_pc *sched_pc);
14277 +
14278 +#endif /* __KERNEL__ */
14279 +#else  /* _VX_SCHED_H */
14280 +#warning duplicate inclusion
14281 +#endif /* _VX_SCHED_H */
14282 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/signal_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/signal_cmd.h
14283 --- linux-2.6.35.2/include/linux/vserver/signal_cmd.h   1970-01-01 01:00:00.000000000 +0100
14284 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/signal_cmd.h     2010-08-02 17:05:06.000000000 +0200
14285 @@ -0,0 +1,43 @@
14286 +#ifndef _VX_SIGNAL_CMD_H
14287 +#define _VX_SIGNAL_CMD_H
14288 +
14289 +
14290 +/*  signalling vserver commands */
14291 +
14292 +#define VCMD_ctx_kill          VC_CMD(PROCTRL, 1, 0)
14293 +#define VCMD_wait_exit         VC_CMD(EVENT, 99, 0)
14294 +
14295 +struct vcmd_ctx_kill_v0 {
14296 +       int32_t pid;
14297 +       int32_t sig;
14298 +};
14299 +
14300 +struct vcmd_wait_exit_v0 {
14301 +       int32_t reboot_cmd;
14302 +       int32_t exit_code;
14303 +};
14304 +
14305 +#ifdef __KERNEL__
14306 +
14307 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14308 +extern int vc_wait_exit(struct vx_info *, void __user *);
14309 +
14310 +#endif /* __KERNEL__ */
14311 +
14312 +/*  process alteration commands */
14313 +
14314 +#define VCMD_get_pflags                VC_CMD(PROCALT, 5, 0)
14315 +#define VCMD_set_pflags                VC_CMD(PROCALT, 6, 0)
14316 +
14317 +struct vcmd_pflags_v0 {
14318 +       uint32_t flagword;
14319 +       uint32_t mask;
14320 +};
14321 +
14322 +#ifdef __KERNEL__
14323 +
14324 +extern int vc_get_pflags(uint32_t pid, void __user *);
14325 +extern int vc_set_pflags(uint32_t pid, void __user *);
14326 +
14327 +#endif /* __KERNEL__ */
14328 +#endif /* _VX_SIGNAL_CMD_H */
14329 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/signal.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/signal.h
14330 --- linux-2.6.35.2/include/linux/vserver/signal.h       1970-01-01 01:00:00.000000000 +0100
14331 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/signal.h 2010-08-02 17:05:06.000000000 +0200
14332 @@ -0,0 +1,14 @@
14333 +#ifndef _VX_SIGNAL_H
14334 +#define _VX_SIGNAL_H
14335 +
14336 +
14337 +#ifdef __KERNEL__
14338 +
14339 +struct vx_info;
14340 +
14341 +int vx_info_kill(struct vx_info *, int, int);
14342 +
14343 +#endif /* __KERNEL__ */
14344 +#else  /* _VX_SIGNAL_H */
14345 +#warning duplicate inclusion
14346 +#endif /* _VX_SIGNAL_H */
14347 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/space_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/space_cmd.h
14348 --- linux-2.6.35.2/include/linux/vserver/space_cmd.h    1970-01-01 01:00:00.000000000 +0100
14349 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/space_cmd.h      2010-08-02 17:05:06.000000000 +0200
14350 @@ -0,0 +1,38 @@
14351 +#ifndef _VX_SPACE_CMD_H
14352 +#define _VX_SPACE_CMD_H
14353 +
14354 +
14355 +#define VCMD_enter_space_v0    VC_CMD(PROCALT, 1, 0)
14356 +#define VCMD_enter_space_v1    VC_CMD(PROCALT, 1, 1)
14357 +#define VCMD_enter_space       VC_CMD(PROCALT, 1, 2)
14358 +
14359 +#define VCMD_set_space_v0      VC_CMD(PROCALT, 3, 0)
14360 +#define VCMD_set_space_v1      VC_CMD(PROCALT, 3, 1)
14361 +#define VCMD_set_space         VC_CMD(PROCALT, 3, 2)
14362 +
14363 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14364 +
14365 +#define VCMD_get_space_mask    VC_CMD(VSPACE, 0, 1)
14366 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14367 +
14368 +
14369 +struct vcmd_space_mask_v1 {
14370 +       uint64_t mask;
14371 +};
14372 +
14373 +struct vcmd_space_mask_v2 {
14374 +       uint64_t mask;
14375 +       uint32_t index;
14376 +};
14377 +
14378 +
14379 +#ifdef __KERNEL__
14380 +
14381 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14382 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14383 +extern int vc_enter_space(struct vx_info *, void __user *);
14384 +extern int vc_set_space(struct vx_info *, void __user *);
14385 +extern int vc_get_space_mask(void __user *, int);
14386 +
14387 +#endif /* __KERNEL__ */
14388 +#endif /* _VX_SPACE_CMD_H */
14389 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/space.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/space.h
14390 --- linux-2.6.35.2/include/linux/vserver/space.h        1970-01-01 01:00:00.000000000 +0100
14391 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/space.h  2010-08-02 17:05:06.000000000 +0200
14392 @@ -0,0 +1,12 @@
14393 +#ifndef _VX_SPACE_H
14394 +#define _VX_SPACE_H
14395 +
14396 +#include <linux/types.h>
14397 +
14398 +struct vx_info;
14399 +
14400 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14401 +
14402 +#else  /* _VX_SPACE_H */
14403 +#warning duplicate inclusion
14404 +#endif /* _VX_SPACE_H */
14405 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/switch.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/switch.h
14406 --- linux-2.6.35.2/include/linux/vserver/switch.h       1970-01-01 01:00:00.000000000 +0100
14407 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/switch.h 2010-08-02 17:05:06.000000000 +0200
14408 @@ -0,0 +1,98 @@
14409 +#ifndef _VX_SWITCH_H
14410 +#define _VX_SWITCH_H
14411 +
14412 +#include <linux/types.h>
14413 +
14414 +
14415 +#define VC_CATEGORY(c)         (((c) >> 24) & 0x3F)
14416 +#define VC_COMMAND(c)          (((c) >> 16) & 0xFF)
14417 +#define VC_VERSION(c)          ((c) & 0xFFF)
14418 +
14419 +#define VC_CMD(c, i, v)                ((((VC_CAT_ ## c) & 0x3F) << 24) \
14420 +                               | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14421 +
14422 +/*
14423 +
14424 +  Syscall Matrix V2.8
14425 +
14426 +        |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14427 +        |STATS  |DESTROY|ALTER  |CHANGE |LIMIT  |TEST   | |       |       |
14428 +        |INFO   |SETUP  |       |MOVE   |       |       | |       |       |
14429 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14430 +  SYSTEM |VERSION|VSETUP |VHOST  |       |       |       | |DEVICE |       |
14431 +  HOST   |     00|     01|     02|     03|     04|     05| |     06|     07|
14432 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14433 +  CPU    |       |VPROC  |PROCALT|PROCMIG|PROCTRL|       | |SCHED. |       |
14434 +  PROCESS|     08|     09|     10|     11|     12|     13| |     14|     15|
14435 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14436 +  MEMORY |       |       |       |       |MEMCTRL|       | |SWAP   |       |
14437 +        |     16|     17|     18|     19|     20|     21| |     22|     23|
14438 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14439 +  NETWORK|       |VNET   |NETALT |NETMIG |NETCTL |       | |SERIAL |       |
14440 +        |     24|     25|     26|     27|     28|     29| |     30|     31|
14441 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14442 +  DISK   |       |       |       |TAGMIG |DLIMIT |       | |INODE  |       |
14443 +  VFS    |     32|     33|     34|     35|     36|     37| |     38|     39|
14444 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14445 +  OTHER  |VSTAT  |       |       |       |       |       | |VINFO  |       |
14446 +        |     40|     41|     42|     43|     44|     45| |     46|     47|
14447 +  =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14448 +  SPECIAL|EVENT  |       |       |       |FLAGS  |       | |VSPACE |       |
14449 +        |     48|     49|     50|     51|     52|     53| |     54|     55|
14450 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14451 +  SPECIAL|DEBUG  |       |       |       |RLIMIT |SYSCALL| |       |COMPAT |
14452 +        |     56|     57|     58|     59|     60|TEST 61| |     62|     63|
14453 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14454 +
14455 +*/
14456 +
14457 +#define VC_CAT_VERSION         0
14458 +
14459 +#define VC_CAT_VSETUP          1
14460 +#define VC_CAT_VHOST           2
14461 +
14462 +#define VC_CAT_DEVICE          6
14463 +
14464 +#define VC_CAT_VPROC           9
14465 +#define VC_CAT_PROCALT         10
14466 +#define VC_CAT_PROCMIG         11
14467 +#define VC_CAT_PROCTRL         12
14468 +
14469 +#define VC_CAT_SCHED           14
14470 +#define VC_CAT_MEMCTRL         20
14471 +
14472 +#define VC_CAT_VNET            25
14473 +#define VC_CAT_NETALT          26
14474 +#define VC_CAT_NETMIG          27
14475 +#define VC_CAT_NETCTRL         28
14476 +
14477 +#define VC_CAT_TAGMIG          35
14478 +#define VC_CAT_DLIMIT          36
14479 +#define VC_CAT_INODE           38
14480 +
14481 +#define VC_CAT_VSTAT           40
14482 +#define VC_CAT_VINFO           46
14483 +#define VC_CAT_EVENT           48
14484 +
14485 +#define VC_CAT_FLAGS           52
14486 +#define VC_CAT_VSPACE          54
14487 +#define VC_CAT_DEBUG           56
14488 +#define VC_CAT_RLIMIT          60
14489 +
14490 +#define VC_CAT_SYSTEST         61
14491 +#define VC_CAT_COMPAT          63
14492 +
14493 +/*  query version */
14494 +
14495 +#define VCMD_get_version       VC_CMD(VERSION, 0, 0)
14496 +#define VCMD_get_vci           VC_CMD(VERSION, 1, 0)
14497 +
14498 +
14499 +#ifdef __KERNEL__
14500 +
14501 +#include <linux/errno.h>
14502 +
14503 +#endif /* __KERNEL__ */
14504 +
14505 +#endif /* _VX_SWITCH_H */
14506 +
14507 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/tag_cmd.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/tag_cmd.h
14508 --- linux-2.6.35.2/include/linux/vserver/tag_cmd.h      1970-01-01 01:00:00.000000000 +0100
14509 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/tag_cmd.h        2010-08-02 17:05:06.000000000 +0200
14510 @@ -0,0 +1,22 @@
14511 +#ifndef _VX_TAG_CMD_H
14512 +#define _VX_TAG_CMD_H
14513 +
14514 +
14515 +/* vinfo commands */
14516 +
14517 +#define VCMD_task_tag          VC_CMD(VINFO, 3, 0)
14518 +
14519 +#ifdef __KERNEL__
14520 +extern int vc_task_tag(uint32_t);
14521 +
14522 +#endif /* __KERNEL__ */
14523 +
14524 +/* context commands */
14525 +
14526 +#define VCMD_tag_migrate       VC_CMD(TAGMIG, 1, 0)
14527 +
14528 +#ifdef __KERNEL__
14529 +extern int vc_tag_migrate(uint32_t);
14530 +
14531 +#endif /* __KERNEL__ */
14532 +#endif /* _VX_TAG_CMD_H */
14533 diff -NurpP --minimal linux-2.6.35.2/include/linux/vserver/tag.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/tag.h
14534 --- linux-2.6.35.2/include/linux/vserver/tag.h  1970-01-01 01:00:00.000000000 +0100
14535 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vserver/tag.h    2010-08-02 17:05:06.000000000 +0200
14536 @@ -0,0 +1,143 @@
14537 +#ifndef _DX_TAG_H
14538 +#define _DX_TAG_H
14539 +
14540 +#include <linux/types.h>
14541 +
14542 +
14543 +#define DX_TAG(in)     (IS_TAGGED(in))
14544 +
14545 +
14546 +#ifdef CONFIG_TAG_NFSD
14547 +#define DX_TAG_NFSD    1
14548 +#else
14549 +#define DX_TAG_NFSD    0
14550 +#endif
14551 +
14552 +
14553 +#ifdef CONFIG_TAGGING_NONE
14554 +
14555 +#define MAX_UID                0xFFFFFFFF
14556 +#define MAX_GID                0xFFFFFFFF
14557 +
14558 +#define INOTAG_TAG(cond, uid, gid, tag)        (0)
14559 +
14560 +#define TAGINO_UID(cond, uid, tag)     (uid)
14561 +#define TAGINO_GID(cond, gid, tag)     (gid)
14562 +
14563 +#endif
14564 +
14565 +
14566 +#ifdef CONFIG_TAGGING_GID16
14567 +
14568 +#define MAX_UID                0xFFFFFFFF
14569 +#define MAX_GID                0x0000FFFF
14570 +
14571 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14572 +       ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14573 +
14574 +#define TAGINO_UID(cond, uid, tag)     (uid)
14575 +#define TAGINO_GID(cond, gid, tag)     \
14576 +       ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14577 +
14578 +#endif
14579 +
14580 +
14581 +#ifdef CONFIG_TAGGING_ID24
14582 +
14583 +#define MAX_UID                0x00FFFFFF
14584 +#define MAX_GID                0x00FFFFFF
14585 +
14586 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14587 +       ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14588 +
14589 +#define TAGINO_UID(cond, uid, tag)     \
14590 +       ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14591 +#define TAGINO_GID(cond, gid, tag)     \
14592 +       ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14593 +
14594 +#endif
14595 +
14596 +
14597 +#ifdef CONFIG_TAGGING_UID16
14598 +
14599 +#define MAX_UID                0x0000FFFF
14600 +#define MAX_GID                0xFFFFFFFF
14601 +
14602 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14603 +       ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14604 +
14605 +#define TAGINO_UID(cond, uid, tag)     \
14606 +       ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14607 +#define TAGINO_GID(cond, gid, tag)     (gid)
14608 +
14609 +#endif
14610 +
14611 +
14612 +#ifdef CONFIG_TAGGING_INTERN
14613 +
14614 +#define MAX_UID                0xFFFFFFFF
14615 +#define MAX_GID                0xFFFFFFFF
14616 +
14617 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14618 +       ((cond) ? (tag) : 0)
14619 +
14620 +#define TAGINO_UID(cond, uid, tag)     (uid)
14621 +#define TAGINO_GID(cond, gid, tag)     (gid)
14622 +
14623 +#endif
14624 +
14625 +
14626 +#ifndef CONFIG_TAGGING_NONE
14627 +#define dx_current_fstag(sb)   \
14628 +       ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14629 +#else
14630 +#define dx_current_fstag(sb)   (0)
14631 +#endif
14632 +
14633 +#ifndef CONFIG_TAGGING_INTERN
14634 +#define TAGINO_TAG(cond, tag)  (0)
14635 +#else
14636 +#define TAGINO_TAG(cond, tag)  ((cond) ? (tag) : 0)
14637 +#endif
14638 +
14639 +#define INOTAG_UID(cond, uid, gid)     \
14640 +       ((cond) ? ((uid) & MAX_UID) : (uid))
14641 +#define INOTAG_GID(cond, uid, gid)     \
14642 +       ((cond) ? ((gid) & MAX_GID) : (gid))
14643 +
14644 +
14645 +static inline uid_t dx_map_uid(uid_t uid)
14646 +{
14647 +       if ((uid > MAX_UID) && (uid != -1))
14648 +               uid = -2;
14649 +       return (uid & MAX_UID);
14650 +}
14651 +
14652 +static inline gid_t dx_map_gid(gid_t gid)
14653 +{
14654 +       if ((gid > MAX_GID) && (gid != -1))
14655 +               gid = -2;
14656 +       return (gid & MAX_GID);
14657 +}
14658 +
14659 +struct peer_tag {
14660 +       int32_t xid;
14661 +       int32_t nid;
14662 +};
14663 +
14664 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14665 +
14666 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14667 +                unsigned long *flags);
14668 +
14669 +#ifdef CONFIG_PROPAGATE
14670 +
14671 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14672 +
14673 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14674 +
14675 +#else
14676 +#define dx_propagate_tag(n, i) do { } while (0)
14677 +#endif
14678 +
14679 +#endif /* _DX_TAG_H */
14680 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_inet6.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_inet6.h
14681 --- linux-2.6.35.2/include/linux/vs_inet6.h     1970-01-01 01:00:00.000000000 +0100
14682 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_inet6.h       2010-08-02 17:05:06.000000000 +0200
14683 @@ -0,0 +1,246 @@
14684 +#ifndef _VS_INET6_H
14685 +#define _VS_INET6_H
14686 +
14687 +#include "vserver/base.h"
14688 +#include "vserver/network.h"
14689 +#include "vserver/debug.h"
14690 +
14691 +#include <net/ipv6.h>
14692 +
14693 +#define NXAV6(a)       &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
14694 +#define NXAV6_FMT      "[%pI6/%pI6/%d:%04x]"
14695 +
14696 +
14697 +#ifdef CONFIG_IPV6
14698 +
14699 +static inline
14700 +int v6_addr_match(struct nx_addr_v6 *nxa,
14701 +       const struct in6_addr *addr, uint16_t mask)
14702 +{
14703 +       int ret = 0;
14704 +
14705 +       switch (nxa->type & mask) {
14706 +       case NXA_TYPE_MASK:
14707 +               ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
14708 +               break;
14709 +       case NXA_TYPE_ADDR:
14710 +               ret = ipv6_addr_equal(&nxa->ip, addr);
14711 +               break;
14712 +       case NXA_TYPE_ANY:
14713 +               ret = 1;
14714 +               break;
14715 +       }
14716 +       vxdprintk(VXD_CBIT(net, 0),
14717 +               "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
14718 +               nxa, NXAV6(nxa), addr, mask, ret);
14719 +       return ret;
14720 +}
14721 +
14722 +static inline
14723 +int v6_addr_in_nx_info(struct nx_info *nxi,
14724 +       const struct in6_addr *addr, uint16_t mask)
14725 +{
14726 +       struct nx_addr_v6 *nxa;
14727 +       int ret = 1;
14728 +
14729 +       if (!nxi)
14730 +               goto out;
14731 +       for (nxa = &nxi->v6; nxa; nxa = nxa->next)
14732 +               if (v6_addr_match(nxa, addr, mask))
14733 +                       goto out;
14734 +       ret = 0;
14735 +out:
14736 +       vxdprintk(VXD_CBIT(net, 0),
14737 +               "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
14738 +               nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
14739 +       return ret;
14740 +}
14741 +
14742 +static inline
14743 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
14744 +{
14745 +       /* FIXME: needs full range checks */
14746 +       return v6_addr_match(nxa, &addr->ip, mask);
14747 +}
14748 +
14749 +static inline
14750 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
14751 +{
14752 +       struct nx_addr_v6 *ptr;
14753 +
14754 +       for (ptr = &nxi->v6; ptr; ptr = ptr->next)
14755 +               if (v6_nx_addr_match(ptr, nxa, mask))
14756 +                       return 1;
14757 +       return 0;
14758 +}
14759 +
14760 +
14761 +/*
14762 + *     Check if a given address matches for a socket
14763 + *
14764 + *     nxi:            the socket's nx_info if any
14765 + *     addr:           to be verified address
14766 + */
14767 +static inline
14768 +int v6_sock_addr_match (
14769 +       struct nx_info *nxi,
14770 +       struct inet_sock *inet,
14771 +       struct in6_addr *addr)
14772 +{
14773 +       struct sock *sk = &inet->sk;
14774 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
14775 +
14776 +       if (!ipv6_addr_any(addr) &&
14777 +               ipv6_addr_equal(saddr, addr))
14778 +               return 1;
14779 +       if (ipv6_addr_any(saddr))
14780 +               return v6_addr_in_nx_info(nxi, addr, -1);
14781 +       return 0;
14782 +}
14783 +
14784 +/*
14785 + *     check if address is covered by socket
14786 + *
14787 + *     sk:     the socket to check against
14788 + *     addr:   the address in question (must be != 0)
14789 + */
14790 +
14791 +static inline
14792 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
14793 +{
14794 +       struct nx_info *nxi = sk->sk_nx_info;
14795 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
14796 +
14797 +       vxdprintk(VXD_CBIT(net, 5),
14798 +               "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
14799 +               sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
14800 +               (sk->sk_socket?sk->sk_socket->flags:0));
14801 +
14802 +       if (!ipv6_addr_any(saddr)) {    /* direct address match */
14803 +               return v6_addr_match(nxa, saddr, -1);
14804 +       } else if (nxi) {               /* match against nx_info */
14805 +               return v6_nx_addr_in_nx_info(nxi, nxa, -1);
14806 +       } else {                        /* unrestricted any socket */
14807 +               return 1;
14808 +       }
14809 +}
14810 +
14811 +
14812 +/* inet related checks and helpers */
14813 +
14814 +
14815 +struct in_ifaddr;
14816 +struct net_device;
14817 +struct sock;
14818 +
14819 +
14820 +#include <linux/netdevice.h>
14821 +#include <linux/inetdevice.h>
14822 +#include <net/inet_timewait_sock.h>
14823 +
14824 +
14825 +int dev_in_nx_info(struct net_device *, struct nx_info *);
14826 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
14827 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
14828 +
14829 +
14830 +
14831 +static inline
14832 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
14833 +{
14834 +       if (!nxi)
14835 +               return 1;
14836 +       if (!ifa)
14837 +               return 0;
14838 +       return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
14839 +}
14840 +
14841 +static inline
14842 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
14843 +{
14844 +       vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
14845 +               nxi, nxi ? nxi->nx_id : 0, ifa,
14846 +               nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
14847 +
14848 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
14849 +               return 1;
14850 +       if (v6_ifa_in_nx_info(ifa, nxi))
14851 +               return 1;
14852 +       return 0;
14853 +}
14854 +
14855 +
14856 +struct nx_v6_sock_addr {
14857 +       struct in6_addr saddr;  /* Address used for validation */
14858 +       struct in6_addr baddr;  /* Address used for socket bind */
14859 +};
14860 +
14861 +static inline
14862 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
14863 +       struct nx_v6_sock_addr *nsa)
14864 +{
14865 +       // struct sock *sk = &inet->sk;
14866 +       // struct nx_info *nxi = sk->sk_nx_info;
14867 +       struct in6_addr saddr = addr->sin6_addr;
14868 +       struct in6_addr baddr = saddr;
14869 +
14870 +       nsa->saddr = saddr;
14871 +       nsa->baddr = baddr;
14872 +       return 0;
14873 +}
14874 +
14875 +static inline
14876 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
14877 +{
14878 +       // struct sock *sk = &inet->sk;
14879 +       // struct in6_addr *saddr = inet6_rcv_saddr(sk);
14880 +
14881 +       // *saddr = nsa->baddr;
14882 +       // inet->inet_saddr = nsa->baddr;
14883 +}
14884 +
14885 +static inline
14886 +int nx_info_has_v6(struct nx_info *nxi)
14887 +{
14888 +       if (!nxi)
14889 +               return 1;
14890 +       if (NX_IPV6(nxi))
14891 +               return 1;
14892 +       return 0;
14893 +}
14894 +
14895 +#else /* CONFIG_IPV6 */
14896 +
14897 +static inline
14898 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
14899 +{
14900 +       return 1;
14901 +}
14902 +
14903 +
14904 +static inline
14905 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
14906 +{
14907 +       return 1;
14908 +}
14909 +
14910 +static inline
14911 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
14912 +{
14913 +       return 1;
14914 +}
14915 +
14916 +static inline
14917 +int nx_info_has_v6(struct nx_info *nxi)
14918 +{
14919 +       return 0;
14920 +}
14921 +
14922 +#endif /* CONFIG_IPV6 */
14923 +
14924 +#define current_nx_info_has_v6() \
14925 +       nx_info_has_v6(current_nx_info())
14926 +
14927 +#else
14928 +#warning duplicate inclusion
14929 +#endif
14930 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_inet.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_inet.h
14931 --- linux-2.6.35.2/include/linux/vs_inet.h      1970-01-01 01:00:00.000000000 +0100
14932 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_inet.h        2010-08-02 17:05:06.000000000 +0200
14933 @@ -0,0 +1,342 @@
14934 +#ifndef _VS_INET_H
14935 +#define _VS_INET_H
14936 +
14937 +#include "vserver/base.h"
14938 +#include "vserver/network.h"
14939 +#include "vserver/debug.h"
14940 +
14941 +#define IPI_LOOPBACK   htonl(INADDR_LOOPBACK)
14942 +
14943 +#define NXAV4(a)       NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
14944 +                       NIPQUAD((a)->mask), (a)->type
14945 +#define NXAV4_FMT      "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
14946 +
14947 +
14948 +static inline
14949 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
14950 +{
14951 +       __be32 ip = nxa->ip[0].s_addr;
14952 +       __be32 mask = nxa->mask.s_addr;
14953 +       __be32 bcast = ip | ~mask;
14954 +       int ret = 0;
14955 +
14956 +       switch (nxa->type & tmask) {
14957 +       case NXA_TYPE_MASK:
14958 +               ret = (ip == (addr & mask));
14959 +               break;
14960 +       case NXA_TYPE_ADDR:
14961 +               ret = 3;
14962 +               if (addr == ip)
14963 +                       break;
14964 +               /* fall through to broadcast */
14965 +       case NXA_MOD_BCAST:
14966 +               ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
14967 +               break;
14968 +       case NXA_TYPE_RANGE:
14969 +               ret = ((nxa->ip[0].s_addr <= addr) &&
14970 +                       (nxa->ip[1].s_addr > addr));
14971 +               break;
14972 +       case NXA_TYPE_ANY:
14973 +               ret = 2;
14974 +               break;
14975 +       }
14976 +
14977 +       vxdprintk(VXD_CBIT(net, 0),
14978 +               "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
14979 +               nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
14980 +       return ret;
14981 +}
14982 +
14983 +static inline
14984 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
14985 +{
14986 +       struct nx_addr_v4 *nxa;
14987 +       int ret = 1;
14988 +
14989 +       if (!nxi)
14990 +               goto out;
14991 +
14992 +       ret = 2;
14993 +       /* allow 127.0.0.1 when remapping lback */
14994 +       if ((tmask & NXA_LOOPBACK) &&
14995 +               (addr == IPI_LOOPBACK) &&
14996 +               nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
14997 +               goto out;
14998 +       ret = 3;
14999 +       /* check for lback address */
15000 +       if ((tmask & NXA_MOD_LBACK) &&
15001 +               (nxi->v4_lback.s_addr == addr))
15002 +               goto out;
15003 +       ret = 4;
15004 +       /* check for broadcast address */
15005 +       if ((tmask & NXA_MOD_BCAST) &&
15006 +               (nxi->v4_bcast.s_addr == addr))
15007 +               goto out;
15008 +       ret = 5;
15009 +       /* check for v4 addresses */
15010 +       for (nxa = &nxi->v4; nxa; nxa = nxa->next)
15011 +               if (v4_addr_match(nxa, addr, tmask))
15012 +                       goto out;
15013 +       ret = 0;
15014 +out:
15015 +       vxdprintk(VXD_CBIT(net, 0),
15016 +               "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
15017 +               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
15018 +       return ret;
15019 +}
15020 +
15021 +static inline
15022 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
15023 +{
15024 +       /* FIXME: needs full range checks */
15025 +       return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
15026 +}
15027 +
15028 +static inline
15029 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
15030 +{
15031 +       struct nx_addr_v4 *ptr;
15032 +
15033 +       for (ptr = &nxi->v4; ptr; ptr = ptr->next)
15034 +               if (v4_nx_addr_match(ptr, nxa, mask))
15035 +                       return 1;
15036 +       return 0;
15037 +}
15038 +
15039 +#include <net/inet_sock.h>
15040 +
15041 +/*
15042 + *     Check if a given address matches for a socket
15043 + *
15044 + *     nxi:            the socket's nx_info if any
15045 + *     addr:           to be verified address
15046 + */
15047 +static inline
15048 +int v4_sock_addr_match (
15049 +       struct nx_info *nxi,
15050 +       struct inet_sock *inet,
15051 +       __be32 addr)
15052 +{
15053 +       __be32 saddr = inet->inet_rcv_saddr;
15054 +       __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
15055 +
15056 +       if (addr && (saddr == addr || bcast == addr))
15057 +               return 1;
15058 +       if (!saddr)
15059 +               return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
15060 +       return 0;
15061 +}
15062 +
15063 +
15064 +/* inet related checks and helpers */
15065 +
15066 +
15067 +struct in_ifaddr;
15068 +struct net_device;
15069 +struct sock;
15070 +
15071 +#ifdef CONFIG_INET
15072 +
15073 +#include <linux/netdevice.h>
15074 +#include <linux/inetdevice.h>
15075 +#include <net/inet_sock.h>
15076 +#include <net/inet_timewait_sock.h>
15077 +
15078 +
15079 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15080 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
15081 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
15082 +
15083 +
15084 +/*
15085 + *     check if address is covered by socket
15086 + *
15087 + *     sk:     the socket to check against
15088 + *     addr:   the address in question (must be != 0)
15089 + */
15090 +
15091 +static inline
15092 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
15093 +{
15094 +       struct nx_info *nxi = sk->sk_nx_info;
15095 +       __be32 saddr = inet_rcv_saddr(sk);
15096 +
15097 +       vxdprintk(VXD_CBIT(net, 5),
15098 +               "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
15099 +               sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
15100 +               (sk->sk_socket?sk->sk_socket->flags:0));
15101 +
15102 +       if (saddr) {            /* direct address match */
15103 +               return v4_addr_match(nxa, saddr, -1);
15104 +       } else if (nxi) {       /* match against nx_info */
15105 +               return v4_nx_addr_in_nx_info(nxi, nxa, -1);
15106 +       } else {                /* unrestricted any socket */
15107 +               return 1;
15108 +       }
15109 +}
15110 +
15111 +
15112 +
15113 +static inline
15114 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
15115 +{
15116 +       vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p Â»%s«) %d",
15117 +               nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
15118 +               nxi ? dev_in_nx_info(dev, nxi) : 0);
15119 +
15120 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15121 +               return 1;
15122 +       if (dev_in_nx_info(dev, nxi))
15123 +               return 1;
15124 +       return 0;
15125 +}
15126 +
15127 +
15128 +static inline
15129 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
15130 +{
15131 +       if (!nxi)
15132 +               return 1;
15133 +       if (!ifa)
15134 +               return 0;
15135 +       return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
15136 +}
15137 +
15138 +static inline
15139 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
15140 +{
15141 +       vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
15142 +               nxi, nxi ? nxi->nx_id : 0, ifa,
15143 +               nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
15144 +
15145 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15146 +               return 1;
15147 +       if (v4_ifa_in_nx_info(ifa, nxi))
15148 +               return 1;
15149 +       return 0;
15150 +}
15151 +
15152 +
15153 +struct nx_v4_sock_addr {
15154 +       __be32 saddr;   /* Address used for validation */
15155 +       __be32 baddr;   /* Address used for socket bind */
15156 +};
15157 +
15158 +static inline
15159 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
15160 +       struct nx_v4_sock_addr *nsa)
15161 +{
15162 +       struct sock *sk = &inet->sk;
15163 +       struct nx_info *nxi = sk->sk_nx_info;
15164 +       __be32 saddr = addr->sin_addr.s_addr;
15165 +       __be32 baddr = saddr;
15166 +
15167 +       vxdprintk(VXD_CBIT(net, 3),
15168 +               "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
15169 +               sk, sk->sk_nx_info, sk->sk_socket,
15170 +               (sk->sk_socket ? sk->sk_socket->flags : 0),
15171 +               NIPQUAD(saddr));
15172 +
15173 +       if (nxi) {
15174 +               if (saddr == INADDR_ANY) {
15175 +                       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
15176 +                               baddr = nxi->v4.ip[0].s_addr;
15177 +               } else if (saddr == IPI_LOOPBACK) {
15178 +                       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15179 +                               baddr = nxi->v4_lback.s_addr;
15180 +               } else {        /* normal address bind */
15181 +                       if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
15182 +                               return -EADDRNOTAVAIL;
15183 +               }
15184 +       }
15185 +
15186 +       vxdprintk(VXD_CBIT(net, 3),
15187 +               "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
15188 +               sk, NIPQUAD(saddr), NIPQUAD(baddr));
15189 +
15190 +       nsa->saddr = saddr;
15191 +       nsa->baddr = baddr;
15192 +       return 0;
15193 +}
15194 +
15195 +static inline
15196 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
15197 +{
15198 +       inet->inet_saddr = nsa->baddr;
15199 +       inet->inet_rcv_saddr = nsa->baddr;
15200 +}
15201 +
15202 +
15203 +/*
15204 + *      helper to simplify inet_lookup_listener
15205 + *
15206 + *      nxi:   the socket's nx_info if any
15207 + *      addr:  to be verified address
15208 + *      saddr: socket address
15209 + */
15210 +static inline int v4_inet_addr_match (
15211 +       struct nx_info *nxi,
15212 +       __be32 addr,
15213 +       __be32 saddr)
15214 +{
15215 +       if (addr && (saddr == addr))
15216 +               return 1;
15217 +       if (!saddr)
15218 +               return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
15219 +       return 0;
15220 +}
15221 +
15222 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
15223 +{
15224 +       if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
15225 +               (addr == nxi->v4_lback.s_addr))
15226 +               return IPI_LOOPBACK;
15227 +       return addr;
15228 +}
15229 +
15230 +static inline
15231 +int nx_info_has_v4(struct nx_info *nxi)
15232 +{
15233 +       if (!nxi)
15234 +               return 1;
15235 +       if (NX_IPV4(nxi))
15236 +               return 1;
15237 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15238 +               return 1;
15239 +       return 0;
15240 +}
15241 +
15242 +#else /* CONFIG_INET */
15243 +
15244 +static inline
15245 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
15246 +{
15247 +       return 1;
15248 +}
15249 +
15250 +static inline
15251 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
15252 +{
15253 +       return 1;
15254 +}
15255 +
15256 +static inline
15257 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
15258 +{
15259 +       return 1;
15260 +}
15261 +
15262 +static inline
15263 +int nx_info_has_v4(struct nx_info *nxi)
15264 +{
15265 +       return 0;
15266 +}
15267 +
15268 +#endif /* CONFIG_INET */
15269 +
15270 +#define current_nx_info_has_v4() \
15271 +       nx_info_has_v4(current_nx_info())
15272 +
15273 +#else
15274 +// #warning duplicate inclusion
15275 +#endif
15276 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_limit.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_limit.h
15277 --- linux-2.6.35.2/include/linux/vs_limit.h     1970-01-01 01:00:00.000000000 +0100
15278 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_limit.h       2010-08-02 17:05:06.000000000 +0200
15279 @@ -0,0 +1,140 @@
15280 +#ifndef _VS_LIMIT_H
15281 +#define _VS_LIMIT_H
15282 +
15283 +#include "vserver/limit.h"
15284 +#include "vserver/base.h"
15285 +#include "vserver/context.h"
15286 +#include "vserver/debug.h"
15287 +#include "vserver/context.h"
15288 +#include "vserver/limit_int.h"
15289 +
15290 +
15291 +#define vx_acc_cres(v, d, p, r) \
15292 +       __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
15293 +
15294 +#define vx_acc_cres_cond(x, d, p, r) \
15295 +       __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15296 +       r, d, p, __FILE__, __LINE__)
15297 +
15298 +
15299 +#define vx_add_cres(v, a, p, r) \
15300 +       __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
15301 +#define vx_sub_cres(v, a, p, r)                vx_add_cres(v, -(a), p, r)
15302 +
15303 +#define vx_add_cres_cond(x, a, p, r) \
15304 +       __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15305 +       r, a, p, __FILE__, __LINE__)
15306 +#define vx_sub_cres_cond(x, a, p, r)   vx_add_cres_cond(x, -(a), p, r)
15307 +
15308 +
15309 +/* process and file limits */
15310 +
15311 +#define vx_nproc_inc(p) \
15312 +       vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
15313 +
15314 +#define vx_nproc_dec(p) \
15315 +       vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
15316 +
15317 +#define vx_files_inc(f) \
15318 +       vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
15319 +
15320 +#define vx_files_dec(f) \
15321 +       vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
15322 +
15323 +#define vx_locks_inc(l) \
15324 +       vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
15325 +
15326 +#define vx_locks_dec(l) \
15327 +       vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
15328 +
15329 +#define vx_openfd_inc(f) \
15330 +       vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
15331 +
15332 +#define vx_openfd_dec(f) \
15333 +       vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
15334 +
15335 +
15336 +#define vx_cres_avail(v, n, r) \
15337 +       __vx_cres_avail(v, r, n, __FILE__, __LINE__)
15338 +
15339 +
15340 +#define vx_nproc_avail(n) \
15341 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
15342 +
15343 +#define vx_files_avail(n) \
15344 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
15345 +
15346 +#define vx_locks_avail(n) \
15347 +       vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
15348 +
15349 +#define vx_openfd_avail(n) \
15350 +       vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
15351 +
15352 +
15353 +/* dentry limits */
15354 +
15355 +#define vx_dentry_inc(d) do {                                          \
15356 +       if (atomic_read(&d->d_count) == 1)                              \
15357 +               vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY);    \
15358 +       } while (0)
15359 +
15360 +#define vx_dentry_dec(d) do {                                          \
15361 +       if (atomic_read(&d->d_count) == 0)                              \
15362 +               vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY);    \
15363 +       } while (0)
15364 +
15365 +#define vx_dentry_avail(n) \
15366 +       vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
15367 +
15368 +
15369 +/* socket limits */
15370 +
15371 +#define vx_sock_inc(s) \
15372 +       vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
15373 +
15374 +#define vx_sock_dec(s) \
15375 +       vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
15376 +
15377 +#define vx_sock_avail(n) \
15378 +       vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
15379 +
15380 +
15381 +/* ipc resource limits */
15382 +
15383 +#define vx_ipcmsg_add(v, u, a) \
15384 +       vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
15385 +
15386 +#define vx_ipcmsg_sub(v, u, a) \
15387 +       vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
15388 +
15389 +#define vx_ipcmsg_avail(v, a) \
15390 +       vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
15391 +
15392 +
15393 +#define vx_ipcshm_add(v, k, a) \
15394 +       vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15395 +
15396 +#define vx_ipcshm_sub(v, k, a) \
15397 +       vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15398 +
15399 +#define vx_ipcshm_avail(v, a) \
15400 +       vx_cres_avail(v, a, VLIMIT_SHMEM)
15401 +
15402 +
15403 +#define vx_semary_inc(a) \
15404 +       vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
15405 +
15406 +#define vx_semary_dec(a) \
15407 +       vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
15408 +
15409 +
15410 +#define vx_nsems_add(a,n) \
15411 +       vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15412 +
15413 +#define vx_nsems_sub(a,n) \
15414 +       vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15415 +
15416 +
15417 +#else
15418 +#warning duplicate inclusion
15419 +#endif
15420 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_memory.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_memory.h
15421 --- linux-2.6.35.2/include/linux/vs_memory.h    1970-01-01 01:00:00.000000000 +0100
15422 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_memory.h      2010-08-02 17:05:06.000000000 +0200
15423 @@ -0,0 +1,58 @@
15424 +#ifndef _VS_MEMORY_H
15425 +#define _VS_MEMORY_H
15426 +
15427 +#include "vserver/limit.h"
15428 +#include "vserver/base.h"
15429 +#include "vserver/context.h"
15430 +#include "vserver/debug.h"
15431 +#include "vserver/context.h"
15432 +#include "vserver/limit_int.h"
15433 +
15434 +enum {
15435 +       VXPT_UNKNOWN = 0,
15436 +       VXPT_ANON,
15437 +       VXPT_NONE,
15438 +       VXPT_FILE,
15439 +       VXPT_SWAP,
15440 +       VXPT_WRITE
15441 +};
15442 +
15443 +#if 0
15444 +#define        vx_page_fault(mm, vma, type, ret)
15445 +#else
15446 +
15447 +static inline
15448 +void __vx_page_fault(struct mm_struct *mm,
15449 +       struct vm_area_struct *vma, int type, int ret)
15450 +{
15451 +       struct vx_info *vxi = mm->mm_vx_info;
15452 +       int what;
15453 +/*
15454 +       static char *page_type[6] =
15455 +               { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
15456 +       static char *page_what[4] =
15457 +               { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
15458 +*/
15459 +
15460 +       if (!vxi)
15461 +               return;
15462 +
15463 +       what = (ret & 0x3);
15464 +
15465 +/*     printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
15466 +               type, what, ret, page_type[type], page_what[what]);
15467 +*/
15468 +       if (ret & VM_FAULT_WRITE)
15469 +               what |= 0x4;
15470 +       atomic_inc(&vxi->cacct.page[type][what]);
15471 +}
15472 +
15473 +#define        vx_page_fault(mm, vma, type, ret)       __vx_page_fault(mm, vma, type, ret)
15474 +#endif
15475 +
15476 +
15477 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
15478 +
15479 +#else
15480 +#warning duplicate inclusion
15481 +#endif
15482 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_network.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_network.h
15483 --- linux-2.6.35.2/include/linux/vs_network.h   1970-01-01 01:00:00.000000000 +0100
15484 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_network.h     2010-08-02 17:05:06.000000000 +0200
15485 @@ -0,0 +1,169 @@
15486 +#ifndef _NX_VS_NETWORK_H
15487 +#define _NX_VS_NETWORK_H
15488 +
15489 +#include "vserver/context.h"
15490 +#include "vserver/network.h"
15491 +#include "vserver/base.h"
15492 +#include "vserver/check.h"
15493 +#include "vserver/debug.h"
15494 +
15495 +#include <linux/sched.h>
15496 +
15497 +
15498 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
15499 +
15500 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
15501 +       const char *_file, int _line)
15502 +{
15503 +       if (!nxi)
15504 +               return NULL;
15505 +
15506 +       vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
15507 +               nxi, nxi ? nxi->nx_id : 0,
15508 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15509 +               _file, _line);
15510 +
15511 +       atomic_inc(&nxi->nx_usecnt);
15512 +       return nxi;
15513 +}
15514 +
15515 +
15516 +extern void free_nx_info(struct nx_info *);
15517 +
15518 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
15519 +
15520 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
15521 +{
15522 +       if (!nxi)
15523 +               return;
15524 +
15525 +       vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
15526 +               nxi, nxi ? nxi->nx_id : 0,
15527 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15528 +               _file, _line);
15529 +
15530 +       if (atomic_dec_and_test(&nxi->nx_usecnt))
15531 +               free_nx_info(nxi);
15532 +}
15533 +
15534 +
15535 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
15536 +
15537 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15538 +               const char *_file, int _line)
15539 +{
15540 +       if (nxi) {
15541 +               vxlprintk(VXD_CBIT(nid, 3),
15542 +                       "init_nx_info(%p[#%d.%d])",
15543 +                       nxi, nxi ? nxi->nx_id : 0,
15544 +                       nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15545 +                       _file, _line);
15546 +
15547 +               atomic_inc(&nxi->nx_usecnt);
15548 +       }
15549 +       *nxp = nxi;
15550 +}
15551 +
15552 +
15553 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
15554 +
15555 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15556 +       const char *_file, int _line)
15557 +{
15558 +       struct nx_info *nxo;
15559 +
15560 +       if (!nxi)
15561 +               return;
15562 +
15563 +       vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
15564 +               nxi, nxi ? nxi->nx_id : 0,
15565 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15566 +               _file, _line);
15567 +
15568 +       atomic_inc(&nxi->nx_usecnt);
15569 +       nxo = xchg(nxp, nxi);
15570 +       BUG_ON(nxo);
15571 +}
15572 +
15573 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
15574 +
15575 +static inline void __clr_nx_info(struct nx_info **nxp,
15576 +       const char *_file, int _line)
15577 +{
15578 +       struct nx_info *nxo;
15579 +
15580 +       nxo = xchg(nxp, NULL);
15581 +       if (!nxo)
15582 +               return;
15583 +
15584 +       vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
15585 +               nxo, nxo ? nxo->nx_id : 0,
15586 +               nxo ? atomic_read(&nxo->nx_usecnt) : 0,
15587 +               _file, _line);
15588 +
15589 +       if (atomic_dec_and_test(&nxo->nx_usecnt))
15590 +               free_nx_info(nxo);
15591 +}
15592 +
15593 +
15594 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
15595 +
15596 +static inline void __claim_nx_info(struct nx_info *nxi,
15597 +       struct task_struct *task, const char *_file, int _line)
15598 +{
15599 +       vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
15600 +               nxi, nxi ? nxi->nx_id : 0,
15601 +               nxi?atomic_read(&nxi->nx_usecnt):0,
15602 +               nxi?atomic_read(&nxi->nx_tasks):0,
15603 +               task, _file, _line);
15604 +
15605 +       atomic_inc(&nxi->nx_tasks);
15606 +}
15607 +
15608 +
15609 +extern void unhash_nx_info(struct nx_info *);
15610 +
15611 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
15612 +
15613 +static inline void __release_nx_info(struct nx_info *nxi,
15614 +       struct task_struct *task, const char *_file, int _line)
15615 +{
15616 +       vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
15617 +               nxi, nxi ? nxi->nx_id : 0,
15618 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15619 +               nxi ? atomic_read(&nxi->nx_tasks) : 0,
15620 +               task, _file, _line);
15621 +
15622 +       might_sleep();
15623 +
15624 +       if (atomic_dec_and_test(&nxi->nx_tasks))
15625 +               unhash_nx_info(nxi);
15626 +}
15627 +
15628 +
15629 +#define task_get_nx_info(i)    __task_get_nx_info(i, __FILE__, __LINE__)
15630 +
15631 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
15632 +       const char *_file, int _line)
15633 +{
15634 +       struct nx_info *nxi;
15635 +
15636 +       task_lock(p);
15637 +       vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
15638 +               p, _file, _line);
15639 +       nxi = __get_nx_info(p->nx_info, _file, _line);
15640 +       task_unlock(p);
15641 +       return nxi;
15642 +}
15643 +
15644 +
15645 +static inline void exit_nx_info(struct task_struct *p)
15646 +{
15647 +       if (p->nx_info)
15648 +               release_nx_info(p->nx_info, p);
15649 +}
15650 +
15651 +
15652 +#else
15653 +#warning duplicate inclusion
15654 +#endif
15655 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_pid.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_pid.h
15656 --- linux-2.6.35.2/include/linux/vs_pid.h       1970-01-01 01:00:00.000000000 +0100
15657 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_pid.h 2010-08-02 17:05:06.000000000 +0200
15658 @@ -0,0 +1,95 @@
15659 +#ifndef _VS_PID_H
15660 +#define _VS_PID_H
15661 +
15662 +#include "vserver/base.h"
15663 +#include "vserver/check.h"
15664 +#include "vserver/context.h"
15665 +#include "vserver/debug.h"
15666 +#include "vserver/pid.h"
15667 +#include <linux/pid_namespace.h>
15668 +
15669 +
15670 +#define VXF_FAKE_INIT  (VXF_INFO_INIT | VXF_STATE_INIT)
15671 +
15672 +static inline
15673 +int vx_proc_task_visible(struct task_struct *task)
15674 +{
15675 +       if ((task->pid == 1) &&
15676 +               !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
15677 +               /* show a blend through init */
15678 +               goto visible;
15679 +       if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
15680 +               goto visible;
15681 +       return 0;
15682 +visible:
15683 +       return 1;
15684 +}
15685 +
15686 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
15687 +
15688 +#if 0
15689 +
15690 +static inline
15691 +struct task_struct *vx_find_proc_task_by_pid(int pid)
15692 +{
15693 +       struct task_struct *task = find_task_by_real_pid(pid);
15694 +
15695 +       if (task && !vx_proc_task_visible(task)) {
15696 +               vxdprintk(VXD_CBIT(misc, 6),
15697 +                       "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
15698 +                       task, task->xid, task->pid,
15699 +                       current, current->xid, current->pid);
15700 +               task = NULL;
15701 +       }
15702 +       return task;
15703 +}
15704 +
15705 +#endif
15706 +
15707 +static inline
15708 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
15709 +{
15710 +       struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
15711 +
15712 +       if (task && !vx_proc_task_visible(task)) {
15713 +               vxdprintk(VXD_CBIT(misc, 6),
15714 +                       "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
15715 +                       task, task->xid, task->pid,
15716 +                       current, current->xid, current->pid);
15717 +               put_task_struct(task);
15718 +               task = NULL;
15719 +       }
15720 +       return task;
15721 +}
15722 +
15723 +#if 0
15724 +
15725 +static inline
15726 +struct task_struct *vx_child_reaper(struct task_struct *p)
15727 +{
15728 +       struct vx_info *vxi = p->vx_info;
15729 +       struct task_struct *reaper = child_reaper(p);
15730 +
15731 +       if (!vxi)
15732 +               goto out;
15733 +
15734 +       BUG_ON(!p->vx_info->vx_reaper);
15735 +
15736 +       /* child reaper for the guest reaper */
15737 +       if (vxi->vx_reaper == p)
15738 +               goto out;
15739 +
15740 +       reaper = vxi->vx_reaper;
15741 +out:
15742 +       vxdprintk(VXD_CBIT(xid, 7),
15743 +               "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
15744 +               p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
15745 +       return reaper;
15746 +}
15747 +
15748 +#endif
15749 +
15750 +
15751 +#else
15752 +#warning duplicate inclusion
15753 +#endif
15754 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_sched.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_sched.h
15755 --- linux-2.6.35.2/include/linux/vs_sched.h     1970-01-01 01:00:00.000000000 +0100
15756 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_sched.h       2010-08-02 17:05:06.000000000 +0200
15757 @@ -0,0 +1,110 @@
15758 +#ifndef _VS_SCHED_H
15759 +#define _VS_SCHED_H
15760 +
15761 +#include "vserver/base.h"
15762 +#include "vserver/context.h"
15763 +#include "vserver/sched.h"
15764 +
15765 +
15766 +#define VAVAVOOM_RATIO          50
15767 +
15768 +#define MAX_PRIO_BIAS           20
15769 +#define MIN_PRIO_BIAS          -20
15770 +
15771 +
15772 +#ifdef CONFIG_VSERVER_HARDCPU
15773 +
15774 +/*
15775 + * effective_prio - return the priority that is based on the static
15776 + * priority but is modified by bonuses/penalties.
15777 + *
15778 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
15779 + * into a -4 ... 0 ... +4 bonus/penalty range.
15780 + *
15781 + * Additionally, we scale another amount based on the number of
15782 + * CPU tokens currently held by the context, if the process is
15783 + * part of a context (and the appropriate SCHED flag is set).
15784 + * This ranges from -5 ... 0 ... +15, quadratically.
15785 + *
15786 + * So, the total bonus is -9 .. 0 .. +19
15787 + * We use ~50% of the full 0...39 priority range so that:
15788 + *
15789 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
15790 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
15791 + *    unless that context is far exceeding its CPU allocation.
15792 + *
15793 + * Both properties are important to certain workloads.
15794 + */
15795 +static inline
15796 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
15797 +{
15798 +       int vavavoom, max;
15799 +
15800 +       /* lots of tokens = lots of vavavoom
15801 +        *      no tokens = no vavavoom      */
15802 +       if ((vavavoom = sched_pc->tokens) >= 0) {
15803 +               max = sched_pc->tokens_max;
15804 +               vavavoom = max - vavavoom;
15805 +               max = max * max;
15806 +               vavavoom = max_prio * VAVAVOOM_RATIO / 100
15807 +                       * (vavavoom*vavavoom - (max >> 2)) / max;
15808 +               return vavavoom;
15809 +       }
15810 +       return 0;
15811 +}
15812 +
15813 +
15814 +static inline
15815 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
15816 +{
15817 +       struct vx_info *vxi = p->vx_info;
15818 +       struct _vx_sched_pc *sched_pc;
15819 +
15820 +       if (!vxi)
15821 +               return prio;
15822 +
15823 +       sched_pc = &vx_cpu(vxi, sched_pc);
15824 +       if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
15825 +               int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
15826 +
15827 +               sched_pc->vavavoom = vavavoom;
15828 +               prio += vavavoom;
15829 +       }
15830 +       prio += sched_pc->prio_bias;
15831 +       return prio;
15832 +}
15833 +
15834 +#else /* !CONFIG_VSERVER_HARDCPU */
15835 +
15836 +static inline
15837 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
15838 +{
15839 +       struct vx_info *vxi = p->vx_info;
15840 +
15841 +       if (vxi)
15842 +               prio += vx_cpu(vxi, sched_pc).prio_bias;
15843 +       return prio;
15844 +}
15845 +
15846 +#endif /* CONFIG_VSERVER_HARDCPU */
15847 +
15848 +
15849 +static inline void vx_account_user(struct vx_info *vxi,
15850 +       cputime_t cputime, int nice)
15851 +{
15852 +       if (!vxi)
15853 +               return;
15854 +       vx_cpu(vxi, sched_pc).user_ticks += cputime;
15855 +}
15856 +
15857 +static inline void vx_account_system(struct vx_info *vxi,
15858 +       cputime_t cputime, int idle)
15859 +{
15860 +       if (!vxi)
15861 +               return;
15862 +       vx_cpu(vxi, sched_pc).sys_ticks += cputime;
15863 +}
15864 +
15865 +#else
15866 +#warning duplicate inclusion
15867 +#endif
15868 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_socket.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_socket.h
15869 --- linux-2.6.35.2/include/linux/vs_socket.h    1970-01-01 01:00:00.000000000 +0100
15870 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_socket.h      2010-08-02 17:05:06.000000000 +0200
15871 @@ -0,0 +1,67 @@
15872 +#ifndef _VS_SOCKET_H
15873 +#define _VS_SOCKET_H
15874 +
15875 +#include "vserver/debug.h"
15876 +#include "vserver/base.h"
15877 +#include "vserver/cacct.h"
15878 +#include "vserver/context.h"
15879 +#include "vserver/tag.h"
15880 +
15881 +
15882 +/* socket accounting */
15883 +
15884 +#include <linux/socket.h>
15885 +
15886 +static inline int vx_sock_type(int family)
15887 +{
15888 +       switch (family) {
15889 +       case PF_UNSPEC:
15890 +               return VXA_SOCK_UNSPEC;
15891 +       case PF_UNIX:
15892 +               return VXA_SOCK_UNIX;
15893 +       case PF_INET:
15894 +               return VXA_SOCK_INET;
15895 +       case PF_INET6:
15896 +               return VXA_SOCK_INET6;
15897 +       case PF_PACKET:
15898 +               return VXA_SOCK_PACKET;
15899 +       default:
15900 +               return VXA_SOCK_OTHER;
15901 +       }
15902 +}
15903 +
15904 +#define vx_acc_sock(v, f, p, s) \
15905 +       __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
15906 +
15907 +static inline void __vx_acc_sock(struct vx_info *vxi,
15908 +       int family, int pos, int size, char *file, int line)
15909 +{
15910 +       if (vxi) {
15911 +               int type = vx_sock_type(family);
15912 +
15913 +               atomic_long_inc(&vxi->cacct.sock[type][pos].count);
15914 +               atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
15915 +       }
15916 +}
15917 +
15918 +#define vx_sock_recv(sk, s) \
15919 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
15920 +#define vx_sock_send(sk, s) \
15921 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
15922 +#define vx_sock_fail(sk, s) \
15923 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
15924 +
15925 +
15926 +#define sock_vx_init(s) do {           \
15927 +       (s)->sk_xid = 0;                \
15928 +       (s)->sk_vx_info = NULL;         \
15929 +       } while (0)
15930 +
15931 +#define sock_nx_init(s) do {           \
15932 +       (s)->sk_nid = 0;                \
15933 +       (s)->sk_nx_info = NULL;         \
15934 +       } while (0)
15935 +
15936 +#else
15937 +#warning duplicate inclusion
15938 +#endif
15939 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_tag.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_tag.h
15940 --- linux-2.6.35.2/include/linux/vs_tag.h       1970-01-01 01:00:00.000000000 +0100
15941 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_tag.h 2010-08-02 17:05:06.000000000 +0200
15942 @@ -0,0 +1,47 @@
15943 +#ifndef _VS_TAG_H
15944 +#define _VS_TAG_H
15945 +
15946 +#include <linux/vserver/tag.h>
15947 +
15948 +/* check conditions */
15949 +
15950 +#define DX_ADMIN       0x0001
15951 +#define DX_WATCH       0x0002
15952 +#define DX_HOSTID      0x0008
15953 +
15954 +#define DX_IDENT       0x0010
15955 +
15956 +#define DX_ARG_MASK    0x0010
15957 +
15958 +
15959 +#define dx_task_tag(t) ((t)->tag)
15960 +
15961 +#define dx_current_tag() dx_task_tag(current)
15962 +
15963 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
15964 +
15965 +#define dx_weak_check(c, m)    ((m) ? dx_check(c, m) : 1)
15966 +
15967 +
15968 +/*
15969 + * check current context for ADMIN/WATCH and
15970 + * optionally against supplied argument
15971 + */
15972 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
15973 +{
15974 +       if (mode & DX_ARG_MASK) {
15975 +               if ((mode & DX_IDENT) && (id == cid))
15976 +                       return 1;
15977 +       }
15978 +       return (((mode & DX_ADMIN) && (cid == 0)) ||
15979 +               ((mode & DX_WATCH) && (cid == 1)) ||
15980 +               ((mode & DX_HOSTID) && (id == 0)));
15981 +}
15982 +
15983 +struct inode;
15984 +int dx_permission(const struct inode *inode, int mask);
15985 +
15986 +
15987 +#else
15988 +#warning duplicate inclusion
15989 +#endif
15990 diff -NurpP --minimal linux-2.6.35.2/include/linux/vs_time.h linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_time.h
15991 --- linux-2.6.35.2/include/linux/vs_time.h      1970-01-01 01:00:00.000000000 +0100
15992 +++ linux-2.6.35.2-vs2.3.0.36.31/include/linux/vs_time.h        2010-08-02 17:05:06.000000000 +0200
15993 @@ -0,0 +1,19 @@
15994 +#ifndef _VS_TIME_H
15995 +#define _VS_TIME_H
15996 +
15997 +
15998 +/* time faking stuff */
15999 +
16000 +#ifdef CONFIG_VSERVER_VTIME
16001 +
16002 +extern void vx_gettimeofday(struct timeval *tv);
16003 +extern int vx_settimeofday(struct timespec *ts);
16004 +
16005 +#else
16006 +#define        vx_gettimeofday(t)      do_gettimeofday(t)
16007 +#define        vx_settimeofday(t)      do_settimeofday(t)
16008 +#endif
16009 +
16010 +#else
16011 +#warning duplicate inclusion
16012 +#endif
16013 diff -NurpP --minimal linux-2.6.35.2/include/net/addrconf.h linux-2.6.35.2-vs2.3.0.36.31/include/net/addrconf.h
16014 --- linux-2.6.35.2/include/net/addrconf.h       2010-07-07 18:31:56.000000000 +0200
16015 +++ linux-2.6.35.2-vs2.3.0.36.31/include/net/addrconf.h 2010-08-02 17:05:06.000000000 +0200
16016 @@ -84,7 +84,8 @@ extern int                    ipv6_dev_get_saddr(struct n
16017                                                struct net_device *dev,
16018                                                const struct in6_addr *daddr,
16019                                                unsigned int srcprefs,
16020 -                                              struct in6_addr *saddr);
16021 +                                              struct in6_addr *saddr,
16022 +                                              struct nx_info *nxi);
16023  extern int                     ipv6_get_lladdr(struct net_device *dev,
16024                                                 struct in6_addr *addr,
16025                                                 unsigned char banned_flags);
16026 diff -NurpP --minimal linux-2.6.35.2/include/net/af_unix.h linux-2.6.35.2-vs2.3.0.36.31/include/net/af_unix.h
16027 --- linux-2.6.35.2/include/net/af_unix.h        2010-08-02 16:52:56.000000000 +0200
16028 +++ linux-2.6.35.2-vs2.3.0.36.31/include/net/af_unix.h  2010-08-02 17:05:06.000000000 +0200
16029 @@ -4,6 +4,7 @@
16030  #include <linux/socket.h>
16031  #include <linux/un.h>
16032  #include <linux/mutex.h>
16033 +#include <linux/vs_base.h>
16034  #include <net/sock.h>
16035  
16036  extern void unix_inflight(struct file *fp);
16037 diff -NurpP --minimal linux-2.6.35.2/include/net/inet_timewait_sock.h linux-2.6.35.2-vs2.3.0.36.31/include/net/inet_timewait_sock.h
16038 --- linux-2.6.35.2/include/net/inet_timewait_sock.h     2010-08-02 16:52:56.000000000 +0200
16039 +++ linux-2.6.35.2-vs2.3.0.36.31/include/net/inet_timewait_sock.h       2010-08-02 17:05:06.000000000 +0200
16040 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
16041  #define tw_hash                        __tw_common.skc_hash
16042  #define tw_prot                        __tw_common.skc_prot
16043  #define tw_net                 __tw_common.skc_net
16044 +#define tw_xid                 __tw_common.skc_xid
16045 +#define tw_vx_info             __tw_common.skc_vx_info
16046 +#define tw_nid                 __tw_common.skc_nid
16047 +#define tw_nx_info             __tw_common.skc_nx_info
16048         int                     tw_timeout;
16049         volatile unsigned char  tw_substate;
16050         /* 3 bits hole, try to pack */
16051 diff -NurpP --minimal linux-2.6.35.2/include/net/route.h linux-2.6.35.2-vs2.3.0.36.31/include/net/route.h
16052 --- linux-2.6.35.2/include/net/route.h  2010-08-02 16:52:57.000000000 +0200
16053 +++ linux-2.6.35.2-vs2.3.0.36.31/include/net/route.h    2010-08-02 17:05:06.000000000 +0200
16054 @@ -147,6 +147,9 @@ static inline void ip_rt_put(struct rtab
16055                 dst_release(&rt->u.dst);
16056  }
16057  
16058 +#include <linux/vs_base.h>
16059 +#include <linux/vs_inet.h>
16060 +
16061  #define IPTOS_RT_MASK  (IPTOS_TOS_MASK & ~3)
16062  
16063  extern const __u8 ip_tos2prio[16];
16064 @@ -156,6 +159,9 @@ static inline char rt_tos2priority(u8 to
16065         return ip_tos2prio[IPTOS_TOS(tos)>>1];
16066  }
16067  
16068 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
16069 +       struct rtable **, struct flowi *);
16070 +
16071  static inline int ip_route_connect(struct rtable **rp, __be32 dst,
16072                                    __be32 src, u32 tos, int oif, u8 protocol,
16073                                    __be16 sport, __be16 dport, struct sock *sk,
16074 @@ -173,11 +179,24 @@ static inline int ip_route_connect(struc
16075  
16076         int err;
16077         struct net *net = sock_net(sk);
16078 +       struct nx_info *nx_info = current_nx_info();
16079  
16080         if (inet_sk(sk)->transparent)
16081                 fl.flags |= FLOWI_FLAG_ANYSRC;
16082  
16083 -       if (!dst || !src) {
16084 +       if (sk)
16085 +               nx_info = sk->sk_nx_info;
16086 +
16087 +       vxdprintk(VXD_CBIT(net, 4),
16088 +               "ip_route_connect(%p) %p,%p;%lx",
16089 +               sk, nx_info, sk->sk_socket,
16090 +               (sk->sk_socket?sk->sk_socket->flags:0));
16091 +
16092 +       err = ip_v4_find_src(net, nx_info, rp, &fl);
16093 +       if (err)
16094 +               return err;
16095 +
16096 +       if (!fl.fl4_dst || !fl.fl4_src) {
16097                 err = __ip_route_output_key(net, rp, &fl);
16098                 if (err)
16099                         return err;
16100 diff -NurpP --minimal linux-2.6.35.2/include/net/sock.h linux-2.6.35.2-vs2.3.0.36.31/include/net/sock.h
16101 --- linux-2.6.35.2/include/net/sock.h   2010-08-02 16:52:57.000000000 +0200
16102 +++ linux-2.6.35.2-vs2.3.0.36.31/include/net/sock.h     2010-08-02 17:05:06.000000000 +0200
16103 @@ -150,6 +150,10 @@ struct sock_common {
16104  #ifdef CONFIG_NET_NS
16105         struct net              *skc_net;
16106  #endif
16107 +       xid_t                   skc_xid;
16108 +       struct vx_info          *skc_vx_info;
16109 +       nid_t                   skc_nid;
16110 +       struct nx_info          *skc_nx_info;
16111  };
16112  
16113  /**
16114 @@ -239,6 +243,10 @@ struct sock {
16115  #define sk_bind_node           __sk_common.skc_bind_node
16116  #define sk_prot                        __sk_common.skc_prot
16117  #define sk_net                 __sk_common.skc_net
16118 +#define sk_xid                 __sk_common.skc_xid
16119 +#define sk_vx_info             __sk_common.skc_vx_info
16120 +#define sk_nid                 __sk_common.skc_nid
16121 +#define sk_nx_info             __sk_common.skc_nx_info
16122         kmemcheck_bitfield_begin(flags);
16123         unsigned int            sk_shutdown  : 2,
16124                                 sk_no_check  : 2,
16125 diff -NurpP --minimal linux-2.6.35.2/init/Kconfig linux-2.6.35.2-vs2.3.0.36.31/init/Kconfig
16126 --- linux-2.6.35.2/init/Kconfig 2010-08-02 16:52:57.000000000 +0200
16127 +++ linux-2.6.35.2-vs2.3.0.36.31/init/Kconfig   2010-08-02 17:05:06.000000000 +0200
16128 @@ -472,6 +472,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
16129  menuconfig CGROUPS
16130         boolean "Control Group support"
16131         depends on EVENTFD
16132 +       default y
16133         help
16134           This option adds support for grouping sets of processes together, for
16135           use with process control subsystems such as Cpusets, CFS, memory
16136 @@ -499,6 +500,7 @@ config CGROUP_DEBUG
16137  config CGROUP_NS
16138         bool "Namespace cgroup subsystem"
16139         depends on CGROUPS
16140 +       default n
16141         help
16142           Provides a simple namespace cgroup subsystem to
16143           provide hierarchical naming of sets of namespaces,
16144 diff -NurpP --minimal linux-2.6.35.2/init/main.c linux-2.6.35.2-vs2.3.0.36.31/init/main.c
16145 --- linux-2.6.35.2/init/main.c  2010-08-02 16:52:57.000000000 +0200
16146 +++ linux-2.6.35.2-vs2.3.0.36.31/init/main.c    2010-08-02 17:05:06.000000000 +0200
16147 @@ -71,6 +71,7 @@
16148  #include <linux/shmem_fs.h>
16149  #include <linux/slab.h>
16150  #include <trace/boot.h>
16151 +#include <linux/vserver/percpu.h>
16152  
16153  #include <asm/io.h>
16154  #include <asm/bugs.h>
16155 diff -NurpP --minimal linux-2.6.35.2/ipc/mqueue.c linux-2.6.35.2-vs2.3.0.36.31/ipc/mqueue.c
16156 --- linux-2.6.35.2/ipc/mqueue.c 2010-08-02 16:52:57.000000000 +0200
16157 +++ linux-2.6.35.2-vs2.3.0.36.31/ipc/mqueue.c   2010-08-02 17:05:06.000000000 +0200
16158 @@ -33,6 +33,8 @@
16159  #include <linux/pid.h>
16160  #include <linux/ipc_namespace.h>
16161  #include <linux/slab.h>
16162 +#include <linux/vs_context.h>
16163 +#include <linux/vs_limit.h>
16164  
16165  #include <net/sock.h>
16166  #include "util.h"
16167 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
16168         struct sigevent notify;
16169         struct pid* notify_owner;
16170         struct user_struct *user;       /* user who created, for accounting */
16171 +       struct vx_info *vxi;
16172         struct sock *notify_sock;
16173         struct sk_buff *notify_cookie;
16174  
16175 @@ -125,6 +128,7 @@ static struct inode *mqueue_get_inode(st
16176                 if (S_ISREG(mode)) {
16177                         struct mqueue_inode_info *info;
16178                         struct task_struct *p = current;
16179 +                       struct vx_info *vxi = p->vx_info;
16180                         unsigned long mq_bytes, mq_msg_tblsz;
16181  
16182                         inode->i_fop = &mqueue_file_operations;
16183 @@ -138,6 +142,7 @@ static struct inode *mqueue_get_inode(st
16184                         info->notify_owner = NULL;
16185                         info->qsize = 0;
16186                         info->user = NULL;      /* set when all is ok */
16187 +                       info->vxi = NULL;
16188                         memset(&info->attr, 0, sizeof(info->attr));
16189                         info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
16190                         info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
16191 @@ -156,16 +161,19 @@ static struct inode *mqueue_get_inode(st
16192                         spin_lock(&mq_lock);
16193                         if (u->mq_bytes + mq_bytes < u->mq_bytes ||
16194                             u->mq_bytes + mq_bytes >
16195 -                           task_rlimit(p, RLIMIT_MSGQUEUE)) {
16196 +                           task_rlimit(p, RLIMIT_MSGQUEUE) ||
16197 +                           !vx_ipcmsg_avail(vxi, mq_bytes)) {
16198                                 spin_unlock(&mq_lock);
16199                                 /* mqueue_delete_inode() releases info->messages */
16200                                 goto out_inode;
16201                         }
16202                         u->mq_bytes += mq_bytes;
16203 +                       vx_ipcmsg_add(vxi, u, mq_bytes);
16204                         spin_unlock(&mq_lock);
16205  
16206                         /* all is ok */
16207                         info->user = get_uid(u);
16208 +                       info->vxi = get_vx_info(vxi);
16209                 } else if (S_ISDIR(mode)) {
16210                         inc_nlink(inode);
16211                         /* Some things misbehave if size == 0 on a directory */
16212 @@ -268,8 +276,11 @@ static void mqueue_delete_inode(struct i
16213             + info->attr.mq_msgsize);
16214         user = info->user;
16215         if (user) {
16216 +               struct vx_info *vxi = info->vxi;
16217 +
16218                 spin_lock(&mq_lock);
16219                 user->mq_bytes -= mq_bytes;
16220 +               vx_ipcmsg_sub(vxi, user, mq_bytes);
16221                 /*
16222                  * get_ns_from_inode() ensures that the
16223                  * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
16224 @@ -279,6 +290,7 @@ static void mqueue_delete_inode(struct i
16225                 if (ipc_ns)
16226                         ipc_ns->mq_queues_count--;
16227                 spin_unlock(&mq_lock);
16228 +               put_vx_info(vxi);
16229                 free_uid(user);
16230         }
16231         if (ipc_ns)
16232 diff -NurpP --minimal linux-2.6.35.2/ipc/msg.c linux-2.6.35.2-vs2.3.0.36.31/ipc/msg.c
16233 --- linux-2.6.35.2/ipc/msg.c    2010-08-02 16:52:57.000000000 +0200
16234 +++ linux-2.6.35.2-vs2.3.0.36.31/ipc/msg.c      2010-08-02 17:05:06.000000000 +0200
16235 @@ -37,6 +37,7 @@
16236  #include <linux/rwsem.h>
16237  #include <linux/nsproxy.h>
16238  #include <linux/ipc_namespace.h>
16239 +#include <linux/vs_base.h>
16240  
16241  #include <asm/current.h>
16242  #include <asm/uaccess.h>
16243 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
16244  
16245         msq->q_perm.mode = msgflg & S_IRWXUGO;
16246         msq->q_perm.key = key;
16247 +       msq->q_perm.xid = vx_current_xid();
16248  
16249         msq->q_perm.security = NULL;
16250         retval = security_msg_queue_alloc(msq);
16251 diff -NurpP --minimal linux-2.6.35.2/ipc/namespace.c linux-2.6.35.2-vs2.3.0.36.31/ipc/namespace.c
16252 --- linux-2.6.35.2/ipc/namespace.c      2009-09-10 15:26:27.000000000 +0200
16253 +++ linux-2.6.35.2-vs2.3.0.36.31/ipc/namespace.c        2010-08-02 17:05:06.000000000 +0200
16254 @@ -11,6 +11,8 @@
16255  #include <linux/slab.h>
16256  #include <linux/fs.h>
16257  #include <linux/mount.h>
16258 +#include <linux/vs_base.h>
16259 +#include <linux/vserver/global.h>
16260  
16261  #include "util.h"
16262  
16263 diff -NurpP --minimal linux-2.6.35.2/ipc/sem.c linux-2.6.35.2-vs2.3.0.36.31/ipc/sem.c
16264 --- linux-2.6.35.2/ipc/sem.c    2010-08-02 16:52:57.000000000 +0200
16265 +++ linux-2.6.35.2-vs2.3.0.36.31/ipc/sem.c      2010-08-02 17:05:06.000000000 +0200
16266 @@ -86,6 +86,8 @@
16267  #include <linux/rwsem.h>
16268  #include <linux/nsproxy.h>
16269  #include <linux/ipc_namespace.h>
16270 +#include <linux/vs_base.h>
16271 +#include <linux/vs_limit.h>
16272  
16273  #include <asm/uaccess.h>
16274  #include "util.h"
16275 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
16276  
16277         sma->sem_perm.mode = (semflg & S_IRWXUGO);
16278         sma->sem_perm.key = key;
16279 +       sma->sem_perm.xid = vx_current_xid();
16280  
16281         sma->sem_perm.security = NULL;
16282         retval = security_sem_alloc(sma);
16283 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
16284                 return id;
16285         }
16286         ns->used_sems += nsems;
16287 +       /* FIXME: obsoleted? */
16288 +       vx_semary_inc(sma);
16289 +       vx_nsems_add(sma, nsems);
16290  
16291         sma->sem_base = (struct sem *) &sma[1];
16292  
16293 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
16294  
16295         wake_up_sem_queue_do(&tasks);
16296         ns->used_sems -= sma->sem_nsems;
16297 +       /* FIXME: obsoleted? */
16298 +       vx_nsems_sub(sma, sma->sem_nsems);
16299 +       vx_semary_dec(sma);
16300         security_sem_free(sma);
16301         ipc_rcu_putref(sma);
16302  }
16303 diff -NurpP --minimal linux-2.6.35.2/ipc/shm.c linux-2.6.35.2-vs2.3.0.36.31/ipc/shm.c
16304 --- linux-2.6.35.2/ipc/shm.c    2010-08-02 16:52:57.000000000 +0200
16305 +++ linux-2.6.35.2-vs2.3.0.36.31/ipc/shm.c      2010-08-02 17:05:06.000000000 +0200
16306 @@ -39,6 +39,8 @@
16307  #include <linux/nsproxy.h>
16308  #include <linux/mount.h>
16309  #include <linux/ipc_namespace.h>
16310 +#include <linux/vs_context.h>
16311 +#include <linux/vs_limit.h>
16312  
16313  #include <asm/uaccess.h>
16314  
16315 @@ -169,7 +171,12 @@ static void shm_open(struct vm_area_stru
16316   */
16317  static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
16318  {
16319 -       ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16320 +       struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
16321 +       int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16322 +
16323 +       vx_ipcshm_sub(vxi, shp, numpages);
16324 +       ns->shm_tot -= numpages;
16325 +
16326         shm_rmid(ns, shp);
16327         shm_unlock(shp);
16328         if (!is_file_hugepages(shp->shm_file))
16329 @@ -179,6 +186,7 @@ static void shm_destroy(struct ipc_names
16330                                                 shp->mlock_user);
16331         fput (shp->shm_file);
16332         security_shm_free(shp);
16333 +       put_vx_info(vxi);
16334         ipc_rcu_putref(shp);
16335  }
16336  
16337 @@ -349,11 +357,15 @@ static int newseg(struct ipc_namespace *
16338         if (ns->shm_tot + numpages > ns->shm_ctlall)
16339                 return -ENOSPC;
16340  
16341 +       if (!vx_ipcshm_avail(current_vx_info(), numpages))
16342 +               return -ENOSPC;
16343 +
16344         shp = ipc_rcu_alloc(sizeof(*shp));
16345         if (!shp)
16346                 return -ENOMEM;
16347  
16348         shp->shm_perm.key = key;
16349 +       shp->shm_perm.xid = vx_current_xid();
16350         shp->shm_perm.mode = (shmflg & S_IRWXUGO);
16351         shp->mlock_user = NULL;
16352  
16353 @@ -407,6 +419,7 @@ static int newseg(struct ipc_namespace *
16354         ns->shm_tot += numpages;
16355         error = shp->shm_perm.id;
16356         shm_unlock(shp);
16357 +       vx_ipcshm_add(current_vx_info(), key, numpages);
16358         return error;
16359  
16360  no_id:
16361 diff -NurpP --minimal linux-2.6.35.2/kernel/capability.c linux-2.6.35.2-vs2.3.0.36.31/kernel/capability.c
16362 --- linux-2.6.35.2/kernel/capability.c  2010-08-02 16:52:57.000000000 +0200
16363 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/capability.c    2010-08-02 17:05:06.000000000 +0200
16364 @@ -14,6 +14,7 @@
16365  #include <linux/security.h>
16366  #include <linux/syscalls.h>
16367  #include <linux/pid_namespace.h>
16368 +#include <linux/vs_context.h>
16369  #include <asm/uaccess.h>
16370  
16371  /*
16372 @@ -119,6 +120,7 @@ static int cap_validate_magic(cap_user_h
16373         return 0;
16374  }
16375  
16376 +
16377  /*
16378   * The only thing that can change the capabilities of the current
16379   * process is the current process. As such, we can't be in this code
16380 @@ -289,6 +291,8 @@ error:
16381         return ret;
16382  }
16383  
16384 +#include <linux/vserver/base.h>
16385 +
16386  /**
16387   * capable - Determine if the current task has a superior capability in effect
16388   * @cap: The capability to be tested for
16389 @@ -301,6 +305,9 @@ error:
16390   */
16391  int capable(int cap)
16392  {
16393 +       /* here for now so we don't require task locking */
16394 +       if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
16395 +               return 0;
16396         if (unlikely(!cap_valid(cap))) {
16397                 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
16398                 BUG();
16399 diff -NurpP --minimal linux-2.6.35.2/kernel/compat.c linux-2.6.35.2-vs2.3.0.36.31/kernel/compat.c
16400 --- linux-2.6.35.2/kernel/compat.c      2010-08-02 16:52:57.000000000 +0200
16401 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/compat.c        2010-08-02 17:05:06.000000000 +0200
16402 @@ -900,7 +900,7 @@ asmlinkage long compat_sys_time(compat_t
16403         compat_time_t i;
16404         struct timeval tv;
16405  
16406 -       do_gettimeofday(&tv);
16407 +       vx_gettimeofday(&tv);
16408         i = tv.tv_sec;
16409  
16410         if (tloc) {
16411 @@ -925,7 +925,7 @@ asmlinkage long compat_sys_stime(compat_
16412         if (err)
16413                 return err;
16414  
16415 -       do_settimeofday(&tv);
16416 +       vx_settimeofday(&tv);
16417         return 0;
16418  }
16419  
16420 diff -NurpP --minimal linux-2.6.35.2/kernel/exit.c linux-2.6.35.2-vs2.3.0.36.31/kernel/exit.c
16421 --- linux-2.6.35.2/kernel/exit.c        2010-08-02 16:52:57.000000000 +0200
16422 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/exit.c  2010-08-02 17:05:06.000000000 +0200
16423 @@ -48,6 +48,10 @@
16424  #include <linux/fs_struct.h>
16425  #include <linux/init_task.h>
16426  #include <linux/perf_event.h>
16427 +#include <linux/vs_limit.h>
16428 +#include <linux/vs_context.h>
16429 +#include <linux/vs_network.h>
16430 +#include <linux/vs_pid.h>
16431  #include <trace/events/sched.h>
16432  #include <linux/hw_breakpoint.h>
16433  
16434 @@ -487,9 +491,11 @@ static void close_files(struct files_str
16435                                         filp_close(file, files);
16436                                         cond_resched();
16437                                 }
16438 +                               vx_openfd_dec(i);
16439                         }
16440                         i++;
16441                         set >>= 1;
16442 +                       cond_resched();
16443                 }
16444         }
16445  }
16446 @@ -1020,11 +1026,16 @@ NORET_TYPE void do_exit(long code)
16447  
16448         validate_creds_for_do_exit(tsk);
16449  
16450 +       /* needs to stay after exit_notify() */
16451 +       exit_vx_info(tsk, code);
16452 +       exit_nx_info(tsk);
16453 +
16454         preempt_disable();
16455         exit_rcu();
16456         /* causes final put_task_struct in finish_task_switch(). */
16457         tsk->state = TASK_DEAD;
16458         schedule();
16459 +       printk("bad task: %p [%lx]\n", current, current->state);
16460         BUG();
16461         /* Avoid "noreturn function does return".  */
16462         for (;;)
16463 diff -NurpP --minimal linux-2.6.35.2/kernel/fork.c linux-2.6.35.2-vs2.3.0.36.31/kernel/fork.c
16464 --- linux-2.6.35.2/kernel/fork.c        2010-08-02 16:52:57.000000000 +0200
16465 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/fork.c  2010-08-02 17:05:06.000000000 +0200
16466 @@ -65,6 +65,10 @@
16467  #include <linux/perf_event.h>
16468  #include <linux/posix-timers.h>
16469  #include <linux/user-return-notifier.h>
16470 +#include <linux/vs_context.h>
16471 +#include <linux/vs_network.h>
16472 +#include <linux/vs_limit.h>
16473 +#include <linux/vs_memory.h>
16474  
16475  #include <asm/pgtable.h>
16476  #include <asm/pgalloc.h>
16477 @@ -160,6 +164,8 @@ void free_task(struct task_struct *tsk)
16478         account_kernel_stack(tsk->stack, -1);
16479         free_thread_info(tsk->stack);
16480         rt_mutex_debug_task_free(tsk);
16481 +       clr_vx_info(&tsk->vx_info);
16482 +       clr_nx_info(&tsk->nx_info);
16483         ftrace_graph_exit_task(tsk);
16484         free_task_struct(tsk);
16485  }
16486 @@ -489,6 +495,7 @@ static struct mm_struct * mm_init(struct
16487         if (likely(!mm_alloc_pgd(mm))) {
16488                 mm->def_flags = 0;
16489                 mmu_notifier_mm_init(mm);
16490 +               set_vx_info(&mm->mm_vx_info, p->vx_info);
16491                 return mm;
16492         }
16493  
16494 @@ -522,6 +529,7 @@ void __mmdrop(struct mm_struct *mm)
16495         mm_free_pgd(mm);
16496         destroy_context(mm);
16497         mmu_notifier_mm_destroy(mm);
16498 +       clr_vx_info(&mm->mm_vx_info);
16499         free_mm(mm);
16500  }
16501  EXPORT_SYMBOL_GPL(__mmdrop);
16502 @@ -657,6 +665,7 @@ struct mm_struct *dup_mm(struct task_str
16503                 goto fail_nomem;
16504  
16505         memcpy(mm, oldmm, sizeof(*mm));
16506 +       mm->mm_vx_info = NULL;
16507  
16508         /* Initializing for Swap token stuff */
16509         mm->token_priority = 0;
16510 @@ -695,6 +704,7 @@ fail_nocontext:
16511          * If init_new_context() failed, we cannot use mmput() to free the mm
16512          * because it calls destroy_context()
16513          */
16514 +       clr_vx_info(&mm->mm_vx_info);
16515         mm_free_pgd(mm);
16516         free_mm(mm);
16517         return NULL;
16518 @@ -969,6 +979,8 @@ static struct task_struct *copy_process(
16519         int retval;
16520         struct task_struct *p;
16521         int cgroup_callbacks_done = 0;
16522 +       struct vx_info *vxi;
16523 +       struct nx_info *nxi;
16524  
16525         if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
16526                 return ERR_PTR(-EINVAL);
16527 @@ -1015,7 +1027,12 @@ static struct task_struct *copy_process(
16528         DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
16529         DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
16530  #endif
16531 +       init_vx_info(&p->vx_info, current_vx_info());
16532 +       init_nx_info(&p->nx_info, current_nx_info());
16533 +
16534         retval = -EAGAIN;
16535 +       if (!vx_nproc_avail(1))
16536 +               goto bad_fork_free;
16537         if (atomic_read(&p->real_cred->user->processes) >=
16538                         task_rlimit(p, RLIMIT_NPROC)) {
16539                 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
16540 @@ -1280,6 +1297,18 @@ static struct task_struct *copy_process(
16541  
16542         total_forks++;
16543         spin_unlock(&current->sighand->siglock);
16544 +
16545 +       /* p is copy of current */
16546 +       vxi = p->vx_info;
16547 +       if (vxi) {
16548 +               claim_vx_info(vxi, p);
16549 +               atomic_inc(&vxi->cvirt.nr_threads);
16550 +               atomic_inc(&vxi->cvirt.total_forks);
16551 +               vx_nproc_inc(p);
16552 +       }
16553 +       nxi = p->nx_info;
16554 +       if (nxi)
16555 +               claim_nx_info(nxi, p);
16556         write_unlock_irq(&tasklist_lock);
16557         proc_fork_connector(p);
16558         cgroup_post_fork(p);
16559 diff -NurpP --minimal linux-2.6.35.2/kernel/kthread.c linux-2.6.35.2-vs2.3.0.36.31/kernel/kthread.c
16560 --- linux-2.6.35.2/kernel/kthread.c     2010-07-07 18:31:57.000000000 +0200
16561 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/kthread.c       2010-08-02 17:05:06.000000000 +0200
16562 @@ -14,6 +14,7 @@
16563  #include <linux/file.h>
16564  #include <linux/module.h>
16565  #include <linux/mutex.h>
16566 +#include <linux/vs_pid.h>
16567  #include <trace/events/sched.h>
16568  
16569  static DEFINE_SPINLOCK(kthread_create_lock);
16570 diff -NurpP --minimal linux-2.6.35.2/kernel/Makefile linux-2.6.35.2-vs2.3.0.36.31/kernel/Makefile
16571 --- linux-2.6.35.2/kernel/Makefile      2010-08-02 16:52:57.000000000 +0200
16572 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/Makefile        2010-08-02 17:05:06.000000000 +0200
16573 @@ -25,6 +25,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
16574  CFLAGS_REMOVE_perf_event.o = -pg
16575  endif
16576  
16577 +obj-y += vserver/
16578  obj-$(CONFIG_FREEZER) += freezer.o
16579  obj-$(CONFIG_PROFILING) += profile.o
16580  obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
16581 diff -NurpP --minimal linux-2.6.35.2/kernel/nsproxy.c linux-2.6.35.2-vs2.3.0.36.31/kernel/nsproxy.c
16582 --- linux-2.6.35.2/kernel/nsproxy.c     2010-07-07 18:31:57.000000000 +0200
16583 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/nsproxy.c       2010-08-02 17:05:06.000000000 +0200
16584 @@ -20,6 +20,8 @@
16585  #include <linux/mnt_namespace.h>
16586  #include <linux/utsname.h>
16587  #include <linux/pid_namespace.h>
16588 +#include <linux/vserver/global.h>
16589 +#include <linux/vserver/debug.h>
16590  #include <net/net_namespace.h>
16591  #include <linux/ipc_namespace.h>
16592  
16593 @@ -43,8 +45,11 @@ static inline struct nsproxy *create_nsp
16594         struct nsproxy *nsproxy;
16595  
16596         nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
16597 -       if (nsproxy)
16598 +       if (nsproxy) {
16599                 atomic_set(&nsproxy->count, 1);
16600 +               atomic_inc(&vs_global_nsproxy);
16601 +       }
16602 +       vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
16603         return nsproxy;
16604  }
16605  
16606 @@ -53,41 +58,52 @@ static inline struct nsproxy *create_nsp
16607   * Return the newly created nsproxy.  Do not attach this to the task,
16608   * leave it to the caller to do proper locking and attach it to task.
16609   */
16610 -static struct nsproxy *create_new_namespaces(unsigned long flags,
16611 -                       struct task_struct *tsk, struct fs_struct *new_fs)
16612 +static struct nsproxy *unshare_namespaces(unsigned long flags,
16613 +                       struct nsproxy *orig, struct fs_struct *new_fs)
16614  {
16615         struct nsproxy *new_nsp;
16616         int err;
16617  
16618 +       vxdprintk(VXD_CBIT(space, 4),
16619 +               "unshare_namespaces(0x%08lx,%p,%p)",
16620 +               flags, orig, new_fs);
16621 +
16622         new_nsp = create_nsproxy();
16623         if (!new_nsp)
16624                 return ERR_PTR(-ENOMEM);
16625  
16626 -       new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
16627 +       new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
16628         if (IS_ERR(new_nsp->mnt_ns)) {
16629                 err = PTR_ERR(new_nsp->mnt_ns);
16630                 goto out_ns;
16631         }
16632  
16633 -       new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
16634 +       new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
16635         if (IS_ERR(new_nsp->uts_ns)) {
16636                 err = PTR_ERR(new_nsp->uts_ns);
16637                 goto out_uts;
16638         }
16639  
16640 -       new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
16641 +       new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
16642         if (IS_ERR(new_nsp->ipc_ns)) {
16643                 err = PTR_ERR(new_nsp->ipc_ns);
16644                 goto out_ipc;
16645         }
16646  
16647 -       new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
16648 +       new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
16649         if (IS_ERR(new_nsp->pid_ns)) {
16650                 err = PTR_ERR(new_nsp->pid_ns);
16651                 goto out_pid;
16652         }
16653  
16654 -       new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
16655 +       /* disabled now?
16656 +       new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
16657 +       if (IS_ERR(new_nsp->user_ns)) {
16658 +               err = PTR_ERR(new_nsp->user_ns);
16659 +               goto out_user;
16660 +       } */
16661 +
16662 +       new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
16663         if (IS_ERR(new_nsp->net_ns)) {
16664                 err = PTR_ERR(new_nsp->net_ns);
16665                 goto out_net;
16666 @@ -112,6 +128,38 @@ out_ns:
16667         return ERR_PTR(err);
16668  }
16669  
16670 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
16671 +                       struct fs_struct *new_fs)
16672 +{
16673 +       return unshare_namespaces(flags, tsk->nsproxy, new_fs);
16674 +}
16675 +
16676 +/*
16677 + * copies the nsproxy, setting refcount to 1, and grabbing a
16678 + * reference to all contained namespaces.
16679 + */
16680 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
16681 +{
16682 +       struct nsproxy *ns = create_nsproxy();
16683 +
16684 +       if (ns) {
16685 +               memcpy(ns, orig, sizeof(struct nsproxy));
16686 +               atomic_set(&ns->count, 1);
16687 +
16688 +               if (ns->mnt_ns)
16689 +                       get_mnt_ns(ns->mnt_ns);
16690 +               if (ns->uts_ns)
16691 +                       get_uts_ns(ns->uts_ns);
16692 +               if (ns->ipc_ns)
16693 +                       get_ipc_ns(ns->ipc_ns);
16694 +               if (ns->pid_ns)
16695 +                       get_pid_ns(ns->pid_ns);
16696 +               if (ns->net_ns)
16697 +                       get_net(ns->net_ns);
16698 +       }
16699 +       return ns;
16700 +}
16701 +
16702  /*
16703   * called from clone.  This now handles copy for nsproxy and all
16704   * namespaces therein.
16705 @@ -119,9 +167,12 @@ out_ns:
16706  int copy_namespaces(unsigned long flags, struct task_struct *tsk)
16707  {
16708         struct nsproxy *old_ns = tsk->nsproxy;
16709 -       struct nsproxy *new_ns;
16710 +       struct nsproxy *new_ns = NULL;
16711         int err = 0;
16712  
16713 +       vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
16714 +               flags, tsk, old_ns);
16715 +
16716         if (!old_ns)
16717                 return 0;
16718  
16719 @@ -131,7 +182,7 @@ int copy_namespaces(unsigned long flags,
16720                                 CLONE_NEWPID | CLONE_NEWNET)))
16721                 return 0;
16722  
16723 -       if (!capable(CAP_SYS_ADMIN)) {
16724 +       if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
16725                 err = -EPERM;
16726                 goto out;
16727         }
16728 @@ -158,6 +209,9 @@ int copy_namespaces(unsigned long flags,
16729  
16730  out:
16731         put_nsproxy(old_ns);
16732 +       vxdprintk(VXD_CBIT(space, 3),
16733 +               "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
16734 +               flags, tsk, old_ns, err, new_ns);
16735         return err;
16736  }
16737  
16738 @@ -171,7 +225,9 @@ void free_nsproxy(struct nsproxy *ns)
16739                 put_ipc_ns(ns->ipc_ns);
16740         if (ns->pid_ns)
16741                 put_pid_ns(ns->pid_ns);
16742 -       put_net(ns->net_ns);
16743 +       if (ns->net_ns)
16744 +               put_net(ns->net_ns);
16745 +       atomic_dec(&vs_global_nsproxy);
16746         kmem_cache_free(nsproxy_cachep, ns);
16747  }
16748  
16749 @@ -184,11 +240,15 @@ int unshare_nsproxy_namespaces(unsigned 
16750  {
16751         int err = 0;
16752  
16753 +       vxdprintk(VXD_CBIT(space, 4),
16754 +               "unshare_nsproxy_namespaces(0x%08lx,[%p])",
16755 +               unshare_flags, current->nsproxy);
16756 +
16757         if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
16758                                CLONE_NEWNET)))
16759                 return 0;
16760  
16761 -       if (!capable(CAP_SYS_ADMIN))
16762 +       if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
16763                 return -EPERM;
16764  
16765         *new_nsp = create_new_namespaces(unshare_flags, current,
16766 diff -NurpP --minimal linux-2.6.35.2/kernel/pid.c linux-2.6.35.2-vs2.3.0.36.31/kernel/pid.c
16767 --- linux-2.6.35.2/kernel/pid.c 2010-08-02 16:52:57.000000000 +0200
16768 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/pid.c   2010-08-02 17:05:06.000000000 +0200
16769 @@ -36,6 +36,7 @@
16770  #include <linux/pid_namespace.h>
16771  #include <linux/init_task.h>
16772  #include <linux/syscalls.h>
16773 +#include <linux/vs_pid.h>
16774  
16775  #define pid_hashfn(nr, ns)     \
16776         hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
16777 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
16778  
16779  struct pid *find_vpid(int nr)
16780  {
16781 -       return find_pid_ns(nr, current->nsproxy->pid_ns);
16782 +       return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
16783  }
16784  EXPORT_SYMBOL_GPL(find_vpid);
16785  
16786 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
16787  struct task_struct *pid_task(struct pid *pid, enum pid_type type)
16788  {
16789         struct task_struct *result = NULL;
16790 +
16791 +       if (type == PIDTYPE_REALPID)
16792 +               type = PIDTYPE_PID;
16793         if (pid) {
16794                 struct hlist_node *first;
16795                 first = rcu_dereference_check(pid->tasks[type].first,
16796 @@ -382,7 +386,7 @@ EXPORT_SYMBOL(pid_task);
16797   */
16798  struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
16799  {
16800 -       return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
16801 +       return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
16802  }
16803  
16804  struct task_struct *find_task_by_vpid(pid_t vnr)
16805 @@ -424,7 +428,7 @@ struct pid *find_get_pid(pid_t nr)
16806  }
16807  EXPORT_SYMBOL_GPL(find_get_pid);
16808  
16809 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16810 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
16811  {
16812         struct upid *upid;
16813         pid_t nr = 0;
16814 @@ -437,6 +441,11 @@ pid_t pid_nr_ns(struct pid *pid, struct 
16815         return nr;
16816  }
16817  
16818 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16819 +{
16820 +       return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
16821 +}
16822 +
16823  pid_t pid_vnr(struct pid *pid)
16824  {
16825         return pid_nr_ns(pid, current->nsproxy->pid_ns);
16826 diff -NurpP --minimal linux-2.6.35.2/kernel/pid_namespace.c linux-2.6.35.2-vs2.3.0.36.31/kernel/pid_namespace.c
16827 --- linux-2.6.35.2/kernel/pid_namespace.c       2010-07-07 18:31:57.000000000 +0200
16828 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/pid_namespace.c 2010-08-02 17:05:06.000000000 +0200
16829 @@ -14,6 +14,7 @@
16830  #include <linux/err.h>
16831  #include <linux/acct.h>
16832  #include <linux/slab.h>
16833 +#include <linux/vserver/global.h>
16834  
16835  #define BITS_PER_PAGE          (PAGE_SIZE*8)
16836  
16837 @@ -87,6 +88,7 @@ static struct pid_namespace *create_pid_
16838                 goto out_free_map;
16839  
16840         kref_init(&ns->kref);
16841 +       atomic_inc(&vs_global_pid_ns);
16842         ns->level = level;
16843         ns->parent = get_pid_ns(parent_pid_ns);
16844  
16845 @@ -112,6 +114,7 @@ static void destroy_pid_namespace(struct
16846  
16847         for (i = 0; i < PIDMAP_ENTRIES; i++)
16848                 kfree(ns->pidmap[i].page);
16849 +       atomic_dec(&vs_global_pid_ns);
16850         kmem_cache_free(pid_ns_cachep, ns);
16851  }
16852  
16853 diff -NurpP --minimal linux-2.6.35.2/kernel/posix-timers.c linux-2.6.35.2-vs2.3.0.36.31/kernel/posix-timers.c
16854 --- linux-2.6.35.2/kernel/posix-timers.c        2010-08-02 16:52:57.000000000 +0200
16855 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/posix-timers.c  2010-08-02 17:05:06.000000000 +0200
16856 @@ -46,6 +46,7 @@
16857  #include <linux/wait.h>
16858  #include <linux/workqueue.h>
16859  #include <linux/module.h>
16860 +#include <linux/vs_context.h>
16861  
16862  /*
16863   * Management arrays for POSIX timers.  Timers are kept in slab memory
16864 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
16865  {
16866         struct task_struct *task;
16867         int shared, ret = -1;
16868 +
16869         /*
16870          * FIXME: if ->sigq is queued we can race with
16871          * dequeue_signal()->do_schedule_next_timer().
16872 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
16873         rcu_read_lock();
16874         task = pid_task(timr->it_pid, PIDTYPE_PID);
16875         if (task) {
16876 +               struct vx_info_save vxis;
16877 +               struct vx_info *vxi;
16878 +
16879 +               vxi = get_vx_info(task->vx_info);
16880 +               enter_vx_info(vxi, &vxis);
16881                 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
16882                 ret = send_sigqueue(timr->sigq, task, shared);
16883 +               leave_vx_info(&vxis);
16884 +               put_vx_info(vxi);
16885         }
16886         rcu_read_unlock();
16887 +
16888         /* If we failed to send the signal the timer stops. */
16889         return ret > 0;
16890  }
16891 diff -NurpP --minimal linux-2.6.35.2/kernel/printk.c linux-2.6.35.2-vs2.3.0.36.31/kernel/printk.c
16892 --- linux-2.6.35.2/kernel/printk.c      2010-08-02 16:52:57.000000000 +0200
16893 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/printk.c        2010-08-02 17:05:06.000000000 +0200
16894 @@ -37,6 +37,7 @@
16895  #include <linux/ratelimit.h>
16896  #include <linux/kmsg_dump.h>
16897  #include <linux/syslog.h>
16898 +#include <linux/vs_cvirt.h>
16899  
16900  #include <asm/uaccess.h>
16901  
16902 @@ -264,18 +265,15 @@ int do_syslog(int type, char __user *buf
16903         unsigned i, j, limit, count;
16904         int do_clear = 0;
16905         char c;
16906 -       int error = 0;
16907 +       int error;
16908  
16909         error = security_syslog(type, from_file);
16910         if (error)
16911                 return error;
16912  
16913 -       switch (type) {
16914 -       case SYSLOG_ACTION_CLOSE:       /* Close log */
16915 -               break;
16916 -       case SYSLOG_ACTION_OPEN:        /* Open log */
16917 -               break;
16918 -       case SYSLOG_ACTION_READ:        /* Read from log */
16919 +       if ((type == SYSLOG_ACTION_READ) ||
16920 +           (type == SYSLOG_ACTION_READ_ALL) ||
16921 +           (type == SYSLOG_ACTION_READ_CLEAR)) {
16922                 error = -EINVAL;
16923                 if (!buf || len < 0)
16924                         goto out;
16925 @@ -286,6 +284,16 @@ int do_syslog(int type, char __user *buf
16926                         error = -EFAULT;
16927                         goto out;
16928                 }
16929 +       }
16930 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
16931 +               return vx_do_syslog(type, buf, len);
16932 +
16933 +       switch (type) {
16934 +       case SYSLOG_ACTION_CLOSE:       /* Close log */
16935 +               break;
16936 +       case SYSLOG_ACTION_OPEN:        /* Open log */
16937 +               break;
16938 +       case SYSLOG_ACTION_READ:        /* Read from log */
16939                 error = wait_event_interruptible(log_wait,
16940                                                         (log_start - log_end));
16941                 if (error)
16942 @@ -312,16 +320,6 @@ int do_syslog(int type, char __user *buf
16943                 /* FALL THRU */
16944         /* Read last kernel messages */
16945         case SYSLOG_ACTION_READ_ALL:
16946 -               error = -EINVAL;
16947 -               if (!buf || len < 0)
16948 -                       goto out;
16949 -               error = 0;
16950 -               if (!len)
16951 -                       goto out;
16952 -               if (!access_ok(VERIFY_WRITE, buf, len)) {
16953 -                       error = -EFAULT;
16954 -                       goto out;
16955 -               }
16956                 count = len;
16957                 if (count > log_buf_len)
16958                         count = log_buf_len;
16959 diff -NurpP --minimal linux-2.6.35.2/kernel/ptrace.c linux-2.6.35.2-vs2.3.0.36.31/kernel/ptrace.c
16960 --- linux-2.6.35.2/kernel/ptrace.c      2010-08-02 16:52:57.000000000 +0200
16961 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/ptrace.c        2010-08-02 17:05:06.000000000 +0200
16962 @@ -22,6 +22,7 @@
16963  #include <linux/syscalls.h>
16964  #include <linux/uaccess.h>
16965  #include <linux/regset.h>
16966 +#include <linux/vs_context.h>
16967  
16968  
16969  /*
16970 @@ -150,6 +151,11 @@ int __ptrace_may_access(struct task_stru
16971                 dumpable = get_dumpable(task->mm);
16972         if (!dumpable && !capable(CAP_SYS_PTRACE))
16973                 return -EPERM;
16974 +       if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
16975 +               return -EPERM;
16976 +       if (!vx_check(task->xid, VS_IDENT) &&
16977 +               !task_vx_flags(task, VXF_STATE_ADMIN, 0))
16978 +               return -EACCES;
16979  
16980         return security_ptrace_access_check(task, mode);
16981  }
16982 @@ -703,6 +709,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
16983                 goto out;
16984         }
16985  
16986 +       ret = -EPERM;
16987 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
16988 +               goto out_put_task_struct;
16989 +
16990         if (request == PTRACE_ATTACH) {
16991                 ret = ptrace_attach(child);
16992                 /*
16993 diff -NurpP --minimal linux-2.6.35.2/kernel/sched.c linux-2.6.35.2-vs2.3.0.36.31/kernel/sched.c
16994 --- linux-2.6.35.2/kernel/sched.c       2010-08-14 18:16:59.000000000 +0200
16995 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/sched.c 2010-08-14 18:19:32.000000000 +0200
16996 @@ -72,6 +72,8 @@
16997  #include <linux/ctype.h>
16998  #include <linux/ftrace.h>
16999  #include <linux/slab.h>
17000 +#include <linux/vs_sched.h>
17001 +#include <linux/vs_cvirt.h>
17002  
17003  #include <asm/tlb.h>
17004  #include <asm/irq_regs.h>
17005 @@ -2947,9 +2949,17 @@ static inline long calc_load_fold_idle(v
17006   */
17007  void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
17008  {
17009 -       loads[0] = (avenrun[0] + offset) << shift;
17010 -       loads[1] = (avenrun[1] + offset) << shift;
17011 -       loads[2] = (avenrun[2] + offset) << shift;
17012 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
17013 +               struct vx_info *vxi = current_vx_info();
17014 +
17015 +               loads[0] = (vxi->cvirt.load[0] + offset) << shift;
17016 +               loads[1] = (vxi->cvirt.load[1] + offset) << shift;
17017 +               loads[2] = (vxi->cvirt.load[2] + offset) << shift;
17018 +       } else {
17019 +               loads[0] = (avenrun[0] + offset) << shift;
17020 +               loads[1] = (avenrun[1] + offset) << shift;
17021 +               loads[2] = (avenrun[2] + offset) << shift;
17022 +       }
17023  }
17024  
17025  static unsigned long
17026 @@ -3157,16 +3167,19 @@ void account_user_time(struct task_struc
17027                        cputime_t cputime_scaled)
17028  {
17029         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17030 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17031         cputime64_t tmp;
17032 +       int nice = (TASK_NICE(p) > 0);
17033  
17034         /* Add user time to process. */
17035         p->utime = cputime_add(p->utime, cputime);
17036         p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
17037 +       vx_account_user(vxi, cputime, nice);
17038         account_group_user_time(p, cputime);
17039  
17040         /* Add user time to cpustat. */
17041         tmp = cputime_to_cputime64(cputime);
17042 -       if (TASK_NICE(p) > 0)
17043 +       if (nice)
17044                 cpustat->nice = cputime64_add(cpustat->nice, tmp);
17045         else
17046                 cpustat->user = cputime64_add(cpustat->user, tmp);
17047 @@ -3217,6 +3230,7 @@ void account_system_time(struct task_str
17048                          cputime_t cputime, cputime_t cputime_scaled)
17049  {
17050         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17051 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17052         cputime64_t tmp;
17053  
17054         if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
17055 @@ -3227,6 +3241,7 @@ void account_system_time(struct task_str
17056         /* Add system time to process. */
17057         p->stime = cputime_add(p->stime, cputime);
17058         p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
17059 +       vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
17060         account_group_system_time(p, cputime);
17061  
17062         /* Add system time to cpustat. */
17063 @@ -4292,7 +4307,7 @@ SYSCALL_DEFINE1(nice, int, increment)
17064                 nice = 19;
17065  
17066         if (increment < 0 && !can_nice(current, nice))
17067 -               return -EPERM;
17068 +               return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
17069  
17070         retval = security_task_setnice(current, nice);
17071         if (retval)
17072 diff -NurpP --minimal linux-2.6.35.2/kernel/sched_fair.c linux-2.6.35.2-vs2.3.0.36.31/kernel/sched_fair.c
17073 --- linux-2.6.35.2/kernel/sched_fair.c  2010-08-02 16:52:57.000000000 +0200
17074 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/sched_fair.c    2010-08-02 17:05:06.000000000 +0200
17075 @@ -782,6 +782,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
17076         check_spread(cfs_rq, se);
17077         if (se != cfs_rq->curr)
17078                 __enqueue_entity(cfs_rq, se);
17079 +
17080 +       if (entity_is_task(se))
17081 +               vx_activate_task(task_of(se));
17082  }
17083  
17084  static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
17085 @@ -825,6 +828,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
17086  
17087         if (se != cfs_rq->curr)
17088                 __dequeue_entity(cfs_rq, se);
17089 +       if (entity_is_task(se))
17090 +               vx_deactivate_task(task_of(se));
17091         account_entity_dequeue(cfs_rq, se);
17092         update_min_vruntime(cfs_rq);
17093  
17094 diff -NurpP --minimal linux-2.6.35.2/kernel/signal.c linux-2.6.35.2-vs2.3.0.36.31/kernel/signal.c
17095 --- linux-2.6.35.2/kernel/signal.c      2010-08-14 18:16:59.000000000 +0200
17096 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/signal.c        2010-08-14 18:19:32.000000000 +0200
17097 @@ -28,6 +28,8 @@
17098  #include <linux/freezer.h>
17099  #include <linux/pid_namespace.h>
17100  #include <linux/nsproxy.h>
17101 +#include <linux/vs_context.h>
17102 +#include <linux/vs_pid.h>
17103  #define CREATE_TRACE_POINTS
17104  #include <trace/events/signal.h>
17105  
17106 @@ -646,9 +648,18 @@ static int check_kill_permission(int sig
17107         struct pid *sid;
17108         int error;
17109  
17110 +       vxdprintk(VXD_CBIT(misc, 7),
17111 +               "check_kill_permission(%d,%p,%p[#%u,%u])",
17112 +               sig, info, t, vx_task_xid(t), t->pid);
17113 +
17114         if (!valid_signal(sig))
17115                 return -EINVAL;
17116  
17117 +/*     FIXME: needed? if so, why?
17118 +       if ((info != SEND_SIG_NOINFO) &&
17119 +               (is_si_special(info) || !si_fromuser(info)))
17120 +               goto skip;      */
17121 +
17122         if (!si_fromuser(info))
17123                 return 0;
17124  
17125 @@ -678,6 +689,20 @@ static int check_kill_permission(int sig
17126                 }
17127         }
17128  
17129 +       error = -EPERM;
17130 +       if (t->pid == 1 && current->xid)
17131 +               return error;
17132 +
17133 +       error = -ESRCH;
17134 +       /* FIXME: we shouldn't return ESRCH ever, to avoid
17135 +                 loops, maybe ENOENT or EACCES? */
17136 +       if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17137 +               vxdprintk(current->xid || VXD_CBIT(misc, 7),
17138 +                       "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17139 +                       sig, info, t, vx_task_xid(t), t->pid, current->xid);
17140 +               return error;
17141 +       }
17142 +/* skip: */
17143         return security_task_kill(t, info, sig, 0);
17144  }
17145  
17146 @@ -1170,7 +1195,7 @@ int kill_pid_info(int sig, struct siginf
17147         rcu_read_lock();
17148  retry:
17149         p = pid_task(pid, PIDTYPE_PID);
17150 -       if (p) {
17151 +       if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17152                 error = group_send_sig_info(sig, info, p);
17153                 if (unlikely(error == -ESRCH))
17154                         /*
17155 @@ -1210,7 +1235,7 @@ int kill_pid_info_as_uid(int sig, struct
17156  
17157         rcu_read_lock();
17158         p = pid_task(pid, PIDTYPE_PID);
17159 -       if (!p) {
17160 +       if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17161                 ret = -ESRCH;
17162                 goto out_unlock;
17163         }
17164 @@ -1265,8 +1290,10 @@ static int kill_something_info(int sig, 
17165                 struct task_struct * p;
17166  
17167                 for_each_process(p) {
17168 -                       if (task_pid_vnr(p) > 1 &&
17169 -                                       !same_thread_group(p, current)) {
17170 +                       if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17171 +                               task_pid_vnr(p) > 1 &&
17172 +                               !same_thread_group(p, current) &&
17173 +                               !vx_current_initpid(p->pid)) {
17174                                 int err = group_send_sig_info(sig, info, p);
17175                                 ++count;
17176                                 if (err != -EPERM)
17177 @@ -1933,6 +1960,11 @@ relock:
17178                                 !sig_kernel_only(signr))
17179                         continue;
17180  
17181 +               /* virtual init is protected against user signals */
17182 +               if ((info->si_code == SI_USER) &&
17183 +                       vx_current_initpid(current->pid))
17184 +                       continue;
17185 +
17186                 if (sig_kernel_stop(signr)) {
17187                         /*
17188                          * The default action is to stop all threads in
17189 diff -NurpP --minimal linux-2.6.35.2/kernel/softirq.c linux-2.6.35.2-vs2.3.0.36.31/kernel/softirq.c
17190 --- linux-2.6.35.2/kernel/softirq.c     2010-08-02 16:52:57.000000000 +0200
17191 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/softirq.c       2010-08-02 17:05:06.000000000 +0200
17192 @@ -24,6 +24,7 @@
17193  #include <linux/ftrace.h>
17194  #include <linux/smp.h>
17195  #include <linux/tick.h>
17196 +#include <linux/vs_context.h>
17197  
17198  #define CREATE_TRACE_POINTS
17199  #include <trace/events/irq.h>
17200 diff -NurpP --minimal linux-2.6.35.2/kernel/sys.c linux-2.6.35.2-vs2.3.0.36.31/kernel/sys.c
17201 --- linux-2.6.35.2/kernel/sys.c 2010-08-02 16:52:57.000000000 +0200
17202 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/sys.c   2010-08-02 17:48:19.000000000 +0200
17203 @@ -42,6 +42,7 @@
17204  #include <linux/syscalls.h>
17205  #include <linux/kprobes.h>
17206  #include <linux/user_namespace.h>
17207 +#include <linux/vs_pid.h>
17208  
17209  #include <asm/uaccess.h>
17210  #include <asm/io.h>
17211 @@ -131,7 +132,10 @@ static int set_one_prio(struct task_stru
17212                 goto out;
17213         }
17214         if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17215 -               error = -EACCES;
17216 +               if (vx_flags(VXF_IGNEG_NICE, 0))
17217 +                       error = 0;
17218 +               else
17219 +                       error = -EACCES;
17220                 goto out;
17221         }
17222         no_nice = security_task_setnice(p, niceval);
17223 @@ -181,6 +185,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17224                         else
17225                                 pgrp = task_pgrp(current);
17226                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17227 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17228 +                                       continue;
17229                                 error = set_one_prio(p, niceval, error);
17230                         } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17231                         break;
17232 @@ -244,6 +250,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17233                         else
17234                                 pgrp = task_pgrp(current);
17235                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17236 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17237 +                                       continue;
17238                                 niceval = 20 - task_nice(p);
17239                                 if (niceval > retval)
17240                                         retval = niceval;
17241 @@ -357,6 +365,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
17242  
17243  static DEFINE_MUTEX(reboot_mutex);
17244  
17245 +long vs_reboot(unsigned int, void __user *);
17246 +
17247  /*
17248   * Reboot system call: for obvious reasons only root may call it,
17249   * and even root needs to set up some magic numbers in the registers
17250 @@ -389,6 +399,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17251         if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17252                 cmd = LINUX_REBOOT_CMD_HALT;
17253  
17254 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
17255 +               return vs_reboot(cmd, arg);
17256 +
17257         mutex_lock(&reboot_mutex);
17258         switch (cmd) {
17259         case LINUX_REBOOT_CMD_RESTART:
17260 @@ -1167,7 +1180,7 @@ SYSCALL_DEFINE2(sethostname, char __user
17261         int errno;
17262         char tmp[__NEW_UTS_LEN];
17263  
17264 -       if (!capable(CAP_SYS_ADMIN))
17265 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17266                 return -EPERM;
17267         if (len < 0 || len > __NEW_UTS_LEN)
17268                 return -EINVAL;
17269 @@ -1216,7 +1229,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
17270         int errno;
17271         char tmp[__NEW_UTS_LEN];
17272  
17273 -       if (!capable(CAP_SYS_ADMIN))
17274 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17275                 return -EPERM;
17276         if (len < 0 || len > __NEW_UTS_LEN)
17277                 return -EINVAL;
17278 @@ -1285,7 +1298,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
17279                 return -EINVAL;
17280         old_rlim = current->signal->rlim + resource;
17281         if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17282 -           !capable(CAP_SYS_RESOURCE))
17283 +           !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17284                 return -EPERM;
17285         if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
17286                 return -EPERM;
17287 diff -NurpP --minimal linux-2.6.35.2/kernel/sysctl_binary.c linux-2.6.35.2-vs2.3.0.36.31/kernel/sysctl_binary.c
17288 --- linux-2.6.35.2/kernel/sysctl_binary.c       2010-08-02 16:52:57.000000000 +0200
17289 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/sysctl_binary.c 2010-08-02 17:05:06.000000000 +0200
17290 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
17291  
17292         { CTL_INT,      KERN_PANIC,                     "panic" },
17293         { CTL_INT,      KERN_REALROOTDEV,               "real-root-dev" },
17294 +       { CTL_STR,      KERN_VSHELPER,                  "vshelper" },
17295  
17296         { CTL_STR,      KERN_SPARC_REBOOT,              "reboot-cmd" },
17297         { CTL_INT,      KERN_CTLALTDEL,                 "ctrl-alt-del" },
17298 diff -NurpP --minimal linux-2.6.35.2/kernel/sysctl.c linux-2.6.35.2-vs2.3.0.36.31/kernel/sysctl.c
17299 --- linux-2.6.35.2/kernel/sysctl.c      2010-08-02 16:52:57.000000000 +0200
17300 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/sysctl.c        2010-08-02 17:05:06.000000000 +0200
17301 @@ -72,6 +72,7 @@
17302  #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
17303  #include <linux/lockdep.h>
17304  #endif
17305 +extern char vshelper_path[];
17306  #ifdef CONFIG_CHR_DEV_SG
17307  #include <scsi/sg.h>
17308  #endif
17309 @@ -571,6 +572,13 @@ static struct ctl_table kern_table[] = {
17310                 .proc_handler   = proc_dostring,
17311         },
17312  #endif
17313 +       {
17314 +               .procname       = "vshelper",
17315 +               .data           = &vshelper_path,
17316 +               .maxlen         = 256,
17317 +               .mode           = 0644,
17318 +               .proc_handler   = &proc_dostring,
17319 +       },
17320  #ifdef CONFIG_CHR_DEV_SG
17321         {
17322                 .procname       = "sg-big-buff",
17323 diff -NurpP --minimal linux-2.6.35.2/kernel/time.c linux-2.6.35.2-vs2.3.0.36.31/kernel/time.c
17324 --- linux-2.6.35.2/kernel/time.c        2010-08-02 16:52:57.000000000 +0200
17325 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/time.c  2010-08-02 17:05:06.000000000 +0200
17326 @@ -62,6 +62,7 @@ EXPORT_SYMBOL(sys_tz);
17327  SYSCALL_DEFINE1(time, time_t __user *, tloc)
17328  {
17329         time_t i = get_seconds();
17330 +/*     FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17331  
17332         if (tloc) {
17333                 if (put_user(i,tloc))
17334 @@ -92,7 +93,7 @@ SYSCALL_DEFINE1(stime, time_t __user *, 
17335         if (err)
17336                 return err;
17337  
17338 -       do_settimeofday(&tv);
17339 +       vx_settimeofday(&tv);
17340         return 0;
17341  }
17342  
17343 @@ -103,7 +104,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
17344  {
17345         if (likely(tv != NULL)) {
17346                 struct timeval ktv;
17347 -               do_gettimeofday(&ktv);
17348 +               vx_gettimeofday(&ktv);
17349                 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17350                         return -EFAULT;
17351         }
17352 @@ -177,7 +178,7 @@ int do_sys_settimeofday(struct timespec 
17353                 /* SMP safe, again the code in arch/foo/time.c should
17354                  * globally block out interrupts when it runs.
17355                  */
17356 -               return do_settimeofday(tv);
17357 +               return vx_settimeofday(tv);
17358         }
17359         return 0;
17360  }
17361 @@ -309,7 +310,7 @@ void getnstimeofday(struct timespec *tv)
17362  {
17363         struct timeval x;
17364  
17365 -       do_gettimeofday(&x);
17366 +       vx_gettimeofday(&x);
17367         tv->tv_sec = x.tv_sec;
17368         tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17369  }
17370 diff -NurpP --minimal linux-2.6.35.2/kernel/timer.c linux-2.6.35.2-vs2.3.0.36.31/kernel/timer.c
17371 --- linux-2.6.35.2/kernel/timer.c       2010-08-02 16:52:58.000000000 +0200
17372 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/timer.c 2010-08-02 17:05:06.000000000 +0200
17373 @@ -40,6 +40,10 @@
17374  #include <linux/perf_event.h>
17375  #include <linux/sched.h>
17376  #include <linux/slab.h>
17377 +#include <linux/vs_base.h>
17378 +#include <linux/vs_cvirt.h>
17379 +#include <linux/vs_pid.h>
17380 +#include <linux/vserver/sched.h>
17381  
17382  #include <asm/uaccess.h>
17383  #include <asm/unistd.h>
17384 @@ -1318,12 +1322,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17385  
17386  #endif
17387  
17388 -#ifndef __alpha__
17389 -
17390 -/*
17391 - * The Alpha uses getxpid, getxuid, and getxgid instead.  Maybe this
17392 - * should be moved into arch/i386 instead?
17393 - */
17394  
17395  /**
17396   * sys_getpid - return the thread group id of the current process
17397 @@ -1352,10 +1350,23 @@ SYSCALL_DEFINE0(getppid)
17398         rcu_read_lock();
17399         pid = task_tgid_vnr(current->real_parent);
17400         rcu_read_unlock();
17401 +       return vx_map_pid(pid);
17402 +}
17403  
17404 -       return pid;
17405 +#ifdef __alpha__
17406 +
17407 +/*
17408 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17409 + */
17410 +
17411 +asmlinkage long do_getxpid(long *ppid)
17412 +{
17413 +       *ppid = sys_getppid();
17414 +       return sys_getpid();
17415  }
17416  
17417 +#else /* _alpha_ */
17418 +
17419  SYSCALL_DEFINE0(getuid)
17420  {
17421         /* Only we change this so SMP safe */
17422 diff -NurpP --minimal linux-2.6.35.2/kernel/user_namespace.c linux-2.6.35.2-vs2.3.0.36.31/kernel/user_namespace.c
17423 --- linux-2.6.35.2/kernel/user_namespace.c      2010-08-02 16:52:58.000000000 +0200
17424 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/user_namespace.c        2010-08-02 17:05:06.000000000 +0200
17425 @@ -10,6 +10,7 @@
17426  #include <linux/slab.h>
17427  #include <linux/user_namespace.h>
17428  #include <linux/cred.h>
17429 +#include <linux/vserver/global.h>
17430  
17431  /*
17432   * Create a new user namespace, deriving the creator from the user in the
17433 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
17434                 return -ENOMEM;
17435  
17436         kref_init(&ns->kref);
17437 +       atomic_inc(&vs_global_user_ns);
17438  
17439         for (n = 0; n < UIDHASH_SZ; ++n)
17440                 INIT_HLIST_HEAD(ns->uidhash_table + n);
17441 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
17442         struct user_namespace *ns =
17443                 container_of(kref, struct user_namespace, kref);
17444  
17445 +       /* FIXME: maybe move into destroyer? */
17446 +       atomic_dec(&vs_global_user_ns);
17447         INIT_WORK(&ns->destroyer, free_user_ns_work);
17448         schedule_work(&ns->destroyer);
17449  }
17450 diff -NurpP --minimal linux-2.6.35.2/kernel/utsname.c linux-2.6.35.2-vs2.3.0.36.31/kernel/utsname.c
17451 --- linux-2.6.35.2/kernel/utsname.c     2009-09-10 15:26:28.000000000 +0200
17452 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/utsname.c       2010-08-02 17:05:06.000000000 +0200
17453 @@ -14,14 +14,17 @@
17454  #include <linux/utsname.h>
17455  #include <linux/err.h>
17456  #include <linux/slab.h>
17457 +#include <linux/vserver/global.h>
17458  
17459  static struct uts_namespace *create_uts_ns(void)
17460  {
17461         struct uts_namespace *uts_ns;
17462  
17463         uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17464 -       if (uts_ns)
17465 +       if (uts_ns) {
17466                 kref_init(&uts_ns->kref);
17467 +               atomic_inc(&vs_global_uts_ns);
17468 +       }
17469         return uts_ns;
17470  }
17471  
17472 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
17473         struct uts_namespace *ns;
17474  
17475         ns = container_of(kref, struct uts_namespace, kref);
17476 +       atomic_dec(&vs_global_uts_ns);
17477         kfree(ns);
17478  }
17479 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/cacct.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cacct.c
17480 --- linux-2.6.35.2/kernel/vserver/cacct.c       1970-01-01 01:00:00.000000000 +0100
17481 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cacct.c 2010-08-02 17:05:06.000000000 +0200
17482 @@ -0,0 +1,42 @@
17483 +/*
17484 + *  linux/kernel/vserver/cacct.c
17485 + *
17486 + *  Virtual Server: Context Accounting
17487 + *
17488 + *  Copyright (C) 2006-2007 Herbert Pötzl
17489 + *
17490 + *  V0.01  added accounting stats
17491 + *
17492 + */
17493 +
17494 +#include <linux/types.h>
17495 +#include <linux/vs_context.h>
17496 +#include <linux/vserver/cacct_cmd.h>
17497 +#include <linux/vserver/cacct_int.h>
17498 +
17499 +#include <asm/errno.h>
17500 +#include <asm/uaccess.h>
17501 +
17502 +
17503 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17504 +{
17505 +       struct vcmd_sock_stat_v0 vc_data;
17506 +       int j, field;
17507 +
17508 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17509 +               return -EFAULT;
17510 +
17511 +       field = vc_data.field;
17512 +       if ((field < 0) || (field >= VXA_SOCK_SIZE))
17513 +               return -EINVAL;
17514 +
17515 +       for (j = 0; j < 3; j++) {
17516 +               vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17517 +               vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17518 +       }
17519 +
17520 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17521 +               return -EFAULT;
17522 +       return 0;
17523 +}
17524 +
17525 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/cacct_init.h linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cacct_init.h
17526 --- linux-2.6.35.2/kernel/vserver/cacct_init.h  1970-01-01 01:00:00.000000000 +0100
17527 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cacct_init.h    2010-08-02 17:05:06.000000000 +0200
17528 @@ -0,0 +1,25 @@
17529 +
17530 +
17531 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17532 +{
17533 +       int i, j;
17534 +
17535 +
17536 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
17537 +               for (j = 0; j < 3; j++) {
17538 +                       atomic_long_set(&cacct->sock[i][j].count, 0);
17539 +                       atomic_long_set(&cacct->sock[i][j].total, 0);
17540 +               }
17541 +       }
17542 +       for (i = 0; i < 8; i++)
17543 +               atomic_set(&cacct->slab[i], 0);
17544 +       for (i = 0; i < 5; i++)
17545 +               for (j = 0; j < 4; j++)
17546 +                       atomic_set(&cacct->page[i][j], 0);
17547 +}
17548 +
17549 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17550 +{
17551 +       return;
17552 +}
17553 +
17554 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/cacct_proc.h linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cacct_proc.h
17555 --- linux-2.6.35.2/kernel/vserver/cacct_proc.h  1970-01-01 01:00:00.000000000 +0100
17556 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cacct_proc.h    2010-08-02 17:05:06.000000000 +0200
17557 @@ -0,0 +1,53 @@
17558 +#ifndef _VX_CACCT_PROC_H
17559 +#define _VX_CACCT_PROC_H
17560 +
17561 +#include <linux/vserver/cacct_int.h>
17562 +
17563 +
17564 +#define VX_SOCKA_TOP   \
17565 +       "Type\t    recv #/bytes\t\t   send #/bytes\t\t    fail #/bytes\n"
17566 +
17567 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17568 +{
17569 +       int i, j, length = 0;
17570 +       static char *type[VXA_SOCK_SIZE] = {
17571 +               "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17572 +       };
17573 +
17574 +       length += sprintf(buffer + length, VX_SOCKA_TOP);
17575 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
17576 +               length += sprintf(buffer + length, "%s:", type[i]);
17577 +               for (j = 0; j < 3; j++) {
17578 +                       length += sprintf(buffer + length,
17579 +                               "\t%10lu/%-10lu",
17580 +                               vx_sock_count(cacct, i, j),
17581 +                               vx_sock_total(cacct, i, j));
17582 +               }
17583 +               buffer[length++] = '\n';
17584 +       }
17585 +
17586 +       length += sprintf(buffer + length, "\n");
17587 +       length += sprintf(buffer + length,
17588 +               "slab:\t %8u %8u %8u %8u\n",
17589 +               atomic_read(&cacct->slab[1]),
17590 +               atomic_read(&cacct->slab[4]),
17591 +               atomic_read(&cacct->slab[0]),
17592 +               atomic_read(&cacct->slab[2]));
17593 +
17594 +       length += sprintf(buffer + length, "\n");
17595 +       for (i = 0; i < 5; i++) {
17596 +               length += sprintf(buffer + length,
17597 +                       "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17598 +                       atomic_read(&cacct->page[i][0]),
17599 +                       atomic_read(&cacct->page[i][1]),
17600 +                       atomic_read(&cacct->page[i][2]),
17601 +                       atomic_read(&cacct->page[i][3]),
17602 +                       atomic_read(&cacct->page[i][4]),
17603 +                       atomic_read(&cacct->page[i][5]),
17604 +                       atomic_read(&cacct->page[i][6]),
17605 +                       atomic_read(&cacct->page[i][7]));
17606 +       }
17607 +       return length;
17608 +}
17609 +
17610 +#endif /* _VX_CACCT_PROC_H */
17611 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/context.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/context.c
17612 --- linux-2.6.35.2/kernel/vserver/context.c     1970-01-01 01:00:00.000000000 +0100
17613 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/context.c       2010-08-02 17:05:06.000000000 +0200
17614 @@ -0,0 +1,1058 @@
17615 +/*
17616 + *  linux/kernel/vserver/context.c
17617 + *
17618 + *  Virtual Server: Context Support
17619 + *
17620 + *  Copyright (C) 2003-2007  Herbert Pötzl
17621 + *
17622 + *  V0.01  context helper
17623 + *  V0.02  vx_ctx_kill syscall command
17624 + *  V0.03  replaced context_info calls
17625 + *  V0.04  redesign of struct (de)alloc
17626 + *  V0.05  rlimit basic implementation
17627 + *  V0.06  task_xid and info commands
17628 + *  V0.07  context flags and caps
17629 + *  V0.08  switch to RCU based hash
17630 + *  V0.09  revert to non RCU for now
17631 + *  V0.10  and back to working RCU hash
17632 + *  V0.11  and back to locking again
17633 + *  V0.12  referenced context store
17634 + *  V0.13  separate per cpu data
17635 + *  V0.14  changed vcmds to vxi arg
17636 + *  V0.15  added context stat
17637 + *  V0.16  have __create claim() the vxi
17638 + *  V0.17  removed older and legacy stuff
17639 + *
17640 + */
17641 +
17642 +#include <linux/slab.h>
17643 +#include <linux/types.h>
17644 +#include <linux/security.h>
17645 +#include <linux/pid_namespace.h>
17646 +
17647 +#include <linux/vserver/context.h>
17648 +#include <linux/vserver/network.h>
17649 +#include <linux/vserver/debug.h>
17650 +#include <linux/vserver/limit.h>
17651 +#include <linux/vserver/limit_int.h>
17652 +#include <linux/vserver/space.h>
17653 +#include <linux/init_task.h>
17654 +#include <linux/fs_struct.h>
17655 +
17656 +#include <linux/vs_context.h>
17657 +#include <linux/vs_limit.h>
17658 +#include <linux/vs_pid.h>
17659 +#include <linux/vserver/context_cmd.h>
17660 +
17661 +#include "cvirt_init.h"
17662 +#include "cacct_init.h"
17663 +#include "limit_init.h"
17664 +#include "sched_init.h"
17665 +
17666 +
17667 +atomic_t vx_global_ctotal      = ATOMIC_INIT(0);
17668 +atomic_t vx_global_cactive     = ATOMIC_INIT(0);
17669 +
17670 +
17671 +/*     now inactive context structures */
17672 +
17673 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17674 +
17675 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17676 +
17677 +
17678 +/*     __alloc_vx_info()
17679 +
17680 +       * allocate an initialized vx_info struct
17681 +       * doesn't make it visible (hash)                        */
17682 +
17683 +static struct vx_info *__alloc_vx_info(xid_t xid)
17684 +{
17685 +       struct vx_info *new = NULL;
17686 +       int cpu, index;
17687 +
17688 +       vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17689 +
17690 +       /* would this benefit from a slab cache? */
17691 +       new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17692 +       if (!new)
17693 +               return 0;
17694 +
17695 +       memset(new, 0, sizeof(struct vx_info));
17696 +#ifdef CONFIG_SMP
17697 +       new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17698 +       if (!new->ptr_pc)
17699 +               goto error;
17700 +#endif
17701 +       new->vx_id = xid;
17702 +       INIT_HLIST_NODE(&new->vx_hlist);
17703 +       atomic_set(&new->vx_usecnt, 0);
17704 +       atomic_set(&new->vx_tasks, 0);
17705 +       new->vx_parent = NULL;
17706 +       new->vx_state = 0;
17707 +       init_waitqueue_head(&new->vx_wait);
17708 +
17709 +       /* prepare reaper */
17710 +       get_task_struct(init_pid_ns.child_reaper);
17711 +       new->vx_reaper = init_pid_ns.child_reaper;
17712 +       new->vx_badness_bias = 0;
17713 +
17714 +       /* rest of init goes here */
17715 +       vx_info_init_limit(&new->limit);
17716 +       vx_info_init_sched(&new->sched);
17717 +       vx_info_init_cvirt(&new->cvirt);
17718 +       vx_info_init_cacct(&new->cacct);
17719 +
17720 +       /* per cpu data structures */
17721 +       for_each_possible_cpu(cpu) {
17722 +               vx_info_init_sched_pc(
17723 +                       &vx_per_cpu(new, sched_pc, cpu), cpu);
17724 +               vx_info_init_cvirt_pc(
17725 +                       &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17726 +       }
17727 +
17728 +       new->vx_flags = VXF_INIT_SET;
17729 +       cap_set_init_eff(new->vx_bcaps);
17730 +       new->vx_ccaps = 0;
17731 +       new->vx_umask = 0;
17732 +
17733 +       new->reboot_cmd = 0;
17734 +       new->exit_code = 0;
17735 +
17736 +       // preconfig fs entries
17737 +       for (index = 0; index < VX_SPACES; index++) {
17738 +               write_lock(&init_fs.lock);
17739 +               init_fs.users++;
17740 +               write_unlock(&init_fs.lock);
17741 +               new->vx_fs[index] = &init_fs;
17742 +       }
17743 +
17744 +       vxdprintk(VXD_CBIT(xid, 0),
17745 +               "alloc_vx_info(%d) = %p", xid, new);
17746 +       vxh_alloc_vx_info(new);
17747 +       atomic_inc(&vx_global_ctotal);
17748 +       return new;
17749 +#ifdef CONFIG_SMP
17750 +error:
17751 +       kfree(new);
17752 +       return 0;
17753 +#endif
17754 +}
17755 +
17756 +/*     __dealloc_vx_info()
17757 +
17758 +       * final disposal of vx_info                             */
17759 +
17760 +static void __dealloc_vx_info(struct vx_info *vxi)
17761 +{
17762 +#ifdef CONFIG_VSERVER_WARN
17763 +       struct vx_info_save vxis;
17764 +       int cpu;
17765 +#endif
17766 +       vxdprintk(VXD_CBIT(xid, 0),
17767 +               "dealloc_vx_info(%p)", vxi);
17768 +       vxh_dealloc_vx_info(vxi);
17769 +
17770 +#ifdef CONFIG_VSERVER_WARN
17771 +       enter_vx_info(vxi, &vxis);
17772 +       vx_info_exit_limit(&vxi->limit);
17773 +       vx_info_exit_sched(&vxi->sched);
17774 +       vx_info_exit_cvirt(&vxi->cvirt);
17775 +       vx_info_exit_cacct(&vxi->cacct);
17776 +
17777 +       for_each_possible_cpu(cpu) {
17778 +               vx_info_exit_sched_pc(
17779 +                       &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17780 +               vx_info_exit_cvirt_pc(
17781 +                       &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17782 +       }
17783 +       leave_vx_info(&vxis);
17784 +#endif
17785 +
17786 +       vxi->vx_id = -1;
17787 +       vxi->vx_state |= VXS_RELEASED;
17788 +
17789 +#ifdef CONFIG_SMP
17790 +       free_percpu(vxi->ptr_pc);
17791 +#endif
17792 +       kfree(vxi);
17793 +       atomic_dec(&vx_global_ctotal);
17794 +}
17795 +
17796 +static void __shutdown_vx_info(struct vx_info *vxi)
17797 +{
17798 +       struct nsproxy *nsproxy;
17799 +       struct fs_struct *fs;
17800 +       int index, kill;
17801 +
17802 +       might_sleep();
17803 +
17804 +       vxi->vx_state |= VXS_SHUTDOWN;
17805 +       vs_state_change(vxi, VSC_SHUTDOWN);
17806 +
17807 +       for (index = 0; index < VX_SPACES; index++) {
17808 +               nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17809 +               if (nsproxy)
17810 +                       put_nsproxy(nsproxy);
17811 +
17812 +               fs = xchg(&vxi->vx_fs[index], NULL);
17813 +               write_lock(&fs->lock);
17814 +               kill = !--fs->users;
17815 +               write_unlock(&fs->lock);
17816 +               if (kill)
17817 +                       free_fs_struct(fs);
17818 +       }
17819 +}
17820 +
17821 +/* exported stuff */
17822 +
17823 +void free_vx_info(struct vx_info *vxi)
17824 +{
17825 +       unsigned long flags;
17826 +       unsigned index;
17827 +
17828 +       /* check for reference counts first */
17829 +       BUG_ON(atomic_read(&vxi->vx_usecnt));
17830 +       BUG_ON(atomic_read(&vxi->vx_tasks));
17831 +
17832 +       /* context must not be hashed */
17833 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
17834 +
17835 +       /* context shutdown is mandatory */
17836 +       BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17837 +
17838 +       /* nsproxy and fs check */
17839 +       for (index = 0; index < VX_SPACES; index++) {
17840 +               BUG_ON(vxi->vx_nsproxy[index]);
17841 +               BUG_ON(vxi->vx_fs[index]);
17842 +       }
17843 +
17844 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
17845 +       hlist_del(&vxi->vx_hlist);
17846 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17847 +
17848 +       __dealloc_vx_info(vxi);
17849 +}
17850 +
17851 +
17852 +/*     hash table for vx_info hash */
17853 +
17854 +#define VX_HASH_SIZE   13
17855 +
17856 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17857 +       { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17858 +
17859 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17860 +
17861 +
17862 +static inline unsigned int __hashval(xid_t xid)
17863 +{
17864 +       return (xid % VX_HASH_SIZE);
17865 +}
17866 +
17867 +
17868 +
17869 +/*     __hash_vx_info()
17870 +
17871 +       * add the vxi to the global hash table
17872 +       * requires the hash_lock to be held                     */
17873 +
17874 +static inline void __hash_vx_info(struct vx_info *vxi)
17875 +{
17876 +       struct hlist_head *head;
17877 +
17878 +       vxd_assert_lock(&vx_info_hash_lock);
17879 +       vxdprintk(VXD_CBIT(xid, 4),
17880 +               "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17881 +       vxh_hash_vx_info(vxi);
17882 +
17883 +       /* context must not be hashed */
17884 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
17885 +
17886 +       vxi->vx_state |= VXS_HASHED;
17887 +       head = &vx_info_hash[__hashval(vxi->vx_id)];
17888 +       hlist_add_head(&vxi->vx_hlist, head);
17889 +       atomic_inc(&vx_global_cactive);
17890 +}
17891 +
17892 +/*     __unhash_vx_info()
17893 +
17894 +       * remove the vxi from the global hash table
17895 +       * requires the hash_lock to be held                     */
17896 +
17897 +static inline void __unhash_vx_info(struct vx_info *vxi)
17898 +{
17899 +       unsigned long flags;
17900 +
17901 +       vxd_assert_lock(&vx_info_hash_lock);
17902 +       vxdprintk(VXD_CBIT(xid, 4),
17903 +               "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17904 +               atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17905 +       vxh_unhash_vx_info(vxi);
17906 +
17907 +       /* context must be hashed */
17908 +       BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17909 +       /* but without tasks */
17910 +       BUG_ON(atomic_read(&vxi->vx_tasks));
17911 +
17912 +       vxi->vx_state &= ~VXS_HASHED;
17913 +       hlist_del_init(&vxi->vx_hlist);
17914 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
17915 +       hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17916 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17917 +       atomic_dec(&vx_global_cactive);
17918 +}
17919 +
17920 +
17921 +/*     __lookup_vx_info()
17922 +
17923 +       * requires the hash_lock to be held
17924 +       * doesn't increment the vx_refcnt                       */
17925 +
17926 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17927 +{
17928 +       struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17929 +       struct hlist_node *pos;
17930 +       struct vx_info *vxi;
17931 +
17932 +       vxd_assert_lock(&vx_info_hash_lock);
17933 +       hlist_for_each(pos, head) {
17934 +               vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17935 +
17936 +               if (vxi->vx_id == xid)
17937 +                       goto found;
17938 +       }
17939 +       vxi = NULL;
17940 +found:
17941 +       vxdprintk(VXD_CBIT(xid, 0),
17942 +               "__lookup_vx_info(#%u): %p[#%u]",
17943 +               xid, vxi, vxi ? vxi->vx_id : 0);
17944 +       vxh_lookup_vx_info(vxi, xid);
17945 +       return vxi;
17946 +}
17947 +
17948 +
17949 +/*     __create_vx_info()
17950 +
17951 +       * create the requested context
17952 +       * get(), claim() and hash it                            */
17953 +
17954 +static struct vx_info *__create_vx_info(int id)
17955 +{
17956 +       struct vx_info *new, *vxi = NULL;
17957 +
17958 +       vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
17959 +
17960 +       if (!(new = __alloc_vx_info(id)))
17961 +               return ERR_PTR(-ENOMEM);
17962 +
17963 +       /* required to make dynamic xids unique */
17964 +       spin_lock(&vx_info_hash_lock);
17965 +
17966 +       /* static context requested */
17967 +       if ((vxi = __lookup_vx_info(id))) {
17968 +               vxdprintk(VXD_CBIT(xid, 0),
17969 +                       "create_vx_info(%d) = %p (already there)", id, vxi);
17970 +               if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
17971 +                       vxi = ERR_PTR(-EBUSY);
17972 +               else
17973 +                       vxi = ERR_PTR(-EEXIST);
17974 +               goto out_unlock;
17975 +       }
17976 +       /* new context */
17977 +       vxdprintk(VXD_CBIT(xid, 0),
17978 +               "create_vx_info(%d) = %p (new)", id, new);
17979 +       claim_vx_info(new, NULL);
17980 +       __hash_vx_info(get_vx_info(new));
17981 +       vxi = new, new = NULL;
17982 +
17983 +out_unlock:
17984 +       spin_unlock(&vx_info_hash_lock);
17985 +       vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
17986 +       if (new)
17987 +               __dealloc_vx_info(new);
17988 +       return vxi;
17989 +}
17990 +
17991 +
17992 +/*     exported stuff                                          */
17993 +
17994 +
17995 +void unhash_vx_info(struct vx_info *vxi)
17996 +{
17997 +       __shutdown_vx_info(vxi);
17998 +       spin_lock(&vx_info_hash_lock);
17999 +       __unhash_vx_info(vxi);
18000 +       spin_unlock(&vx_info_hash_lock);
18001 +       __wakeup_vx_info(vxi);
18002 +}
18003 +
18004 +
18005 +/*     lookup_vx_info()
18006 +
18007 +       * search for a vx_info and get() it
18008 +       * negative id means current                             */
18009 +
18010 +struct vx_info *lookup_vx_info(int id)
18011 +{
18012 +       struct vx_info *vxi = NULL;
18013 +
18014 +       if (id < 0) {
18015 +               vxi = get_vx_info(current_vx_info());
18016 +       } else if (id > 1) {
18017 +               spin_lock(&vx_info_hash_lock);
18018 +               vxi = get_vx_info(__lookup_vx_info(id));
18019 +               spin_unlock(&vx_info_hash_lock);
18020 +       }
18021 +       return vxi;
18022 +}
18023 +
18024 +/*     xid_is_hashed()
18025 +
18026 +       * verify that xid is still hashed                       */
18027 +
18028 +int xid_is_hashed(xid_t xid)
18029 +{
18030 +       int hashed;
18031 +
18032 +       spin_lock(&vx_info_hash_lock);
18033 +       hashed = (__lookup_vx_info(xid) != NULL);
18034 +       spin_unlock(&vx_info_hash_lock);
18035 +       return hashed;
18036 +}
18037 +
18038 +#ifdef CONFIG_PROC_FS
18039 +
18040 +/*     get_xid_list()
18041 +
18042 +       * get a subset of hashed xids for proc
18043 +       * assumes size is at least one                          */
18044 +
18045 +int get_xid_list(int index, unsigned int *xids, int size)
18046 +{
18047 +       int hindex, nr_xids = 0;
18048 +
18049 +       /* only show current and children */
18050 +       if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18051 +               if (index > 0)
18052 +                       return 0;
18053 +               xids[nr_xids] = vx_current_xid();
18054 +               return 1;
18055 +       }
18056 +
18057 +       for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18058 +               struct hlist_head *head = &vx_info_hash[hindex];
18059 +               struct hlist_node *pos;
18060 +
18061 +               spin_lock(&vx_info_hash_lock);
18062 +               hlist_for_each(pos, head) {
18063 +                       struct vx_info *vxi;
18064 +
18065 +                       if (--index > 0)
18066 +                               continue;
18067 +
18068 +                       vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18069 +                       xids[nr_xids] = vxi->vx_id;
18070 +                       if (++nr_xids >= size) {
18071 +                               spin_unlock(&vx_info_hash_lock);
18072 +                               goto out;
18073 +                       }
18074 +               }
18075 +               /* keep the lock time short */
18076 +               spin_unlock(&vx_info_hash_lock);
18077 +       }
18078 +out:
18079 +       return nr_xids;
18080 +}
18081 +#endif
18082 +
18083 +#ifdef CONFIG_VSERVER_DEBUG
18084 +
18085 +void   dump_vx_info_inactive(int level)
18086 +{
18087 +       struct hlist_node *entry, *next;
18088 +
18089 +       hlist_for_each_safe(entry, next, &vx_info_inactive) {
18090 +               struct vx_info *vxi =
18091 +                       list_entry(entry, struct vx_info, vx_hlist);
18092 +
18093 +               dump_vx_info(vxi, level);
18094 +       }
18095 +}
18096 +
18097 +#endif
18098 +
18099 +#if 0
18100 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18101 +{
18102 +       struct user_struct *new_user, *old_user;
18103 +
18104 +       if (!p || !vxi)
18105 +               BUG();
18106 +
18107 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18108 +               return -EACCES;
18109 +
18110 +       new_user = alloc_uid(vxi->vx_id, p->uid);
18111 +       if (!new_user)
18112 +               return -ENOMEM;
18113 +
18114 +       old_user = p->user;
18115 +       if (new_user != old_user) {
18116 +               atomic_inc(&new_user->processes);
18117 +               atomic_dec(&old_user->processes);
18118 +               p->user = new_user;
18119 +       }
18120 +       free_uid(old_user);
18121 +       return 0;
18122 +}
18123 +#endif
18124 +
18125 +#if 0
18126 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18127 +{
18128 +       // p->cap_effective &= vxi->vx_cap_bset;
18129 +       p->cap_effective =
18130 +               cap_intersect(p->cap_effective, vxi->cap_bset);
18131 +       // p->cap_inheritable &= vxi->vx_cap_bset;
18132 +       p->cap_inheritable =
18133 +               cap_intersect(p->cap_inheritable, vxi->cap_bset);
18134 +       // p->cap_permitted &= vxi->vx_cap_bset;
18135 +       p->cap_permitted =
18136 +               cap_intersect(p->cap_permitted, vxi->cap_bset);
18137 +}
18138 +#endif
18139 +
18140 +
18141 +#include <linux/file.h>
18142 +#include <linux/fdtable.h>
18143 +
18144 +static int vx_openfd_task(struct task_struct *tsk)
18145 +{
18146 +       struct files_struct *files = tsk->files;
18147 +       struct fdtable *fdt;
18148 +       const unsigned long *bptr;
18149 +       int count, total;
18150 +
18151 +       /* no rcu_read_lock() because of spin_lock() */
18152 +       spin_lock(&files->file_lock);
18153 +       fdt = files_fdtable(files);
18154 +       bptr = fdt->open_fds->fds_bits;
18155 +       count = fdt->max_fds / (sizeof(unsigned long) * 8);
18156 +       for (total = 0; count > 0; count--) {
18157 +               if (*bptr)
18158 +                       total += hweight_long(*bptr);
18159 +               bptr++;
18160 +       }
18161 +       spin_unlock(&files->file_lock);
18162 +       return total;
18163 +}
18164 +
18165 +
18166 +/*     for *space compatibility */
18167 +
18168 +asmlinkage long sys_unshare(unsigned long);
18169 +
18170 +/*
18171 + *     migrate task to new context
18172 + *     gets vxi, puts old_vxi on change
18173 + *     optionally unshares namespaces (hack)
18174 + */
18175 +
18176 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18177 +{
18178 +       struct vx_info *old_vxi;
18179 +       int ret = 0;
18180 +
18181 +       if (!p || !vxi)
18182 +               BUG();
18183 +
18184 +       vxdprintk(VXD_CBIT(xid, 5),
18185 +               "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18186 +               vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18187 +
18188 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18189 +               !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18190 +               return -EACCES;
18191 +
18192 +       if (vx_info_state(vxi, VXS_SHUTDOWN))
18193 +               return -EFAULT;
18194 +
18195 +       old_vxi = task_get_vx_info(p);
18196 +       if (old_vxi == vxi)
18197 +               goto out;
18198 +
18199 +//     if (!(ret = vx_migrate_user(p, vxi))) {
18200 +       {
18201 +               int openfd;
18202 +
18203 +               task_lock(p);
18204 +               openfd = vx_openfd_task(p);
18205 +
18206 +               if (old_vxi) {
18207 +                       atomic_dec(&old_vxi->cvirt.nr_threads);
18208 +                       atomic_dec(&old_vxi->cvirt.nr_running);
18209 +                       __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18210 +                       /* FIXME: what about the struct files here? */
18211 +                       __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18212 +                       /* account for the executable */
18213 +                       __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18214 +               }
18215 +               atomic_inc(&vxi->cvirt.nr_threads);
18216 +               atomic_inc(&vxi->cvirt.nr_running);
18217 +               __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18218 +               /* FIXME: what about the struct files here? */
18219 +               __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18220 +               /* account for the executable */
18221 +               __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18222 +
18223 +               if (old_vxi) {
18224 +                       release_vx_info(old_vxi, p);
18225 +                       clr_vx_info(&p->vx_info);
18226 +               }
18227 +               claim_vx_info(vxi, p);
18228 +               set_vx_info(&p->vx_info, vxi);
18229 +               p->xid = vxi->vx_id;
18230 +
18231 +               vxdprintk(VXD_CBIT(xid, 5),
18232 +                       "moved task %p into vxi:%p[#%d]",
18233 +                       p, vxi, vxi->vx_id);
18234 +
18235 +               // vx_mask_cap_bset(vxi, p);
18236 +               task_unlock(p);
18237 +
18238 +               /* hack for *spaces to provide compatibility */
18239 +               if (unshare) {
18240 +                       struct nsproxy *old_nsp, *new_nsp;
18241 +
18242 +                       ret = unshare_nsproxy_namespaces(
18243 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18244 +                               &new_nsp, NULL);
18245 +                       if (ret)
18246 +                               goto out;
18247 +
18248 +                       old_nsp = xchg(&p->nsproxy, new_nsp);
18249 +                       vx_set_space(vxi,
18250 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18251 +                       put_nsproxy(old_nsp);
18252 +               }
18253 +       }
18254 +out:
18255 +       put_vx_info(old_vxi);
18256 +       return ret;
18257 +}
18258 +
18259 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18260 +{
18261 +       struct task_struct *old_reaper;
18262 +
18263 +       if (!vxi)
18264 +               return -EINVAL;
18265 +
18266 +       vxdprintk(VXD_CBIT(xid, 6),
18267 +               "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18268 +               vxi, vxi->vx_id, p, p->xid, p->pid);
18269 +
18270 +       old_reaper = vxi->vx_reaper;
18271 +       if (old_reaper == p)
18272 +               return 0;
18273 +
18274 +       /* set new child reaper */
18275 +       get_task_struct(p);
18276 +       vxi->vx_reaper = p;
18277 +       put_task_struct(old_reaper);
18278 +       return 0;
18279 +}
18280 +
18281 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18282 +{
18283 +       if (!vxi)
18284 +               return -EINVAL;
18285 +
18286 +       vxdprintk(VXD_CBIT(xid, 6),
18287 +               "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18288 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18289 +
18290 +       vxi->vx_flags &= ~VXF_STATE_INIT;
18291 +       // vxi->vx_initpid = p->tgid;
18292 +       vxi->vx_initpid = p->pid;
18293 +       return 0;
18294 +}
18295 +
18296 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18297 +{
18298 +       vxdprintk(VXD_CBIT(xid, 6),
18299 +               "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18300 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18301 +
18302 +       vxi->exit_code = code;
18303 +       vxi->vx_initpid = 0;
18304 +}
18305 +
18306 +
18307 +void vx_set_persistent(struct vx_info *vxi)
18308 +{
18309 +       vxdprintk(VXD_CBIT(xid, 6),
18310 +               "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18311 +
18312 +       get_vx_info(vxi);
18313 +       claim_vx_info(vxi, NULL);
18314 +}
18315 +
18316 +void vx_clear_persistent(struct vx_info *vxi)
18317 +{
18318 +       vxdprintk(VXD_CBIT(xid, 6),
18319 +               "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18320 +
18321 +       release_vx_info(vxi, NULL);
18322 +       put_vx_info(vxi);
18323 +}
18324 +
18325 +void vx_update_persistent(struct vx_info *vxi)
18326 +{
18327 +       if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18328 +               vx_set_persistent(vxi);
18329 +       else
18330 +               vx_clear_persistent(vxi);
18331 +}
18332 +
18333 +
18334 +/*     task must be current or locked          */
18335 +
18336 +void   exit_vx_info(struct task_struct *p, int code)
18337 +{
18338 +       struct vx_info *vxi = p->vx_info;
18339 +
18340 +       if (vxi) {
18341 +               atomic_dec(&vxi->cvirt.nr_threads);
18342 +               vx_nproc_dec(p);
18343 +
18344 +               vxi->exit_code = code;
18345 +               release_vx_info(vxi, p);
18346 +       }
18347 +}
18348 +
18349 +void   exit_vx_info_early(struct task_struct *p, int code)
18350 +{
18351 +       struct vx_info *vxi = p->vx_info;
18352 +
18353 +       if (vxi) {
18354 +               if (vxi->vx_initpid == p->pid)
18355 +                       vx_exit_init(vxi, p, code);
18356 +               if (vxi->vx_reaper == p)
18357 +                       vx_set_reaper(vxi, init_pid_ns.child_reaper);
18358 +       }
18359 +}
18360 +
18361 +
18362 +/* vserver syscall commands below here */
18363 +
18364 +/* taks xid and vx_info functions */
18365 +
18366 +#include <asm/uaccess.h>
18367 +
18368 +
18369 +int vc_task_xid(uint32_t id)
18370 +{
18371 +       xid_t xid;
18372 +
18373 +       if (id) {
18374 +               struct task_struct *tsk;
18375 +
18376 +               read_lock(&tasklist_lock);
18377 +               tsk = find_task_by_real_pid(id);
18378 +               xid = (tsk) ? tsk->xid : -ESRCH;
18379 +               read_unlock(&tasklist_lock);
18380 +       } else
18381 +               xid = vx_current_xid();
18382 +       return xid;
18383 +}
18384 +
18385 +
18386 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18387 +{
18388 +       struct vcmd_vx_info_v0 vc_data;
18389 +
18390 +       vc_data.xid = vxi->vx_id;
18391 +       vc_data.initpid = vxi->vx_initpid;
18392 +
18393 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18394 +               return -EFAULT;
18395 +       return 0;
18396 +}
18397 +
18398 +
18399 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18400 +{
18401 +       struct vcmd_ctx_stat_v0 vc_data;
18402 +
18403 +       vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18404 +       vc_data.tasks = atomic_read(&vxi->vx_tasks);
18405 +
18406 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18407 +               return -EFAULT;
18408 +       return 0;
18409 +}
18410 +
18411 +
18412 +/* context functions */
18413 +
18414 +int vc_ctx_create(uint32_t xid, void __user *data)
18415 +{
18416 +       struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18417 +       struct vx_info *new_vxi;
18418 +       int ret;
18419 +
18420 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18421 +               return -EFAULT;
18422 +
18423 +       if ((xid > MAX_S_CONTEXT) || (xid < 2))
18424 +               return -EINVAL;
18425 +
18426 +       new_vxi = __create_vx_info(xid);
18427 +       if (IS_ERR(new_vxi))
18428 +               return PTR_ERR(new_vxi);
18429 +
18430 +       /* initial flags */
18431 +       new_vxi->vx_flags = vc_data.flagword;
18432 +
18433 +       ret = -ENOEXEC;
18434 +       if (vs_state_change(new_vxi, VSC_STARTUP))
18435 +               goto out;
18436 +
18437 +       ret = vx_migrate_task(current, new_vxi, (!data));
18438 +       if (ret)
18439 +               goto out;
18440 +
18441 +       /* return context id on success */
18442 +       ret = new_vxi->vx_id;
18443 +
18444 +       /* get a reference for persistent contexts */
18445 +       if ((vc_data.flagword & VXF_PERSISTENT))
18446 +               vx_set_persistent(new_vxi);
18447 +out:
18448 +       release_vx_info(new_vxi, NULL);
18449 +       put_vx_info(new_vxi);
18450 +       return ret;
18451 +}
18452 +
18453 +
18454 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18455 +{
18456 +       struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18457 +       int ret;
18458 +
18459 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18460 +               return -EFAULT;
18461 +
18462 +       ret = vx_migrate_task(current, vxi, 0);
18463 +       if (ret)
18464 +               return ret;
18465 +       if (vc_data.flagword & VXM_SET_INIT)
18466 +               ret = vx_set_init(vxi, current);
18467 +       if (ret)
18468 +               return ret;
18469 +       if (vc_data.flagword & VXM_SET_REAPER)
18470 +               ret = vx_set_reaper(vxi, current);
18471 +       return ret;
18472 +}
18473 +
18474 +
18475 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18476 +{
18477 +       struct vcmd_ctx_flags_v0 vc_data;
18478 +
18479 +       vc_data.flagword = vxi->vx_flags;
18480 +
18481 +       /* special STATE flag handling */
18482 +       vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18483 +
18484 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18485 +               return -EFAULT;
18486 +       return 0;
18487 +}
18488 +
18489 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18490 +{
18491 +       struct vcmd_ctx_flags_v0 vc_data;
18492 +       uint64_t mask, trigger;
18493 +
18494 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18495 +               return -EFAULT;
18496 +
18497 +       /* special STATE flag handling */
18498 +       mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18499 +       trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18500 +
18501 +       if (vxi == current_vx_info()) {
18502 +               /* if (trigger & VXF_STATE_SETUP)
18503 +                       vx_mask_cap_bset(vxi, current); */
18504 +               if (trigger & VXF_STATE_INIT) {
18505 +                       int ret;
18506 +
18507 +                       ret = vx_set_init(vxi, current);
18508 +                       if (ret)
18509 +                               return ret;
18510 +                       ret = vx_set_reaper(vxi, current);
18511 +                       if (ret)
18512 +                               return ret;
18513 +               }
18514 +       }
18515 +
18516 +       vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18517 +               vc_data.flagword, mask);
18518 +       if (trigger & VXF_PERSISTENT)
18519 +               vx_update_persistent(vxi);
18520 +
18521 +       return 0;
18522 +}
18523 +
18524 +
18525 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18526 +{
18527 +       uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18528 +
18529 +       // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18530 +       return v;
18531 +}
18532 +
18533 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18534 +{
18535 +       kernel_cap_t c = __cap_empty_set;
18536 +
18537 +       c.cap[0] = v & 0xFFFFFFFF;
18538 +       c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18539 +
18540 +       // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18541 +       return c;
18542 +}
18543 +
18544 +
18545 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18546 +{
18547 +       if (bcaps)
18548 +               *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18549 +       if (ccaps)
18550 +               *ccaps = vxi->vx_ccaps;
18551 +
18552 +       return 0;
18553 +}
18554 +
18555 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18556 +{
18557 +       struct vcmd_ctx_caps_v1 vc_data;
18558 +       int ret;
18559 +
18560 +       ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18561 +       if (ret)
18562 +               return ret;
18563 +       vc_data.cmask = ~0ULL;
18564 +
18565 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18566 +               return -EFAULT;
18567 +       return 0;
18568 +}
18569 +
18570 +static int do_set_caps(struct vx_info *vxi,
18571 +       uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18572 +{
18573 +       uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18574 +
18575 +#if 0
18576 +       printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18577 +               bcaps, bmask, ccaps, cmask);
18578 +#endif
18579 +       vxi->vx_bcaps = cap_t_from_caps(
18580 +               vs_mask_flags(bcold, bcaps, bmask));
18581 +       vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18582 +
18583 +       return 0;
18584 +}
18585 +
18586 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18587 +{
18588 +       struct vcmd_ctx_caps_v1 vc_data;
18589 +
18590 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18591 +               return -EFAULT;
18592 +
18593 +       return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18594 +}
18595 +
18596 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18597 +{
18598 +       struct vcmd_bcaps vc_data;
18599 +       int ret;
18600 +
18601 +       ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18602 +       if (ret)
18603 +               return ret;
18604 +       vc_data.bmask = ~0ULL;
18605 +
18606 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18607 +               return -EFAULT;
18608 +       return 0;
18609 +}
18610 +
18611 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18612 +{
18613 +       struct vcmd_bcaps vc_data;
18614 +
18615 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18616 +               return -EFAULT;
18617 +
18618 +       return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18619 +}
18620 +
18621 +
18622 +int vc_get_umask(struct vx_info *vxi, void __user *data)
18623 +{
18624 +       struct vcmd_umask vc_data;
18625 +
18626 +       vc_data.umask = vxi->vx_umask;
18627 +       vc_data.mask = ~0ULL;
18628 +
18629 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18630 +               return -EFAULT;
18631 +       return 0;
18632 +}
18633 +
18634 +int vc_set_umask(struct vx_info *vxi, void __user *data)
18635 +{
18636 +       struct vcmd_umask vc_data;
18637 +
18638 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18639 +               return -EFAULT;
18640 +
18641 +       vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
18642 +               vc_data.umask, vc_data.mask);
18643 +       return 0;
18644 +}
18645 +
18646 +
18647 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18648 +{
18649 +       struct vcmd_badness_v0 vc_data;
18650 +
18651 +       vc_data.bias = vxi->vx_badness_bias;
18652 +
18653 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18654 +               return -EFAULT;
18655 +       return 0;
18656 +}
18657 +
18658 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18659 +{
18660 +       struct vcmd_badness_v0 vc_data;
18661 +
18662 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18663 +               return -EFAULT;
18664 +
18665 +       vxi->vx_badness_bias = vc_data.bias;
18666 +       return 0;
18667 +}
18668 +
18669 +#include <linux/module.h>
18670 +
18671 +EXPORT_SYMBOL_GPL(free_vx_info);
18672 +
18673 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/cvirt.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cvirt.c
18674 --- linux-2.6.35.2/kernel/vserver/cvirt.c       1970-01-01 01:00:00.000000000 +0100
18675 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cvirt.c 2010-08-02 17:05:06.000000000 +0200
18676 @@ -0,0 +1,304 @@
18677 +/*
18678 + *  linux/kernel/vserver/cvirt.c
18679 + *
18680 + *  Virtual Server: Context Virtualization
18681 + *
18682 + *  Copyright (C) 2004-2007  Herbert Pötzl
18683 + *
18684 + *  V0.01  broken out from limit.c
18685 + *  V0.02  added utsname stuff
18686 + *  V0.03  changed vcmds to vxi arg
18687 + *
18688 + */
18689 +
18690 +#include <linux/types.h>
18691 +#include <linux/utsname.h>
18692 +#include <linux/vs_cvirt.h>
18693 +#include <linux/vserver/switch.h>
18694 +#include <linux/vserver/cvirt_cmd.h>
18695 +
18696 +#include <asm/uaccess.h>
18697 +
18698 +
18699 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18700 +{
18701 +       struct vx_info *vxi = current_vx_info();
18702 +
18703 +       set_normalized_timespec(uptime,
18704 +               uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18705 +               uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18706 +       if (!idle)
18707 +               return;
18708 +       set_normalized_timespec(idle,
18709 +               idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18710 +               idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18711 +       return;
18712 +}
18713 +
18714 +uint64_t vx_idle_jiffies(void)
18715 +{
18716 +       return init_task.utime + init_task.stime;
18717 +}
18718 +
18719 +
18720 +
18721 +static inline uint32_t __update_loadavg(uint32_t load,
18722 +       int wsize, int delta, int n)
18723 +{
18724 +       unsigned long long calc, prev;
18725 +
18726 +       /* just set it to n */
18727 +       if (unlikely(delta >= wsize))
18728 +               return (n << FSHIFT);
18729 +
18730 +       calc = delta * n;
18731 +       calc <<= FSHIFT;
18732 +       prev = (wsize - delta);
18733 +       prev *= load;
18734 +       calc += prev;
18735 +       do_div(calc, wsize);
18736 +       return calc;
18737 +}
18738 +
18739 +
18740 +void vx_update_load(struct vx_info *vxi)
18741 +{
18742 +       uint32_t now, last, delta;
18743 +       unsigned int nr_running, nr_uninterruptible;
18744 +       unsigned int total;
18745 +       unsigned long flags;
18746 +
18747 +       spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18748 +
18749 +       now = jiffies;
18750 +       last = vxi->cvirt.load_last;
18751 +       delta = now - last;
18752 +
18753 +       if (delta < 5*HZ)
18754 +               goto out;
18755 +
18756 +       nr_running = atomic_read(&vxi->cvirt.nr_running);
18757 +       nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18758 +       total = nr_running + nr_uninterruptible;
18759 +
18760 +       vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18761 +               60*HZ, delta, total);
18762 +       vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18763 +               5*60*HZ, delta, total);
18764 +       vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18765 +               15*60*HZ, delta, total);
18766 +
18767 +       vxi->cvirt.load_last = now;
18768 +out:
18769 +       atomic_inc(&vxi->cvirt.load_updates);
18770 +       spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18771 +}
18772 +
18773 +
18774 +/*
18775 + * Commands to do_syslog:
18776 + *
18777 + *      0 -- Close the log.  Currently a NOP.
18778 + *      1 -- Open the log. Currently a NOP.
18779 + *      2 -- Read from the log.
18780 + *      3 -- Read all messages remaining in the ring buffer.
18781 + *      4 -- Read and clear all messages remaining in the ring buffer
18782 + *      5 -- Clear ring buffer.
18783 + *      6 -- Disable printk's to console
18784 + *      7 -- Enable printk's to console
18785 + *      8 -- Set level of messages printed to console
18786 + *      9 -- Return number of unread characters in the log buffer
18787 + *     10 -- Return size of the log buffer
18788 + */
18789 +int vx_do_syslog(int type, char __user *buf, int len)
18790 +{
18791 +       int error = 0;
18792 +       int do_clear = 0;
18793 +       struct vx_info *vxi = current_vx_info();
18794 +       struct _vx_syslog *log;
18795 +
18796 +       if (!vxi)
18797 +               return -EINVAL;
18798 +       log = &vxi->cvirt.syslog;
18799 +
18800 +       switch (type) {
18801 +       case 0:         /* Close log */
18802 +       case 1:         /* Open log */
18803 +               break;
18804 +       case 2:         /* Read from log */
18805 +               error = wait_event_interruptible(log->log_wait,
18806 +                       (log->log_start - log->log_end));
18807 +               if (error)
18808 +                       break;
18809 +               spin_lock_irq(&log->logbuf_lock);
18810 +               spin_unlock_irq(&log->logbuf_lock);
18811 +               break;
18812 +       case 4:         /* Read/clear last kernel messages */
18813 +               do_clear = 1;
18814 +               /* fall through */
18815 +       case 3:         /* Read last kernel messages */
18816 +               return 0;
18817 +
18818 +       case 5:         /* Clear ring buffer */
18819 +               return 0;
18820 +
18821 +       case 6:         /* Disable logging to console */
18822 +       case 7:         /* Enable logging to console */
18823 +       case 8:         /* Set level of messages printed to console */
18824 +               break;
18825 +
18826 +       case 9:         /* Number of chars in the log buffer */
18827 +               return 0;
18828 +       case 10:        /* Size of the log buffer */
18829 +               return 0;
18830 +       default:
18831 +               error = -EINVAL;
18832 +               break;
18833 +       }
18834 +       return error;
18835 +}
18836 +
18837 +
18838 +/* virtual host info names */
18839 +
18840 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18841 +{
18842 +       struct nsproxy *nsproxy;
18843 +       struct uts_namespace *uts;
18844 +
18845 +       if (id == VHIN_CONTEXT)
18846 +               return vxi->vx_name;
18847 +
18848 +       nsproxy = vxi->vx_nsproxy[0];
18849 +       if (!nsproxy)
18850 +               return NULL;
18851 +
18852 +       uts = nsproxy->uts_ns;
18853 +       if (!uts)
18854 +               return NULL;
18855 +
18856 +       switch (id) {
18857 +       case VHIN_SYSNAME:
18858 +               return uts->name.sysname;
18859 +       case VHIN_NODENAME:
18860 +               return uts->name.nodename;
18861 +       case VHIN_RELEASE:
18862 +               return uts->name.release;
18863 +       case VHIN_VERSION:
18864 +               return uts->name.version;
18865 +       case VHIN_MACHINE:
18866 +               return uts->name.machine;
18867 +       case VHIN_DOMAINNAME:
18868 +               return uts->name.domainname;
18869 +       default:
18870 +               return NULL;
18871 +       }
18872 +       return NULL;
18873 +}
18874 +
18875 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18876 +{
18877 +       struct vcmd_vhi_name_v0 vc_data;
18878 +       char *name;
18879 +
18880 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18881 +               return -EFAULT;
18882 +
18883 +       name = vx_vhi_name(vxi, vc_data.field);
18884 +       if (!name)
18885 +               return -EINVAL;
18886 +
18887 +       memcpy(name, vc_data.name, 65);
18888 +       return 0;
18889 +}
18890 +
18891 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18892 +{
18893 +       struct vcmd_vhi_name_v0 vc_data;
18894 +       char *name;
18895 +
18896 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18897 +               return -EFAULT;
18898 +
18899 +       name = vx_vhi_name(vxi, vc_data.field);
18900 +       if (!name)
18901 +               return -EINVAL;
18902 +
18903 +       memcpy(vc_data.name, name, 65);
18904 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18905 +               return -EFAULT;
18906 +       return 0;
18907 +}
18908 +
18909 +
18910 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18911 +{
18912 +       struct vcmd_virt_stat_v0 vc_data;
18913 +       struct _vx_cvirt *cvirt = &vxi->cvirt;
18914 +       struct timespec uptime;
18915 +
18916 +       do_posix_clock_monotonic_gettime(&uptime);
18917 +       set_normalized_timespec(&uptime,
18918 +               uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18919 +               uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18920 +
18921 +       vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18922 +       vc_data.uptime = timespec_to_ns(&uptime);
18923 +       vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18924 +       vc_data.nr_running = atomic_read(&cvirt->nr_running);
18925 +       vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18926 +       vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18927 +       vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18928 +       vc_data.load[0] = cvirt->load[0];
18929 +       vc_data.load[1] = cvirt->load[1];
18930 +       vc_data.load[2] = cvirt->load[2];
18931 +
18932 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18933 +               return -EFAULT;
18934 +       return 0;
18935 +}
18936 +
18937 +
18938 +#ifdef CONFIG_VSERVER_VTIME
18939 +
18940 +/* virtualized time base */
18941 +
18942 +void vx_gettimeofday(struct timeval *tv)
18943 +{
18944 +       struct vx_info *vxi;
18945 +
18946 +       do_gettimeofday(tv);
18947 +       if (!vx_flags(VXF_VIRT_TIME, 0))
18948 +               return;
18949 +
18950 +       vxi = current_vx_info();
18951 +       tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
18952 +       tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
18953 +
18954 +       if (tv->tv_usec >= USEC_PER_SEC) {
18955 +               tv->tv_sec++;
18956 +               tv->tv_usec -= USEC_PER_SEC;
18957 +       } else if (tv->tv_usec < 0) {
18958 +               tv->tv_sec--;
18959 +               tv->tv_usec += USEC_PER_SEC;
18960 +       }
18961 +}
18962 +
18963 +int vx_settimeofday(struct timespec *ts)
18964 +{
18965 +       struct timeval tv;
18966 +       struct vx_info *vxi;
18967 +
18968 +       if (!vx_flags(VXF_VIRT_TIME, 0))
18969 +               return do_settimeofday(ts);
18970 +
18971 +       do_gettimeofday(&tv);
18972 +       vxi = current_vx_info();
18973 +       vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
18974 +       vxi->cvirt.bias_tv.tv_usec =
18975 +               (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
18976 +       return 0;
18977 +}
18978 +
18979 +#endif
18980 +
18981 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/cvirt_init.h linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cvirt_init.h
18982 --- linux-2.6.35.2/kernel/vserver/cvirt_init.h  1970-01-01 01:00:00.000000000 +0100
18983 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cvirt_init.h    2010-08-02 17:05:06.000000000 +0200
18984 @@ -0,0 +1,69 @@
18985 +
18986 +
18987 +extern uint64_t vx_idle_jiffies(void);
18988 +
18989 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
18990 +{
18991 +       uint64_t idle_jiffies = vx_idle_jiffies();
18992 +       uint64_t nsuptime;
18993 +
18994 +       do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
18995 +       nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
18996 +               * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
18997 +       cvirt->bias_clock = nsec_to_clock_t(nsuptime);
18998 +       cvirt->bias_tv.tv_sec = 0;
18999 +       cvirt->bias_tv.tv_usec = 0;
19000 +
19001 +       jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19002 +       atomic_set(&cvirt->nr_threads, 0);
19003 +       atomic_set(&cvirt->nr_running, 0);
19004 +       atomic_set(&cvirt->nr_uninterruptible, 0);
19005 +       atomic_set(&cvirt->nr_onhold, 0);
19006 +
19007 +       spin_lock_init(&cvirt->load_lock);
19008 +       cvirt->load_last = jiffies;
19009 +       atomic_set(&cvirt->load_updates, 0);
19010 +       cvirt->load[0] = 0;
19011 +       cvirt->load[1] = 0;
19012 +       cvirt->load[2] = 0;
19013 +       atomic_set(&cvirt->total_forks, 0);
19014 +
19015 +       spin_lock_init(&cvirt->syslog.logbuf_lock);
19016 +       init_waitqueue_head(&cvirt->syslog.log_wait);
19017 +       cvirt->syslog.log_start = 0;
19018 +       cvirt->syslog.log_end = 0;
19019 +       cvirt->syslog.con_start = 0;
19020 +       cvirt->syslog.logged_chars = 0;
19021 +}
19022 +
19023 +static inline
19024 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19025 +{
19026 +       // cvirt_pc->cpustat = { 0 };
19027 +}
19028 +
19029 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19030 +{
19031 +       int value;
19032 +
19033 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19034 +               "!!! cvirt: %p[nr_threads] = %d on exit.",
19035 +               cvirt, value);
19036 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19037 +               "!!! cvirt: %p[nr_running] = %d on exit.",
19038 +               cvirt, value);
19039 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19040 +               "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19041 +               cvirt, value);
19042 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19043 +               "!!! cvirt: %p[nr_onhold] = %d on exit.",
19044 +               cvirt, value);
19045 +       return;
19046 +}
19047 +
19048 +static inline
19049 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19050 +{
19051 +       return;
19052 +}
19053 +
19054 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/cvirt_proc.h linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cvirt_proc.h
19055 --- linux-2.6.35.2/kernel/vserver/cvirt_proc.h  1970-01-01 01:00:00.000000000 +0100
19056 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/cvirt_proc.h    2010-08-02 17:05:06.000000000 +0200
19057 @@ -0,0 +1,135 @@
19058 +#ifndef _VX_CVIRT_PROC_H
19059 +#define _VX_CVIRT_PROC_H
19060 +
19061 +#include <linux/nsproxy.h>
19062 +#include <linux/mnt_namespace.h>
19063 +#include <linux/ipc_namespace.h>
19064 +#include <linux/utsname.h>
19065 +#include <linux/ipc.h>
19066 +
19067 +
19068 +static inline
19069 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19070 +{
19071 +       struct mnt_namespace *ns;
19072 +       struct uts_namespace *uts;
19073 +       struct ipc_namespace *ipc;
19074 +       struct path path;
19075 +       char *pstr, *root;
19076 +       int length = 0;
19077 +
19078 +       if (!nsproxy)
19079 +               goto out;
19080 +
19081 +       length += sprintf(buffer + length,
19082 +               "NSProxy:\t%p [%p,%p,%p]\n",
19083 +               nsproxy, nsproxy->mnt_ns,
19084 +               nsproxy->uts_ns, nsproxy->ipc_ns);
19085 +
19086 +       ns = nsproxy->mnt_ns;
19087 +       if (!ns)
19088 +               goto skip_ns;
19089 +
19090 +       pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19091 +       if (!pstr)
19092 +               goto skip_ns;
19093 +
19094 +       path.mnt = ns->root;
19095 +       path.dentry = ns->root->mnt_root;
19096 +       root = d_path(&path, pstr, PATH_MAX - 2);
19097 +       length += sprintf(buffer + length,
19098 +               "Namespace:\t%p [#%u]\n"
19099 +               "RootPath:\t%s\n",
19100 +               ns, atomic_read(&ns->count),
19101 +               root);
19102 +       kfree(pstr);
19103 +skip_ns:
19104 +
19105 +       uts = nsproxy->uts_ns;
19106 +       if (!uts)
19107 +               goto skip_uts;
19108 +
19109 +       length += sprintf(buffer + length,
19110 +               "SysName:\t%.*s\n"
19111 +               "NodeName:\t%.*s\n"
19112 +               "Release:\t%.*s\n"
19113 +               "Version:\t%.*s\n"
19114 +               "Machine:\t%.*s\n"
19115 +               "DomainName:\t%.*s\n",
19116 +               __NEW_UTS_LEN, uts->name.sysname,
19117 +               __NEW_UTS_LEN, uts->name.nodename,
19118 +               __NEW_UTS_LEN, uts->name.release,
19119 +               __NEW_UTS_LEN, uts->name.version,
19120 +               __NEW_UTS_LEN, uts->name.machine,
19121 +               __NEW_UTS_LEN, uts->name.domainname);
19122 +skip_uts:
19123 +
19124 +       ipc = nsproxy->ipc_ns;
19125 +       if (!ipc)
19126 +               goto skip_ipc;
19127 +
19128 +       length += sprintf(buffer + length,
19129 +               "SEMS:\t\t%d %d %d %d  %d\n"
19130 +               "MSG:\t\t%d %d %d\n"
19131 +               "SHM:\t\t%lu %lu  %d %d\n",
19132 +               ipc->sem_ctls[0], ipc->sem_ctls[1],
19133 +               ipc->sem_ctls[2], ipc->sem_ctls[3],
19134 +               ipc->used_sems,
19135 +               ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19136 +               (unsigned long)ipc->shm_ctlmax,
19137 +               (unsigned long)ipc->shm_ctlall,
19138 +               ipc->shm_ctlmni, ipc->shm_tot);
19139 +skip_ipc:
19140 +out:
19141 +       return length;
19142 +}
19143 +
19144 +
19145 +#include <linux/sched.h>
19146 +
19147 +#define LOAD_INT(x) ((x) >> FSHIFT)
19148 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19149 +
19150 +static inline
19151 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19152 +{
19153 +       int length = 0;
19154 +       int a, b, c;
19155 +
19156 +       length += sprintf(buffer + length,
19157 +               "BiasUptime:\t%lu.%02lu\n",
19158 +               (unsigned long)cvirt->bias_uptime.tv_sec,
19159 +               (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19160 +
19161 +       a = cvirt->load[0] + (FIXED_1 / 200);
19162 +       b = cvirt->load[1] + (FIXED_1 / 200);
19163 +       c = cvirt->load[2] + (FIXED_1 / 200);
19164 +       length += sprintf(buffer + length,
19165 +               "nr_threads:\t%d\n"
19166 +               "nr_running:\t%d\n"
19167 +               "nr_unintr:\t%d\n"
19168 +               "nr_onhold:\t%d\n"
19169 +               "load_updates:\t%d\n"
19170 +               "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19171 +               "total_forks:\t%d\n",
19172 +               atomic_read(&cvirt->nr_threads),
19173 +               atomic_read(&cvirt->nr_running),
19174 +               atomic_read(&cvirt->nr_uninterruptible),
19175 +               atomic_read(&cvirt->nr_onhold),
19176 +               atomic_read(&cvirt->load_updates),
19177 +               LOAD_INT(a), LOAD_FRAC(a),
19178 +               LOAD_INT(b), LOAD_FRAC(b),
19179 +               LOAD_INT(c), LOAD_FRAC(c),
19180 +               atomic_read(&cvirt->total_forks));
19181 +       return length;
19182 +}
19183 +
19184 +static inline
19185 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19186 +       char *buffer, int cpu)
19187 +{
19188 +       int length = 0;
19189 +       return length;
19190 +}
19191 +
19192 +#endif /* _VX_CVIRT_PROC_H */
19193 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/debug.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/debug.c
19194 --- linux-2.6.35.2/kernel/vserver/debug.c       1970-01-01 01:00:00.000000000 +0100
19195 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/debug.c 2010-08-02 17:05:06.000000000 +0200
19196 @@ -0,0 +1,32 @@
19197 +/*
19198 + *  kernel/vserver/debug.c
19199 + *
19200 + *  Copyright (C) 2005-2007 Herbert Pötzl
19201 + *
19202 + *  V0.01  vx_info dump support
19203 + *
19204 + */
19205 +
19206 +#include <linux/module.h>
19207 +
19208 +#include <linux/vserver/context.h>
19209 +
19210 +
19211 +void   dump_vx_info(struct vx_info *vxi, int level)
19212 +{
19213 +       printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19214 +               atomic_read(&vxi->vx_usecnt),
19215 +               atomic_read(&vxi->vx_tasks),
19216 +               vxi->vx_state);
19217 +       if (level > 0) {
19218 +               __dump_vx_limit(&vxi->limit);
19219 +               __dump_vx_sched(&vxi->sched);
19220 +               __dump_vx_cvirt(&vxi->cvirt);
19221 +               __dump_vx_cacct(&vxi->cacct);
19222 +       }
19223 +       printk("---\n");
19224 +}
19225 +
19226 +
19227 +EXPORT_SYMBOL_GPL(dump_vx_info);
19228 +
19229 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/device.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/device.c
19230 --- linux-2.6.35.2/kernel/vserver/device.c      1970-01-01 01:00:00.000000000 +0100
19231 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/device.c        2010-08-02 17:05:06.000000000 +0200
19232 @@ -0,0 +1,443 @@
19233 +/*
19234 + *  linux/kernel/vserver/device.c
19235 + *
19236 + *  Linux-VServer: Device Support
19237 + *
19238 + *  Copyright (C) 2006  Herbert Pötzl
19239 + *  Copyright (C) 2007  Daniel Hokka Zakrisson
19240 + *
19241 + *  V0.01  device mapping basics
19242 + *  V0.02  added defaults
19243 + *
19244 + */
19245 +
19246 +#include <linux/slab.h>
19247 +#include <linux/rcupdate.h>
19248 +#include <linux/fs.h>
19249 +#include <linux/namei.h>
19250 +#include <linux/hash.h>
19251 +
19252 +#include <asm/errno.h>
19253 +#include <asm/uaccess.h>
19254 +#include <linux/vserver/base.h>
19255 +#include <linux/vserver/debug.h>
19256 +#include <linux/vserver/context.h>
19257 +#include <linux/vserver/device.h>
19258 +#include <linux/vserver/device_cmd.h>
19259 +
19260 +
19261 +#define DMAP_HASH_BITS 4
19262 +
19263 +
19264 +struct vs_mapping {
19265 +       union {
19266 +               struct hlist_node hlist;
19267 +               struct list_head list;
19268 +       } u;
19269 +#define dm_hlist       u.hlist
19270 +#define dm_list                u.list
19271 +       xid_t xid;
19272 +       dev_t device;
19273 +       struct vx_dmap_target target;
19274 +};
19275 +
19276 +
19277 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19278 +
19279 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
19280 +
19281 +static struct vx_dmap_target dmap_defaults[2] = {
19282 +       { .flags = DATTR_OPEN },
19283 +       { .flags = DATTR_OPEN },
19284 +};
19285 +
19286 +
19287 +struct kmem_cache *dmap_cachep __read_mostly;
19288 +
19289 +int __init dmap_cache_init(void)
19290 +{
19291 +       dmap_cachep = kmem_cache_create("dmap_cache",
19292 +               sizeof(struct vs_mapping), 0,
19293 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19294 +       return 0;
19295 +}
19296 +
19297 +__initcall(dmap_cache_init);
19298 +
19299 +
19300 +static inline unsigned int __hashval(dev_t dev, int bits)
19301 +{
19302 +       return hash_long((unsigned long)dev, bits);
19303 +}
19304 +
19305 +
19306 +/*     __hash_mapping()
19307 + *     add the mapping to the hash table
19308 + */
19309 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19310 +{
19311 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19312 +       struct hlist_head *head, *hash = dmap_main_hash;
19313 +       int device = vdm->device;
19314 +
19315 +       spin_lock(hash_lock);
19316 +       vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19317 +               vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19318 +
19319 +       head = &hash[__hashval(device, DMAP_HASH_BITS)];
19320 +       hlist_add_head(&vdm->dm_hlist, head);
19321 +       spin_unlock(hash_lock);
19322 +}
19323 +
19324 +
19325 +static inline int __mode_to_default(umode_t mode)
19326 +{
19327 +       switch (mode) {
19328 +       case S_IFBLK:
19329 +               return 0;
19330 +       case S_IFCHR:
19331 +               return 1;
19332 +       default:
19333 +               BUG();
19334 +       }
19335 +}
19336 +
19337 +
19338 +/*     __set_default()
19339 + *     set a default
19340 + */
19341 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19342 +       struct vx_dmap_target *vdmt)
19343 +{
19344 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19345 +       spin_lock(hash_lock);
19346 +
19347 +       if (vxi)
19348 +               vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19349 +       else
19350 +               dmap_defaults[__mode_to_default(mode)] = *vdmt;
19351 +
19352 +
19353 +       spin_unlock(hash_lock);
19354 +
19355 +       vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19356 +                 vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19357 +}
19358 +
19359 +
19360 +/*     __remove_default()
19361 + *     remove a default
19362 + */
19363 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19364 +{
19365 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19366 +       spin_lock(hash_lock);
19367 +
19368 +       if (vxi)
19369 +               vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19370 +       else    /* remove == reset */
19371 +               dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19372 +
19373 +       spin_unlock(hash_lock);
19374 +       return 0;
19375 +}
19376 +
19377 +
19378 +/*     __find_mapping()
19379 + *     find a mapping in the hash table
19380 + *
19381 + *     caller must hold hash_lock
19382 + */
19383 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19384 +       struct vs_mapping **local, struct vs_mapping **global)
19385 +{
19386 +       struct hlist_head *hash = dmap_main_hash;
19387 +       struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19388 +       struct hlist_node *pos;
19389 +       struct vs_mapping *vdm;
19390 +
19391 +       *local = NULL;
19392 +       if (global)
19393 +               *global = NULL;
19394 +
19395 +       hlist_for_each(pos, head) {
19396 +               vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19397 +
19398 +               if ((vdm->device == device) &&
19399 +                       !((vdm->target.flags ^ mode) & S_IFMT)) {
19400 +                       if (vdm->xid == xid) {
19401 +                               *local = vdm;
19402 +                               return 1;
19403 +                       } else if (global && vdm->xid == 0)
19404 +                               *global = vdm;
19405 +               }
19406 +       }
19407 +
19408 +       if (global && *global)
19409 +               return 0;
19410 +       else
19411 +               return -ENOENT;
19412 +}
19413 +
19414 +
19415 +/*     __lookup_mapping()
19416 + *     find a mapping and store the result in target and flags
19417 + */
19418 +static inline int __lookup_mapping(struct vx_info *vxi,
19419 +       dev_t device, dev_t *target, int *flags, umode_t mode)
19420 +{
19421 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19422 +       struct vs_mapping *vdm, *global;
19423 +       struct vx_dmap_target *vdmt;
19424 +       int ret = 0;
19425 +       xid_t xid = vxi->vx_id;
19426 +       int index;
19427 +
19428 +       spin_lock(hash_lock);
19429 +       if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19430 +               ret = 1;
19431 +               vdmt = &vdm->target;
19432 +               goto found;
19433 +       }
19434 +
19435 +       index = __mode_to_default(mode);
19436 +       if (vxi && vxi->dmap.targets[index].flags) {
19437 +               ret = 2;
19438 +               vdmt = &vxi->dmap.targets[index];
19439 +       } else if (global) {
19440 +               ret = 3;
19441 +               vdmt = &global->target;
19442 +               goto found;
19443 +       } else {
19444 +               ret = 4;
19445 +               vdmt = &dmap_defaults[index];
19446 +       }
19447 +
19448 +found:
19449 +       if (target && (vdmt->flags & DATTR_REMAP))
19450 +               *target = vdmt->target;
19451 +       else if (target)
19452 +               *target = device;
19453 +       if (flags)
19454 +               *flags = vdmt->flags;
19455 +
19456 +       spin_unlock(hash_lock);
19457 +
19458 +       return ret;
19459 +}
19460 +
19461 +
19462 +/*     __remove_mapping()
19463 + *     remove a mapping from the hash table
19464 + */
19465 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19466 +       umode_t mode)
19467 +{
19468 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19469 +       struct vs_mapping *vdm = NULL;
19470 +       int ret = 0;
19471 +
19472 +       spin_lock(hash_lock);
19473 +
19474 +       ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19475 +               NULL);
19476 +       vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19477 +               vxi, vxi ? vxi->vx_id : 0, device, mode);
19478 +       if (ret < 0)
19479 +               goto out;
19480 +       hlist_del(&vdm->dm_hlist);
19481 +
19482 +out:
19483 +       spin_unlock(hash_lock);
19484 +       if (vdm)
19485 +               kmem_cache_free(dmap_cachep, vdm);
19486 +       return ret;
19487 +}
19488 +
19489 +
19490 +
19491 +int vs_map_device(struct vx_info *vxi,
19492 +       dev_t device, dev_t *target, umode_t mode)
19493 +{
19494 +       int ret, flags = DATTR_MASK;
19495 +
19496 +       if (!vxi) {
19497 +               if (target)
19498 +                       *target = device;
19499 +               goto out;
19500 +       }
19501 +       ret = __lookup_mapping(vxi, device, target, &flags, mode);
19502 +       vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19503 +               device, target ? *target : 0, flags, mode, ret);
19504 +out:
19505 +       return (flags & DATTR_MASK);
19506 +}
19507 +
19508 +
19509 +
19510 +static int do_set_mapping(struct vx_info *vxi,
19511 +       dev_t device, dev_t target, int flags, umode_t mode)
19512 +{
19513 +       if (device) {
19514 +               struct vs_mapping *new;
19515 +
19516 +               new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19517 +               if (!new)
19518 +                       return -ENOMEM;
19519 +
19520 +               INIT_HLIST_NODE(&new->dm_hlist);
19521 +               new->device = device;
19522 +               new->target.target = target;
19523 +               new->target.flags = flags | mode;
19524 +               new->xid = (vxi ? vxi->vx_id : 0);
19525 +
19526 +               vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19527 +               __hash_mapping(vxi, new);
19528 +       } else {
19529 +               struct vx_dmap_target new = {
19530 +                       .target = target,
19531 +                       .flags = flags | mode,
19532 +               };
19533 +               __set_default(vxi, mode, &new);
19534 +       }
19535 +       return 0;
19536 +}
19537 +
19538 +
19539 +static int do_unset_mapping(struct vx_info *vxi,
19540 +       dev_t device, dev_t target, int flags, umode_t mode)
19541 +{
19542 +       int ret = -EINVAL;
19543 +
19544 +       if (device) {
19545 +               ret = __remove_mapping(vxi, device, mode);
19546 +               if (ret < 0)
19547 +                       goto out;
19548 +       } else {
19549 +               ret = __remove_default(vxi, mode);
19550 +               if (ret < 0)
19551 +                       goto out;
19552 +       }
19553 +
19554 +out:
19555 +       return ret;
19556 +}
19557 +
19558 +
19559 +static inline int __user_device(const char __user *name, dev_t *dev,
19560 +       umode_t *mode)
19561 +{
19562 +       struct nameidata nd;
19563 +       int ret;
19564 +
19565 +       if (!name) {
19566 +               *dev = 0;
19567 +               return 0;
19568 +       }
19569 +       ret = user_lpath(name, &nd.path);
19570 +       if (ret)
19571 +               return ret;
19572 +       if (nd.path.dentry->d_inode) {
19573 +               *dev = nd.path.dentry->d_inode->i_rdev;
19574 +               *mode = nd.path.dentry->d_inode->i_mode;
19575 +       }
19576 +       path_put(&nd.path);
19577 +       return 0;
19578 +}
19579 +
19580 +static inline int __mapping_mode(dev_t device, dev_t target,
19581 +       umode_t device_mode, umode_t target_mode, umode_t *mode)
19582 +{
19583 +       if (device)
19584 +               *mode = device_mode & S_IFMT;
19585 +       else if (target)
19586 +               *mode = target_mode & S_IFMT;
19587 +       else
19588 +               return -EINVAL;
19589 +
19590 +       /* if both given, device and target mode have to match */
19591 +       if (device && target &&
19592 +               ((device_mode ^ target_mode) & S_IFMT))
19593 +               return -EINVAL;
19594 +       return 0;
19595 +}
19596 +
19597 +
19598 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19599 +       const char __user *target_path, int flags, int set)
19600 +{
19601 +       dev_t device = ~0, target = ~0;
19602 +       umode_t device_mode = 0, target_mode = 0, mode;
19603 +       int ret;
19604 +
19605 +       ret = __user_device(device_path, &device, &device_mode);
19606 +       if (ret)
19607 +               return ret;
19608 +       ret = __user_device(target_path, &target, &target_mode);
19609 +       if (ret)
19610 +               return ret;
19611 +
19612 +       ret = __mapping_mode(device, target,
19613 +               device_mode, target_mode, &mode);
19614 +       if (ret)
19615 +               return ret;
19616 +
19617 +       if (set)
19618 +               return do_set_mapping(vxi, device, target,
19619 +                       flags, mode);
19620 +       else
19621 +               return do_unset_mapping(vxi, device, target,
19622 +                       flags, mode);
19623 +}
19624 +
19625 +
19626 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19627 +{
19628 +       struct vcmd_set_mapping_v0 vc_data;
19629 +
19630 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19631 +               return -EFAULT;
19632 +
19633 +       return do_mapping(vxi, vc_data.device, vc_data.target,
19634 +               vc_data.flags, 1);
19635 +}
19636 +
19637 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19638 +{
19639 +       struct vcmd_set_mapping_v0 vc_data;
19640 +
19641 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19642 +               return -EFAULT;
19643 +
19644 +       return do_mapping(vxi, vc_data.device, vc_data.target,
19645 +               vc_data.flags, 0);
19646 +}
19647 +
19648 +
19649 +#ifdef CONFIG_COMPAT
19650 +
19651 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19652 +{
19653 +       struct vcmd_set_mapping_v0_x32 vc_data;
19654 +
19655 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19656 +               return -EFAULT;
19657 +
19658 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19659 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19660 +}
19661 +
19662 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19663 +{
19664 +       struct vcmd_set_mapping_v0_x32 vc_data;
19665 +
19666 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19667 +               return -EFAULT;
19668 +
19669 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19670 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19671 +}
19672 +
19673 +#endif /* CONFIG_COMPAT */
19674 +
19675 +
19676 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/dlimit.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/dlimit.c
19677 --- linux-2.6.35.2/kernel/vserver/dlimit.c      1970-01-01 01:00:00.000000000 +0100
19678 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/dlimit.c        2010-08-02 17:05:06.000000000 +0200
19679 @@ -0,0 +1,531 @@
19680 +/*
19681 + *  linux/kernel/vserver/dlimit.c
19682 + *
19683 + *  Virtual Server: Context Disk Limits
19684 + *
19685 + *  Copyright (C) 2004-2009  Herbert Pötzl
19686 + *
19687 + *  V0.01  initial version
19688 + *  V0.02  compat32 splitup
19689 + *  V0.03  extended interface
19690 + *
19691 + */
19692 +
19693 +#include <linux/statfs.h>
19694 +#include <linux/sched.h>
19695 +#include <linux/namei.h>
19696 +#include <linux/vs_tag.h>
19697 +#include <linux/vs_dlimit.h>
19698 +#include <linux/vserver/dlimit_cmd.h>
19699 +#include <linux/slab.h>
19700 +// #include <linux/gfp.h>
19701 +
19702 +#include <asm/uaccess.h>
19703 +
19704 +/*     __alloc_dl_info()
19705 +
19706 +       * allocate an initialized dl_info struct
19707 +       * doesn't make it visible (hash)                        */
19708 +
19709 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19710 +{
19711 +       struct dl_info *new = NULL;
19712 +
19713 +       vxdprintk(VXD_CBIT(dlim, 5),
19714 +               "alloc_dl_info(%p,%d)*", sb, tag);
19715 +
19716 +       /* would this benefit from a slab cache? */
19717 +       new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19718 +       if (!new)
19719 +               return 0;
19720 +
19721 +       memset(new, 0, sizeof(struct dl_info));
19722 +       new->dl_tag = tag;
19723 +       new->dl_sb = sb;
19724 +       INIT_RCU_HEAD(&new->dl_rcu);
19725 +       INIT_HLIST_NODE(&new->dl_hlist);
19726 +       spin_lock_init(&new->dl_lock);
19727 +       atomic_set(&new->dl_refcnt, 0);
19728 +       atomic_set(&new->dl_usecnt, 0);
19729 +
19730 +       /* rest of init goes here */
19731 +
19732 +       vxdprintk(VXD_CBIT(dlim, 4),
19733 +               "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19734 +       return new;
19735 +}
19736 +
19737 +/*     __dealloc_dl_info()
19738 +
19739 +       * final disposal of dl_info                             */
19740 +
19741 +static void __dealloc_dl_info(struct dl_info *dli)
19742 +{
19743 +       vxdprintk(VXD_CBIT(dlim, 4),
19744 +               "dealloc_dl_info(%p)", dli);
19745 +
19746 +       dli->dl_hlist.next = LIST_POISON1;
19747 +       dli->dl_tag = -1;
19748 +       dli->dl_sb = 0;
19749 +
19750 +       BUG_ON(atomic_read(&dli->dl_usecnt));
19751 +       BUG_ON(atomic_read(&dli->dl_refcnt));
19752 +
19753 +       kfree(dli);
19754 +}
19755 +
19756 +
19757 +/*     hash table for dl_info hash */
19758 +
19759 +#define DL_HASH_SIZE   13
19760 +
19761 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19762 +
19763 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19764 +
19765 +
19766 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19767 +{
19768 +       return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19769 +}
19770 +
19771 +
19772 +
19773 +/*     __hash_dl_info()
19774 +
19775 +       * add the dli to the global hash table
19776 +       * requires the hash_lock to be held                     */
19777 +
19778 +static inline void __hash_dl_info(struct dl_info *dli)
19779 +{
19780 +       struct hlist_head *head;
19781 +
19782 +       vxdprintk(VXD_CBIT(dlim, 6),
19783 +               "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19784 +       get_dl_info(dli);
19785 +       head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19786 +       hlist_add_head_rcu(&dli->dl_hlist, head);
19787 +}
19788 +
19789 +/*     __unhash_dl_info()
19790 +
19791 +       * remove the dli from the global hash table
19792 +       * requires the hash_lock to be held                     */
19793 +
19794 +static inline void __unhash_dl_info(struct dl_info *dli)
19795 +{
19796 +       vxdprintk(VXD_CBIT(dlim, 6),
19797 +               "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19798 +       hlist_del_rcu(&dli->dl_hlist);
19799 +       put_dl_info(dli);
19800 +}
19801 +
19802 +
19803 +/*     __lookup_dl_info()
19804 +
19805 +       * requires the rcu_read_lock()
19806 +       * doesn't increment the dl_refcnt                       */
19807 +
19808 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19809 +{
19810 +       struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19811 +       struct hlist_node *pos;
19812 +       struct dl_info *dli;
19813 +
19814 +       hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19815 +
19816 +               if (dli->dl_tag == tag && dli->dl_sb == sb) {
19817 +                       return dli;
19818 +               }
19819 +       }
19820 +       return NULL;
19821 +}
19822 +
19823 +
19824 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19825 +{
19826 +       struct dl_info *dli;
19827 +
19828 +       rcu_read_lock();
19829 +       dli = get_dl_info(__lookup_dl_info(sb, tag));
19830 +       vxdprintk(VXD_CBIT(dlim, 7),
19831 +               "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19832 +       rcu_read_unlock();
19833 +       return dli;
19834 +}
19835 +
19836 +void rcu_free_dl_info(struct rcu_head *head)
19837 +{
19838 +       struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19839 +       int usecnt, refcnt;
19840 +
19841 +       BUG_ON(!dli || !head);
19842 +
19843 +       usecnt = atomic_read(&dli->dl_usecnt);
19844 +       BUG_ON(usecnt < 0);
19845 +
19846 +       refcnt = atomic_read(&dli->dl_refcnt);
19847 +       BUG_ON(refcnt < 0);
19848 +
19849 +       vxdprintk(VXD_CBIT(dlim, 3),
19850 +               "rcu_free_dl_info(%p)", dli);
19851 +       if (!usecnt)
19852 +               __dealloc_dl_info(dli);
19853 +       else
19854 +               printk("!!! rcu didn't free\n");
19855 +}
19856 +
19857 +
19858 +
19859 +
19860 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19861 +       uint32_t flags, int add)
19862 +{
19863 +       struct path path;
19864 +       int ret;
19865 +
19866 +       ret = user_lpath(name, &path);
19867 +       if (!ret) {
19868 +               struct super_block *sb;
19869 +               struct dl_info *dli;
19870 +
19871 +               ret = -EINVAL;
19872 +               if (!path.dentry->d_inode)
19873 +                       goto out_release;
19874 +               if (!(sb = path.dentry->d_inode->i_sb))
19875 +                       goto out_release;
19876 +
19877 +               if (add) {
19878 +                       dli = __alloc_dl_info(sb, id);
19879 +                       spin_lock(&dl_info_hash_lock);
19880 +
19881 +                       ret = -EEXIST;
19882 +                       if (__lookup_dl_info(sb, id))
19883 +                               goto out_unlock;
19884 +                       __hash_dl_info(dli);
19885 +                       dli = NULL;
19886 +               } else {
19887 +                       spin_lock(&dl_info_hash_lock);
19888 +                       dli = __lookup_dl_info(sb, id);
19889 +
19890 +                       ret = -ESRCH;
19891 +                       if (!dli)
19892 +                               goto out_unlock;
19893 +                       __unhash_dl_info(dli);
19894 +               }
19895 +               ret = 0;
19896 +       out_unlock:
19897 +               spin_unlock(&dl_info_hash_lock);
19898 +               if (add && dli)
19899 +                       __dealloc_dl_info(dli);
19900 +       out_release:
19901 +               path_put(&path);
19902 +       }
19903 +       return ret;
19904 +}
19905 +
19906 +int vc_add_dlimit(uint32_t id, void __user *data)
19907 +{
19908 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
19909 +
19910 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19911 +               return -EFAULT;
19912 +
19913 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19914 +}
19915 +
19916 +int vc_rem_dlimit(uint32_t id, void __user *data)
19917 +{
19918 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
19919 +
19920 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19921 +               return -EFAULT;
19922 +
19923 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19924 +}
19925 +
19926 +#ifdef CONFIG_COMPAT
19927 +
19928 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19929 +{
19930 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19931 +
19932 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19933 +               return -EFAULT;
19934 +
19935 +       return do_addrem_dlimit(id,
19936 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19937 +}
19938 +
19939 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19940 +{
19941 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19942 +
19943 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19944 +               return -EFAULT;
19945 +
19946 +       return do_addrem_dlimit(id,
19947 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19948 +}
19949 +
19950 +#endif /* CONFIG_COMPAT */
19951 +
19952 +
19953 +static inline
19954 +int do_set_dlimit(uint32_t id, const char __user *name,
19955 +       uint32_t space_used, uint32_t space_total,
19956 +       uint32_t inodes_used, uint32_t inodes_total,
19957 +       uint32_t reserved, uint32_t flags)
19958 +{
19959 +       struct path path;
19960 +       int ret;
19961 +
19962 +       ret = user_lpath(name, &path);
19963 +       if (!ret) {
19964 +               struct super_block *sb;
19965 +               struct dl_info *dli;
19966 +
19967 +               ret = -EINVAL;
19968 +               if (!path.dentry->d_inode)
19969 +                       goto out_release;
19970 +               if (!(sb = path.dentry->d_inode->i_sb))
19971 +                       goto out_release;
19972 +
19973 +               /* sanity checks */
19974 +               if ((reserved != CDLIM_KEEP &&
19975 +                       reserved > 100) ||
19976 +                       (inodes_used != CDLIM_KEEP &&
19977 +                       inodes_used > inodes_total) ||
19978 +                       (space_used != CDLIM_KEEP &&
19979 +                       space_used > space_total))
19980 +                       goto out_release;
19981 +
19982 +               ret = -ESRCH;
19983 +               dli = locate_dl_info(sb, id);
19984 +               if (!dli)
19985 +                       goto out_release;
19986 +
19987 +               spin_lock(&dli->dl_lock);
19988 +
19989 +               if (inodes_used != CDLIM_KEEP)
19990 +                       dli->dl_inodes_used = inodes_used;
19991 +               if (inodes_total != CDLIM_KEEP)
19992 +                       dli->dl_inodes_total = inodes_total;
19993 +               if (space_used != CDLIM_KEEP)
19994 +                       dli->dl_space_used = dlimit_space_32to64(
19995 +                               space_used, flags, DLIMS_USED);
19996 +
19997 +               if (space_total == CDLIM_INFINITY)
19998 +                       dli->dl_space_total = DLIM_INFINITY;
19999 +               else if (space_total != CDLIM_KEEP)
20000 +                       dli->dl_space_total = dlimit_space_32to64(
20001 +                               space_total, flags, DLIMS_TOTAL);
20002 +
20003 +               if (reserved != CDLIM_KEEP)
20004 +                       dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20005 +
20006 +               spin_unlock(&dli->dl_lock);
20007 +
20008 +               put_dl_info(dli);
20009 +               ret = 0;
20010 +
20011 +       out_release:
20012 +               path_put(&path);
20013 +       }
20014 +       return ret;
20015 +}
20016 +
20017 +int vc_set_dlimit(uint32_t id, void __user *data)
20018 +{
20019 +       struct vcmd_ctx_dlimit_v0 vc_data;
20020 +
20021 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20022 +               return -EFAULT;
20023 +
20024 +       return do_set_dlimit(id, vc_data.name,
20025 +               vc_data.space_used, vc_data.space_total,
20026 +               vc_data.inodes_used, vc_data.inodes_total,
20027 +               vc_data.reserved, vc_data.flags);
20028 +}
20029 +
20030 +#ifdef CONFIG_COMPAT
20031 +
20032 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20033 +{
20034 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20035 +
20036 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20037 +               return -EFAULT;
20038 +
20039 +       return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20040 +               vc_data.space_used, vc_data.space_total,
20041 +               vc_data.inodes_used, vc_data.inodes_total,
20042 +               vc_data.reserved, vc_data.flags);
20043 +}
20044 +
20045 +#endif /* CONFIG_COMPAT */
20046 +
20047 +
20048 +static inline
20049 +int do_get_dlimit(uint32_t id, const char __user *name,
20050 +       uint32_t *space_used, uint32_t *space_total,
20051 +       uint32_t *inodes_used, uint32_t *inodes_total,
20052 +       uint32_t *reserved, uint32_t *flags)
20053 +{
20054 +       struct path path;
20055 +       int ret;
20056 +
20057 +       ret = user_lpath(name, &path);
20058 +       if (!ret) {
20059 +               struct super_block *sb;
20060 +               struct dl_info *dli;
20061 +
20062 +               ret = -EINVAL;
20063 +               if (!path.dentry->d_inode)
20064 +                       goto out_release;
20065 +               if (!(sb = path.dentry->d_inode->i_sb))
20066 +                       goto out_release;
20067 +
20068 +               ret = -ESRCH;
20069 +               dli = locate_dl_info(sb, id);
20070 +               if (!dli)
20071 +                       goto out_release;
20072 +
20073 +               spin_lock(&dli->dl_lock);
20074 +               *inodes_used = dli->dl_inodes_used;
20075 +               *inodes_total = dli->dl_inodes_total;
20076 +
20077 +               *space_used = dlimit_space_64to32(
20078 +                       dli->dl_space_used, flags, DLIMS_USED);
20079 +
20080 +               if (dli->dl_space_total == DLIM_INFINITY)
20081 +                       *space_total = CDLIM_INFINITY;
20082 +               else
20083 +                       *space_total = dlimit_space_64to32(
20084 +                               dli->dl_space_total, flags, DLIMS_TOTAL);
20085 +
20086 +               *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20087 +               spin_unlock(&dli->dl_lock);
20088 +
20089 +               put_dl_info(dli);
20090 +               ret = -EFAULT;
20091 +
20092 +               ret = 0;
20093 +       out_release:
20094 +               path_put(&path);
20095 +       }
20096 +       return ret;
20097 +}
20098 +
20099 +
20100 +int vc_get_dlimit(uint32_t id, void __user *data)
20101 +{
20102 +       struct vcmd_ctx_dlimit_v0 vc_data;
20103 +       int ret;
20104 +
20105 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20106 +               return -EFAULT;
20107 +
20108 +       ret = do_get_dlimit(id, vc_data.name,
20109 +               &vc_data.space_used, &vc_data.space_total,
20110 +               &vc_data.inodes_used, &vc_data.inodes_total,
20111 +               &vc_data.reserved, &vc_data.flags);
20112 +       if (ret)
20113 +               return ret;
20114 +
20115 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20116 +               return -EFAULT;
20117 +       return 0;
20118 +}
20119 +
20120 +#ifdef CONFIG_COMPAT
20121 +
20122 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20123 +{
20124 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20125 +       int ret;
20126 +
20127 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20128 +               return -EFAULT;
20129 +
20130 +       ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20131 +               &vc_data.space_used, &vc_data.space_total,
20132 +               &vc_data.inodes_used, &vc_data.inodes_total,
20133 +               &vc_data.reserved, &vc_data.flags);
20134 +       if (ret)
20135 +               return ret;
20136 +
20137 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20138 +               return -EFAULT;
20139 +       return 0;
20140 +}
20141 +
20142 +#endif /* CONFIG_COMPAT */
20143 +
20144 +
20145 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20146 +{
20147 +       struct dl_info *dli;
20148 +       __u64 blimit, bfree, bavail;
20149 +       __u32 ifree;
20150 +
20151 +       dli = locate_dl_info(sb, dx_current_tag());
20152 +       if (!dli)
20153 +               return;
20154 +
20155 +       spin_lock(&dli->dl_lock);
20156 +       if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20157 +               goto no_ilim;
20158 +
20159 +       /* reduce max inodes available to limit */
20160 +       if (buf->f_files > dli->dl_inodes_total)
20161 +               buf->f_files = dli->dl_inodes_total;
20162 +
20163 +       ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20164 +       /* reduce free inodes to min */
20165 +       if (ifree < buf->f_ffree)
20166 +               buf->f_ffree = ifree;
20167 +
20168 +no_ilim:
20169 +       if (dli->dl_space_total == DLIM_INFINITY)
20170 +               goto no_blim;
20171 +
20172 +       blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20173 +
20174 +       if (dli->dl_space_total < dli->dl_space_used)
20175 +               bfree = 0;
20176 +       else
20177 +               bfree = (dli->dl_space_total - dli->dl_space_used)
20178 +                       >> sb->s_blocksize_bits;
20179 +
20180 +       bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20181 +       if (bavail < dli->dl_space_used)
20182 +               bavail = 0;
20183 +       else
20184 +               bavail = (bavail - dli->dl_space_used)
20185 +                       >> sb->s_blocksize_bits;
20186 +
20187 +       /* reduce max space available to limit */
20188 +       if (buf->f_blocks > blimit)
20189 +               buf->f_blocks = blimit;
20190 +
20191 +       /* reduce free space to min */
20192 +       if (bfree < buf->f_bfree)
20193 +               buf->f_bfree = bfree;
20194 +
20195 +       /* reduce avail space to min */
20196 +       if (bavail < buf->f_bavail)
20197 +               buf->f_bavail = bavail;
20198 +
20199 +no_blim:
20200 +       spin_unlock(&dli->dl_lock);
20201 +       put_dl_info(dli);
20202 +
20203 +       return;
20204 +}
20205 +
20206 +#include <linux/module.h>
20207 +
20208 +EXPORT_SYMBOL_GPL(locate_dl_info);
20209 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20210 +
20211 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/helper.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/helper.c
20212 --- linux-2.6.35.2/kernel/vserver/helper.c      1970-01-01 01:00:00.000000000 +0100
20213 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/helper.c        2010-08-02 17:05:06.000000000 +0200
20214 @@ -0,0 +1,223 @@
20215 +/*
20216 + *  linux/kernel/vserver/helper.c
20217 + *
20218 + *  Virtual Context Support
20219 + *
20220 + *  Copyright (C) 2004-2007  Herbert Pötzl
20221 + *
20222 + *  V0.01  basic helper
20223 + *
20224 + */
20225 +
20226 +#include <linux/kmod.h>
20227 +#include <linux/reboot.h>
20228 +#include <linux/vs_context.h>
20229 +#include <linux/vs_network.h>
20230 +#include <linux/vserver/signal.h>
20231 +
20232 +
20233 +char vshelper_path[255] = "/sbin/vshelper";
20234 +
20235 +
20236 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20237 +{
20238 +       int ret;
20239 +
20240 +       if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20241 +               printk( KERN_WARNING
20242 +                       "%s: (%s %s) returned %s with %d\n",
20243 +                       name, argv[1], argv[2],
20244 +                       sync ? "sync" : "async", ret);
20245 +       }
20246 +       vxdprintk(VXD_CBIT(switch, 4),
20247 +               "%s: (%s %s) returned %s with %d",
20248 +               name, argv[1], argv[2], sync ? "sync" : "async", ret);
20249 +       return ret;
20250 +}
20251 +
20252 +/*
20253 + *      vshelper path is set via /proc/sys
20254 + *      invoked by vserver sys_reboot(), with
20255 + *      the following arguments
20256 + *
20257 + *      argv [0] = vshelper_path;
20258 + *      argv [1] = action: "restart", "halt", "poweroff", ...
20259 + *      argv [2] = context identifier
20260 + *
20261 + *      envp [*] = type-specific parameters
20262 + */
20263 +
20264 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20265 +{
20266 +       char id_buf[8], cmd_buf[16];
20267 +       char uid_buf[16], pid_buf[16];
20268 +       int ret;
20269 +
20270 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20271 +       char *envp[] = {"HOME=/", "TERM=linux",
20272 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20273 +                       uid_buf, pid_buf, cmd_buf, 0};
20274 +
20275 +       if (vx_info_state(vxi, VXS_HELPER))
20276 +               return -EAGAIN;
20277 +       vxi->vx_state |= VXS_HELPER;
20278 +
20279 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20280 +
20281 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20282 +       snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20283 +       snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20284 +
20285 +       switch (cmd) {
20286 +       case LINUX_REBOOT_CMD_RESTART:
20287 +               argv[1] = "restart";
20288 +               break;
20289 +
20290 +       case LINUX_REBOOT_CMD_HALT:
20291 +               argv[1] = "halt";
20292 +               break;
20293 +
20294 +       case LINUX_REBOOT_CMD_POWER_OFF:
20295 +               argv[1] = "poweroff";
20296 +               break;
20297 +
20298 +       case LINUX_REBOOT_CMD_SW_SUSPEND:
20299 +               argv[1] = "swsusp";
20300 +               break;
20301 +
20302 +       case LINUX_REBOOT_CMD_OOM:
20303 +               argv[1] = "oom";
20304 +               break;
20305 +
20306 +       default:
20307 +               vxi->vx_state &= ~VXS_HELPER;
20308 +               return 0;
20309 +       }
20310 +
20311 +       ret = do_vshelper(vshelper_path, argv, envp, 0);
20312 +       vxi->vx_state &= ~VXS_HELPER;
20313 +       __wakeup_vx_info(vxi);
20314 +       return (ret) ? -EPERM : 0;
20315 +}
20316 +
20317 +
20318 +long vs_reboot(unsigned int cmd, void __user *arg)
20319 +{
20320 +       struct vx_info *vxi = current_vx_info();
20321 +       long ret = 0;
20322 +
20323 +       vxdprintk(VXD_CBIT(misc, 5),
20324 +               "vs_reboot(%p[#%d],%u)",
20325 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20326 +
20327 +       ret = vs_reboot_helper(vxi, cmd, arg);
20328 +       if (ret)
20329 +               return ret;
20330 +
20331 +       vxi->reboot_cmd = cmd;
20332 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20333 +               switch (cmd) {
20334 +               case LINUX_REBOOT_CMD_RESTART:
20335 +               case LINUX_REBOOT_CMD_HALT:
20336 +               case LINUX_REBOOT_CMD_POWER_OFF:
20337 +                       vx_info_kill(vxi, 0, SIGKILL);
20338 +                       vx_info_kill(vxi, 1, SIGKILL);
20339 +               default:
20340 +                       break;
20341 +               }
20342 +       }
20343 +       return 0;
20344 +}
20345 +
20346 +long vs_oom_action(unsigned int cmd)
20347 +{
20348 +       struct vx_info *vxi = current_vx_info();
20349 +       long ret = 0;
20350 +
20351 +       vxdprintk(VXD_CBIT(misc, 5),
20352 +               "vs_oom_action(%p[#%d],%u)",
20353 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20354 +
20355 +       ret = vs_reboot_helper(vxi, cmd, NULL);
20356 +       if (ret)
20357 +               return ret;
20358 +
20359 +       vxi->reboot_cmd = cmd;
20360 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20361 +               vx_info_kill(vxi, 0, SIGKILL);
20362 +               vx_info_kill(vxi, 1, SIGKILL);
20363 +       }
20364 +       return 0;
20365 +}
20366 +
20367 +/*
20368 + *      argv [0] = vshelper_path;
20369 + *      argv [1] = action: "startup", "shutdown"
20370 + *      argv [2] = context identifier
20371 + *
20372 + *      envp [*] = type-specific parameters
20373 + */
20374 +
20375 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20376 +{
20377 +       char id_buf[8], cmd_buf[16];
20378 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20379 +       char *envp[] = {"HOME=/", "TERM=linux",
20380 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20381 +
20382 +       if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20383 +               return 0;
20384 +
20385 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20386 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20387 +
20388 +       switch (cmd) {
20389 +       case VSC_STARTUP:
20390 +               argv[1] = "startup";
20391 +               break;
20392 +       case VSC_SHUTDOWN:
20393 +               argv[1] = "shutdown";
20394 +               break;
20395 +       default:
20396 +               return 0;
20397 +       }
20398 +
20399 +       return do_vshelper(vshelper_path, argv, envp, 1);
20400 +}
20401 +
20402 +
20403 +/*
20404 + *      argv [0] = vshelper_path;
20405 + *      argv [1] = action: "netup", "netdown"
20406 + *      argv [2] = context identifier
20407 + *
20408 + *      envp [*] = type-specific parameters
20409 + */
20410 +
20411 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20412 +{
20413 +       char id_buf[8], cmd_buf[16];
20414 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20415 +       char *envp[] = {"HOME=/", "TERM=linux",
20416 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20417 +
20418 +       if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20419 +               return 0;
20420 +
20421 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20422 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20423 +
20424 +       switch (cmd) {
20425 +       case VSC_NETUP:
20426 +               argv[1] = "netup";
20427 +               break;
20428 +       case VSC_NETDOWN:
20429 +               argv[1] = "netdown";
20430 +               break;
20431 +       default:
20432 +               return 0;
20433 +       }
20434 +
20435 +       return do_vshelper(vshelper_path, argv, envp, 1);
20436 +}
20437 +
20438 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/history.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/history.c
20439 --- linux-2.6.35.2/kernel/vserver/history.c     1970-01-01 01:00:00.000000000 +0100
20440 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/history.c       2010-08-02 17:05:06.000000000 +0200
20441 @@ -0,0 +1,258 @@
20442 +/*
20443 + *  kernel/vserver/history.c
20444 + *
20445 + *  Virtual Context History Backtrace
20446 + *
20447 + *  Copyright (C) 2004-2007  Herbert Pötzl
20448 + *
20449 + *  V0.01  basic structure
20450 + *  V0.02  hash/unhash and trace
20451 + *  V0.03  preemption fixes
20452 + *
20453 + */
20454 +
20455 +#include <linux/module.h>
20456 +#include <asm/uaccess.h>
20457 +
20458 +#include <linux/vserver/context.h>
20459 +#include <linux/vserver/debug.h>
20460 +#include <linux/vserver/debug_cmd.h>
20461 +#include <linux/vserver/history.h>
20462 +
20463 +
20464 +#ifdef CONFIG_VSERVER_HISTORY
20465 +#define VXH_SIZE       CONFIG_VSERVER_HISTORY_SIZE
20466 +#else
20467 +#define VXH_SIZE       64
20468 +#endif
20469 +
20470 +struct _vx_history {
20471 +       unsigned int counter;
20472 +
20473 +       struct _vx_hist_entry entry[VXH_SIZE + 1];
20474 +};
20475 +
20476 +
20477 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20478 +
20479 +unsigned volatile int vxh_active = 1;
20480 +
20481 +static atomic_t sequence = ATOMIC_INIT(0);
20482 +
20483 +
20484 +/*     vxh_advance()
20485 +
20486 +       * requires disabled preemption                          */
20487 +
20488 +struct _vx_hist_entry *vxh_advance(void *loc)
20489 +{
20490 +       unsigned int cpu = smp_processor_id();
20491 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20492 +       struct _vx_hist_entry *entry;
20493 +       unsigned int index;
20494 +
20495 +       index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20496 +       entry = &hist->entry[index];
20497 +
20498 +       entry->seq = atomic_inc_return(&sequence);
20499 +       entry->loc = loc;
20500 +       return entry;
20501 +}
20502 +
20503 +EXPORT_SYMBOL_GPL(vxh_advance);
20504 +
20505 +
20506 +#define VXH_LOC_FMTS   "(#%04x,*%d):%p"
20507 +
20508 +#define VXH_LOC_ARGS(e)        (e)->seq, cpu, (e)->loc
20509 +
20510 +
20511 +#define VXH_VXI_FMTS   "%p[#%d,%d.%d]"
20512 +
20513 +#define VXH_VXI_ARGS(e)        (e)->vxi.ptr,                           \
20514 +                       (e)->vxi.ptr ? (e)->vxi.xid : 0,        \
20515 +                       (e)->vxi.ptr ? (e)->vxi.usecnt : 0,     \
20516 +                       (e)->vxi.ptr ? (e)->vxi.tasks : 0
20517 +
20518 +void   vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20519 +{
20520 +       switch (e->type) {
20521 +       case VXH_THROW_OOPS:
20522 +               printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20523 +               break;
20524 +
20525 +       case VXH_GET_VX_INFO:
20526 +       case VXH_PUT_VX_INFO:
20527 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20528 +                       VXH_LOC_ARGS(e),
20529 +                       (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20530 +                       VXH_VXI_ARGS(e));
20531 +               break;
20532 +
20533 +       case VXH_INIT_VX_INFO:
20534 +       case VXH_SET_VX_INFO:
20535 +       case VXH_CLR_VX_INFO:
20536 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20537 +                       VXH_LOC_ARGS(e),
20538 +                       (e->type == VXH_INIT_VX_INFO) ? "init" :
20539 +                       ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20540 +                       VXH_VXI_ARGS(e), e->sc.data);
20541 +               break;
20542 +
20543 +       case VXH_CLAIM_VX_INFO:
20544 +       case VXH_RELEASE_VX_INFO:
20545 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20546 +                       VXH_LOC_ARGS(e),
20547 +                       (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20548 +                       VXH_VXI_ARGS(e), e->sc.data);
20549 +               break;
20550 +
20551 +       case VXH_ALLOC_VX_INFO:
20552 +       case VXH_DEALLOC_VX_INFO:
20553 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20554 +                       VXH_LOC_ARGS(e),
20555 +                       (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20556 +                       VXH_VXI_ARGS(e));
20557 +               break;
20558 +
20559 +       case VXH_HASH_VX_INFO:
20560 +       case VXH_UNHASH_VX_INFO:
20561 +               printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20562 +                       VXH_LOC_ARGS(e),
20563 +                       (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20564 +                       VXH_VXI_ARGS(e));
20565 +               break;
20566 +
20567 +       case VXH_LOC_VX_INFO:
20568 +       case VXH_LOOKUP_VX_INFO:
20569 +       case VXH_CREATE_VX_INFO:
20570 +               printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20571 +                       VXH_LOC_ARGS(e),
20572 +                       (e->type == VXH_CREATE_VX_INFO) ? "create" :
20573 +                       ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20574 +                       e->ll.arg, VXH_VXI_ARGS(e));
20575 +               break;
20576 +       }
20577 +}
20578 +
20579 +static void __vxh_dump_history(void)
20580 +{
20581 +       unsigned int i, cpu;
20582 +
20583 +       printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20584 +               atomic_read(&sequence), NR_CPUS);
20585 +
20586 +       for (i = 0; i < VXH_SIZE; i++) {
20587 +               for_each_online_cpu(cpu) {
20588 +                       struct _vx_history *hist =
20589 +                               &per_cpu(vx_history_buffer, cpu);
20590 +                       unsigned int index = (hist->counter - i) % VXH_SIZE;
20591 +                       struct _vx_hist_entry *entry = &hist->entry[index];
20592 +
20593 +                       vxh_dump_entry(entry, cpu);
20594 +               }
20595 +       }
20596 +}
20597 +
20598 +void   vxh_dump_history(void)
20599 +{
20600 +       vxh_active = 0;
20601 +#ifdef CONFIG_SMP
20602 +       local_irq_enable();
20603 +       smp_send_stop();
20604 +       local_irq_disable();
20605 +#endif
20606 +       __vxh_dump_history();
20607 +}
20608 +
20609 +
20610 +/* vserver syscall commands below here */
20611 +
20612 +
20613 +int vc_dump_history(uint32_t id)
20614 +{
20615 +       vxh_active = 0;
20616 +       __vxh_dump_history();
20617 +       vxh_active = 1;
20618 +
20619 +       return 0;
20620 +}
20621 +
20622 +
20623 +int do_read_history(struct __user _vx_hist_entry *data,
20624 +       int cpu, uint32_t *index, uint32_t *count)
20625 +{
20626 +       int pos, ret = 0;
20627 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20628 +       int end = hist->counter;
20629 +       int start = end - VXH_SIZE + 2;
20630 +       int idx = *index;
20631 +
20632 +       /* special case: get current pos */
20633 +       if (!*count) {
20634 +               *index = end;
20635 +               return 0;
20636 +       }
20637 +
20638 +       /* have we lost some data? */
20639 +       if (idx < start)
20640 +               idx = start;
20641 +
20642 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20643 +               struct _vx_hist_entry *entry =
20644 +                       &hist->entry[idx % VXH_SIZE];
20645 +
20646 +               /* send entry to userspace */
20647 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20648 +               if (ret)
20649 +                       break;
20650 +       }
20651 +       /* save new index and count */
20652 +       *index = idx;
20653 +       *count = pos;
20654 +       return ret ? ret : (*index < end);
20655 +}
20656 +
20657 +int vc_read_history(uint32_t id, void __user *data)
20658 +{
20659 +       struct vcmd_read_history_v0 vc_data;
20660 +       int ret;
20661 +
20662 +       if (id >= NR_CPUS)
20663 +               return -EINVAL;
20664 +
20665 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20666 +               return -EFAULT;
20667 +
20668 +       ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20669 +               id, &vc_data.index, &vc_data.count);
20670 +
20671 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20672 +               return -EFAULT;
20673 +       return ret;
20674 +}
20675 +
20676 +#ifdef CONFIG_COMPAT
20677 +
20678 +int vc_read_history_x32(uint32_t id, void __user *data)
20679 +{
20680 +       struct vcmd_read_history_v0_x32 vc_data;
20681 +       int ret;
20682 +
20683 +       if (id >= NR_CPUS)
20684 +               return -EINVAL;
20685 +
20686 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20687 +               return -EFAULT;
20688 +
20689 +       ret = do_read_history((struct __user _vx_hist_entry *)
20690 +               compat_ptr(vc_data.data_ptr),
20691 +               id, &vc_data.index, &vc_data.count);
20692 +
20693 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20694 +               return -EFAULT;
20695 +       return ret;
20696 +}
20697 +
20698 +#endif /* CONFIG_COMPAT */
20699 +
20700 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/inet.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/inet.c
20701 --- linux-2.6.35.2/kernel/vserver/inet.c        1970-01-01 01:00:00.000000000 +0100
20702 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/inet.c  2010-08-02 18:54:03.000000000 +0200
20703 @@ -0,0 +1,224 @@
20704 +
20705 +#include <linux/in.h>
20706 +#include <linux/inetdevice.h>
20707 +#include <linux/vs_inet.h>
20708 +#include <linux/vs_inet6.h>
20709 +#include <linux/vserver/debug.h>
20710 +#include <net/route.h>
20711 +#include <net/addrconf.h>
20712 +
20713 +
20714 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20715 +{
20716 +       int ret = 0;
20717 +
20718 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
20719 +               ret = 1;
20720 +       else {
20721 +               struct nx_addr_v4 *ptr;
20722 +
20723 +               for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20724 +                       if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20725 +                               ret = 1;
20726 +                               break;
20727 +                       }
20728 +               }
20729 +       }
20730 +
20731 +       vxdprintk(VXD_CBIT(net, 2),
20732 +               "nx_v4_addr_conflict(%p,%p): %d",
20733 +               nxi1, nxi2, ret);
20734 +
20735 +       return ret;
20736 +}
20737 +
20738 +
20739 +#ifdef CONFIG_IPV6
20740 +
20741 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20742 +{
20743 +       int ret = 0;
20744 +
20745 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
20746 +               ret = 1;
20747 +       else {
20748 +               struct nx_addr_v6 *ptr;
20749 +
20750 +               for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20751 +                       if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20752 +                               ret = 1;
20753 +                               break;
20754 +                       }
20755 +               }
20756 +       }
20757 +
20758 +       vxdprintk(VXD_CBIT(net, 2),
20759 +               "nx_v6_addr_conflict(%p,%p): %d",
20760 +               nxi1, nxi2, ret);
20761 +
20762 +       return ret;
20763 +}
20764 +
20765 +#endif
20766 +
20767 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20768 +{
20769 +       struct in_device *in_dev;
20770 +       struct in_ifaddr **ifap;
20771 +       struct in_ifaddr *ifa;
20772 +       int ret = 0;
20773 +
20774 +       if (!dev)
20775 +               goto out;
20776 +       in_dev = in_dev_get(dev);
20777 +       if (!in_dev)
20778 +               goto out;
20779 +
20780 +       for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20781 +               ifap = &ifa->ifa_next) {
20782 +               if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20783 +                       ret = 1;
20784 +                       break;
20785 +               }
20786 +       }
20787 +       in_dev_put(in_dev);
20788 +out:
20789 +       return ret;
20790 +}
20791 +
20792 +
20793 +#ifdef CONFIG_IPV6
20794 +
20795 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20796 +{
20797 +       struct inet6_dev *in_dev;
20798 +       struct inet6_ifaddr *ifa;
20799 +       int ret = 0;
20800 +
20801 +       if (!dev)
20802 +               goto out;
20803 +       in_dev = in6_dev_get(dev);
20804 +       if (!in_dev)
20805 +               goto out;
20806 +
20807 +       // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20808 +       list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
20809 +               if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20810 +                       ret = 1;
20811 +                       break;
20812 +               }
20813 +       }
20814 +       in6_dev_put(in_dev);
20815 +out:
20816 +       return ret;
20817 +}
20818 +
20819 +#endif
20820 +
20821 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20822 +{
20823 +       int ret = 1;
20824 +
20825 +       if (!nxi)
20826 +               goto out;
20827 +       if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20828 +               goto out;
20829 +#ifdef CONFIG_IPV6
20830 +       ret = 2;
20831 +       if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20832 +               goto out;
20833 +#endif
20834 +       ret = 0;
20835 +out:
20836 +       vxdprintk(VXD_CBIT(net, 3),
20837 +               "dev_in_nx_info(%p,%p[#%d]) = %d",
20838 +               dev, nxi, nxi ? nxi->nx_id : 0, ret);
20839 +       return ret;
20840 +}
20841 +
20842 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20843 +       struct rtable **rp, struct flowi *fl)
20844 +{
20845 +       if (!nxi)
20846 +               return 0;
20847 +
20848 +       /* FIXME: handle lback only case */
20849 +       if (!NX_IPV4(nxi))
20850 +               return -EPERM;
20851 +
20852 +       vxdprintk(VXD_CBIT(net, 4),
20853 +               "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20854 +               nxi, nxi ? nxi->nx_id : 0,
20855 +               NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20856 +
20857 +       /* single IP is unconditional */
20858 +       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20859 +               (fl->fl4_src == INADDR_ANY))
20860 +               fl->fl4_src = nxi->v4.ip[0].s_addr;
20861 +
20862 +       if (fl->fl4_src == INADDR_ANY) {
20863 +               struct nx_addr_v4 *ptr;
20864 +               __be32 found = 0;
20865 +               int err;
20866 +
20867 +               err = __ip_route_output_key(net, rp, fl);
20868 +               if (!err) {
20869 +                       found = (*rp)->rt_src;
20870 +                       ip_rt_put(*rp);
20871 +                       vxdprintk(VXD_CBIT(net, 4),
20872 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20873 +                               nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20874 +                       if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20875 +                               goto found;
20876 +               }
20877 +
20878 +               for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20879 +                       __be32 primary = ptr->ip[0].s_addr;
20880 +                       __be32 mask = ptr->mask.s_addr;
20881 +                       __be32 neta = primary & mask;
20882 +
20883 +                       vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20884 +                               NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20885 +                               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20886 +                               NIPQUAD(mask), NIPQUAD(neta));
20887 +                       if ((found & mask) != neta)
20888 +                               continue;
20889 +
20890 +                       fl->fl4_src = primary;
20891 +                       err = __ip_route_output_key(net, rp, fl);
20892 +                       vxdprintk(VXD_CBIT(net, 4),
20893 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20894 +                               nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20895 +                       if (!err) {
20896 +                               found = (*rp)->rt_src;
20897 +                               ip_rt_put(*rp);
20898 +                               if (found == primary)
20899 +                                       goto found;
20900 +                       }
20901 +               }
20902 +               /* still no source ip? */
20903 +               found = ipv4_is_loopback(fl->fl4_dst)
20904 +                       ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20905 +       found:
20906 +               /* assign src ip to flow */
20907 +               fl->fl4_src = found;
20908 +
20909 +       } else {
20910 +               if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20911 +                       return -EPERM;
20912 +       }
20913 +
20914 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20915 +               if (ipv4_is_loopback(fl->fl4_dst))
20916 +                       fl->fl4_dst = nxi->v4_lback.s_addr;
20917 +               if (ipv4_is_loopback(fl->fl4_src))
20918 +                       fl->fl4_src = nxi->v4_lback.s_addr;
20919 +       } else if (ipv4_is_loopback(fl->fl4_dst) &&
20920 +               !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20921 +               return -EPERM;
20922 +
20923 +       return 0;
20924 +}
20925 +
20926 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20927 +
20928 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/init.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/init.c
20929 --- linux-2.6.35.2/kernel/vserver/init.c        1970-01-01 01:00:00.000000000 +0100
20930 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/init.c  2010-08-02 17:05:06.000000000 +0200
20931 @@ -0,0 +1,45 @@
20932 +/*
20933 + *  linux/kernel/init.c
20934 + *
20935 + *  Virtual Server Init
20936 + *
20937 + *  Copyright (C) 2004-2007  Herbert Pötzl
20938 + *
20939 + *  V0.01  basic structure
20940 + *
20941 + */
20942 +
20943 +#include <linux/init.h>
20944 +
20945 +int    vserver_register_sysctl(void);
20946 +void   vserver_unregister_sysctl(void);
20947 +
20948 +
20949 +static int __init init_vserver(void)
20950 +{
20951 +       int ret = 0;
20952 +
20953 +#ifdef CONFIG_VSERVER_DEBUG
20954 +       vserver_register_sysctl();
20955 +#endif
20956 +       return ret;
20957 +}
20958 +
20959 +
20960 +static void __exit exit_vserver(void)
20961 +{
20962 +
20963 +#ifdef CONFIG_VSERVER_DEBUG
20964 +       vserver_unregister_sysctl();
20965 +#endif
20966 +       return;
20967 +}
20968 +
20969 +/* FIXME: GFP_ZONETYPES gone
20970 +long vx_slab[GFP_ZONETYPES]; */
20971 +long vx_area;
20972 +
20973 +
20974 +module_init(init_vserver);
20975 +module_exit(exit_vserver);
20976 +
20977 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/inode.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/inode.c
20978 --- linux-2.6.35.2/kernel/vserver/inode.c       1970-01-01 01:00:00.000000000 +0100
20979 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/inode.c 2010-08-02 17:05:06.000000000 +0200
20980 @@ -0,0 +1,433 @@
20981 +/*
20982 + *  linux/kernel/vserver/inode.c
20983 + *
20984 + *  Virtual Server: File System Support
20985 + *
20986 + *  Copyright (C) 2004-2007  Herbert Pötzl
20987 + *
20988 + *  V0.01  separated from vcontext V0.05
20989 + *  V0.02  moved to tag (instead of xid)
20990 + *
20991 + */
20992 +
20993 +#include <linux/tty.h>
20994 +#include <linux/proc_fs.h>
20995 +#include <linux/devpts_fs.h>
20996 +#include <linux/fs.h>
20997 +#include <linux/file.h>
20998 +#include <linux/mount.h>
20999 +#include <linux/parser.h>
21000 +#include <linux/namei.h>
21001 +#include <linux/vserver/inode.h>
21002 +#include <linux/vserver/inode_cmd.h>
21003 +#include <linux/vs_base.h>
21004 +#include <linux/vs_tag.h>
21005 +
21006 +#include <asm/uaccess.h>
21007 +
21008 +
21009 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21010 +{
21011 +       struct proc_dir_entry *entry;
21012 +
21013 +       if (!in || !in->i_sb)
21014 +               return -ESRCH;
21015 +
21016 +       *flags = IATTR_TAG
21017 +               | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21018 +               | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21019 +               | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21020 +               | (IS_COW(in) ? IATTR_COW : 0);
21021 +       *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21022 +
21023 +       if (S_ISDIR(in->i_mode))
21024 +               *mask |= IATTR_BARRIER;
21025 +
21026 +       if (IS_TAGGED(in)) {
21027 +               *tag = in->i_tag;
21028 +               *mask |= IATTR_TAG;
21029 +       }
21030 +
21031 +       switch (in->i_sb->s_magic) {
21032 +       case PROC_SUPER_MAGIC:
21033 +               entry = PROC_I(in)->pde;
21034 +
21035 +               /* check for specific inodes? */
21036 +               if (entry)
21037 +                       *mask |= IATTR_FLAGS;
21038 +               if (entry)
21039 +                       *flags |= (entry->vx_flags & IATTR_FLAGS);
21040 +               else
21041 +                       *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21042 +               break;
21043 +
21044 +       case DEVPTS_SUPER_MAGIC:
21045 +               *tag = in->i_tag;
21046 +               *mask |= IATTR_TAG;
21047 +               break;
21048 +
21049 +       default:
21050 +               break;
21051 +       }
21052 +       return 0;
21053 +}
21054 +
21055 +int vc_get_iattr(void __user *data)
21056 +{
21057 +       struct path path;
21058 +       struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21059 +       int ret;
21060 +
21061 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21062 +               return -EFAULT;
21063 +
21064 +       ret = user_lpath(vc_data.name, &path);
21065 +       if (!ret) {
21066 +               ret = __vc_get_iattr(path.dentry->d_inode,
21067 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21068 +               path_put(&path);
21069 +       }
21070 +       if (ret)
21071 +               return ret;
21072 +
21073 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21074 +               ret = -EFAULT;
21075 +       return ret;
21076 +}
21077 +
21078 +#ifdef CONFIG_COMPAT
21079 +
21080 +int vc_get_iattr_x32(void __user *data)
21081 +{
21082 +       struct path path;
21083 +       struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21084 +       int ret;
21085 +
21086 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21087 +               return -EFAULT;
21088 +
21089 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21090 +       if (!ret) {
21091 +               ret = __vc_get_iattr(path.dentry->d_inode,
21092 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21093 +               path_put(&path);
21094 +       }
21095 +       if (ret)
21096 +               return ret;
21097 +
21098 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21099 +               ret = -EFAULT;
21100 +       return ret;
21101 +}
21102 +
21103 +#endif /* CONFIG_COMPAT */
21104 +
21105 +
21106 +int vc_fget_iattr(uint32_t fd, void __user *data)
21107 +{
21108 +       struct file *filp;
21109 +       struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21110 +       int ret;
21111 +
21112 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21113 +               return -EFAULT;
21114 +
21115 +       filp = fget(fd);
21116 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21117 +               return -EBADF;
21118 +
21119 +       ret = __vc_get_iattr(filp->f_dentry->d_inode,
21120 +               &vc_data.tag, &vc_data.flags, &vc_data.mask);
21121 +
21122 +       fput(filp);
21123 +
21124 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21125 +               ret = -EFAULT;
21126 +       return ret;
21127 +}
21128 +
21129 +
21130 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21131 +{
21132 +       struct inode *in = de->d_inode;
21133 +       int error = 0, is_proc = 0, has_tag = 0;
21134 +       struct iattr attr = { 0 };
21135 +
21136 +       if (!in || !in->i_sb)
21137 +               return -ESRCH;
21138 +
21139 +       is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21140 +       if ((*mask & IATTR_FLAGS) && !is_proc)
21141 +               return -EINVAL;
21142 +
21143 +       has_tag = IS_TAGGED(in) ||
21144 +               (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21145 +       if ((*mask & IATTR_TAG) && !has_tag)
21146 +               return -EINVAL;
21147 +
21148 +       mutex_lock(&in->i_mutex);
21149 +       if (*mask & IATTR_TAG) {
21150 +               attr.ia_tag = *tag;
21151 +               attr.ia_valid |= ATTR_TAG;
21152 +       }
21153 +
21154 +       if (*mask & IATTR_FLAGS) {
21155 +               struct proc_dir_entry *entry = PROC_I(in)->pde;
21156 +               unsigned int iflags = PROC_I(in)->vx_flags;
21157 +
21158 +               iflags = (iflags & ~(*mask & IATTR_FLAGS))
21159 +                       | (*flags & IATTR_FLAGS);
21160 +               PROC_I(in)->vx_flags = iflags;
21161 +               if (entry)
21162 +                       entry->vx_flags = iflags;
21163 +       }
21164 +
21165 +       if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21166 +               IATTR_BARRIER | IATTR_COW)) {
21167 +               int iflags = in->i_flags;
21168 +               int vflags = in->i_vflags;
21169 +
21170 +               if (*mask & IATTR_IMMUTABLE) {
21171 +                       if (*flags & IATTR_IMMUTABLE)
21172 +                               iflags |= S_IMMUTABLE;
21173 +                       else
21174 +                               iflags &= ~S_IMMUTABLE;
21175 +               }
21176 +               if (*mask & IATTR_IXUNLINK) {
21177 +                       if (*flags & IATTR_IXUNLINK)
21178 +                               iflags |= S_IXUNLINK;
21179 +                       else
21180 +                               iflags &= ~S_IXUNLINK;
21181 +               }
21182 +               if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21183 +                       if (*flags & IATTR_BARRIER)
21184 +                               vflags |= V_BARRIER;
21185 +                       else
21186 +                               vflags &= ~V_BARRIER;
21187 +               }
21188 +               if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21189 +                       if (*flags & IATTR_COW)
21190 +                               vflags |= V_COW;
21191 +                       else
21192 +                               vflags &= ~V_COW;
21193 +               }
21194 +               if (in->i_op && in->i_op->sync_flags) {
21195 +                       error = in->i_op->sync_flags(in, iflags, vflags);
21196 +                       if (error)
21197 +                               goto out;
21198 +               }
21199 +       }
21200 +
21201 +       if (attr.ia_valid) {
21202 +               if (in->i_op && in->i_op->setattr)
21203 +                       error = in->i_op->setattr(de, &attr);
21204 +               else {
21205 +                       error = inode_change_ok(in, &attr);
21206 +                       if (!error)
21207 +                               error = inode_setattr(in, &attr);
21208 +               }
21209 +       }
21210 +
21211 +out:
21212 +       mutex_unlock(&in->i_mutex);
21213 +       return error;
21214 +}
21215 +
21216 +int vc_set_iattr(void __user *data)
21217 +{
21218 +       struct path path;
21219 +       struct vcmd_ctx_iattr_v1 vc_data;
21220 +       int ret;
21221 +
21222 +       if (!capable(CAP_LINUX_IMMUTABLE))
21223 +               return -EPERM;
21224 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21225 +               return -EFAULT;
21226 +
21227 +       ret = user_lpath(vc_data.name, &path);
21228 +       if (!ret) {
21229 +               ret = __vc_set_iattr(path.dentry,
21230 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21231 +               path_put(&path);
21232 +       }
21233 +
21234 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21235 +               ret = -EFAULT;
21236 +       return ret;
21237 +}
21238 +
21239 +#ifdef CONFIG_COMPAT
21240 +
21241 +int vc_set_iattr_x32(void __user *data)
21242 +{
21243 +       struct path path;
21244 +       struct vcmd_ctx_iattr_v1_x32 vc_data;
21245 +       int ret;
21246 +
21247 +       if (!capable(CAP_LINUX_IMMUTABLE))
21248 +               return -EPERM;
21249 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21250 +               return -EFAULT;
21251 +
21252 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21253 +       if (!ret) {
21254 +               ret = __vc_set_iattr(path.dentry,
21255 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21256 +               path_put(&path);
21257 +       }
21258 +
21259 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21260 +               ret = -EFAULT;
21261 +       return ret;
21262 +}
21263 +
21264 +#endif /* CONFIG_COMPAT */
21265 +
21266 +int vc_fset_iattr(uint32_t fd, void __user *data)
21267 +{
21268 +       struct file *filp;
21269 +       struct vcmd_ctx_fiattr_v0 vc_data;
21270 +       int ret;
21271 +
21272 +       if (!capable(CAP_LINUX_IMMUTABLE))
21273 +               return -EPERM;
21274 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21275 +               return -EFAULT;
21276 +
21277 +       filp = fget(fd);
21278 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21279 +               return -EBADF;
21280 +
21281 +       ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21282 +               &vc_data.flags, &vc_data.mask);
21283 +
21284 +       fput(filp);
21285 +
21286 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21287 +               return -EFAULT;
21288 +       return ret;
21289 +}
21290 +
21291 +
21292 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21293 +
21294 +static match_table_t tokens = {
21295 +       {Opt_notagcheck, "notagcheck"},
21296 +#ifdef CONFIG_PROPAGATE
21297 +       {Opt_notag, "notag"},
21298 +       {Opt_tag, "tag"},
21299 +       {Opt_tagid, "tagid=%u"},
21300 +#endif
21301 +       {Opt_err, NULL}
21302 +};
21303 +
21304 +
21305 +static void __dx_parse_remove(char *string, char *opt)
21306 +{
21307 +       char *p = strstr(string, opt);
21308 +       char *q = p;
21309 +
21310 +       if (p) {
21311 +               while (*q != '\0' && *q != ',')
21312 +                       q++;
21313 +               while (*q)
21314 +                       *p++ = *q++;
21315 +               while (*p)
21316 +                       *p++ = '\0';
21317 +       }
21318 +}
21319 +
21320 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21321 +                unsigned long *flags)
21322 +{
21323 +       int set = 0;
21324 +       substring_t args[MAX_OPT_ARGS];
21325 +       int token, option = 0;
21326 +       char *s, *p, *opts;
21327 +
21328 +       if (!string)
21329 +               return 0;
21330 +       s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21331 +       if (!s)
21332 +               return 0;
21333 +
21334 +       opts = s;
21335 +       while ((p = strsep(&opts, ",")) != NULL) {
21336 +               token = match_token(p, tokens, args);
21337 +
21338 +               vxdprintk(VXD_CBIT(tag, 7),
21339 +                       "dx_parse_tag(»%s«): %d:#%d",
21340 +                       p, token, option);
21341 +
21342 +               switch (token) {
21343 +#ifdef CONFIG_PROPAGATE
21344 +               case Opt_tag:
21345 +                       if (tag)
21346 +                               *tag = 0;
21347 +                       if (remove)
21348 +                               __dx_parse_remove(s, "tag");
21349 +                       *mnt_flags |= MNT_TAGID;
21350 +                       set |= MNT_TAGID;
21351 +                       break;
21352 +               case Opt_notag:
21353 +                       if (remove)
21354 +                               __dx_parse_remove(s, "notag");
21355 +                       *mnt_flags |= MNT_NOTAG;
21356 +                       set |= MNT_NOTAG;
21357 +                       break;
21358 +               case Opt_tagid:
21359 +                       if (tag && !match_int(args, &option))
21360 +                               *tag = option;
21361 +                       if (remove)
21362 +                               __dx_parse_remove(s, "tagid");
21363 +                       *mnt_flags |= MNT_TAGID;
21364 +                       set |= MNT_TAGID;
21365 +                       break;
21366 +#endif
21367 +               case Opt_notagcheck:
21368 +                       if (remove)
21369 +                               __dx_parse_remove(s, "notagcheck");
21370 +                       *flags |= MS_NOTAGCHECK;
21371 +                       set |= MS_NOTAGCHECK;
21372 +                       break;
21373 +               }
21374 +       }
21375 +       if (set)
21376 +               strcpy(string, s);
21377 +       kfree(s);
21378 +       return set;
21379 +}
21380 +
21381 +#ifdef CONFIG_PROPAGATE
21382 +
21383 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21384 +{
21385 +       tag_t new_tag = 0;
21386 +       struct vfsmount *mnt;
21387 +       int propagate;
21388 +
21389 +       if (!nd)
21390 +               return;
21391 +       mnt = nd->path.mnt;
21392 +       if (!mnt)
21393 +               return;
21394 +
21395 +       propagate = (mnt->mnt_flags & MNT_TAGID);
21396 +       if (propagate)
21397 +               new_tag = mnt->mnt_tag;
21398 +
21399 +       vxdprintk(VXD_CBIT(tag, 7),
21400 +               "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21401 +               inode, inode->i_ino, inode->i_tag,
21402 +               new_tag, (propagate) ? 1 : 0);
21403 +
21404 +       if (propagate)
21405 +               inode->i_tag = new_tag;
21406 +}
21407 +
21408 +#include <linux/module.h>
21409 +
21410 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21411 +
21412 +#endif /* CONFIG_PROPAGATE */
21413 +
21414 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/Kconfig linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/Kconfig
21415 --- linux-2.6.35.2/kernel/vserver/Kconfig       1970-01-01 01:00:00.000000000 +0100
21416 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/Kconfig 2010-08-02 17:05:06.000000000 +0200
21417 @@ -0,0 +1,260 @@
21418 +#
21419 +# Linux VServer configuration
21420 +#
21421 +
21422 +menu "Linux VServer"
21423 +
21424 +config VSERVER_AUTO_LBACK
21425 +       bool    "Automatically Assign Loopback IP"
21426 +       default y
21427 +       help
21428 +         Automatically assign a guest specific loopback
21429 +         IP and add it to the kernel network stack on
21430 +         startup.
21431 +
21432 +config VSERVER_AUTO_SINGLE
21433 +       bool    "Automatic Single IP Special Casing"
21434 +       depends on EXPERIMENTAL
21435 +       default y
21436 +       help
21437 +         This allows network contexts with a single IP to
21438 +         automatically remap 0.0.0.0 bindings to that IP,
21439 +         avoiding further network checks and improving
21440 +         performance.
21441 +
21442 +         (note: such guests do not allow to change the ip
21443 +          on the fly and do not show loopback addresses)
21444 +
21445 +config VSERVER_COWBL
21446 +       bool    "Enable COW Immutable Link Breaking"
21447 +       default y
21448 +       help
21449 +         This enables the COW (Copy-On-Write) link break code.
21450 +         It allows you to treat unified files like normal files
21451 +         when writing to them (which will implicitely break the
21452 +         link and create a copy of the unified file)
21453 +
21454 +config VSERVER_VTIME
21455 +       bool    "Enable Virtualized Guest Time"
21456 +       depends on EXPERIMENTAL
21457 +       default n
21458 +       help
21459 +         This enables per guest time offsets to allow for
21460 +         adjusting the system clock individually per guest.
21461 +         this adds some overhead to the time functions and
21462 +         therefore should not be enabled without good reason.
21463 +
21464 +config VSERVER_DEVICE
21465 +       bool    "Enable Guest Device Mapping"
21466 +       depends on EXPERIMENTAL
21467 +       default n
21468 +       help
21469 +         This enables generic device remapping.
21470 +
21471 +config VSERVER_PROC_SECURE
21472 +       bool    "Enable Proc Security"
21473 +       depends on PROC_FS
21474 +       default y
21475 +       help
21476 +         This configures ProcFS security to initially hide
21477 +         non-process entries for all contexts except the main and
21478 +         spectator context (i.e. for all guests), which is a secure
21479 +         default.
21480 +
21481 +         (note: on 1.2x the entries were visible by default)
21482 +
21483 +config VSERVER_HARDCPU
21484 +       bool    "Enable Hard CPU Limits"
21485 +       default y
21486 +       help
21487 +         Activate the Hard CPU Limits
21488 +
21489 +         This will compile in code that allows the Token Bucket
21490 +         Scheduler to put processes on hold when a context's
21491 +         tokens are depleted (provided that its per-context
21492 +         sched_hard flag is set).
21493 +
21494 +         Processes belonging to that context will not be able
21495 +         to consume CPU resources again until a per-context
21496 +         configured minimum of tokens has been reached.
21497 +
21498 +config VSERVER_IDLETIME
21499 +       bool    "Avoid idle CPUs by skipping Time"
21500 +       depends on VSERVER_HARDCPU
21501 +       default y
21502 +       help
21503 +         This option allows the scheduler to artificially
21504 +         advance time (per cpu) when otherwise the idle
21505 +         task would be scheduled, thus keeping the cpu
21506 +         busy and sharing the available resources among
21507 +         certain contexts.
21508 +
21509 +config VSERVER_IDLELIMIT
21510 +       bool    "Limit the IDLE task"
21511 +       depends on VSERVER_HARDCPU
21512 +       default n
21513 +       help
21514 +         Limit the idle slices, so the the next context
21515 +         will be scheduled as soon as possible.
21516 +
21517 +         This might improve interactivity and latency, but
21518 +         will also marginally increase scheduling overhead.
21519 +
21520 +choice
21521 +       prompt  "Persistent Inode Tagging"
21522 +       default TAGGING_ID24
21523 +       help
21524 +         This adds persistent context information to filesystems
21525 +         mounted with the tagxid option. Tagging is a requirement
21526 +         for per-context disk limits and per-context quota.
21527 +
21528 +
21529 +config TAGGING_NONE
21530 +       bool    "Disabled"
21531 +       help
21532 +         do not store per-context information in inodes.
21533 +
21534 +config TAGGING_UID16
21535 +       bool    "UID16/GID32"
21536 +       help
21537 +         reduces UID to 16 bit, but leaves GID at 32 bit.
21538 +
21539 +config TAGGING_GID16
21540 +       bool    "UID32/GID16"
21541 +       help
21542 +         reduces GID to 16 bit, but leaves UID at 32 bit.
21543 +
21544 +config TAGGING_ID24
21545 +       bool    "UID24/GID24"
21546 +       help
21547 +         uses the upper 8bit from UID and GID for XID tagging
21548 +         which leaves 24bit for UID/GID each, which should be
21549 +         more than sufficient for normal use.
21550 +
21551 +config TAGGING_INTERN
21552 +       bool    "UID32/GID32"
21553 +       help
21554 +         this uses otherwise reserved inode fields in the on
21555 +         disk representation, which limits the use to a few
21556 +         filesystems (currently ext2 and ext3)
21557 +
21558 +endchoice
21559 +
21560 +config TAG_NFSD
21561 +       bool    "Tag NFSD User Auth and Files"
21562 +       default n
21563 +       help
21564 +         Enable this if you do want the in-kernel NFS
21565 +         Server to use the tagging specified above.
21566 +         (will require patched clients too)
21567 +
21568 +config VSERVER_PRIVACY
21569 +       bool    "Honor Privacy Aspects of Guests"
21570 +       default n
21571 +       help
21572 +         When enabled, most context checks will disallow
21573 +         access to structures assigned to a specific context,
21574 +         like ptys or loop devices.
21575 +
21576 +config VSERVER_CONTEXTS
21577 +       int     "Maximum number of Contexts (1-65533)"  if EMBEDDED
21578 +       range 1 65533
21579 +       default "768"   if 64BIT
21580 +       default "256"
21581 +       help
21582 +         This setting will optimize certain data structures
21583 +         and memory allocations according to the expected
21584 +         maximum.
21585 +
21586 +         note: this is not a strict upper limit.
21587 +
21588 +config VSERVER_WARN
21589 +       bool    "VServer Warnings"
21590 +       default y
21591 +       help
21592 +         This enables various runtime warnings, which will
21593 +         notify about potential manipulation attempts or
21594 +         resource shortage. It is generally considered to
21595 +         be a good idea to have that enabled.
21596 +
21597 +config VSERVER_DEBUG
21598 +       bool    "VServer Debugging Code"
21599 +       default n
21600 +       help
21601 +         Set this to yes if you want to be able to activate
21602 +         debugging output at runtime. It adds a very small
21603 +         overhead to all vserver related functions and
21604 +         increases the kernel size by about 20k.
21605 +
21606 +config VSERVER_HISTORY
21607 +       bool    "VServer History Tracing"
21608 +       depends on VSERVER_DEBUG
21609 +       default n
21610 +       help
21611 +         Set this to yes if you want to record the history of
21612 +         linux-vserver activities, so they can be replayed in
21613 +         the event of a kernel panic or oops.
21614 +
21615 +config VSERVER_HISTORY_SIZE
21616 +       int     "Per-CPU History Size (32-65536)"
21617 +       depends on VSERVER_HISTORY
21618 +       range 32 65536
21619 +       default 64
21620 +       help
21621 +         This allows you to specify the number of entries in
21622 +         the per-CPU history buffer.
21623 +
21624 +config VSERVER_MONITOR
21625 +       bool    "VServer Scheduling Monitor"
21626 +       depends on VSERVER_DISABLED
21627 +       default n
21628 +       help
21629 +         Set this to yes if you want to record the scheduling
21630 +         decisions, so that they can be relayed to userspace
21631 +         for detailed analysis.
21632 +
21633 +config VSERVER_MONITOR_SIZE
21634 +       int     "Per-CPU Monitor Queue Size (32-65536)"
21635 +       depends on VSERVER_MONITOR
21636 +       range 32 65536
21637 +       default 1024
21638 +       help
21639 +         This allows you to specify the number of entries in
21640 +         the per-CPU scheduling monitor buffer.
21641 +
21642 +config VSERVER_MONITOR_SYNC
21643 +       int     "Per-CPU Monitor Sync Interval (0-65536)"
21644 +       depends on VSERVER_MONITOR
21645 +       range 0 65536
21646 +       default 256
21647 +       help
21648 +         This allows you to specify the interval in ticks
21649 +         when a time sync entry is inserted.
21650 +
21651 +config VSERVER_LEGACY_MEM
21652 +       bool    "Legacy Memory Limits"
21653 +       default n
21654 +       help
21655 +         This provides fake memory limits to keep
21656 +         older tools happy in the face of memory
21657 +         cgroups
21658 +
21659 +
21660 +endmenu
21661 +
21662 +
21663 +config VSERVER
21664 +       bool
21665 +       default y
21666 +       select NAMESPACES
21667 +       select UTS_NS
21668 +       select IPC_NS
21669 +       select USER_NS
21670 +       select SYSVIPC
21671 +
21672 +config VSERVER_SECURITY
21673 +       bool
21674 +       depends on SECURITY
21675 +       default y
21676 +       select SECURITY_CAPABILITIES
21677 +
21678 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/limit.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/limit.c
21679 --- linux-2.6.35.2/kernel/vserver/limit.c       1970-01-01 01:00:00.000000000 +0100
21680 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/limit.c 2010-08-02 17:05:06.000000000 +0200
21681 @@ -0,0 +1,354 @@
21682 +/*
21683 + *  linux/kernel/vserver/limit.c
21684 + *
21685 + *  Virtual Server: Context Limits
21686 + *
21687 + *  Copyright (C) 2004-2010  Herbert Pötzl
21688 + *
21689 + *  V0.01  broken out from vcontext V0.05
21690 + *  V0.02  changed vcmds to vxi arg
21691 + *  V0.03  added memory cgroup support
21692 + *
21693 + */
21694 +
21695 +#include <linux/sched.h>
21696 +#include <linux/module.h>
21697 +#include <linux/memcontrol.h>
21698 +#include <linux/res_counter.h>
21699 +#include <linux/vs_limit.h>
21700 +#include <linux/vserver/limit.h>
21701 +#include <linux/vserver/limit_cmd.h>
21702 +
21703 +#include <asm/uaccess.h>
21704 +
21705 +
21706 +const char *vlimit_name[NUM_LIMITS] = {
21707 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21708 +       [RLIMIT_RSS]            = "RSS",
21709 +       [RLIMIT_AS]             = "VM",
21710 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21711 +       [RLIMIT_CPU]            = "CPU",
21712 +       [RLIMIT_NPROC]          = "NPROC",
21713 +       [RLIMIT_NOFILE]         = "NOFILE",
21714 +       [RLIMIT_LOCKS]          = "LOCKS",
21715 +       [RLIMIT_SIGPENDING]     = "SIGP",
21716 +       [RLIMIT_MSGQUEUE]       = "MSGQ",
21717 +
21718 +       [VLIMIT_NSOCK]          = "NSOCK",
21719 +       [VLIMIT_OPENFD]         = "OPENFD",
21720 +       [VLIMIT_SHMEM]          = "SHMEM",
21721 +       [VLIMIT_DENTRY]         = "DENTRY",
21722 +};
21723 +
21724 +EXPORT_SYMBOL_GPL(vlimit_name);
21725 +
21726 +#define MASK_ENTRY(x)  (1 << (x))
21727 +
21728 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21729 +               /* minimum */
21730 +       0
21731 +       ,       /* softlimit */
21732 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21733 +       MASK_ENTRY( RLIMIT_RSS          ) |
21734 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21735 +       0
21736 +       ,       /* maximum */
21737 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21738 +       MASK_ENTRY( RLIMIT_RSS          ) |
21739 +       MASK_ENTRY( RLIMIT_AS           ) |
21740 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21741 +       MASK_ENTRY( RLIMIT_NPROC        ) |
21742 +       MASK_ENTRY( RLIMIT_NOFILE       ) |
21743 +       MASK_ENTRY( RLIMIT_LOCKS        ) |
21744 +       MASK_ENTRY( RLIMIT_MSGQUEUE     ) |
21745 +
21746 +       MASK_ENTRY( VLIMIT_NSOCK        ) |
21747 +       MASK_ENTRY( VLIMIT_OPENFD       ) |
21748 +       MASK_ENTRY( VLIMIT_SHMEM        ) |
21749 +       MASK_ENTRY( VLIMIT_DENTRY       ) |
21750 +       0
21751 +};
21752 +               /* accounting only */
21753 +uint32_t account_mask =
21754 +       MASK_ENTRY( VLIMIT_SEMARY       ) |
21755 +       MASK_ENTRY( VLIMIT_NSEMS        ) |
21756 +       MASK_ENTRY( VLIMIT_MAPPED       ) |
21757 +       0;
21758 +
21759 +
21760 +static int is_valid_vlimit(int id)
21761 +{
21762 +       uint32_t mask = vlimit_mask.minimum |
21763 +               vlimit_mask.softlimit | vlimit_mask.maximum;
21764 +       return mask & (1 << id);
21765 +}
21766 +
21767 +static int is_accounted_vlimit(int id)
21768 +{
21769 +       if (is_valid_vlimit(id))
21770 +               return 1;
21771 +       return account_mask & (1 << id);
21772 +}
21773 +
21774 +
21775 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21776 +{
21777 +       rlim_t limit = __rlim_soft(&vxi->limit, id);
21778 +       return VX_VLIM(limit);
21779 +}
21780 +
21781 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21782 +{
21783 +       rlim_t limit = __rlim_hard(&vxi->limit, id);
21784 +       return VX_VLIM(limit);
21785 +}
21786 +
21787 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21788 +       uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21789 +{
21790 +       if (!is_valid_vlimit(id))
21791 +               return -EINVAL;
21792 +
21793 +       if (minimum)
21794 +               *minimum = CRLIM_UNSET;
21795 +       if (softlimit)
21796 +               *softlimit = vc_get_soft(vxi, id);
21797 +       if (maximum)
21798 +               *maximum = vc_get_hard(vxi, id);
21799 +       return 0;
21800 +}
21801 +
21802 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21803 +{
21804 +       struct vcmd_ctx_rlimit_v0 vc_data;
21805 +       int ret;
21806 +
21807 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21808 +               return -EFAULT;
21809 +
21810 +       ret = do_get_rlimit(vxi, vc_data.id,
21811 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21812 +       if (ret)
21813 +               return ret;
21814 +
21815 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21816 +               return -EFAULT;
21817 +       return 0;
21818 +}
21819 +
21820 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21821 +       uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21822 +{
21823 +       if (!is_valid_vlimit(id))
21824 +               return -EINVAL;
21825 +
21826 +       if (maximum != CRLIM_KEEP)
21827 +               __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21828 +       if (softlimit != CRLIM_KEEP)
21829 +               __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21830 +
21831 +       /* clamp soft limit */
21832 +       if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21833 +               __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21834 +
21835 +       return 0;
21836 +}
21837 +
21838 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21839 +{
21840 +       struct vcmd_ctx_rlimit_v0 vc_data;
21841 +
21842 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21843 +               return -EFAULT;
21844 +
21845 +       return do_set_rlimit(vxi, vc_data.id,
21846 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21847 +}
21848 +
21849 +#ifdef CONFIG_IA32_EMULATION
21850 +
21851 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21852 +{
21853 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
21854 +
21855 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21856 +               return -EFAULT;
21857 +
21858 +       return do_set_rlimit(vxi, vc_data.id,
21859 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21860 +}
21861 +
21862 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21863 +{
21864 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
21865 +       int ret;
21866 +
21867 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21868 +               return -EFAULT;
21869 +
21870 +       ret = do_get_rlimit(vxi, vc_data.id,
21871 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21872 +       if (ret)
21873 +               return ret;
21874 +
21875 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21876 +               return -EFAULT;
21877 +       return 0;
21878 +}
21879 +
21880 +#endif /* CONFIG_IA32_EMULATION */
21881 +
21882 +
21883 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21884 +{
21885 +       if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21886 +               return -EFAULT;
21887 +       return 0;
21888 +}
21889 +
21890 +
21891 +static inline void vx_reset_hits(struct _vx_limit *limit)
21892 +{
21893 +       int lim;
21894 +
21895 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
21896 +               atomic_set(&__rlim_lhit(limit, lim), 0);
21897 +       }
21898 +}
21899 +
21900 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
21901 +{
21902 +       vx_reset_hits(&vxi->limit);
21903 +       return 0;
21904 +}
21905 +
21906 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21907 +{
21908 +       rlim_t value;
21909 +       int lim;
21910 +
21911 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
21912 +               value = __rlim_get(limit, lim);
21913 +               __rlim_rmax(limit, lim) = value;
21914 +               __rlim_rmin(limit, lim) = value;
21915 +       }
21916 +}
21917 +
21918 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21919 +{
21920 +       vx_reset_minmax(&vxi->limit);
21921 +       return 0;
21922 +}
21923 +
21924 +
21925 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21926 +{
21927 +       struct vcmd_rlimit_stat_v0 vc_data;
21928 +       struct _vx_limit *limit = &vxi->limit;
21929 +       int id;
21930 +
21931 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21932 +               return -EFAULT;
21933 +
21934 +       id = vc_data.id;
21935 +       if (!is_accounted_vlimit(id))
21936 +               return -EINVAL;
21937 +
21938 +       vx_limit_fixup(limit, id);
21939 +       vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21940 +       vc_data.value = __rlim_get(limit, id);
21941 +       vc_data.minimum = __rlim_rmin(limit, id);
21942 +       vc_data.maximum = __rlim_rmax(limit, id);
21943 +
21944 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21945 +               return -EFAULT;
21946 +       return 0;
21947 +}
21948 +
21949 +
21950 +void vx_vsi_meminfo(struct sysinfo *val)
21951 +{
21952 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21953 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21954 +       u64 res_limit, res_usage;
21955 +
21956 +       if (!mcg)
21957 +               return;
21958 +
21959 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21960 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21961 +
21962 +       if (res_limit != RESOURCE_MAX)
21963 +               val->totalram = (res_limit >> PAGE_SHIFT);
21964 +       val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
21965 +       val->bufferram = 0;
21966 +       val->totalhigh = 0;
21967 +       val->freehigh = 0;
21968 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
21969 +       return;
21970 +}
21971 +
21972 +void vx_vsi_swapinfo(struct sysinfo *val)
21973 +{
21974 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21975 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
21976 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21977 +       u64 res_limit, res_usage, memsw_limit, memsw_usage;
21978 +       s64 swap_limit, swap_usage;
21979 +
21980 +       if (!mcg)
21981 +               return;
21982 +
21983 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21984 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21985 +       memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
21986 +       memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
21987 +
21988 +       if (res_limit == RESOURCE_MAX)
21989 +               return;
21990 +
21991 +       swap_limit = memsw_limit - res_limit;
21992 +       if (memsw_limit != RESOURCE_MAX)
21993 +               val->totalswap = swap_limit >> PAGE_SHIFT;
21994 +
21995 +       swap_usage = memsw_usage - res_usage;
21996 +       val->freeswap = (swap_usage < swap_limit) ?
21997 +               val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
21998 +#else  /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
21999 +       val->totalswap = 0;
22000 +       val->freeswap = 0;
22001 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22002 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22003 +       return;
22004 +}
22005 +
22006 +long vx_vsi_cached(struct sysinfo *val)
22007 +{
22008 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22009 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22010 +
22011 +       return mem_cgroup_stat_read_cache(mcg);
22012 +#else
22013 +       return 0;
22014 +#endif
22015 +}
22016 +
22017 +
22018 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22019 +{
22020 +       struct vx_info *vxi = mm->mm_vx_info;
22021 +       unsigned long points;
22022 +       rlim_t v, w;
22023 +
22024 +       if (!vxi)
22025 +               return 0;
22026 +
22027 +       points = vxi->vx_badness_bias;
22028 +
22029 +       v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22030 +       w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22031 +       points += (v > w) ? (v - w) : 0;
22032 +
22033 +       return points;
22034 +}
22035 +
22036 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/limit_init.h linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/limit_init.h
22037 --- linux-2.6.35.2/kernel/vserver/limit_init.h  1970-01-01 01:00:00.000000000 +0100
22038 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/limit_init.h    2010-08-02 17:05:06.000000000 +0200
22039 @@ -0,0 +1,31 @@
22040 +
22041 +
22042 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22043 +{
22044 +       int lim;
22045 +
22046 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22047 +               __rlim_soft(limit, lim) = RLIM_INFINITY;
22048 +               __rlim_hard(limit, lim) = RLIM_INFINITY;
22049 +               __rlim_set(limit, lim, 0);
22050 +               atomic_set(&__rlim_lhit(limit, lim), 0);
22051 +               __rlim_rmin(limit, lim) = 0;
22052 +               __rlim_rmax(limit, lim) = 0;
22053 +       }
22054 +}
22055 +
22056 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22057 +{
22058 +       rlim_t value;
22059 +       int lim;
22060 +
22061 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22062 +               if ((1 << lim) & VLIM_NOCHECK)
22063 +                       continue;
22064 +               value = __rlim_get(limit, lim);
22065 +               vxwprintk_xid(value,
22066 +                       "!!! limit: %p[%s,%d] = %ld on exit.",
22067 +                       limit, vlimit_name[lim], lim, (long)value);
22068 +       }
22069 +}
22070 +
22071 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/limit_proc.h linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/limit_proc.h
22072 --- linux-2.6.35.2/kernel/vserver/limit_proc.h  1970-01-01 01:00:00.000000000 +0100
22073 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/limit_proc.h    2010-08-02 17:05:06.000000000 +0200
22074 @@ -0,0 +1,57 @@
22075 +#ifndef _VX_LIMIT_PROC_H
22076 +#define _VX_LIMIT_PROC_H
22077 +
22078 +#include <linux/vserver/limit_int.h>
22079 +
22080 +
22081 +#define VX_LIMIT_FMT   ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22082 +#define VX_LIMIT_TOP   \
22083 +       "Limit\t current\t     min/max\t\t    soft/hard\t\thits\n"
22084 +
22085 +#define VX_LIMIT_ARG(r)                                \
22086 +       (unsigned long)__rlim_get(limit, r),    \
22087 +       (unsigned long)__rlim_rmin(limit, r),   \
22088 +       (unsigned long)__rlim_rmax(limit, r),   \
22089 +       VX_VLIM(__rlim_soft(limit, r)),         \
22090 +       VX_VLIM(__rlim_hard(limit, r)),         \
22091 +       atomic_read(&__rlim_lhit(limit, r))
22092 +
22093 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22094 +{
22095 +       vx_limit_fixup(limit, -1);
22096 +       return sprintf(buffer, VX_LIMIT_TOP
22097 +               "PROC"  VX_LIMIT_FMT
22098 +               "VM"    VX_LIMIT_FMT
22099 +               "VML"   VX_LIMIT_FMT
22100 +               "RSS"   VX_LIMIT_FMT
22101 +               "ANON"  VX_LIMIT_FMT
22102 +               "RMAP"  VX_LIMIT_FMT
22103 +               "FILES" VX_LIMIT_FMT
22104 +               "OFD"   VX_LIMIT_FMT
22105 +               "LOCKS" VX_LIMIT_FMT
22106 +               "SOCK"  VX_LIMIT_FMT
22107 +               "MSGQ"  VX_LIMIT_FMT
22108 +               "SHM"   VX_LIMIT_FMT
22109 +               "SEMA"  VX_LIMIT_FMT
22110 +               "SEMS"  VX_LIMIT_FMT
22111 +               "DENT"  VX_LIMIT_FMT,
22112 +               VX_LIMIT_ARG(RLIMIT_NPROC),
22113 +               VX_LIMIT_ARG(RLIMIT_AS),
22114 +               VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22115 +               VX_LIMIT_ARG(RLIMIT_RSS),
22116 +               VX_LIMIT_ARG(VLIMIT_ANON),
22117 +               VX_LIMIT_ARG(VLIMIT_MAPPED),
22118 +               VX_LIMIT_ARG(RLIMIT_NOFILE),
22119 +               VX_LIMIT_ARG(VLIMIT_OPENFD),
22120 +               VX_LIMIT_ARG(RLIMIT_LOCKS),
22121 +               VX_LIMIT_ARG(VLIMIT_NSOCK),
22122 +               VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22123 +               VX_LIMIT_ARG(VLIMIT_SHMEM),
22124 +               VX_LIMIT_ARG(VLIMIT_SEMARY),
22125 +               VX_LIMIT_ARG(VLIMIT_NSEMS),
22126 +               VX_LIMIT_ARG(VLIMIT_DENTRY));
22127 +}
22128 +
22129 +#endif /* _VX_LIMIT_PROC_H */
22130 +
22131 +
22132 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/Makefile linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/Makefile
22133 --- linux-2.6.35.2/kernel/vserver/Makefile      1970-01-01 01:00:00.000000000 +0100
22134 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/Makefile        2010-08-02 17:05:06.000000000 +0200
22135 @@ -0,0 +1,18 @@
22136 +#
22137 +# Makefile for the Linux vserver routines.
22138 +#
22139 +
22140 +
22141 +obj-y          += vserver.o
22142 +
22143 +vserver-y      := switch.o context.o space.o sched.o network.o inode.o \
22144 +                  limit.o cvirt.o cacct.o signal.o helper.o init.o \
22145 +                  dlimit.o tag.o
22146 +
22147 +vserver-$(CONFIG_INET) += inet.o
22148 +vserver-$(CONFIG_PROC_FS) += proc.o
22149 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
22150 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
22151 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
22152 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
22153 +
22154 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/monitor.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/monitor.c
22155 --- linux-2.6.35.2/kernel/vserver/monitor.c     1970-01-01 01:00:00.000000000 +0100
22156 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/monitor.c       2010-08-02 17:05:06.000000000 +0200
22157 @@ -0,0 +1,138 @@
22158 +/*
22159 + *  kernel/vserver/monitor.c
22160 + *
22161 + *  Virtual Context Scheduler Monitor
22162 + *
22163 + *  Copyright (C) 2006-2007 Herbert Pötzl
22164 + *
22165 + *  V0.01  basic design
22166 + *
22167 + */
22168 +
22169 +#include <linux/module.h>
22170 +#include <linux/jiffies.h>
22171 +#include <asm/uaccess.h>
22172 +#include <asm/atomic.h>
22173 +
22174 +#include <linux/vserver/monitor.h>
22175 +#include <linux/vserver/debug_cmd.h>
22176 +
22177 +
22178 +#ifdef CONFIG_VSERVER_MONITOR
22179 +#define VXM_SIZE       CONFIG_VSERVER_MONITOR_SIZE
22180 +#else
22181 +#define VXM_SIZE       64
22182 +#endif
22183 +
22184 +struct _vx_monitor {
22185 +       unsigned int counter;
22186 +
22187 +       struct _vx_mon_entry entry[VXM_SIZE+1];
22188 +};
22189 +
22190 +
22191 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
22192 +
22193 +unsigned volatile int vxm_active = 1;
22194 +
22195 +static atomic_t sequence = ATOMIC_INIT(0);
22196 +
22197 +
22198 +/*     vxm_advance()
22199 +
22200 +       * requires disabled preemption                          */
22201 +
22202 +struct _vx_mon_entry *vxm_advance(int cpu)
22203 +{
22204 +       struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22205 +       struct _vx_mon_entry *entry;
22206 +       unsigned int index;
22207 +
22208 +       index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
22209 +       entry = &mon->entry[index];
22210 +
22211 +       entry->ev.seq = atomic_inc_return(&sequence);
22212 +       entry->ev.jif = jiffies;
22213 +       return entry;
22214 +}
22215 +
22216 +EXPORT_SYMBOL_GPL(vxm_advance);
22217 +
22218 +
22219 +int do_read_monitor(struct __user _vx_mon_entry *data,
22220 +       int cpu, uint32_t *index, uint32_t *count)
22221 +{
22222 +       int pos, ret = 0;
22223 +       struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22224 +       int end = mon->counter;
22225 +       int start = end - VXM_SIZE + 2;
22226 +       int idx = *index;
22227 +
22228 +       /* special case: get current pos */
22229 +       if (!*count) {
22230 +               *index = end;
22231 +               return 0;
22232 +       }
22233 +
22234 +       /* have we lost some data? */
22235 +       if (idx < start)
22236 +               idx = start;
22237 +
22238 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22239 +               struct _vx_mon_entry *entry =
22240 +                       &mon->entry[idx % VXM_SIZE];
22241 +
22242 +               /* send entry to userspace */
22243 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22244 +               if (ret)
22245 +                       break;
22246 +       }
22247 +       /* save new index and count */
22248 +       *index = idx;
22249 +       *count = pos;
22250 +       return ret ? ret : (*index < end);
22251 +}
22252 +
22253 +int vc_read_monitor(uint32_t id, void __user *data)
22254 +{
22255 +       struct vcmd_read_monitor_v0 vc_data;
22256 +       int ret;
22257 +
22258 +       if (id >= NR_CPUS)
22259 +               return -EINVAL;
22260 +
22261 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22262 +               return -EFAULT;
22263 +
22264 +       ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22265 +               id, &vc_data.index, &vc_data.count);
22266 +
22267 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22268 +               return -EFAULT;
22269 +       return ret;
22270 +}
22271 +
22272 +#ifdef CONFIG_COMPAT
22273 +
22274 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22275 +{
22276 +       struct vcmd_read_monitor_v0_x32 vc_data;
22277 +       int ret;
22278 +
22279 +       if (id >= NR_CPUS)
22280 +               return -EINVAL;
22281 +
22282 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22283 +               return -EFAULT;
22284 +
22285 +       ret = do_read_monitor((struct __user _vx_mon_entry *)
22286 +               compat_ptr(vc_data.data_ptr),
22287 +               id, &vc_data.index, &vc_data.count);
22288 +
22289 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22290 +               return -EFAULT;
22291 +       return ret;
22292 +}
22293 +
22294 +#endif /* CONFIG_COMPAT */
22295 +
22296 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/network.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/network.c
22297 --- linux-2.6.35.2/kernel/vserver/network.c     1970-01-01 01:00:00.000000000 +0100
22298 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/network.c       2010-08-02 17:05:06.000000000 +0200
22299 @@ -0,0 +1,864 @@
22300 +/*
22301 + *  linux/kernel/vserver/network.c
22302 + *
22303 + *  Virtual Server: Network Support
22304 + *
22305 + *  Copyright (C) 2003-2007  Herbert Pötzl
22306 + *
22307 + *  V0.01  broken out from vcontext V0.05
22308 + *  V0.02  cleaned up implementation
22309 + *  V0.03  added equiv nx commands
22310 + *  V0.04  switch to RCU based hash
22311 + *  V0.05  and back to locking again
22312 + *  V0.06  changed vcmds to nxi arg
22313 + *  V0.07  have __create claim() the nxi
22314 + *
22315 + */
22316 +
22317 +#include <linux/err.h>
22318 +#include <linux/slab.h>
22319 +#include <linux/rcupdate.h>
22320 +
22321 +#include <linux/vs_network.h>
22322 +#include <linux/vs_pid.h>
22323 +#include <linux/vserver/network_cmd.h>
22324 +
22325 +
22326 +atomic_t nx_global_ctotal      = ATOMIC_INIT(0);
22327 +atomic_t nx_global_cactive     = ATOMIC_INIT(0);
22328 +
22329 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22330 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22331 +
22332 +
22333 +static int __init init_network(void)
22334 +{
22335 +       nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22336 +               sizeof(struct nx_addr_v4), 0,
22337 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22338 +       nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22339 +               sizeof(struct nx_addr_v6), 0,
22340 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22341 +       return 0;
22342 +}
22343 +
22344 +
22345 +/*     __alloc_nx_addr_v4()                                    */
22346 +
22347 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22348 +{
22349 +       struct nx_addr_v4 *nxa = kmem_cache_alloc(
22350 +               nx_addr_v4_cachep, GFP_KERNEL);
22351 +
22352 +       if (!IS_ERR(nxa))
22353 +               memset(nxa, 0, sizeof(*nxa));
22354 +       return nxa;
22355 +}
22356 +
22357 +/*     __dealloc_nx_addr_v4()                                  */
22358 +
22359 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22360 +{
22361 +       kmem_cache_free(nx_addr_v4_cachep, nxa);
22362 +}
22363 +
22364 +/*     __dealloc_nx_addr_v4_all()                              */
22365 +
22366 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22367 +{
22368 +       while (nxa) {
22369 +               struct nx_addr_v4 *next = nxa->next;
22370 +
22371 +               __dealloc_nx_addr_v4(nxa);
22372 +               nxa = next;
22373 +       }
22374 +}
22375 +
22376 +
22377 +#ifdef CONFIG_IPV6
22378 +
22379 +/*     __alloc_nx_addr_v6()                                    */
22380 +
22381 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22382 +{
22383 +       struct nx_addr_v6 *nxa = kmem_cache_alloc(
22384 +               nx_addr_v6_cachep, GFP_KERNEL);
22385 +
22386 +       if (!IS_ERR(nxa))
22387 +               memset(nxa, 0, sizeof(*nxa));
22388 +       return nxa;
22389 +}
22390 +
22391 +/*     __dealloc_nx_addr_v6()                                  */
22392 +
22393 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22394 +{
22395 +       kmem_cache_free(nx_addr_v6_cachep, nxa);
22396 +}
22397 +
22398 +/*     __dealloc_nx_addr_v6_all()                              */
22399 +
22400 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22401 +{
22402 +       while (nxa) {
22403 +               struct nx_addr_v6 *next = nxa->next;
22404 +
22405 +               __dealloc_nx_addr_v6(nxa);
22406 +               nxa = next;
22407 +       }
22408 +}
22409 +
22410 +#endif /* CONFIG_IPV6 */
22411 +
22412 +/*     __alloc_nx_info()
22413 +
22414 +       * allocate an initialized nx_info struct
22415 +       * doesn't make it visible (hash)                        */
22416 +
22417 +static struct nx_info *__alloc_nx_info(nid_t nid)
22418 +{
22419 +       struct nx_info *new = NULL;
22420 +
22421 +       vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22422 +
22423 +       /* would this benefit from a slab cache? */
22424 +       new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22425 +       if (!new)
22426 +               return 0;
22427 +
22428 +       memset(new, 0, sizeof(struct nx_info));
22429 +       new->nx_id = nid;
22430 +       INIT_HLIST_NODE(&new->nx_hlist);
22431 +       atomic_set(&new->nx_usecnt, 0);
22432 +       atomic_set(&new->nx_tasks, 0);
22433 +       new->nx_state = 0;
22434 +
22435 +       new->nx_flags = NXF_INIT_SET;
22436 +
22437 +       /* rest of init goes here */
22438 +
22439 +       new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22440 +       new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22441 +
22442 +       vxdprintk(VXD_CBIT(nid, 0),
22443 +               "alloc_nx_info(%d) = %p", nid, new);
22444 +       atomic_inc(&nx_global_ctotal);
22445 +       return new;
22446 +}
22447 +
22448 +/*     __dealloc_nx_info()
22449 +
22450 +       * final disposal of nx_info                             */
22451 +
22452 +static void __dealloc_nx_info(struct nx_info *nxi)
22453 +{
22454 +       vxdprintk(VXD_CBIT(nid, 0),
22455 +               "dealloc_nx_info(%p)", nxi);
22456 +
22457 +       nxi->nx_hlist.next = LIST_POISON1;
22458 +       nxi->nx_id = -1;
22459 +
22460 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
22461 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22462 +
22463 +       __dealloc_nx_addr_v4_all(nxi->v4.next);
22464 +
22465 +       nxi->nx_state |= NXS_RELEASED;
22466 +       kfree(nxi);
22467 +       atomic_dec(&nx_global_ctotal);
22468 +}
22469 +
22470 +static void __shutdown_nx_info(struct nx_info *nxi)
22471 +{
22472 +       nxi->nx_state |= NXS_SHUTDOWN;
22473 +       vs_net_change(nxi, VSC_NETDOWN);
22474 +}
22475 +
22476 +/*     exported stuff                                          */
22477 +
22478 +void free_nx_info(struct nx_info *nxi)
22479 +{
22480 +       /* context shutdown is mandatory */
22481 +       BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22482 +
22483 +       /* context must not be hashed */
22484 +       BUG_ON(nxi->nx_state & NXS_HASHED);
22485 +
22486 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
22487 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22488 +
22489 +       __dealloc_nx_info(nxi);
22490 +}
22491 +
22492 +
22493 +void __nx_set_lback(struct nx_info *nxi)
22494 +{
22495 +       int nid = nxi->nx_id;
22496 +       __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22497 +
22498 +       nxi->v4_lback.s_addr = lback;
22499 +}
22500 +
22501 +extern int __nx_inet_add_lback(__be32 addr);
22502 +extern int __nx_inet_del_lback(__be32 addr);
22503 +
22504 +
22505 +/*     hash table for nx_info hash */
22506 +
22507 +#define NX_HASH_SIZE   13
22508 +
22509 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22510 +
22511 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22512 +
22513 +
22514 +static inline unsigned int __hashval(nid_t nid)
22515 +{
22516 +       return (nid % NX_HASH_SIZE);
22517 +}
22518 +
22519 +
22520 +
22521 +/*     __hash_nx_info()
22522 +
22523 +       * add the nxi to the global hash table
22524 +       * requires the hash_lock to be held                     */
22525 +
22526 +static inline void __hash_nx_info(struct nx_info *nxi)
22527 +{
22528 +       struct hlist_head *head;
22529 +
22530 +       vxd_assert_lock(&nx_info_hash_lock);
22531 +       vxdprintk(VXD_CBIT(nid, 4),
22532 +               "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22533 +
22534 +       /* context must not be hashed */
22535 +       BUG_ON(nx_info_state(nxi, NXS_HASHED));
22536 +
22537 +       nxi->nx_state |= NXS_HASHED;
22538 +       head = &nx_info_hash[__hashval(nxi->nx_id)];
22539 +       hlist_add_head(&nxi->nx_hlist, head);
22540 +       atomic_inc(&nx_global_cactive);
22541 +}
22542 +
22543 +/*     __unhash_nx_info()
22544 +
22545 +       * remove the nxi from the global hash table
22546 +       * requires the hash_lock to be held                     */
22547 +
22548 +static inline void __unhash_nx_info(struct nx_info *nxi)
22549 +{
22550 +       vxd_assert_lock(&nx_info_hash_lock);
22551 +       vxdprintk(VXD_CBIT(nid, 4),
22552 +               "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22553 +               atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22554 +
22555 +       /* context must be hashed */
22556 +       BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22557 +       /* but without tasks */
22558 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22559 +
22560 +       nxi->nx_state &= ~NXS_HASHED;
22561 +       hlist_del(&nxi->nx_hlist);
22562 +       atomic_dec(&nx_global_cactive);
22563 +}
22564 +
22565 +
22566 +/*     __lookup_nx_info()
22567 +
22568 +       * requires the hash_lock to be held
22569 +       * doesn't increment the nx_refcnt                       */
22570 +
22571 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22572 +{
22573 +       struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22574 +       struct hlist_node *pos;
22575 +       struct nx_info *nxi;
22576 +
22577 +       vxd_assert_lock(&nx_info_hash_lock);
22578 +       hlist_for_each(pos, head) {
22579 +               nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22580 +
22581 +               if (nxi->nx_id == nid)
22582 +                       goto found;
22583 +       }
22584 +       nxi = NULL;
22585 +found:
22586 +       vxdprintk(VXD_CBIT(nid, 0),
22587 +               "__lookup_nx_info(#%u): %p[#%u]",
22588 +               nid, nxi, nxi ? nxi->nx_id : 0);
22589 +       return nxi;
22590 +}
22591 +
22592 +
22593 +/*     __create_nx_info()
22594 +
22595 +       * create the requested context
22596 +       * get(), claim() and hash it                            */
22597 +
22598 +static struct nx_info *__create_nx_info(int id)
22599 +{
22600 +       struct nx_info *new, *nxi = NULL;
22601 +
22602 +       vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22603 +
22604 +       if (!(new = __alloc_nx_info(id)))
22605 +               return ERR_PTR(-ENOMEM);
22606 +
22607 +       /* required to make dynamic xids unique */
22608 +       spin_lock(&nx_info_hash_lock);
22609 +
22610 +       /* static context requested */
22611 +       if ((nxi = __lookup_nx_info(id))) {
22612 +               vxdprintk(VXD_CBIT(nid, 0),
22613 +                       "create_nx_info(%d) = %p (already there)", id, nxi);
22614 +               if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22615 +                       nxi = ERR_PTR(-EBUSY);
22616 +               else
22617 +                       nxi = ERR_PTR(-EEXIST);
22618 +               goto out_unlock;
22619 +       }
22620 +       /* new context */
22621 +       vxdprintk(VXD_CBIT(nid, 0),
22622 +               "create_nx_info(%d) = %p (new)", id, new);
22623 +       claim_nx_info(new, NULL);
22624 +       __nx_set_lback(new);
22625 +       __hash_nx_info(get_nx_info(new));
22626 +       nxi = new, new = NULL;
22627 +
22628 +out_unlock:
22629 +       spin_unlock(&nx_info_hash_lock);
22630 +       if (new)
22631 +               __dealloc_nx_info(new);
22632 +       return nxi;
22633 +}
22634 +
22635 +
22636 +
22637 +/*     exported stuff                                          */
22638 +
22639 +
22640 +void unhash_nx_info(struct nx_info *nxi)
22641 +{
22642 +       __shutdown_nx_info(nxi);
22643 +       spin_lock(&nx_info_hash_lock);
22644 +       __unhash_nx_info(nxi);
22645 +       spin_unlock(&nx_info_hash_lock);
22646 +}
22647 +
22648 +/*     lookup_nx_info()
22649 +
22650 +       * search for a nx_info and get() it
22651 +       * negative id means current                             */
22652 +
22653 +struct nx_info *lookup_nx_info(int id)
22654 +{
22655 +       struct nx_info *nxi = NULL;
22656 +
22657 +       if (id < 0) {
22658 +               nxi = get_nx_info(current_nx_info());
22659 +       } else if (id > 1) {
22660 +               spin_lock(&nx_info_hash_lock);
22661 +               nxi = get_nx_info(__lookup_nx_info(id));
22662 +               spin_unlock(&nx_info_hash_lock);
22663 +       }
22664 +       return nxi;
22665 +}
22666 +
22667 +/*     nid_is_hashed()
22668 +
22669 +       * verify that nid is still hashed                       */
22670 +
22671 +int nid_is_hashed(nid_t nid)
22672 +{
22673 +       int hashed;
22674 +
22675 +       spin_lock(&nx_info_hash_lock);
22676 +       hashed = (__lookup_nx_info(nid) != NULL);
22677 +       spin_unlock(&nx_info_hash_lock);
22678 +       return hashed;
22679 +}
22680 +
22681 +
22682 +#ifdef CONFIG_PROC_FS
22683 +
22684 +/*     get_nid_list()
22685 +
22686 +       * get a subset of hashed nids for proc
22687 +       * assumes size is at least one                          */
22688 +
22689 +int get_nid_list(int index, unsigned int *nids, int size)
22690 +{
22691 +       int hindex, nr_nids = 0;
22692 +
22693 +       /* only show current and children */
22694 +       if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22695 +               if (index > 0)
22696 +                       return 0;
22697 +               nids[nr_nids] = nx_current_nid();
22698 +               return 1;
22699 +       }
22700 +
22701 +       for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22702 +               struct hlist_head *head = &nx_info_hash[hindex];
22703 +               struct hlist_node *pos;
22704 +
22705 +               spin_lock(&nx_info_hash_lock);
22706 +               hlist_for_each(pos, head) {
22707 +                       struct nx_info *nxi;
22708 +
22709 +                       if (--index > 0)
22710 +                               continue;
22711 +
22712 +                       nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22713 +                       nids[nr_nids] = nxi->nx_id;
22714 +                       if (++nr_nids >= size) {
22715 +                               spin_unlock(&nx_info_hash_lock);
22716 +                               goto out;
22717 +                       }
22718 +               }
22719 +               /* keep the lock time short */
22720 +               spin_unlock(&nx_info_hash_lock);
22721 +       }
22722 +out:
22723 +       return nr_nids;
22724 +}
22725 +#endif
22726 +
22727 +
22728 +/*
22729 + *     migrate task to new network
22730 + *     gets nxi, puts old_nxi on change
22731 + */
22732 +
22733 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22734 +{
22735 +       struct nx_info *old_nxi;
22736 +       int ret = 0;
22737 +
22738 +       if (!p || !nxi)
22739 +               BUG();
22740 +
22741 +       vxdprintk(VXD_CBIT(nid, 5),
22742 +               "nx_migrate_task(%p,%p[#%d.%d.%d])",
22743 +               p, nxi, nxi->nx_id,
22744 +               atomic_read(&nxi->nx_usecnt),
22745 +               atomic_read(&nxi->nx_tasks));
22746 +
22747 +       if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22748 +               !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22749 +               return -EACCES;
22750 +
22751 +       if (nx_info_state(nxi, NXS_SHUTDOWN))
22752 +               return -EFAULT;
22753 +
22754 +       /* maybe disallow this completely? */
22755 +       old_nxi = task_get_nx_info(p);
22756 +       if (old_nxi == nxi)
22757 +               goto out;
22758 +
22759 +       task_lock(p);
22760 +       if (old_nxi)
22761 +               clr_nx_info(&p->nx_info);
22762 +       claim_nx_info(nxi, p);
22763 +       set_nx_info(&p->nx_info, nxi);
22764 +       p->nid = nxi->nx_id;
22765 +       task_unlock(p);
22766 +
22767 +       vxdprintk(VXD_CBIT(nid, 5),
22768 +               "moved task %p into nxi:%p[#%d]",
22769 +               p, nxi, nxi->nx_id);
22770 +
22771 +       if (old_nxi)
22772 +               release_nx_info(old_nxi, p);
22773 +       ret = 0;
22774 +out:
22775 +       put_nx_info(old_nxi);
22776 +       return ret;
22777 +}
22778 +
22779 +
22780 +void nx_set_persistent(struct nx_info *nxi)
22781 +{
22782 +       vxdprintk(VXD_CBIT(nid, 6),
22783 +               "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22784 +
22785 +       get_nx_info(nxi);
22786 +       claim_nx_info(nxi, NULL);
22787 +}
22788 +
22789 +void nx_clear_persistent(struct nx_info *nxi)
22790 +{
22791 +       vxdprintk(VXD_CBIT(nid, 6),
22792 +               "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22793 +
22794 +       release_nx_info(nxi, NULL);
22795 +       put_nx_info(nxi);
22796 +}
22797 +
22798 +void nx_update_persistent(struct nx_info *nxi)
22799 +{
22800 +       if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22801 +               nx_set_persistent(nxi);
22802 +       else
22803 +               nx_clear_persistent(nxi);
22804 +}
22805 +
22806 +/* vserver syscall commands below here */
22807 +
22808 +/* taks nid and nx_info functions */
22809 +
22810 +#include <asm/uaccess.h>
22811 +
22812 +
22813 +int vc_task_nid(uint32_t id)
22814 +{
22815 +       nid_t nid;
22816 +
22817 +       if (id) {
22818 +               struct task_struct *tsk;
22819 +
22820 +               read_lock(&tasklist_lock);
22821 +               tsk = find_task_by_real_pid(id);
22822 +               nid = (tsk) ? tsk->nid : -ESRCH;
22823 +               read_unlock(&tasklist_lock);
22824 +       } else
22825 +               nid = nx_current_nid();
22826 +       return nid;
22827 +}
22828 +
22829 +
22830 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22831 +{
22832 +       struct vcmd_nx_info_v0 vc_data;
22833 +
22834 +       vc_data.nid = nxi->nx_id;
22835 +
22836 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22837 +               return -EFAULT;
22838 +       return 0;
22839 +}
22840 +
22841 +
22842 +/* network functions */
22843 +
22844 +int vc_net_create(uint32_t nid, void __user *data)
22845 +{
22846 +       struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22847 +       struct nx_info *new_nxi;
22848 +       int ret;
22849 +
22850 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22851 +               return -EFAULT;
22852 +
22853 +       if ((nid > MAX_S_CONTEXT) || (nid < 2))
22854 +               return -EINVAL;
22855 +
22856 +       new_nxi = __create_nx_info(nid);
22857 +       if (IS_ERR(new_nxi))
22858 +               return PTR_ERR(new_nxi);
22859 +
22860 +       /* initial flags */
22861 +       new_nxi->nx_flags = vc_data.flagword;
22862 +
22863 +       ret = -ENOEXEC;
22864 +       if (vs_net_change(new_nxi, VSC_NETUP))
22865 +               goto out;
22866 +
22867 +       ret = nx_migrate_task(current, new_nxi);
22868 +       if (ret)
22869 +               goto out;
22870 +
22871 +       /* return context id on success */
22872 +       ret = new_nxi->nx_id;
22873 +
22874 +       /* get a reference for persistent contexts */
22875 +       if ((vc_data.flagword & NXF_PERSISTENT))
22876 +               nx_set_persistent(new_nxi);
22877 +out:
22878 +       release_nx_info(new_nxi, NULL);
22879 +       put_nx_info(new_nxi);
22880 +       return ret;
22881 +}
22882 +
22883 +
22884 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22885 +{
22886 +       return nx_migrate_task(current, nxi);
22887 +}
22888 +
22889 +
22890 +
22891 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22892 +       uint16_t type, uint16_t flags)
22893 +{
22894 +       struct nx_addr_v4 *nxa = &nxi->v4;
22895 +
22896 +       if (NX_IPV4(nxi)) {
22897 +               /* locate last entry */
22898 +               for (; nxa->next; nxa = nxa->next);
22899 +               nxa->next = __alloc_nx_addr_v4();
22900 +               nxa = nxa->next;
22901 +
22902 +               if (IS_ERR(nxa))
22903 +                       return PTR_ERR(nxa);
22904 +       }
22905 +
22906 +       if (nxi->v4.next)
22907 +               /* remove single ip for ip list */
22908 +               nxi->nx_flags &= ~NXF_SINGLE_IP;
22909 +
22910 +       nxa->ip[0].s_addr = ip;
22911 +       nxa->ip[1].s_addr = ip2;
22912 +       nxa->mask.s_addr = mask;
22913 +       nxa->type = type;
22914 +       nxa->flags = flags;
22915 +       return 0;
22916 +}
22917 +
22918 +
22919 +int vc_net_add(struct nx_info *nxi, void __user *data)
22920 +{
22921 +       struct vcmd_net_addr_v0 vc_data;
22922 +       int index, ret = 0;
22923 +
22924 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22925 +               return -EFAULT;
22926 +
22927 +       switch (vc_data.type) {
22928 +       case NXA_TYPE_IPV4:
22929 +               if ((vc_data.count < 1) || (vc_data.count > 4))
22930 +                       return -EINVAL;
22931 +
22932 +               index = 0;
22933 +               while (index < vc_data.count) {
22934 +                       ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22935 +                               vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22936 +                       if (ret)
22937 +                               return ret;
22938 +                       index++;
22939 +               }
22940 +               ret = index;
22941 +               break;
22942 +
22943 +       case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22944 +               nxi->v4_bcast = vc_data.ip[0];
22945 +               ret = 1;
22946 +               break;
22947 +
22948 +       case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22949 +               nxi->v4_lback = vc_data.ip[0];
22950 +               ret = 1;
22951 +               break;
22952 +
22953 +       default:
22954 +               ret = -EINVAL;
22955 +               break;
22956 +       }
22957 +       return ret;
22958 +}
22959 +
22960 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22961 +{
22962 +       struct vcmd_net_addr_v0 vc_data;
22963 +
22964 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22965 +               return -EFAULT;
22966 +
22967 +       switch (vc_data.type) {
22968 +       case NXA_TYPE_ANY:
22969 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22970 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
22971 +               break;
22972 +
22973 +       default:
22974 +               return -EINVAL;
22975 +       }
22976 +       return 0;
22977 +}
22978 +
22979 +
22980 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
22981 +{
22982 +       struct vcmd_net_addr_ipv4_v1 vc_data;
22983 +
22984 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22985 +               return -EFAULT;
22986 +
22987 +       switch (vc_data.type) {
22988 +       case NXA_TYPE_ADDR:
22989 +       case NXA_TYPE_RANGE:
22990 +       case NXA_TYPE_MASK:
22991 +               return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22992 +                       vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22993 +
22994 +       case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22995 +               nxi->v4_bcast = vc_data.ip;
22996 +               break;
22997 +
22998 +       case NXA_TYPE_ADDR | NXA_MOD_LBACK:
22999 +               nxi->v4_lback = vc_data.ip;
23000 +               break;
23001 +
23002 +       default:
23003 +               return -EINVAL;
23004 +       }
23005 +       return 0;
23006 +}
23007 +
23008 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
23009 +{
23010 +       struct vcmd_net_addr_ipv4_v1 vc_data;
23011 +
23012 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23013 +               return -EFAULT;
23014 +
23015 +       switch (vc_data.type) {
23016 +/*     case NXA_TYPE_ADDR:
23017 +               break;          */
23018 +
23019 +       case NXA_TYPE_ANY:
23020 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23021 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
23022 +               break;
23023 +
23024 +       default:
23025 +               return -EINVAL;
23026 +       }
23027 +       return 0;
23028 +}
23029 +
23030 +
23031 +#ifdef CONFIG_IPV6
23032 +
23033 +int do_add_v6_addr(struct nx_info *nxi,
23034 +       struct in6_addr *ip, struct in6_addr *mask,
23035 +       uint32_t prefix, uint16_t type, uint16_t flags)
23036 +{
23037 +       struct nx_addr_v6 *nxa = &nxi->v6;
23038 +
23039 +       if (NX_IPV6(nxi)) {
23040 +               /* locate last entry */
23041 +               for (; nxa->next; nxa = nxa->next);
23042 +               nxa->next = __alloc_nx_addr_v6();
23043 +               nxa = nxa->next;
23044 +
23045 +               if (IS_ERR(nxa))
23046 +                       return PTR_ERR(nxa);
23047 +       }
23048 +
23049 +       nxa->ip = *ip;
23050 +       nxa->mask = *mask;
23051 +       nxa->prefix = prefix;
23052 +       nxa->type = type;
23053 +       nxa->flags = flags;
23054 +       return 0;
23055 +}
23056 +
23057 +
23058 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23059 +{
23060 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23061 +
23062 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23063 +               return -EFAULT;
23064 +
23065 +       switch (vc_data.type) {
23066 +       case NXA_TYPE_ADDR:
23067 +       case NXA_TYPE_MASK:
23068 +               return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23069 +                       vc_data.prefix, vc_data.type, vc_data.flags);
23070 +       default:
23071 +               return -EINVAL;
23072 +       }
23073 +       return 0;
23074 +}
23075 +
23076 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23077 +{
23078 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23079 +
23080 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23081 +               return -EFAULT;
23082 +
23083 +       switch (vc_data.type) {
23084 +       case NXA_TYPE_ANY:
23085 +               __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23086 +               memset(&nxi->v6, 0, sizeof(nxi->v6));
23087 +               break;
23088 +
23089 +       default:
23090 +               return -EINVAL;
23091 +       }
23092 +       return 0;
23093 +}
23094 +
23095 +#endif /* CONFIG_IPV6 */
23096 +
23097 +
23098 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23099 +{
23100 +       struct vcmd_net_flags_v0 vc_data;
23101 +
23102 +       vc_data.flagword = nxi->nx_flags;
23103 +
23104 +       /* special STATE flag handling */
23105 +       vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23106 +
23107 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23108 +               return -EFAULT;
23109 +       return 0;
23110 +}
23111 +
23112 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23113 +{
23114 +       struct vcmd_net_flags_v0 vc_data;
23115 +       uint64_t mask, trigger;
23116 +
23117 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23118 +               return -EFAULT;
23119 +
23120 +       /* special STATE flag handling */
23121 +       mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23122 +       trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23123 +
23124 +       nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23125 +               vc_data.flagword, mask);
23126 +       if (trigger & NXF_PERSISTENT)
23127 +               nx_update_persistent(nxi);
23128 +
23129 +       return 0;
23130 +}
23131 +
23132 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23133 +{
23134 +       struct vcmd_net_caps_v0 vc_data;
23135 +
23136 +       vc_data.ncaps = nxi->nx_ncaps;
23137 +       vc_data.cmask = ~0ULL;
23138 +
23139 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23140 +               return -EFAULT;
23141 +       return 0;
23142 +}
23143 +
23144 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23145 +{
23146 +       struct vcmd_net_caps_v0 vc_data;
23147 +
23148 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23149 +               return -EFAULT;
23150 +
23151 +       nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23152 +               vc_data.ncaps, vc_data.cmask);
23153 +       return 0;
23154 +}
23155 +
23156 +
23157 +#include <linux/module.h>
23158 +
23159 +module_init(init_network);
23160 +
23161 +EXPORT_SYMBOL_GPL(free_nx_info);
23162 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23163 +
23164 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/proc.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/proc.c
23165 --- linux-2.6.35.2/kernel/vserver/proc.c        1970-01-01 01:00:00.000000000 +0100
23166 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/proc.c  2010-08-02 17:05:06.000000000 +0200
23167 @@ -0,0 +1,1098 @@
23168 +/*
23169 + *  linux/kernel/vserver/proc.c
23170 + *
23171 + *  Virtual Context Support
23172 + *
23173 + *  Copyright (C) 2003-2007  Herbert Pötzl
23174 + *
23175 + *  V0.01  basic structure
23176 + *  V0.02  adaptation vs1.3.0
23177 + *  V0.03  proc permissions
23178 + *  V0.04  locking/generic
23179 + *  V0.05  next generation procfs
23180 + *  V0.06  inode validation
23181 + *  V0.07  generic rewrite vid
23182 + *  V0.08  remove inode type
23183 + *
23184 + */
23185 +
23186 +#include <linux/proc_fs.h>
23187 +#include <linux/fs_struct.h>
23188 +#include <linux/mount.h>
23189 +#include <asm/unistd.h>
23190 +
23191 +#include <linux/vs_context.h>
23192 +#include <linux/vs_network.h>
23193 +#include <linux/vs_cvirt.h>
23194 +
23195 +#include <linux/in.h>
23196 +#include <linux/inetdevice.h>
23197 +#include <linux/vs_inet.h>
23198 +#include <linux/vs_inet6.h>
23199 +
23200 +#include <linux/vserver/global.h>
23201 +
23202 +#include "cvirt_proc.h"
23203 +#include "cacct_proc.h"
23204 +#include "limit_proc.h"
23205 +#include "sched_proc.h"
23206 +#include "vci_config.h"
23207 +
23208 +
23209 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23210 +{
23211 +       unsigned __capi;
23212 +
23213 +       CAP_FOR_EACH_U32(__capi) {
23214 +               buffer += sprintf(buffer, "%08x",
23215 +                       c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23216 +       }
23217 +       return buffer;
23218 +}
23219 +
23220 +
23221 +static struct proc_dir_entry *proc_virtual;
23222 +
23223 +static struct proc_dir_entry *proc_virtnet;
23224 +
23225 +
23226 +/* first the actual feeds */
23227 +
23228 +
23229 +static int proc_vci(char *buffer)
23230 +{
23231 +       return sprintf(buffer,
23232 +               "VCIVersion:\t%04x:%04x\n"
23233 +               "VCISyscall:\t%d\n"
23234 +               "VCIKernel:\t%08x\n",
23235 +               VCI_VERSION >> 16,
23236 +               VCI_VERSION & 0xFFFF,
23237 +               __NR_vserver,
23238 +               vci_kernel_config());
23239 +}
23240 +
23241 +static int proc_virtual_info(char *buffer)
23242 +{
23243 +       return proc_vci(buffer);
23244 +}
23245 +
23246 +static int proc_virtual_status(char *buffer)
23247 +{
23248 +       return sprintf(buffer,
23249 +               "#CTotal:\t%d\n"
23250 +               "#CActive:\t%d\n"
23251 +               "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23252 +               "#InitTask:\t%d\t%d %d\n",
23253 +               atomic_read(&vx_global_ctotal),
23254 +               atomic_read(&vx_global_cactive),
23255 +               atomic_read(&vs_global_nsproxy),
23256 +               atomic_read(&vs_global_fs),
23257 +               atomic_read(&vs_global_mnt_ns),
23258 +               atomic_read(&vs_global_uts_ns),
23259 +               atomic_read(&nr_ipc_ns),
23260 +               atomic_read(&vs_global_user_ns),
23261 +               atomic_read(&vs_global_pid_ns),
23262 +               atomic_read(&init_task.usage),
23263 +               atomic_read(&init_task.nsproxy->count),
23264 +               init_task.fs->users);
23265 +}
23266 +
23267 +
23268 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23269 +{
23270 +       int length;
23271 +
23272 +       length = sprintf(buffer,
23273 +               "ID:\t%d\n"
23274 +               "Info:\t%p\n"
23275 +               "Init:\t%d\n"
23276 +               "OOM:\t%lld\n",
23277 +               vxi->vx_id,
23278 +               vxi,
23279 +               vxi->vx_initpid,
23280 +               vxi->vx_badness_bias);
23281 +       return length;
23282 +}
23283 +
23284 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23285 +{
23286 +       char *orig = buffer;
23287 +
23288 +       buffer += sprintf(buffer,
23289 +               "UseCnt:\t%d\n"
23290 +               "Tasks:\t%d\n"
23291 +               "Flags:\t%016llx\n",
23292 +               atomic_read(&vxi->vx_usecnt),
23293 +               atomic_read(&vxi->vx_tasks),
23294 +               (unsigned long long)vxi->vx_flags);
23295 +
23296 +       buffer += sprintf(buffer, "BCaps:\t");
23297 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23298 +       buffer += sprintf(buffer, "\n");
23299 +
23300 +       buffer += sprintf(buffer,
23301 +               "CCaps:\t%016llx\n"
23302 +               "Spaces:\t%08lx %08lx\n",
23303 +               (unsigned long long)vxi->vx_ccaps,
23304 +               vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
23305 +       return buffer - orig;
23306 +}
23307 +
23308 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23309 +{
23310 +       return vx_info_proc_limit(&vxi->limit, buffer);
23311 +}
23312 +
23313 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23314 +{
23315 +       int cpu, length;
23316 +
23317 +       length = vx_info_proc_sched(&vxi->sched, buffer);
23318 +       for_each_online_cpu(cpu) {
23319 +               length += vx_info_proc_sched_pc(
23320 +                       &vx_per_cpu(vxi, sched_pc, cpu),
23321 +                       buffer + length, cpu);
23322 +       }
23323 +       return length;
23324 +}
23325 +
23326 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23327 +{
23328 +       return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
23329 +}
23330 +
23331 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23332 +{
23333 +       return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
23334 +}
23335 +
23336 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23337 +{
23338 +       int cpu, length;
23339 +
23340 +       vx_update_load(vxi);
23341 +       length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23342 +       for_each_online_cpu(cpu) {
23343 +               length += vx_info_proc_cvirt_pc(
23344 +                       &vx_per_cpu(vxi, cvirt_pc, cpu),
23345 +                       buffer + length, cpu);
23346 +       }
23347 +       return length;
23348 +}
23349 +
23350 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23351 +{
23352 +       return vx_info_proc_cacct(&vxi->cacct, buffer);
23353 +}
23354 +
23355 +
23356 +static int proc_virtnet_info(char *buffer)
23357 +{
23358 +       return proc_vci(buffer);
23359 +}
23360 +
23361 +static int proc_virtnet_status(char *buffer)
23362 +{
23363 +       return sprintf(buffer,
23364 +               "#CTotal:\t%d\n"
23365 +               "#CActive:\t%d\n",
23366 +               atomic_read(&nx_global_ctotal),
23367 +               atomic_read(&nx_global_cactive));
23368 +}
23369 +
23370 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23371 +{
23372 +       struct nx_addr_v4 *v4a;
23373 +#ifdef CONFIG_IPV6
23374 +       struct nx_addr_v6 *v6a;
23375 +#endif
23376 +       int length, i;
23377 +
23378 +       length = sprintf(buffer,
23379 +               "ID:\t%d\n"
23380 +               "Info:\t%p\n"
23381 +               "Bcast:\t" NIPQUAD_FMT "\n"
23382 +               "Lback:\t" NIPQUAD_FMT "\n",
23383 +               nxi->nx_id,
23384 +               nxi,
23385 +               NIPQUAD(nxi->v4_bcast.s_addr),
23386 +               NIPQUAD(nxi->v4_lback.s_addr));
23387 +
23388 +       if (!NX_IPV4(nxi))
23389 +               goto skip_v4;
23390 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23391 +               length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23392 +                       i, NXAV4(v4a));
23393 +skip_v4:
23394 +#ifdef CONFIG_IPV6
23395 +       if (!NX_IPV6(nxi))
23396 +               goto skip_v6;
23397 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23398 +               length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23399 +                       i, NXAV6(v6a));
23400 +skip_v6:
23401 +#endif
23402 +       return length;
23403 +}
23404 +
23405 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23406 +{
23407 +       int length;
23408 +
23409 +       length = sprintf(buffer,
23410 +               "UseCnt:\t%d\n"
23411 +               "Tasks:\t%d\n"
23412 +               "Flags:\t%016llx\n"
23413 +               "NCaps:\t%016llx\n",
23414 +               atomic_read(&nxi->nx_usecnt),
23415 +               atomic_read(&nxi->nx_tasks),
23416 +               (unsigned long long)nxi->nx_flags,
23417 +               (unsigned long long)nxi->nx_ncaps);
23418 +       return length;
23419 +}
23420 +
23421 +
23422 +
23423 +/* here the inode helpers */
23424 +
23425 +struct vs_entry {
23426 +       int len;
23427 +       char *name;
23428 +       mode_t mode;
23429 +       struct inode_operations *iop;
23430 +       struct file_operations *fop;
23431 +       union proc_op op;
23432 +};
23433 +
23434 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23435 +{
23436 +       struct inode *inode = new_inode(sb);
23437 +
23438 +       if (!inode)
23439 +               goto out;
23440 +
23441 +       inode->i_mode = p->mode;
23442 +       if (p->iop)
23443 +               inode->i_op = p->iop;
23444 +       if (p->fop)
23445 +               inode->i_fop = p->fop;
23446 +
23447 +       inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23448 +       inode->i_flags |= S_IMMUTABLE;
23449 +
23450 +       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23451 +
23452 +       inode->i_uid = 0;
23453 +       inode->i_gid = 0;
23454 +       inode->i_tag = 0;
23455 +out:
23456 +       return inode;
23457 +}
23458 +
23459 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23460 +       struct dentry *dentry, int id, void *ptr)
23461 +{
23462 +       struct vs_entry *p = ptr;
23463 +       struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23464 +       struct dentry *error = ERR_PTR(-EINVAL);
23465 +
23466 +       if (!inode)
23467 +               goto out;
23468 +
23469 +       PROC_I(inode)->op = p->op;
23470 +       PROC_I(inode)->fd = id;
23471 +       d_add(dentry, inode);
23472 +       error = NULL;
23473 +out:
23474 +       return error;
23475 +}
23476 +
23477 +/* Lookups */
23478 +
23479 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23480 +
23481 +/*
23482 + * Fill a directory entry.
23483 + *
23484 + * If possible create the dcache entry and derive our inode number and
23485 + * file type from dcache entry.
23486 + *
23487 + * Since all of the proc inode numbers are dynamically generated, the inode
23488 + * numbers do not exist until the inode is cache.  This means creating the
23489 + * the dcache entry in readdir is necessary to keep the inode numbers
23490 + * reported by readdir in sync with the inode numbers reported
23491 + * by stat.
23492 + */
23493 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23494 +       char *name, int len, instantiate_t instantiate, int id, void *ptr)
23495 +{
23496 +       struct dentry *child, *dir = filp->f_dentry;
23497 +       struct inode *inode;
23498 +       struct qstr qname;
23499 +       ino_t ino = 0;
23500 +       unsigned type = DT_UNKNOWN;
23501 +
23502 +       qname.name = name;
23503 +       qname.len  = len;
23504 +       qname.hash = full_name_hash(name, len);
23505 +
23506 +       child = d_lookup(dir, &qname);
23507 +       if (!child) {
23508 +               struct dentry *new;
23509 +               new = d_alloc(dir, &qname);
23510 +               if (new) {
23511 +                       child = instantiate(dir->d_inode, new, id, ptr);
23512 +                       if (child)
23513 +                               dput(new);
23514 +                       else
23515 +                               child = new;
23516 +               }
23517 +       }
23518 +       if (!child || IS_ERR(child) || !child->d_inode)
23519 +               goto end_instantiate;
23520 +       inode = child->d_inode;
23521 +       if (inode) {
23522 +               ino = inode->i_ino;
23523 +               type = inode->i_mode >> 12;
23524 +       }
23525 +       dput(child);
23526 +end_instantiate:
23527 +       if (!ino)
23528 +               ino = find_inode_number(dir, &qname);
23529 +       if (!ino)
23530 +               ino = 1;
23531 +       return filldir(dirent, name, len, filp->f_pos, ino, type);
23532 +}
23533 +
23534 +
23535 +
23536 +/* get and revalidate vx_info/xid */
23537 +
23538 +static inline
23539 +struct vx_info *get_proc_vx_info(struct inode *inode)
23540 +{
23541 +       return lookup_vx_info(PROC_I(inode)->fd);
23542 +}
23543 +
23544 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23545 +{
23546 +       struct inode *inode = dentry->d_inode;
23547 +       xid_t xid = PROC_I(inode)->fd;
23548 +
23549 +       if (!xid || xid_is_hashed(xid))
23550 +               return 1;
23551 +       d_drop(dentry);
23552 +       return 0;
23553 +}
23554 +
23555 +
23556 +/* get and revalidate nx_info/nid */
23557 +
23558 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23559 +{
23560 +       struct inode *inode = dentry->d_inode;
23561 +       nid_t nid = PROC_I(inode)->fd;
23562 +
23563 +       if (!nid || nid_is_hashed(nid))
23564 +               return 1;
23565 +       d_drop(dentry);
23566 +       return 0;
23567 +}
23568 +
23569 +
23570 +
23571 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23572 +
23573 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23574 +                         size_t count, loff_t *ppos)
23575 +{
23576 +       struct inode *inode = file->f_dentry->d_inode;
23577 +       unsigned long page;
23578 +       ssize_t length = 0;
23579 +
23580 +       if (count > PROC_BLOCK_SIZE)
23581 +               count = PROC_BLOCK_SIZE;
23582 +
23583 +       /* fade that out as soon as stable */
23584 +       WARN_ON(PROC_I(inode)->fd);
23585 +
23586 +       if (!(page = __get_free_page(GFP_KERNEL)))
23587 +               return -ENOMEM;
23588 +
23589 +       BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23590 +       length = PROC_I(inode)->op.proc_vs_read((char *)page);
23591 +
23592 +       if (length >= 0)
23593 +               length = simple_read_from_buffer(buf, count, ppos,
23594 +                       (char *)page, length);
23595 +
23596 +       free_page(page);
23597 +       return length;
23598 +}
23599 +
23600 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23601 +                         size_t count, loff_t *ppos)
23602 +{
23603 +       struct inode *inode = file->f_dentry->d_inode;
23604 +       struct vx_info *vxi = NULL;
23605 +       xid_t xid = PROC_I(inode)->fd;
23606 +       unsigned long page;
23607 +       ssize_t length = 0;
23608 +
23609 +       if (count > PROC_BLOCK_SIZE)
23610 +               count = PROC_BLOCK_SIZE;
23611 +
23612 +       /* fade that out as soon as stable */
23613 +       WARN_ON(!xid);
23614 +       vxi = lookup_vx_info(xid);
23615 +       if (!vxi)
23616 +               goto out;
23617 +
23618 +       length = -ENOMEM;
23619 +       if (!(page = __get_free_page(GFP_KERNEL)))
23620 +               goto out_put;
23621 +
23622 +       BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23623 +       length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23624 +
23625 +       if (length >= 0)
23626 +               length = simple_read_from_buffer(buf, count, ppos,
23627 +                       (char *)page, length);
23628 +
23629 +       free_page(page);
23630 +out_put:
23631 +       put_vx_info(vxi);
23632 +out:
23633 +       return length;
23634 +}
23635 +
23636 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23637 +                         size_t count, loff_t *ppos)
23638 +{
23639 +       struct inode *inode = file->f_dentry->d_inode;
23640 +       struct nx_info *nxi = NULL;
23641 +       nid_t nid = PROC_I(inode)->fd;
23642 +       unsigned long page;
23643 +       ssize_t length = 0;
23644 +
23645 +       if (count > PROC_BLOCK_SIZE)
23646 +               count = PROC_BLOCK_SIZE;
23647 +
23648 +       /* fade that out as soon as stable */
23649 +       WARN_ON(!nid);
23650 +       nxi = lookup_nx_info(nid);
23651 +       if (!nxi)
23652 +               goto out;
23653 +
23654 +       length = -ENOMEM;
23655 +       if (!(page = __get_free_page(GFP_KERNEL)))
23656 +               goto out_put;
23657 +
23658 +       BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23659 +       length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23660 +
23661 +       if (length >= 0)
23662 +               length = simple_read_from_buffer(buf, count, ppos,
23663 +                       (char *)page, length);
23664 +
23665 +       free_page(page);
23666 +out_put:
23667 +       put_nx_info(nxi);
23668 +out:
23669 +       return length;
23670 +}
23671 +
23672 +
23673 +
23674 +/* here comes the lower level */
23675 +
23676 +
23677 +#define NOD(NAME, MODE, IOP, FOP, OP) {        \
23678 +       .len  = sizeof(NAME) - 1,       \
23679 +       .name = (NAME),                 \
23680 +       .mode = MODE,                   \
23681 +       .iop  = IOP,                    \
23682 +       .fop  = FOP,                    \
23683 +       .op   = OP,                     \
23684 +}
23685 +
23686 +
23687 +#define DIR(NAME, MODE, OTYPE)                         \
23688 +       NOD(NAME, (S_IFDIR | (MODE)),                   \
23689 +               &proc_ ## OTYPE ## _inode_operations,   \
23690 +               &proc_ ## OTYPE ## _file_operations, { } )
23691 +
23692 +#define INF(NAME, MODE, OTYPE)                         \
23693 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23694 +               &proc_vs_info_file_operations,          \
23695 +               { .proc_vs_read = &proc_##OTYPE } )
23696 +
23697 +#define VINF(NAME, MODE, OTYPE)                                \
23698 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23699 +               &proc_vx_info_file_operations,          \
23700 +               { .proc_vxi_read = &proc_##OTYPE } )
23701 +
23702 +#define NINF(NAME, MODE, OTYPE)                                \
23703 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23704 +               &proc_nx_info_file_operations,          \
23705 +               { .proc_nxi_read = &proc_##OTYPE } )
23706 +
23707 +
23708 +static struct file_operations proc_vs_info_file_operations = {
23709 +       .read =         proc_vs_info_read,
23710 +};
23711 +
23712 +static struct file_operations proc_vx_info_file_operations = {
23713 +       .read =         proc_vx_info_read,
23714 +};
23715 +
23716 +static struct dentry_operations proc_xid_dentry_operations = {
23717 +       .d_revalidate = proc_xid_revalidate,
23718 +};
23719 +
23720 +static struct vs_entry vx_base_stuff[] = {
23721 +       VINF("info",    S_IRUGO, vxi_info),
23722 +       VINF("status",  S_IRUGO, vxi_status),
23723 +       VINF("limit",   S_IRUGO, vxi_limit),
23724 +       VINF("sched",   S_IRUGO, vxi_sched),
23725 +       VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23726 +       VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23727 +       VINF("cvirt",   S_IRUGO, vxi_cvirt),
23728 +       VINF("cacct",   S_IRUGO, vxi_cacct),
23729 +       {}
23730 +};
23731 +
23732 +
23733 +
23734 +
23735 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23736 +       struct dentry *dentry, int id, void *ptr)
23737 +{
23738 +       dentry->d_op = &proc_xid_dentry_operations;
23739 +       return vs_proc_instantiate(dir, dentry, id, ptr);
23740 +}
23741 +
23742 +static struct dentry *proc_xid_lookup(struct inode *dir,
23743 +       struct dentry *dentry, struct nameidata *nd)
23744 +{
23745 +       struct vs_entry *p = vx_base_stuff;
23746 +       struct dentry *error = ERR_PTR(-ENOENT);
23747 +
23748 +       for (; p->name; p++) {
23749 +               if (p->len != dentry->d_name.len)
23750 +                       continue;
23751 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23752 +                       break;
23753 +       }
23754 +       if (!p->name)
23755 +               goto out;
23756 +
23757 +       error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23758 +out:
23759 +       return error;
23760 +}
23761 +
23762 +static int proc_xid_readdir(struct file *filp,
23763 +       void *dirent, filldir_t filldir)
23764 +{
23765 +       struct dentry *dentry = filp->f_dentry;
23766 +       struct inode *inode = dentry->d_inode;
23767 +       struct vs_entry *p = vx_base_stuff;
23768 +       int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23769 +       int pos, index;
23770 +       u64 ino;
23771 +
23772 +       pos = filp->f_pos;
23773 +       switch (pos) {
23774 +       case 0:
23775 +               ino = inode->i_ino;
23776 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23777 +                       goto out;
23778 +               pos++;
23779 +               /* fall through */
23780 +       case 1:
23781 +               ino = parent_ino(dentry);
23782 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23783 +                       goto out;
23784 +               pos++;
23785 +               /* fall through */
23786 +       default:
23787 +               index = pos - 2;
23788 +               if (index >= size)
23789 +                       goto out;
23790 +               for (p += index; p->name; p++) {
23791 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23792 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
23793 +                               goto out;
23794 +                       pos++;
23795 +               }
23796 +       }
23797 +out:
23798 +       filp->f_pos = pos;
23799 +       return 1;
23800 +}
23801 +
23802 +
23803 +
23804 +static struct file_operations proc_nx_info_file_operations = {
23805 +       .read =         proc_nx_info_read,
23806 +};
23807 +
23808 +static struct dentry_operations proc_nid_dentry_operations = {
23809 +       .d_revalidate = proc_nid_revalidate,
23810 +};
23811 +
23812 +static struct vs_entry nx_base_stuff[] = {
23813 +       NINF("info",    S_IRUGO, nxi_info),
23814 +       NINF("status",  S_IRUGO, nxi_status),
23815 +       {}
23816 +};
23817 +
23818 +
23819 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23820 +       struct dentry *dentry, int id, void *ptr)
23821 +{
23822 +       dentry->d_op = &proc_nid_dentry_operations;
23823 +       return vs_proc_instantiate(dir, dentry, id, ptr);
23824 +}
23825 +
23826 +static struct dentry *proc_nid_lookup(struct inode *dir,
23827 +       struct dentry *dentry, struct nameidata *nd)
23828 +{
23829 +       struct vs_entry *p = nx_base_stuff;
23830 +       struct dentry *error = ERR_PTR(-ENOENT);
23831 +
23832 +       for (; p->name; p++) {
23833 +               if (p->len != dentry->d_name.len)
23834 +                       continue;
23835 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23836 +                       break;
23837 +       }
23838 +       if (!p->name)
23839 +               goto out;
23840 +
23841 +       error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23842 +out:
23843 +       return error;
23844 +}
23845 +
23846 +static int proc_nid_readdir(struct file *filp,
23847 +       void *dirent, filldir_t filldir)
23848 +{
23849 +       struct dentry *dentry = filp->f_dentry;
23850 +       struct inode *inode = dentry->d_inode;
23851 +       struct vs_entry *p = nx_base_stuff;
23852 +       int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23853 +       int pos, index;
23854 +       u64 ino;
23855 +
23856 +       pos = filp->f_pos;
23857 +       switch (pos) {
23858 +       case 0:
23859 +               ino = inode->i_ino;
23860 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23861 +                       goto out;
23862 +               pos++;
23863 +               /* fall through */
23864 +       case 1:
23865 +               ino = parent_ino(dentry);
23866 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23867 +                       goto out;
23868 +               pos++;
23869 +               /* fall through */
23870 +       default:
23871 +               index = pos - 2;
23872 +               if (index >= size)
23873 +                       goto out;
23874 +               for (p += index; p->name; p++) {
23875 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23876 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
23877 +                               goto out;
23878 +                       pos++;
23879 +               }
23880 +       }
23881 +out:
23882 +       filp->f_pos = pos;
23883 +       return 1;
23884 +}
23885 +
23886 +
23887 +#define MAX_MULBY10    ((~0U - 9) / 10)
23888 +
23889 +static inline int atovid(const char *str, int len)
23890 +{
23891 +       int vid, c;
23892 +
23893 +       vid = 0;
23894 +       while (len-- > 0) {
23895 +               c = *str - '0';
23896 +               str++;
23897 +               if (c > 9)
23898 +                       return -1;
23899 +               if (vid >= MAX_MULBY10)
23900 +                       return -1;
23901 +               vid *= 10;
23902 +               vid += c;
23903 +               if (!vid)
23904 +                       return -1;
23905 +       }
23906 +       return vid;
23907 +}
23908 +
23909 +/* now the upper level (virtual) */
23910 +
23911 +
23912 +static struct file_operations proc_xid_file_operations = {
23913 +       .read =         generic_read_dir,
23914 +       .readdir =      proc_xid_readdir,
23915 +};
23916 +
23917 +static struct inode_operations proc_xid_inode_operations = {
23918 +       .lookup =       proc_xid_lookup,
23919 +};
23920 +
23921 +static struct vs_entry vx_virtual_stuff[] = {
23922 +       INF("info",     S_IRUGO, virtual_info),
23923 +       INF("status",   S_IRUGO, virtual_status),
23924 +       DIR(NULL,       S_IRUGO | S_IXUGO, xid),
23925 +};
23926 +
23927 +
23928 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23929 +       struct dentry *dentry, struct nameidata *nd)
23930 +{
23931 +       struct vs_entry *p = vx_virtual_stuff;
23932 +       struct dentry *error = ERR_PTR(-ENOENT);
23933 +       int id = 0;
23934 +
23935 +       for (; p->name; p++) {
23936 +               if (p->len != dentry->d_name.len)
23937 +                       continue;
23938 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23939 +                       break;
23940 +       }
23941 +       if (p->name)
23942 +               goto instantiate;
23943 +
23944 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
23945 +       if ((id < 0) || !xid_is_hashed(id))
23946 +               goto out;
23947 +
23948 +instantiate:
23949 +       error = proc_xid_instantiate(dir, dentry, id, p);
23950 +out:
23951 +       return error;
23952 +}
23953 +
23954 +static struct file_operations proc_nid_file_operations = {
23955 +       .read =         generic_read_dir,
23956 +       .readdir =      proc_nid_readdir,
23957 +};
23958 +
23959 +static struct inode_operations proc_nid_inode_operations = {
23960 +       .lookup =       proc_nid_lookup,
23961 +};
23962 +
23963 +static struct vs_entry nx_virtnet_stuff[] = {
23964 +       INF("info",     S_IRUGO, virtnet_info),
23965 +       INF("status",   S_IRUGO, virtnet_status),
23966 +       DIR(NULL,       S_IRUGO | S_IXUGO, nid),
23967 +};
23968 +
23969 +
23970 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23971 +       struct dentry *dentry, struct nameidata *nd)
23972 +{
23973 +       struct vs_entry *p = nx_virtnet_stuff;
23974 +       struct dentry *error = ERR_PTR(-ENOENT);
23975 +       int id = 0;
23976 +
23977 +       for (; p->name; p++) {
23978 +               if (p->len != dentry->d_name.len)
23979 +                       continue;
23980 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23981 +                       break;
23982 +       }
23983 +       if (p->name)
23984 +               goto instantiate;
23985 +
23986 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
23987 +       if ((id < 0) || !nid_is_hashed(id))
23988 +               goto out;
23989 +
23990 +instantiate:
23991 +       error = proc_nid_instantiate(dir, dentry, id, p);
23992 +out:
23993 +       return error;
23994 +}
23995 +
23996 +
23997 +#define PROC_MAXVIDS 32
23998 +
23999 +int proc_virtual_readdir(struct file *filp,
24000 +       void *dirent, filldir_t filldir)
24001 +{
24002 +       struct dentry *dentry = filp->f_dentry;
24003 +       struct inode *inode = dentry->d_inode;
24004 +       struct vs_entry *p = vx_virtual_stuff;
24005 +       int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24006 +       int pos, index;
24007 +       unsigned int xid_array[PROC_MAXVIDS];
24008 +       char buf[PROC_NUMBUF];
24009 +       unsigned int nr_xids, i;
24010 +       u64 ino;
24011 +
24012 +       pos = filp->f_pos;
24013 +       switch (pos) {
24014 +       case 0:
24015 +               ino = inode->i_ino;
24016 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24017 +                       goto out;
24018 +               pos++;
24019 +               /* fall through */
24020 +       case 1:
24021 +               ino = parent_ino(dentry);
24022 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24023 +                       goto out;
24024 +               pos++;
24025 +               /* fall through */
24026 +       default:
24027 +               index = pos - 2;
24028 +               if (index >= size)
24029 +                       goto entries;
24030 +               for (p += index; p->name; p++) {
24031 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24032 +                               vs_proc_instantiate, 0, p))
24033 +                               goto out;
24034 +                       pos++;
24035 +               }
24036 +       entries:
24037 +               index = pos - size;
24038 +               p = &vx_virtual_stuff[size - 1];
24039 +               nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24040 +               for (i = 0; i < nr_xids; i++) {
24041 +                       int n, xid = xid_array[i];
24042 +                       unsigned int j = PROC_NUMBUF;
24043 +
24044 +                       n = xid;
24045 +                       do
24046 +                               buf[--j] = '0' + (n % 10);
24047 +                       while (n /= 10);
24048 +
24049 +                       if (proc_fill_cache(filp, dirent, filldir,
24050 +                               buf + j, PROC_NUMBUF - j,
24051 +                               vs_proc_instantiate, xid, p))
24052 +                               goto out;
24053 +                       pos++;
24054 +               }
24055 +       }
24056 +out:
24057 +       filp->f_pos = pos;
24058 +       return 0;
24059 +}
24060 +
24061 +static int proc_virtual_getattr(struct vfsmount *mnt,
24062 +       struct dentry *dentry, struct kstat *stat)
24063 +{
24064 +       struct inode *inode = dentry->d_inode;
24065 +
24066 +       generic_fillattr(inode, stat);
24067 +       stat->nlink = 2 + atomic_read(&vx_global_cactive);
24068 +       return 0;
24069 +}
24070 +
24071 +static struct file_operations proc_virtual_dir_operations = {
24072 +       .read =         generic_read_dir,
24073 +       .readdir =      proc_virtual_readdir,
24074 +};
24075 +
24076 +static struct inode_operations proc_virtual_dir_inode_operations = {
24077 +       .getattr =      proc_virtual_getattr,
24078 +       .lookup =       proc_virtual_lookup,
24079 +};
24080 +
24081 +
24082 +
24083 +
24084 +
24085 +int proc_virtnet_readdir(struct file *filp,
24086 +       void *dirent, filldir_t filldir)
24087 +{
24088 +       struct dentry *dentry = filp->f_dentry;
24089 +       struct inode *inode = dentry->d_inode;
24090 +       struct vs_entry *p = nx_virtnet_stuff;
24091 +       int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24092 +       int pos, index;
24093 +       unsigned int nid_array[PROC_MAXVIDS];
24094 +       char buf[PROC_NUMBUF];
24095 +       unsigned int nr_nids, i;
24096 +       u64 ino;
24097 +
24098 +       pos = filp->f_pos;
24099 +       switch (pos) {
24100 +       case 0:
24101 +               ino = inode->i_ino;
24102 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24103 +                       goto out;
24104 +               pos++;
24105 +               /* fall through */
24106 +       case 1:
24107 +               ino = parent_ino(dentry);
24108 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24109 +                       goto out;
24110 +               pos++;
24111 +               /* fall through */
24112 +       default:
24113 +               index = pos - 2;
24114 +               if (index >= size)
24115 +                       goto entries;
24116 +               for (p += index; p->name; p++) {
24117 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24118 +                               vs_proc_instantiate, 0, p))
24119 +                               goto out;
24120 +                       pos++;
24121 +               }
24122 +       entries:
24123 +               index = pos - size;
24124 +               p = &nx_virtnet_stuff[size - 1];
24125 +               nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24126 +               for (i = 0; i < nr_nids; i++) {
24127 +                       int n, nid = nid_array[i];
24128 +                       unsigned int j = PROC_NUMBUF;
24129 +
24130 +                       n = nid;
24131 +                       do
24132 +                               buf[--j] = '0' + (n % 10);
24133 +                       while (n /= 10);
24134 +
24135 +                       if (proc_fill_cache(filp, dirent, filldir,
24136 +                               buf + j, PROC_NUMBUF - j,
24137 +                               vs_proc_instantiate, nid, p))
24138 +                               goto out;
24139 +                       pos++;
24140 +               }
24141 +       }
24142 +out:
24143 +       filp->f_pos = pos;
24144 +       return 0;
24145 +}
24146 +
24147 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24148 +       struct dentry *dentry, struct kstat *stat)
24149 +{
24150 +       struct inode *inode = dentry->d_inode;
24151 +
24152 +       generic_fillattr(inode, stat);
24153 +       stat->nlink = 2 + atomic_read(&nx_global_cactive);
24154 +       return 0;
24155 +}
24156 +
24157 +static struct file_operations proc_virtnet_dir_operations = {
24158 +       .read =         generic_read_dir,
24159 +       .readdir =      proc_virtnet_readdir,
24160 +};
24161 +
24162 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24163 +       .getattr =      proc_virtnet_getattr,
24164 +       .lookup =       proc_virtnet_lookup,
24165 +};
24166 +
24167 +
24168 +
24169 +void proc_vx_init(void)
24170 +{
24171 +       struct proc_dir_entry *ent;
24172 +
24173 +       ent = proc_mkdir("virtual", 0);
24174 +       if (ent) {
24175 +               ent->proc_fops = &proc_virtual_dir_operations;
24176 +               ent->proc_iops = &proc_virtual_dir_inode_operations;
24177 +       }
24178 +       proc_virtual = ent;
24179 +
24180 +       ent = proc_mkdir("virtnet", 0);
24181 +       if (ent) {
24182 +               ent->proc_fops = &proc_virtnet_dir_operations;
24183 +               ent->proc_iops = &proc_virtnet_dir_inode_operations;
24184 +       }
24185 +       proc_virtnet = ent;
24186 +}
24187 +
24188 +
24189 +
24190 +
24191 +/* per pid info */
24192 +
24193 +
24194 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24195 +{
24196 +       struct vx_info *vxi;
24197 +       char *orig = buffer;
24198 +
24199 +       buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24200 +
24201 +       vxi = task_get_vx_info(p);
24202 +       if (!vxi)
24203 +               goto out;
24204 +
24205 +       buffer += sprintf(buffer, "BCaps:\t");
24206 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24207 +       buffer += sprintf(buffer, "\n");
24208 +       buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24209 +               (unsigned long long)vxi->vx_ccaps);
24210 +       buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24211 +               (unsigned long long)vxi->vx_flags);
24212 +       buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24213 +
24214 +       put_vx_info(vxi);
24215 +out:
24216 +       return buffer - orig;
24217 +}
24218 +
24219 +
24220 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24221 +{
24222 +       struct nx_info *nxi;
24223 +       struct nx_addr_v4 *v4a;
24224 +#ifdef CONFIG_IPV6
24225 +       struct nx_addr_v6 *v6a;
24226 +#endif
24227 +       char *orig = buffer;
24228 +       int i;
24229 +
24230 +       buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24231 +
24232 +       nxi = task_get_nx_info(p);
24233 +       if (!nxi)
24234 +               goto out;
24235 +
24236 +       buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24237 +               (unsigned long long)nxi->nx_ncaps);
24238 +       buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24239 +               (unsigned long long)nxi->nx_flags);
24240 +
24241 +       buffer += sprintf(buffer,
24242 +               "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24243 +               NIPQUAD(nxi->v4_bcast.s_addr));
24244 +       buffer += sprintf (buffer,
24245 +               "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24246 +               NIPQUAD(nxi->v4_lback.s_addr));
24247 +       if (!NX_IPV4(nxi))
24248 +               goto skip_v4;
24249 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24250 +               buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24251 +                       i, NXAV4(v4a));
24252 +skip_v4:
24253 +#ifdef CONFIG_IPV6
24254 +       if (!NX_IPV6(nxi))
24255 +               goto skip_v6;
24256 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24257 +               buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24258 +                       i, NXAV6(v6a));
24259 +skip_v6:
24260 +#endif
24261 +       put_nx_info(nxi);
24262 +out:
24263 +       return buffer - orig;
24264 +}
24265 +
24266 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/sched.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/sched.c
24267 --- linux-2.6.35.2/kernel/vserver/sched.c       1970-01-01 01:00:00.000000000 +0100
24268 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/sched.c 2010-08-02 17:05:06.000000000 +0200
24269 @@ -0,0 +1,414 @@
24270 +/*
24271 + *  linux/kernel/vserver/sched.c
24272 + *
24273 + *  Virtual Server: Scheduler Support
24274 + *
24275 + *  Copyright (C) 2004-2007  Herbert Pötzl
24276 + *
24277 + *  V0.01  adapted Sam Vilains version to 2.6.3
24278 + *  V0.02  removed legacy interface
24279 + *  V0.03  changed vcmds to vxi arg
24280 + *  V0.04  removed older and legacy interfaces
24281 + *
24282 + */
24283 +
24284 +#include <linux/vs_context.h>
24285 +#include <linux/vs_sched.h>
24286 +#include <linux/vserver/sched_cmd.h>
24287 +
24288 +#include <asm/uaccess.h>
24289 +
24290 +
24291 +#define vxd_check_range(val, min, max) do {            \
24292 +       vxlprintk((val < min) || (val > max),           \
24293 +               "check_range(%ld,%ld,%ld)",             \
24294 +               (long)val, (long)min, (long)max,        \
24295 +               __FILE__, __LINE__);                    \
24296 +       } while (0)
24297 +
24298 +
24299 +void vx_update_sched_param(struct _vx_sched *sched,
24300 +       struct _vx_sched_pc *sched_pc)
24301 +{
24302 +       unsigned int set_mask = sched->update_mask;
24303 +
24304 +       if (set_mask & VXSM_FILL_RATE)
24305 +               sched_pc->fill_rate[0] = sched->fill_rate[0];
24306 +       if (set_mask & VXSM_INTERVAL)
24307 +               sched_pc->interval[0] = sched->interval[0];
24308 +       if (set_mask & VXSM_FILL_RATE2)
24309 +               sched_pc->fill_rate[1] = sched->fill_rate[1];
24310 +       if (set_mask & VXSM_INTERVAL2)
24311 +               sched_pc->interval[1] = sched->interval[1];
24312 +       if (set_mask & VXSM_TOKENS)
24313 +               sched_pc->tokens = sched->tokens;
24314 +       if (set_mask & VXSM_TOKENS_MIN)
24315 +               sched_pc->tokens_min = sched->tokens_min;
24316 +       if (set_mask & VXSM_TOKENS_MAX)
24317 +               sched_pc->tokens_max = sched->tokens_max;
24318 +       if (set_mask & VXSM_PRIO_BIAS)
24319 +               sched_pc->prio_bias = sched->prio_bias;
24320 +
24321 +       if (set_mask & VXSM_IDLE_TIME)
24322 +               sched_pc->flags |= VXSF_IDLE_TIME;
24323 +       else
24324 +               sched_pc->flags &= ~VXSF_IDLE_TIME;
24325 +
24326 +       /* reset time */
24327 +       sched_pc->norm_time = jiffies;
24328 +}
24329 +
24330 +
24331 +/*
24332 + * recalculate the context's scheduling tokens
24333 + *
24334 + * ret > 0 : number of tokens available
24335 + * ret < 0 : on hold, check delta_min[]
24336 + *          -1 only jiffies
24337 + *          -2 also idle time
24338 + *
24339 + */
24340 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24341 +       unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24342 +{
24343 +       long delta;
24344 +       long tokens = 0;
24345 +       int flags = sched_pc->flags;
24346 +
24347 +       /* how much time did pass? */
24348 +       delta = *norm_time - sched_pc->norm_time;
24349 +       // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
24350 +       vxd_check_range(delta, 0, INT_MAX);
24351 +
24352 +       if (delta >= sched_pc->interval[0]) {
24353 +               long tokens, integral;
24354 +
24355 +               /* calc integral token part */
24356 +               tokens = delta / sched_pc->interval[0];
24357 +               integral = tokens * sched_pc->interval[0];
24358 +               tokens *= sched_pc->fill_rate[0];
24359 +#ifdef CONFIG_VSERVER_HARDCPU
24360 +               delta_min[0] = delta - integral;
24361 +               vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24362 +#endif
24363 +               /* advance time */
24364 +               sched_pc->norm_time += delta;
24365 +
24366 +               /* add tokens */
24367 +               sched_pc->tokens += tokens;
24368 +               sched_pc->token_time += tokens;
24369 +       } else
24370 +               delta_min[0] = delta;
24371 +
24372 +#ifdef CONFIG_VSERVER_IDLETIME
24373 +       if (!(flags & VXSF_IDLE_TIME))
24374 +               goto skip_idle;
24375 +
24376 +       /* how much was the idle skip? */
24377 +       delta = *idle_time - sched_pc->idle_time;
24378 +       vxd_check_range(delta, 0, INT_MAX);
24379 +
24380 +       if (delta >= sched_pc->interval[1]) {
24381 +               long tokens, integral;
24382 +
24383 +               /* calc fair share token part */
24384 +               tokens = delta / sched_pc->interval[1];
24385 +               integral = tokens * sched_pc->interval[1];
24386 +               tokens *= sched_pc->fill_rate[1];
24387 +               delta_min[1] = delta - integral;
24388 +               vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24389 +
24390 +               /* advance idle time */
24391 +               sched_pc->idle_time += integral;
24392 +
24393 +               /* add tokens */
24394 +               sched_pc->tokens += tokens;
24395 +               sched_pc->token_time += tokens;
24396 +       } else
24397 +               delta_min[1] = delta;
24398 +skip_idle:
24399 +#endif
24400 +
24401 +       /* clip at maximum */
24402 +       if (sched_pc->tokens > sched_pc->tokens_max)
24403 +               sched_pc->tokens = sched_pc->tokens_max;
24404 +       tokens = sched_pc->tokens;
24405 +
24406 +       if ((flags & VXSF_ONHOLD)) {
24407 +               /* can we unhold? */
24408 +               if (tokens >= sched_pc->tokens_min) {
24409 +                       flags &= ~VXSF_ONHOLD;
24410 +                       sched_pc->hold_ticks +=
24411 +                               *norm_time - sched_pc->onhold;
24412 +               } else
24413 +                       goto on_hold;
24414 +       } else {
24415 +               /* put on hold? */
24416 +               if (tokens <= 0) {
24417 +                       flags |= VXSF_ONHOLD;
24418 +                       sched_pc->onhold = *norm_time;
24419 +                       goto on_hold;
24420 +               }
24421 +       }
24422 +       sched_pc->flags = flags;
24423 +       return tokens;
24424 +
24425 +on_hold:
24426 +       tokens = sched_pc->tokens_min - tokens;
24427 +       sched_pc->flags = flags;
24428 +       // BUG_ON(tokens < 0); probably doesn't hold anymore
24429 +
24430 +#ifdef CONFIG_VSERVER_HARDCPU
24431 +       /* next interval? */
24432 +       if (!sched_pc->fill_rate[0])
24433 +               delta_min[0] = HZ;
24434 +       else if (tokens > sched_pc->fill_rate[0])
24435 +               delta_min[0] += sched_pc->interval[0] *
24436 +                       tokens / sched_pc->fill_rate[0];
24437 +       else
24438 +               delta_min[0] = sched_pc->interval[0] - delta_min[0];
24439 +       vxd_check_range(delta_min[0], 0, INT_MAX);
24440 +
24441 +#ifdef CONFIG_VSERVER_IDLETIME
24442 +       if (!(flags & VXSF_IDLE_TIME))
24443 +               return -1;
24444 +
24445 +       /* next interval? */
24446 +       if (!sched_pc->fill_rate[1])
24447 +               delta_min[1] = HZ;
24448 +       else if (tokens > sched_pc->fill_rate[1])
24449 +               delta_min[1] += sched_pc->interval[1] *
24450 +                       tokens / sched_pc->fill_rate[1];
24451 +       else
24452 +               delta_min[1] = sched_pc->interval[1] - delta_min[1];
24453 +       vxd_check_range(delta_min[1], 0, INT_MAX);
24454 +
24455 +       return -2;
24456 +#else
24457 +       return -1;
24458 +#endif /* CONFIG_VSERVER_IDLETIME */
24459 +#else
24460 +       return 0;
24461 +#endif /* CONFIG_VSERVER_HARDCPU */
24462 +}
24463 +
24464 +static inline unsigned long msec_to_ticks(unsigned long msec)
24465 +{
24466 +       return msecs_to_jiffies(msec);
24467 +}
24468 +
24469 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24470 +{
24471 +       return jiffies_to_msecs(ticks);
24472 +}
24473 +
24474 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24475 +{
24476 +       return jiffies_to_usecs(ticks);
24477 +}
24478 +
24479 +
24480 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24481 +{
24482 +       unsigned int set_mask = data->mask;
24483 +       unsigned int update_mask;
24484 +       int i, cpu;
24485 +
24486 +       /* Sanity check data values */
24487 +       if (data->tokens_max <= 0)
24488 +               data->tokens_max = HZ;
24489 +       if (data->tokens_min < 0)
24490 +               data->tokens_min = HZ / 3;
24491 +       if (data->tokens_min >= data->tokens_max)
24492 +               data->tokens_min = data->tokens_max;
24493 +
24494 +       if (data->prio_bias > MAX_PRIO_BIAS)
24495 +               data->prio_bias = MAX_PRIO_BIAS;
24496 +       if (data->prio_bias < MIN_PRIO_BIAS)
24497 +               data->prio_bias = MIN_PRIO_BIAS;
24498 +
24499 +       spin_lock(&vxi->sched.tokens_lock);
24500 +
24501 +       /* sync up on delayed updates */
24502 +       for_each_cpu_mask(cpu, vxi->sched.update)
24503 +               vx_update_sched_param(&vxi->sched,
24504 +                       &vx_per_cpu(vxi, sched_pc, cpu));
24505 +
24506 +       if (set_mask & VXSM_FILL_RATE)
24507 +               vxi->sched.fill_rate[0] = data->fill_rate[0];
24508 +       if (set_mask & VXSM_FILL_RATE2)
24509 +               vxi->sched.fill_rate[1] = data->fill_rate[1];
24510 +       if (set_mask & VXSM_INTERVAL)
24511 +               vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24512 +                       msec_to_ticks(data->interval[0]) : data->interval[0];
24513 +       if (set_mask & VXSM_INTERVAL2)
24514 +               vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24515 +                       msec_to_ticks(data->interval[1]) : data->interval[1];
24516 +       if (set_mask & VXSM_TOKENS)
24517 +               vxi->sched.tokens = data->tokens;
24518 +       if (set_mask & VXSM_TOKENS_MIN)
24519 +               vxi->sched.tokens_min = data->tokens_min;
24520 +       if (set_mask & VXSM_TOKENS_MAX)
24521 +               vxi->sched.tokens_max = data->tokens_max;
24522 +       if (set_mask & VXSM_PRIO_BIAS)
24523 +               vxi->sched.prio_bias = data->prio_bias;
24524 +
24525 +       /* Sanity check rate/interval */
24526 +       for (i = 0; i < 2; i++) {
24527 +               if (data->fill_rate[i] < 0)
24528 +                       data->fill_rate[i] = 0;
24529 +               if (data->interval[i] <= 0)
24530 +                       data->interval[i] = HZ;
24531 +       }
24532 +
24533 +       update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24534 +       update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24535 +       vxi->sched.update_mask = update_mask;
24536 +
24537 +#ifdef CONFIG_SMP
24538 +       rmb();
24539 +       if (set_mask & VXSM_CPU_ID) {
24540 +               vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24541 +               cpus_and(vxi->sched.update, cpu_online_map,
24542 +                       vxi->sched.update);
24543 +       } else
24544 +               vxi->sched.update = cpu_online_map;
24545 +
24546 +       /* forced reload? */
24547 +       if (set_mask & VXSM_FORCE) {
24548 +               for_each_cpu_mask(cpu, vxi->sched.update)
24549 +                       vx_update_sched_param(&vxi->sched,
24550 +                               &vx_per_cpu(vxi, sched_pc, cpu));
24551 +               vxi->sched.update = CPU_MASK_NONE;
24552 +       }
24553 +#else
24554 +       /* on UP we update immediately */
24555 +       vx_update_sched_param(&vxi->sched,
24556 +               &vx_per_cpu(vxi, sched_pc, 0));
24557 +#endif
24558 +
24559 +       spin_unlock(&vxi->sched.tokens_lock);
24560 +       return 0;
24561 +}
24562 +
24563 +
24564 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24565 +#define COPY_PRI(C) C(prio_bias)
24566 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24567 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]);   \
24568 +                   C(fill_rate[1]); C(interval[1]);
24569 +
24570 +#define COPY_VALUE(name) vc_data.name = data->name
24571 +
24572 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24573 +{
24574 +       struct vcmd_sched_v5 vc_data;
24575 +
24576 +       vc_data.mask = data->set_mask;
24577 +       COPY_IDS(COPY_VALUE);
24578 +       COPY_PRI(COPY_VALUE);
24579 +       COPY_TOK(COPY_VALUE);
24580 +       vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24581 +       vc_data.interval[0] = vc_data.interval[1] = data->interval;
24582 +       return do_set_sched(vxi, &vc_data);
24583 +}
24584 +
24585 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24586 +{
24587 +       struct vcmd_set_sched_v4 vc_data;
24588 +
24589 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24590 +               return -EFAULT;
24591 +
24592 +       return do_set_sched_v4(vxi, &vc_data);
24593 +}
24594 +
24595 +       /* latest interface is v5 */
24596 +
24597 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24598 +{
24599 +       struct vcmd_sched_v5 vc_data;
24600 +
24601 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24602 +               return -EFAULT;
24603 +
24604 +       return do_set_sched(vxi, &vc_data);
24605 +}
24606 +
24607 +
24608 +#define COPY_PRI(C) C(prio_bias)
24609 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24610 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]);    \
24611 +                   C(fill_rate[1]); C(interval[1]);
24612 +
24613 +#define COPY_VALUE(name) vc_data.name = data->name
24614 +
24615 +
24616 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24617 +{
24618 +       struct vcmd_sched_v5 vc_data;
24619 +
24620 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24621 +               return -EFAULT;
24622 +
24623 +       if (vc_data.mask & VXSM_CPU_ID) {
24624 +               int cpu = vc_data.cpu_id;
24625 +               struct _vx_sched_pc *data;
24626 +
24627 +               if (!cpu_possible(cpu))
24628 +                       return -EINVAL;
24629 +
24630 +               data = &vx_per_cpu(vxi, sched_pc, cpu);
24631 +               COPY_TOK(COPY_VALUE);
24632 +               COPY_PRI(COPY_VALUE);
24633 +               COPY_FRI(COPY_VALUE);
24634 +
24635 +               if (data->flags & VXSF_IDLE_TIME)
24636 +                       vc_data.mask |= VXSM_IDLE_TIME;
24637 +       } else {
24638 +               struct _vx_sched *data = &vxi->sched;
24639 +
24640 +               COPY_TOK(COPY_VALUE);
24641 +               COPY_PRI(COPY_VALUE);
24642 +               COPY_FRI(COPY_VALUE);
24643 +       }
24644 +
24645 +       if (vc_data.mask & VXSM_MSEC) {
24646 +               vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24647 +               vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24648 +       }
24649 +
24650 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24651 +               return -EFAULT;
24652 +       return 0;
24653 +}
24654 +
24655 +
24656 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24657 +{
24658 +       struct vcmd_sched_info vc_data;
24659 +       int cpu;
24660 +
24661 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24662 +               return -EFAULT;
24663 +
24664 +       cpu = vc_data.cpu_id;
24665 +       if (!cpu_possible(cpu))
24666 +               return -EINVAL;
24667 +
24668 +       if (vxi) {
24669 +               struct _vx_sched_pc *sched_pc =
24670 +                       &vx_per_cpu(vxi, sched_pc, cpu);
24671 +
24672 +               vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24673 +               vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24674 +               vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24675 +               vc_data.vavavoom = sched_pc->vavavoom;
24676 +       }
24677 +       vc_data.token_usec = ticks_to_usec(1);
24678 +
24679 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24680 +               return -EFAULT;
24681 +       return 0;
24682 +}
24683 +
24684 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/sched_init.h linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/sched_init.h
24685 --- linux-2.6.35.2/kernel/vserver/sched_init.h  1970-01-01 01:00:00.000000000 +0100
24686 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/sched_init.h    2010-08-02 17:05:06.000000000 +0200
24687 @@ -0,0 +1,50 @@
24688 +
24689 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24690 +{
24691 +       static struct lock_class_key tokens_lock_key;
24692 +
24693 +       /* scheduling; hard code starting values as constants */
24694 +       sched->fill_rate[0]     = 1;
24695 +       sched->interval[0]      = 4;
24696 +       sched->fill_rate[1]     = 1;
24697 +       sched->interval[1]      = 8;
24698 +       sched->tokens           = HZ >> 2;
24699 +       sched->tokens_min       = HZ >> 4;
24700 +       sched->tokens_max       = HZ >> 1;
24701 +       sched->tokens_lock      = SPIN_LOCK_UNLOCKED;
24702 +       sched->prio_bias        = 0;
24703 +
24704 +       lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24705 +}
24706 +
24707 +static inline
24708 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24709 +{
24710 +       sched_pc->fill_rate[0]  = 1;
24711 +       sched_pc->interval[0]   = 4;
24712 +       sched_pc->fill_rate[1]  = 1;
24713 +       sched_pc->interval[1]   = 8;
24714 +       sched_pc->tokens        = HZ >> 2;
24715 +       sched_pc->tokens_min    = HZ >> 4;
24716 +       sched_pc->tokens_max    = HZ >> 1;
24717 +       sched_pc->prio_bias     = 0;
24718 +       sched_pc->vavavoom      = 0;
24719 +       sched_pc->token_time    = 0;
24720 +       sched_pc->idle_time     = 0;
24721 +       sched_pc->norm_time     = jiffies;
24722 +
24723 +       sched_pc->user_ticks = 0;
24724 +       sched_pc->sys_ticks = 0;
24725 +       sched_pc->hold_ticks = 0;
24726 +}
24727 +
24728 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24729 +{
24730 +       return;
24731 +}
24732 +
24733 +static inline
24734 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24735 +{
24736 +       return;
24737 +}
24738 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/sched_proc.h linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/sched_proc.h
24739 --- linux-2.6.35.2/kernel/vserver/sched_proc.h  1970-01-01 01:00:00.000000000 +0100
24740 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/sched_proc.h    2010-08-02 17:05:06.000000000 +0200
24741 @@ -0,0 +1,57 @@
24742 +#ifndef _VX_SCHED_PROC_H
24743 +#define _VX_SCHED_PROC_H
24744 +
24745 +
24746 +static inline
24747 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24748 +{
24749 +       int length = 0;
24750 +
24751 +       length += sprintf(buffer,
24752 +               "FillRate:\t%8d,%d\n"
24753 +               "Interval:\t%8d,%d\n"
24754 +               "TokensMin:\t%8d\n"
24755 +               "TokensMax:\t%8d\n"
24756 +               "PrioBias:\t%8d\n",
24757 +               sched->fill_rate[0],
24758 +               sched->fill_rate[1],
24759 +               sched->interval[0],
24760 +               sched->interval[1],
24761 +               sched->tokens_min,
24762 +               sched->tokens_max,
24763 +               sched->prio_bias);
24764 +       return length;
24765 +}
24766 +
24767 +static inline
24768 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24769 +       char *buffer, int cpu)
24770 +{
24771 +       int length = 0;
24772 +
24773 +       length += sprintf(buffer + length,
24774 +               "cpu %d: %lld %lld %lld %ld %ld", cpu,
24775 +               (unsigned long long)sched_pc->user_ticks,
24776 +               (unsigned long long)sched_pc->sys_ticks,
24777 +               (unsigned long long)sched_pc->hold_ticks,
24778 +               sched_pc->token_time,
24779 +               sched_pc->idle_time);
24780 +       length += sprintf(buffer + length,
24781 +               " %c%c %d %d %d %d/%d %d/%d",
24782 +               (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24783 +               (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24784 +               sched_pc->tokens,
24785 +               sched_pc->tokens_min,
24786 +               sched_pc->tokens_max,
24787 +               sched_pc->fill_rate[0],
24788 +               sched_pc->interval[0],
24789 +               sched_pc->fill_rate[1],
24790 +               sched_pc->interval[1]);
24791 +       length += sprintf(buffer + length,
24792 +               " %d %d\n",
24793 +               sched_pc->prio_bias,
24794 +               sched_pc->vavavoom);
24795 +       return length;
24796 +}
24797 +
24798 +#endif /* _VX_SCHED_PROC_H */
24799 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/signal.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/signal.c
24800 --- linux-2.6.35.2/kernel/vserver/signal.c      1970-01-01 01:00:00.000000000 +0100
24801 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/signal.c        2010-08-02 17:05:06.000000000 +0200
24802 @@ -0,0 +1,132 @@
24803 +/*
24804 + *  linux/kernel/vserver/signal.c
24805 + *
24806 + *  Virtual Server: Signal Support
24807 + *
24808 + *  Copyright (C) 2003-2007  Herbert Pötzl
24809 + *
24810 + *  V0.01  broken out from vcontext V0.05
24811 + *  V0.02  changed vcmds to vxi arg
24812 + *  V0.03  adjusted siginfo for kill
24813 + *
24814 + */
24815 +
24816 +#include <asm/uaccess.h>
24817 +
24818 +#include <linux/vs_context.h>
24819 +#include <linux/vs_pid.h>
24820 +#include <linux/vserver/signal_cmd.h>
24821 +
24822 +
24823 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24824 +{
24825 +       int retval, count = 0;
24826 +       struct task_struct *p;
24827 +       struct siginfo *sip = SEND_SIG_PRIV;
24828 +
24829 +       retval = -ESRCH;
24830 +       vxdprintk(VXD_CBIT(misc, 4),
24831 +               "vx_info_kill(%p[#%d],%d,%d)*",
24832 +               vxi, vxi->vx_id, pid, sig);
24833 +       read_lock(&tasklist_lock);
24834 +       switch (pid) {
24835 +       case  0:
24836 +       case -1:
24837 +               for_each_process(p) {
24838 +                       int err = 0;
24839 +
24840 +                       if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24841 +                               (pid && vxi->vx_initpid == p->pid))
24842 +                               continue;
24843 +
24844 +                       err = group_send_sig_info(sig, sip, p);
24845 +                       ++count;
24846 +                       if (err != -EPERM)
24847 +                               retval = err;
24848 +               }
24849 +               break;
24850 +
24851 +       case 1:
24852 +               if (vxi->vx_initpid) {
24853 +                       pid = vxi->vx_initpid;
24854 +                       /* for now, only SIGINT to private init ... */
24855 +                       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24856 +                               /* ... as long as there are tasks left */
24857 +                               (atomic_read(&vxi->vx_tasks) > 1))
24858 +                               sig = SIGINT;
24859 +               }
24860 +               /* fallthrough */
24861 +       default:
24862 +               p = find_task_by_real_pid(pid);
24863 +               if (p) {
24864 +                       if (vx_task_xid(p) == vxi->vx_id)
24865 +                               retval = group_send_sig_info(sig, sip, p);
24866 +               }
24867 +               break;
24868 +       }
24869 +       read_unlock(&tasklist_lock);
24870 +       vxdprintk(VXD_CBIT(misc, 4),
24871 +               "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24872 +               vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24873 +       return retval;
24874 +}
24875 +
24876 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24877 +{
24878 +       struct vcmd_ctx_kill_v0 vc_data;
24879 +
24880 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24881 +               return -EFAULT;
24882 +
24883 +       /* special check to allow guest shutdown */
24884 +       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24885 +               /* forbid killall pid=0 when init is present */
24886 +               (((vc_data.pid < 1) && vxi->vx_initpid) ||
24887 +               (vc_data.pid > 1)))
24888 +               return -EACCES;
24889 +
24890 +       return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24891 +}
24892 +
24893 +
24894 +static int __wait_exit(struct vx_info *vxi)
24895 +{
24896 +       DECLARE_WAITQUEUE(wait, current);
24897 +       int ret = 0;
24898 +
24899 +       add_wait_queue(&vxi->vx_wait, &wait);
24900 +       set_current_state(TASK_INTERRUPTIBLE);
24901 +
24902 +wait:
24903 +       if (vx_info_state(vxi,
24904 +               VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24905 +               goto out;
24906 +       if (signal_pending(current)) {
24907 +               ret = -ERESTARTSYS;
24908 +               goto out;
24909 +       }
24910 +       schedule();
24911 +       goto wait;
24912 +
24913 +out:
24914 +       set_current_state(TASK_RUNNING);
24915 +       remove_wait_queue(&vxi->vx_wait, &wait);
24916 +       return ret;
24917 +}
24918 +
24919 +
24920 +
24921 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24922 +{
24923 +       struct vcmd_wait_exit_v0 vc_data;
24924 +       int ret;
24925 +
24926 +       ret = __wait_exit(vxi);
24927 +       vc_data.reboot_cmd = vxi->reboot_cmd;
24928 +       vc_data.exit_code = vxi->exit_code;
24929 +
24930 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24931 +               ret = -EFAULT;
24932 +       return ret;
24933 +}
24934 +
24935 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/space.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/space.c
24936 --- linux-2.6.35.2/kernel/vserver/space.c       1970-01-01 01:00:00.000000000 +0100
24937 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/space.c 2010-08-02 17:05:06.000000000 +0200
24938 @@ -0,0 +1,375 @@
24939 +/*
24940 + *  linux/kernel/vserver/space.c
24941 + *
24942 + *  Virtual Server: Context Space Support
24943 + *
24944 + *  Copyright (C) 2003-2007  Herbert Pötzl
24945 + *
24946 + *  V0.01  broken out from context.c 0.07
24947 + *  V0.02  added task locking for namespace
24948 + *  V0.03  broken out vx_enter_namespace
24949 + *  V0.04  added *space support and commands
24950 + *
24951 + */
24952 +
24953 +#include <linux/utsname.h>
24954 +#include <linux/nsproxy.h>
24955 +#include <linux/err.h>
24956 +#include <linux/fs_struct.h>
24957 +#include <asm/uaccess.h>
24958 +
24959 +#include <linux/vs_context.h>
24960 +#include <linux/vserver/space.h>
24961 +#include <linux/vserver/space_cmd.h>
24962 +
24963 +atomic_t vs_global_nsproxy     = ATOMIC_INIT(0);
24964 +atomic_t vs_global_fs          = ATOMIC_INIT(0);
24965 +atomic_t vs_global_mnt_ns      = ATOMIC_INIT(0);
24966 +atomic_t vs_global_uts_ns      = ATOMIC_INIT(0);
24967 +atomic_t vs_global_user_ns     = ATOMIC_INIT(0);
24968 +atomic_t vs_global_pid_ns      = ATOMIC_INIT(0);
24969 +
24970 +
24971 +/* namespace functions */
24972 +
24973 +#include <linux/mnt_namespace.h>
24974 +#include <linux/user_namespace.h>
24975 +#include <linux/pid_namespace.h>
24976 +#include <linux/ipc_namespace.h>
24977 +#include <net/net_namespace.h>
24978 +
24979 +
24980 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24981 +       .mask = CLONE_FS |
24982 +               CLONE_NEWNS |
24983 +               CLONE_NEWUTS |
24984 +               CLONE_NEWIPC |
24985 +               CLONE_NEWUSER |
24986 +               0
24987 +};
24988 +
24989 +static const struct vcmd_space_mask_v1 space_mask = {
24990 +       .mask = CLONE_FS |
24991 +               CLONE_NEWNS |
24992 +               CLONE_NEWUTS |
24993 +               CLONE_NEWIPC |
24994 +               CLONE_NEWUSER |
24995 +#ifdef CONFIG_PID_NS
24996 +               CLONE_NEWPID |
24997 +#endif
24998 +#ifdef CONFIG_NET_NS
24999 +               CLONE_NEWNET |
25000 +#endif
25001 +               0
25002 +};
25003 +
25004 +static const struct vcmd_space_mask_v1 default_space_mask = {
25005 +       .mask = CLONE_FS |
25006 +               CLONE_NEWNS |
25007 +               CLONE_NEWUTS |
25008 +               CLONE_NEWIPC |
25009 +               CLONE_NEWUSER |
25010 +#ifdef CONFIG_PID_NS
25011 +//             CLONE_NEWPID |
25012 +#endif
25013 +               0
25014 +};
25015 +
25016 +/*
25017 + *     build a new nsproxy mix
25018 + *      assumes that both proxies are 'const'
25019 + *     does not touch nsproxy refcounts
25020 + *     will hold a reference on the result.
25021 + */
25022 +
25023 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
25024 +       struct nsproxy *new_nsproxy, unsigned long mask)
25025 +{
25026 +       struct mnt_namespace *old_ns;
25027 +       struct uts_namespace *old_uts;
25028 +       struct ipc_namespace *old_ipc;
25029 +#ifdef CONFIG_PID_NS
25030 +       struct pid_namespace *old_pid;
25031 +#endif
25032 +#ifdef CONFIG_NET_NS
25033 +       struct net *old_net;
25034 +#endif
25035 +       struct nsproxy *nsproxy;
25036 +
25037 +       nsproxy = copy_nsproxy(old_nsproxy);
25038 +       if (!nsproxy)
25039 +               goto out;
25040 +
25041 +       if (mask & CLONE_NEWNS) {
25042 +               old_ns = nsproxy->mnt_ns;
25043 +               nsproxy->mnt_ns = new_nsproxy->mnt_ns;
25044 +               if (nsproxy->mnt_ns)
25045 +                       get_mnt_ns(nsproxy->mnt_ns);
25046 +       } else
25047 +               old_ns = NULL;
25048 +
25049 +       if (mask & CLONE_NEWUTS) {
25050 +               old_uts = nsproxy->uts_ns;
25051 +               nsproxy->uts_ns = new_nsproxy->uts_ns;
25052 +               if (nsproxy->uts_ns)
25053 +                       get_uts_ns(nsproxy->uts_ns);
25054 +       } else
25055 +               old_uts = NULL;
25056 +
25057 +       if (mask & CLONE_NEWIPC) {
25058 +               old_ipc = nsproxy->ipc_ns;
25059 +               nsproxy->ipc_ns = new_nsproxy->ipc_ns;
25060 +               if (nsproxy->ipc_ns)
25061 +                       get_ipc_ns(nsproxy->ipc_ns);
25062 +       } else
25063 +               old_ipc = NULL;
25064 +
25065 +#ifdef CONFIG_PID_NS
25066 +       if (mask & CLONE_NEWPID) {
25067 +               old_pid = nsproxy->pid_ns;
25068 +               nsproxy->pid_ns = new_nsproxy->pid_ns;
25069 +               if (nsproxy->pid_ns)
25070 +                       get_pid_ns(nsproxy->pid_ns);
25071 +       } else
25072 +               old_pid = NULL;
25073 +#endif
25074 +#ifdef CONFIG_NET_NS
25075 +       if (mask & CLONE_NEWNET) {
25076 +               old_net = nsproxy->net_ns;
25077 +               nsproxy->net_ns = new_nsproxy->net_ns;
25078 +               if (nsproxy->net_ns)
25079 +                       get_net(nsproxy->net_ns);
25080 +       } else
25081 +               old_net = NULL;
25082 +#endif
25083 +       if (old_ns)
25084 +               put_mnt_ns(old_ns);
25085 +       if (old_uts)
25086 +               put_uts_ns(old_uts);
25087 +       if (old_ipc)
25088 +               put_ipc_ns(old_ipc);
25089 +#ifdef CONFIG_PID_NS
25090 +       if (old_pid)
25091 +               put_pid_ns(old_pid);
25092 +#endif
25093 +#ifdef CONFIG_NET_NS
25094 +       if (old_net)
25095 +               put_net(old_net);
25096 +#endif
25097 +out:
25098 +       return nsproxy;
25099 +}
25100 +
25101 +
25102 +/*
25103 + *     merge two nsproxy structs into a new one.
25104 + *     will hold a reference on the result.
25105 + */
25106 +
25107 +static inline
25108 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
25109 +       struct nsproxy *proxy, unsigned long mask)
25110 +{
25111 +       struct nsproxy null_proxy = { .mnt_ns = NULL };
25112 +
25113 +       if (!proxy)
25114 +               return NULL;
25115 +
25116 +       if (mask) {
25117 +               /* vs_mix_nsproxy returns with reference */
25118 +               return vs_mix_nsproxy(old ? old : &null_proxy,
25119 +                       proxy, mask);
25120 +       }
25121 +       get_nsproxy(proxy);
25122 +       return proxy;
25123 +}
25124 +
25125 +
25126 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25127 +{
25128 +       struct nsproxy *proxy, *proxy_cur, *proxy_new;
25129 +       struct fs_struct *fs_cur, *fs = NULL;
25130 +       int ret, kill = 0;
25131 +
25132 +       vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
25133 +               vxi, vxi->vx_id, mask, index);
25134 +
25135 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
25136 +               return -EACCES;
25137 +
25138 +       if (!mask)
25139 +               mask = vxi->vx_nsmask[index];
25140 +
25141 +       if ((mask & vxi->vx_nsmask[index]) != mask)
25142 +               return -EINVAL;
25143 +
25144 +       if (mask & CLONE_FS) {
25145 +               fs = copy_fs_struct(vxi->vx_fs[index]);
25146 +               if (!fs)
25147 +                       return -ENOMEM;
25148 +       }
25149 +       proxy = vxi->vx_nsproxy[index];
25150 +
25151 +       vxdprintk(VXD_CBIT(space, 9),
25152 +               "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
25153 +               vxi, vxi->vx_id, mask, index, proxy, fs);
25154 +
25155 +       task_lock(current);
25156 +       fs_cur = current->fs;
25157 +
25158 +       if (mask & CLONE_FS) {
25159 +               write_lock(&fs_cur->lock);
25160 +               current->fs = fs;
25161 +               kill = !--fs_cur->users;
25162 +               write_unlock(&fs_cur->lock);
25163 +       }
25164 +
25165 +       proxy_cur = current->nsproxy;
25166 +       get_nsproxy(proxy_cur);
25167 +       task_unlock(current);
25168 +
25169 +       if (kill)
25170 +               free_fs_struct(fs_cur);
25171 +
25172 +       proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
25173 +       if (IS_ERR(proxy_new)) {
25174 +               ret = PTR_ERR(proxy_new);
25175 +               goto out_put;
25176 +       }
25177 +
25178 +       proxy_new = xchg(&current->nsproxy, proxy_new);
25179 +       ret = 0;
25180 +
25181 +       if (proxy_new)
25182 +               put_nsproxy(proxy_new);
25183 +out_put:
25184 +       if (proxy_cur)
25185 +               put_nsproxy(proxy_cur);
25186 +       return ret;
25187 +}
25188 +
25189 +
25190 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25191 +{
25192 +       struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25193 +       struct fs_struct *fs_vxi, *fs;
25194 +       int ret, kill = 0;
25195 +
25196 +       vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
25197 +               vxi, vxi->vx_id, mask, index);
25198 +#if 0
25199 +       if (!mask)
25200 +               mask = default_space_mask.mask;
25201 +#endif
25202 +       if ((mask & space_mask.mask) != mask)
25203 +               return -EINVAL;
25204 +
25205 +       proxy_vxi = vxi->vx_nsproxy[index];
25206 +       fs_vxi = vxi->vx_fs[index];
25207 +
25208 +       if (mask & CLONE_FS) {
25209 +               fs = copy_fs_struct(current->fs);
25210 +               if (!fs)
25211 +                       return -ENOMEM;
25212 +       }
25213 +
25214 +       task_lock(current);
25215 +
25216 +       if (mask & CLONE_FS) {
25217 +               write_lock(&fs_vxi->lock);
25218 +               vxi->vx_fs[index] = fs;
25219 +               kill = !--fs_vxi->users;
25220 +               write_unlock(&fs_vxi->lock);
25221 +       }
25222 +
25223 +       proxy_cur = current->nsproxy;
25224 +       get_nsproxy(proxy_cur);
25225 +       task_unlock(current);
25226 +
25227 +       if (kill)
25228 +               free_fs_struct(fs_vxi);
25229 +
25230 +       proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25231 +       if (IS_ERR(proxy_new)) {
25232 +               ret = PTR_ERR(proxy_new);
25233 +               goto out_put;
25234 +       }
25235 +
25236 +       proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
25237 +       vxi->vx_nsmask[index] |= mask;
25238 +       ret = 0;
25239 +
25240 +       if (proxy_new)
25241 +               put_nsproxy(proxy_new);
25242 +out_put:
25243 +       if (proxy_cur)
25244 +               put_nsproxy(proxy_cur);
25245 +       return ret;
25246 +}
25247 +
25248 +
25249 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25250 +{
25251 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25252 +
25253 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25254 +               return -EFAULT;
25255 +
25256 +       return vx_enter_space(vxi, vc_data.mask, 0);
25257 +}
25258 +
25259 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25260 +{
25261 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25262 +
25263 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25264 +               return -EFAULT;
25265 +
25266 +       if (vc_data.index >= VX_SPACES)
25267 +               return -EINVAL;
25268 +
25269 +       return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25270 +}
25271 +
25272 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25273 +{
25274 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25275 +
25276 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25277 +               return -EFAULT;
25278 +
25279 +       return vx_set_space(vxi, vc_data.mask, 0);
25280 +}
25281 +
25282 +int vc_set_space(struct vx_info *vxi, void __user *data)
25283 +{
25284 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25285 +
25286 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25287 +               return -EFAULT;
25288 +
25289 +       if (vc_data.index >= VX_SPACES)
25290 +               return -EINVAL;
25291 +
25292 +       return vx_set_space(vxi, vc_data.mask, vc_data.index);
25293 +}
25294 +
25295 +int vc_get_space_mask(void __user *data, int type)
25296 +{
25297 +       const struct vcmd_space_mask_v1 *mask;
25298 +
25299 +       if (type == 0)
25300 +               mask = &space_mask_v0;
25301 +       else if (type == 1)
25302 +               mask = &space_mask;
25303 +       else
25304 +               mask = &default_space_mask;
25305 +
25306 +       vxdprintk(VXD_CBIT(space, 10),
25307 +               "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25308 +
25309 +       if (copy_to_user(data, mask, sizeof(*mask)))
25310 +               return -EFAULT;
25311 +       return 0;
25312 +}
25313 +
25314 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/switch.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/switch.c
25315 --- linux-2.6.35.2/kernel/vserver/switch.c      1970-01-01 01:00:00.000000000 +0100
25316 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/switch.c        2010-08-02 17:05:06.000000000 +0200
25317 @@ -0,0 +1,546 @@
25318 +/*
25319 + *  linux/kernel/vserver/switch.c
25320 + *
25321 + *  Virtual Server: Syscall Switch
25322 + *
25323 + *  Copyright (C) 2003-2007  Herbert Pötzl
25324 + *
25325 + *  V0.01  syscall switch
25326 + *  V0.02  added signal to context
25327 + *  V0.03  added rlimit functions
25328 + *  V0.04  added iattr, task/xid functions
25329 + *  V0.05  added debug/history stuff
25330 + *  V0.06  added compat32 layer
25331 + *  V0.07  vcmd args and perms
25332 + *  V0.08  added status commands
25333 + *  V0.09  added tag commands
25334 + *  V0.10  added oom bias
25335 + *  V0.11  added device commands
25336 + *
25337 + */
25338 +
25339 +#include <linux/vs_context.h>
25340 +#include <linux/vs_network.h>
25341 +#include <linux/vserver/switch.h>
25342 +
25343 +#include "vci_config.h"
25344 +
25345 +
25346 +static inline
25347 +int vc_get_version(uint32_t id)
25348 +{
25349 +       return VCI_VERSION;
25350 +}
25351 +
25352 +static inline
25353 +int vc_get_vci(uint32_t id)
25354 +{
25355 +       return vci_kernel_config();
25356 +}
25357 +
25358 +#include <linux/vserver/context_cmd.h>
25359 +#include <linux/vserver/cvirt_cmd.h>
25360 +#include <linux/vserver/cacct_cmd.h>
25361 +#include <linux/vserver/limit_cmd.h>
25362 +#include <linux/vserver/network_cmd.h>
25363 +#include <linux/vserver/sched_cmd.h>
25364 +#include <linux/vserver/debug_cmd.h>
25365 +#include <linux/vserver/inode_cmd.h>
25366 +#include <linux/vserver/dlimit_cmd.h>
25367 +#include <linux/vserver/signal_cmd.h>
25368 +#include <linux/vserver/space_cmd.h>
25369 +#include <linux/vserver/tag_cmd.h>
25370 +#include <linux/vserver/device_cmd.h>
25371 +
25372 +#include <linux/vserver/inode.h>
25373 +#include <linux/vserver/dlimit.h>
25374 +
25375 +
25376 +#ifdef CONFIG_COMPAT
25377 +#define __COMPAT(name, id, data, compat)       \
25378 +       (compat) ? name ## _x32(id, data) : name(id, data)
25379 +#define __COMPAT_NO_ID(name, data, compat)     \
25380 +       (compat) ? name ## _x32(data) : name(data)
25381 +#else
25382 +#define __COMPAT(name, id, data, compat)       \
25383 +       name(id, data)
25384 +#define __COMPAT_NO_ID(name, data, compat)     \
25385 +       name(data)
25386 +#endif
25387 +
25388 +
25389 +static inline
25390 +long do_vcmd(uint32_t cmd, uint32_t id,
25391 +       struct vx_info *vxi, struct nx_info *nxi,
25392 +       void __user *data, int compat)
25393 +{
25394 +       switch (cmd) {
25395 +
25396 +       case VCMD_get_version:
25397 +               return vc_get_version(id);
25398 +       case VCMD_get_vci:
25399 +               return vc_get_vci(id);
25400 +
25401 +       case VCMD_task_xid:
25402 +               return vc_task_xid(id);
25403 +       case VCMD_vx_info:
25404 +               return vc_vx_info(vxi, data);
25405 +
25406 +       case VCMD_task_nid:
25407 +               return vc_task_nid(id);
25408 +       case VCMD_nx_info:
25409 +               return vc_nx_info(nxi, data);
25410 +
25411 +       case VCMD_task_tag:
25412 +               return vc_task_tag(id);
25413 +
25414 +       case VCMD_set_space_v1:
25415 +               return vc_set_space_v1(vxi, data);
25416 +       /* this is version 2 */
25417 +       case VCMD_set_space:
25418 +               return vc_set_space(vxi, data);
25419 +
25420 +       case VCMD_get_space_mask_v0:
25421 +               return vc_get_space_mask(data, 0);
25422 +       /* this is version 1 */
25423 +       case VCMD_get_space_mask:
25424 +               return vc_get_space_mask(data, 1);
25425 +
25426 +       case VCMD_get_space_default:
25427 +               return vc_get_space_mask(data, -1);
25428 +
25429 +#ifdef CONFIG_IA32_EMULATION
25430 +       case VCMD_get_rlimit:
25431 +               return __COMPAT(vc_get_rlimit, vxi, data, compat);
25432 +       case VCMD_set_rlimit:
25433 +               return __COMPAT(vc_set_rlimit, vxi, data, compat);
25434 +#else
25435 +       case VCMD_get_rlimit:
25436 +               return vc_get_rlimit(vxi, data);
25437 +       case VCMD_set_rlimit:
25438 +               return vc_set_rlimit(vxi, data);
25439 +#endif
25440 +       case VCMD_get_rlimit_mask:
25441 +               return vc_get_rlimit_mask(id, data);
25442 +       case VCMD_reset_hits:
25443 +               return vc_reset_hits(vxi, data);
25444 +       case VCMD_reset_minmax:
25445 +               return vc_reset_minmax(vxi, data);
25446 +
25447 +       case VCMD_get_vhi_name:
25448 +               return vc_get_vhi_name(vxi, data);
25449 +       case VCMD_set_vhi_name:
25450 +               return vc_set_vhi_name(vxi, data);
25451 +
25452 +       case VCMD_ctx_stat:
25453 +               return vc_ctx_stat(vxi, data);
25454 +       case VCMD_virt_stat:
25455 +               return vc_virt_stat(vxi, data);
25456 +       case VCMD_sock_stat:
25457 +               return vc_sock_stat(vxi, data);
25458 +       case VCMD_rlimit_stat:
25459 +               return vc_rlimit_stat(vxi, data);
25460 +
25461 +       case VCMD_set_cflags:
25462 +               return vc_set_cflags(vxi, data);
25463 +       case VCMD_get_cflags:
25464 +               return vc_get_cflags(vxi, data);
25465 +
25466 +       /* this is version 1 */
25467 +       case VCMD_set_ccaps:
25468 +               return vc_set_ccaps(vxi, data);
25469 +       /* this is version 1 */
25470 +       case VCMD_get_ccaps:
25471 +               return vc_get_ccaps(vxi, data);
25472 +       case VCMD_set_bcaps:
25473 +               return vc_set_bcaps(vxi, data);
25474 +       case VCMD_get_bcaps:
25475 +               return vc_get_bcaps(vxi, data);
25476 +
25477 +       case VCMD_set_badness:
25478 +               return vc_set_badness(vxi, data);
25479 +       case VCMD_get_badness:
25480 +               return vc_get_badness(vxi, data);
25481 +
25482 +       case VCMD_set_nflags:
25483 +               return vc_set_nflags(nxi, data);
25484 +       case VCMD_get_nflags:
25485 +               return vc_get_nflags(nxi, data);
25486 +
25487 +       case VCMD_set_ncaps:
25488 +               return vc_set_ncaps(nxi, data);
25489 +       case VCMD_get_ncaps:
25490 +               return vc_get_ncaps(nxi, data);
25491 +
25492 +       case VCMD_set_sched_v4:
25493 +               return vc_set_sched_v4(vxi, data);
25494 +       /* this is version 5 */
25495 +       case VCMD_set_sched:
25496 +               return vc_set_sched(vxi, data);
25497 +       case VCMD_get_sched:
25498 +               return vc_get_sched(vxi, data);
25499 +       case VCMD_sched_info:
25500 +               return vc_sched_info(vxi, data);
25501 +
25502 +       case VCMD_add_dlimit:
25503 +               return __COMPAT(vc_add_dlimit, id, data, compat);
25504 +       case VCMD_rem_dlimit:
25505 +               return __COMPAT(vc_rem_dlimit, id, data, compat);
25506 +       case VCMD_set_dlimit:
25507 +               return __COMPAT(vc_set_dlimit, id, data, compat);
25508 +       case VCMD_get_dlimit:
25509 +               return __COMPAT(vc_get_dlimit, id, data, compat);
25510 +
25511 +       case VCMD_ctx_kill:
25512 +               return vc_ctx_kill(vxi, data);
25513 +
25514 +       case VCMD_wait_exit:
25515 +               return vc_wait_exit(vxi, data);
25516 +
25517 +       case VCMD_get_iattr:
25518 +               return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25519 +       case VCMD_set_iattr:
25520 +               return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25521 +
25522 +       case VCMD_fget_iattr:
25523 +               return vc_fget_iattr(id, data);
25524 +       case VCMD_fset_iattr:
25525 +               return vc_fset_iattr(id, data);
25526 +
25527 +       case VCMD_enter_space_v0:
25528 +               return vc_enter_space_v1(vxi, NULL);
25529 +       case VCMD_enter_space_v1:
25530 +               return vc_enter_space_v1(vxi, data);
25531 +       /* this is version 2 */
25532 +       case VCMD_enter_space:
25533 +               return vc_enter_space(vxi, data);
25534 +
25535 +       case VCMD_ctx_create_v0:
25536 +               return vc_ctx_create(id, NULL);
25537 +       case VCMD_ctx_create:
25538 +               return vc_ctx_create(id, data);
25539 +       case VCMD_ctx_migrate_v0:
25540 +               return vc_ctx_migrate(vxi, NULL);
25541 +       case VCMD_ctx_migrate:
25542 +               return vc_ctx_migrate(vxi, data);
25543 +
25544 +       case VCMD_net_create_v0:
25545 +               return vc_net_create(id, NULL);
25546 +       case VCMD_net_create:
25547 +               return vc_net_create(id, data);
25548 +       case VCMD_net_migrate:
25549 +               return vc_net_migrate(nxi, data);
25550 +
25551 +       case VCMD_tag_migrate:
25552 +               return vc_tag_migrate(id);
25553 +
25554 +       case VCMD_net_add:
25555 +               return vc_net_add(nxi, data);
25556 +       case VCMD_net_remove:
25557 +               return vc_net_remove(nxi, data);
25558 +
25559 +       case VCMD_net_add_ipv4:
25560 +               return vc_net_add_ipv4(nxi, data);
25561 +       case VCMD_net_remove_ipv4:
25562 +               return vc_net_remove_ipv4(nxi, data);
25563 +#ifdef CONFIG_IPV6
25564 +       case VCMD_net_add_ipv6:
25565 +               return vc_net_add_ipv6(nxi, data);
25566 +       case VCMD_net_remove_ipv6:
25567 +               return vc_net_remove_ipv6(nxi, data);
25568 +#endif
25569 +/*     case VCMD_add_match_ipv4:
25570 +               return vc_add_match_ipv4(nxi, data);
25571 +       case VCMD_get_match_ipv4:
25572 +               return vc_get_match_ipv4(nxi, data);
25573 +#ifdef CONFIG_IPV6
25574 +       case VCMD_add_match_ipv6:
25575 +               return vc_add_match_ipv6(nxi, data);
25576 +       case VCMD_get_match_ipv6:
25577 +               return vc_get_match_ipv6(nxi, data);
25578 +#endif */
25579 +
25580 +#ifdef CONFIG_VSERVER_DEVICE
25581 +       case VCMD_set_mapping:
25582 +               return __COMPAT(vc_set_mapping, vxi, data, compat);
25583 +       case VCMD_unset_mapping:
25584 +               return __COMPAT(vc_unset_mapping, vxi, data, compat);
25585 +#endif
25586 +#ifdef CONFIG_VSERVER_HISTORY
25587 +       case VCMD_dump_history:
25588 +               return vc_dump_history(id);
25589 +       case VCMD_read_history:
25590 +               return __COMPAT(vc_read_history, id, data, compat);
25591 +#endif
25592 +#ifdef CONFIG_VSERVER_MONITOR
25593 +       case VCMD_read_monitor:
25594 +               return __COMPAT(vc_read_monitor, id, data, compat);
25595 +#endif
25596 +       default:
25597 +               vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25598 +                       VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25599 +       }
25600 +       return -ENOSYS;
25601 +}
25602 +
25603 +
25604 +#define        __VCMD(vcmd, _perm, _args, _flags)              \
25605 +       case VCMD_ ## vcmd: perm = _perm;               \
25606 +               args = _args; flags = _flags; break
25607 +
25608 +
25609 +#define VCA_NONE       0x00
25610 +#define VCA_VXI                0x01
25611 +#define VCA_NXI                0x02
25612 +
25613 +#define VCF_NONE       0x00
25614 +#define VCF_INFO       0x01
25615 +#define VCF_ADMIN      0x02
25616 +#define VCF_ARES       0x06    /* includes admin */
25617 +#define VCF_SETUP      0x08
25618 +
25619 +#define VCF_ZIDOK      0x10    /* zero id okay */
25620 +
25621 +
25622 +static inline
25623 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25624 +{
25625 +       long ret;
25626 +       int permit = -1, state = 0;
25627 +       int perm = -1, args = 0, flags = 0;
25628 +       struct vx_info *vxi = NULL;
25629 +       struct nx_info *nxi = NULL;
25630 +
25631 +       switch (cmd) {
25632 +       /* unpriviledged commands */
25633 +       __VCMD(get_version,      0, VCA_NONE,   0);
25634 +       __VCMD(get_vci,          0, VCA_NONE,   0);
25635 +       __VCMD(get_rlimit_mask,  0, VCA_NONE,   0);
25636 +       __VCMD(get_space_mask_v0,0, VCA_NONE,   0);
25637 +       __VCMD(get_space_mask,   0, VCA_NONE,   0);
25638 +       __VCMD(get_space_default,0, VCA_NONE,   0);
25639 +
25640 +       /* info commands */
25641 +       __VCMD(task_xid,         2, VCA_NONE,   0);
25642 +       __VCMD(reset_hits,       2, VCA_VXI,    0);
25643 +       __VCMD(reset_minmax,     2, VCA_VXI,    0);
25644 +       __VCMD(vx_info,          3, VCA_VXI,    VCF_INFO);
25645 +       __VCMD(get_bcaps,        3, VCA_VXI,    VCF_INFO);
25646 +       __VCMD(get_ccaps,        3, VCA_VXI,    VCF_INFO);
25647 +       __VCMD(get_cflags,       3, VCA_VXI,    VCF_INFO);
25648 +       __VCMD(get_badness,      3, VCA_VXI,    VCF_INFO);
25649 +       __VCMD(get_vhi_name,     3, VCA_VXI,    VCF_INFO);
25650 +       __VCMD(get_rlimit,       3, VCA_VXI,    VCF_INFO);
25651 +
25652 +       __VCMD(ctx_stat,         3, VCA_VXI,    VCF_INFO);
25653 +       __VCMD(virt_stat,        3, VCA_VXI,    VCF_INFO);
25654 +       __VCMD(sock_stat,        3, VCA_VXI,    VCF_INFO);
25655 +       __VCMD(rlimit_stat,      3, VCA_VXI,    VCF_INFO);
25656 +
25657 +       __VCMD(task_nid,         2, VCA_NONE,   0);
25658 +       __VCMD(nx_info,          3, VCA_NXI,    VCF_INFO);
25659 +       __VCMD(get_ncaps,        3, VCA_NXI,    VCF_INFO);
25660 +       __VCMD(get_nflags,       3, VCA_NXI,    VCF_INFO);
25661 +
25662 +       __VCMD(task_tag,         2, VCA_NONE,   0);
25663 +
25664 +       __VCMD(get_iattr,        2, VCA_NONE,   0);
25665 +       __VCMD(fget_iattr,       2, VCA_NONE,   0);
25666 +       __VCMD(get_dlimit,       3, VCA_NONE,   VCF_INFO);
25667 +       __VCMD(get_sched,        3, VCA_VXI,    VCF_INFO);
25668 +       __VCMD(sched_info,       3, VCA_VXI,    VCF_INFO | VCF_ZIDOK);
25669 +
25670 +       /* lower admin commands */
25671 +       __VCMD(wait_exit,        4, VCA_VXI,    VCF_INFO);
25672 +       __VCMD(ctx_create_v0,    5, VCA_NONE,   0);
25673 +       __VCMD(ctx_create,       5, VCA_NONE,   0);
25674 +       __VCMD(ctx_migrate_v0,   5, VCA_VXI,    VCF_ADMIN);
25675 +       __VCMD(ctx_migrate,      5, VCA_VXI,    VCF_ADMIN);
25676 +       __VCMD(enter_space_v0,   5, VCA_VXI,    VCF_ADMIN);
25677 +       __VCMD(enter_space_v1,   5, VCA_VXI,    VCF_ADMIN);
25678 +       __VCMD(enter_space,      5, VCA_VXI,    VCF_ADMIN);
25679 +
25680 +       __VCMD(net_create_v0,    5, VCA_NONE,   0);
25681 +       __VCMD(net_create,       5, VCA_NONE,   0);
25682 +       __VCMD(net_migrate,      5, VCA_NXI,    VCF_ADMIN);
25683 +
25684 +       __VCMD(tag_migrate,      5, VCA_NONE,   VCF_ADMIN);
25685 +
25686 +       /* higher admin commands */
25687 +       __VCMD(ctx_kill,         6, VCA_VXI,    VCF_ARES);
25688 +       __VCMD(set_space_v1,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25689 +       __VCMD(set_space,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25690 +
25691 +       __VCMD(set_ccaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25692 +       __VCMD(set_bcaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25693 +       __VCMD(set_cflags,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25694 +       __VCMD(set_badness,      7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25695 +
25696 +       __VCMD(set_vhi_name,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25697 +       __VCMD(set_rlimit,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25698 +       __VCMD(set_sched,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25699 +       __VCMD(set_sched_v4,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25700 +
25701 +       __VCMD(set_ncaps,        7, VCA_NXI,    VCF_ARES | VCF_SETUP);
25702 +       __VCMD(set_nflags,       7, VCA_NXI,    VCF_ARES | VCF_SETUP);
25703 +       __VCMD(net_add,          8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25704 +       __VCMD(net_remove,       8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25705 +       __VCMD(net_add_ipv4,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25706 +       __VCMD(net_remove_ipv4,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25707 +#ifdef CONFIG_IPV6
25708 +       __VCMD(net_add_ipv6,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25709 +       __VCMD(net_remove_ipv6,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25710 +#endif
25711 +       __VCMD(set_iattr,        7, VCA_NONE,   0);
25712 +       __VCMD(fset_iattr,       7, VCA_NONE,   0);
25713 +       __VCMD(set_dlimit,       7, VCA_NONE,   VCF_ARES);
25714 +       __VCMD(add_dlimit,       8, VCA_NONE,   VCF_ARES);
25715 +       __VCMD(rem_dlimit,       8, VCA_NONE,   VCF_ARES);
25716 +
25717 +#ifdef CONFIG_VSERVER_DEVICE
25718 +       __VCMD(set_mapping,      8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
25719 +       __VCMD(unset_mapping,    8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
25720 +#endif
25721 +       /* debug level admin commands */
25722 +#ifdef CONFIG_VSERVER_HISTORY
25723 +       __VCMD(dump_history,     9, VCA_NONE,   0);
25724 +       __VCMD(read_history,     9, VCA_NONE,   0);
25725 +#endif
25726 +#ifdef CONFIG_VSERVER_MONITOR
25727 +       __VCMD(read_monitor,     9, VCA_NONE,   0);
25728 +#endif
25729 +
25730 +       default:
25731 +               perm = -1;
25732 +       }
25733 +
25734 +       vxdprintk(VXD_CBIT(switch, 0),
25735 +               "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25736 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
25737 +               VC_VERSION(cmd), id, data, compat,
25738 +               perm, args, flags);
25739 +
25740 +       ret = -ENOSYS;
25741 +       if (perm < 0)
25742 +               goto out;
25743 +
25744 +       state = 1;
25745 +       if (!capable(CAP_CONTEXT))
25746 +               goto out;
25747 +
25748 +       state = 2;
25749 +       /* moved here from the individual commands */
25750 +       ret = -EPERM;
25751 +       if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25752 +               goto out;
25753 +
25754 +       state = 3;
25755 +       /* vcmd involves resource management  */
25756 +       ret = -EPERM;
25757 +       if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25758 +               goto out;
25759 +
25760 +       state = 4;
25761 +       /* various legacy exceptions */
25762 +       switch (cmd) {
25763 +       /* will go away when spectator is a cap */
25764 +       case VCMD_ctx_migrate_v0:
25765 +       case VCMD_ctx_migrate:
25766 +               if (id == 1) {
25767 +                       current->xid = 1;
25768 +                       ret = 1;
25769 +                       goto out;
25770 +               }
25771 +               break;
25772 +
25773 +       /* will go away when spectator is a cap */
25774 +       case VCMD_net_migrate:
25775 +               if (id == 1) {
25776 +                       current->nid = 1;
25777 +                       ret = 1;
25778 +                       goto out;
25779 +               }
25780 +               break;
25781 +       }
25782 +
25783 +       /* vcmds are fine by default */
25784 +       permit = 1;
25785 +
25786 +       /* admin type vcmds require admin ... */
25787 +       if (flags & VCF_ADMIN)
25788 +               permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25789 +
25790 +       /* ... but setup type vcmds override that */
25791 +       if (!permit && (flags & VCF_SETUP))
25792 +               permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25793 +
25794 +       state = 5;
25795 +       ret = -EPERM;
25796 +       if (!permit)
25797 +               goto out;
25798 +
25799 +       state = 6;
25800 +       if (!id && (flags & VCF_ZIDOK))
25801 +               goto skip_id;
25802 +
25803 +       ret = -ESRCH;
25804 +       if (args & VCA_VXI) {
25805 +               vxi = lookup_vx_info(id);
25806 +               if (!vxi)
25807 +                       goto out;
25808 +
25809 +               if ((flags & VCF_ADMIN) &&
25810 +                       /* special case kill for shutdown */
25811 +                       (cmd != VCMD_ctx_kill) &&
25812 +                       /* can context be administrated? */
25813 +                       !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25814 +                       ret = -EACCES;
25815 +                       goto out_vxi;
25816 +               }
25817 +       }
25818 +       state = 7;
25819 +       if (args & VCA_NXI) {
25820 +               nxi = lookup_nx_info(id);
25821 +               if (!nxi)
25822 +                       goto out_vxi;
25823 +
25824 +               if ((flags & VCF_ADMIN) &&
25825 +                       /* can context be administrated? */
25826 +                       !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25827 +                       ret = -EACCES;
25828 +                       goto out_nxi;
25829 +               }
25830 +       }
25831 +skip_id:
25832 +       state = 8;
25833 +       ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25834 +
25835 +out_nxi:
25836 +       if ((args & VCA_NXI) && nxi)
25837 +               put_nx_info(nxi);
25838 +out_vxi:
25839 +       if ((args & VCA_VXI) && vxi)
25840 +               put_vx_info(vxi);
25841 +out:
25842 +       vxdprintk(VXD_CBIT(switch, 1),
25843 +               "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25844 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
25845 +               VC_VERSION(cmd), ret, ret, state, permit);
25846 +       return ret;
25847 +}
25848 +
25849 +asmlinkage long
25850 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25851 +{
25852 +       return do_vserver(cmd, id, data, 0);
25853 +}
25854 +
25855 +#ifdef CONFIG_COMPAT
25856 +
25857 +asmlinkage long
25858 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25859 +{
25860 +       return do_vserver(cmd, id, data, 1);
25861 +}
25862 +
25863 +#endif /* CONFIG_COMPAT */
25864 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/sysctl.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/sysctl.c
25865 --- linux-2.6.35.2/kernel/vserver/sysctl.c      1970-01-01 01:00:00.000000000 +0100
25866 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/sysctl.c        2010-08-02 17:05:06.000000000 +0200
25867 @@ -0,0 +1,241 @@
25868 +/*
25869 + *  kernel/vserver/sysctl.c
25870 + *
25871 + *  Virtual Context Support
25872 + *
25873 + *  Copyright (C) 2004-2007  Herbert Pötzl
25874 + *
25875 + *  V0.01  basic structure
25876 + *
25877 + */
25878 +
25879 +#include <linux/module.h>
25880 +#include <linux/ctype.h>
25881 +#include <linux/sysctl.h>
25882 +#include <linux/parser.h>
25883 +#include <asm/uaccess.h>
25884 +
25885 +enum {
25886 +       CTL_DEBUG_ERROR         = 0,
25887 +       CTL_DEBUG_SWITCH        = 1,
25888 +       CTL_DEBUG_XID,
25889 +       CTL_DEBUG_NID,
25890 +       CTL_DEBUG_TAG,
25891 +       CTL_DEBUG_NET,
25892 +       CTL_DEBUG_LIMIT,
25893 +       CTL_DEBUG_CRES,
25894 +       CTL_DEBUG_DLIM,
25895 +       CTL_DEBUG_QUOTA,
25896 +       CTL_DEBUG_CVIRT,
25897 +       CTL_DEBUG_SPACE,
25898 +       CTL_DEBUG_MISC,
25899 +};
25900 +
25901 +
25902 +unsigned int vx_debug_switch   = 0;
25903 +unsigned int vx_debug_xid      = 0;
25904 +unsigned int vx_debug_nid      = 0;
25905 +unsigned int vx_debug_tag      = 0;
25906 +unsigned int vx_debug_net      = 0;
25907 +unsigned int vx_debug_limit    = 0;
25908 +unsigned int vx_debug_cres     = 0;
25909 +unsigned int vx_debug_dlim     = 0;
25910 +unsigned int vx_debug_quota    = 0;
25911 +unsigned int vx_debug_cvirt    = 0;
25912 +unsigned int vx_debug_space    = 0;
25913 +unsigned int vx_debug_misc     = 0;
25914 +
25915 +
25916 +static struct ctl_table_header *vserver_table_header;
25917 +static ctl_table vserver_root_table[];
25918 +
25919 +
25920 +void vserver_register_sysctl(void)
25921 +{
25922 +       if (!vserver_table_header) {
25923 +               vserver_table_header = register_sysctl_table(vserver_root_table);
25924 +       }
25925 +
25926 +}
25927 +
25928 +void vserver_unregister_sysctl(void)
25929 +{
25930 +       if (vserver_table_header) {
25931 +               unregister_sysctl_table(vserver_table_header);
25932 +               vserver_table_header = NULL;
25933 +       }
25934 +}
25935 +
25936 +
25937 +static int proc_dodebug(ctl_table *table, int write,
25938 +       void __user *buffer, size_t *lenp, loff_t *ppos)
25939 +{
25940 +       char            tmpbuf[20], *p, c;
25941 +       unsigned int    value;
25942 +       size_t          left, len;
25943 +
25944 +       if ((*ppos && !write) || !*lenp) {
25945 +               *lenp = 0;
25946 +               return 0;
25947 +       }
25948 +
25949 +       left = *lenp;
25950 +
25951 +       if (write) {
25952 +               if (!access_ok(VERIFY_READ, buffer, left))
25953 +                       return -EFAULT;
25954 +               p = (char *)buffer;
25955 +               while (left && __get_user(c, p) >= 0 && isspace(c))
25956 +                       left--, p++;
25957 +               if (!left)
25958 +                       goto done;
25959 +
25960 +               if (left > sizeof(tmpbuf) - 1)
25961 +                       return -EINVAL;
25962 +               if (copy_from_user(tmpbuf, p, left))
25963 +                       return -EFAULT;
25964 +               tmpbuf[left] = '\0';
25965 +
25966 +               for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25967 +                       value = 10 * value + (*p - '0');
25968 +               if (*p && !isspace(*p))
25969 +                       return -EINVAL;
25970 +               while (left && isspace(*p))
25971 +                       left--, p++;
25972 +               *(unsigned int *)table->data = value;
25973 +       } else {
25974 +               if (!access_ok(VERIFY_WRITE, buffer, left))
25975 +                       return -EFAULT;
25976 +               len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25977 +               if (len > left)
25978 +                       len = left;
25979 +               if (__copy_to_user(buffer, tmpbuf, len))
25980 +                       return -EFAULT;
25981 +               if ((left -= len) > 0) {
25982 +                       if (put_user('\n', (char *)buffer + len))
25983 +                               return -EFAULT;
25984 +                       left--;
25985 +               }
25986 +       }
25987 +
25988 +done:
25989 +       *lenp -= left;
25990 +       *ppos += *lenp;
25991 +       return 0;
25992 +}
25993 +
25994 +static int zero;
25995 +
25996 +#define        CTL_ENTRY(ctl, name)                            \
25997 +       {                                               \
25998 +               .procname       = #name,                \
25999 +               .data           = &vx_ ## name,         \
26000 +               .maxlen         = sizeof(int),          \
26001 +               .mode           = 0644,                 \
26002 +               .proc_handler   = &proc_dodebug,        \
26003 +               .extra1         = &zero,                \
26004 +               .extra2         = &zero,                \
26005 +       }
26006 +
26007 +static ctl_table vserver_debug_table[] = {
26008 +       CTL_ENTRY(CTL_DEBUG_SWITCH,     debug_switch),
26009 +       CTL_ENTRY(CTL_DEBUG_XID,        debug_xid),
26010 +       CTL_ENTRY(CTL_DEBUG_NID,        debug_nid),
26011 +       CTL_ENTRY(CTL_DEBUG_TAG,        debug_tag),
26012 +       CTL_ENTRY(CTL_DEBUG_NET,        debug_net),
26013 +       CTL_ENTRY(CTL_DEBUG_LIMIT,      debug_limit),
26014 +       CTL_ENTRY(CTL_DEBUG_CRES,       debug_cres),
26015 +       CTL_ENTRY(CTL_DEBUG_DLIM,       debug_dlim),
26016 +       CTL_ENTRY(CTL_DEBUG_QUOTA,      debug_quota),
26017 +       CTL_ENTRY(CTL_DEBUG_CVIRT,      debug_cvirt),
26018 +       CTL_ENTRY(CTL_DEBUG_SPACE,      debug_space),
26019 +       CTL_ENTRY(CTL_DEBUG_MISC,       debug_misc),
26020 +       { 0 }
26021 +};
26022 +
26023 +static ctl_table vserver_root_table[] = {
26024 +       {
26025 +               .procname       = "vserver",
26026 +               .mode           = 0555,
26027 +               .child          = vserver_debug_table
26028 +       },
26029 +       { 0 }
26030 +};
26031 +
26032 +
26033 +static match_table_t tokens = {
26034 +       { CTL_DEBUG_SWITCH,     "switch=%x"     },
26035 +       { CTL_DEBUG_XID,        "xid=%x"        },
26036 +       { CTL_DEBUG_NID,        "nid=%x"        },
26037 +       { CTL_DEBUG_TAG,        "tag=%x"        },
26038 +       { CTL_DEBUG_NET,        "net=%x"        },
26039 +       { CTL_DEBUG_LIMIT,      "limit=%x"      },
26040 +       { CTL_DEBUG_CRES,       "cres=%x"       },
26041 +       { CTL_DEBUG_DLIM,       "dlim=%x"       },
26042 +       { CTL_DEBUG_QUOTA,      "quota=%x"      },
26043 +       { CTL_DEBUG_CVIRT,      "cvirt=%x"      },
26044 +       { CTL_DEBUG_SPACE,      "space=%x"      },
26045 +       { CTL_DEBUG_MISC,       "misc=%x"       },
26046 +       { CTL_DEBUG_ERROR,      NULL            }
26047 +};
26048 +
26049 +#define        HANDLE_CASE(id, name, val)                              \
26050 +       case CTL_DEBUG_ ## id:                                  \
26051 +               vx_debug_ ## name = val;                        \
26052 +               printk("vs_debug_" #name "=0x%x\n", val);       \
26053 +               break
26054 +
26055 +
26056 +static int __init vs_debug_setup(char *str)
26057 +{
26058 +       char *p;
26059 +       int token;
26060 +
26061 +       printk("vs_debug_setup(%s)\n", str);
26062 +       while ((p = strsep(&str, ",")) != NULL) {
26063 +               substring_t args[MAX_OPT_ARGS];
26064 +               unsigned int value;
26065 +
26066 +               if (!*p)
26067 +                       continue;
26068 +
26069 +               token = match_token(p, tokens, args);
26070 +               value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
26071 +
26072 +               switch (token) {
26073 +               HANDLE_CASE(SWITCH, switch, value);
26074 +               HANDLE_CASE(XID,    xid,    value);
26075 +               HANDLE_CASE(NID,    nid,    value);
26076 +               HANDLE_CASE(TAG,    tag,    value);
26077 +               HANDLE_CASE(NET,    net,    value);
26078 +               HANDLE_CASE(LIMIT,  limit,  value);
26079 +               HANDLE_CASE(CRES,   cres,   value);
26080 +               HANDLE_CASE(DLIM,   dlim,   value);
26081 +               HANDLE_CASE(QUOTA,  quota,  value);
26082 +               HANDLE_CASE(CVIRT,  cvirt,  value);
26083 +               HANDLE_CASE(SPACE,  space,  value);
26084 +               HANDLE_CASE(MISC,   misc,   value);
26085 +               default:
26086 +                       return -EINVAL;
26087 +                       break;
26088 +               }
26089 +       }
26090 +       return 1;
26091 +}
26092 +
26093 +__setup("vsdebug=", vs_debug_setup);
26094 +
26095 +
26096 +
26097 +EXPORT_SYMBOL_GPL(vx_debug_switch);
26098 +EXPORT_SYMBOL_GPL(vx_debug_xid);
26099 +EXPORT_SYMBOL_GPL(vx_debug_nid);
26100 +EXPORT_SYMBOL_GPL(vx_debug_net);
26101 +EXPORT_SYMBOL_GPL(vx_debug_limit);
26102 +EXPORT_SYMBOL_GPL(vx_debug_cres);
26103 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
26104 +EXPORT_SYMBOL_GPL(vx_debug_quota);
26105 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
26106 +EXPORT_SYMBOL_GPL(vx_debug_space);
26107 +EXPORT_SYMBOL_GPL(vx_debug_misc);
26108 +
26109 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/tag.c linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/tag.c
26110 --- linux-2.6.35.2/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
26111 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/tag.c   2010-08-02 17:05:06.000000000 +0200
26112 @@ -0,0 +1,63 @@
26113 +/*
26114 + *  linux/kernel/vserver/tag.c
26115 + *
26116 + *  Virtual Server: Shallow Tag Space
26117 + *
26118 + *  Copyright (C) 2007  Herbert Pötzl
26119 + *
26120 + *  V0.01  basic implementation
26121 + *
26122 + */
26123 +
26124 +#include <linux/sched.h>
26125 +#include <linux/vserver/debug.h>
26126 +#include <linux/vs_pid.h>
26127 +#include <linux/vs_tag.h>
26128 +
26129 +#include <linux/vserver/tag_cmd.h>
26130 +
26131 +
26132 +int dx_migrate_task(struct task_struct *p, tag_t tag)
26133 +{
26134 +       if (!p)
26135 +               BUG();
26136 +
26137 +       vxdprintk(VXD_CBIT(tag, 5),
26138 +               "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
26139 +
26140 +       task_lock(p);
26141 +       p->tag = tag;
26142 +       task_unlock(p);
26143 +
26144 +       vxdprintk(VXD_CBIT(tag, 5),
26145 +               "moved task %p into [#%d]", p, tag);
26146 +       return 0;
26147 +}
26148 +
26149 +/* vserver syscall commands below here */
26150 +
26151 +/* taks xid and vx_info functions */
26152 +
26153 +
26154 +int vc_task_tag(uint32_t id)
26155 +{
26156 +       tag_t tag;
26157 +
26158 +       if (id) {
26159 +               struct task_struct *tsk;
26160 +               read_lock(&tasklist_lock);
26161 +               tsk = find_task_by_real_pid(id);
26162 +               tag = (tsk) ? tsk->tag : -ESRCH;
26163 +               read_unlock(&tasklist_lock);
26164 +       } else
26165 +               tag = dx_current_tag();
26166 +       return tag;
26167 +}
26168 +
26169 +
26170 +int vc_tag_migrate(uint32_t tag)
26171 +{
26172 +       return dx_migrate_task(current, tag & 0xFFFF);
26173 +}
26174 +
26175 +
26176 diff -NurpP --minimal linux-2.6.35.2/kernel/vserver/vci_config.h linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/vci_config.h
26177 --- linux-2.6.35.2/kernel/vserver/vci_config.h  1970-01-01 01:00:00.000000000 +0100
26178 +++ linux-2.6.35.2-vs2.3.0.36.31/kernel/vserver/vci_config.h    2010-08-02 17:05:06.000000000 +0200
26179 @@ -0,0 +1,85 @@
26180 +
26181 +/*  interface version */
26182 +
26183 +#define VCI_VERSION            0x00020306
26184 +
26185 +
26186 +enum {
26187 +       VCI_KCBIT_NO_DYNAMIC = 0,
26188 +
26189 +       VCI_KCBIT_PROC_SECURE = 4,
26190 +       VCI_KCBIT_HARDCPU = 5,
26191 +       VCI_KCBIT_IDLELIMIT = 6,
26192 +       VCI_KCBIT_IDLETIME = 7,
26193 +
26194 +       VCI_KCBIT_COWBL = 8,
26195 +       VCI_KCBIT_FULLCOWBL = 9,
26196 +       VCI_KCBIT_SPACES = 10,
26197 +       VCI_KCBIT_NETV2 = 11,
26198 +       VCI_KCBIT_MEMCG = 12,
26199 +
26200 +       VCI_KCBIT_DEBUG = 16,
26201 +       VCI_KCBIT_HISTORY = 20,
26202 +       VCI_KCBIT_TAGGED = 24,
26203 +       VCI_KCBIT_PPTAG = 28,
26204 +
26205 +       VCI_KCBIT_MORE = 31,
26206 +};
26207 +
26208 +
26209 +static inline uint32_t vci_kernel_config(void)
26210 +{
26211 +       return
26212 +       (1 << VCI_KCBIT_NO_DYNAMIC) |
26213 +
26214 +       /* configured features */
26215 +#ifdef CONFIG_VSERVER_PROC_SECURE
26216 +       (1 << VCI_KCBIT_PROC_SECURE) |
26217 +#endif
26218 +#ifdef CONFIG_VSERVER_HARDCPU
26219 +       (1 << VCI_KCBIT_HARDCPU) |
26220 +#endif
26221 +#ifdef CONFIG_VSERVER_IDLELIMIT
26222 +       (1 << VCI_KCBIT_IDLELIMIT) |
26223 +#endif
26224 +#ifdef CONFIG_VSERVER_IDLETIME
26225 +       (1 << VCI_KCBIT_IDLETIME) |
26226 +#endif
26227 +#ifdef CONFIG_VSERVER_COWBL
26228 +       (1 << VCI_KCBIT_COWBL) |
26229 +       (1 << VCI_KCBIT_FULLCOWBL) |
26230 +#endif
26231 +       (1 << VCI_KCBIT_SPACES) |
26232 +       (1 << VCI_KCBIT_NETV2) |
26233 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
26234 +       (1 << VCI_KCBIT_MEMCG) |
26235 +#endif
26236 +
26237 +       /* debug options */
26238 +#ifdef CONFIG_VSERVER_DEBUG
26239 +       (1 << VCI_KCBIT_DEBUG) |
26240 +#endif
26241 +#ifdef CONFIG_VSERVER_HISTORY
26242 +       (1 << VCI_KCBIT_HISTORY) |
26243 +#endif
26244 +
26245 +       /* inode context tagging */
26246 +#if    defined(CONFIG_TAGGING_NONE)
26247 +       (0 << VCI_KCBIT_TAGGED) |
26248 +#elif  defined(CONFIG_TAGGING_UID16)
26249 +       (1 << VCI_KCBIT_TAGGED) |
26250 +#elif  defined(CONFIG_TAGGING_GID16)
26251 +       (2 << VCI_KCBIT_TAGGED) |
26252 +#elif  defined(CONFIG_TAGGING_ID24)
26253 +       (3 << VCI_KCBIT_TAGGED) |
26254 +#elif  defined(CONFIG_TAGGING_INTERN)
26255 +       (4 << VCI_KCBIT_TAGGED) |
26256 +#elif  defined(CONFIG_TAGGING_RUNTIME)
26257 +       (5 << VCI_KCBIT_TAGGED) |
26258 +#else
26259 +       (7 << VCI_KCBIT_TAGGED) |
26260 +#endif
26261 +       (1 << VCI_KCBIT_PPTAG) |
26262 +       0;
26263 +}
26264 +
26265 diff -NurpP --minimal linux-2.6.35.2/mm/filemap_xip.c linux-2.6.35.2-vs2.3.0.36.31/mm/filemap_xip.c
26266 --- linux-2.6.35.2/mm/filemap_xip.c     2010-07-07 18:31:58.000000000 +0200
26267 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/filemap_xip.c       2010-08-02 17:05:06.000000000 +0200
26268 @@ -18,6 +18,7 @@
26269  #include <linux/seqlock.h>
26270  #include <linux/mutex.h>
26271  #include <linux/gfp.h>
26272 +#include <linux/vs_memory.h>
26273  #include <asm/tlbflush.h>
26274  #include <asm/io.h>
26275  
26276 diff -NurpP --minimal linux-2.6.35.2/mm/fremap.c linux-2.6.35.2-vs2.3.0.36.31/mm/fremap.c
26277 --- linux-2.6.35.2/mm/fremap.c  2010-07-07 18:31:58.000000000 +0200
26278 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/fremap.c    2010-08-02 17:05:06.000000000 +0200
26279 @@ -16,6 +16,7 @@
26280  #include <linux/module.h>
26281  #include <linux/syscalls.h>
26282  #include <linux/mmu_notifier.h>
26283 +#include <linux/vs_memory.h>
26284  
26285  #include <asm/mmu_context.h>
26286  #include <asm/cacheflush.h>
26287 diff -NurpP --minimal linux-2.6.35.2/mm/hugetlb.c linux-2.6.35.2-vs2.3.0.36.31/mm/hugetlb.c
26288 --- linux-2.6.35.2/mm/hugetlb.c 2010-08-02 16:52:58.000000000 +0200
26289 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/hugetlb.c   2010-08-02 17:05:06.000000000 +0200
26290 @@ -25,6 +25,7 @@
26291  
26292  #include <linux/hugetlb.h>
26293  #include <linux/node.h>
26294 +#include <linux/vs_memory.h>
26295  #include "internal.h"
26296  
26297  const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26298 diff -NurpP --minimal linux-2.6.35.2/mm/memcontrol.c linux-2.6.35.2-vs2.3.0.36.31/mm/memcontrol.c
26299 --- linux-2.6.35.2/mm/memcontrol.c      2010-08-02 16:52:58.000000000 +0200
26300 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/memcontrol.c        2010-08-02 17:05:06.000000000 +0200
26301 @@ -635,6 +635,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26302                                 struct mem_cgroup, css);
26303  }
26304  
26305 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26306 +{
26307 +       return res_counter_read_u64(&mem->res, member);
26308 +}
26309 +
26310 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26311 +{
26312 +       return res_counter_read_u64(&mem->memsw, member);
26313 +}
26314 +
26315 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26316 +{
26317 +       return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
26318 +}
26319 +
26320 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26321 +{
26322 +       return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
26323 +}
26324 +
26325 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26326 +{
26327 +       return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
26328 +}
26329 +
26330  static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26331  {
26332         struct mem_cgroup *mem = NULL;
26333 diff -NurpP --minimal linux-2.6.35.2/mm/memory.c linux-2.6.35.2-vs2.3.0.36.31/mm/memory.c
26334 --- linux-2.6.35.2/mm/memory.c  2010-08-14 18:16:59.000000000 +0200
26335 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/memory.c    2010-08-14 18:19:32.000000000 +0200
26336 @@ -3101,6 +3101,7 @@ static inline int handle_pte_fault(struc
26337  {
26338         pte_t entry;
26339         spinlock_t *ptl;
26340 +       int ret = 0, type = VXPT_UNKNOWN;
26341  
26342         entry = *pte;
26343         if (!pte_present(entry)) {
26344 @@ -3125,9 +3126,12 @@ static inline int handle_pte_fault(struc
26345         if (unlikely(!pte_same(*pte, entry)))
26346                 goto unlock;
26347         if (flags & FAULT_FLAG_WRITE) {
26348 -               if (!pte_write(entry))
26349 -                       return do_wp_page(mm, vma, address,
26350 +               if (!pte_write(entry)) {
26351 +                       ret = do_wp_page(mm, vma, address,
26352                                         pte, pmd, ptl, entry);
26353 +                       type = VXPT_WRITE;
26354 +                       goto out;
26355 +               }
26356                 entry = pte_mkdirty(entry);
26357         }
26358         entry = pte_mkyoung(entry);
26359 @@ -3145,7 +3149,10 @@ static inline int handle_pte_fault(struc
26360         }
26361  unlock:
26362         pte_unmap_unlock(pte, ptl);
26363 -       return 0;
26364 +       ret = 0;
26365 +out:
26366 +       vx_page_fault(mm, vma, type, ret);
26367 +       return ret;
26368  }
26369  
26370  /*
26371 diff -NurpP --minimal linux-2.6.35.2/mm/mlock.c linux-2.6.35.2-vs2.3.0.36.31/mm/mlock.c
26372 --- linux-2.6.35.2/mm/mlock.c   2010-08-02 16:52:58.000000000 +0200
26373 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/mlock.c     2010-08-02 17:05:06.000000000 +0200
26374 @@ -18,6 +18,7 @@
26375  #include <linux/rmap.h>
26376  #include <linux/mmzone.h>
26377  #include <linux/hugetlb.h>
26378 +#include <linux/vs_memory.h>
26379  
26380  #include "internal.h"
26381  
26382 @@ -471,7 +472,7 @@ static int do_mlock(unsigned long start,
26383  
26384  SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
26385  {
26386 -       unsigned long locked;
26387 +       unsigned long locked, grow;
26388         unsigned long lock_limit;
26389         int error = -ENOMEM;
26390  
26391 @@ -493,6 +494,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26392         /* check against resource limits */
26393         if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26394                 error = do_mlock(start, len, 1);
26395 +out:
26396         up_write(&current->mm->mmap_sem);
26397         return error;
26398  }
26399 diff -NurpP --minimal linux-2.6.35.2/mm/mremap.c linux-2.6.35.2-vs2.3.0.36.31/mm/mremap.c
26400 --- linux-2.6.35.2/mm/mremap.c  2010-07-07 18:31:58.000000000 +0200
26401 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/mremap.c    2010-08-02 17:05:06.000000000 +0200
26402 @@ -19,6 +19,7 @@
26403  #include <linux/security.h>
26404  #include <linux/syscalls.h>
26405  #include <linux/mmu_notifier.h>
26406 +#include <linux/vs_memory.h>
26407  
26408  #include <asm/uaccess.h>
26409  #include <asm/cacheflush.h>
26410 diff -NurpP --minimal linux-2.6.35.2/mm/oom_kill.c linux-2.6.35.2-vs2.3.0.36.31/mm/oom_kill.c
26411 --- linux-2.6.35.2/mm/oom_kill.c        2010-08-02 16:52:58.000000000 +0200
26412 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/oom_kill.c  2010-08-02 17:05:06.000000000 +0200
26413 @@ -28,6 +28,9 @@
26414  #include <linux/notifier.h>
26415  #include <linux/memcontrol.h>
26416  #include <linux/security.h>
26417 +#include <linux/reboot.h>
26418 +#include <linux/vs_memory.h>
26419 +#include <linux/vs_context.h>
26420  
26421  int sysctl_panic_on_oom;
26422  int sysctl_oom_kill_allocating_task;
26423 @@ -187,9 +190,21 @@ unsigned long badness(struct task_struct
26424                         points >>= -(oom_adj);
26425         }
26426  
26427 +       /*
26428 +        * add points for context badness and
26429 +        * reduce badness for processes belonging to
26430 +        * a different context
26431 +        */
26432 +
26433 +       points += vx_badness(p, mm);
26434 +
26435 +       if ((vx_current_xid() > 1) &&
26436 +               vx_current_xid() != vx_task_xid(p))
26437 +               points /= 16;
26438 +
26439  #ifdef DEBUG
26440 -       printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26441 -       p->pid, p->comm, points);
26442 +       printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26443 +               task_pid_nr(p), p->xid, p->comm, points);
26444  #endif
26445         return points;
26446  }
26447 @@ -250,6 +265,7 @@ static struct task_struct *select_bad_pr
26448         struct task_struct *p;
26449         struct task_struct *chosen = NULL;
26450         struct timespec uptime;
26451 +       unsigned xid = vx_current_xid();
26452         *ppoints = 0;
26453  
26454         do_posix_clock_monotonic_gettime(&uptime);
26455 @@ -262,11 +278,14 @@ static struct task_struct *select_bad_pr
26456                  */
26457                 if (!p->mm)
26458                         continue;
26459 -               /* skip the init task */
26460 -               if (is_global_init(p))
26461 +               /* skip the init task, global and per guest */
26462 +               if (task_is_init(p))
26463                         continue;
26464                 if (mem && !task_in_mem_cgroup(p, mem))
26465                         continue;
26466 +               /* skip other guest and host processes if oom in guest */
26467 +               if (xid && vx_task_xid(p) != xid)
26468 +                       continue;
26469  
26470                 /*
26471                  * This task already has access to memory reserves and is
26472 @@ -398,9 +417,9 @@ static void __oom_kill_task(struct task_
26473         }
26474  
26475         if (verbose)
26476 -               printk(KERN_ERR "Killed process %d (%s) "
26477 +               printk(KERN_ERR "Killed process %s(%d:#%u) "
26478                        "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
26479 -                      task_pid_nr(p), p->comm,
26480 +                      p->comm, task_pid_nr(p), p->xid,
26481                        K(p->mm->total_vm),
26482                        K(get_mm_counter(p->mm, MM_ANONPAGES)),
26483                        K(get_mm_counter(p->mm, MM_FILEPAGES)));
26484 @@ -453,8 +472,8 @@ static int oom_kill_process(struct task_
26485                 return 0;
26486         }
26487  
26488 -       printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26489 -                                       message, task_pid_nr(p), p->comm, points);
26490 +       printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
26491 +               message, p->comm, task_pid_nr(p), p->xid, points);
26492  
26493         /* Try to kill a child first */
26494         list_for_each_entry(c, &p->children, sibling) {
26495 @@ -554,6 +573,8 @@ void clear_zonelist_oom(struct zonelist 
26496         spin_unlock(&zone_scan_lock);
26497  }
26498  
26499 +long vs_oom_action(unsigned int);
26500 +
26501  /*
26502   * Must be called with tasklist_lock held for read.
26503   */
26504 @@ -580,7 +601,11 @@ retry:
26505         if (!p) {
26506                 read_unlock(&tasklist_lock);
26507                 dump_header(NULL, gfp_mask, order, NULL);
26508 -               panic("Out of memory and no killable processes...\n");
26509 +               /* avoid panic for guest OOM */
26510 +               if (current->xid)
26511 +                       vs_oom_action(LINUX_REBOOT_CMD_OOM);
26512 +               else
26513 +                       panic("Out of memory and no killable processes...\n");
26514         }
26515  
26516         if (oom_kill_process(p, gfp_mask, order, points, NULL,
26517 diff -NurpP --minimal linux-2.6.35.2/mm/page_alloc.c linux-2.6.35.2-vs2.3.0.36.31/mm/page_alloc.c
26518 --- linux-2.6.35.2/mm/page_alloc.c      2010-08-02 16:52:58.000000000 +0200
26519 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/page_alloc.c        2010-08-02 17:46:11.000000000 +0200
26520 @@ -52,6 +52,8 @@
26521  #include <linux/compaction.h>
26522  #include <trace/events/kmem.h>
26523  #include <linux/ftrace_event.h>
26524 +#include <linux/vs_base.h>
26525 +#include <linux/vs_limit.h>
26526  
26527  #include <asm/tlbflush.h>
26528  #include <asm/div64.h>
26529 @@ -2305,6 +2307,9 @@ void si_meminfo(struct sysinfo *val)
26530         val->totalhigh = totalhigh_pages;
26531         val->freehigh = nr_free_highpages();
26532         val->mem_unit = PAGE_SIZE;
26533 +
26534 +       if (vx_flags(VXF_VIRT_MEM, 0))
26535 +               vx_vsi_meminfo(val);
26536  }
26537  
26538  EXPORT_SYMBOL(si_meminfo);
26539 @@ -2325,6 +2330,9 @@ void si_meminfo_node(struct sysinfo *val
26540         val->freehigh = 0;
26541  #endif
26542         val->mem_unit = PAGE_SIZE;
26543 +
26544 +       if (vx_flags(VXF_VIRT_MEM, 0))
26545 +               vx_vsi_meminfo(val);
26546  }
26547  #endif
26548  
26549 diff -NurpP --minimal linux-2.6.35.2/mm/rmap.c linux-2.6.35.2-vs2.3.0.36.31/mm/rmap.c
26550 --- linux-2.6.35.2/mm/rmap.c    2010-08-02 16:52:58.000000000 +0200
26551 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/rmap.c      2010-08-02 17:05:06.000000000 +0200
26552 @@ -56,6 +56,7 @@
26553  #include <linux/memcontrol.h>
26554  #include <linux/mmu_notifier.h>
26555  #include <linux/migrate.h>
26556 +#include <linux/vs_memory.h>
26557  
26558  #include <asm/tlbflush.h>
26559  
26560 diff -NurpP --minimal linux-2.6.35.2/mm/shmem.c linux-2.6.35.2-vs2.3.0.36.31/mm/shmem.c
26561 --- linux-2.6.35.2/mm/shmem.c   2010-08-02 16:52:58.000000000 +0200
26562 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/shmem.c     2010-08-02 17:05:06.000000000 +0200
26563 @@ -1788,7 +1788,7 @@ static int shmem_statfs(struct dentry *d
26564  {
26565         struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26566  
26567 -       buf->f_type = TMPFS_MAGIC;
26568 +       buf->f_type = TMPFS_SUPER_MAGIC;
26569         buf->f_bsize = PAGE_CACHE_SIZE;
26570         buf->f_namelen = NAME_MAX;
26571         spin_lock(&sbinfo->stat_lock);
26572 @@ -2350,7 +2350,7 @@ int shmem_fill_super(struct super_block 
26573         sb->s_maxbytes = SHMEM_MAX_BYTES;
26574         sb->s_blocksize = PAGE_CACHE_SIZE;
26575         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26576 -       sb->s_magic = TMPFS_MAGIC;
26577 +       sb->s_magic = TMPFS_SUPER_MAGIC;
26578         sb->s_op = &shmem_ops;
26579         sb->s_time_gran = 1;
26580  #ifdef CONFIG_TMPFS_POSIX_ACL
26581 diff -NurpP --minimal linux-2.6.35.2/mm/slab.c linux-2.6.35.2-vs2.3.0.36.31/mm/slab.c
26582 --- linux-2.6.35.2/mm/slab.c    2010-08-02 16:52:58.000000000 +0200
26583 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/slab.c      2010-08-02 17:05:06.000000000 +0200
26584 @@ -408,6 +408,8 @@ static void kmem_list3_init(struct kmem_
26585  #define STATS_INC_FREEMISS(x)  do { } while (0)
26586  #endif
26587  
26588 +#include "slab_vs.h"
26589 +
26590  #if DEBUG
26591  
26592  /*
26593 @@ -3347,6 +3349,7 @@ retry:
26594  
26595         obj = slab_get_obj(cachep, slabp, nodeid);
26596         check_slabp(cachep, slabp);
26597 +       vx_slab_alloc(cachep, flags);
26598         l3->free_objects--;
26599         /* move slabp to correct slabp list: */
26600         list_del(&slabp->list);
26601 @@ -3424,6 +3427,7 @@ __cache_alloc_node(struct kmem_cache *ca
26602         /* ___cache_alloc_node can fall back to other nodes */
26603         ptr = ____cache_alloc_node(cachep, flags, nodeid);
26604    out:
26605 +       vx_slab_alloc(cachep, flags);
26606         local_irq_restore(save_flags);
26607         ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26608         kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
26609 @@ -3610,6 +3614,7 @@ static inline void __cache_free(struct k
26610         check_irq_off();
26611         kmemleak_free_recursive(objp, cachep->flags);
26612         objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26613 +       vx_slab_free(cachep);
26614  
26615         kmemcheck_slab_free(cachep, objp, obj_size(cachep));
26616  
26617 diff -NurpP --minimal linux-2.6.35.2/mm/slab_vs.h linux-2.6.35.2-vs2.3.0.36.31/mm/slab_vs.h
26618 --- linux-2.6.35.2/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26619 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/slab_vs.h   2010-08-02 17:05:06.000000000 +0200
26620 @@ -0,0 +1,29 @@
26621 +
26622 +#include <linux/vserver/context.h>
26623 +
26624 +#include <linux/vs_context.h>
26625 +
26626 +static inline
26627 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26628 +{
26629 +       int what = gfp_zone(cachep->gfpflags);
26630 +       struct vx_info *vxi = current_vx_info();
26631 +
26632 +       if (!vxi)
26633 +               return;
26634 +
26635 +       atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
26636 +}
26637 +
26638 +static inline
26639 +void vx_slab_free(struct kmem_cache *cachep)
26640 +{
26641 +       int what = gfp_zone(cachep->gfpflags);
26642 +       struct vx_info *vxi = current_vx_info();
26643 +
26644 +       if (!vxi)
26645 +               return;
26646 +
26647 +       atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
26648 +}
26649 +
26650 diff -NurpP --minimal linux-2.6.35.2/mm/swapfile.c linux-2.6.35.2-vs2.3.0.36.31/mm/swapfile.c
26651 --- linux-2.6.35.2/mm/swapfile.c        2010-08-14 18:16:59.000000000 +0200
26652 +++ linux-2.6.35.2-vs2.3.0.36.31/mm/swapfile.c  2010-08-14 18:19:32.000000000 +0200
26653 @@ -35,6 +35,8 @@
26654  #include <asm/tlbflush.h>
26655  #include <linux/swapops.h>
26656  #include <linux/page_cgroup.h>
26657 +#include <linux/vs_base.h>
26658 +#include <linux/vs_memory.h>
26659  
26660  static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
26661                                  unsigned char);
26662 @@ -1734,6 +1736,16 @@ static int swap_show(struct seq_file *sw
26663  
26664         if (si == SEQ_START_TOKEN) {
26665                 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
26666 +               if (vx_flags(VXF_VIRT_MEM, 0)) {
26667 +                       struct sysinfo si;
26668 +
26669 +                       vx_vsi_swapinfo(&si);
26670 +                       if (si.totalswap < (1 << 10))
26671 +                               return 0;
26672 +                       seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
26673 +                               "hdv0", "partition", si.totalswap >> 10,
26674 +                               (si.totalswap - si.freeswap) >> 10, -1);
26675 +               }
26676                 return 0;
26677         }
26678  
26679 @@ -2118,6 +2130,8 @@ void si_swapinfo(struct sysinfo *val)
26680         val->freeswap = nr_swap_pages + nr_to_be_unused;
26681         val->totalswap = total_swap_pages + nr_to_be_unused;
26682         spin_unlock(&swap_lock);
26683 +       if (vx_flags(VXF_VIRT_MEM, 0))
26684 +               vx_vsi_swapinfo(val);
26685  }
26686  
26687  /*
26688 diff -NurpP --minimal linux-2.6.35.2/net/core/dev.c linux-2.6.35.2-vs2.3.0.36.31/net/core/dev.c
26689 --- linux-2.6.35.2/net/core/dev.c       2010-08-02 16:52:59.000000000 +0200
26690 +++ linux-2.6.35.2-vs2.3.0.36.31/net/core/dev.c 2010-08-02 17:05:06.000000000 +0200
26691 @@ -129,6 +129,7 @@
26692  #include <linux/in.h>
26693  #include <linux/jhash.h>
26694  #include <linux/random.h>
26695 +#include <linux/vs_inet.h>
26696  #include <trace/events/napi.h>
26697  #include <linux/pci.h>
26698  
26699 @@ -609,7 +610,8 @@ struct net_device *__dev_get_by_name(str
26700         struct hlist_head *head = dev_name_hash(net, name);
26701  
26702         hlist_for_each_entry(dev, p, head, name_hlist)
26703 -               if (!strncmp(dev->name, name, IFNAMSIZ))
26704 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
26705 +                   nx_dev_visible(current_nx_info(), dev))
26706                         return dev;
26707  
26708         return NULL;
26709 @@ -635,7 +637,8 @@ struct net_device *dev_get_by_name_rcu(s
26710         struct hlist_head *head = dev_name_hash(net, name);
26711  
26712         hlist_for_each_entry_rcu(dev, p, head, name_hlist)
26713 -               if (!strncmp(dev->name, name, IFNAMSIZ))
26714 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
26715 +                   nx_dev_visible(current_nx_info(), dev))
26716                         return dev;
26717  
26718         return NULL;
26719 @@ -686,7 +689,8 @@ struct net_device *__dev_get_by_index(st
26720         struct hlist_head *head = dev_index_hash(net, ifindex);
26721  
26722         hlist_for_each_entry(dev, p, head, index_hlist)
26723 -               if (dev->ifindex == ifindex)
26724 +               if ((dev->ifindex == ifindex) &&
26725 +                   nx_dev_visible(current_nx_info(), dev))
26726                         return dev;
26727  
26728         return NULL;
26729 @@ -711,7 +715,8 @@ struct net_device *dev_get_by_index_rcu(
26730         struct hlist_head *head = dev_index_hash(net, ifindex);
26731  
26732         hlist_for_each_entry_rcu(dev, p, head, index_hlist)
26733 -               if (dev->ifindex == ifindex)
26734 +               if ((dev->ifindex == ifindex) &&
26735 +                   nx_dev_visible(current_nx_info(), dev))
26736                         return dev;
26737  
26738         return NULL;
26739 @@ -764,10 +769,12 @@ struct net_device *dev_getbyhwaddr(struc
26740  
26741         ASSERT_RTNL();
26742  
26743 -       for_each_netdev(net, dev)
26744 +       for_each_netdev(net, dev) {
26745                 if (dev->type == type &&
26746 -                   !memcmp(dev->dev_addr, ha, dev->addr_len))
26747 +                   !memcmp(dev->dev_addr, ha, dev->addr_len) &&
26748 +                   nx_dev_visible(current_nx_info(), dev))
26749                         return dev;
26750 +       }
26751  
26752         return NULL;
26753  }
26754 @@ -778,9 +785,11 @@ struct net_device *__dev_getfirstbyhwtyp
26755         struct net_device *dev;
26756  
26757         ASSERT_RTNL();
26758 -       for_each_netdev(net, dev)
26759 -               if (dev->type == type)
26760 +       for_each_netdev(net, dev) {
26761 +               if ((dev->type == type) &&
26762 +                   nx_dev_visible(current_nx_info(), dev))
26763                         return dev;
26764 +       }
26765  
26766         return NULL;
26767  }
26768 @@ -902,6 +911,8 @@ static int __dev_alloc_name(struct net *
26769                                 continue;
26770                         if (i < 0 || i >= max_netdevices)
26771                                 continue;
26772 +                       if (!nx_dev_visible(current_nx_info(), d))
26773 +                               continue;
26774  
26775                         /*  avoid cases where sscanf is not exact inverse of printf */
26776                         snprintf(buf, IFNAMSIZ, name, i);
26777 @@ -3651,6 +3662,8 @@ static int dev_ifconf(struct net *net, c
26778  
26779         total = 0;
26780         for_each_netdev(net, dev) {
26781 +               if (!nx_dev_visible(current_nx_info(), dev))
26782 +                       continue;
26783                 for (i = 0; i < NPROTO; i++) {
26784                         if (gifconf_list[i]) {
26785                                 int done;
26786 @@ -3721,6 +3734,9 @@ static void dev_seq_printf_stats(struct 
26787  {
26788         const struct net_device_stats *stats = dev_get_stats(dev);
26789  
26790 +       if (!nx_dev_visible(current_nx_info(), dev))
26791 +               return;
26792 +
26793         seq_printf(seq, "%6s: %7lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26794                    "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26795                    dev->name, stats->rx_bytes, stats->rx_packets,
26796 diff -NurpP --minimal linux-2.6.35.2/net/core/rtnetlink.c linux-2.6.35.2-vs2.3.0.36.31/net/core/rtnetlink.c
26797 --- linux-2.6.35.2/net/core/rtnetlink.c 2010-08-02 16:52:59.000000000 +0200
26798 +++ linux-2.6.35.2-vs2.3.0.36.31/net/core/rtnetlink.c   2010-08-02 17:05:06.000000000 +0200
26799 @@ -926,6 +926,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26800                 hlist_for_each_entry(dev, node, head, index_hlist) {
26801                         if (idx < s_idx)
26802                                 goto cont;
26803 +                       if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26804 +                               continue;
26805                         if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26806                                              NETLINK_CB(cb->skb).pid,
26807                                              cb->nlh->nlmsg_seq, 0,
26808 @@ -1642,6 +1644,9 @@ void rtmsg_ifinfo(int type, struct net_d
26809         struct sk_buff *skb;
26810         int err = -ENOBUFS;
26811  
26812 +       if (!nx_dev_visible(current_nx_info(), dev))
26813 +               return;
26814 +
26815         skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26816         if (skb == NULL)
26817                 goto errout;
26818 diff -NurpP --minimal linux-2.6.35.2/net/core/sock.c linux-2.6.35.2-vs2.3.0.36.31/net/core/sock.c
26819 --- linux-2.6.35.2/net/core/sock.c      2010-08-02 16:52:59.000000000 +0200
26820 +++ linux-2.6.35.2-vs2.3.0.36.31/net/core/sock.c        2010-08-02 17:05:06.000000000 +0200
26821 @@ -126,6 +126,10 @@
26822  #include <net/cls_cgroup.h>
26823  
26824  #include <linux/filter.h>
26825 +#include <linux/vs_socket.h>
26826 +#include <linux/vs_limit.h>
26827 +#include <linux/vs_context.h>
26828 +#include <linux/vs_network.h>
26829  
26830  #ifdef CONFIG_INET
26831  #include <net/tcp.h>
26832 @@ -1027,6 +1031,8 @@ static struct sock *sk_prot_alloc(struct
26833                         goto out_free_sec;
26834                 sk_tx_queue_clear(sk);
26835         }
26836 +               sock_vx_init(sk);
26837 +               sock_nx_init(sk);
26838  
26839         return sk;
26840  
26841 @@ -1120,6 +1126,11 @@ static void __sk_free(struct sock *sk)
26842                        __func__, atomic_read(&sk->sk_omem_alloc));
26843  
26844         put_net(sock_net(sk));
26845 +       vx_sock_dec(sk);
26846 +       clr_vx_info(&sk->sk_vx_info);
26847 +       sk->sk_xid = -1;
26848 +       clr_nx_info(&sk->sk_nx_info);
26849 +       sk->sk_nid = -1;
26850         sk_prot_free(sk->sk_prot_creator, sk);
26851  }
26852  
26853 @@ -1167,6 +1178,8 @@ struct sock *sk_clone(const struct sock 
26854  
26855                 /* SANITY */
26856                 get_net(sock_net(newsk));
26857 +               sock_vx_init(newsk);
26858 +               sock_nx_init(newsk);
26859                 sk_node_init(&newsk->sk_node);
26860                 sock_lock_init(newsk);
26861                 bh_lock_sock(newsk);
26862 @@ -1222,6 +1235,12 @@ struct sock *sk_clone(const struct sock 
26863                 smp_wmb();
26864                 atomic_set(&newsk->sk_refcnt, 2);
26865  
26866 +               set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26867 +               newsk->sk_xid = sk->sk_xid;
26868 +               vx_sock_inc(newsk);
26869 +               set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26870 +               newsk->sk_nid = sk->sk_nid;
26871 +
26872                 /*
26873                  * Increment the counter in the same struct proto as the master
26874                  * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26875 @@ -1964,6 +1983,12 @@ void sock_init_data(struct socket *sock,
26876  
26877         sk->sk_stamp = ktime_set(-1L, 0);
26878  
26879 +       set_vx_info(&sk->sk_vx_info, current_vx_info());
26880 +       sk->sk_xid = vx_current_xid();
26881 +       vx_sock_inc(sk);
26882 +       set_nx_info(&sk->sk_nx_info, current_nx_info());
26883 +       sk->sk_nid = nx_current_nid();
26884 +
26885         /*
26886          * Before updating sk_refcnt, we must commit prior changes to memory
26887          * (Documentation/RCU/rculist_nulls.txt for details)
26888 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/af_inet.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/af_inet.c
26889 --- linux-2.6.35.2/net/ipv4/af_inet.c   2010-08-02 16:52:59.000000000 +0200
26890 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/af_inet.c     2010-08-02 17:05:06.000000000 +0200
26891 @@ -116,6 +116,7 @@
26892  #ifdef CONFIG_IP_MROUTE
26893  #include <linux/mroute.h>
26894  #endif
26895 +#include <linux/vs_limit.h>
26896  
26897  
26898  /* The inetsw table contains everything that inet_create needs to
26899 @@ -327,9 +328,13 @@ lookup_protocol:
26900         }
26901  
26902         err = -EPERM;
26903 +       if ((protocol == IPPROTO_ICMP) &&
26904 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
26905 +               goto override;
26906 +
26907         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
26908                 goto out_rcu_unlock;
26909 -
26910 +override:
26911         err = -EAFNOSUPPORT;
26912         if (!inet_netns_ok(net, protocol))
26913                 goto out_rcu_unlock;
26914 @@ -451,6 +456,7 @@ int inet_bind(struct socket *sock, struc
26915         struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26916         struct sock *sk = sock->sk;
26917         struct inet_sock *inet = inet_sk(sk);
26918 +       struct nx_v4_sock_addr nsa;
26919         unsigned short snum;
26920         int chk_addr_ret;
26921         int err;
26922 @@ -464,7 +470,11 @@ int inet_bind(struct socket *sock, struc
26923         if (addr_len < sizeof(struct sockaddr_in))
26924                 goto out;
26925  
26926 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26927 +       err = v4_map_sock_addr(inet, addr, &nsa);
26928 +       if (err)
26929 +               goto out;
26930 +
26931 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26932  
26933         /* Not specified by any standard per-se, however it breaks too
26934          * many applications when removed.  It is unfortunate since
26935 @@ -476,7 +486,7 @@ int inet_bind(struct socket *sock, struc
26936         err = -EADDRNOTAVAIL;
26937         if (!sysctl_ip_nonlocal_bind &&
26938             !(inet->freebind || inet->transparent) &&
26939 -           addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26940 +           nsa.saddr != htonl(INADDR_ANY) &&
26941             chk_addr_ret != RTN_LOCAL &&
26942             chk_addr_ret != RTN_MULTICAST &&
26943             chk_addr_ret != RTN_BROADCAST)
26944 @@ -501,7 +511,7 @@ int inet_bind(struct socket *sock, struc
26945         if (sk->sk_state != TCP_CLOSE || inet->inet_num)
26946                 goto out_release_sock;
26947  
26948 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26949 +       v4_set_sock_addr(inet, &nsa);
26950         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26951                 inet->inet_saddr = 0;  /* Use device */
26952  
26953 @@ -703,11 +713,13 @@ int inet_getname(struct socket *sock, st
26954                      peer == 1))
26955                         return -ENOTCONN;
26956                 sin->sin_port = inet->inet_dport;
26957 -               sin->sin_addr.s_addr = inet->inet_daddr;
26958 +               sin->sin_addr.s_addr =
26959 +                       nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
26960         } else {
26961                 __be32 addr = inet->inet_rcv_saddr;
26962                 if (!addr)
26963                         addr = inet->inet_saddr;
26964 +               addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26965                 sin->sin_port = inet->inet_sport;
26966                 sin->sin_addr.s_addr = addr;
26967         }
26968 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/devinet.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/devinet.c
26969 --- linux-2.6.35.2/net/ipv4/devinet.c   2010-08-14 18:16:59.000000000 +0200
26970 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/devinet.c     2010-08-14 18:19:32.000000000 +0200
26971 @@ -417,6 +417,7 @@ struct in_device *inetdev_by_index(struc
26972  }
26973  EXPORT_SYMBOL(inetdev_by_index);
26974  
26975 +
26976  /* Called only from RTNL semaphored context. No locks. */
26977  
26978  struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26979 @@ -659,6 +660,8 @@ int devinet_ioctl(struct net *net, unsig
26980  
26981         in_dev = __in_dev_get_rtnl(dev);
26982         if (in_dev) {
26983 +               struct nx_info *nxi = current_nx_info();
26984 +
26985                 if (tryaddrmatch) {
26986                         /* Matthias Andree */
26987                         /* compare label and address (4.4BSD style) */
26988 @@ -667,6 +670,8 @@ int devinet_ioctl(struct net *net, unsig
26989                            This is checked above. */
26990                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26991                              ifap = &ifa->ifa_next) {
26992 +                               if (!nx_v4_ifa_visible(nxi, ifa))
26993 +                                       continue;
26994                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26995                                     sin_orig.sin_addr.s_addr ==
26996                                                         ifa->ifa_address) {
26997 @@ -679,9 +684,12 @@ int devinet_ioctl(struct net *net, unsig
26998                    comparing just the label */
26999                 if (!ifa) {
27000                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27001 -                            ifap = &ifa->ifa_next)
27002 +                            ifap = &ifa->ifa_next) {
27003 +                               if (!nx_v4_ifa_visible(nxi, ifa))
27004 +                                       continue;
27005                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
27006                                         break;
27007 +                       }
27008                 }
27009         }
27010  
27011 @@ -833,6 +841,8 @@ static int inet_gifconf(struct net_devic
27012                 goto out;
27013  
27014         for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
27015 +               if (!nx_v4_ifa_visible(current_nx_info(), ifa))
27016 +                       continue;
27017                 if (!buf) {
27018                         done += sizeof(ifr);
27019                         continue;
27020 @@ -1182,6 +1192,7 @@ static int inet_dump_ifaddr(struct sk_bu
27021         struct net_device *dev;
27022         struct in_device *in_dev;
27023         struct in_ifaddr *ifa;
27024 +       struct sock *sk = skb->sk;
27025         struct hlist_head *head;
27026         struct hlist_node *node;
27027  
27028 @@ -1204,6 +1215,8 @@ static int inet_dump_ifaddr(struct sk_bu
27029  
27030                         for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
27031                              ifa = ifa->ifa_next, ip_idx++) {
27032 +                       if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
27033 +                               continue;
27034                                 if (ip_idx < s_ip_idx)
27035                                         continue;
27036                                 if (inet_fill_ifaddr(skb, ifa,
27037 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/fib_hash.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/fib_hash.c
27038 --- linux-2.6.35.2/net/ipv4/fib_hash.c  2010-07-07 18:31:59.000000000 +0200
27039 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/fib_hash.c    2010-08-02 17:05:06.000000000 +0200
27040 @@ -1017,7 +1017,7 @@ static int fib_seq_show(struct seq_file 
27041         prefix  = f->fn_key;
27042         mask    = FZ_MASK(iter->zone);
27043         flags   = fib_flag_trans(fa->fa_type, mask, fi);
27044 -       if (fi)
27045 +       if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
27046                 seq_printf(seq,
27047                          "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
27048                          fi->fib_dev ? fi->fib_dev->name : "*", prefix,
27049 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/inet_connection_sock.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/inet_connection_sock.c
27050 --- linux-2.6.35.2/net/ipv4/inet_connection_sock.c      2010-08-02 16:52:59.000000000 +0200
27051 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/inet_connection_sock.c        2010-08-02 17:05:06.000000000 +0200
27052 @@ -52,10 +52,40 @@ void inet_get_local_port_range(int *low,
27053  }
27054  EXPORT_SYMBOL(inet_get_local_port_range);
27055  
27056 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27057 +{
27058 +       __be32  sk1_rcv_saddr = inet_rcv_saddr(sk1),
27059 +               sk2_rcv_saddr = inet_rcv_saddr(sk2);
27060 +
27061 +       if (inet_v6_ipv6only(sk2))
27062 +               return 0;
27063 +
27064 +       if (sk1_rcv_saddr &&
27065 +           sk2_rcv_saddr &&
27066 +           sk1_rcv_saddr == sk2_rcv_saddr)
27067 +               return 1;
27068 +
27069 +       if (sk1_rcv_saddr &&
27070 +           !sk2_rcv_saddr &&
27071 +           v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
27072 +               return 1;
27073 +
27074 +       if (sk2_rcv_saddr &&
27075 +           !sk1_rcv_saddr &&
27076 +           v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
27077 +               return 1;
27078 +
27079 +       if (!sk1_rcv_saddr &&
27080 +           !sk2_rcv_saddr &&
27081 +           nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
27082 +               return 1;
27083 +
27084 +       return 0;
27085 +}
27086 +
27087  int inet_csk_bind_conflict(const struct sock *sk,
27088                            const struct inet_bind_bucket *tb)
27089  {
27090 -       const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27091         struct sock *sk2;
27092         struct hlist_node *node;
27093         int reuse = sk->sk_reuse;
27094 @@ -75,9 +105,7 @@ int inet_csk_bind_conflict(const struct 
27095                      sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27096                         if (!reuse || !sk2->sk_reuse ||
27097                             sk2->sk_state == TCP_LISTEN) {
27098 -                               const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27099 -                               if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27100 -                                   sk2_rcv_saddr == sk_rcv_saddr)
27101 +                               if (ipv4_rcv_saddr_equal(sk, sk2))
27102                                         break;
27103                         }
27104                 }
27105 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/inet_diag.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/inet_diag.c
27106 --- linux-2.6.35.2/net/ipv4/inet_diag.c 2010-07-07 18:31:59.000000000 +0200
27107 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/inet_diag.c   2010-08-02 17:05:06.000000000 +0200
27108 @@ -33,6 +33,8 @@
27109  #include <linux/stddef.h>
27110  
27111  #include <linux/inet_diag.h>
27112 +#include <linux/vs_network.h>
27113 +#include <linux/vs_inet.h>
27114  
27115  static const struct inet_diag_handler **inet_diag_table;
27116  
27117 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
27118  
27119         r->id.idiag_sport = inet->inet_sport;
27120         r->id.idiag_dport = inet->inet_dport;
27121 -       r->id.idiag_src[0] = inet->inet_rcv_saddr;
27122 -       r->id.idiag_dst[0] = inet->inet_daddr;
27123 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
27124 +               inet->inet_rcv_saddr);
27125 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
27126 +               inet->inet_daddr);
27127  
27128  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27129         if (r->idiag_family == AF_INET6) {
27130 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
27131         r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
27132         r->id.idiag_sport     = tw->tw_sport;
27133         r->id.idiag_dport     = tw->tw_dport;
27134 -       r->id.idiag_src[0]    = tw->tw_rcv_saddr;
27135 -       r->id.idiag_dst[0]    = tw->tw_daddr;
27136 +       r->id.idiag_src[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
27137 +       r->id.idiag_dst[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
27138         r->idiag_state        = tw->tw_substate;
27139         r->idiag_timer        = 3;
27140         r->idiag_expires      = DIV_ROUND_UP(tmo * 1000, HZ);
27141 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
27142         err = -EINVAL;
27143  
27144         if (req->idiag_family == AF_INET) {
27145 +               /* TODO: lback */
27146                 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
27147                                  req->id.idiag_dport, req->id.idiag_src[0],
27148                                  req->id.idiag_sport, req->id.idiag_if);
27149 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
27150                 } else
27151  #endif
27152                 {
27153 +                       /* TODO: lback */
27154                         entry.saddr = &inet->inet_rcv_saddr;
27155                         entry.daddr = &inet->inet_daddr;
27156                 }
27157 @@ -541,6 +547,7 @@ static int inet_twsk_diag_dump(struct in
27158                 } else
27159  #endif
27160                 {
27161 +                       /* TODO: lback */
27162                         entry.saddr = &tw->tw_rcv_saddr;
27163                         entry.daddr = &tw->tw_daddr;
27164                 }
27165 @@ -587,8 +594,8 @@ static int inet_diag_fill_req(struct sk_
27166  
27167         r->id.idiag_sport = inet->inet_sport;
27168         r->id.idiag_dport = ireq->rmt_port;
27169 -       r->id.idiag_src[0] = ireq->loc_addr;
27170 -       r->id.idiag_dst[0] = ireq->rmt_addr;
27171 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
27172 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
27173         r->idiag_expires = jiffies_to_msecs(tmo);
27174         r->idiag_rqueue = 0;
27175         r->idiag_wqueue = 0;
27176 @@ -658,6 +665,7 @@ static int inet_diag_dump_reqs(struct sk
27177                                 continue;
27178  
27179                         if (bc) {
27180 +                               /* TODO: lback */
27181                                 entry.saddr =
27182  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27183                                         (entry.family == AF_INET6) ?
27184 @@ -728,6 +736,8 @@ static int inet_diag_dump(struct sk_buff
27185                         sk_nulls_for_each(sk, node, &ilb->head) {
27186                                 struct inet_sock *inet = inet_sk(sk);
27187  
27188 +                               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27189 +                                       continue;
27190                                 if (num < s_num) {
27191                                         num++;
27192                                         continue;
27193 @@ -794,6 +804,8 @@ skip_listen_ht:
27194                 sk_nulls_for_each(sk, node, &head->chain) {
27195                         struct inet_sock *inet = inet_sk(sk);
27196  
27197 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27198 +                               continue;
27199                         if (num < s_num)
27200                                 goto next_normal;
27201                         if (!(r->idiag_states & (1 << sk->sk_state)))
27202 @@ -818,6 +830,8 @@ next_normal:
27203                         inet_twsk_for_each(tw, node,
27204                                     &head->twchain) {
27205  
27206 +                               if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27207 +                                       continue;
27208                                 if (num < s_num)
27209                                         goto next_dying;
27210                                 if (r->id.idiag_sport != tw->tw_sport &&
27211 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/inet_hashtables.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/inet_hashtables.c
27212 --- linux-2.6.35.2/net/ipv4/inet_hashtables.c   2010-08-02 16:52:59.000000000 +0200
27213 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/inet_hashtables.c     2010-08-02 17:05:06.000000000 +0200
27214 @@ -21,6 +21,7 @@
27215  
27216  #include <net/inet_connection_sock.h>
27217  #include <net/inet_hashtables.h>
27218 +#include <net/route.h>
27219  #include <net/ip.h>
27220  
27221  /*
27222 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
27223                         if (rcv_saddr != daddr)
27224                                 return -1;
27225                         score += 2;
27226 +               } else {
27227 +                       /* block non nx_info ips */
27228 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
27229 +                               daddr, NXA_MASK_BIND))
27230 +                               return -1;
27231                 }
27232                 if (sk->sk_bound_dev_if) {
27233                         if (sk->sk_bound_dev_if != dif)
27234 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
27235   * wildcarded during the search since they can never be otherwise.
27236   */
27237  
27238 -
27239  struct sock *__inet_lookup_listener(struct net *net,
27240                                     struct inet_hashinfo *hashinfo,
27241                                     const __be32 daddr, const unsigned short hnum,
27242 @@ -174,6 +179,7 @@ begin:
27243                         hiscore = score;
27244                 }
27245         }
27246 +
27247         /*
27248          * if the nulls value we got at the end of this lookup is
27249          * not the expected one, we must restart lookup.
27250 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/netfilter/nf_nat_helper.c
27251 --- linux-2.6.35.2/net/ipv4/netfilter/nf_nat_helper.c   2010-07-07 18:31:59.000000000 +0200
27252 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/netfilter/nf_nat_helper.c     2010-08-02 17:05:06.000000000 +0200
27253 @@ -20,6 +20,7 @@
27254  #include <net/route.h>
27255  
27256  #include <linux/netfilter_ipv4.h>
27257 +#include <net/route.h>
27258  #include <net/netfilter/nf_conntrack.h>
27259  #include <net/netfilter/nf_conntrack_helper.h>
27260  #include <net/netfilter/nf_conntrack_ecache.h>
27261 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/netfilter.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/netfilter.c
27262 --- linux-2.6.35.2/net/ipv4/netfilter.c 2010-08-02 16:52:59.000000000 +0200
27263 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/netfilter.c   2010-08-02 17:05:06.000000000 +0200
27264 @@ -5,7 +5,7 @@
27265  #include <linux/ip.h>
27266  #include <linux/skbuff.h>
27267  #include <linux/gfp.h>
27268 -#include <net/route.h>
27269 +// #include <net/route.h>
27270  #include <net/xfrm.h>
27271  #include <net/ip.h>
27272  #include <net/netfilter/nf_queue.h>
27273 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/raw.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/raw.c
27274 --- linux-2.6.35.2/net/ipv4/raw.c       2010-08-02 16:52:59.000000000 +0200
27275 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/raw.c 2010-08-02 18:19:23.000000000 +0200
27276 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
27277  
27278                 if (net_eq(sock_net(sk), net) && inet->inet_num == num  &&
27279                     !(inet->inet_daddr && inet->inet_daddr != raddr)    &&
27280 -                   !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
27281 +                   v4_sock_addr_match(sk->sk_nx_info, inet, laddr)     &&
27282                     !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27283                         goto found; /* gotcha */
27284         }
27285 @@ -381,6 +381,12 @@ static int raw_send_hdrinc(struct sock *
27286                 icmp_out_count(net, ((struct icmphdr *)
27287                         skb_transport_header(skb))->type);
27288  
27289 +       err = -EPERM;
27290 +       if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27291 +               sk->sk_nx_info &&
27292 +               !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27293 +               goto error_free;
27294 +
27295         err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
27296                       rt->u.dst.dev, dst_output);
27297         if (err > 0)
27298 @@ -561,6 +567,13 @@ static int raw_sendmsg(struct kiocb *ioc
27299                 }
27300  
27301                 security_sk_classify_flow(sk, &fl);
27302 +               if (sk->sk_nx_info) {
27303 +                       err = ip_v4_find_src(sock_net(sk),
27304 +                               sk->sk_nx_info, &rt, &fl);
27305 +
27306 +                       if (err)
27307 +                               goto done;
27308 +               }
27309                 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
27310         }
27311         if (err)
27312 @@ -633,17 +646,19 @@ static int raw_bind(struct sock *sk, str
27313  {
27314         struct inet_sock *inet = inet_sk(sk);
27315         struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27316 +       struct nx_v4_sock_addr nsa = { 0 };
27317         int ret = -EINVAL;
27318         int chk_addr_ret;
27319  
27320         if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27321                 goto out;
27322 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27323 +       v4_map_sock_addr(inet, addr, &nsa);
27324 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27325         ret = -EADDRNOTAVAIL;
27326 -       if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27327 +       if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27328             chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27329                 goto out;
27330 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
27331 +       v4_set_sock_addr(inet, &nsa);
27332         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27333                 inet->inet_saddr = 0;  /* Use device */
27334         sk_dst_reset(sk);
27335 @@ -695,7 +710,8 @@ static int raw_recvmsg(struct kiocb *ioc
27336         /* Copy the address. */
27337         if (sin) {
27338                 sin->sin_family = AF_INET;
27339 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27340 +               sin->sin_addr.s_addr =
27341 +                       nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27342                 sin->sin_port = 0;
27343                 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27344         }
27345 @@ -873,7 +889,8 @@ static struct sock *raw_get_first(struct
27346                 struct hlist_node *node;
27347  
27348                 sk_for_each(sk, node, &state->h->ht[state->bucket])
27349 -                       if (sock_net(sk) == seq_file_net(seq))
27350 +                       if ((sock_net(sk) == seq_file_net(seq)) &&
27351 +                               nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27352                                 goto found;
27353         }
27354         sk = NULL;
27355 @@ -889,7 +906,8 @@ static struct sock *raw_get_next(struct 
27356                 sk = sk_next(sk);
27357  try_again:
27358                 ;
27359 -       } while (sk && sock_net(sk) != seq_file_net(seq));
27360 +       } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27361 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27362  
27363         if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27364                 sk = sk_head(&state->h->ht[state->bucket]);
27365 @@ -948,7 +966,10 @@ static void raw_sock_seq_show(struct seq
27366  
27367         seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
27368                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
27369 -               i, src, srcp, dest, destp, sp->sk_state,
27370 +               i,
27371 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27372 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27373 +               sp->sk_state,
27374                 sk_wmem_alloc_get(sp),
27375                 sk_rmem_alloc_get(sp),
27376                 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27377 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/tcp.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/tcp.c
27378 --- linux-2.6.35.2/net/ipv4/tcp.c       2010-08-02 16:52:59.000000000 +0200
27379 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/tcp.c 2010-08-02 17:05:06.000000000 +0200
27380 @@ -266,6 +266,7 @@
27381  #include <linux/crypto.h>
27382  #include <linux/time.h>
27383  #include <linux/slab.h>
27384 +#include <linux/in.h>
27385  
27386  #include <net/icmp.h>
27387  #include <net/tcp.h>
27388 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/tcp_ipv4.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/tcp_ipv4.c
27389 --- linux-2.6.35.2/net/ipv4/tcp_ipv4.c  2010-08-02 16:52:59.000000000 +0200
27390 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/tcp_ipv4.c    2010-08-02 17:05:06.000000000 +0200
27391 @@ -2004,6 +2004,12 @@ static void *listening_get_next(struct s
27392                 req = req->dl_next;
27393                 while (1) {
27394                         while (req) {
27395 +                               vxdprintk(VXD_CBIT(net, 6),
27396 +                                       "sk,req: %p [#%d] (from %d)", req->sk,
27397 +                                       (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27398 +                               if (req->sk &&
27399 +                                       !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27400 +                                       continue;
27401                                 if (req->rsk_ops->family == st->family) {
27402                                         cur = req;
27403                                         goto out;
27404 @@ -2028,6 +2034,10 @@ get_req:
27405         }
27406  get_sk:
27407         sk_nulls_for_each_from(sk, node) {
27408 +               vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27409 +                       sk, sk->sk_nid, nx_current_nid());
27410 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27411 +                       continue;
27412                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
27413                         cur = sk;
27414                         goto out;
27415 @@ -2091,6 +2101,11 @@ static void *established_get_first(struc
27416  
27417                 spin_lock_bh(lock);
27418                 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27419 +                       vxdprintk(VXD_CBIT(net, 6),
27420 +                               "sk,egf: %p [#%d] (from %d)",
27421 +                               sk, sk->sk_nid, nx_current_nid());
27422 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27423 +                               continue;
27424                         if (sk->sk_family != st->family ||
27425                             !net_eq(sock_net(sk), net)) {
27426                                 continue;
27427 @@ -2101,6 +2116,11 @@ static void *established_get_first(struc
27428                 st->state = TCP_SEQ_STATE_TIME_WAIT;
27429                 inet_twsk_for_each(tw, node,
27430                                    &tcp_hashinfo.ehash[st->bucket].twchain) {
27431 +                       vxdprintk(VXD_CBIT(net, 6),
27432 +                               "tw: %p [#%d] (from %d)",
27433 +                               tw, tw->tw_nid, nx_current_nid());
27434 +                       if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27435 +                               continue;
27436                         if (tw->tw_family != st->family ||
27437                             !net_eq(twsk_net(tw), net)) {
27438                                 continue;
27439 @@ -2129,7 +2149,9 @@ static void *established_get_next(struct
27440                 tw = cur;
27441                 tw = tw_next(tw);
27442  get_tw:
27443 -               while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27444 +               while (tw && (tw->tw_family != st->family ||
27445 +                       !net_eq(twsk_net(tw), net) ||
27446 +                       !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27447                         tw = tw_next(tw);
27448                 }
27449                 if (tw) {
27450 @@ -2152,6 +2174,11 @@ get_tw:
27451                 sk = sk_nulls_next(sk);
27452  
27453         sk_nulls_for_each_from(sk, node) {
27454 +               vxdprintk(VXD_CBIT(net, 6),
27455 +                       "sk,egn: %p [#%d] (from %d)",
27456 +                       sk, sk->sk_nid, nx_current_nid());
27457 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27458 +                       continue;
27459                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27460                         goto found;
27461         }
27462 @@ -2303,9 +2330,9 @@ static void get_openreq4(struct sock *sk
27463         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27464                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
27465                 i,
27466 -               ireq->loc_addr,
27467 +               nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27468                 ntohs(inet_sk(sk)->inet_sport),
27469 -               ireq->rmt_addr,
27470 +               nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27471                 ntohs(ireq->rmt_port),
27472                 TCP_SYN_RECV,
27473                 0, 0, /* could print option size, but that is af dependent. */
27474 @@ -2357,7 +2384,10 @@ static void get_tcp4_sock(struct sock *s
27475  
27476         seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
27477                         "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
27478 -               i, src, srcp, dest, destp, sk->sk_state,
27479 +               i,
27480 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27481 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27482 +               sk->sk_state,
27483                 tp->write_seq - tp->snd_una,
27484                 rx_queue,
27485                 timer_active,
27486 @@ -2392,7 +2422,10 @@ static void get_timewait4_sock(struct in
27487  
27488         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27489                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
27490 -               i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
27491 +               i,
27492 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27493 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27494 +               tw->tw_substate, 0, 0,
27495                 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
27496                 atomic_read(&tw->tw_refcnt), tw, len);
27497  }
27498 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/tcp_minisocks.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/tcp_minisocks.c
27499 --- linux-2.6.35.2/net/ipv4/tcp_minisocks.c     2010-08-02 16:52:59.000000000 +0200
27500 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/tcp_minisocks.c       2010-08-02 17:05:06.000000000 +0200
27501 @@ -23,6 +23,9 @@
27502  #include <linux/slab.h>
27503  #include <linux/sysctl.h>
27504  #include <linux/workqueue.h>
27505 +#include <linux/vs_limit.h>
27506 +#include <linux/vs_socket.h>
27507 +#include <linux/vs_context.h>
27508  #include <net/tcp.h>
27509  #include <net/inet_common.h>
27510  #include <net/xfrm.h>
27511 @@ -290,6 +293,11 @@ void tcp_time_wait(struct sock *sk, int 
27512                 tcptw->tw_ts_recent     = tp->rx_opt.ts_recent;
27513                 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27514  
27515 +               tw->tw_xid              = sk->sk_xid;
27516 +               tw->tw_vx_info          = NULL;
27517 +               tw->tw_nid              = sk->sk_nid;
27518 +               tw->tw_nx_info          = NULL;
27519 +
27520  #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27521                 if (tw->tw_family == PF_INET6) {
27522                         struct ipv6_pinfo *np = inet6_sk(sk);
27523 diff -NurpP --minimal linux-2.6.35.2/net/ipv4/udp.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/udp.c
27524 --- linux-2.6.35.2/net/ipv4/udp.c       2010-08-02 16:52:59.000000000 +0200
27525 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv4/udp.c 2010-08-02 17:05:06.000000000 +0200
27526 @@ -296,14 +296,7 @@ fail:
27527  }
27528  EXPORT_SYMBOL(udp_lib_get_port);
27529  
27530 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27531 -{
27532 -       struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27533 -
27534 -       return  (!ipv6_only_sock(sk2)  &&
27535 -                (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
27536 -                  inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
27537 -}
27538 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27539  
27540  static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
27541                                        unsigned int port)
27542 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
27543                         if (inet->inet_rcv_saddr != daddr)
27544                                 return -1;
27545                         score += 2;
27546 +               } else {
27547 +                       /* block non nx_info ips */
27548 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
27549 +                               daddr, NXA_MASK_BIND))
27550 +                               return -1;
27551                 }
27552                 if (inet->inet_daddr) {
27553                         if (inet->inet_daddr != saddr)
27554 @@ -441,6 +439,7 @@ exact_match:
27555         return result;
27556  }
27557  
27558 +
27559  /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27560   * harder than this. -DaveM
27561   */
27562 @@ -486,6 +485,11 @@ begin:
27563         sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27564                 score = compute_score(sk, net, saddr, hnum, sport,
27565                                       daddr, dport, dif);
27566 +               /* FIXME: disabled?
27567 +               if (score == 9) {
27568 +                       result = sk;
27569 +                       break;
27570 +               } else */
27571                 if (score > badness) {
27572                         result = sk;
27573                         badness = score;
27574 @@ -499,6 +503,7 @@ begin:
27575         if (get_nulls_value(node) != slot)
27576                 goto begin;
27577  
27578 +
27579         if (result) {
27580                 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
27581                         result = NULL;
27582 @@ -508,6 +513,7 @@ begin:
27583                         goto begin;
27584                 }
27585         }
27586 +
27587         rcu_read_unlock();
27588         return result;
27589  }
27590 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
27591                     udp_sk(s)->udp_port_hash != hnum ||
27592                     (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
27593                     (inet->inet_dport != rmt_port && inet->inet_dport) ||
27594 -                   (inet->inet_rcv_saddr &&
27595 -                    inet->inet_rcv_saddr != loc_addr) ||
27596 +                   !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27597                     ipv6_only_sock(s) ||
27598                     (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27599                         continue;
27600 @@ -900,8 +905,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27601                                                { .sport = inet->inet_sport,
27602                                                  .dport = dport } } };
27603                 struct net *net = sock_net(sk);
27604 +               struct nx_info *nxi = sk->sk_nx_info;
27605  
27606                 security_sk_classify_flow(sk, &fl);
27607 +               err = ip_v4_find_src(net, nxi, &rt, &fl);
27608 +               if (err)
27609 +                       goto out;
27610 +
27611                 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27612                 if (err) {
27613                         if (err == -ENETUNREACH)
27614 @@ -1183,7 +1193,8 @@ try_again:
27615         if (sin) {
27616                 sin->sin_family = AF_INET;
27617                 sin->sin_port = udp_hdr(skb)->source;
27618 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27619 +               sin->sin_addr.s_addr = nx_map_sock_lback(
27620 +                       skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27621                 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27622         }
27623         if (inet->cmsg_flags)
27624 @@ -1879,6 +1890,8 @@ static struct sock *udp_get_first(struct
27625                 sk_nulls_for_each(sk, node, &hslot->head) {
27626                         if (!net_eq(sock_net(sk), net))
27627                                 continue;
27628 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27629 +                               continue;
27630                         if (sk->sk_family == state->family)
27631                                 goto found;
27632                 }
27633 @@ -1896,7 +1909,9 @@ static struct sock *udp_get_next(struct 
27634  
27635         do {
27636                 sk = sk_nulls_next(sk);
27637 -       } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27638 +       } while (sk && (!net_eq(sock_net(sk), net) ||
27639 +               sk->sk_family != state->family ||
27640 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27641  
27642         if (!sk) {
27643                 if (state->bucket <= state->udp_table->mask)
27644 @@ -2003,7 +2018,10 @@ static void udp4_format_sock(struct sock
27645  
27646         seq_printf(f, "%5d: %08X:%04X %08X:%04X"
27647                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27648 -               bucket, src, srcp, dest, destp, sp->sk_state,
27649 +               bucket,
27650 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27651 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27652 +               sp->sk_state,
27653                 sk_wmem_alloc_get(sp),
27654                 sk_rmem_alloc_get(sp),
27655                 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27656 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/addrconf.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/addrconf.c
27657 --- linux-2.6.35.2/net/ipv6/addrconf.c  2010-08-02 16:52:59.000000000 +0200
27658 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/addrconf.c    2010-08-02 17:05:06.000000000 +0200
27659 @@ -87,6 +87,8 @@
27660  
27661  #include <linux/proc_fs.h>
27662  #include <linux/seq_file.h>
27663 +#include <linux/vs_network.h>
27664 +#include <linux/vs_inet6.h>
27665  
27666  /* Set to 3 to get tracing... */
27667  #define ACONF_DEBUG 2
27668 @@ -1117,7 +1119,7 @@ out:
27669  
27670  int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27671                        const struct in6_addr *daddr, unsigned int prefs,
27672 -                      struct in6_addr *saddr)
27673 +                      struct in6_addr *saddr, struct nx_info *nxi)
27674  {
27675         struct ipv6_saddr_score scores[2],
27676                                 *score = &scores[0], *hiscore = &scores[1];
27677 @@ -1189,6 +1191,8 @@ int ipv6_dev_get_saddr(struct net *net, 
27678                                                dev->name);
27679                                 continue;
27680                         }
27681 +                       if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27682 +                               continue;
27683  
27684                         score->rule = -1;
27685                         bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27686 @@ -3074,7 +3078,10 @@ static void if6_seq_stop(struct seq_file
27687  static int if6_seq_show(struct seq_file *seq, void *v)
27688  {
27689         struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27690 -       seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27691 +
27692 +       if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27693 +           v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27694 +               seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27695                    &ifp->addr,
27696                    ifp->idev->dev->ifindex,
27697                    ifp->prefix_len,
27698 @@ -3578,6 +3585,11 @@ static int in6_dump_addrs(struct inet6_d
27699         struct ifacaddr6 *ifaca;
27700         int err = 1;
27701         int ip_idx = *p_ip_idx;
27702 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27703 +
27704 +       /* disable ipv6 on non v6 guests */
27705 +       if (nxi && !nx_info_has_v6(nxi))
27706 +               return skb->len;
27707  
27708         read_lock_bh(&idev->lock);
27709         switch (type) {
27710 @@ -3588,6 +3600,8 @@ static int in6_dump_addrs(struct inet6_d
27711                 list_for_each_entry(ifa, &idev->addr_list, if_list) {
27712                         if (++ip_idx < s_ip_idx)
27713                                 continue;
27714 +                               if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27715 +                                       continue;
27716                         err = inet6_fill_ifaddr(skb, ifa,
27717                                                 NETLINK_CB(cb->skb).pid,
27718                                                 cb->nlh->nlmsg_seq,
27719 @@ -3604,6 +3618,8 @@ static int in6_dump_addrs(struct inet6_d
27720                      ifmca = ifmca->next, ip_idx++) {
27721                         if (ip_idx < s_ip_idx)
27722                                 continue;
27723 +                               if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27724 +                                       continue;
27725                         err = inet6_fill_ifmcaddr(skb, ifmca,
27726                                                   NETLINK_CB(cb->skb).pid,
27727                                                   cb->nlh->nlmsg_seq,
27728 @@ -3619,6 +3635,8 @@ static int in6_dump_addrs(struct inet6_d
27729                      ifaca = ifaca->aca_next, ip_idx++) {
27730                         if (ip_idx < s_ip_idx)
27731                                 continue;
27732 +                               if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27733 +                                       continue;
27734                         err = inet6_fill_ifacaddr(skb, ifaca,
27735                                                   NETLINK_CB(cb->skb).pid,
27736                                                   cb->nlh->nlmsg_seq,
27737 @@ -3950,6 +3968,11 @@ static int inet6_dump_ifinfo(struct sk_b
27738         struct inet6_dev *idev;
27739         struct hlist_head *head;
27740         struct hlist_node *node;
27741 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27742 +
27743 +       /* FIXME: maybe disable ipv6 on non v6 guests?
27744 +       if (skb->sk && skb->sk->sk_vx_info)
27745 +               return skb->len; */
27746  
27747         s_h = cb->args[0];
27748         s_idx = cb->args[1];
27749 @@ -3961,6 +3984,8 @@ static int inet6_dump_ifinfo(struct sk_b
27750                 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
27751                         if (idx < s_idx)
27752                                 goto cont;
27753 +                       if (!v6_dev_in_nx_info(dev, nxi))
27754 +                               goto cont;
27755                         idev = __in6_dev_get(dev);
27756                         if (!idev)
27757                                 goto cont;
27758 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/af_inet6.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/af_inet6.c
27759 --- linux-2.6.35.2/net/ipv6/af_inet6.c  2010-08-02 16:52:59.000000000 +0200
27760 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/af_inet6.c    2010-08-02 17:05:06.000000000 +0200
27761 @@ -42,6 +42,8 @@
27762  #include <linux/netdevice.h>
27763  #include <linux/icmpv6.h>
27764  #include <linux/netfilter_ipv6.h>
27765 +#include <linux/vs_inet.h>
27766 +#include <linux/vs_inet6.h>
27767  
27768  #include <net/ip.h>
27769  #include <net/ipv6.h>
27770 @@ -160,9 +162,12 @@ lookup_protocol:
27771         }
27772  
27773         err = -EPERM;
27774 +       if ((protocol == IPPROTO_ICMPV6) &&
27775 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
27776 +               goto override;
27777         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
27778                 goto out_rcu_unlock;
27779 -
27780 +override:
27781         sock->ops = answer->ops;
27782         answer_prot = answer->prot;
27783         answer_no_check = answer->no_check;
27784 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
27785         struct inet_sock *inet = inet_sk(sk);
27786         struct ipv6_pinfo *np = inet6_sk(sk);
27787         struct net *net = sock_net(sk);
27788 +       struct nx_v6_sock_addr nsa;
27789         __be32 v4addr = 0;
27790         unsigned short snum;
27791         int addr_type = 0;
27792 @@ -272,6 +278,11 @@ int inet6_bind(struct socket *sock, stru
27793  
27794         if (addr_len < SIN6_LEN_RFC2133)
27795                 return -EINVAL;
27796 +
27797 +       err = v6_map_sock_addr(inet, addr, &nsa);
27798 +       if (err)
27799 +               return err;
27800 +
27801         addr_type = ipv6_addr_type(&addr->sin6_addr);
27802         if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27803                 return -EINVAL;
27804 @@ -303,6 +314,7 @@ int inet6_bind(struct socket *sock, stru
27805                 /* Reproduce AF_INET checks to make the bindings consitant */
27806                 v4addr = addr->sin6_addr.s6_addr32[3];
27807                 chk_addr_ret = inet_addr_type(net, v4addr);
27808 +
27809                 if (!sysctl_ip_nonlocal_bind &&
27810                     !(inet->freebind || inet->transparent) &&
27811                     v4addr != htonl(INADDR_ANY) &&
27812 @@ -312,6 +324,10 @@ int inet6_bind(struct socket *sock, stru
27813                         err = -EADDRNOTAVAIL;
27814                         goto out;
27815                 }
27816 +               if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27817 +                       err = -EADDRNOTAVAIL;
27818 +                       goto out;
27819 +               }
27820         } else {
27821                 if (addr_type != IPV6_ADDR_ANY) {
27822                         struct net_device *dev = NULL;
27823 @@ -338,6 +354,11 @@ int inet6_bind(struct socket *sock, stru
27824                                 }
27825                         }
27826  
27827 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27828 +                               err = -EADDRNOTAVAIL;
27829 +                               goto out;
27830 +                       }
27831 +
27832                         /* ipv4 addr of the socket is invalid.  Only the
27833                          * unspecified and mapped address have a v4 equivalent.
27834                          */
27835 @@ -353,6 +374,9 @@ int inet6_bind(struct socket *sock, stru
27836                 }
27837         }
27838  
27839 +       /* what's that for? */
27840 +       v6_set_sock_addr(inet, &nsa);
27841 +
27842         inet->inet_rcv_saddr = v4addr;
27843         inet->inet_saddr = v4addr;
27844  
27845 @@ -454,9 +478,11 @@ int inet6_getname(struct socket *sock, s
27846                         return -ENOTCONN;
27847                 sin->sin6_port = inet->inet_dport;
27848                 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27849 +               /* FIXME: remap lback? */
27850                 if (np->sndflow)
27851                         sin->sin6_flowinfo = np->flow_label;
27852         } else {
27853 +               /* FIXME: remap lback? */
27854                 if (ipv6_addr_any(&np->rcv_saddr))
27855                         ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27856                 else
27857 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/fib6_rules.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/fib6_rules.c
27858 --- linux-2.6.35.2/net/ipv6/fib6_rules.c        2010-08-02 16:52:59.000000000 +0200
27859 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/fib6_rules.c  2010-08-02 17:05:06.000000000 +0200
27860 @@ -89,7 +89,7 @@ static int fib6_rule_action(struct fib_r
27861                                                ip6_dst_idev(&rt->u.dst)->dev,
27862                                                &flp->fl6_dst,
27863                                                rt6_flags2srcprefs(flags),
27864 -                                              &saddr))
27865 +                                              &saddr, NULL))
27866                                 goto again;
27867                         if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27868                                                r->src.plen))
27869 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/inet6_hashtables.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/inet6_hashtables.c
27870 --- linux-2.6.35.2/net/ipv6/inet6_hashtables.c  2010-02-25 11:52:10.000000000 +0100
27871 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/inet6_hashtables.c    2010-08-02 17:05:06.000000000 +0200
27872 @@ -16,6 +16,7 @@
27873  
27874  #include <linux/module.h>
27875  #include <linux/random.h>
27876 +#include <linux/vs_inet6.h>
27877  
27878  #include <net/inet_connection_sock.h>
27879  #include <net/inet_hashtables.h>
27880 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
27881         unsigned int slot = hash & hashinfo->ehash_mask;
27882         struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
27883  
27884 -
27885         rcu_read_lock();
27886  begin:
27887         sk_nulls_for_each_rcu(sk, node, &head->chain) {
27888 @@ -94,7 +94,7 @@ begin:
27889                                 sock_put(sk);
27890                                 goto begin;
27891                         }
27892 -               goto out;
27893 +                       goto out;
27894                 }
27895         }
27896         if (get_nulls_value(node) != slot)
27897 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
27898                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27899                                 return -1;
27900                         score++;
27901 +               } else {
27902 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27903 +                               return -1;
27904                 }
27905                 if (sk->sk_bound_dev_if) {
27906                         if (sk->sk_bound_dev_if != dif)
27907 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/ip6_output.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/ip6_output.c
27908 --- linux-2.6.35.2/net/ipv6/ip6_output.c        2010-08-02 16:52:59.000000000 +0200
27909 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/ip6_output.c  2010-08-02 17:05:06.000000000 +0200
27910 @@ -930,7 +930,7 @@ static int ip6_dst_lookup_tail(struct so
27911                 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
27912                                          &fl->fl6_dst,
27913                                          sk ? inet6_sk(sk)->srcprefs : 0,
27914 -                                        &fl->fl6_src);
27915 +                                        &fl->fl6_src, sk->sk_nx_info);
27916                 if (err)
27917                         goto out_err_release;
27918         }
27919 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/Kconfig linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/Kconfig
27920 --- linux-2.6.35.2/net/ipv6/Kconfig     2010-08-02 16:52:59.000000000 +0200
27921 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/Kconfig       2010-08-02 17:05:06.000000000 +0200
27922 @@ -4,8 +4,8 @@
27923  
27924  #   IPv6 as module will cause a CRASH if you try to unload it
27925  menuconfig IPV6
27926 -       tristate "The IPv6 protocol"
27927 -       default m
27928 +       bool "The IPv6 protocol"
27929 +       default n
27930         ---help---
27931           This is complemental support for the IP version 6.
27932           You will still be able to do traditional IPv4 networking as well.
27933 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/ndisc.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/ndisc.c
27934 --- linux-2.6.35.2/net/ipv6/ndisc.c     2010-08-02 16:53:00.000000000 +0200
27935 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/ndisc.c       2010-08-02 17:05:06.000000000 +0200
27936 @@ -591,7 +591,7 @@ static void ndisc_send_na(struct net_dev
27937         } else {
27938                 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27939                                        inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27940 -                                      &tmpaddr))
27941 +                                      &tmpaddr, NULL /* FIXME: ? */ ))
27942                         return;
27943                 src_addr = &tmpaddr;
27944         }
27945 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/raw.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/raw.c
27946 --- linux-2.6.35.2/net/ipv6/raw.c       2010-08-02 16:53:00.000000000 +0200
27947 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/raw.c 2010-08-02 17:05:06.000000000 +0200
27948 @@ -30,6 +30,7 @@
27949  #include <linux/icmpv6.h>
27950  #include <linux/netfilter.h>
27951  #include <linux/netfilter_ipv6.h>
27952 +#include <linux/vs_inet6.h>
27953  #include <linux/skbuff.h>
27954  #include <asm/uaccess.h>
27955  #include <asm/ioctls.h>
27956 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
27957                                 goto out_unlock;
27958                 }
27959  
27960 +               if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27961 +                       err = -EADDRNOTAVAIL;
27962 +                       if (dev)
27963 +                               dev_put(dev);
27964 +                       goto out;
27965 +               }
27966 +
27967                 /* ipv4 addr of the socket is invalid.  Only the
27968                  * unspecified and mapped address have a v4 equivalent.
27969                  */
27970 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/route.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/route.c
27971 --- linux-2.6.35.2/net/ipv6/route.c     2010-08-02 16:53:00.000000000 +0200
27972 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/route.c       2010-08-02 17:05:06.000000000 +0200
27973 @@ -2255,7 +2255,8 @@ static int rt6_fill_node(struct net *net
27974                 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
27975                 struct in6_addr saddr_buf;
27976                 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27977 -                                      dst, 0, &saddr_buf) == 0)
27978 +                       dst, 0, &saddr_buf,
27979 +                       (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27980                         NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27981         }
27982  
27983 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/tcp_ipv6.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/tcp_ipv6.c
27984 --- linux-2.6.35.2/net/ipv6/tcp_ipv6.c  2010-08-02 16:53:00.000000000 +0200
27985 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/tcp_ipv6.c    2010-08-02 17:05:06.000000000 +0200
27986 @@ -69,6 +69,7 @@
27987  
27988  #include <linux/crypto.h>
27989  #include <linux/scatterlist.h>
27990 +#include <linux/vs_inet6.h>
27991  
27992  static void    tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27993  static void    tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27994 @@ -160,8 +161,15 @@ static int tcp_v6_connect(struct sock *s
27995          *      connect() to INADDR_ANY means loopback (BSD'ism).
27996          */
27997  
27998 -       if(ipv6_addr_any(&usin->sin6_addr))
27999 -               usin->sin6_addr.s6_addr[15] = 0x1;
28000 +       if(ipv6_addr_any(&usin->sin6_addr)) {
28001 +               struct nx_info *nxi =  sk->sk_nx_info;
28002 +
28003 +               if (nxi && nx_info_has_v6(nxi))
28004 +                       /* FIXME: remap lback? */
28005 +                       usin->sin6_addr = nxi->v6.ip;
28006 +               else
28007 +                       usin->sin6_addr.s6_addr[15] = 0x1;
28008 +       }
28009  
28010         addr_type = ipv6_addr_type(&usin->sin6_addr);
28011  
28012 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/udp.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/udp.c
28013 --- linux-2.6.35.2/net/ipv6/udp.c       2010-08-02 16:53:00.000000000 +0200
28014 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/udp.c 2010-08-02 17:05:06.000000000 +0200
28015 @@ -48,13 +48,14 @@
28016  
28017  #include <linux/proc_fs.h>
28018  #include <linux/seq_file.h>
28019 +#include <linux/vs_inet6.h>
28020  #include "udp_impl.h"
28021  
28022  int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
28023  {
28024         const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
28025         const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
28026 -       __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28027 +       __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28028         __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28029         int sk_ipv6only = ipv6_only_sock(sk);
28030         int sk2_ipv6only = inet_v6_ipv6only(sk2);
28031 @@ -62,24 +63,49 @@ int ipv6_rcv_saddr_equal(const struct so
28032         int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
28033  
28034         /* if both are mapped, treat as IPv4 */
28035 -       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
28036 -               return (!sk2_ipv6only &&
28037 -                       (!sk1_rcv_saddr || !sk2_rcv_saddr ||
28038 -                         sk1_rcv_saddr == sk2_rcv_saddr));
28039 +       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
28040 +               if (!sk2_ipv6only &&
28041 +                       (!sk_rcv_saddr || !sk2_rcv_saddr ||
28042 +                         sk_rcv_saddr == sk2_rcv_saddr))
28043 +                       goto vs_v4;
28044 +               else
28045 +                       return 0;
28046 +       }
28047  
28048         if (addr_type2 == IPV6_ADDR_ANY &&
28049             !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
28050 -               return 1;
28051 +               goto vs;
28052  
28053         if (addr_type == IPV6_ADDR_ANY &&
28054             !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
28055 -               return 1;
28056 +               goto vs;
28057  
28058         if (sk2_rcv_saddr6 &&
28059             ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
28060 -               return 1;
28061 +               goto vs;
28062  
28063         return 0;
28064 +
28065 +vs_v4:
28066 +       if (!sk_rcv_saddr && !sk2_rcv_saddr)
28067 +               return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28068 +       if (!sk2_rcv_saddr)
28069 +               return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
28070 +       if (!sk_rcv_saddr)
28071 +               return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
28072 +       return 1;
28073 +vs:
28074 +       if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
28075 +               return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28076 +       else if (addr_type2 == IPV6_ADDR_ANY)
28077 +               return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
28078 +       else if (addr_type == IPV6_ADDR_ANY) {
28079 +               if (addr_type2 == IPV6_ADDR_MAPPED)
28080 +                       return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28081 +               else
28082 +                       return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
28083 +       }
28084 +       return 1;
28085  }
28086  
28087  static unsigned int udp6_portaddr_hash(struct net *net,
28088 @@ -134,6 +160,10 @@ static inline int compute_score(struct s
28089                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28090                                 return -1;
28091                         score++;
28092 +               } else {
28093 +                       /* block non nx_info ips */
28094 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28095 +                               return -1;
28096                 }
28097                 if (!ipv6_addr_any(&np->daddr)) {
28098                         if (!ipv6_addr_equal(&np->daddr, saddr))
28099 diff -NurpP --minimal linux-2.6.35.2/net/ipv6/xfrm6_policy.c linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/xfrm6_policy.c
28100 --- linux-2.6.35.2/net/ipv6/xfrm6_policy.c      2010-08-02 16:53:00.000000000 +0200
28101 +++ linux-2.6.35.2-vs2.3.0.36.31/net/ipv6/xfrm6_policy.c        2010-08-02 17:05:06.000000000 +0200
28102 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
28103         dev = ip6_dst_idev(dst)->dev;
28104         ipv6_dev_get_saddr(dev_net(dev), dev,
28105                            (struct in6_addr *)&daddr->a6, 0,
28106 -                          (struct in6_addr *)&saddr->a6);
28107 +                          (struct in6_addr *)&saddr->a6, NULL);
28108         dst_release(dst);
28109         return 0;
28110  }
28111 diff -NurpP --minimal linux-2.6.35.2/net/netlink/af_netlink.c linux-2.6.35.2-vs2.3.0.36.31/net/netlink/af_netlink.c
28112 --- linux-2.6.35.2/net/netlink/af_netlink.c     2010-08-02 16:53:01.000000000 +0200
28113 +++ linux-2.6.35.2-vs2.3.0.36.31/net/netlink/af_netlink.c       2010-08-02 17:05:06.000000000 +0200
28114 @@ -55,6 +55,9 @@
28115  #include <linux/types.h>
28116  #include <linux/audit.h>
28117  #include <linux/mutex.h>
28118 +#include <linux/vs_context.h>
28119 +#include <linux/vs_network.h>
28120 +#include <linux/vs_limit.h>
28121  
28122  #include <net/net_namespace.h>
28123  #include <net/sock.h>
28124 @@ -1936,6 +1939,8 @@ static struct sock *netlink_seq_socket_i
28125                         sk_for_each(s, node, &hash->table[j]) {
28126                                 if (sock_net(s) != seq_file_net(seq))
28127                                         continue;
28128 +                               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28129 +                                       continue;
28130                                 if (off == pos) {
28131                                         iter->link = i;
28132                                         iter->hash_idx = j;
28133 @@ -1970,7 +1975,8 @@ static void *netlink_seq_next(struct seq
28134         s = v;
28135         do {
28136                 s = sk_next(s);
28137 -       } while (s && sock_net(s) != seq_file_net(seq));
28138 +       } while (s && (sock_net(s) != seq_file_net(seq) ||
28139 +               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28140         if (s)
28141                 return s;
28142  
28143 @@ -1982,7 +1988,8 @@ static void *netlink_seq_next(struct seq
28144  
28145                 for (; j <= hash->mask; j++) {
28146                         s = sk_head(&hash->table[j]);
28147 -                       while (s && sock_net(s) != seq_file_net(seq))
28148 +                       while (s && (sock_net(s) != seq_file_net(seq) ||
28149 +                               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28150                                 s = sk_next(s);
28151                         if (s) {
28152                                 iter->link = i;
28153 diff -NurpP --minimal linux-2.6.35.2/net/sctp/ipv6.c linux-2.6.35.2-vs2.3.0.36.31/net/sctp/ipv6.c
28154 --- linux-2.6.35.2/net/sctp/ipv6.c      2010-08-02 16:53:01.000000000 +0200
28155 +++ linux-2.6.35.2-vs2.3.0.36.31/net/sctp/ipv6.c        2010-08-02 17:05:06.000000000 +0200
28156 @@ -304,7 +304,8 @@ static void sctp_v6_get_saddr(struct sct
28157                                    dst ? ip6_dst_idev(dst)->dev : NULL,
28158                                    &daddr->v6.sin6_addr,
28159                                    inet6_sk(&sk->inet.sk)->srcprefs,
28160 -                                  &saddr->v6.sin6_addr);
28161 +                                  &saddr->v6.sin6_addr,
28162 +                                  asoc->base.sk->sk_nx_info);
28163                 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
28164                                   &saddr->v6.sin6_addr);
28165                 return;
28166 diff -NurpP --minimal linux-2.6.35.2/net/socket.c linux-2.6.35.2-vs2.3.0.36.31/net/socket.c
28167 --- linux-2.6.35.2/net/socket.c 2010-08-02 16:53:02.000000000 +0200
28168 +++ linux-2.6.35.2-vs2.3.0.36.31/net/socket.c   2010-08-02 17:05:06.000000000 +0200
28169 @@ -98,6 +98,10 @@
28170  
28171  #include <net/sock.h>
28172  #include <linux/netfilter.h>
28173 +#include <linux/vs_base.h>
28174 +#include <linux/vs_socket.h>
28175 +#include <linux/vs_inet.h>
28176 +#include <linux/vs_inet6.h>
28177  
28178  #include <linux/if_tun.h>
28179  #include <linux/ipv6_route.h>
28180 @@ -557,7 +561,7 @@ static inline int __sock_sendmsg(struct 
28181                                  struct msghdr *msg, size_t size)
28182  {
28183         struct sock_iocb *si = kiocb_to_siocb(iocb);
28184 -       int err;
28185 +       int err, len;
28186  
28187         sock_update_classid(sock->sk);
28188  
28189 @@ -570,7 +574,22 @@ static inline int __sock_sendmsg(struct 
28190         if (err)
28191                 return err;
28192  
28193 -       return sock->ops->sendmsg(iocb, sock, msg, size);
28194 +       len = sock->ops->sendmsg(iocb, sock, msg, size);
28195 +       if (sock->sk) {
28196 +               if (len == size)
28197 +                       vx_sock_send(sock->sk, size);
28198 +               else
28199 +                       vx_sock_fail(sock->sk, size);
28200 +       }
28201 +       vxdprintk(VXD_CBIT(net, 7),
28202 +               "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28203 +               sock, sock->sk,
28204 +               (sock->sk)?sock->sk->sk_nx_info:0,
28205 +               (sock->sk)?sock->sk->sk_vx_info:0,
28206 +               (sock->sk)?sock->sk->sk_xid:0,
28207 +               (sock->sk)?sock->sk->sk_nid:0,
28208 +               (unsigned int)size, len);
28209 +       return len;
28210  }
28211  
28212  int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
28213 @@ -686,6 +705,7 @@ static inline int __sock_recvmsg_nosec(s
28214                                        struct msghdr *msg, size_t size, int flags)
28215  {
28216         struct sock_iocb *si = kiocb_to_siocb(iocb);
28217 +       int len;
28218  
28219         sock_update_classid(sock->sk);
28220  
28221 @@ -695,7 +715,18 @@ static inline int __sock_recvmsg_nosec(s
28222         si->size = size;
28223         si->flags = flags;
28224  
28225 -       return sock->ops->recvmsg(iocb, sock, msg, size, flags);
28226 +       len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
28227 +       if ((len >= 0) && sock->sk)
28228 +               vx_sock_recv(sock->sk, len);
28229 +       vxdprintk(VXD_CBIT(net, 7),
28230 +               "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28231 +               sock, sock->sk,
28232 +               (sock->sk)?sock->sk->sk_nx_info:0,
28233 +               (sock->sk)?sock->sk->sk_vx_info:0,
28234 +               (sock->sk)?sock->sk->sk_xid:0,
28235 +               (sock->sk)?sock->sk->sk_nid:0,
28236 +               (unsigned int)size, len);
28237 +       return len;
28238  }
28239  
28240  static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
28241 @@ -1163,6 +1194,13 @@ static int __sock_create(struct net *net
28242         if (type < 0 || type >= SOCK_MAX)
28243                 return -EINVAL;
28244  
28245 +       if (!nx_check(0, VS_ADMIN)) {
28246 +               if (family == PF_INET && !current_nx_info_has_v4())
28247 +                       return -EAFNOSUPPORT;
28248 +               if (family == PF_INET6 && !current_nx_info_has_v6())
28249 +                       return -EAFNOSUPPORT;
28250 +       }
28251 +
28252         /* Compatibility.
28253  
28254            This uglymoron is moved from INET layer to here to avoid
28255 @@ -1295,6 +1333,7 @@ SYSCALL_DEFINE3(socket, int, family, int
28256         if (retval < 0)
28257                 goto out;
28258  
28259 +       set_bit(SOCK_USER_SOCKET, &sock->flags);
28260         retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
28261         if (retval < 0)
28262                 goto out_release;
28263 @@ -1336,10 +1375,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
28264         err = sock_create(family, type, protocol, &sock1);
28265         if (err < 0)
28266                 goto out;
28267 +       set_bit(SOCK_USER_SOCKET, &sock1->flags);
28268  
28269         err = sock_create(family, type, protocol, &sock2);
28270         if (err < 0)
28271                 goto out_release_1;
28272 +       set_bit(SOCK_USER_SOCKET, &sock2->flags);
28273  
28274         err = sock1->ops->socketpair(sock1, sock2);
28275         if (err < 0)
28276 diff -NurpP --minimal linux-2.6.35.2/net/sunrpc/auth.c linux-2.6.35.2-vs2.3.0.36.31/net/sunrpc/auth.c
28277 --- linux-2.6.35.2/net/sunrpc/auth.c    2010-08-02 16:53:02.000000000 +0200
28278 +++ linux-2.6.35.2-vs2.3.0.36.31/net/sunrpc/auth.c      2010-08-02 17:05:06.000000000 +0200
28279 @@ -14,6 +14,7 @@
28280  #include <linux/hash.h>
28281  #include <linux/sunrpc/clnt.h>
28282  #include <linux/spinlock.h>
28283 +#include <linux/vs_tag.h>
28284  
28285  #ifdef RPC_DEBUG
28286  # define RPCDBG_FACILITY       RPCDBG_AUTH
28287 @@ -366,6 +367,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
28288         memset(&acred, 0, sizeof(acred));
28289         acred.uid = cred->fsuid;
28290         acred.gid = cred->fsgid;
28291 +       acred.tag = dx_current_tag();
28292         acred.group_info = get_group_info(((struct cred *)cred)->group_info);
28293  
28294         ret = auth->au_ops->lookup_cred(auth, &acred, flags);
28295 @@ -406,6 +408,7 @@ rpcauth_bind_root_cred(struct rpc_task *
28296         struct auth_cred acred = {
28297                 .uid = 0,
28298                 .gid = 0,
28299 +               .tag = dx_current_tag(),
28300         };
28301         struct rpc_cred *ret;
28302  
28303 diff -NurpP --minimal linux-2.6.35.2/net/sunrpc/auth_unix.c linux-2.6.35.2-vs2.3.0.36.31/net/sunrpc/auth_unix.c
28304 --- linux-2.6.35.2/net/sunrpc/auth_unix.c       2010-07-07 18:32:01.000000000 +0200
28305 +++ linux-2.6.35.2-vs2.3.0.36.31/net/sunrpc/auth_unix.c 2010-08-02 17:05:06.000000000 +0200
28306 @@ -12,12 +12,14 @@
28307  #include <linux/module.h>
28308  #include <linux/sunrpc/clnt.h>
28309  #include <linux/sunrpc/auth.h>
28310 +#include <linux/vs_tag.h>
28311  
28312  #define NFS_NGROUPS    16
28313  
28314  struct unx_cred {
28315         struct rpc_cred         uc_base;
28316         gid_t                   uc_gid;
28317 +       tag_t                   uc_tag;
28318         gid_t                   uc_gids[NFS_NGROUPS];
28319  };
28320  #define uc_uid                 uc_base.cr_uid
28321 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
28322                 groups = NFS_NGROUPS;
28323  
28324         cred->uc_gid = acred->gid;
28325 +       cred->uc_tag = acred->tag;
28326         for (i = 0; i < groups; i++)
28327                 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28328         if (i < NFS_NGROUPS)
28329 @@ -120,7 +123,9 @@ unx_match(struct auth_cred *acred, struc
28330         unsigned int i;
28331  
28332  
28333 -       if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28334 +       if (cred->uc_uid != acred->uid ||
28335 +               cred->uc_gid != acred->gid ||
28336 +               cred->uc_tag != acred->tag)
28337                 return 0;
28338  
28339         if (acred->group_info != NULL)
28340 @@ -143,7 +148,7 @@ unx_marshal(struct rpc_task *task, __be3
28341         struct rpc_clnt *clnt = task->tk_client;
28342         struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
28343         __be32          *base, *hold;
28344 -       int             i;
28345 +       int             i, tag;
28346  
28347         *p++ = htonl(RPC_AUTH_UNIX);
28348         base = p++;
28349 @@ -153,9 +158,12 @@ unx_marshal(struct rpc_task *task, __be3
28350          * Copy the UTS nodename captured when the client was created.
28351          */
28352         p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28353 +       tag = task->tk_client->cl_tag;
28354  
28355 -       *p++ = htonl((u32) cred->uc_uid);
28356 -       *p++ = htonl((u32) cred->uc_gid);
28357 +       *p++ = htonl((u32) TAGINO_UID(tag,
28358 +               cred->uc_uid, cred->uc_tag));
28359 +       *p++ = htonl((u32) TAGINO_GID(tag,
28360 +               cred->uc_gid, cred->uc_tag));
28361         hold = p++;
28362         for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28363                 *p++ = htonl((u32) cred->uc_gids[i]);
28364 diff -NurpP --minimal linux-2.6.35.2/net/sunrpc/clnt.c linux-2.6.35.2-vs2.3.0.36.31/net/sunrpc/clnt.c
28365 --- linux-2.6.35.2/net/sunrpc/clnt.c    2010-08-02 16:53:02.000000000 +0200
28366 +++ linux-2.6.35.2-vs2.3.0.36.31/net/sunrpc/clnt.c      2010-08-02 17:05:06.000000000 +0200
28367 @@ -33,6 +33,7 @@
28368  #include <linux/utsname.h>
28369  #include <linux/workqueue.h>
28370  #include <linux/in6.h>
28371 +#include <linux/vs_cvirt.h>
28372  
28373  #include <linux/sunrpc/clnt.h>
28374  #include <linux/sunrpc/rpc_pipe_fs.h>
28375 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28376         if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28377                 clnt->cl_chatty = 1;
28378  
28379 +       /* TODO: handle RPC_CLNT_CREATE_TAGGED
28380 +       if (args->flags & RPC_CLNT_CREATE_TAGGED)
28381 +               clnt->cl_tag = 1; */
28382         return clnt;
28383  }
28384  EXPORT_SYMBOL_GPL(rpc_create);
28385 diff -NurpP --minimal linux-2.6.35.2/net/unix/af_unix.c linux-2.6.35.2-vs2.3.0.36.31/net/unix/af_unix.c
28386 --- linux-2.6.35.2/net/unix/af_unix.c   2010-08-02 16:53:02.000000000 +0200
28387 +++ linux-2.6.35.2-vs2.3.0.36.31/net/unix/af_unix.c     2010-08-02 17:05:06.000000000 +0200
28388 @@ -114,6 +114,8 @@
28389  #include <linux/mount.h>
28390  #include <net/checksum.h>
28391  #include <linux/security.h>
28392 +#include <linux/vs_context.h>
28393 +#include <linux/vs_limit.h>
28394  
28395  static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28396  static DEFINE_SPINLOCK(unix_table_lock);
28397 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28398                 if (!net_eq(sock_net(s), net))
28399                         continue;
28400  
28401 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28402 +                       continue;
28403                 if (u->addr->len == len &&
28404                     !memcmp(u->addr->name, sunname, len))
28405                         goto found;
28406 @@ -2114,6 +2118,8 @@ static struct sock *unix_seq_idx(struct 
28407         for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28408                 if (sock_net(s) != seq_file_net(seq))
28409                         continue;
28410 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28411 +                       continue;
28412                 if (off == pos)
28413                         return s;
28414                 ++off;
28415 @@ -2138,7 +2144,8 @@ static void *unix_seq_next(struct seq_fi
28416                 sk = first_unix_socket(&iter->i);
28417         else
28418                 sk = next_unix_socket(&iter->i, sk);
28419 -       while (sk && (sock_net(sk) != seq_file_net(seq)))
28420 +       while (sk && (sock_net(sk) != seq_file_net(seq) ||
28421 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28422                 sk = next_unix_socket(&iter->i, sk);
28423         return sk;
28424  }
28425 diff -NurpP --minimal linux-2.6.35.2/net/x25/af_x25.c linux-2.6.35.2-vs2.3.0.36.31/net/x25/af_x25.c
28426 --- linux-2.6.35.2/net/x25/af_x25.c     2010-08-02 16:53:02.000000000 +0200
28427 +++ linux-2.6.35.2-vs2.3.0.36.31/net/x25/af_x25.c       2010-08-02 17:05:06.000000000 +0200
28428 @@ -568,7 +568,10 @@ static int x25_create(struct net *net, s
28429  
28430         x25 = x25_sk(sk);
28431  
28432 -       sock_init_data(sock, sk);
28433 +       sk->sk_socket = sock;
28434 +       sk->sk_type = sock->type;
28435 +       sk->sk_sleep = &sock->wait;
28436 +       sock->sk = sk;
28437  
28438         x25_init_timers(sk);
28439  
28440 diff -NurpP --minimal linux-2.6.35.2/scripts/checksyscalls.sh linux-2.6.35.2-vs2.3.0.36.31/scripts/checksyscalls.sh
28441 --- linux-2.6.35.2/scripts/checksyscalls.sh     2009-09-10 15:26:31.000000000 +0200
28442 +++ linux-2.6.35.2-vs2.3.0.36.31/scripts/checksyscalls.sh       2010-08-02 17:05:06.000000000 +0200
28443 @@ -194,7 +194,6 @@ cat << EOF
28444  #define __IGNORE_afs_syscall
28445  #define __IGNORE_getpmsg
28446  #define __IGNORE_putpmsg
28447 -#define __IGNORE_vserver
28448  EOF
28449  }
28450  
28451 diff -NurpP --minimal linux-2.6.35.2/security/commoncap.c linux-2.6.35.2-vs2.3.0.36.31/security/commoncap.c
28452 --- linux-2.6.35.2/security/commoncap.c 2010-08-02 16:53:03.000000000 +0200
28453 +++ linux-2.6.35.2-vs2.3.0.36.31/security/commoncap.c   2010-08-02 17:05:06.000000000 +0200
28454 @@ -28,6 +28,7 @@
28455  #include <linux/prctl.h>
28456  #include <linux/securebits.h>
28457  #include <linux/syslog.h>
28458 +#include <linux/vs_context.h>
28459  
28460  /*
28461   * If a non-root user executes a setuid-root binary in
28462 @@ -53,7 +54,7 @@ static void warn_setuid_and_fcaps_mixed(
28463  
28464  int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
28465  {
28466 -       NETLINK_CB(skb).eff_cap = current_cap();
28467 +       NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
28468         return 0;
28469  }
28470  
28471 @@ -63,6 +64,7 @@ int cap_netlink_recv(struct sk_buff *skb
28472                 return -EPERM;
28473         return 0;
28474  }
28475 +
28476  EXPORT_SYMBOL(cap_netlink_recv);
28477  
28478  /**
28479 @@ -83,7 +85,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
28480  int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
28481                 int audit)
28482  {
28483 -       return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
28484 +       struct vx_info *vxi = tsk->vx_info;
28485 +
28486 +#if 0
28487 +       printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
28488 +               vx_info_flags(vxi, VXF_STATE_SETUP, 0),
28489 +               cap_raised(tsk->cap_effective, cap),
28490 +               tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
28491 +#endif
28492 +
28493 +       /* special case SETUP */
28494 +       if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28495 +               /* FIXME: maybe use cred instead? */
28496 +               cap_raised(tsk->cred->cap_effective, cap))
28497 +               return 0;
28498 +
28499 +       return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
28500  }
28501  
28502  /**
28503 @@ -571,7 +588,7 @@ int cap_inode_setxattr(struct dentry *de
28504  
28505         if (!strncmp(name, XATTR_SECURITY_PREFIX,
28506                      sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28507 -           !capable(CAP_SYS_ADMIN))
28508 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28509                 return -EPERM;
28510         return 0;
28511  }
28512 @@ -597,7 +614,7 @@ int cap_inode_removexattr(struct dentry 
28513  
28514         if (!strncmp(name, XATTR_SECURITY_PREFIX,
28515                      sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28516 -           !capable(CAP_SYS_ADMIN))
28517 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28518                 return -EPERM;
28519         return 0;
28520  }
28521 @@ -899,7 +916,8 @@ int cap_syslog(int type, bool from_file)
28522         if (type != SYSLOG_ACTION_OPEN && from_file)
28523                 return 0;
28524         if ((type != SYSLOG_ACTION_READ_ALL &&
28525 -            type != SYSLOG_ACTION_SIZE_BUFFER) && !capable(CAP_SYS_ADMIN))
28526 +            type != SYSLOG_ACTION_SIZE_BUFFER) &&
28527 +               !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
28528                 return -EPERM;
28529         return 0;
28530  }
28531 @@ -951,3 +969,4 @@ int cap_file_mmap(struct file *file, uns
28532         }
28533         return ret;
28534  }
28535 +
28536 diff -NurpP --minimal linux-2.6.35.2/security/selinux/av_permissions.h linux-2.6.35.2-vs2.3.0.36.31/security/selinux/av_permissions.h
28537 --- linux-2.6.35.2/security/selinux/av_permissions.h    1970-01-01 01:00:00.000000000 +0100
28538 +++ linux-2.6.35.2-vs2.3.0.36.31/security/selinux/av_permissions.h      2010-08-02 17:05:06.000000000 +0200
28539 @@ -0,0 +1,827 @@
28540 +/* This file is automatically generated.  Do not edit. */
28541 +#ifndef _SELINUX_AV_PERMISSIONS_H_
28542 +#define _SELINUX_AV_PERMISSIONS_H_
28543 +
28544 +#define SECURITY__COMPUTE_AV                      0x00000001UL
28545 +#define SECURITY__COMPUTE_CREATE                  0x00000002UL
28546 +#define SECURITY__COMPUTE_MEMBER                  0x00000004UL
28547 +#define SECURITY__CHECK_CONTEXT                   0x00000008UL
28548 +#define SECURITY__LOAD_POLICY                     0x00000010UL
28549 +#define SECURITY__COMPUTE_RELABEL                 0x00000020UL
28550 +#define SECURITY__COMPUTE_USER                    0x00000040UL
28551 +#define SECURITY__SETENFORCE                      0x00000080UL
28552 +#define SECURITY__SETBOOL                         0x00000100UL
28553 +#define SECURITY__SETSECPARAM                     0x00000200UL
28554 +#define SECURITY__SETCHECKREQPROT                 0x00000400UL
28555 +#define PROCESS__FORK                             0x00000001UL
28556 +#define PROCESS__TRANSITION                       0x00000002UL
28557 +#define PROCESS__SIGCHLD                          0x00000004UL
28558 +#define PROCESS__SIGKILL                          0x00000008UL
28559 +#define PROCESS__SIGSTOP                          0x00000010UL
28560 +#define PROCESS__SIGNULL                          0x00000020UL
28561 +#define PROCESS__SIGNAL                           0x00000040UL
28562 +#define PROCESS__PTRACE                           0x00000080UL
28563 +#define PROCESS__GETSCHED                         0x00000100UL
28564 +#define PROCESS__SETSCHED                         0x00000200UL
28565 +#define PROCESS__GETSESSION                       0x00000400UL
28566 +#define PROCESS__GETPGID                          0x00000800UL
28567 +#define PROCESS__SETPGID                          0x00001000UL
28568 +#define PROCESS__GETCAP                           0x00002000UL
28569 +#define PROCESS__SETCAP                           0x00004000UL
28570 +#define PROCESS__SHARE                            0x00008000UL
28571 +#define PROCESS__GETATTR                          0x00010000UL
28572 +#define PROCESS__SETEXEC                          0x00020000UL
28573 +#define PROCESS__SETFSCREATE                      0x00040000UL
28574 +#define PROCESS__NOATSECURE                       0x00080000UL
28575 +#define PROCESS__SIGINH                           0x00100000UL
28576 +#define PROCESS__SETRLIMIT                        0x00200000UL
28577 +#define PROCESS__RLIMITINH                        0x00400000UL
28578 +#define PROCESS__DYNTRANSITION                    0x00800000UL
28579 +#define PROCESS__SETCURRENT                       0x01000000UL
28580 +#define PROCESS__EXECMEM                          0x02000000UL
28581 +#define PROCESS__EXECSTACK                        0x04000000UL
28582 +#define PROCESS__EXECHEAP                         0x08000000UL
28583 +#define PROCESS__SETKEYCREATE                     0x10000000UL
28584 +#define PROCESS__SETSOCKCREATE                    0x20000000UL
28585 +#define SYSTEM__IPC_INFO                          0x00000001UL
28586 +#define SYSTEM__SYSLOG_READ                       0x00000002UL
28587 +#define SYSTEM__SYSLOG_MOD                        0x00000004UL
28588 +#define SYSTEM__SYSLOG_CONSOLE                    0x00000008UL
28589 +#define SYSTEM__MODULE_REQUEST                    0x00000010UL
28590 +#define CAPABILITY__CHOWN                         0x00000001UL
28591 +#define CAPABILITY__DAC_OVERRIDE                  0x00000002UL
28592 +#define CAPABILITY__DAC_READ_SEARCH               0x00000004UL
28593 +#define CAPABILITY__FOWNER                        0x00000008UL
28594 +#define CAPABILITY__FSETID                        0x00000010UL
28595 +#define CAPABILITY__KILL                          0x00000020UL
28596 +#define CAPABILITY__SETGID                        0x00000040UL
28597 +#define CAPABILITY__SETUID                        0x00000080UL
28598 +#define CAPABILITY__SETPCAP                       0x00000100UL
28599 +#define CAPABILITY__LINUX_IMMUTABLE               0x00000200UL
28600 +#define CAPABILITY__NET_BIND_SERVICE              0x00000400UL
28601 +#define CAPABILITY__NET_BROADCAST                 0x00000800UL
28602 +#define CAPABILITY__NET_ADMIN                     0x00001000UL
28603 +#define CAPABILITY__NET_RAW                       0x00002000UL
28604 +#define CAPABILITY__IPC_LOCK                      0x00004000UL
28605 +#define CAPABILITY__IPC_OWNER                     0x00008000UL
28606 +#define CAPABILITY__SYS_MODULE                    0x00010000UL
28607 +#define CAPABILITY__SYS_RAWIO                     0x00020000UL
28608 +#define CAPABILITY__SYS_CHROOT                    0x00040000UL
28609 +#define CAPABILITY__SYS_PTRACE                    0x00080000UL
28610 +#define CAPABILITY__SYS_PACCT                     0x00100000UL
28611 +#define CAPABILITY__SYS_ADMIN                     0x00200000UL
28612 +#define CAPABILITY__SYS_BOOT                      0x00400000UL
28613 +#define CAPABILITY__SYS_NICE                      0x00800000UL
28614 +#define CAPABILITY__SYS_RESOURCE                  0x01000000UL
28615 +#define CAPABILITY__SYS_TIME                      0x02000000UL
28616 +#define CAPABILITY__SYS_TTY_CONFIG                0x04000000UL
28617 +#define CAPABILITY__MKNOD                         0x08000000UL
28618 +#define CAPABILITY__LEASE                         0x10000000UL
28619 +#define CAPABILITY__AUDIT_WRITE                   0x20000000UL
28620 +#define CAPABILITY__AUDIT_CONTROL                 0x40000000UL
28621 +#define CAPABILITY__SETFCAP                       0x80000000UL
28622 +#define FILESYSTEM__MOUNT                         0x00000001UL
28623 +#define FILESYSTEM__REMOUNT                       0x00000002UL
28624 +#define FILESYSTEM__UNMOUNT                       0x00000004UL
28625 +#define FILESYSTEM__GETATTR                       0x00000008UL
28626 +#define FILESYSTEM__RELABELFROM                   0x00000010UL
28627 +#define FILESYSTEM__RELABELTO                     0x00000020UL
28628 +#define FILESYSTEM__TRANSITION                    0x00000040UL
28629 +#define FILESYSTEM__ASSOCIATE                     0x00000080UL
28630 +#define FILESYSTEM__QUOTAMOD                      0x00000100UL
28631 +#define FILESYSTEM__QUOTAGET                      0x00000200UL
28632 +#define FILE__IOCTL                               0x00000001UL
28633 +#define FILE__READ                                0x00000002UL
28634 +#define FILE__WRITE                               0x00000004UL
28635 +#define FILE__CREATE                              0x00000008UL
28636 +#define FILE__GETATTR                             0x00000010UL
28637 +#define FILE__SETATTR                             0x00000020UL
28638 +#define FILE__LOCK                                0x00000040UL
28639 +#define FILE__RELABELFROM                         0x00000080UL
28640 +#define FILE__RELABELTO                           0x00000100UL
28641 +#define FILE__APPEND                              0x00000200UL
28642 +#define FILE__UNLINK                              0x00000400UL
28643 +#define FILE__LINK                                0x00000800UL
28644 +#define FILE__RENAME                              0x00001000UL
28645 +#define FILE__EXECUTE                             0x00002000UL
28646 +#define FILE__SWAPON                              0x00004000UL
28647 +#define FILE__QUOTAON                             0x00008000UL
28648 +#define FILE__MOUNTON                             0x00010000UL
28649 +#define FILE__EXECUTE_NO_TRANS                    0x00020000UL
28650 +#define FILE__ENTRYPOINT                          0x00040000UL
28651 +#define FILE__EXECMOD                             0x00080000UL
28652 +#define FILE__OPEN                                0x00100000UL
28653 +#define DIR__IOCTL                                0x00000001UL
28654 +#define DIR__READ                                 0x00000002UL
28655 +#define DIR__WRITE                                0x00000004UL
28656 +#define DIR__CREATE                               0x00000008UL
28657 +#define DIR__GETATTR                              0x00000010UL
28658 +#define DIR__SETATTR                              0x00000020UL
28659 +#define DIR__LOCK                                 0x00000040UL
28660 +#define DIR__RELABELFROM                          0x00000080UL
28661 +#define DIR__RELABELTO                            0x00000100UL
28662 +#define DIR__APPEND                               0x00000200UL
28663 +#define DIR__UNLINK                               0x00000400UL
28664 +#define DIR__LINK                                 0x00000800UL
28665 +#define DIR__RENAME                               0x00001000UL
28666 +#define DIR__EXECUTE                              0x00002000UL
28667 +#define DIR__SWAPON                               0x00004000UL
28668 +#define DIR__QUOTAON                              0x00008000UL
28669 +#define DIR__MOUNTON                              0x00010000UL
28670 +#define DIR__ADD_NAME                             0x00020000UL
28671 +#define DIR__REMOVE_NAME                          0x00040000UL
28672 +#define DIR__REPARENT                             0x00080000UL
28673 +#define DIR__SEARCH                               0x00100000UL
28674 +#define DIR__RMDIR                                0x00200000UL
28675 +#define DIR__OPEN                                 0x00400000UL
28676 +#define FD__USE                                   0x00000001UL
28677 +#define LNK_FILE__IOCTL                           0x00000001UL
28678 +#define LNK_FILE__READ                            0x00000002UL
28679 +#define LNK_FILE__WRITE                           0x00000004UL
28680 +#define LNK_FILE__CREATE                          0x00000008UL
28681 +#define LNK_FILE__GETATTR                         0x00000010UL
28682 +#define LNK_FILE__SETATTR                         0x00000020UL
28683 +#define LNK_FILE__LOCK                            0x00000040UL
28684 +#define LNK_FILE__RELABELFROM                     0x00000080UL
28685 +#define LNK_FILE__RELABELTO                       0x00000100UL
28686 +#define LNK_FILE__APPEND                          0x00000200UL
28687 +#define LNK_FILE__UNLINK                          0x00000400UL
28688 +#define LNK_FILE__LINK                            0x00000800UL
28689 +#define LNK_FILE__RENAME                          0x00001000UL
28690 +#define LNK_FILE__EXECUTE                         0x00002000UL
28691 +#define LNK_FILE__SWAPON                          0x00004000UL
28692 +#define LNK_FILE__QUOTAON                         0x00008000UL
28693 +#define LNK_FILE__MOUNTON                         0x00010000UL
28694 +#define CHR_FILE__IOCTL                           0x00000001UL
28695 +#define CHR_FILE__READ                            0x00000002UL
28696 +#define CHR_FILE__WRITE                           0x00000004UL
28697 +#define CHR_FILE__CREATE                          0x00000008UL
28698 +#define CHR_FILE__GETATTR                         0x00000010UL
28699 +#define CHR_FILE__SETATTR                         0x00000020UL
28700 +#define CHR_FILE__LOCK                            0x00000040UL
28701 +#define CHR_FILE__RELABELFROM                     0x00000080UL
28702 +#define CHR_FILE__RELABELTO                       0x00000100UL
28703 +#define CHR_FILE__APPEND                          0x00000200UL
28704 +#define CHR_FILE__UNLINK                          0x00000400UL
28705 +#define CHR_FILE__LINK                            0x00000800UL
28706 +#define CHR_FILE__RENAME                          0x00001000UL
28707 +#define CHR_FILE__EXECUTE                         0x00002000UL
28708 +#define CHR_FILE__SWAPON                          0x00004000UL
28709 +#define CHR_FILE__QUOTAON                         0x00008000UL
28710 +#define CHR_FILE__MOUNTON                         0x00010000UL
28711 +#define CHR_FILE__EXECUTE_NO_TRANS                0x00020000UL
28712 +#define CHR_FILE__ENTRYPOINT                      0x00040000UL
28713 +#define CHR_FILE__EXECMOD                         0x00080000UL
28714 +#define CHR_FILE__OPEN                            0x00100000UL
28715 +#define BLK_FILE__IOCTL                           0x00000001UL
28716 +#define BLK_FILE__READ                            0x00000002UL
28717 +#define BLK_FILE__WRITE                           0x00000004UL
28718 +#define BLK_FILE__CREATE                          0x00000008UL
28719 +#define BLK_FILE__GETATTR                         0x00000010UL
28720 +#define BLK_FILE__SETATTR                         0x00000020UL
28721 +#define BLK_FILE__LOCK                            0x00000040UL
28722 +#define BLK_FILE__RELABELFROM                     0x00000080UL
28723 +#define BLK_FILE__RELABELTO                       0x00000100UL
28724 +#define BLK_FILE__APPEND                          0x00000200UL
28725 +#define BLK_FILE__UNLINK                          0x00000400UL
28726 +#define BLK_FILE__LINK                            0x00000800UL
28727 +#define BLK_FILE__RENAME                          0x00001000UL
28728 +#define BLK_FILE__EXECUTE                         0x00002000UL
28729 +#define BLK_FILE__SWAPON                          0x00004000UL
28730 +#define BLK_FILE__QUOTAON                         0x00008000UL
28731 +#define BLK_FILE__MOUNTON                         0x00010000UL
28732 +#define BLK_FILE__OPEN                            0x00020000UL
28733 +#define SOCK_FILE__IOCTL                          0x00000001UL
28734 +#define SOCK_FILE__READ                           0x00000002UL
28735 +#define SOCK_FILE__WRITE                          0x00000004UL
28736 +#define SOCK_FILE__CREATE                         0x00000008UL
28737 +#define SOCK_FILE__GETATTR                        0x00000010UL
28738 +#define SOCK_FILE__SETATTR                        0x00000020UL
28739 +#define SOCK_FILE__LOCK                           0x00000040UL
28740 +#define SOCK_FILE__RELABELFROM                    0x00000080UL
28741 +#define SOCK_FILE__RELABELTO                      0x00000100UL
28742 +#define SOCK_FILE__APPEND                         0x00000200UL
28743 +#define SOCK_FILE__UNLINK                         0x00000400UL
28744 +#define SOCK_FILE__LINK                           0x00000800UL
28745 +#define SOCK_FILE__RENAME                         0x00001000UL
28746 +#define SOCK_FILE__EXECUTE                        0x00002000UL
28747 +#define SOCK_FILE__SWAPON                         0x00004000UL
28748 +#define SOCK_FILE__QUOTAON                        0x00008000UL
28749 +#define SOCK_FILE__MOUNTON                        0x00010000UL
28750 +#define SOCK_FILE__OPEN                           0x00020000UL
28751 +#define FIFO_FILE__IOCTL                          0x00000001UL
28752 +#define FIFO_FILE__READ                           0x00000002UL
28753 +#define FIFO_FILE__WRITE                          0x00000004UL
28754 +#define FIFO_FILE__CREATE                         0x00000008UL
28755 +#define FIFO_FILE__GETATTR                        0x00000010UL
28756 +#define FIFO_FILE__SETATTR                        0x00000020UL
28757 +#define FIFO_FILE__LOCK                           0x00000040UL
28758 +#define FIFO_FILE__RELABELFROM                    0x00000080UL
28759 +#define FIFO_FILE__RELABELTO                      0x00000100UL
28760 +#define FIFO_FILE__APPEND                         0x00000200UL
28761 +#define FIFO_FILE__UNLINK                         0x00000400UL
28762 +#define FIFO_FILE__LINK                           0x00000800UL
28763 +#define FIFO_FILE__RENAME                         0x00001000UL
28764 +#define FIFO_FILE__EXECUTE                        0x00002000UL
28765 +#define FIFO_FILE__SWAPON                         0x00004000UL
28766 +#define FIFO_FILE__QUOTAON                        0x00008000UL
28767 +#define FIFO_FILE__MOUNTON                        0x00010000UL
28768 +#define FIFO_FILE__OPEN                           0x00020000UL
28769 +#define SOCKET__IOCTL                             0x00000001UL
28770 +#define SOCKET__READ                              0x00000002UL
28771 +#define SOCKET__WRITE                             0x00000004UL
28772 +#define SOCKET__CREATE                            0x00000008UL
28773 +#define SOCKET__GETATTR                           0x00000010UL
28774 +#define SOCKET__SETATTR                           0x00000020UL
28775 +#define SOCKET__LOCK                              0x00000040UL
28776 +#define SOCKET__RELABELFROM                       0x00000080UL
28777 +#define SOCKET__RELABELTO                         0x00000100UL
28778 +#define SOCKET__APPEND                            0x00000200UL
28779 +#define SOCKET__BIND                              0x00000400UL
28780 +#define SOCKET__CONNECT                           0x00000800UL
28781 +#define SOCKET__LISTEN                            0x00001000UL
28782 +#define SOCKET__ACCEPT                            0x00002000UL
28783 +#define SOCKET__GETOPT                            0x00004000UL
28784 +#define SOCKET__SETOPT                            0x00008000UL
28785 +#define SOCKET__SHUTDOWN                          0x00010000UL
28786 +#define SOCKET__RECVFROM                          0x00020000UL
28787 +#define SOCKET__SENDTO                            0x00040000UL
28788 +#define SOCKET__RECV_MSG                          0x00080000UL
28789 +#define SOCKET__SEND_MSG                          0x00100000UL
28790 +#define SOCKET__NAME_BIND                         0x00200000UL
28791 +#define TCP_SOCKET__IOCTL                         0x00000001UL
28792 +#define TCP_SOCKET__READ                          0x00000002UL
28793 +#define TCP_SOCKET__WRITE                         0x00000004UL
28794 +#define TCP_SOCKET__CREATE                        0x00000008UL
28795 +#define TCP_SOCKET__GETATTR                       0x00000010UL
28796 +#define TCP_SOCKET__SETATTR                       0x00000020UL
28797 +#define TCP_SOCKET__LOCK                          0x00000040UL
28798 +#define TCP_SOCKET__RELABELFROM                   0x00000080UL
28799 +#define TCP_SOCKET__RELABELTO                     0x00000100UL
28800 +#define TCP_SOCKET__APPEND                        0x00000200UL
28801 +#define TCP_SOCKET__BIND                          0x00000400UL
28802 +#define TCP_SOCKET__CONNECT                       0x00000800UL
28803 +#define TCP_SOCKET__LISTEN                        0x00001000UL
28804 +#define TCP_SOCKET__ACCEPT                        0x00002000UL
28805 +#define TCP_SOCKET__GETOPT                        0x00004000UL
28806 +#define TCP_SOCKET__SETOPT                        0x00008000UL
28807 +#define TCP_SOCKET__SHUTDOWN                      0x00010000UL
28808 +#define TCP_SOCKET__RECVFROM                      0x00020000UL
28809 +#define TCP_SOCKET__SENDTO                        0x00040000UL
28810 +#define TCP_SOCKET__RECV_MSG                      0x00080000UL
28811 +#define TCP_SOCKET__SEND_MSG                      0x00100000UL
28812 +#define TCP_SOCKET__NAME_BIND                     0x00200000UL
28813 +#define TCP_SOCKET__CONNECTTO                     0x00400000UL
28814 +#define TCP_SOCKET__NEWCONN                       0x00800000UL
28815 +#define TCP_SOCKET__ACCEPTFROM                    0x01000000UL
28816 +#define TCP_SOCKET__NODE_BIND                     0x02000000UL
28817 +#define TCP_SOCKET__NAME_CONNECT                  0x04000000UL
28818 +#define UDP_SOCKET__IOCTL                         0x00000001UL
28819 +#define UDP_SOCKET__READ                          0x00000002UL
28820 +#define UDP_SOCKET__WRITE                         0x00000004UL
28821 +#define UDP_SOCKET__CREATE                        0x00000008UL
28822 +#define UDP_SOCKET__GETATTR                       0x00000010UL
28823 +#define UDP_SOCKET__SETATTR                       0x00000020UL
28824 +#define UDP_SOCKET__LOCK                          0x00000040UL
28825 +#define UDP_SOCKET__RELABELFROM                   0x00000080UL
28826 +#define UDP_SOCKET__RELABELTO                     0x00000100UL
28827 +#define UDP_SOCKET__APPEND                        0x00000200UL
28828 +#define UDP_SOCKET__BIND                          0x00000400UL
28829 +#define UDP_SOCKET__CONNECT                       0x00000800UL
28830 +#define UDP_SOCKET__LISTEN                        0x00001000UL
28831 +#define UDP_SOCKET__ACCEPT                        0x00002000UL
28832 +#define UDP_SOCKET__GETOPT                        0x00004000UL
28833 +#define UDP_SOCKET__SETOPT                        0x00008000UL
28834 +#define UDP_SOCKET__SHUTDOWN                      0x00010000UL
28835 +#define UDP_SOCKET__RECVFROM                      0x00020000UL
28836 +#define UDP_SOCKET__SENDTO                        0x00040000UL
28837 +#define UDP_SOCKET__RECV_MSG                      0x00080000UL
28838 +#define UDP_SOCKET__SEND_MSG                      0x00100000UL
28839 +#define UDP_SOCKET__NAME_BIND                     0x00200000UL
28840 +#define UDP_SOCKET__NODE_BIND                     0x00400000UL
28841 +#define RAWIP_SOCKET__IOCTL                       0x00000001UL
28842 +#define RAWIP_SOCKET__READ                        0x00000002UL
28843 +#define RAWIP_SOCKET__WRITE                       0x00000004UL
28844 +#define RAWIP_SOCKET__CREATE                      0x00000008UL
28845 +#define RAWIP_SOCKET__GETATTR                     0x00000010UL
28846 +#define RAWIP_SOCKET__SETATTR                     0x00000020UL
28847 +#define RAWIP_SOCKET__LOCK                        0x00000040UL
28848 +#define RAWIP_SOCKET__RELABELFROM                 0x00000080UL
28849 +#define RAWIP_SOCKET__RELABELTO                   0x00000100UL
28850 +#define RAWIP_SOCKET__APPEND                      0x00000200UL
28851 +#define RAWIP_SOCKET__BIND                        0x00000400UL
28852 +#define RAWIP_SOCKET__CONNECT                     0x00000800UL
28853 +#define RAWIP_SOCKET__LISTEN                      0x00001000UL
28854 +#define RAWIP_SOCKET__ACCEPT                      0x00002000UL
28855 +#define RAWIP_SOCKET__GETOPT                      0x00004000UL
28856 +#define RAWIP_SOCKET__SETOPT                      0x00008000UL
28857 +#define RAWIP_SOCKET__SHUTDOWN                    0x00010000UL
28858 +#define RAWIP_SOCKET__RECVFROM                    0x00020000UL
28859 +#define RAWIP_SOCKET__SENDTO                      0x00040000UL
28860 +#define RAWIP_SOCKET__RECV_MSG                    0x00080000UL
28861 +#define RAWIP_SOCKET__SEND_MSG                    0x00100000UL
28862 +#define RAWIP_SOCKET__NAME_BIND                   0x00200000UL
28863 +#define RAWIP_SOCKET__NODE_BIND                   0x00400000UL
28864 +#define NODE__TCP_RECV                            0x00000001UL
28865 +#define NODE__TCP_SEND                            0x00000002UL
28866 +#define NODE__UDP_RECV                            0x00000004UL
28867 +#define NODE__UDP_SEND                            0x00000008UL
28868 +#define NODE__RAWIP_RECV                          0x00000010UL
28869 +#define NODE__RAWIP_SEND                          0x00000020UL
28870 +#define NODE__ENFORCE_DEST                        0x00000040UL
28871 +#define NODE__DCCP_RECV                           0x00000080UL
28872 +#define NODE__DCCP_SEND                           0x00000100UL
28873 +#define NODE__RECVFROM                            0x00000200UL
28874 +#define NODE__SENDTO                              0x00000400UL
28875 +#define NETIF__TCP_RECV                           0x00000001UL
28876 +#define NETIF__TCP_SEND                           0x00000002UL
28877 +#define NETIF__UDP_RECV                           0x00000004UL
28878 +#define NETIF__UDP_SEND                           0x00000008UL
28879 +#define NETIF__RAWIP_RECV                         0x00000010UL
28880 +#define NETIF__RAWIP_SEND                         0x00000020UL
28881 +#define NETIF__DCCP_RECV                          0x00000040UL
28882 +#define NETIF__DCCP_SEND                          0x00000080UL
28883 +#define NETIF__INGRESS                            0x00000100UL
28884 +#define NETIF__EGRESS                             0x00000200UL
28885 +#define NETLINK_SOCKET__IOCTL                     0x00000001UL
28886 +#define NETLINK_SOCKET__READ                      0x00000002UL
28887 +#define NETLINK_SOCKET__WRITE                     0x00000004UL
28888 +#define NETLINK_SOCKET__CREATE                    0x00000008UL
28889 +#define NETLINK_SOCKET__GETATTR                   0x00000010UL
28890 +#define NETLINK_SOCKET__SETATTR                   0x00000020UL
28891 +#define NETLINK_SOCKET__LOCK                      0x00000040UL
28892 +#define NETLINK_SOCKET__RELABELFROM               0x00000080UL
28893 +#define NETLINK_SOCKET__RELABELTO                 0x00000100UL
28894 +#define NETLINK_SOCKET__APPEND                    0x00000200UL
28895 +#define NETLINK_SOCKET__BIND                      0x00000400UL
28896 +#define NETLINK_SOCKET__CONNECT                   0x00000800UL
28897 +#define NETLINK_SOCKET__LISTEN                    0x00001000UL
28898 +#define NETLINK_SOCKET__ACCEPT                    0x00002000UL
28899 +#define NETLINK_SOCKET__GETOPT                    0x00004000UL
28900 +#define NETLINK_SOCKET__SETOPT                    0x00008000UL
28901 +#define NETLINK_SOCKET__SHUTDOWN                  0x00010000UL
28902 +#define NETLINK_SOCKET__RECVFROM                  0x00020000UL
28903 +#define NETLINK_SOCKET__SENDTO                    0x00040000UL
28904 +#define NETLINK_SOCKET__RECV_MSG                  0x00080000UL
28905 +#define NETLINK_SOCKET__SEND_MSG                  0x00100000UL
28906 +#define NETLINK_SOCKET__NAME_BIND                 0x00200000UL
28907 +#define PACKET_SOCKET__IOCTL                      0x00000001UL
28908 +#define PACKET_SOCKET__READ                       0x00000002UL
28909 +#define PACKET_SOCKET__WRITE                      0x00000004UL
28910 +#define PACKET_SOCKET__CREATE                     0x00000008UL
28911 +#define PACKET_SOCKET__GETATTR                    0x00000010UL
28912 +#define PACKET_SOCKET__SETATTR                    0x00000020UL
28913 +#define PACKET_SOCKET__LOCK                       0x00000040UL
28914 +#define PACKET_SOCKET__RELABELFROM                0x00000080UL
28915 +#define PACKET_SOCKET__RELABELTO                  0x00000100UL
28916 +#define PACKET_SOCKET__APPEND                     0x00000200UL
28917 +#define PACKET_SOCKET__BIND                       0x00000400UL
28918 +#define PACKET_SOCKET__CONNECT                    0x00000800UL
28919 +#define PACKET_SOCKET__LISTEN                     0x00001000UL
28920 +#define PACKET_SOCKET__ACCEPT                     0x00002000UL
28921 +#define PACKET_SOCKET__GETOPT                     0x00004000UL
28922 +#define PACKET_SOCKET__SETOPT                     0x00008000UL
28923 +#define PACKET_SOCKET__SHUTDOWN                   0x00010000UL
28924 +#define PACKET_SOCKET__RECVFROM                   0x00020000UL
28925 +#define PACKET_SOCKET__SENDTO                     0x00040000UL
28926 +#define PACKET_SOCKET__RECV_MSG                   0x00080000UL
28927 +#define PACKET_SOCKET__SEND_MSG                   0x00100000UL
28928 +#define PACKET_SOCKET__NAME_BIND                  0x00200000UL
28929 +#define KEY_SOCKET__IOCTL                         0x00000001UL
28930 +#define KEY_SOCKET__READ                          0x00000002UL
28931 +#define KEY_SOCKET__WRITE                         0x00000004UL
28932 +#define KEY_SOCKET__CREATE                        0x00000008UL
28933 +#define KEY_SOCKET__GETATTR                       0x00000010UL
28934 +#define KEY_SOCKET__SETATTR                       0x00000020UL
28935 +#define KEY_SOCKET__LOCK                          0x00000040UL
28936 +#define KEY_SOCKET__RELABELFROM                   0x00000080UL
28937 +#define KEY_SOCKET__RELABELTO                     0x00000100UL
28938 +#define KEY_SOCKET__APPEND                        0x00000200UL
28939 +#define KEY_SOCKET__BIND                          0x00000400UL
28940 +#define KEY_SOCKET__CONNECT                       0x00000800UL
28941 +#define KEY_SOCKET__LISTEN                        0x00001000UL
28942 +#define KEY_SOCKET__ACCEPT                        0x00002000UL
28943 +#define KEY_SOCKET__GETOPT                        0x00004000UL
28944 +#define KEY_SOCKET__SETOPT                        0x00008000UL
28945 +#define KEY_SOCKET__SHUTDOWN                      0x00010000UL
28946 +#define KEY_SOCKET__RECVFROM                      0x00020000UL
28947 +#define KEY_SOCKET__SENDTO                        0x00040000UL
28948 +#define KEY_SOCKET__RECV_MSG                      0x00080000UL
28949 +#define KEY_SOCKET__SEND_MSG                      0x00100000UL
28950 +#define KEY_SOCKET__NAME_BIND                     0x00200000UL
28951 +#define UNIX_STREAM_SOCKET__IOCTL                 0x00000001UL
28952 +#define UNIX_STREAM_SOCKET__READ                  0x00000002UL
28953 +#define UNIX_STREAM_SOCKET__WRITE                 0x00000004UL
28954 +#define UNIX_STREAM_SOCKET__CREATE                0x00000008UL
28955 +#define UNIX_STREAM_SOCKET__GETATTR               0x00000010UL
28956 +#define UNIX_STREAM_SOCKET__SETATTR               0x00000020UL
28957 +#define UNIX_STREAM_SOCKET__LOCK                  0x00000040UL
28958 +#define UNIX_STREAM_SOCKET__RELABELFROM           0x00000080UL
28959 +#define UNIX_STREAM_SOCKET__RELABELTO             0x00000100UL
28960 +#define UNIX_STREAM_SOCKET__APPEND                0x00000200UL
28961 +#define UNIX_STREAM_SOCKET__BIND                  0x00000400UL
28962 +#define UNIX_STREAM_SOCKET__CONNECT               0x00000800UL
28963 +#define UNIX_STREAM_SOCKET__LISTEN                0x00001000UL
28964 +#define UNIX_STREAM_SOCKET__ACCEPT                0x00002000UL
28965 +#define UNIX_STREAM_SOCKET__GETOPT                0x00004000UL
28966 +#define UNIX_STREAM_SOCKET__SETOPT                0x00008000UL
28967 +#define UNIX_STREAM_SOCKET__SHUTDOWN              0x00010000UL
28968 +#define UNIX_STREAM_SOCKET__RECVFROM              0x00020000UL
28969 +#define UNIX_STREAM_SOCKET__SENDTO                0x00040000UL
28970 +#define UNIX_STREAM_SOCKET__RECV_MSG              0x00080000UL
28971 +#define UNIX_STREAM_SOCKET__SEND_MSG              0x00100000UL
28972 +#define UNIX_STREAM_SOCKET__NAME_BIND             0x00200000UL
28973 +#define UNIX_STREAM_SOCKET__CONNECTTO             0x00400000UL
28974 +#define UNIX_STREAM_SOCKET__NEWCONN               0x00800000UL
28975 +#define UNIX_STREAM_SOCKET__ACCEPTFROM            0x01000000UL
28976 +#define UNIX_DGRAM_SOCKET__IOCTL                  0x00000001UL
28977 +#define UNIX_DGRAM_SOCKET__READ                   0x00000002UL
28978 +#define UNIX_DGRAM_SOCKET__WRITE                  0x00000004UL
28979 +#define UNIX_DGRAM_SOCKET__CREATE                 0x00000008UL
28980 +#define UNIX_DGRAM_SOCKET__GETATTR                0x00000010UL
28981 +#define UNIX_DGRAM_SOCKET__SETATTR                0x00000020UL
28982 +#define UNIX_DGRAM_SOCKET__LOCK                   0x00000040UL
28983 +#define UNIX_DGRAM_SOCKET__RELABELFROM            0x00000080UL
28984 +#define UNIX_DGRAM_SOCKET__RELABELTO              0x00000100UL
28985 +#define UNIX_DGRAM_SOCKET__APPEND                 0x00000200UL
28986 +#define UNIX_DGRAM_SOCKET__BIND                   0x00000400UL
28987 +#define UNIX_DGRAM_SOCKET__CONNECT                0x00000800UL
28988 +#define UNIX_DGRAM_SOCKET__LISTEN                 0x00001000UL
28989 +#define UNIX_DGRAM_SOCKET__ACCEPT                 0x00002000UL
28990 +#define UNIX_DGRAM_SOCKET__GETOPT                 0x00004000UL
28991 +#define UNIX_DGRAM_SOCKET__SETOPT                 0x00008000UL
28992 +#define UNIX_DGRAM_SOCKET__SHUTDOWN               0x00010000UL
28993 +#define UNIX_DGRAM_SOCKET__RECVFROM               0x00020000UL
28994 +#define UNIX_DGRAM_SOCKET__SENDTO                 0x00040000UL
28995 +#define UNIX_DGRAM_SOCKET__RECV_MSG               0x00080000UL
28996 +#define UNIX_DGRAM_SOCKET__SEND_MSG               0x00100000UL
28997 +#define UNIX_DGRAM_SOCKET__NAME_BIND              0x00200000UL
28998 +#define SEM__CREATE                               0x00000001UL
28999 +#define SEM__DESTROY                              0x00000002UL
29000 +#define SEM__GETATTR                              0x00000004UL
29001 +#define SEM__SETATTR                              0x00000008UL
29002 +#define SEM__READ                                 0x00000010UL
29003 +#define SEM__WRITE                                0x00000020UL
29004 +#define SEM__ASSOCIATE                            0x00000040UL
29005 +#define SEM__UNIX_READ                            0x00000080UL
29006 +#define SEM__UNIX_WRITE                           0x00000100UL
29007 +#define MSG__SEND                                 0x00000001UL
29008 +#define MSG__RECEIVE                              0x00000002UL
29009 +#define MSGQ__CREATE                              0x00000001UL
29010 +#define MSGQ__DESTROY                             0x00000002UL
29011 +#define MSGQ__GETATTR                             0x00000004UL
29012 +#define MSGQ__SETATTR                             0x00000008UL
29013 +#define MSGQ__READ                                0x00000010UL
29014 +#define MSGQ__WRITE                               0x00000020UL
29015 +#define MSGQ__ASSOCIATE                           0x00000040UL
29016 +#define MSGQ__UNIX_READ                           0x00000080UL
29017 +#define MSGQ__UNIX_WRITE                          0x00000100UL
29018 +#define MSGQ__ENQUEUE                             0x00000200UL
29019 +#define SHM__CREATE                               0x00000001UL
29020 +#define SHM__DESTROY                              0x00000002UL
29021 +#define SHM__GETATTR                              0x00000004UL
29022 +#define SHM__SETATTR                              0x00000008UL
29023 +#define SHM__READ                                 0x00000010UL
29024 +#define SHM__WRITE                                0x00000020UL
29025 +#define SHM__ASSOCIATE                            0x00000040UL
29026 +#define SHM__UNIX_READ                            0x00000080UL
29027 +#define SHM__UNIX_WRITE                           0x00000100UL
29028 +#define SHM__LOCK                                 0x00000200UL
29029 +#define IPC__CREATE                               0x00000001UL
29030 +#define IPC__DESTROY                              0x00000002UL
29031 +#define IPC__GETATTR                              0x00000004UL
29032 +#define IPC__SETATTR                              0x00000008UL
29033 +#define IPC__READ                                 0x00000010UL
29034 +#define IPC__WRITE                                0x00000020UL
29035 +#define IPC__ASSOCIATE                            0x00000040UL
29036 +#define IPC__UNIX_READ                            0x00000080UL
29037 +#define IPC__UNIX_WRITE                           0x00000100UL
29038 +#define NETLINK_ROUTE_SOCKET__IOCTL               0x00000001UL
29039 +#define NETLINK_ROUTE_SOCKET__READ                0x00000002UL
29040 +#define NETLINK_ROUTE_SOCKET__WRITE               0x00000004UL
29041 +#define NETLINK_ROUTE_SOCKET__CREATE              0x00000008UL
29042 +#define NETLINK_ROUTE_SOCKET__GETATTR             0x00000010UL
29043 +#define NETLINK_ROUTE_SOCKET__SETATTR             0x00000020UL
29044 +#define NETLINK_ROUTE_SOCKET__LOCK                0x00000040UL
29045 +#define NETLINK_ROUTE_SOCKET__RELABELFROM         0x00000080UL
29046 +#define NETLINK_ROUTE_SOCKET__RELABELTO           0x00000100UL
29047 +#define NETLINK_ROUTE_SOCKET__APPEND              0x00000200UL
29048 +#define NETLINK_ROUTE_SOCKET__BIND                0x00000400UL
29049 +#define NETLINK_ROUTE_SOCKET__CONNECT             0x00000800UL
29050 +#define NETLINK_ROUTE_SOCKET__LISTEN              0x00001000UL
29051 +#define NETLINK_ROUTE_SOCKET__ACCEPT              0x00002000UL
29052 +#define NETLINK_ROUTE_SOCKET__GETOPT              0x00004000UL
29053 +#define NETLINK_ROUTE_SOCKET__SETOPT              0x00008000UL
29054 +#define NETLINK_ROUTE_SOCKET__SHUTDOWN            0x00010000UL
29055 +#define NETLINK_ROUTE_SOCKET__RECVFROM            0x00020000UL
29056 +#define NETLINK_ROUTE_SOCKET__SENDTO              0x00040000UL
29057 +#define NETLINK_ROUTE_SOCKET__RECV_MSG            0x00080000UL
29058 +#define NETLINK_ROUTE_SOCKET__SEND_MSG            0x00100000UL
29059 +#define NETLINK_ROUTE_SOCKET__NAME_BIND           0x00200000UL
29060 +#define NETLINK_ROUTE_SOCKET__NLMSG_READ          0x00400000UL
29061 +#define NETLINK_ROUTE_SOCKET__NLMSG_WRITE         0x00800000UL
29062 +#define NETLINK_FIREWALL_SOCKET__IOCTL            0x00000001UL
29063 +#define NETLINK_FIREWALL_SOCKET__READ             0x00000002UL
29064 +#define NETLINK_FIREWALL_SOCKET__WRITE            0x00000004UL
29065 +#define NETLINK_FIREWALL_SOCKET__CREATE           0x00000008UL
29066 +#define NETLINK_FIREWALL_SOCKET__GETATTR          0x00000010UL
29067 +#define NETLINK_FIREWALL_SOCKET__SETATTR          0x00000020UL
29068 +#define NETLINK_FIREWALL_SOCKET__LOCK             0x00000040UL
29069 +#define NETLINK_FIREWALL_SOCKET__RELABELFROM      0x00000080UL
29070 +#define NETLINK_FIREWALL_SOCKET__RELABELTO        0x00000100UL
29071 +#define NETLINK_FIREWALL_SOCKET__APPEND           0x00000200UL
29072 +#define NETLINK_FIREWALL_SOCKET__BIND             0x00000400UL
29073 +#define NETLINK_FIREWALL_SOCKET__CONNECT          0x00000800UL
29074 +#define NETLINK_FIREWALL_SOCKET__LISTEN           0x00001000UL
29075 +#define NETLINK_FIREWALL_SOCKET__ACCEPT           0x00002000UL
29076 +#define NETLINK_FIREWALL_SOCKET__GETOPT           0x00004000UL
29077 +#define NETLINK_FIREWALL_SOCKET__SETOPT           0x00008000UL
29078 +#define NETLINK_FIREWALL_SOCKET__SHUTDOWN         0x00010000UL
29079 +#define NETLINK_FIREWALL_SOCKET__RECVFROM         0x00020000UL
29080 +#define NETLINK_FIREWALL_SOCKET__SENDTO           0x00040000UL
29081 +#define NETLINK_FIREWALL_SOCKET__RECV_MSG         0x00080000UL
29082 +#define NETLINK_FIREWALL_SOCKET__SEND_MSG         0x00100000UL
29083 +#define NETLINK_FIREWALL_SOCKET__NAME_BIND        0x00200000UL
29084 +#define NETLINK_FIREWALL_SOCKET__NLMSG_READ       0x00400000UL
29085 +#define NETLINK_FIREWALL_SOCKET__NLMSG_WRITE      0x00800000UL
29086 +#define NETLINK_TCPDIAG_SOCKET__IOCTL             0x00000001UL
29087 +#define NETLINK_TCPDIAG_SOCKET__READ              0x00000002UL
29088 +#define NETLINK_TCPDIAG_SOCKET__WRITE             0x00000004UL
29089 +#define NETLINK_TCPDIAG_SOCKET__CREATE            0x00000008UL
29090 +#define NETLINK_TCPDIAG_SOCKET__GETATTR           0x00000010UL
29091 +#define NETLINK_TCPDIAG_SOCKET__SETATTR           0x00000020UL
29092 +#define NETLINK_TCPDIAG_SOCKET__LOCK              0x00000040UL
29093 +#define NETLINK_TCPDIAG_SOCKET__RELABELFROM       0x00000080UL
29094 +#define NETLINK_TCPDIAG_SOCKET__RELABELTO         0x00000100UL
29095 +#define NETLINK_TCPDIAG_SOCKET__APPEND            0x00000200UL
29096 +#define NETLINK_TCPDIAG_SOCKET__BIND              0x00000400UL
29097 +#define NETLINK_TCPDIAG_SOCKET__CONNECT           0x00000800UL
29098 +#define NETLINK_TCPDIAG_SOCKET__LISTEN            0x00001000UL
29099 +#define NETLINK_TCPDIAG_SOCKET__ACCEPT            0x00002000UL
29100 +#define NETLINK_TCPDIAG_SOCKET__GETOPT            0x00004000UL
29101 +#define NETLINK_TCPDIAG_SOCKET__SETOPT            0x00008000UL
29102 +#define NETLINK_TCPDIAG_SOCKET__SHUTDOWN          0x00010000UL
29103 +#define NETLINK_TCPDIAG_SOCKET__RECVFROM          0x00020000UL
29104 +#define NETLINK_TCPDIAG_SOCKET__SENDTO            0x00040000UL
29105 +#define NETLINK_TCPDIAG_SOCKET__RECV_MSG          0x00080000UL
29106 +#define NETLINK_TCPDIAG_SOCKET__SEND_MSG          0x00100000UL
29107 +#define NETLINK_TCPDIAG_SOCKET__NAME_BIND         0x00200000UL
29108 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_READ        0x00400000UL
29109 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_WRITE       0x00800000UL
29110 +#define NETLINK_NFLOG_SOCKET__IOCTL               0x00000001UL
29111 +#define NETLINK_NFLOG_SOCKET__READ                0x00000002UL
29112 +#define NETLINK_NFLOG_SOCKET__WRITE               0x00000004UL
29113 +#define NETLINK_NFLOG_SOCKET__CREATE              0x00000008UL
29114 +#define NETLINK_NFLOG_SOCKET__GETATTR             0x00000010UL
29115 +#define NETLINK_NFLOG_SOCKET__SETATTR             0x00000020UL
29116 +#define NETLINK_NFLOG_SOCKET__LOCK                0x00000040UL
29117 +#define NETLINK_NFLOG_SOCKET__RELABELFROM         0x00000080UL
29118 +#define NETLINK_NFLOG_SOCKET__RELABELTO           0x00000100UL
29119 +#define NETLINK_NFLOG_SOCKET__APPEND              0x00000200UL
29120 +#define NETLINK_NFLOG_SOCKET__BIND                0x00000400UL
29121 +#define NETLINK_NFLOG_SOCKET__CONNECT             0x00000800UL
29122 +#define NETLINK_NFLOG_SOCKET__LISTEN              0x00001000UL
29123 +#define NETLINK_NFLOG_SOCKET__ACCEPT              0x00002000UL
29124 +#define NETLINK_NFLOG_SOCKET__GETOPT              0x00004000UL
29125 +#define NETLINK_NFLOG_SOCKET__SETOPT              0x00008000UL
29126 +#define NETLINK_NFLOG_SOCKET__SHUTDOWN            0x00010000UL
29127 +#define NETLINK_NFLOG_SOCKET__RECVFROM            0x00020000UL
29128 +#define NETLINK_NFLOG_SOCKET__SENDTO              0x00040000UL
29129 +#define NETLINK_NFLOG_SOCKET__RECV_MSG            0x00080000UL
29130 +#define NETLINK_NFLOG_SOCKET__SEND_MSG            0x00100000UL
29131 +#define NETLINK_NFLOG_SOCKET__NAME_BIND           0x00200000UL
29132 +#define NETLINK_XFRM_SOCKET__IOCTL                0x00000001UL
29133 +#define NETLINK_XFRM_SOCKET__READ                 0x00000002UL
29134 +#define NETLINK_XFRM_SOCKET__WRITE                0x00000004UL
29135 +#define NETLINK_XFRM_SOCKET__CREATE               0x00000008UL
29136 +#define NETLINK_XFRM_SOCKET__GETATTR              0x00000010UL
29137 +#define NETLINK_XFRM_SOCKET__SETATTR              0x00000020UL
29138 +#define NETLINK_XFRM_SOCKET__LOCK                 0x00000040UL
29139 +#define NETLINK_XFRM_SOCKET__RELABELFROM          0x00000080UL
29140 +#define NETLINK_XFRM_SOCKET__RELABELTO            0x00000100UL
29141 +#define NETLINK_XFRM_SOCKET__APPEND               0x00000200UL
29142 +#define NETLINK_XFRM_SOCKET__BIND                 0x00000400UL
29143 +#define NETLINK_XFRM_SOCKET__CONNECT              0x00000800UL
29144 +#define NETLINK_XFRM_SOCKET__LISTEN               0x00001000UL
29145 +#define NETLINK_XFRM_SOCKET__ACCEPT               0x00002000UL
29146 +#define NETLINK_XFRM_SOCKET__GETOPT               0x00004000UL
29147 +#define NETLINK_XFRM_SOCKET__SETOPT               0x00008000UL
29148 +#define NETLINK_XFRM_SOCKET__SHUTDOWN             0x00010000UL
29149 +#define NETLINK_XFRM_SOCKET__RECVFROM             0x00020000UL
29150 +#define NETLINK_XFRM_SOCKET__SENDTO               0x00040000UL
29151 +#define NETLINK_XFRM_SOCKET__RECV_MSG             0x00080000UL
29152 +#define NETLINK_XFRM_SOCKET__SEND_MSG             0x00100000UL
29153 +#define NETLINK_XFRM_SOCKET__NAME_BIND            0x00200000UL
29154 +#define NETLINK_XFRM_SOCKET__NLMSG_READ           0x00400000UL
29155 +#define NETLINK_XFRM_SOCKET__NLMSG_WRITE          0x00800000UL
29156 +#define NETLINK_SELINUX_SOCKET__IOCTL             0x00000001UL
29157 +#define NETLINK_SELINUX_SOCKET__READ              0x00000002UL
29158 +#define NETLINK_SELINUX_SOCKET__WRITE             0x00000004UL
29159 +#define NETLINK_SELINUX_SOCKET__CREATE            0x00000008UL
29160 +#define NETLINK_SELINUX_SOCKET__GETATTR           0x00000010UL
29161 +#define NETLINK_SELINUX_SOCKET__SETATTR           0x00000020UL
29162 +#define NETLINK_SELINUX_SOCKET__LOCK              0x00000040UL
29163 +#define NETLINK_SELINUX_SOCKET__RELABELFROM       0x00000080UL
29164 +#define NETLINK_SELINUX_SOCKET__RELABELTO         0x00000100UL
29165 +#define NETLINK_SELINUX_SOCKET__APPEND            0x00000200UL
29166 +#define NETLINK_SELINUX_SOCKET__BIND              0x00000400UL
29167 +#define NETLINK_SELINUX_SOCKET__CONNECT           0x00000800UL
29168 +#define NETLINK_SELINUX_SOCKET__LISTEN            0x00001000UL
29169 +#define NETLINK_SELINUX_SOCKET__ACCEPT            0x00002000UL
29170 +#define NETLINK_SELINUX_SOCKET__GETOPT            0x00004000UL
29171 +#define NETLINK_SELINUX_SOCKET__SETOPT            0x00008000UL
29172 +#define NETLINK_SELINUX_SOCKET__SHUTDOWN          0x00010000UL
29173 +#define NETLINK_SELINUX_SOCKET__RECVFROM          0x00020000UL
29174 +#define NETLINK_SELINUX_SOCKET__SENDTO            0x00040000UL
29175 +#define NETLINK_SELINUX_SOCKET__RECV_MSG          0x00080000UL
29176 +#define NETLINK_SELINUX_SOCKET__SEND_MSG          0x00100000UL
29177 +#define NETLINK_SELINUX_SOCKET__NAME_BIND         0x00200000UL
29178 +#define NETLINK_AUDIT_SOCKET__IOCTL               0x00000001UL
29179 +#define NETLINK_AUDIT_SOCKET__READ                0x00000002UL
29180 +#define NETLINK_AUDIT_SOCKET__WRITE               0x00000004UL
29181 +#define NETLINK_AUDIT_SOCKET__CREATE              0x00000008UL
29182 +#define NETLINK_AUDIT_SOCKET__GETATTR             0x00000010UL
29183 +#define NETLINK_AUDIT_SOCKET__SETATTR             0x00000020UL
29184 +#define NETLINK_AUDIT_SOCKET__LOCK                0x00000040UL
29185 +#define NETLINK_AUDIT_SOCKET__RELABELFROM         0x00000080UL
29186 +#define NETLINK_AUDIT_SOCKET__RELABELTO           0x00000100UL
29187 +#define NETLINK_AUDIT_SOCKET__APPEND              0x00000200UL
29188 +#define NETLINK_AUDIT_SOCKET__BIND                0x00000400UL
29189 +#define NETLINK_AUDIT_SOCKET__CONNECT             0x00000800UL
29190 +#define NETLINK_AUDIT_SOCKET__LISTEN              0x00001000UL
29191 +#define NETLINK_AUDIT_SOCKET__ACCEPT              0x00002000UL
29192 +#define NETLINK_AUDIT_SOCKET__GETOPT              0x00004000UL
29193 +#define NETLINK_AUDIT_SOCKET__SETOPT              0x00008000UL
29194 +#define NETLINK_AUDIT_SOCKET__SHUTDOWN            0x00010000UL
29195 +#define NETLINK_AUDIT_SOCKET__RECVFROM            0x00020000UL
29196 +#define NETLINK_AUDIT_SOCKET__SENDTO              0x00040000UL
29197 +#define NETLINK_AUDIT_SOCKET__RECV_MSG            0x00080000UL
29198 +#define NETLINK_AUDIT_SOCKET__SEND_MSG            0x00100000UL
29199 +#define NETLINK_AUDIT_SOCKET__NAME_BIND           0x00200000UL
29200 +#define NETLINK_AUDIT_SOCKET__NLMSG_READ          0x00400000UL
29201 +#define NETLINK_AUDIT_SOCKET__NLMSG_WRITE         0x00800000UL
29202 +#define NETLINK_AUDIT_SOCKET__NLMSG_RELAY         0x01000000UL
29203 +#define NETLINK_AUDIT_SOCKET__NLMSG_READPRIV      0x02000000UL
29204 +#define NETLINK_AUDIT_SOCKET__NLMSG_TTY_AUDIT     0x04000000UL
29205 +#define NETLINK_IP6FW_SOCKET__IOCTL               0x00000001UL
29206 +#define NETLINK_IP6FW_SOCKET__READ                0x00000002UL
29207 +#define NETLINK_IP6FW_SOCKET__WRITE               0x00000004UL
29208 +#define NETLINK_IP6FW_SOCKET__CREATE              0x00000008UL
29209 +#define NETLINK_IP6FW_SOCKET__GETATTR             0x00000010UL
29210 +#define NETLINK_IP6FW_SOCKET__SETATTR             0x00000020UL
29211 +#define NETLINK_IP6FW_SOCKET__LOCK                0x00000040UL
29212 +#define NETLINK_IP6FW_SOCKET__RELABELFROM         0x00000080UL
29213 +#define NETLINK_IP6FW_SOCKET__RELABELTO           0x00000100UL
29214 +#define NETLINK_IP6FW_SOCKET__APPEND              0x00000200UL
29215 +#define NETLINK_IP6FW_SOCKET__BIND                0x00000400UL
29216 +#define NETLINK_IP6FW_SOCKET__CONNECT             0x00000800UL
29217 +#define NETLINK_IP6FW_SOCKET__LISTEN              0x00001000UL
29218 +#define NETLINK_IP6FW_SOCKET__ACCEPT              0x00002000UL
29219 +#define NETLINK_IP6FW_SOCKET__GETOPT              0x00004000UL
29220 +#define NETLINK_IP6FW_SOCKET__SETOPT              0x00008000UL
29221 +#define NETLINK_IP6FW_SOCKET__SHUTDOWN            0x00010000UL
29222 +#define NETLINK_IP6FW_SOCKET__RECVFROM            0x00020000UL
29223 +#define NETLINK_IP6FW_SOCKET__SENDTO              0x00040000UL
29224 +#define NETLINK_IP6FW_SOCKET__RECV_MSG            0x00080000UL
29225 +#define NETLINK_IP6FW_SOCKET__SEND_MSG            0x00100000UL
29226 +#define NETLINK_IP6FW_SOCKET__NAME_BIND           0x00200000UL
29227 +#define NETLINK_IP6FW_SOCKET__NLMSG_READ          0x00400000UL
29228 +#define NETLINK_IP6FW_SOCKET__NLMSG_WRITE         0x00800000UL
29229 +#define NETLINK_DNRT_SOCKET__IOCTL                0x00000001UL
29230 +#define NETLINK_DNRT_SOCKET__READ                 0x00000002UL
29231 +#define NETLINK_DNRT_SOCKET__WRITE                0x00000004UL
29232 +#define NETLINK_DNRT_SOCKET__CREATE               0x00000008UL
29233 +#define NETLINK_DNRT_SOCKET__GETATTR              0x00000010UL
29234 +#define NETLINK_DNRT_SOCKET__SETATTR              0x00000020UL
29235 +#define NETLINK_DNRT_SOCKET__LOCK                 0x00000040UL
29236 +#define NETLINK_DNRT_SOCKET__RELABELFROM          0x00000080UL
29237 +#define NETLINK_DNRT_SOCKET__RELABELTO            0x00000100UL
29238 +#define NETLINK_DNRT_SOCKET__APPEND               0x00000200UL
29239 +#define NETLINK_DNRT_SOCKET__BIND                 0x00000400UL
29240 +#define NETLINK_DNRT_SOCKET__CONNECT              0x00000800UL
29241 +#define NETLINK_DNRT_SOCKET__LISTEN               0x00001000UL
29242 +#define NETLINK_DNRT_SOCKET__ACCEPT               0x00002000UL
29243 +#define NETLINK_DNRT_SOCKET__GETOPT               0x00004000UL
29244 +#define NETLINK_DNRT_SOCKET__SETOPT               0x00008000UL
29245 +#define NETLINK_DNRT_SOCKET__SHUTDOWN             0x00010000UL
29246 +#define NETLINK_DNRT_SOCKET__RECVFROM             0x00020000UL
29247 +#define NETLINK_DNRT_SOCKET__SENDTO               0x00040000UL
29248 +#define NETLINK_DNRT_SOCKET__RECV_MSG             0x00080000UL
29249 +#define NETLINK_DNRT_SOCKET__SEND_MSG             0x00100000UL
29250 +#define NETLINK_DNRT_SOCKET__NAME_BIND            0x00200000UL
29251 +#define ASSOCIATION__SENDTO                       0x00000001UL
29252 +#define ASSOCIATION__RECVFROM                     0x00000002UL
29253 +#define ASSOCIATION__SETCONTEXT                   0x00000004UL
29254 +#define ASSOCIATION__POLMATCH                     0x00000008UL
29255 +#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL      0x00000001UL
29256 +#define NETLINK_KOBJECT_UEVENT_SOCKET__READ       0x00000002UL
29257 +#define NETLINK_KOBJECT_UEVENT_SOCKET__WRITE      0x00000004UL
29258 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CREATE     0x00000008UL
29259 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETATTR    0x00000010UL
29260 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETATTR    0x00000020UL
29261 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LOCK       0x00000040UL
29262 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELFROM 0x00000080UL
29263 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELTO  0x00000100UL
29264 +#define NETLINK_KOBJECT_UEVENT_SOCKET__APPEND     0x00000200UL
29265 +#define NETLINK_KOBJECT_UEVENT_SOCKET__BIND       0x00000400UL
29266 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CONNECT    0x00000800UL
29267 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LISTEN     0x00001000UL
29268 +#define NETLINK_KOBJECT_UEVENT_SOCKET__ACCEPT     0x00002000UL
29269 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETOPT     0x00004000UL
29270 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETOPT     0x00008000UL
29271 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SHUTDOWN   0x00010000UL
29272 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECVFROM   0x00020000UL
29273 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SENDTO     0x00040000UL
29274 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECV_MSG   0x00080000UL
29275 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SEND_MSG   0x00100000UL
29276 +#define NETLINK_KOBJECT_UEVENT_SOCKET__NAME_BIND  0x00200000UL
29277 +#define APPLETALK_SOCKET__IOCTL                   0x00000001UL
29278 +#define APPLETALK_SOCKET__READ                    0x00000002UL
29279 +#define APPLETALK_SOCKET__WRITE                   0x00000004UL
29280 +#define APPLETALK_SOCKET__CREATE                  0x00000008UL
29281 +#define APPLETALK_SOCKET__GETATTR                 0x00000010UL
29282 +#define APPLETALK_SOCKET__SETATTR                 0x00000020UL
29283 +#define APPLETALK_SOCKET__LOCK                    0x00000040UL
29284 +#define APPLETALK_SOCKET__RELABELFROM             0x00000080UL
29285 +#define APPLETALK_SOCKET__RELABELTO               0x00000100UL
29286 +#define APPLETALK_SOCKET__APPEND                  0x00000200UL
29287 +#define APPLETALK_SOCKET__BIND                    0x00000400UL
29288 +#define APPLETALK_SOCKET__CONNECT                 0x00000800UL
29289 +#define APPLETALK_SOCKET__LISTEN                  0x00001000UL
29290 +#define APPLETALK_SOCKET__ACCEPT                  0x00002000UL
29291 +#define APPLETALK_SOCKET__GETOPT                  0x00004000UL
29292 +#define APPLETALK_SOCKET__SETOPT                  0x00008000UL
29293 +#define APPLETALK_SOCKET__SHUTDOWN                0x00010000UL
29294 +#define APPLETALK_SOCKET__RECVFROM                0x00020000UL
29295 +#define APPLETALK_SOCKET__SENDTO                  0x00040000UL
29296 +#define APPLETALK_SOCKET__RECV_MSG                0x00080000UL
29297 +#define APPLETALK_SOCKET__SEND_MSG                0x00100000UL
29298 +#define APPLETALK_SOCKET__NAME_BIND               0x00200000UL
29299 +#define PACKET__SEND                              0x00000001UL
29300 +#define PACKET__RECV                              0x00000002UL
29301 +#define PACKET__RELABELTO                         0x00000004UL
29302 +#define PACKET__FLOW_IN                           0x00000008UL
29303 +#define PACKET__FLOW_OUT                          0x00000010UL
29304 +#define PACKET__FORWARD_IN                        0x00000020UL
29305 +#define PACKET__FORWARD_OUT                       0x00000040UL
29306 +#define KEY__VIEW                                 0x00000001UL
29307 +#define KEY__READ                                 0x00000002UL
29308 +#define KEY__WRITE                                0x00000004UL
29309 +#define KEY__SEARCH                               0x00000008UL
29310 +#define KEY__LINK                                 0x00000010UL
29311 +#define KEY__SETATTR                              0x00000020UL
29312 +#define KEY__CREATE                               0x00000040UL
29313 +#define DCCP_SOCKET__IOCTL                        0x00000001UL
29314 +#define DCCP_SOCKET__READ                         0x00000002UL
29315 +#define DCCP_SOCKET__WRITE                        0x00000004UL
29316 +#define DCCP_SOCKET__CREATE                       0x00000008UL
29317 +#define DCCP_SOCKET__GETATTR                      0x00000010UL
29318 +#define DCCP_SOCKET__SETATTR                      0x00000020UL
29319 +#define DCCP_SOCKET__LOCK                         0x00000040UL
29320 +#define DCCP_SOCKET__RELABELFROM                  0x00000080UL
29321 +#define DCCP_SOCKET__RELABELTO                    0x00000100UL
29322 +#define DCCP_SOCKET__APPEND                       0x00000200UL
29323 +#define DCCP_SOCKET__BIND                         0x00000400UL
29324 +#define DCCP_SOCKET__CONNECT                      0x00000800UL
29325 +#define DCCP_SOCKET__LISTEN                       0x00001000UL
29326 +#define DCCP_SOCKET__ACCEPT                       0x00002000UL
29327 +#define DCCP_SOCKET__GETOPT                       0x00004000UL
29328 +#define DCCP_SOCKET__SETOPT                       0x00008000UL
29329 +#define DCCP_SOCKET__SHUTDOWN                     0x00010000UL
29330 +#define DCCP_SOCKET__RECVFROM                     0x00020000UL
29331 +#define DCCP_SOCKET__SENDTO                       0x00040000UL
29332 +#define DCCP_SOCKET__RECV_MSG                     0x00080000UL
29333 +#define DCCP_SOCKET__SEND_MSG                     0x00100000UL
29334 +#define DCCP_SOCKET__NAME_BIND                    0x00200000UL
29335 +#define DCCP_SOCKET__NODE_BIND                    0x00400000UL
29336 +#define DCCP_SOCKET__NAME_CONNECT                 0x00800000UL
29337 +#define MEMPROTECT__MMAP_ZERO                     0x00000001UL
29338 +#define PEER__RECV                                0x00000001UL
29339 +#define CAPABILITY2__MAC_OVERRIDE                 0x00000001UL
29340 +#define CAPABILITY2__MAC_ADMIN                    0x00000002UL
29341 +#define KERNEL_SERVICE__USE_AS_OVERRIDE           0x00000001UL
29342 +#define KERNEL_SERVICE__CREATE_FILES_AS           0x00000002UL
29343 +#define TUN_SOCKET__IOCTL                         0x00000001UL
29344 +#define TUN_SOCKET__READ                          0x00000002UL
29345 +#define TUN_SOCKET__WRITE                         0x00000004UL
29346 +#define TUN_SOCKET__CREATE                        0x00000008UL
29347 +#define TUN_SOCKET__GETATTR                       0x00000010UL
29348 +#define TUN_SOCKET__SETATTR                       0x00000020UL
29349 +#define TUN_SOCKET__LOCK                          0x00000040UL
29350 +#define TUN_SOCKET__RELABELFROM                   0x00000080UL
29351 +#define TUN_SOCKET__RELABELTO                     0x00000100UL
29352 +#define TUN_SOCKET__APPEND                        0x00000200UL
29353 +#define TUN_SOCKET__BIND                          0x00000400UL
29354 +#define TUN_SOCKET__CONNECT                       0x00000800UL
29355 +#define TUN_SOCKET__LISTEN                        0x00001000UL
29356 +#define TUN_SOCKET__ACCEPT                        0x00002000UL
29357 +#define TUN_SOCKET__GETOPT                        0x00004000UL
29358 +#define TUN_SOCKET__SETOPT                        0x00008000UL
29359 +#define TUN_SOCKET__SHUTDOWN                      0x00010000UL
29360 +#define TUN_SOCKET__RECVFROM                      0x00020000UL
29361 +#define TUN_SOCKET__SENDTO                        0x00040000UL
29362 +#define TUN_SOCKET__RECV_MSG                      0x00080000UL
29363 +#define TUN_SOCKET__SEND_MSG                      0x00100000UL
29364 +#define TUN_SOCKET__NAME_BIND                     0x00200000UL
29365 +
29366 +#endif
29367 diff -NurpP --minimal linux-2.6.35.2/security/selinux/hooks.c linux-2.6.35.2-vs2.3.0.36.31/security/selinux/hooks.c
29368 --- linux-2.6.35.2/security/selinux/hooks.c     2010-08-02 16:53:03.000000000 +0200
29369 +++ linux-2.6.35.2-vs2.3.0.36.31/security/selinux/hooks.c       2010-08-02 17:05:06.000000000 +0200
29370 @@ -64,7 +64,6 @@
29371  #include <linux/dccp.h>
29372  #include <linux/quota.h>
29373  #include <linux/un.h>          /* for Unix socket types */
29374 -#include <net/af_unix.h>       /* for Unix socket types */
29375  #include <linux/parser.h>
29376  #include <linux/nfs_mount.h>
29377  #include <net/ipv6.h>
This page took 3.629992 seconds and 4 git commands to generate.