]> git.pld-linux.org Git - packages/kernel.git/blob - kernel-vserver-2.3.patch
- vserver patch up to patch-2.6.34-vs2.3.0.36.30.4.pre6.diff
[packages/kernel.git] / kernel-vserver-2.3.patch
1 diff -NurpP --minimal linux-2.6.34/arch/alpha/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/Kconfig
2 --- linux-2.6.34/arch/alpha/Kconfig     2010-05-18 15:07:43.000000000 +0200
3 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/Kconfig        2010-05-18 18:11:22.000000000 +0200
4 @@ -679,6 +679,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.34/arch/alpha/kernel/entry.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/kernel/entry.S
14 --- linux-2.6.34/arch/alpha/kernel/entry.S      2009-06-11 17:11:46.000000000 +0200
15 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/kernel/entry.S 2010-05-18 18:11:22.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.34/arch/alpha/kernel/osf_sys.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.34/arch/alpha/kernel/osf_sys.c    2010-05-18 15:07:43.000000000 +0200
50 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/kernel/osf_sys.c       2010-05-18 18:11:22.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.34/arch/alpha/kernel/ptrace.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.34/arch/alpha/kernel/ptrace.c     2010-05-18 15:07:43.000000000 +0200
62 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/kernel/ptrace.c        2010-05-18 18:11:22.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.34/arch/alpha/kernel/systbls.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/kernel/systbls.S
72 --- linux-2.6.34/arch/alpha/kernel/systbls.S    2010-02-25 11:51:19.000000000 +0100
73 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/kernel/systbls.S       2010-05-18 18:11:22.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.34/arch/alpha/kernel/traps.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/kernel/traps.c
84 --- linux-2.6.34/arch/alpha/kernel/traps.c      2010-05-18 15:07:43.000000000 +0200
85 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/kernel/traps.c 2010-05-18 18:11:22.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.34/arch/alpha/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/mm/fault.c
97 --- linux-2.6.34/arch/alpha/mm/fault.c  2009-09-10 15:25:14.000000000 +0200
98 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/alpha/mm/fault.c     2010-05-18 18:11:22.000000000 +0200
99 @@ -193,8 +193,8 @@ do_page_fault(unsigned long address, uns
100                 down_read(&mm->mmap_sem);
101                 goto survive;
102         }
103 -       printk(KERN_ALERT "VM: killing process %s(%d)\n",
104 -              current->comm, task_pid_nr(current));
105 +       printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
106 +              current->comm, task_pid_nr(current), current->xid);
107         if (!user_mode(regs))
108                 goto no_context;
109         do_group_exit(SIGKILL);
110 diff -NurpP --minimal linux-2.6.34/arch/arm/include/asm/tlb.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/arm/include/asm/tlb.h
111 --- linux-2.6.34/arch/arm/include/asm/tlb.h     2009-09-10 15:25:15.000000000 +0200
112 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/arm/include/asm/tlb.h        2010-05-18 18:11:22.000000000 +0200
113 @@ -27,6 +27,7 @@
114  
115  #else /* !CONFIG_MMU */
116  
117 +#include <linux/vs_memory.h>
118  #include <asm/pgalloc.h>
119  
120  /*
121 diff -NurpP --minimal linux-2.6.34/arch/arm/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/arm/Kconfig
122 --- linux-2.6.34/arch/arm/Kconfig       2010-05-18 15:07:43.000000000 +0200
123 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/arm/Kconfig  2010-05-18 18:11:22.000000000 +0200
124 @@ -1655,6 +1655,8 @@ source "fs/Kconfig"
125  
126  source "arch/arm/Kconfig.debug"
127  
128 +source "kernel/vserver/Kconfig"
129 +
130  source "security/Kconfig"
131  
132  source "crypto/Kconfig"
133 diff -NurpP --minimal linux-2.6.34/arch/arm/kernel/calls.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/arm/kernel/calls.S
134 --- linux-2.6.34/arch/arm/kernel/calls.S        2010-05-18 15:07:43.000000000 +0200
135 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/arm/kernel/calls.S   2010-05-18 18:11:22.000000000 +0200
136 @@ -322,7 +322,7 @@
137  /* 310 */      CALL(sys_request_key)
138                 CALL(sys_keyctl)
139                 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
140 -/* vserver */  CALL(sys_ni_syscall)
141 +               CALL(sys_vserver)
142                 CALL(sys_ioprio_set)
143  /* 315 */      CALL(sys_ioprio_get)
144                 CALL(sys_inotify_init)
145 diff -NurpP --minimal linux-2.6.34/arch/arm/kernel/process.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/arm/kernel/process.c
146 --- linux-2.6.34/arch/arm/kernel/process.c      2010-05-18 15:07:43.000000000 +0200
147 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/arm/kernel/process.c 2010-05-18 18:11:22.000000000 +0200
148 @@ -269,7 +269,8 @@ void __show_regs(struct pt_regs *regs)
149  void show_regs(struct pt_regs * regs)
150  {
151         printk("\n");
152 -       printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
153 +       printk("Pid: %d[#%u], comm: %20s\n",
154 +               task_pid_nr(current), current->xid, current->comm);
155         __show_regs(regs);
156         __backtrace();
157  }
158 diff -NurpP --minimal linux-2.6.34/arch/arm/kernel/traps.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/arm/kernel/traps.c
159 --- linux-2.6.34/arch/arm/kernel/traps.c        2010-05-18 15:07:43.000000000 +0200
160 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/arm/kernel/traps.c   2010-05-18 18:11:22.000000000 +0200
161 @@ -243,8 +243,8 @@ static int __die(const char *str, int er
162  
163         print_modules();
164         __show_regs(regs);
165 -       printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
166 -               TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
167 +       printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
168 +               TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
169  
170         if (!user_mode(regs) || in_interrupt()) {
171                 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
172 diff -NurpP --minimal linux-2.6.34/arch/avr32/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/avr32/mm/fault.c
173 --- linux-2.6.34/arch/avr32/mm/fault.c  2009-09-10 15:25:20.000000000 +0200
174 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/avr32/mm/fault.c     2010-05-18 18:11:22.000000000 +0200
175 @@ -216,7 +216,8 @@ out_of_memory:
176                 down_read(&mm->mmap_sem);
177                 goto survive;
178         }
179 -       printk("VM: Killing process %s\n", tsk->comm);
180 +       printk("VM: Killing process %s(%d:#%u)\n",
181 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
182         if (user_mode(regs))
183                 do_group_exit(SIGKILL);
184         goto no_context;
185 diff -NurpP --minimal linux-2.6.34/arch/cris/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/cris/Kconfig
186 --- linux-2.6.34/arch/cris/Kconfig      2010-05-18 15:07:44.000000000 +0200
187 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/cris/Kconfig 2010-05-18 18:11:22.000000000 +0200
188 @@ -691,6 +691,8 @@ source "drivers/staging/Kconfig"
189  
190  source "arch/cris/Kconfig.debug"
191  
192 +source "kernel/vserver/Kconfig"
193 +
194  source "security/Kconfig"
195  
196  source "crypto/Kconfig"
197 diff -NurpP --minimal linux-2.6.34/arch/cris/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/cris/mm/fault.c
198 --- linux-2.6.34/arch/cris/mm/fault.c   2010-02-25 11:51:26.000000000 +0100
199 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/cris/mm/fault.c      2010-05-18 18:11:22.000000000 +0200
200 @@ -245,7 +245,8 @@ do_page_fault(unsigned long address, str
201  
202   out_of_memory:
203         up_read(&mm->mmap_sem);
204 -       printk("VM: killing process %s\n", tsk->comm);
205 +       printk("VM: killing process %s(%d:#%u)\n",
206 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
207         if (user_mode(regs))
208                 do_exit(SIGKILL);
209         goto no_context;
210 diff -NurpP --minimal linux-2.6.34/arch/frv/kernel/kernel_thread.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/frv/kernel/kernel_thread.S
211 --- linux-2.6.34/arch/frv/kernel/kernel_thread.S        2008-12-25 00:26:37.000000000 +0100
212 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/frv/kernel/kernel_thread.S   2010-05-18 18:11:22.000000000 +0200
213 @@ -37,7 +37,7 @@ kernel_thread:
214  
215         # start by forking the current process, but with shared VM
216         setlos.p        #__NR_clone,gr7         ; syscall number
217 -       ori             gr10,#CLONE_VM,gr8      ; first syscall arg     [clone_flags]
218 +       ori             gr10,#CLONE_KT,gr8      ; first syscall arg     [clone_flags]
219         sethi.p         #0xe4e4,gr9             ; second syscall arg    [newsp]
220         setlo           #0xe4e4,gr9
221         setlos.p        #0,gr10                 ; third syscall arg     [parent_tidptr]
222 diff -NurpP --minimal linux-2.6.34/arch/frv/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/frv/mm/fault.c
223 --- linux-2.6.34/arch/frv/mm/fault.c    2009-09-10 15:25:22.000000000 +0200
224 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/frv/mm/fault.c       2010-05-18 18:11:22.000000000 +0200
225 @@ -257,7 +257,8 @@ asmlinkage void do_page_fault(int datamm
226   */
227   out_of_memory:
228         up_read(&mm->mmap_sem);
229 -       printk("VM: killing process %s\n", current->comm);
230 +       printk("VM: killing process %s(%d:#%u)\n",
231 +               current->comm, task_pid_nr(current), current->xid);
232         if (user_mode(__frame))
233                 do_group_exit(SIGKILL);
234         goto no_context;
235 diff -NurpP --minimal linux-2.6.34/arch/h8300/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/h8300/Kconfig
236 --- linux-2.6.34/arch/h8300/Kconfig     2010-02-25 11:51:26.000000000 +0100
237 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/h8300/Kconfig        2010-05-18 18:11:22.000000000 +0200
238 @@ -230,6 +230,8 @@ source "fs/Kconfig"
239  
240  source "arch/h8300/Kconfig.debug"
241  
242 +source "kernel/vserver/Kconfig"
243 +
244  source "security/Kconfig"
245  
246  source "crypto/Kconfig"
247 diff -NurpP --minimal linux-2.6.34/arch/ia64/include/asm/tlb.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/include/asm/tlb.h
248 --- linux-2.6.34/arch/ia64/include/asm/tlb.h    2010-02-25 11:51:26.000000000 +0100
249 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/include/asm/tlb.h       2010-05-18 18:11:22.000000000 +0200
250 @@ -40,6 +40,7 @@
251  #include <linux/mm.h>
252  #include <linux/pagemap.h>
253  #include <linux/swap.h>
254 +#include <linux/vs_memory.h>
255  
256  #include <asm/pgalloc.h>
257  #include <asm/processor.h>
258 diff -NurpP --minimal linux-2.6.34/arch/ia64/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/Kconfig
259 --- linux-2.6.34/arch/ia64/Kconfig      2010-05-18 15:07:44.000000000 +0200
260 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/Kconfig 2010-05-18 18:11:22.000000000 +0200
261 @@ -668,6 +668,8 @@ source "fs/Kconfig"
262  
263  source "arch/ia64/Kconfig.debug"
264  
265 +source "kernel/vserver/Kconfig"
266 +
267  source "security/Kconfig"
268  
269  source "crypto/Kconfig"
270 diff -NurpP --minimal linux-2.6.34/arch/ia64/kernel/entry.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/kernel/entry.S
271 --- linux-2.6.34/arch/ia64/kernel/entry.S       2010-05-18 15:07:44.000000000 +0200
272 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/kernel/entry.S  2010-05-18 18:11:22.000000000 +0200
273 @@ -1714,7 +1714,7 @@ sys_call_table:
274         data8 sys_mq_notify
275         data8 sys_mq_getsetattr
276         data8 sys_kexec_load
277 -       data8 sys_ni_syscall                    // reserved for vserver
278 +       data8 sys_vserver
279         data8 sys_waitid                        // 1270
280         data8 sys_add_key
281         data8 sys_request_key
282 diff -NurpP --minimal linux-2.6.34/arch/ia64/kernel/perfmon.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/kernel/perfmon.c
283 --- linux-2.6.34/arch/ia64/kernel/perfmon.c     2010-05-18 15:07:44.000000000 +0200
284 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/kernel/perfmon.c        2010-05-19 03:10:18.000000000 +0200
285 @@ -42,6 +42,7 @@
286  #include <linux/completion.h>
287  #include <linux/tracehook.h>
288  #include <linux/slab.h>
289 +#include <linux/vs_memory.h>
290  
291  #include <asm/errno.h>
292  #include <asm/intrinsics.h>
293 diff -NurpP --minimal linux-2.6.34/arch/ia64/kernel/process.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/kernel/process.c
294 --- linux-2.6.34/arch/ia64/kernel/process.c     2010-05-18 15:07:44.000000000 +0200
295 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/kernel/process.c        2010-05-18 18:11:22.000000000 +0200
296 @@ -113,8 +113,8 @@ show_regs (struct pt_regs *regs)
297         unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
298  
299         print_modules();
300 -       printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
301 -                       smp_processor_id(), current->comm);
302 +       printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
303 +                       current->xid, smp_processor_id(), current->comm);
304         printk("psr : %016lx ifs : %016lx ip  : [<%016lx>]    %s (%s)\n",
305                regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
306                init_utsname()->release);
307 diff -NurpP --minimal linux-2.6.34/arch/ia64/kernel/ptrace.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/kernel/ptrace.c
308 --- linux-2.6.34/arch/ia64/kernel/ptrace.c      2010-05-18 15:07:44.000000000 +0200
309 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/kernel/ptrace.c 2010-05-18 18:11:22.000000000 +0200
310 @@ -21,6 +21,7 @@
311  #include <linux/regset.h>
312  #include <linux/elf.h>
313  #include <linux/tracehook.h>
314 +#include <linux/vs_base.h>
315  
316  #include <asm/pgtable.h>
317  #include <asm/processor.h>
318 diff -NurpP --minimal linux-2.6.34/arch/ia64/kernel/traps.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/kernel/traps.c
319 --- linux-2.6.34/arch/ia64/kernel/traps.c       2010-05-18 15:07:44.000000000 +0200
320 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/kernel/traps.c  2010-05-18 18:11:22.000000000 +0200
321 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
322         put_cpu();
323  
324         if (++die.lock_owner_depth < 3) {
325 -               printk("%s[%d]: %s %ld [%d]\n",
326 -               current->comm, task_pid_nr(current), str, err, ++die_counter);
327 +               printk("%s[%d[#%u]]: %s %ld [%d]\n",
328 +                       current->comm, task_pid_nr(current), current->xid,
329 +                       str, err, ++die_counter);
330                 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
331                     != NOTIFY_STOP)
332                         show_regs(regs);
333 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
334                         if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
335                                 last.time = current_jiffies + 5 * HZ;
336                                 printk(KERN_WARNING
337 -                                       "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
338 -                                       current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
339 +                                       "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
340 +                                       current->comm, task_pid_nr(current), current->xid,
341 +                                       regs->cr_iip + ia64_psr(regs)->ri, isr);
342                         }
343                 }
344         }
345 diff -NurpP --minimal linux-2.6.34/arch/ia64/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/mm/fault.c
346 --- linux-2.6.34/arch/ia64/mm/fault.c   2009-09-10 15:25:23.000000000 +0200
347 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/ia64/mm/fault.c      2010-05-18 18:11:22.000000000 +0200
348 @@ -10,6 +10,7 @@
349  #include <linux/interrupt.h>
350  #include <linux/kprobes.h>
351  #include <linux/kdebug.h>
352 +#include <linux/vs_memory.h>
353  
354  #include <asm/pgtable.h>
355  #include <asm/processor.h>
356 @@ -281,7 +282,8 @@ ia64_do_page_fault (unsigned long addres
357                 down_read(&mm->mmap_sem);
358                 goto survive;
359         }
360 -       printk(KERN_CRIT "VM: killing process %s\n", current->comm);
361 +       printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
362 +               current->comm, task_pid_nr(current), current->xid);
363         if (user_mode(regs))
364                 do_group_exit(SIGKILL);
365         goto no_context;
366 diff -NurpP --minimal linux-2.6.34/arch/m32r/kernel/traps.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m32r/kernel/traps.c
367 --- linux-2.6.34/arch/m32r/kernel/traps.c       2009-12-03 20:01:57.000000000 +0100
368 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m32r/kernel/traps.c  2010-05-18 18:11:22.000000000 +0200
369 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
370         } else {
371                 printk("SPI: %08lx\n", sp);
372         }
373 -       printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
374 -               current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
375 +       printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
376 +               current->comm, task_pid_nr(current), current->xid,
377 +               0xffff & i, 4096+(unsigned long)current);
378  
379         /*
380          * When in-kernel, we also print out the stack and code at the
381 diff -NurpP --minimal linux-2.6.34/arch/m32r/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m32r/mm/fault.c
382 --- linux-2.6.34/arch/m32r/mm/fault.c   2010-05-18 15:07:44.000000000 +0200
383 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m32r/mm/fault.c      2010-05-18 18:11:22.000000000 +0200
384 @@ -276,7 +276,8 @@ out_of_memory:
385                 down_read(&mm->mmap_sem);
386                 goto survive;
387         }
388 -       printk("VM: killing process %s\n", tsk->comm);
389 +       printk("VM: killing process %s(%d:#%u)\n",
390 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
391         if (error_code & ACE_USERMODE)
392                 do_group_exit(SIGKILL);
393         goto no_context;
394 diff -NurpP --minimal linux-2.6.34/arch/m68k/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68k/Kconfig
395 --- linux-2.6.34/arch/m68k/Kconfig      2010-05-18 15:07:44.000000000 +0200
396 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68k/Kconfig 2010-05-18 18:11:22.000000000 +0200
397 @@ -618,6 +618,8 @@ source "fs/Kconfig"
398  
399  source "arch/m68k/Kconfig.debug"
400  
401 +source "kernel/vserver/Kconfig"
402 +
403  source "security/Kconfig"
404  
405  source "crypto/Kconfig"
406 diff -NurpP --minimal linux-2.6.34/arch/m68k/kernel/ptrace.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68k/kernel/ptrace.c
407 --- linux-2.6.34/arch/m68k/kernel/ptrace.c      2010-05-18 15:07:44.000000000 +0200
408 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68k/kernel/ptrace.c 2010-05-18 18:11:22.000000000 +0200
409 @@ -18,6 +18,7 @@
410  #include <linux/ptrace.h>
411  #include <linux/user.h>
412  #include <linux/signal.h>
413 +#include <linux/vs_base.h>
414  
415  #include <asm/uaccess.h>
416  #include <asm/page.h>
417 @@ -254,6 +255,8 @@ long arch_ptrace(struct task_struct *chi
418                 ret = ptrace_request(child, request, addr, data);
419                 break;
420         }
421 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
422 +               goto out_tsk;
423  
424         return ret;
425  out_eio:
426 diff -NurpP --minimal linux-2.6.34/arch/m68k/kernel/traps.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68k/kernel/traps.c
427 --- linux-2.6.34/arch/m68k/kernel/traps.c       2009-09-10 15:25:23.000000000 +0200
428 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68k/kernel/traps.c  2010-05-18 18:11:22.000000000 +0200
429 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
430         printk("d4: %08lx    d5: %08lx    a0: %08lx    a1: %08lx\n",
431                regs->d4, regs->d5, regs->a0, regs->a1);
432  
433 -       printk("Process %s (pid: %d, task=%p)\n",
434 -               current->comm, task_pid_nr(current), current);
435 +       printk("Process %s (pid: %d[#%u], task=%p)\n",
436 +               current->comm, task_pid_nr(current), current->xid, current);
437         addr = (unsigned long)&fp->un;
438         printk("Frame format=%X ", regs->format);
439         switch (regs->format) {
440 diff -NurpP --minimal linux-2.6.34/arch/m68k/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68k/mm/fault.c
441 --- linux-2.6.34/arch/m68k/mm/fault.c   2009-09-10 15:25:23.000000000 +0200
442 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68k/mm/fault.c      2010-05-18 18:11:22.000000000 +0200
443 @@ -186,7 +186,8 @@ out_of_memory:
444                 goto survive;
445         }
446  
447 -       printk("VM: killing process %s\n", current->comm);
448 +       printk("VM: killing process %s(%d:#%u)\n",
449 +               current->comm, task_pid_nr(current), current->xid);
450         if (user_mode(regs))
451                 do_group_exit(SIGKILL);
452  
453 diff -NurpP --minimal linux-2.6.34/arch/m68knommu/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68knommu/Kconfig
454 --- linux-2.6.34/arch/m68knommu/Kconfig 2010-02-25 11:51:27.000000000 +0100
455 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68knommu/Kconfig    2010-05-18 18:11:22.000000000 +0200
456 @@ -734,6 +734,8 @@ source "fs/Kconfig"
457  
458  source "arch/m68knommu/Kconfig.debug"
459  
460 +source "kernel/vserver/Kconfig"
461 +
462  source "security/Kconfig"
463  
464  source "crypto/Kconfig"
465 diff -NurpP --minimal linux-2.6.34/arch/m68knommu/kernel/traps.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68knommu/kernel/traps.c
466 --- linux-2.6.34/arch/m68knommu/kernel/traps.c  2009-09-10 15:25:23.000000000 +0200
467 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/m68knommu/kernel/traps.c     2010-05-18 18:11:22.000000000 +0200
468 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
469         printk(KERN_EMERG "d4: %08lx    d5: %08lx    a0: %08lx    a1: %08lx\n",
470                fp->d4, fp->d5, fp->a0, fp->a1);
471  
472 -       printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
473 -               current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
474 +       printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
475 +               current->comm, task_pid_nr(current), current->xid,
476 +               PAGE_SIZE+(unsigned long)current);
477         show_stack(NULL, (unsigned long *)(fp + 1));
478         add_taint(TAINT_DIE);
479         do_exit(SIGSEGV);
480 diff -NurpP --minimal linux-2.6.34/arch/mips/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/Kconfig
481 --- linux-2.6.34/arch/mips/Kconfig      2010-05-18 15:07:44.000000000 +0200
482 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/Kconfig 2010-05-18 18:11:22.000000000 +0200
483 @@ -2251,6 +2251,8 @@ source "fs/Kconfig"
484  
485  source "arch/mips/Kconfig.debug"
486  
487 +source "kernel/vserver/Kconfig"
488 +
489  source "security/Kconfig"
490  
491  source "crypto/Kconfig"
492 diff -NurpP --minimal linux-2.6.34/arch/mips/kernel/ptrace.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/ptrace.c
493 --- linux-2.6.34/arch/mips/kernel/ptrace.c      2010-05-18 15:07:44.000000000 +0200
494 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/ptrace.c 2010-05-18 18:11:22.000000000 +0200
495 @@ -25,6 +25,7 @@
496  #include <linux/security.h>
497  #include <linux/audit.h>
498  #include <linux/seccomp.h>
499 +#include <linux/vs_base.h>
500  
501  #include <asm/byteorder.h>
502  #include <asm/cpu.h>
503 @@ -259,6 +260,9 @@ long arch_ptrace(struct task_struct *chi
504  {
505         int ret;
506  
507 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
508 +               goto out;
509 +
510         switch (request) {
511         /* when I and D space are separate, these will need to be fixed. */
512         case PTRACE_PEEKTEXT: /* read word at location addr. */
513 diff -NurpP --minimal linux-2.6.34/arch/mips/kernel/scall32-o32.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/scall32-o32.S
514 --- linux-2.6.34/arch/mips/kernel/scall32-o32.S 2010-02-25 11:51:28.000000000 +0100
515 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/scall32-o32.S    2010-05-18 18:11:22.000000000 +0200
516 @@ -525,7 +525,7 @@ einval:     li      v0, -ENOSYS
517         sys     sys_mq_timedreceive     5
518         sys     sys_mq_notify           2       /* 4275 */
519         sys     sys_mq_getsetattr       3
520 -       sys     sys_ni_syscall          0       /* sys_vserver */
521 +       sys     sys_vserver             3
522         sys     sys_waitid              5
523         sys     sys_ni_syscall          0       /* available, was setaltroot */
524         sys     sys_add_key             5       /* 4280 */
525 diff -NurpP --minimal linux-2.6.34/arch/mips/kernel/scall64-64.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/scall64-64.S
526 --- linux-2.6.34/arch/mips/kernel/scall64-64.S  2010-02-25 11:51:28.000000000 +0100
527 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/scall64-64.S     2010-05-18 18:11:22.000000000 +0200
528 @@ -362,7 +362,7 @@ sys_call_table:
529         PTR     sys_mq_timedreceive
530         PTR     sys_mq_notify
531         PTR     sys_mq_getsetattr               /* 5235 */
532 -       PTR     sys_ni_syscall                  /* sys_vserver */
533 +       PTR     sys_vserver
534         PTR     sys_waitid
535         PTR     sys_ni_syscall                  /* available, was setaltroot */
536         PTR     sys_add_key
537 diff -NurpP --minimal linux-2.6.34/arch/mips/kernel/scall64-n32.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/scall64-n32.S
538 --- linux-2.6.34/arch/mips/kernel/scall64-n32.S 2010-05-18 15:07:44.000000000 +0200
539 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/scall64-n32.S    2010-05-18 18:11:22.000000000 +0200
540 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
541         PTR     compat_sys_mq_timedreceive
542         PTR     compat_sys_mq_notify
543         PTR     compat_sys_mq_getsetattr
544 -       PTR     sys_ni_syscall                  /* 6240, sys_vserver */
545 +       PTR     sys32_vserver                   /* 6240 */
546         PTR     compat_sys_waitid
547         PTR     sys_ni_syscall                  /* available, was setaltroot */
548         PTR     sys_add_key
549 diff -NurpP --minimal linux-2.6.34/arch/mips/kernel/scall64-o32.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/scall64-o32.S
550 --- linux-2.6.34/arch/mips/kernel/scall64-o32.S 2010-05-18 15:07:44.000000000 +0200
551 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/scall64-o32.S    2010-05-18 18:11:22.000000000 +0200
552 @@ -480,7 +480,7 @@ sys_call_table:
553         PTR     compat_sys_mq_timedreceive
554         PTR     compat_sys_mq_notify            /* 4275 */
555         PTR     compat_sys_mq_getsetattr
556 -       PTR     sys_ni_syscall                  /* sys_vserver */
557 +       PTR     sys32_vserver
558         PTR     sys_32_waitid
559         PTR     sys_ni_syscall                  /* available, was setaltroot */
560         PTR     sys_add_key                     /* 4280 */
561 diff -NurpP --minimal linux-2.6.34/arch/mips/kernel/traps.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/traps.c
562 --- linux-2.6.34/arch/mips/kernel/traps.c       2010-05-18 15:07:44.000000000 +0200
563 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mips/kernel/traps.c  2010-05-18 18:11:22.000000000 +0200
564 @@ -334,9 +334,10 @@ void show_registers(const struct pt_regs
565  
566         __show_regs(regs);
567         print_modules();
568 -       printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
569 -              current->comm, current->pid, current_thread_info(), current,
570 -             field, current_thread_info()->tp_value);
571 +       printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
572 +               current->comm, task_pid_nr(current), current->xid,
573 +               current_thread_info(), current,
574 +               field, current_thread_info()->tp_value);
575         if (cpu_has_userlocal) {
576                 unsigned long tls;
577  
578 diff -NurpP --minimal linux-2.6.34/arch/mn10300/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mn10300/mm/fault.c
579 --- linux-2.6.34/arch/mn10300/mm/fault.c        2009-09-10 15:25:39.000000000 +0200
580 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/mn10300/mm/fault.c   2010-05-18 18:11:22.000000000 +0200
581 @@ -339,7 +339,8 @@ no_context:
582  out_of_memory:
583         up_read(&mm->mmap_sem);
584         monitor_signal(regs);
585 -       printk(KERN_ALERT "VM: killing process %s\n", tsk->comm);
586 +       printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
587 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
588         if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR)
589                 do_exit(SIGKILL);
590         goto no_context;
591 diff -NurpP --minimal linux-2.6.34/arch/parisc/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/parisc/Kconfig
592 --- linux-2.6.34/arch/parisc/Kconfig    2010-05-18 15:07:44.000000000 +0200
593 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/parisc/Kconfig       2010-05-18 18:11:22.000000000 +0200
594 @@ -296,6 +296,8 @@ source "fs/Kconfig"
595  
596  source "arch/parisc/Kconfig.debug"
597  
598 +source "kernel/vserver/Kconfig"
599 +
600  source "security/Kconfig"
601  
602  source "crypto/Kconfig"
603 diff -NurpP --minimal linux-2.6.34/arch/parisc/kernel/syscall_table.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/parisc/kernel/syscall_table.S
604 --- linux-2.6.34/arch/parisc/kernel/syscall_table.S     2010-05-18 15:07:44.000000000 +0200
605 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/parisc/kernel/syscall_table.S        2010-05-18 18:11:22.000000000 +0200
606 @@ -361,7 +361,7 @@
607         ENTRY_COMP(mbind)               /* 260 */
608         ENTRY_COMP(get_mempolicy)
609         ENTRY_COMP(set_mempolicy)
610 -       ENTRY_SAME(ni_syscall)  /* 263: reserved for vserver */
611 +       ENTRY_DIFF(vserver)
612         ENTRY_SAME(add_key)
613         ENTRY_SAME(request_key)         /* 265 */
614         ENTRY_SAME(keyctl)
615 diff -NurpP --minimal linux-2.6.34/arch/parisc/kernel/traps.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/parisc/kernel/traps.c
616 --- linux-2.6.34/arch/parisc/kernel/traps.c     2009-09-10 15:25:40.000000000 +0200
617 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/parisc/kernel/traps.c        2010-05-18 18:11:22.000000000 +0200
618 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
619                 if (err == 0)
620                         return; /* STFU */
621  
622 -               printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
623 -                       current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
624 +               printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
625 +                       current->comm, task_pid_nr(current), current->xid,
626 +                       str, err, regs->iaoq[0]);
627  #ifdef PRINT_USER_FAULTS
628                 /* XXX for debugging only */
629                 show_regs(regs);
630 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
631                 pdc_console_restart();
632         
633         if (err)
634 -               printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
635 -                       current->comm, task_pid_nr(current), str, err);
636 +               printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
637 +                       current->comm, task_pid_nr(current), current->xid, str, err);
638  
639         /* Wot's wrong wif bein' racy? */
640         if (current->thread.flags & PARISC_KERNEL_DEATH) {
641 diff -NurpP --minimal linux-2.6.34/arch/parisc/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/parisc/mm/fault.c
642 --- linux-2.6.34/arch/parisc/mm/fault.c 2009-09-10 15:25:40.000000000 +0200
643 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/parisc/mm/fault.c    2010-05-18 18:11:22.000000000 +0200
644 @@ -237,8 +237,9 @@ bad_area:
645  
646  #ifdef PRINT_USER_FAULTS
647                 printk(KERN_DEBUG "\n");
648 -               printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
649 -                   task_pid_nr(tsk), tsk->comm, code, address);
650 +               printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
651 +                   "command='%s' type=%lu address=0x%08lx\n",
652 +                   task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
653                 if (vma) {
654                         printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
655                                         vma->vm_start, vma->vm_end);
656 @@ -264,7 +265,8 @@ no_context:
657  
658    out_of_memory:
659         up_read(&mm->mmap_sem);
660 -       printk(KERN_CRIT "VM: killing process %s\n", current->comm);
661 +       printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
662 +               current->comm, current->pid, current->xid);
663         if (user_mode(regs))
664                 do_group_exit(SIGKILL);
665         goto no_context;
666 diff -NurpP --minimal linux-2.6.34/arch/powerpc/include/asm/unistd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/include/asm/unistd.h
667 --- linux-2.6.34/arch/powerpc/include/asm/unistd.h      2010-05-18 15:07:45.000000000 +0200
668 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/include/asm/unistd.h 2010-05-18 18:11:22.000000000 +0200
669 @@ -275,7 +275,7 @@
670  #endif
671  #define __NR_rtas              255
672  #define __NR_sys_debug_setcontext 256
673 -/* Number 257 is reserved for vserver */
674 +#define __NR_vserver           257
675  #define __NR_migrate_pages     258
676  #define __NR_mbind             259
677  #define __NR_get_mempolicy     260
678 diff -NurpP --minimal linux-2.6.34/arch/powerpc/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/Kconfig
679 --- linux-2.6.34/arch/powerpc/Kconfig   2010-05-18 15:07:44.000000000 +0200
680 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/Kconfig      2010-05-18 18:11:22.000000000 +0200
681 @@ -986,6 +986,8 @@ source "lib/Kconfig"
682  
683  source "arch/powerpc/Kconfig.debug"
684  
685 +source "kernel/vserver/Kconfig"
686 +
687  source "security/Kconfig"
688  
689  config KEYS_COMPAT
690 diff -NurpP --minimal linux-2.6.34/arch/powerpc/kernel/process.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/kernel/process.c
691 --- linux-2.6.34/arch/powerpc/kernel/process.c  2010-05-18 15:07:45.000000000 +0200
692 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/kernel/process.c     2010-05-18 18:11:22.000000000 +0200
693 @@ -602,8 +602,9 @@ void show_regs(struct pt_regs * regs)
694  #else
695                 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
696  #endif
697 -       printk("TASK = %p[%d] '%s' THREAD: %p",
698 -              current, task_pid_nr(current), current->comm, task_thread_info(current));
699 +       printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
700 +              current, task_pid_nr(current), current->xid,
701 +              current->comm, task_thread_info(current));
702  
703  #ifdef CONFIG_SMP
704         printk(" CPU: %d", raw_smp_processor_id());
705 diff -NurpP --minimal linux-2.6.34/arch/powerpc/kernel/traps.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/kernel/traps.c
706 --- linux-2.6.34/arch/powerpc/kernel/traps.c    2010-05-18 15:07:45.000000000 +0200
707 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/kernel/traps.c       2010-05-18 18:11:22.000000000 +0200
708 @@ -924,8 +924,9 @@ void nonrecoverable_exception(struct pt_
709  
710  void trace_syscall(struct pt_regs *regs)
711  {
712 -       printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld    %s\n",
713 -              current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
714 +       printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld    %s\n",
715 +              current, task_pid_nr(current), current->xid,
716 +              regs->nip, regs->link, regs->gpr[0],
717                regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
718  }
719  
720 diff -NurpP --minimal linux-2.6.34/arch/powerpc/kernel/vdso.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/kernel/vdso.c
721 --- linux-2.6.34/arch/powerpc/kernel/vdso.c     2010-02-25 11:51:31.000000000 +0100
722 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/kernel/vdso.c        2010-05-18 18:11:22.000000000 +0200
723 @@ -23,6 +23,7 @@
724  #include <linux/security.h>
725  #include <linux/bootmem.h>
726  #include <linux/lmb.h>
727 +#include <linux/vs_memory.h>
728  
729  #include <asm/pgtable.h>
730  #include <asm/system.h>
731 diff -NurpP --minimal linux-2.6.34/arch/powerpc/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/mm/fault.c
732 --- linux-2.6.34/arch/powerpc/mm/fault.c        2010-02-25 11:51:31.000000000 +0100
733 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/powerpc/mm/fault.c   2010-05-18 18:11:22.000000000 +0200
734 @@ -364,7 +364,8 @@ out_of_memory:
735                 down_read(&mm->mmap_sem);
736                 goto survive;
737         }
738 -       printk("VM: killing process %s\n", current->comm);
739 +       printk("VM: killing process %s(%d:#%u)\n",
740 +               current->comm, current->pid, current->xid);
741         if (user_mode(regs))
742                 do_group_exit(SIGKILL);
743         return SIGKILL;
744 diff -NurpP --minimal linux-2.6.34/arch/s390/include/asm/tlb.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/s390/include/asm/tlb.h
745 --- linux-2.6.34/arch/s390/include/asm/tlb.h    2009-09-10 15:25:43.000000000 +0200
746 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/s390/include/asm/tlb.h       2010-05-18 18:11:22.000000000 +0200
747 @@ -23,6 +23,8 @@
748  
749  #include <linux/mm.h>
750  #include <linux/swap.h>
751 +#include <linux/vs_memory.h>
752 +
753  #include <asm/processor.h>
754  #include <asm/pgalloc.h>
755  #include <asm/smp.h>
756 diff -NurpP --minimal linux-2.6.34/arch/s390/include/asm/unistd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/s390/include/asm/unistd.h
757 --- linux-2.6.34/arch/s390/include/asm/unistd.h 2010-05-18 15:07:45.000000000 +0200
758 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/s390/include/asm/unistd.h    2010-05-18 18:11:22.000000000 +0200
759 @@ -202,7 +202,7 @@
760  #define __NR_clock_gettime     (__NR_timer_create+6)
761  #define __NR_clock_getres      (__NR_timer_create+7)
762  #define __NR_clock_nanosleep   (__NR_timer_create+8)
763 -/* Number 263 is reserved for vserver */
764 +#define __NR_vserver           263
765  #define __NR_statfs64          265
766  #define __NR_fstatfs64         266
767  #define __NR_remap_file_pages  267
768 diff -NurpP --minimal linux-2.6.34/arch/s390/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/s390/Kconfig
769 --- linux-2.6.34/arch/s390/Kconfig      2010-05-18 15:07:45.000000000 +0200
770 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/s390/Kconfig 2010-05-18 18:11:22.000000000 +0200
771 @@ -636,6 +636,8 @@ source "fs/Kconfig"
772  
773  source "arch/s390/Kconfig.debug"
774  
775 +source "kernel/vserver/Kconfig"
776 +
777  source "security/Kconfig"
778  
779  source "crypto/Kconfig"
780 diff -NurpP --minimal linux-2.6.34/arch/s390/kernel/ptrace.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/s390/kernel/ptrace.c
781 --- linux-2.6.34/arch/s390/kernel/ptrace.c      2010-05-18 15:07:45.000000000 +0200
782 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/s390/kernel/ptrace.c 2010-05-18 18:11:22.000000000 +0200
783 @@ -36,6 +36,7 @@
784  #include <linux/regset.h>
785  #include <linux/tracehook.h>
786  #include <linux/seccomp.h>
787 +#include <linux/vs_base.h>
788  #include <trace/syscall.h>
789  #include <asm/compat.h>
790  #include <asm/segment.h>
791 diff -NurpP --minimal linux-2.6.34/arch/s390/kernel/syscalls.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/s390/kernel/syscalls.S
792 --- linux-2.6.34/arch/s390/kernel/syscalls.S    2010-05-18 15:07:45.000000000 +0200
793 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/s390/kernel/syscalls.S       2010-05-18 18:11:22.000000000 +0200
794 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
795  SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper)       /* 260 */
796  SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
797  SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
798 -NI_SYSCALL                                                     /* reserved for vserver */
799 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
800  SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
801  SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
802  SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
803 diff -NurpP --minimal linux-2.6.34/arch/sh/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sh/Kconfig
804 --- linux-2.6.34/arch/sh/Kconfig        2010-05-18 15:07:45.000000000 +0200
805 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sh/Kconfig   2010-05-18 18:11:22.000000000 +0200
806 @@ -859,6 +859,8 @@ source "fs/Kconfig"
807  
808  source "arch/sh/Kconfig.debug"
809  
810 +source "kernel/vserver/Kconfig"
811 +
812  source "security/Kconfig"
813  
814  source "crypto/Kconfig"
815 diff -NurpP --minimal linux-2.6.34/arch/sh/kernel/irq.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sh/kernel/irq.c
816 --- linux-2.6.34/arch/sh/kernel/irq.c   2010-02-25 11:51:33.000000000 +0100
817 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sh/kernel/irq.c      2010-05-18 18:11:22.000000000 +0200
818 @@ -12,6 +12,7 @@
819  #include <linux/kernel_stat.h>
820  #include <linux/seq_file.h>
821  #include <linux/ftrace.h>
822 +// #include <linux/vs_context.h>
823  #include <asm/processor.h>
824  #include <asm/machvec.h>
825  #include <asm/uaccess.h>
826 diff -NurpP --minimal linux-2.6.34/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sh/kernel/vsyscall/vsyscall.c
827 --- linux-2.6.34/arch/sh/kernel/vsyscall/vsyscall.c     2010-05-18 15:07:45.000000000 +0200
828 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sh/kernel/vsyscall/vsyscall.c        2010-05-18 18:11:22.000000000 +0200
829 @@ -18,6 +18,7 @@
830  #include <linux/elf.h>
831  #include <linux/sched.h>
832  #include <linux/err.h>
833 +#include <linux/vs_memory.h>
834  
835  /*
836   * Should the kernel map a VDSO page into processes and pass its
837 diff -NurpP --minimal linux-2.6.34/arch/sh/mm/fault_32.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sh/mm/fault_32.c
838 --- linux-2.6.34/arch/sh/mm/fault_32.c  2010-05-18 15:07:45.000000000 +0200
839 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sh/mm/fault_32.c     2010-05-18 18:11:22.000000000 +0200
840 @@ -295,7 +295,8 @@ out_of_memory:
841                 down_read(&mm->mmap_sem);
842                 goto survive;
843         }
844 -       printk("VM: killing process %s\n", tsk->comm);
845 +       printk("VM: killing process %s(%d:#%u)\n",
846 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
847         if (user_mode(regs))
848                 do_group_exit(SIGKILL);
849         goto no_context;
850 diff -NurpP --minimal linux-2.6.34/arch/sh/mm/tlbflush_64.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sh/mm/tlbflush_64.c
851 --- linux-2.6.34/arch/sh/mm/tlbflush_64.c       2010-05-18 15:07:45.000000000 +0200
852 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sh/mm/tlbflush_64.c  2010-05-18 18:11:22.000000000 +0200
853 @@ -306,7 +306,8 @@ out_of_memory:
854                 down_read(&mm->mmap_sem);
855                 goto survive;
856         }
857 -       printk("VM: killing process %s\n", tsk->comm);
858 +       printk("VM: killing process %s(%d:#%u)\n",
859 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
860         if (user_mode(regs))
861                 do_group_exit(SIGKILL);
862         goto no_context;
863 diff -NurpP --minimal linux-2.6.34/arch/sparc/include/asm/tlb_64.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sparc/include/asm/tlb_64.h
864 --- linux-2.6.34/arch/sparc/include/asm/tlb_64.h        2009-09-10 15:25:45.000000000 +0200
865 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sparc/include/asm/tlb_64.h   2010-05-18 18:11:22.000000000 +0200
866 @@ -3,6 +3,7 @@
867  
868  #include <linux/swap.h>
869  #include <linux/pagemap.h>
870 +#include <linux/vs_memory.h>
871  #include <asm/pgalloc.h>
872  #include <asm/tlbflush.h>
873  #include <asm/mmu_context.h>
874 diff -NurpP --minimal linux-2.6.34/arch/sparc/include/asm/unistd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sparc/include/asm/unistd.h
875 --- linux-2.6.34/arch/sparc/include/asm/unistd.h        2010-05-18 15:07:45.000000000 +0200
876 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sparc/include/asm/unistd.h   2010-05-18 18:11:22.000000000 +0200
877 @@ -335,7 +335,7 @@
878  #define __NR_timer_getoverrun  264
879  #define __NR_timer_delete      265
880  #define __NR_timer_create      266
881 -/* #define __NR_vserver                267 Reserved for VSERVER */
882 +#define __NR_vserver           267
883  #define __NR_io_setup          268
884  #define __NR_io_destroy                269
885  #define __NR_io_submit         270
886 diff -NurpP --minimal linux-2.6.34/arch/sparc/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sparc/Kconfig
887 --- linux-2.6.34/arch/sparc/Kconfig     2010-05-18 15:07:45.000000000 +0200
888 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sparc/Kconfig        2010-05-18 18:11:22.000000000 +0200
889 @@ -567,6 +567,8 @@ source "fs/Kconfig"
890  
891  source "arch/sparc/Kconfig.debug"
892  
893 +source "kernel/vserver/Kconfig"
894 +
895  source "security/Kconfig"
896  
897  source "crypto/Kconfig"
898 diff -NurpP --minimal linux-2.6.34/arch/sparc/kernel/systbls_32.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sparc/kernel/systbls_32.S
899 --- linux-2.6.34/arch/sparc/kernel/systbls_32.S 2010-02-25 11:51:34.000000000 +0100
900 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sparc/kernel/systbls_32.S    2010-05-18 18:11:22.000000000 +0200
901 @@ -70,7 +70,7 @@ sys_call_table:
902  /*250*/        .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
903  /*255*/        .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
904  /*260*/        .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
905 -/*265*/        .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
906 +/*265*/        .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
907  /*270*/        .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
908  /*275*/        .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
909  /*280*/        .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
910 diff -NurpP --minimal linux-2.6.34/arch/sparc/kernel/systbls_64.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sparc/kernel/systbls_64.S
911 --- linux-2.6.34/arch/sparc/kernel/systbls_64.S 2010-05-18 15:07:45.000000000 +0200
912 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/sparc/kernel/systbls_64.S    2010-05-18 18:11:22.000000000 +0200
913 @@ -71,7 +71,7 @@ sys_call_table32:
914  /*250*/        .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
915         .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
916  /*260*/        .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
917 -       .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
918 +       .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
919  /*270*/        .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
920         .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
921  /*280*/        .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
922 @@ -146,7 +146,7 @@ sys_call_table:
923  /*250*/        .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
924         .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
925  /*260*/        .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
926 -       .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
927 +       .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
928  /*270*/        .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
929         .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
930  /*280*/        .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
931 diff -NurpP --minimal linux-2.6.34/arch/um/include/asm/tlb.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/include/asm/tlb.h
932 --- linux-2.6.34/arch/um/include/asm/tlb.h      2009-09-10 15:25:46.000000000 +0200
933 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/include/asm/tlb.h 2010-05-18 18:11:22.000000000 +0200
934 @@ -3,6 +3,7 @@
935  
936  #include <linux/pagemap.h>
937  #include <linux/swap.h>
938 +#include <linux/vs_memory.h>
939  #include <asm/percpu.h>
940  #include <asm/pgalloc.h>
941  #include <asm/tlbflush.h>
942 diff -NurpP --minimal linux-2.6.34/arch/um/include/shared/kern_constants.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/include/shared/kern_constants.h
943 --- linux-2.6.34/arch/um/include/shared/kern_constants.h        1970-01-01 01:00:00.000000000 +0100
944 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/include/shared/kern_constants.h   2010-05-18 18:11:22.000000000 +0200
945 @@ -0,0 +1 @@
946 +#include "../../../../include/generated/asm-offsets.h"
947 diff -NurpP --minimal linux-2.6.34/arch/um/include/shared/user_constants.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/include/shared/user_constants.h
948 --- linux-2.6.34/arch/um/include/shared/user_constants.h        1970-01-01 01:00:00.000000000 +0100
949 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/include/shared/user_constants.h   2010-05-18 18:11:22.000000000 +0200
950 @@ -0,0 +1,40 @@
951 +/*
952 + * DO NOT MODIFY.
953 + *
954 + * This file was generated by arch/um/Makefile
955 + *
956 + */
957 +
958 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2)    # */
959 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err)    # */
960 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno)      # */
961 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long)     # */
962 +#define HOST_RBX 5 /* RBX      # */
963 +#define HOST_RCX 11 /* RCX     # */
964 +#define HOST_RDI 14 /* RDI     # */
965 +#define HOST_RSI 13 /* RSI     # */
966 +#define HOST_RDX 12 /* RDX     # */
967 +#define HOST_RBP 4 /* RBP      # */
968 +#define HOST_RAX 10 /* RAX     # */
969 +#define HOST_R8 9 /* R8        # */
970 +#define HOST_R9 8 /* R9        # */
971 +#define HOST_R10 7 /* R10      # */
972 +#define HOST_R11 6 /* R11      # */
973 +#define HOST_R12 3 /* R12      # */
974 +#define HOST_R13 2 /* R13      # */
975 +#define HOST_R14 1 /* R14      # */
976 +#define HOST_R15 0 /* R15      # */
977 +#define HOST_ORIG_RAX 15 /* ORIG_RAX   # */
978 +#define HOST_CS 17 /* CS       # */
979 +#define HOST_SS 20 /* SS       # */
980 +#define HOST_EFLAGS 18 /* EFLAGS       # */
981 +#define HOST_IP 16 /* RIP      # */
982 +#define HOST_SP 19 /* RSP      # */
983 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct)   # */
984 +#define UM_POLLIN 1 /* POLLIN  # */
985 +#define UM_POLLPRI 2 /* POLLPRI        # */
986 +#define UM_POLLOUT 4 /* POLLOUT        # */
987 +#define UM_PROT_READ 1 /* PROT_READ    # */
988 +#define UM_PROT_WRITE 2 /* PROT_WRITE  # */
989 +#define UM_PROT_EXEC 4 /* PROT_EXEC    # */
990 +
991 diff -NurpP --minimal linux-2.6.34/arch/um/Kconfig.rest linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/Kconfig.rest
992 --- linux-2.6.34/arch/um/Kconfig.rest   2009-06-11 17:12:19.000000000 +0200
993 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/Kconfig.rest      2010-05-18 18:11:22.000000000 +0200
994 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
995  
996  source "fs/Kconfig"
997  
998 +source "kernel/vserver/Kconfig"
999 +
1000  source "security/Kconfig"
1001  
1002  source "crypto/Kconfig"
1003 diff -NurpP --minimal linux-2.6.34/arch/um/kernel/config.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/kernel/config.c
1004 --- linux-2.6.34/arch/um/kernel/config.c        1970-01-01 01:00:00.000000000 +0100
1005 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/kernel/config.c   2010-05-18 18:11:22.000000000 +0200
1006 @@ -0,0 +1,417 @@
1007 +/*
1008 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
1009 + * Licensed under the GPL
1010 + */
1011 +
1012 +#include <stdio.h>
1013 +#include <stdlib.h>
1014 +#include "init.h"
1015 +
1016 +static __initdata const char *config[] = {
1017 +
1018 +"#\n",
1019 +"# Automatically generated make config: don't edit\n",
1020 +"# Linux kernel version: 2.6.33-vs2.3.0.36.29.1\n",
1021 +"# Wed Mar 10 20:29:46 2010\n",
1022 +"#\n",
1023 +"CONFIG_DEFCONFIG_LIST=\"arch/$ARCH/defconfig\"\n",
1024 +"CONFIG_GENERIC_HARDIRQS=y\n",
1025 +"CONFIG_UML=y\n",
1026 +"CONFIG_MMU=y\n",
1027 +"CONFIG_NO_IOMEM=y\n",
1028 +"# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set\n",
1029 +"CONFIG_LOCKDEP_SUPPORT=y\n",
1030 +"# CONFIG_STACKTRACE_SUPPORT is not set\n",
1031 +"CONFIG_GENERIC_CALIBRATE_DELAY=y\n",
1032 +"CONFIG_GENERIC_BUG=y\n",
1033 +"CONFIG_GENERIC_TIME=y\n",
1034 +"CONFIG_GENERIC_CLOCKEVENTS=y\n",
1035 +"CONFIG_IRQ_RELEASE_METHOD=y\n",
1036 +"CONFIG_HZ=100\n",
1037 +"\n",
1038 +"#\n",
1039 +"# UML-specific options\n",
1040 +"#\n",
1041 +"\n",
1042 +"#\n",
1043 +"# Host processor type and features\n",
1044 +"#\n",
1045 +"# CONFIG_M386 is not set\n",
1046 +"# CONFIG_M486 is not set\n",
1047 +"# CONFIG_M586 is not set\n",
1048 +"# CONFIG_M586TSC is not set\n",
1049 +"# CONFIG_M586MMX is not set\n",
1050 +"# CONFIG_M686 is not set\n",
1051 +"# CONFIG_MPENTIUMII is not set\n",
1052 +"# CONFIG_MPENTIUMIII is not set\n",
1053 +"# CONFIG_MPENTIUMM is not set\n",
1054 +"# CONFIG_MPENTIUM4 is not set\n",
1055 +"# CONFIG_MK6 is not set\n",
1056 +"# CONFIG_MK7 is not set\n",
1057 +"CONFIG_MK8=y\n",
1058 +"# CONFIG_MCRUSOE is not set\n",
1059 +"# CONFIG_MEFFICEON is not set\n",
1060 +"# CONFIG_MWINCHIPC6 is not set\n",
1061 +"# CONFIG_MWINCHIP3D is not set\n",
1062 +"# CONFIG_MGEODEGX1 is not set\n",
1063 +"# CONFIG_MGEODE_LX is not set\n",
1064 +"# CONFIG_MCYRIXIII is not set\n",
1065 +"# CONFIG_MVIAC3_2 is not set\n",
1066 +"# CONFIG_MVIAC7 is not set\n",
1067 +"# CONFIG_MPSC is not set\n",
1068 +"# CONFIG_MCORE2 is not set\n",
1069 +"# CONFIG_MATOM is not set\n",
1070 +"# CONFIG_GENERIC_CPU is not set\n",
1071 +"CONFIG_X86_CPU=y\n",
1072 +"CONFIG_X86_INTERNODE_CACHE_SHIFT=6\n",
1073 +"# CONFIG_X86_CMPXCHG is not set\n",
1074 +"CONFIG_X86_L1_CACHE_SHIFT=6\n",
1075 +"CONFIG_X86_WP_WORKS_OK=y\n",
1076 +"CONFIG_X86_INTEL_USERCOPY=y\n",
1077 +"CONFIG_X86_USE_PPRO_CHECKSUM=y\n",
1078 +"CONFIG_X86_TSC=y\n",
1079 +"CONFIG_X86_CMOV=y\n",
1080 +"CONFIG_X86_MINIMUM_CPU_FAMILY=3\n",
1081 +"CONFIG_CPU_SUP_INTEL=y\n",
1082 +"CONFIG_CPU_SUP_AMD=y\n",
1083 +"CONFIG_CPU_SUP_CENTAUR=y\n",
1084 +"CONFIG_UML_X86=y\n",
1085 +"CONFIG_64BIT=y\n",
1086 +"# CONFIG_X86_32 is not set\n",
1087 +"# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set\n",
1088 +"CONFIG_RWSEM_GENERIC_SPINLOCK=y\n",
1089 +"# CONFIG_ARCH_HAS_SC_SIGNALS is not set\n",
1090 +"# CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA is not set\n",
1091 +"CONFIG_SMP_BROKEN=y\n",
1092 +"CONFIG_GENERIC_HWEIGHT=y\n",
1093 +"# CONFIG_STATIC_LINK is not set\n",
1094 +"CONFIG_FLATMEM=y\n",
1095 +"CONFIG_FLAT_NODE_MEM_MAP=y\n",
1096 +"CONFIG_PAGEFLAGS_EXTENDED=y\n",
1097 +"CONFIG_SPLIT_PTLOCK_CPUS=4\n",
1098 +"CONFIG_PHYS_ADDR_T_64BIT=y\n",
1099 +"CONFIG_ZONE_DMA_FLAG=0\n",
1100 +"CONFIG_VIRT_TO_BUS=y\n",
1101 +"# CONFIG_KSM is not set\n",
1102 +"CONFIG_DEFAULT_MMAP_MIN_ADDR=4096\n",
1103 +"# CONFIG_NO_HZ is not set\n",
1104 +"# CONFIG_HIGH_RES_TIMERS is not set\n",
1105 +"CONFIG_GENERIC_CLOCKEVENTS_BUILD=y\n",
1106 +"CONFIG_LD_SCRIPT_DYN=y\n",
1107 +"# CONFIG_BINFMT_ELF is not set\n",
1108 +"# CONFIG_HAVE_AOUT is not set\n",
1109 +"# CONFIG_BINFMT_MISC is not set\n",
1110 +"# CONFIG_HOSTFS is not set\n",
1111 +"# CONFIG_MCONSOLE is not set\n",
1112 +"CONFIG_KERNEL_STACK_ORDER=1\n",
1113 +"\n",
1114 +"#\n",
1115 +"# General setup\n",
1116 +"#\n",
1117 +"# CONFIG_EXPERIMENTAL is not set\n",
1118 +"CONFIG_BROKEN_ON_SMP=y\n",
1119 +"CONFIG_INIT_ENV_ARG_LIMIT=128\n",
1120 +"CONFIG_LOCALVERSION=\"\"\n",
1121 +"# CONFIG_LOCALVERSION_AUTO is not set\n",
1122 +"# CONFIG_SWAP is not set\n",
1123 +"CONFIG_SYSVIPC=y\n",
1124 +"CONFIG_SYSVIPC_SYSCTL=y\n",
1125 +"# CONFIG_BSD_PROCESS_ACCT is not set\n",
1126 +"\n",
1127 +"#\n",
1128 +"# RCU Subsystem\n",
1129 +"#\n",
1130 +"CONFIG_TREE_RCU=y\n",
1131 +"# CONFIG_TREE_PREEMPT_RCU is not set\n",
1132 +"# CONFIG_TINY_RCU is not set\n",
1133 +"# CONFIG_RCU_TRACE is not set\n",
1134 +"CONFIG_RCU_FANOUT=64\n",
1135 +"# CONFIG_RCU_FANOUT_EXACT is not set\n",
1136 +"# CONFIG_TREE_RCU_TRACE is not set\n",
1137 +"# CONFIG_IKCONFIG is not set\n",
1138 +"CONFIG_LOG_BUF_SHIFT=17\n",
1139 +"# CONFIG_CGROUPS is not set\n",
1140 +"# CONFIG_SYSFS_DEPRECATED_V2 is not set\n",
1141 +"# CONFIG_RELAY is not set\n",
1142 +"CONFIG_NAMESPACES=y\n",
1143 +"CONFIG_UTS_NS=y\n",
1144 +"CONFIG_IPC_NS=y\n",
1145 +"CONFIG_USER_NS=y\n",
1146 +"# CONFIG_BLK_DEV_INITRD is not set\n",
1147 +"# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set\n",
1148 +"CONFIG_SYSCTL=y\n",
1149 +"CONFIG_ANON_INODES=y\n",
1150 +"# CONFIG_EMBEDDED is not set\n",
1151 +"CONFIG_UID16=y\n",
1152 +"CONFIG_SYSCTL_SYSCALL=y\n",
1153 +"CONFIG_KALLSYMS=y\n",
1154 +"# CONFIG_KALLSYMS_EXTRA_PASS is not set\n",
1155 +"CONFIG_HOTPLUG=y\n",
1156 +"CONFIG_PRINTK=y\n",
1157 +"CONFIG_BUG=y\n",
1158 +"CONFIG_ELF_CORE=y\n",
1159 +"CONFIG_BASE_FULL=y\n",
1160 +"CONFIG_FUTEX=y\n",
1161 +"CONFIG_EPOLL=y\n",
1162 +"CONFIG_SIGNALFD=y\n",
1163 +"CONFIG_TIMERFD=y\n",
1164 +"CONFIG_EVENTFD=y\n",
1165 +"CONFIG_SHMEM=y\n",
1166 +"CONFIG_AIO=y\n",
1167 +"\n",
1168 +"#\n",
1169 +"# Kernel Performance Events And Counters\n",
1170 +"#\n",
1171 +"CONFIG_VM_EVENT_COUNTERS=y\n",
1172 +"CONFIG_SLUB_DEBUG=y\n",
1173 +"# CONFIG_COMPAT_BRK is not set\n",
1174 +"# CONFIG_SLAB is not set\n",
1175 +"CONFIG_SLUB=y\n",
1176 +"# CONFIG_SLOB is not set\n",
1177 +"# CONFIG_PROFILING is not set\n",
1178 +"\n",
1179 +"#\n",
1180 +"# GCOV-based kernel profiling\n",
1181 +"#\n",
1182 +"# CONFIG_SLOW_WORK is not set\n",
1183 +"# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set\n",
1184 +"CONFIG_SLABINFO=y\n",
1185 +"CONFIG_RT_MUTEXES=y\n",
1186 +"CONFIG_BASE_SMALL=0\n",
1187 +"# CONFIG_MODULES is not set\n",
1188 +"CONFIG_BLOCK=y\n",
1189 +"# CONFIG_BLK_DEV_BSG is not set\n",
1190 +"# CONFIG_BLK_DEV_INTEGRITY is not set\n",
1191 +"\n",
1192 +"#\n",
1193 +"# IO Schedulers\n",
1194 +"#\n",
1195 +"CONFIG_IOSCHED_NOOP=y\n",
1196 +"# CONFIG_IOSCHED_DEADLINE is not set\n",
1197 +"# CONFIG_IOSCHED_CFQ is not set\n",
1198 +"# CONFIG_DEFAULT_DEADLINE is not set\n",
1199 +"# CONFIG_DEFAULT_CFQ is not set\n",
1200 +"CONFIG_DEFAULT_NOOP=y\n",
1201 +"CONFIG_DEFAULT_IOSCHED=\"noop\"\n",
1202 +"# CONFIG_INLINE_SPIN_TRYLOCK is not set\n",
1203 +"# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set\n",
1204 +"# CONFIG_INLINE_SPIN_LOCK is not set\n",
1205 +"# CONFIG_INLINE_SPIN_LOCK_BH is not set\n",
1206 +"# CONFIG_INLINE_SPIN_LOCK_IRQ is not set\n",
1207 +"# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set\n",
1208 +"CONFIG_INLINE_SPIN_UNLOCK=y\n",
1209 +"# CONFIG_INLINE_SPIN_UNLOCK_BH is not set\n",
1210 +"CONFIG_INLINE_SPIN_UNLOCK_IRQ=y\n",
1211 +"# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set\n",
1212 +"# CONFIG_INLINE_READ_TRYLOCK is not set\n",
1213 +"# CONFIG_INLINE_READ_LOCK is not set\n",
1214 +"# CONFIG_INLINE_READ_LOCK_BH is not set\n",
1215 +"# CONFIG_INLINE_READ_LOCK_IRQ is not set\n",
1216 +"# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set\n",
1217 +"CONFIG_INLINE_READ_UNLOCK=y\n",
1218 +"# CONFIG_INLINE_READ_UNLOCK_BH is not set\n",
1219 +"CONFIG_INLINE_READ_UNLOCK_IRQ=y\n",
1220 +"# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set\n",
1221 +"# CONFIG_INLINE_WRITE_TRYLOCK is not set\n",
1222 +"# CONFIG_INLINE_WRITE_LOCK is not set\n",
1223 +"# CONFIG_INLINE_WRITE_LOCK_BH is not set\n",
1224 +"# CONFIG_INLINE_WRITE_LOCK_IRQ is not set\n",
1225 +"# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set\n",
1226 +"CONFIG_INLINE_WRITE_UNLOCK=y\n",
1227 +"# CONFIG_INLINE_WRITE_UNLOCK_BH is not set\n",
1228 +"CONFIG_INLINE_WRITE_UNLOCK_IRQ=y\n",
1229 +"# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set\n",
1230 +"# CONFIG_MUTEX_SPIN_ON_OWNER is not set\n",
1231 +"# CONFIG_FREEZER is not set\n",
1232 +"# CONFIG_BLK_DEV is not set\n",
1233 +"\n",
1234 +"#\n",
1235 +"# Character Devices\n",
1236 +"#\n",
1237 +"# CONFIG_STDERR_CONSOLE is not set\n",
1238 +"CONFIG_STDIO_CONSOLE=y\n",
1239 +"# CONFIG_SSL is not set\n",
1240 +"# CONFIG_NULL_CHAN is not set\n",
1241 +"# CONFIG_PORT_CHAN is not set\n",
1242 +"# CONFIG_PTY_CHAN is not set\n",
1243 +"# CONFIG_TTY_CHAN is not set\n",
1244 +"# CONFIG_XTERM_CHAN is not set\n",
1245 +"CONFIG_NOCONFIG_CHAN=y\n",
1246 +"CONFIG_CON_ZERO_CHAN=\"fd:0,fd:1\"\n",
1247 +"CONFIG_CON_CHAN=\"xterm\"\n",
1248 +"CONFIG_SSL_CHAN=\"pty\"\n",
1249 +"# CONFIG_UNIX98_PTYS is not set\n",
1250 +"# CONFIG_LEGACY_PTYS is not set\n",
1251 +"# CONFIG_RAW_DRIVER is not set\n",
1252 +"# CONFIG_WATCHDOG is not set\n",
1253 +"# CONFIG_UML_SOUND is not set\n",
1254 +"# CONFIG_SOUND is not set\n",
1255 +"# CONFIG_SOUND_OSS_CORE is not set\n",
1256 +"# CONFIG_HOSTAUDIO is not set\n",
1257 +"# CONFIG_HW_RANDOM is not set\n",
1258 +"# CONFIG_UML_RANDOM is not set\n",
1259 +"# CONFIG_MMAPPER is not set\n",
1260 +"\n",
1261 +"#\n",
1262 +"# Generic Driver Options\n",
1263 +"#\n",
1264 +"CONFIG_UEVENT_HELPER_PATH=\"/sbin/hotplug\"\n",
1265 +"CONFIG_STANDALONE=y\n",
1266 +"# CONFIG_PREVENT_FIRMWARE_BUILD is not set\n",
1267 +"CONFIG_FW_LOADER=y\n",
1268 +"# CONFIG_FIRMWARE_IN_KERNEL is not set\n",
1269 +"CONFIG_EXTRA_FIRMWARE=\"\"\n",
1270 +"# CONFIG_SYS_HYPERVISOR is not set\n",
1271 +"# CONFIG_NET is not set\n",
1272 +"\n",
1273 +"#\n",
1274 +"# File systems\n",
1275 +"#\n",
1276 +"# CONFIG_EXT2_FS is not set\n",
1277 +"# CONFIG_EXT3_FS is not set\n",
1278 +"# CONFIG_EXT4_FS is not set\n",
1279 +"# CONFIG_REISERFS_FS is not set\n",
1280 +"# CONFIG_JFS_FS is not set\n",
1281 +"# CONFIG_FS_POSIX_ACL is not set\n",
1282 +"# CONFIG_XFS_FS is not set\n",
1283 +"CONFIG_FILE_LOCKING=y\n",
1284 +"# CONFIG_FSNOTIFY is not set\n",
1285 +"# CONFIG_DNOTIFY is not set\n",
1286 +"# CONFIG_INOTIFY is not set\n",
1287 +"# CONFIG_INOTIFY_USER is not set\n",
1288 +"# CONFIG_QUOTA is not set\n",
1289 +"# CONFIG_AUTOFS_FS is not set\n",
1290 +"# CONFIG_AUTOFS4_FS is not set\n",
1291 +"# CONFIG_FUSE_FS is not set\n",
1292 +"\n",
1293 +"#\n",
1294 +"# Caches\n",
1295 +"#\n",
1296 +"\n",
1297 +"#\n",
1298 +"# CD-ROM/DVD Filesystems\n",
1299 +"#\n",
1300 +"# CONFIG_ISO9660_FS is not set\n",
1301 +"# CONFIG_UDF_FS is not set\n",
1302 +"\n",
1303 +"#\n",
1304 +"# DOS/FAT/NT Filesystems\n",
1305 +"#\n",
1306 +"# CONFIG_MSDOS_FS is not set\n",
1307 +"# CONFIG_VFAT_FS is not set\n",
1308 +"# CONFIG_NTFS_FS is not set\n",
1309 +"\n",
1310 +"#\n",
1311 +"# Pseudo filesystems\n",
1312 +"#\n",
1313 +"CONFIG_PROC_FS=y\n",
1314 +"# CONFIG_PROC_KCORE is not set\n",
1315 +"CONFIG_PROC_SYSCTL=y\n",
1316 +"CONFIG_PROC_PAGE_MONITOR=y\n",
1317 +"CONFIG_SYSFS=y\n",
1318 +"# CONFIG_TMPFS is not set\n",
1319 +"# CONFIG_HUGETLB_PAGE is not set\n",
1320 +"# CONFIG_CONFIGFS_FS is not set\n",
1321 +"# CONFIG_MISC_FILESYSTEMS is not set\n",
1322 +"\n",
1323 +"#\n",
1324 +"# Partition Types\n",
1325 +"#\n",
1326 +"# CONFIG_PARTITION_ADVANCED is not set\n",
1327 +"CONFIG_MSDOS_PARTITION=y\n",
1328 +"# CONFIG_NLS is not set\n",
1329 +"\n",
1330 +"#\n",
1331 +"# Linux VServer\n",
1332 +"#\n",
1333 +"# CONFIG_VSERVER_AUTO_LBACK is not set\n",
1334 +"# CONFIG_VSERVER_COWBL is not set\n",
1335 +"# CONFIG_VSERVER_PROC_SECURE is not set\n",
1336 +"# CONFIG_VSERVER_HARDCPU is not set\n",
1337 +"# CONFIG_TAGGING_NONE is not set\n",
1338 +"# CONFIG_TAGGING_UID16 is not set\n",
1339 +"# CONFIG_TAGGING_GID16 is not set\n",
1340 +"CONFIG_TAGGING_ID24=y\n",
1341 +"# CONFIG_TAGGING_INTERN is not set\n",
1342 +"# CONFIG_TAG_NFSD is not set\n",
1343 +"# CONFIG_VSERVER_PRIVACY is not set\n",
1344 +"CONFIG_VSERVER_CONTEXTS=768\n",
1345 +"# CONFIG_VSERVER_WARN is not set\n",
1346 +"# CONFIG_VSERVER_DEBUG is not set\n",
1347 +"CONFIG_VSERVER=y\n",
1348 +"\n",
1349 +"#\n",
1350 +"# Security options\n",
1351 +"#\n",
1352 +"# CONFIG_KEYS is not set\n",
1353 +"# CONFIG_SECURITY is not set\n",
1354 +"# CONFIG_SECURITYFS is not set\n",
1355 +"# CONFIG_DEFAULT_SECURITY_SELINUX is not set\n",
1356 +"# CONFIG_DEFAULT_SECURITY_SMACK is not set\n",
1357 +"# CONFIG_DEFAULT_SECURITY_TOMOYO is not set\n",
1358 +"CONFIG_DEFAULT_SECURITY_DAC=y\n",
1359 +"CONFIG_DEFAULT_SECURITY=\"\"\n",
1360 +"# CONFIG_CRYPTO is not set\n",
1361 +"# CONFIG_BINARY_PRINTF is not set\n",
1362 +"\n",
1363 +"#\n",
1364 +"# Library routines\n",
1365 +"#\n",
1366 +"CONFIG_GENERIC_FIND_FIRST_BIT=y\n",
1367 +"CONFIG_GENERIC_FIND_NEXT_BIT=y\n",
1368 +"CONFIG_GENERIC_FIND_LAST_BIT=y\n",
1369 +"# CONFIG_CRC_CCITT is not set\n",
1370 +"# CONFIG_CRC16 is not set\n",
1371 +"# CONFIG_CRC_T10DIF is not set\n",
1372 +"# CONFIG_CRC_ITU_T is not set\n",
1373 +"# CONFIG_CRC32 is not set\n",
1374 +"# CONFIG_CRC7 is not set\n",
1375 +"# CONFIG_LIBCRC32C is not set\n",
1376 +"CONFIG_HAS_DMA=y\n",
1377 +"\n",
1378 +"#\n",
1379 +"# SCSI device support\n",
1380 +"#\n",
1381 +"# CONFIG_RAID_ATTRS is not set\n",
1382 +"# CONFIG_SCSI is not set\n",
1383 +"# CONFIG_SCSI_DMA is not set\n",
1384 +"# CONFIG_SCSI_NETLINK is not set\n",
1385 +"# CONFIG_MD is not set\n",
1386 +"# CONFIG_NEW_LEDS is not set\n",
1387 +"# CONFIG_INPUT is not set\n",
1388 +"\n",
1389 +"#\n",
1390 +"# Kernel hacking\n",
1391 +"#\n",
1392 +"# CONFIG_PRINTK_TIME is not set\n",
1393 +"# CONFIG_ENABLE_WARN_DEPRECATED is not set\n",
1394 +"# CONFIG_ENABLE_MUST_CHECK is not set\n",
1395 +"CONFIG_FRAME_WARN=2048\n",
1396 +"# CONFIG_STRIP_ASM_SYMS is not set\n",
1397 +"# CONFIG_UNUSED_SYMBOLS is not set\n",
1398 +"# CONFIG_DEBUG_FS is not set\n",
1399 +"# CONFIG_DEBUG_KERNEL is not set\n",
1400 +"# CONFIG_SLUB_DEBUG_ON is not set\n",
1401 +"# CONFIG_SLUB_STATS is not set\n",
1402 +"CONFIG_DEBUG_BUGVERBOSE=y\n",
1403 +"CONFIG_DEBUG_MEMORY_INIT=y\n",
1404 +"# CONFIG_RCU_CPU_STALL_DETECTOR is not set\n",
1405 +"# CONFIG_SYSCTL_SYSCALL_CHECK is not set\n",
1406 +"# CONFIG_SAMPLES is not set\n",
1407 +"# CONFIG_DEBUG_STACK_USAGE is not set\n",
1408 +""
1409 +};
1410 +
1411 +static int __init print_config(char *line, int *add)
1412 +{
1413 +       int i;
1414 +       for (i = 0; i < sizeof(config)/sizeof(config[0]); i++)
1415 +               printf("%s", config[i]);
1416 +       exit(0);
1417 +}
1418 +
1419 +__uml_setup("--showconfig", print_config,
1420 +"--showconfig\n"
1421 +"    Prints the config file that this UML binary was generated from.\n\n"
1422 +);
1423 +
1424 diff -NurpP --minimal linux-2.6.34/arch/um/kernel/config.tmp linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/kernel/config.tmp
1425 --- linux-2.6.34/arch/um/kernel/config.tmp      1970-01-01 01:00:00.000000000 +0100
1426 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/kernel/config.tmp 2010-05-18 18:11:22.000000000 +0200
1427 @@ -0,0 +1,390 @@
1428 +"#\n",
1429 +"# Automatically generated make config: don't edit\n",
1430 +"# Linux kernel version: 2.6.33-vs2.3.0.36.29.1\n",
1431 +"# Wed Mar 10 20:29:46 2010\n",
1432 +"#\n",
1433 +"CONFIG_DEFCONFIG_LIST=\"arch/$ARCH/defconfig\"\n",
1434 +"CONFIG_GENERIC_HARDIRQS=y\n",
1435 +"CONFIG_UML=y\n",
1436 +"CONFIG_MMU=y\n",
1437 +"CONFIG_NO_IOMEM=y\n",
1438 +"# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set\n",
1439 +"CONFIG_LOCKDEP_SUPPORT=y\n",
1440 +"# CONFIG_STACKTRACE_SUPPORT is not set\n",
1441 +"CONFIG_GENERIC_CALIBRATE_DELAY=y\n",
1442 +"CONFIG_GENERIC_BUG=y\n",
1443 +"CONFIG_GENERIC_TIME=y\n",
1444 +"CONFIG_GENERIC_CLOCKEVENTS=y\n",
1445 +"CONFIG_IRQ_RELEASE_METHOD=y\n",
1446 +"CONFIG_HZ=100\n",
1447 +"\n",
1448 +"#\n",
1449 +"# UML-specific options\n",
1450 +"#\n",
1451 +"\n",
1452 +"#\n",
1453 +"# Host processor type and features\n",
1454 +"#\n",
1455 +"# CONFIG_M386 is not set\n",
1456 +"# CONFIG_M486 is not set\n",
1457 +"# CONFIG_M586 is not set\n",
1458 +"# CONFIG_M586TSC is not set\n",
1459 +"# CONFIG_M586MMX is not set\n",
1460 +"# CONFIG_M686 is not set\n",
1461 +"# CONFIG_MPENTIUMII is not set\n",
1462 +"# CONFIG_MPENTIUMIII is not set\n",
1463 +"# CONFIG_MPENTIUMM is not set\n",
1464 +"# CONFIG_MPENTIUM4 is not set\n",
1465 +"# CONFIG_MK6 is not set\n",
1466 +"# CONFIG_MK7 is not set\n",
1467 +"CONFIG_MK8=y\n",
1468 +"# CONFIG_MCRUSOE is not set\n",
1469 +"# CONFIG_MEFFICEON is not set\n",
1470 +"# CONFIG_MWINCHIPC6 is not set\n",
1471 +"# CONFIG_MWINCHIP3D is not set\n",
1472 +"# CONFIG_MGEODEGX1 is not set\n",
1473 +"# CONFIG_MGEODE_LX is not set\n",
1474 +"# CONFIG_MCYRIXIII is not set\n",
1475 +"# CONFIG_MVIAC3_2 is not set\n",
1476 +"# CONFIG_MVIAC7 is not set\n",
1477 +"# CONFIG_MPSC is not set\n",
1478 +"# CONFIG_MCORE2 is not set\n",
1479 +"# CONFIG_MATOM is not set\n",
1480 +"# CONFIG_GENERIC_CPU is not set\n",
1481 +"CONFIG_X86_CPU=y\n",
1482 +"CONFIG_X86_INTERNODE_CACHE_SHIFT=6\n",
1483 +"# CONFIG_X86_CMPXCHG is not set\n",
1484 +"CONFIG_X86_L1_CACHE_SHIFT=6\n",
1485 +"CONFIG_X86_WP_WORKS_OK=y\n",
1486 +"CONFIG_X86_INTEL_USERCOPY=y\n",
1487 +"CONFIG_X86_USE_PPRO_CHECKSUM=y\n",
1488 +"CONFIG_X86_TSC=y\n",
1489 +"CONFIG_X86_CMOV=y\n",
1490 +"CONFIG_X86_MINIMUM_CPU_FAMILY=3\n",
1491 +"CONFIG_CPU_SUP_INTEL=y\n",
1492 +"CONFIG_CPU_SUP_AMD=y\n",
1493 +"CONFIG_CPU_SUP_CENTAUR=y\n",
1494 +"CONFIG_UML_X86=y\n",
1495 +"CONFIG_64BIT=y\n",
1496 +"# CONFIG_X86_32 is not set\n",
1497 +"# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set\n",
1498 +"CONFIG_RWSEM_GENERIC_SPINLOCK=y\n",
1499 +"# CONFIG_ARCH_HAS_SC_SIGNALS is not set\n",
1500 +"# CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA is not set\n",
1501 +"CONFIG_SMP_BROKEN=y\n",
1502 +"CONFIG_GENERIC_HWEIGHT=y\n",
1503 +"# CONFIG_STATIC_LINK is not set\n",
1504 +"CONFIG_FLATMEM=y\n",
1505 +"CONFIG_FLAT_NODE_MEM_MAP=y\n",
1506 +"CONFIG_PAGEFLAGS_EXTENDED=y\n",
1507 +"CONFIG_SPLIT_PTLOCK_CPUS=4\n",
1508 +"CONFIG_PHYS_ADDR_T_64BIT=y\n",
1509 +"CONFIG_ZONE_DMA_FLAG=0\n",
1510 +"CONFIG_VIRT_TO_BUS=y\n",
1511 +"# CONFIG_KSM is not set\n",
1512 +"CONFIG_DEFAULT_MMAP_MIN_ADDR=4096\n",
1513 +"# CONFIG_NO_HZ is not set\n",
1514 +"# CONFIG_HIGH_RES_TIMERS is not set\n",
1515 +"CONFIG_GENERIC_CLOCKEVENTS_BUILD=y\n",
1516 +"CONFIG_LD_SCRIPT_DYN=y\n",
1517 +"# CONFIG_BINFMT_ELF is not set\n",
1518 +"# CONFIG_HAVE_AOUT is not set\n",
1519 +"# CONFIG_BINFMT_MISC is not set\n",
1520 +"# CONFIG_HOSTFS is not set\n",
1521 +"# CONFIG_MCONSOLE is not set\n",
1522 +"CONFIG_KERNEL_STACK_ORDER=1\n",
1523 +"\n",
1524 +"#\n",
1525 +"# General setup\n",
1526 +"#\n",
1527 +"# CONFIG_EXPERIMENTAL is not set\n",
1528 +"CONFIG_BROKEN_ON_SMP=y\n",
1529 +"CONFIG_INIT_ENV_ARG_LIMIT=128\n",
1530 +"CONFIG_LOCALVERSION=\"\"\n",
1531 +"# CONFIG_LOCALVERSION_AUTO is not set\n",
1532 +"# CONFIG_SWAP is not set\n",
1533 +"CONFIG_SYSVIPC=y\n",
1534 +"CONFIG_SYSVIPC_SYSCTL=y\n",
1535 +"# CONFIG_BSD_PROCESS_ACCT is not set\n",
1536 +"\n",
1537 +"#\n",
1538 +"# RCU Subsystem\n",
1539 +"#\n",
1540 +"CONFIG_TREE_RCU=y\n",
1541 +"# CONFIG_TREE_PREEMPT_RCU is not set\n",
1542 +"# CONFIG_TINY_RCU is not set\n",
1543 +"# CONFIG_RCU_TRACE is not set\n",
1544 +"CONFIG_RCU_FANOUT=64\n",
1545 +"# CONFIG_RCU_FANOUT_EXACT is not set\n",
1546 +"# CONFIG_TREE_RCU_TRACE is not set\n",
1547 +"# CONFIG_IKCONFIG is not set\n",
1548 +"CONFIG_LOG_BUF_SHIFT=17\n",
1549 +"# CONFIG_CGROUPS is not set\n",
1550 +"# CONFIG_SYSFS_DEPRECATED_V2 is not set\n",
1551 +"# CONFIG_RELAY is not set\n",
1552 +"CONFIG_NAMESPACES=y\n",
1553 +"CONFIG_UTS_NS=y\n",
1554 +"CONFIG_IPC_NS=y\n",
1555 +"CONFIG_USER_NS=y\n",
1556 +"# CONFIG_BLK_DEV_INITRD is not set\n",
1557 +"# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set\n",
1558 +"CONFIG_SYSCTL=y\n",
1559 +"CONFIG_ANON_INODES=y\n",
1560 +"# CONFIG_EMBEDDED is not set\n",
1561 +"CONFIG_UID16=y\n",
1562 +"CONFIG_SYSCTL_SYSCALL=y\n",
1563 +"CONFIG_KALLSYMS=y\n",
1564 +"# CONFIG_KALLSYMS_EXTRA_PASS is not set\n",
1565 +"CONFIG_HOTPLUG=y\n",
1566 +"CONFIG_PRINTK=y\n",
1567 +"CONFIG_BUG=y\n",
1568 +"CONFIG_ELF_CORE=y\n",
1569 +"CONFIG_BASE_FULL=y\n",
1570 +"CONFIG_FUTEX=y\n",
1571 +"CONFIG_EPOLL=y\n",
1572 +"CONFIG_SIGNALFD=y\n",
1573 +"CONFIG_TIMERFD=y\n",
1574 +"CONFIG_EVENTFD=y\n",
1575 +"CONFIG_SHMEM=y\n",
1576 +"CONFIG_AIO=y\n",
1577 +"\n",
1578 +"#\n",
1579 +"# Kernel Performance Events And Counters\n",
1580 +"#\n",
1581 +"CONFIG_VM_EVENT_COUNTERS=y\n",
1582 +"CONFIG_SLUB_DEBUG=y\n",
1583 +"# CONFIG_COMPAT_BRK is not set\n",
1584 +"# CONFIG_SLAB is not set\n",
1585 +"CONFIG_SLUB=y\n",
1586 +"# CONFIG_SLOB is not set\n",
1587 +"# CONFIG_PROFILING is not set\n",
1588 +"\n",
1589 +"#\n",
1590 +"# GCOV-based kernel profiling\n",
1591 +"#\n",
1592 +"# CONFIG_SLOW_WORK is not set\n",
1593 +"# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set\n",
1594 +"CONFIG_SLABINFO=y\n",
1595 +"CONFIG_RT_MUTEXES=y\n",
1596 +"CONFIG_BASE_SMALL=0\n",
1597 +"# CONFIG_MODULES is not set\n",
1598 +"CONFIG_BLOCK=y\n",
1599 +"# CONFIG_BLK_DEV_BSG is not set\n",
1600 +"# CONFIG_BLK_DEV_INTEGRITY is not set\n",
1601 +"\n",
1602 +"#\n",
1603 +"# IO Schedulers\n",
1604 +"#\n",
1605 +"CONFIG_IOSCHED_NOOP=y\n",
1606 +"# CONFIG_IOSCHED_DEADLINE is not set\n",
1607 +"# CONFIG_IOSCHED_CFQ is not set\n",
1608 +"# CONFIG_DEFAULT_DEADLINE is not set\n",
1609 +"# CONFIG_DEFAULT_CFQ is not set\n",
1610 +"CONFIG_DEFAULT_NOOP=y\n",
1611 +"CONFIG_DEFAULT_IOSCHED=\"noop\"\n",
1612 +"# CONFIG_INLINE_SPIN_TRYLOCK is not set\n",
1613 +"# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set\n",
1614 +"# CONFIG_INLINE_SPIN_LOCK is not set\n",
1615 +"# CONFIG_INLINE_SPIN_LOCK_BH is not set\n",
1616 +"# CONFIG_INLINE_SPIN_LOCK_IRQ is not set\n",
1617 +"# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set\n",
1618 +"CONFIG_INLINE_SPIN_UNLOCK=y\n",
1619 +"# CONFIG_INLINE_SPIN_UNLOCK_BH is not set\n",
1620 +"CONFIG_INLINE_SPIN_UNLOCK_IRQ=y\n",
1621 +"# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set\n",
1622 +"# CONFIG_INLINE_READ_TRYLOCK is not set\n",
1623 +"# CONFIG_INLINE_READ_LOCK is not set\n",
1624 +"# CONFIG_INLINE_READ_LOCK_BH is not set\n",
1625 +"# CONFIG_INLINE_READ_LOCK_IRQ is not set\n",
1626 +"# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set\n",
1627 +"CONFIG_INLINE_READ_UNLOCK=y\n",
1628 +"# CONFIG_INLINE_READ_UNLOCK_BH is not set\n",
1629 +"CONFIG_INLINE_READ_UNLOCK_IRQ=y\n",
1630 +"# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set\n",
1631 +"# CONFIG_INLINE_WRITE_TRYLOCK is not set\n",
1632 +"# CONFIG_INLINE_WRITE_LOCK is not set\n",
1633 +"# CONFIG_INLINE_WRITE_LOCK_BH is not set\n",
1634 +"# CONFIG_INLINE_WRITE_LOCK_IRQ is not set\n",
1635 +"# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set\n",
1636 +"CONFIG_INLINE_WRITE_UNLOCK=y\n",
1637 +"# CONFIG_INLINE_WRITE_UNLOCK_BH is not set\n",
1638 +"CONFIG_INLINE_WRITE_UNLOCK_IRQ=y\n",
1639 +"# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set\n",
1640 +"# CONFIG_MUTEX_SPIN_ON_OWNER is not set\n",
1641 +"# CONFIG_FREEZER is not set\n",
1642 +"# CONFIG_BLK_DEV is not set\n",
1643 +"\n",
1644 +"#\n",
1645 +"# Character Devices\n",
1646 +"#\n",
1647 +"# CONFIG_STDERR_CONSOLE is not set\n",
1648 +"CONFIG_STDIO_CONSOLE=y\n",
1649 +"# CONFIG_SSL is not set\n",
1650 +"# CONFIG_NULL_CHAN is not set\n",
1651 +"# CONFIG_PORT_CHAN is not set\n",
1652 +"# CONFIG_PTY_CHAN is not set\n",
1653 +"# CONFIG_TTY_CHAN is not set\n",
1654 +"# CONFIG_XTERM_CHAN is not set\n",
1655 +"CONFIG_NOCONFIG_CHAN=y\n",
1656 +"CONFIG_CON_ZERO_CHAN=\"fd:0,fd:1\"\n",
1657 +"CONFIG_CON_CHAN=\"xterm\"\n",
1658 +"CONFIG_SSL_CHAN=\"pty\"\n",
1659 +"# CONFIG_UNIX98_PTYS is not set\n",
1660 +"# CONFIG_LEGACY_PTYS is not set\n",
1661 +"# CONFIG_RAW_DRIVER is not set\n",
1662 +"# CONFIG_WATCHDOG is not set\n",
1663 +"# CONFIG_UML_SOUND is not set\n",
1664 +"# CONFIG_SOUND is not set\n",
1665 +"# CONFIG_SOUND_OSS_CORE is not set\n",
1666 +"# CONFIG_HOSTAUDIO is not set\n",
1667 +"# CONFIG_HW_RANDOM is not set\n",
1668 +"# CONFIG_UML_RANDOM is not set\n",
1669 +"# CONFIG_MMAPPER is not set\n",
1670 +"\n",
1671 +"#\n",
1672 +"# Generic Driver Options\n",
1673 +"#\n",
1674 +"CONFIG_UEVENT_HELPER_PATH=\"/sbin/hotplug\"\n",
1675 +"CONFIG_STANDALONE=y\n",
1676 +"# CONFIG_PREVENT_FIRMWARE_BUILD is not set\n",
1677 +"CONFIG_FW_LOADER=y\n",
1678 +"# CONFIG_FIRMWARE_IN_KERNEL is not set\n",
1679 +"CONFIG_EXTRA_FIRMWARE=\"\"\n",
1680 +"# CONFIG_SYS_HYPERVISOR is not set\n",
1681 +"# CONFIG_NET is not set\n",
1682 +"\n",
1683 +"#\n",
1684 +"# File systems\n",
1685 +"#\n",
1686 +"# CONFIG_EXT2_FS is not set\n",
1687 +"# CONFIG_EXT3_FS is not set\n",
1688 +"# CONFIG_EXT4_FS is not set\n",
1689 +"# CONFIG_REISERFS_FS is not set\n",
1690 +"# CONFIG_JFS_FS is not set\n",
1691 +"# CONFIG_FS_POSIX_ACL is not set\n",
1692 +"# CONFIG_XFS_FS is not set\n",
1693 +"CONFIG_FILE_LOCKING=y\n",
1694 +"# CONFIG_FSNOTIFY is not set\n",
1695 +"# CONFIG_DNOTIFY is not set\n",
1696 +"# CONFIG_INOTIFY is not set\n",
1697 +"# CONFIG_INOTIFY_USER is not set\n",
1698 +"# CONFIG_QUOTA is not set\n",
1699 +"# CONFIG_AUTOFS_FS is not set\n",
1700 +"# CONFIG_AUTOFS4_FS is not set\n",
1701 +"# CONFIG_FUSE_FS is not set\n",
1702 +"\n",
1703 +"#\n",
1704 +"# Caches\n",
1705 +"#\n",
1706 +"\n",
1707 +"#\n",
1708 +"# CD-ROM/DVD Filesystems\n",
1709 +"#\n",
1710 +"# CONFIG_ISO9660_FS is not set\n",
1711 +"# CONFIG_UDF_FS is not set\n",
1712 +"\n",
1713 +"#\n",
1714 +"# DOS/FAT/NT Filesystems\n",
1715 +"#\n",
1716 +"# CONFIG_MSDOS_FS is not set\n",
1717 +"# CONFIG_VFAT_FS is not set\n",
1718 +"# CONFIG_NTFS_FS is not set\n",
1719 +"\n",
1720 +"#\n",
1721 +"# Pseudo filesystems\n",
1722 +"#\n",
1723 +"CONFIG_PROC_FS=y\n",
1724 +"# CONFIG_PROC_KCORE is not set\n",
1725 +"CONFIG_PROC_SYSCTL=y\n",
1726 +"CONFIG_PROC_PAGE_MONITOR=y\n",
1727 +"CONFIG_SYSFS=y\n",
1728 +"# CONFIG_TMPFS is not set\n",
1729 +"# CONFIG_HUGETLB_PAGE is not set\n",
1730 +"# CONFIG_CONFIGFS_FS is not set\n",
1731 +"# CONFIG_MISC_FILESYSTEMS is not set\n",
1732 +"\n",
1733 +"#\n",
1734 +"# Partition Types\n",
1735 +"#\n",
1736 +"# CONFIG_PARTITION_ADVANCED is not set\n",
1737 +"CONFIG_MSDOS_PARTITION=y\n",
1738 +"# CONFIG_NLS is not set\n",
1739 +"\n",
1740 +"#\n",
1741 +"# Linux VServer\n",
1742 +"#\n",
1743 +"# CONFIG_VSERVER_AUTO_LBACK is not set\n",
1744 +"# CONFIG_VSERVER_COWBL is not set\n",
1745 +"# CONFIG_VSERVER_PROC_SECURE is not set\n",
1746 +"# CONFIG_VSERVER_HARDCPU is not set\n",
1747 +"# CONFIG_TAGGING_NONE is not set\n",
1748 +"# CONFIG_TAGGING_UID16 is not set\n",
1749 +"# CONFIG_TAGGING_GID16 is not set\n",
1750 +"CONFIG_TAGGING_ID24=y\n",
1751 +"# CONFIG_TAGGING_INTERN is not set\n",
1752 +"# CONFIG_TAG_NFSD is not set\n",
1753 +"# CONFIG_VSERVER_PRIVACY is not set\n",
1754 +"CONFIG_VSERVER_CONTEXTS=768\n",
1755 +"# CONFIG_VSERVER_WARN is not set\n",
1756 +"# CONFIG_VSERVER_DEBUG is not set\n",
1757 +"CONFIG_VSERVER=y\n",
1758 +"\n",
1759 +"#\n",
1760 +"# Security options\n",
1761 +"#\n",
1762 +"# CONFIG_KEYS is not set\n",
1763 +"# CONFIG_SECURITY is not set\n",
1764 +"# CONFIG_SECURITYFS is not set\n",
1765 +"# CONFIG_DEFAULT_SECURITY_SELINUX is not set\n",
1766 +"# CONFIG_DEFAULT_SECURITY_SMACK is not set\n",
1767 +"# CONFIG_DEFAULT_SECURITY_TOMOYO is not set\n",
1768 +"CONFIG_DEFAULT_SECURITY_DAC=y\n",
1769 +"CONFIG_DEFAULT_SECURITY=\"\"\n",
1770 +"# CONFIG_CRYPTO is not set\n",
1771 +"# CONFIG_BINARY_PRINTF is not set\n",
1772 +"\n",
1773 +"#\n",
1774 +"# Library routines\n",
1775 +"#\n",
1776 +"CONFIG_GENERIC_FIND_FIRST_BIT=y\n",
1777 +"CONFIG_GENERIC_FIND_NEXT_BIT=y\n",
1778 +"CONFIG_GENERIC_FIND_LAST_BIT=y\n",
1779 +"# CONFIG_CRC_CCITT is not set\n",
1780 +"# CONFIG_CRC16 is not set\n",
1781 +"# CONFIG_CRC_T10DIF is not set\n",
1782 +"# CONFIG_CRC_ITU_T is not set\n",
1783 +"# CONFIG_CRC32 is not set\n",
1784 +"# CONFIG_CRC7 is not set\n",
1785 +"# CONFIG_LIBCRC32C is not set\n",
1786 +"CONFIG_HAS_DMA=y\n",
1787 +"\n",
1788 +"#\n",
1789 +"# SCSI device support\n",
1790 +"#\n",
1791 +"# CONFIG_RAID_ATTRS is not set\n",
1792 +"# CONFIG_SCSI is not set\n",
1793 +"# CONFIG_SCSI_DMA is not set\n",
1794 +"# CONFIG_SCSI_NETLINK is not set\n",
1795 +"# CONFIG_MD is not set\n",
1796 +"# CONFIG_NEW_LEDS is not set\n",
1797 +"# CONFIG_INPUT is not set\n",
1798 +"\n",
1799 +"#\n",
1800 +"# Kernel hacking\n",
1801 +"#\n",
1802 +"# CONFIG_PRINTK_TIME is not set\n",
1803 +"# CONFIG_ENABLE_WARN_DEPRECATED is not set\n",
1804 +"# CONFIG_ENABLE_MUST_CHECK is not set\n",
1805 +"CONFIG_FRAME_WARN=2048\n",
1806 +"# CONFIG_STRIP_ASM_SYMS is not set\n",
1807 +"# CONFIG_UNUSED_SYMBOLS is not set\n",
1808 +"# CONFIG_DEBUG_FS is not set\n",
1809 +"# CONFIG_DEBUG_KERNEL is not set\n",
1810 +"# CONFIG_SLUB_DEBUG_ON is not set\n",
1811 +"# CONFIG_SLUB_STATS is not set\n",
1812 +"CONFIG_DEBUG_BUGVERBOSE=y\n",
1813 +"CONFIG_DEBUG_MEMORY_INIT=y\n",
1814 +"# CONFIG_RCU_CPU_STALL_DETECTOR is not set\n",
1815 +"# CONFIG_SYSCTL_SYSCALL_CHECK is not set\n",
1816 +"# CONFIG_SAMPLES is not set\n",
1817 +"# CONFIG_DEBUG_STACK_USAGE is not set\n",
1818 diff -NurpP --minimal linux-2.6.34/arch/um/kernel/vmlinux.lds linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/kernel/vmlinux.lds
1819 --- linux-2.6.34/arch/um/kernel/vmlinux.lds     1970-01-01 01:00:00.000000000 +0100
1820 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/um/kernel/vmlinux.lds        2010-05-18 18:11:22.000000000 +0200
1821 @@ -0,0 +1,547 @@
1822 +
1823 +
1824 +/*
1825 + * Automatically generated C config: don't edit
1826 + * Linux kernel version: 2.6.33-vs2.3.0.36.29.1
1827 + * Wed Mar 10 20:12:10 2010
1828 + */
1829 +KERNEL_STACK_SIZE = 4096 * (1 << 1);
1830 +/*
1831 + * Helper macros to support writing architecture specific
1832 + * linker scripts.
1833 + *
1834 + * A minimal linker scripts has following content:
1835 + * [This is a sample, architectures may have special requiriements]
1836 + *
1837 + * OUTPUT_FORMAT(...)
1838 + * OUTPUT_ARCH(...)
1839 + * ENTRY(...)
1840 + * SECTIONS
1841 + * {
1842 + *     . = START;
1843 + *     __init_begin = .;
1844 + *     HEAD_TEXT_SECTION
1845 + *     INIT_TEXT_SECTION(PAGE_SIZE)
1846 + *     INIT_DATA_SECTION(...)
1847 + *     PERCPU(PAGE_SIZE)
1848 + *     __init_end = .;
1849 + *
1850 + *     _stext = .;
1851 + *     TEXT_SECTION = 0
1852 + *     _etext = .;
1853 + *
1854 + *      _sdata = .;
1855 + *     RO_DATA_SECTION(PAGE_SIZE)
1856 + *     RW_DATA_SECTION(...)
1857 + *     _edata = .;
1858 + *
1859 + *     EXCEPTION_TABLE(...)
1860 + *     NOTES
1861 + *
1862 + *     BSS_SECTION(0, 0, 0)
1863 + *     _end = .;
1864 + *
1865 + *     STABS_DEBUG
1866 + *     DWARF_DEBUG
1867 + *
1868 + *     DISCARDS                // must be the last
1869 + * }
1870 + *
1871 + * [__init_begin, __init_end] is the init section that may be freed after init
1872 + * [_stext, _etext] is the text section
1873 + * [_sdata, _edata] is the data section
1874 + *
1875 + * Some of the included output section have their own set of constants.
1876 + * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
1877 + *               [__nosave_begin, __nosave_end] for the nosave data
1878 + */
1879 +
1880 +
1881 +
1882 +
1883 +
1884 +
1885 +
1886 +/* Align . to a 8 byte boundary equals to maximum function alignment. */
1887 +
1888 +
1889 +/* The actual configuration determine if the init/exit sections
1890 + * are handled as text/data or they can be discarded (which
1891 + * often happens at runtime)
1892 + */
1893 +/* .data section */
1894 +/*
1895 + * Data section helpers
1896 + */
1897 +/*
1898 + * Read only Data
1899 + */
1900 +/* RODATA & RO_DATA provided for backward compatibility.
1901 + * All archs are supposed to use RO_DATA() */
1902 +/* .text section. Map to function alignment to avoid address changes
1903 + * during second ld run in second ld pass when generating System.map */
1904 +/* sched.text is aling to function alignment to secure we have same
1905 + * address even at second ld pass when generating System.map */
1906 +/* spinlock.text is aling to function alignment to secure we have same
1907 + * address even at second ld pass when generating System.map */
1908 +/* Section used for early init (in .S files) */
1909 +/*
1910 + * Exception table
1911 + */
1912 +/*
1913 + * Init task
1914 + */
1915 +/* init and exit section handling */
1916 +/*
1917 + * bss (Block Started by Symbol) - uninitialized data
1918 + * zeroed during startup
1919 + */
1920 +/*
1921 + * DWARF debug sections.
1922 + * Symbols in the DWARF debugging sections are relative to
1923 + * the beginning of the section so we begin them at 0.
1924 + */
1925 +  /* Stabs debugging sections.  */
1926 +/*
1927 + * Default discarded sections.
1928 + *
1929 + * Some archs want to discard exit text/data at runtime rather than
1930 + * link time due to cross-section references such as alt instructions,
1931 + * bug table, eh_frame, etc.  DISCARDS must be the last of output
1932 + * section definitions so that such archs put those in earlier section
1933 + * definitions.
1934 + */
1935 +/**
1936 + * PERCPU_VADDR - define output section for percpu area
1937 + * @vaddr: explicit base address (optional)
1938 + * @phdr: destination PHDR (optional)
1939 + *
1940 + * Macro which expands to output section for percpu area.  If @vaddr
1941 + * is not blank, it specifies explicit base address and all percpu
1942 + * symbols will be offset from the given address.  If blank, @vaddr
1943 + * always equals @laddr + LOAD_OFFSET.
1944 + *
1945 + * @phdr defines the output PHDR to use if not blank.  Be warned that
1946 + * output PHDR is sticky.  If @phdr is specified, the next output
1947 + * section in the linker script will go there too.  @phdr should have
1948 + * a leading colon.
1949 + *
1950 + * Note that this macros defines __per_cpu_load as an absolute symbol.
1951 + * If there is no need to put the percpu section at a predetermined
1952 + * address, use PERCPU().
1953 + */
1954 +/**
1955 + * PERCPU - define output section for percpu area, simple version
1956 + * @align: required alignment
1957 + *
1958 + * Align to @align and outputs output section for percpu area.  This
1959 + * macro doesn't maniuplate @vaddr or @phdr and __per_cpu_load and
1960 + * __per_cpu_start will be identical.
1961 + *
1962 + * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except
1963 + * that __per_cpu_load is defined as a relative symbol against
1964 + * .data.percpu which is required for relocatable x86_32
1965 + * configuration.
1966 + */
1967 +/*
1968 + * Definition of the high level *_SECTION macros
1969 + * They will fit only a subset of the architectures
1970 + */
1971 +/*
1972 + * Writeable data.
1973 + * All sections are combined in a single .data section.
1974 + * The sections following CONSTRUCTORS are arranged so their
1975 + * typical alignment matches.
1976 + * A cacheline is typical/always less than a PAGE_SIZE so
1977 + * the sections that has this restriction (or similar)
1978 + * is located before the ones requiring PAGE_SIZE alignment.
1979 + * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
1980 + * matches the requirment of PAGE_ALIGNED_DATA.
1981 + *
1982 + * use 0 as page_align if page_aligned data is not used */
1983 +/*
1984 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
1985 + * Copyright 2003 PathScale, Inc.
1986 + * Licensed under the GPL
1987 + */
1988 +/* const.h: Macros for dealing with constants.  */
1989 +/* Some constant macros are used in both assembler and
1990 + * C code.  Therefore we cannot annotate them always with
1991 + * 'UL' and other type specifiers unilaterally.  We
1992 + * use the following macros to deal with this.
1993 + *
1994 + * Similarly, _AT() will cast an expression with a type in C, but
1995 + * leave it unchanged in asm.
1996 + */
1997 +/* PAGE_SHIFT determines the page size */
1998 +OUTPUT_FORMAT(elf64-x86-64)
1999 +OUTPUT_ARCH(i386:x86-64)
2000 +ENTRY(_start)
2001 +jiffies = jiffies_64;
2002 +SECTIONS
2003 +{
2004 +  PROVIDE (__executable_start = 0x60000000);
2005 +  . = 0x60000000 + SIZEOF_HEADERS;
2006 +  .interp : { *(.interp) }
2007 +  __binary_start = .;
2008 +  . = ALIGN(4096); /* Init code and data */
2009 +  _text = .;
2010 +  _stext = .;
2011 +  __init_begin = .;
2012 +  . = ALIGN((1 << 12)); .init.text : AT(ADDR(.init.text) - 0) { _sinittext = .; *(.init.text) *(.cpuinit.text) *(.meminit.text) _einittext = .; }
2013 +  . = ALIGN((1 << 12));
2014 +  /* Read-only sections, merged into text segment: */
2015 +  .hash : { *(.hash) }
2016 +  .gnu.hash : { *(.gnu.hash) }
2017 +  .dynsym : { *(.dynsym) }
2018 +  .dynstr : { *(.dynstr) }
2019 +  .gnu.version : { *(.gnu.version) }
2020 +  .gnu.version_d : { *(.gnu.version_d) }
2021 +  .gnu.version_r : { *(.gnu.version_r) }
2022 +  .rel.init : { *(.rel.init) }
2023 +  .rela.init : { *(.rela.init) }
2024 +  .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
2025 +  .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
2026 +  .rel.fini : { *(.rel.fini) }
2027 +  .rela.fini : { *(.rela.fini) }
2028 +  .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
2029 +  .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
2030 +  .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
2031 +  .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
2032 +  .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
2033 +  .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
2034 +  .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
2035 +  .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
2036 +  .rel.ctors : { *(.rel.ctors) }
2037 +  .rela.ctors : { *(.rela.ctors) }
2038 +  .rel.dtors : { *(.rel.dtors) }
2039 +  .rela.dtors : { *(.rela.dtors) }
2040 +  .rel.got : { *(.rel.got) }
2041 +  .rela.got : { *(.rela.got) }
2042 +  .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
2043 +  .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
2044 +  .rel.plt : { *(.rel.plt) }
2045 +  .rela.plt : { *(.rela.plt) }
2046 +  .init : {
2047 +    KEEP (*(.init))
2048 +  } =0x90909090
2049 +  .plt : { *(.plt) }
2050 +  .text : {
2051 +    . = ALIGN(8); *(.text.hot) *(.text) *(.ref.text) *(.devinit.text) *(.devexit.text) *(.text.unlikely)
2052 +    . = ALIGN(8); __sched_text_start = .; *(.sched.text) __sched_text_end = .;
2053 +    . = ALIGN(8); __lock_text_start = .; *(.spinlock.text) __lock_text_end = .;
2054 +    *(.fixup)
2055 +    *(.stub .text.* .gnu.linkonce.t.*)
2056 +    /* .gnu.warning sections are handled specially by elf32.em.  */
2057 +    *(.gnu.warning)
2058 +    . = ALIGN((1 << 12));
2059 +  } =0x90909090
2060 +  . = ALIGN((1 << 12));
2061 +  .syscall_stub : {
2062 + __syscall_stub_start = .;
2063 + *(.__syscall_stub*)
2064 + __syscall_stub_end = .;
2065 +  }
2066 +  .fini : {
2067 +    KEEP (*(.fini))
2068 +  } =0x90909090
2069 +  .kstrtab : { *(.kstrtab) }
2070 +/*
2071 + * Helper macros to support writing architecture specific
2072 + * linker scripts.
2073 + *
2074 + * A minimal linker scripts has following content:
2075 + * [This is a sample, architectures may have special requiriements]
2076 + *
2077 + * OUTPUT_FORMAT(...)
2078 + * OUTPUT_ARCH(...)
2079 + * ENTRY(...)
2080 + * SECTIONS
2081 + * {
2082 + *     . = START;
2083 + *     __init_begin = .;
2084 + *     HEAD_TEXT_SECTION
2085 + *     INIT_TEXT_SECTION(PAGE_SIZE)
2086 + *     INIT_DATA_SECTION(...)
2087 + *     PERCPU(PAGE_SIZE)
2088 + *     __init_end = .;
2089 + *
2090 + *     _stext = .;
2091 + *     TEXT_SECTION = 0
2092 + *     _etext = .;
2093 + *
2094 + *      _sdata = .;
2095 + *     RO_DATA_SECTION(PAGE_SIZE)
2096 + *     RW_DATA_SECTION(...)
2097 + *     _edata = .;
2098 + *
2099 + *     EXCEPTION_TABLE(...)
2100 + *     NOTES
2101 + *
2102 + *     BSS_SECTION(0, 0, 0)
2103 + *     _end = .;
2104 + *
2105 + *     STABS_DEBUG
2106 + *     DWARF_DEBUG
2107 + *
2108 + *     DISCARDS                // must be the last
2109 + * }
2110 + *
2111 + * [__init_begin, __init_end] is the init section that may be freed after init
2112 + * [_stext, _etext] is the text section
2113 + * [_sdata, _edata] is the data section
2114 + *
2115 + * Some of the included output section have their own set of constants.
2116 + * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
2117 + *               [__nosave_begin, __nosave_end] for the nosave data
2118 + */
2119 +/* Align . to a 8 byte boundary equals to maximum function alignment. */
2120 +/* The actual configuration determine if the init/exit sections
2121 + * are handled as text/data or they can be discarded (which
2122 + * often happens at runtime)
2123 + */
2124 +/* .data section */
2125 +/*
2126 + * Data section helpers
2127 + */
2128 +/*
2129 + * Read only Data
2130 + */
2131 +/* RODATA & RO_DATA provided for backward compatibility.
2132 + * All archs are supposed to use RO_DATA() */
2133 +/* .text section. Map to function alignment to avoid address changes
2134 + * during second ld run in second ld pass when generating System.map */
2135 +/* sched.text is aling to function alignment to secure we have same
2136 + * address even at second ld pass when generating System.map */
2137 +/* spinlock.text is aling to function alignment to secure we have same
2138 + * address even at second ld pass when generating System.map */
2139 +/* Section used for early init (in .S files) */
2140 +/*
2141 + * Exception table
2142 + */
2143 +/*
2144 + * Init task
2145 + */
2146 +/* init and exit section handling */
2147 +/*
2148 + * bss (Block Started by Symbol) - uninitialized data
2149 + * zeroed during startup
2150 + */
2151 +/*
2152 + * DWARF debug sections.
2153 + * Symbols in the DWARF debugging sections are relative to
2154 + * the beginning of the section so we begin them at 0.
2155 + */
2156 +  /* Stabs debugging sections.  */
2157 +/*
2158 + * Default discarded sections.
2159 + *
2160 + * Some archs want to discard exit text/data at runtime rather than
2161 + * link time due to cross-section references such as alt instructions,
2162 + * bug table, eh_frame, etc.  DISCARDS must be the last of output
2163 + * section definitions so that such archs put those in earlier section
2164 + * definitions.
2165 + */
2166 +/**
2167 + * PERCPU_VADDR - define output section for percpu area
2168 + * @vaddr: explicit base address (optional)
2169 + * @phdr: destination PHDR (optional)
2170 + *
2171 + * Macro which expands to output section for percpu area.  If @vaddr
2172 + * is not blank, it specifies explicit base address and all percpu
2173 + * symbols will be offset from the given address.  If blank, @vaddr
2174 + * always equals @laddr + LOAD_OFFSET.
2175 + *
2176 + * @phdr defines the output PHDR to use if not blank.  Be warned that
2177 + * output PHDR is sticky.  If @phdr is specified, the next output
2178 + * section in the linker script will go there too.  @phdr should have
2179 + * a leading colon.
2180 + *
2181 + * Note that this macros defines __per_cpu_load as an absolute symbol.
2182 + * If there is no need to put the percpu section at a predetermined
2183 + * address, use PERCPU().
2184 + */
2185 +/**
2186 + * PERCPU - define output section for percpu area, simple version
2187 + * @align: required alignment
2188 + *
2189 + * Align to @align and outputs output section for percpu area.  This
2190 + * macro doesn't maniuplate @vaddr or @phdr and __per_cpu_load and
2191 + * __per_cpu_start will be identical.
2192 + *
2193 + * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except
2194 + * that __per_cpu_load is defined as a relative symbol against
2195 + * .data.percpu which is required for relocatable x86_32
2196 + * configuration.
2197 + */
2198 +/*
2199 + * Definition of the high level *_SECTION macros
2200 + * They will fit only a subset of the architectures
2201 + */
2202 +/*
2203 + * Writeable data.
2204 + * All sections are combined in a single .data section.
2205 + * The sections following CONSTRUCTORS are arranged so their
2206 + * typical alignment matches.
2207 + * A cacheline is typical/always less than a PAGE_SIZE so
2208 + * the sections that has this restriction (or similar)
2209 + * is located before the ones requiring PAGE_SIZE alignment.
2210 + * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
2211 + * matches the requirment of PAGE_ALIGNED_DATA.
2212 + *
2213 + * use 0 as page_align if page_aligned data is not used */
2214 +  .fini : { *(.fini) } =0x9090
2215 +  _etext = .;
2216 +  PROVIDE (etext = .);
2217 +  . = ALIGN(4096);
2218 +  _sdata = .;
2219 +  PROVIDE (sdata = .);
2220 +  . = 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));
2221 +  .unprotected : { *(.unprotected) }
2222 +  . = ALIGN(4096);
2223 +  PROVIDE (_unprotected_end = .);
2224 +  . = ALIGN(4096);
2225 +  .note : { *(.note.*) }
2226 +  . = ALIGN(0); __ex_table : AT(ADDR(__ex_table) - 0) { __start___ex_table = .; *(__ex_table) __stop___ex_table = .; }
2227 +  . = ALIGN(8); __bug_table : AT(ADDR(__bug_table) - 0) { __start___bug_table = .; *(__bug_table) __stop___bug_table = .; }
2228 +  .uml.setup.init : {
2229 + __uml_setup_start = .;
2230 + *(.uml.setup.init)
2231 + __uml_setup_end = .;
2232 +  }
2233 +  .uml.help.init : {
2234 + __uml_help_start = .;
2235 + *(.uml.help.init)
2236 + __uml_help_end = .;
2237 +  }
2238 +  .uml.postsetup.init : {
2239 + __uml_postsetup_start = .;
2240 + *(.uml.postsetup.init)
2241 + __uml_postsetup_end = .;
2242 +  }
2243 +  .init.setup : {
2244 + . = ALIGN(0); __setup_start = .; *(.init.setup) __setup_end = .;
2245 +  }
2246 +  . = 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 = .; }
2247 +  .initcall.init : {
2248 + __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 = .;
2249 +  }
2250 +  .con_initcall.init : {
2251 + __con_initcall_start = .; *(.con_initcall.init) __con_initcall_end = .;
2252 +  }
2253 +  .uml.initcall.init : {
2254 + __uml_initcall_start = .;
2255 + *(.uml.initcall.init)
2256 + __uml_initcall_end = .;
2257 +  }
2258 +  __init_end = .;
2259 +  .security_initcall.init : AT(ADDR(.security_initcall.init) - 0) { __security_initcall_start = .; *(.security_initcall.init) __security_initcall_end = .; }
2260 +  .exitcall : {
2261 + __exitcall_begin = .;
2262 + *(.exitcall.exit)
2263 + __exitcall_end = .;
2264 +  }
2265 +  .uml.exitcall : {
2266 + __uml_exitcall_begin = .;
2267 + *(.uml.exitcall.exit)
2268 + __uml_exitcall_end = .;
2269 +  }
2270 +  . = ALIGN(4);
2271 +  .altinstructions : {
2272 + __alt_instructions = .;
2273 + *(.altinstructions)
2274 + __alt_instructions_end = .;
2275 +  }
2276 +  .altinstr_replacement : { *(.altinstr_replacement) }
2277 +  /* .exit.text is discard at runtime, not link time, to deal with references
2278 +     from .altinstructions and .eh_frame */
2279 +  .exit.text : { *(.exit.text) }
2280 +  .exit.data : { *(.exit.data) }
2281 +  .preinit_array : {
2282 + __preinit_array_start = .;
2283 + *(.preinit_array)
2284 + __preinit_array_end = .;
2285 +  }
2286 +  .init_array : {
2287 + __init_array_start = .;
2288 + *(.init_array)
2289 + __init_array_end = .;
2290 +  }
2291 +  .fini_array : {
2292 + __fini_array_start = .;
2293 + *(.fini_array)
2294 + __fini_array_end = .;
2295 +  }
2296 +   . = ALIGN(4096);
2297 +  .init.ramfs : {
2298 +
2299 +  }
2300 +  init.data : { *(.init.data) *(.cpuinit.data) *(.meminit.data) *(.init.rodata) *(.cpuinit.rodata) *(.meminit.rodata) }
2301 +  /* Ensure the __preinit_array_start label is properly aligned.  We
2302 +     could instead move the label definition inside the section, but
2303 +     the linker would then create the section even if it turns out to
2304 +     be empty, which isn't pretty.  */
2305 +  . = ALIGN(32 / 8);
2306 +  .preinit_array : { *(.preinit_array) }
2307 +  .init_array : { *(.init_array) }
2308 +  .fini_array : { *(.fini_array) }
2309 +  .data : {
2310 +    . = ALIGN(KERNEL_STACK_SIZE); *(.data.init_task)
2311 +    . = ALIGN(KERNEL_STACK_SIZE);
2312 +    *(.data.init_irqstack)
2313 +    *(.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 = .;
2314 +    *(.data.* .gnu.linkonce.d.*)
2315 +    SORT(CONSTRUCTORS)
2316 +  }
2317 +  .data1 : { *(.data1) }
2318 +  .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
2319 +  .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
2320 +  .eh_frame : { KEEP (*(.eh_frame)) }
2321 +  .gcc_except_table : { *(.gcc_except_table) }
2322 +  .dynamic : { *(.dynamic) }
2323 +  .ctors : {
2324 +    /* gcc uses crtbegin.o to find the start of
2325 +       the constructors, so we make sure it is
2326 +       first.  Because this is a wildcard, it
2327 +       doesn't matter if the user does not
2328 +       actually link against crtbegin.o; the
2329 +       linker won't look for a file to match a
2330 +       wildcard.  The wildcard also means that it
2331 +       doesn't matter which directory crtbegin.o
2332 +       is in.  */
2333 +    KEEP (*crtbegin.o(.ctors))
2334 +    /* We don't want to include the .ctor section from
2335 +       from the crtend.o file until after the sorted ctors.
2336 +       The .ctor section from the crtend file contains the
2337 +       end of ctors marker and it must be last */
2338 +    KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
2339 +    KEEP (*(SORT(.ctors.*)))
2340 +    KEEP (*(.ctors))
2341 +  }
2342 +  .dtors : {
2343 +    KEEP (*crtbegin.o(.dtors))
2344 +    KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
2345 +    KEEP (*(SORT(.dtors.*)))
2346 +    KEEP (*(.dtors))
2347 +  }
2348 +  .jcr : { KEEP (*(.jcr)) }
2349 +  .got : { *(.got.plt) *(.got) }
2350 +  _edata = .;
2351 +  PROVIDE (edata = .);
2352 +  .bss : {
2353 +   __bss_start = .;
2354 +   *(.dynbss)
2355 +   *(.bss .bss.* .gnu.linkonce.b.*)
2356 +   *(COMMON)
2357 +   /* Align here to ensure that the .bss section occupies space up to
2358 +      _end.  Align after .bss to ensure correct alignment even if the
2359 +      .bss section disappears because there are no input sections.  */
2360 +   . = ALIGN(32 / 8);
2361 +  . = ALIGN(32 / 8);
2362 +  }
2363 +  _end = .;
2364 +  PROVIDE (end = .);
2365 +  .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) }
2366 +  .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) }
2367 +  /DISCARD/ : { *(.exit.text) *(.cpuexit.text) *(.memexit.text) *(.exit.data) *(.cpuexit.data) *(.cpuexit.rodata) *(.memexit.data) *(.memexit.rodata) *(.exitcall.exit) *(.discard) }
2368 +}
2369 diff -NurpP --minimal linux-2.6.34/arch/x86/ia32/ia32entry.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/x86/ia32/ia32entry.S
2370 --- linux-2.6.34/arch/x86/ia32/ia32entry.S      2010-05-18 15:07:45.000000000 +0200
2371 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/x86/ia32/ia32entry.S 2010-05-18 18:11:22.000000000 +0200
2372 @@ -777,7 +777,7 @@ ia32_sys_call_table:
2373         .quad sys_tgkill                /* 270 */
2374         .quad compat_sys_utimes
2375         .quad sys32_fadvise64_64
2376 -       .quad quiet_ni_syscall  /* sys_vserver */
2377 +       .quad sys32_vserver
2378         .quad sys_mbind
2379         .quad compat_sys_get_mempolicy  /* 275 */
2380         .quad sys_set_mempolicy
2381 diff -NurpP --minimal linux-2.6.34/arch/x86/include/asm/unistd_64.h linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/x86/include/asm/unistd_64.h
2382 --- linux-2.6.34/arch/x86/include/asm/unistd_64.h       2010-05-18 15:07:45.000000000 +0200
2383 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/x86/include/asm/unistd_64.h  2010-05-18 18:11:22.000000000 +0200
2384 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
2385  #define __NR_utimes                            235
2386  __SYSCALL(__NR_utimes, sys_utimes)
2387  #define __NR_vserver                           236
2388 -__SYSCALL(__NR_vserver, sys_ni_syscall)
2389 +__SYSCALL(__NR_vserver, sys_vserver)
2390  #define __NR_mbind                             237
2391  __SYSCALL(__NR_mbind, sys_mbind)
2392  #define __NR_set_mempolicy                     238
2393 diff -NurpP --minimal linux-2.6.34/arch/x86/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/x86/Kconfig
2394 --- linux-2.6.34/arch/x86/Kconfig       2010-05-18 15:07:45.000000000 +0200
2395 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/x86/Kconfig  2010-05-18 18:11:22.000000000 +0200
2396 @@ -2118,6 +2118,8 @@ source "fs/Kconfig"
2397  
2398  source "arch/x86/Kconfig.debug"
2399  
2400 +source "kernel/vserver/Kconfig"
2401 +
2402  source "security/Kconfig"
2403  
2404  source "crypto/Kconfig"
2405 diff -NurpP --minimal linux-2.6.34/arch/x86/kernel/syscall_table_32.S linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/x86/kernel/syscall_table_32.S
2406 --- linux-2.6.34/arch/x86/kernel/syscall_table_32.S     2010-05-18 15:07:45.000000000 +0200
2407 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/x86/kernel/syscall_table_32.S        2010-05-18 18:11:22.000000000 +0200
2408 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
2409         .long sys_tgkill        /* 270 */
2410         .long sys_utimes
2411         .long sys_fadvise64_64
2412 -       .long sys_ni_syscall    /* sys_vserver */
2413 +       .long sys_vserver
2414         .long sys_mbind
2415         .long sys_get_mempolicy
2416         .long sys_set_mempolicy
2417 diff -NurpP --minimal linux-2.6.34/arch/xtensa/mm/fault.c linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/xtensa/mm/fault.c
2418 --- linux-2.6.34/arch/xtensa/mm/fault.c 2009-09-10 15:25:48.000000000 +0200
2419 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/arch/xtensa/mm/fault.c    2010-05-18 18:11:22.000000000 +0200
2420 @@ -151,7 +151,8 @@ out_of_memory:
2421                 down_read(&mm->mmap_sem);
2422                 goto survive;
2423         }
2424 -       printk("VM: killing process %s\n", current->comm);
2425 +       printk("VM: killing process %s(%d:#%u)\n",
2426 +               current->comm, task_pid_nr(current), current->xid);
2427         if (user_mode(regs))
2428                 do_group_exit(SIGKILL);
2429         bad_page_fault(regs, address, SIGKILL);
2430 diff -NurpP --minimal linux-2.6.34/Documentation/vserver/debug.txt linux-2.6.34-vs2.3.0.36.30.4.pre6/Documentation/vserver/debug.txt
2431 --- linux-2.6.34/Documentation/vserver/debug.txt        1970-01-01 01:00:00.000000000 +0100
2432 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/Documentation/vserver/debug.txt   2010-05-18 18:11:22.000000000 +0200
2433 @@ -0,0 +1,154 @@
2434 +
2435 +debug_cvirt:
2436 +
2437 + 2   4 "vx_map_tgid: %p/%llx: %d -> %d"
2438 +       "vx_rmap_tgid: %p/%llx: %d -> %d"
2439 +
2440 +debug_dlim:
2441 +
2442 + 0   1 "ALLOC (%p,#%d)%c inode (%d)"
2443 +       "FREE  (%p,#%d)%c inode"
2444 + 1   2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
2445 +       "FREE  (%p,#%d)%c %lld bytes"
2446 + 2   4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
2447 + 3   8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
2448 +       "ext3_has_free_blocks(%p): free=%lu, root=%lu"
2449 +       "rcu_free_dl_info(%p)"
2450 + 4  10 "alloc_dl_info(%p,%d) = %p"
2451 +       "dealloc_dl_info(%p)"
2452 +       "get_dl_info(%p[#%d.%d])"
2453 +       "put_dl_info(%p[#%d.%d])"
2454 + 5  20 "alloc_dl_info(%p,%d)*"
2455 + 6  40 "__hash_dl_info: %p[#%d]"
2456 +       "__unhash_dl_info: %p[#%d]"
2457 + 7  80 "locate_dl_info(%p,#%d) = %p"
2458 +
2459 +debug_misc:
2460 +
2461 + 0   1 "destroy_dqhash: %p [#0x%08x] c=%d"
2462 +       "new_dqhash: %p [#0x%08x]"
2463 +       "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
2464 +       "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
2465 +       "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
2466 +       "vroot_get_real_bdev not set"
2467 + 1   2 "cow_break_link(»%s«)"
2468 +       "temp copy Â»%s«"
2469 + 2   4 "dentry_open(new): %p"
2470 +       "dentry_open(old): %p"
2471 +       "lookup_create(new): %p"
2472 +       "old path Â»%s«"
2473 +       "path_lookup(old): %d"
2474 +       "vfs_create(new): %d"
2475 +       "vfs_rename: %d"
2476 +       "vfs_sendfile: %d"
2477 + 3   8 "fput(new_file=%p[#%d])"
2478 +       "fput(old_file=%p[#%d])"
2479 + 4  10 "vx_info_kill(%p[#%d],%d,%d) = %d"
2480 +       "vx_info_kill(%p[#%d],%d,%d)*"
2481 + 5  20 "vs_reboot(%p[#%d],%d)"
2482 + 6  40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
2483 +
2484 +debug_net:
2485 +
2486 + 2   4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
2487 + 3   8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
2488 +       "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
2489 + 4  10 "ip_route_connect(%p) %p,%p;%lx"
2490 + 5  20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
2491 + 6  40 "sk,egf: %p [#%d] (from %d)"
2492 +       "sk,egn: %p [#%d] (from %d)"
2493 +       "sk,req: %p [#%d] (from %d)"
2494 +       "sk: %p [#%d] (from %d)"
2495 +       "tw: %p [#%d] (from %d)"
2496 + 7  80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
2497 +       "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
2498 +
2499 +debug_nid:
2500 +
2501 + 0   1 "__lookup_nx_info(#%u): %p[#%u]"
2502 +       "alloc_nx_info(%d) = %p"
2503 +       "create_nx_info(%d) (dynamic rejected)"
2504 +       "create_nx_info(%d) = %p (already there)"
2505 +       "create_nx_info(%d) = %p (new)"
2506 +       "dealloc_nx_info(%p)"
2507 + 1   2 "alloc_nx_info(%d)*"
2508 +       "create_nx_info(%d)*"
2509 + 2   4 "get_nx_info(%p[#%d.%d])"
2510 +       "put_nx_info(%p[#%d.%d])"
2511 + 3   8 "claim_nx_info(%p[#%d.%d.%d]) %p"
2512 +       "clr_nx_info(%p[#%d.%d])"
2513 +       "init_nx_info(%p[#%d.%d])"
2514 +       "release_nx_info(%p[#%d.%d.%d]) %p"
2515 +       "set_nx_info(%p[#%d.%d])"
2516 + 4  10 "__hash_nx_info: %p[#%d]"
2517 +       "__nx_dynamic_id: [#%d]"
2518 +       "__unhash_nx_info: %p[#%d.%d.%d]"
2519 + 5  20 "moved task %p into nxi:%p[#%d]"
2520 +       "nx_migrate_task(%p,%p[#%d.%d.%d])"
2521 +       "task_get_nx_info(%p)"
2522 + 6  40 "nx_clear_persistent(%p[#%d])"
2523 +
2524 +debug_quota:
2525 +
2526 + 0   1 "quota_sync_dqh(%p,%d) discard inode %p"
2527 + 1   2 "quota_sync_dqh(%p,%d)"
2528 +       "sync_dquots(%p,%d)"
2529 +       "sync_dquots_dqh(%p,%d)"
2530 + 3   8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
2531 +
2532 +debug_switch:
2533 +
2534 + 0   1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
2535 + 1   2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
2536 + 4  10 "%s: (%s %s) returned %s with %d"
2537 +
2538 +debug_tag:
2539 +
2540 + 7  80 "dx_parse_tag(»%s«): %d:#%d"
2541 +       "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
2542 +
2543 +debug_xid:
2544 +
2545 + 0   1 "__lookup_vx_info(#%u): %p[#%u]"
2546 +       "alloc_vx_info(%d) = %p"
2547 +       "alloc_vx_info(%d)*"
2548 +       "create_vx_info(%d) (dynamic rejected)"
2549 +       "create_vx_info(%d) = %p (already there)"
2550 +       "create_vx_info(%d) = %p (new)"
2551 +       "dealloc_vx_info(%p)"
2552 +       "loc_vx_info(%d) = %p (found)"
2553 +       "loc_vx_info(%d) = %p (new)"
2554 +       "loc_vx_info(%d) = %p (not available)"
2555 + 1   2 "create_vx_info(%d)*"
2556 +       "loc_vx_info(%d)*"
2557 + 2   4 "get_vx_info(%p[#%d.%d])"
2558 +       "put_vx_info(%p[#%d.%d])"
2559 + 3   8 "claim_vx_info(%p[#%d.%d.%d]) %p"
2560 +       "clr_vx_info(%p[#%d.%d])"
2561 +       "init_vx_info(%p[#%d.%d])"
2562 +       "release_vx_info(%p[#%d.%d.%d]) %p"
2563 +       "set_vx_info(%p[#%d.%d])"
2564 + 4  10 "__hash_vx_info: %p[#%d]"
2565 +       "__unhash_vx_info: %p[#%d.%d.%d]"
2566 +       "__vx_dynamic_id: [#%d]"
2567 + 5  20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
2568 +       "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
2569 +       "moved task %p into vxi:%p[#%d]"
2570 +       "task_get_vx_info(%p)"
2571 +       "vx_migrate_task(%p,%p[#%d.%d])"
2572 + 6  40 "vx_clear_persistent(%p[#%d])"
2573 +       "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
2574 +       "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
2575 +       "vx_set_persistent(%p[#%d])"
2576 +       "vx_set_reaper(%p[#%d],%p[#%d,%d])"
2577 + 7  80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
2578 +
2579 +
2580 +debug_limit:
2581 +
2582 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
2583 +       "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
2584 +
2585 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
2586 +       "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
2587 +       "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
2588 diff -NurpP --minimal linux-2.6.34/drivers/block/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/block/Kconfig
2589 --- linux-2.6.34/drivers/block/Kconfig  2010-02-25 11:51:36.000000000 +0100
2590 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/block/Kconfig     2010-05-18 18:11:22.000000000 +0200
2591 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
2592  
2593  source "drivers/block/drbd/Kconfig"
2594  
2595 +config BLK_DEV_VROOT
2596 +       tristate "Virtual Root device support"
2597 +       depends on QUOTACTL
2598 +       ---help---
2599 +         Saying Y here will allow you to use quota/fs ioctls on a shared
2600 +         partition within a virtual server without compromising security.
2601 +
2602  config BLK_DEV_NBD
2603         tristate "Network block device support"
2604         depends on NET
2605 diff -NurpP --minimal linux-2.6.34/drivers/block/loop.c linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/block/loop.c
2606 --- linux-2.6.34/drivers/block/loop.c   2010-05-18 15:07:45.000000000 +0200
2607 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/block/loop.c      2010-05-18 18:11:22.000000000 +0200
2608 @@ -73,6 +73,7 @@
2609  #include <linux/highmem.h>
2610  #include <linux/kthread.h>
2611  #include <linux/splice.h>
2612 +#include <linux/vs_context.h>
2613  
2614  #include <asm/uaccess.h>
2615  
2616 @@ -813,6 +814,7 @@ static int loop_set_fd(struct loop_devic
2617         lo->lo_blocksize = lo_blocksize;
2618         lo->lo_device = bdev;
2619         lo->lo_flags = lo_flags;
2620 +       lo->lo_xid = vx_current_xid();
2621         lo->lo_backing_file = file;
2622         lo->transfer = transfer_none;
2623         lo->ioctl = NULL;
2624 @@ -938,6 +940,7 @@ static int loop_clr_fd(struct loop_devic
2625         lo->lo_encrypt_key_size = 0;
2626         lo->lo_flags = 0;
2627         lo->lo_thread = NULL;
2628 +       lo->lo_xid = 0;
2629         memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2630         memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2631         memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2632 @@ -972,7 +975,7 @@ loop_set_status(struct loop_device *lo, 
2633  
2634         if (lo->lo_encrypt_key_size &&
2635             lo->lo_key_owner != uid &&
2636 -           !capable(CAP_SYS_ADMIN))
2637 +           !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2638                 return -EPERM;
2639         if (lo->lo_state != Lo_bound)
2640                 return -ENXIO;
2641 @@ -1056,7 +1059,8 @@ loop_get_status(struct loop_device *lo, 
2642         memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2643         info->lo_encrypt_type =
2644                 lo->lo_encryption ? lo->lo_encryption->number : 0;
2645 -       if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2646 +       if (lo->lo_encrypt_key_size &&
2647 +               vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2648                 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2649                 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2650                        lo->lo_encrypt_key_size);
2651 @@ -1400,6 +1404,9 @@ static int lo_open(struct block_device *
2652  {
2653         struct loop_device *lo = bdev->bd_disk->private_data;
2654  
2655 +       if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
2656 +               return -EACCES;
2657 +
2658         mutex_lock(&lo->lo_ctl_mutex);
2659         lo->lo_refcnt++;
2660         mutex_unlock(&lo->lo_ctl_mutex);
2661 diff -NurpP --minimal linux-2.6.34/drivers/block/Makefile linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/block/Makefile
2662 --- linux-2.6.34/drivers/block/Makefile 2010-02-25 11:51:36.000000000 +0100
2663 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/block/Makefile    2010-05-18 18:11:22.000000000 +0200
2664 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD)         += viodasd.o
2665  obj-$(CONFIG_BLK_DEV_SX8)      += sx8.o
2666  obj-$(CONFIG_BLK_DEV_UB)       += ub.o
2667  obj-$(CONFIG_BLK_DEV_HD)       += hd.o
2668 +obj-$(CONFIG_BLK_DEV_VROOT)    += vroot.o
2669  
2670  obj-$(CONFIG_XEN_BLKDEV_FRONTEND)      += xen-blkfront.o
2671  obj-$(CONFIG_BLK_DEV_DRBD)     += drbd/
2672 diff -NurpP --minimal linux-2.6.34/drivers/block/vroot.c linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/block/vroot.c
2673 --- linux-2.6.34/drivers/block/vroot.c  1970-01-01 01:00:00.000000000 +0100
2674 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/block/vroot.c     2010-05-18 18:11:22.000000000 +0200
2675 @@ -0,0 +1,281 @@
2676 +/*
2677 + *  linux/drivers/block/vroot.c
2678 + *
2679 + *  written by Herbert Pötzl, 9/11/2002
2680 + *  ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2681 + *
2682 + *  based on the loop.c code by Theodore Ts'o.
2683 + *
2684 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2685 + * Redistribution of this file is permitted under the
2686 + * GNU General Public License.
2687 + *
2688 + */
2689 +
2690 +#include <linux/module.h>
2691 +#include <linux/moduleparam.h>
2692 +#include <linux/file.h>
2693 +#include <linux/major.h>
2694 +#include <linux/blkdev.h>
2695 +
2696 +#include <linux/vroot.h>
2697 +#include <linux/vs_context.h>
2698 +
2699 +
2700 +static int max_vroot = 8;
2701 +
2702 +static struct vroot_device *vroot_dev;
2703 +static struct gendisk **disks;
2704 +
2705 +
2706 +static int vroot_set_dev(
2707 +       struct vroot_device *vr,
2708 +       struct block_device *bdev,
2709 +       unsigned int arg)
2710 +{
2711 +       struct block_device *real_bdev;
2712 +       struct file *file;
2713 +       struct inode *inode;
2714 +       int error;
2715 +
2716 +       error = -EBUSY;
2717 +       if (vr->vr_state != Vr_unbound)
2718 +               goto out;
2719 +
2720 +       error = -EBADF;
2721 +       file = fget(arg);
2722 +       if (!file)
2723 +               goto out;
2724 +
2725 +       error = -EINVAL;
2726 +       inode = file->f_dentry->d_inode;
2727 +
2728 +
2729 +       if (S_ISBLK(inode->i_mode)) {
2730 +               real_bdev = inode->i_bdev;
2731 +               vr->vr_device = real_bdev;
2732 +               __iget(real_bdev->bd_inode);
2733 +       } else
2734 +               goto out_fput;
2735 +
2736 +       vxdprintk(VXD_CBIT(misc, 0),
2737 +               "vroot[%d]_set_dev: dev=" VXF_DEV,
2738 +               vr->vr_number, VXD_DEV(real_bdev));
2739 +
2740 +       vr->vr_state = Vr_bound;
2741 +       error = 0;
2742 +
2743 + out_fput:
2744 +       fput(file);
2745 + out:
2746 +       return error;
2747 +}
2748 +
2749 +static int vroot_clr_dev(
2750 +       struct vroot_device *vr,
2751 +       struct block_device *bdev)
2752 +{
2753 +       struct block_device *real_bdev;
2754 +
2755 +       if (vr->vr_state != Vr_bound)
2756 +               return -ENXIO;
2757 +       if (vr->vr_refcnt > 1)  /* we needed one fd for the ioctl */
2758 +               return -EBUSY;
2759 +
2760 +       real_bdev = vr->vr_device;
2761 +
2762 +       vxdprintk(VXD_CBIT(misc, 0),
2763 +               "vroot[%d]_clr_dev: dev=" VXF_DEV,
2764 +               vr->vr_number, VXD_DEV(real_bdev));
2765 +
2766 +       bdput(real_bdev);
2767 +       vr->vr_state = Vr_unbound;
2768 +       vr->vr_device = NULL;
2769 +       return 0;
2770 +}
2771 +
2772 +
2773 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
2774 +       unsigned int cmd, unsigned long arg)
2775 +{
2776 +       struct vroot_device *vr = bdev->bd_disk->private_data;
2777 +       int err;
2778 +
2779 +       down(&vr->vr_ctl_mutex);
2780 +       switch (cmd) {
2781 +       case VROOT_SET_DEV:
2782 +               err = vroot_set_dev(vr, bdev, arg);
2783 +               break;
2784 +       case VROOT_CLR_DEV:
2785 +               err = vroot_clr_dev(vr, bdev);
2786 +               break;
2787 +       default:
2788 +               err = -EINVAL;
2789 +               break;
2790 +       }
2791 +       up(&vr->vr_ctl_mutex);
2792 +       return err;
2793 +}
2794 +
2795 +static int vr_open(struct block_device *bdev, fmode_t mode)
2796 +{
2797 +       struct vroot_device *vr = bdev->bd_disk->private_data;
2798 +
2799 +       down(&vr->vr_ctl_mutex);
2800 +       vr->vr_refcnt++;
2801 +       up(&vr->vr_ctl_mutex);
2802 +       return 0;
2803 +}
2804 +
2805 +static int vr_release(struct gendisk *disk, fmode_t mode)
2806 +{
2807 +       struct vroot_device *vr = disk->private_data;
2808 +
2809 +       down(&vr->vr_ctl_mutex);
2810 +       --vr->vr_refcnt;
2811 +       up(&vr->vr_ctl_mutex);
2812 +       return 0;
2813 +}
2814 +
2815 +static struct block_device_operations vr_fops = {
2816 +       .owner =        THIS_MODULE,
2817 +       .open =         vr_open,
2818 +       .release =      vr_release,
2819 +       .ioctl =        vr_ioctl,
2820 +};
2821 +
2822 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2823 +{
2824 +       struct inode *inode = bdev->bd_inode;
2825 +       struct vroot_device *vr;
2826 +       struct block_device *real_bdev;
2827 +       int minor = iminor(inode);
2828 +
2829 +       vr = &vroot_dev[minor];
2830 +       real_bdev = vr->vr_device;
2831 +
2832 +       vxdprintk(VXD_CBIT(misc, 0),
2833 +               "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2834 +               vr->vr_number, VXD_DEV(real_bdev));
2835 +
2836 +       if (vr->vr_state != Vr_bound)
2837 +               return ERR_PTR(-ENXIO);
2838 +
2839 +       __iget(real_bdev->bd_inode);
2840 +       return real_bdev;
2841 +}
2842 +
2843 +/*
2844 + * And now the modules code and kernel interface.
2845 + */
2846 +
2847 +module_param(max_vroot, int, 0);
2848 +
2849 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
2850 +MODULE_LICENSE("GPL");
2851 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
2852 +
2853 +MODULE_AUTHOR ("Herbert Pötzl");
2854 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
2855 +
2856 +
2857 +int __init vroot_init(void)
2858 +{
2859 +       int err, i;
2860 +
2861 +       if (max_vroot < 1 || max_vroot > 256) {
2862 +               max_vroot = MAX_VROOT_DEFAULT;
2863 +               printk(KERN_WARNING "vroot: invalid max_vroot "
2864 +                       "(must be between 1 and 256), "
2865 +                       "using default (%d)\n", max_vroot);
2866 +       }
2867 +
2868 +       if (register_blkdev(VROOT_MAJOR, "vroot"))
2869 +               return -EIO;
2870 +
2871 +       err = -ENOMEM;
2872 +       vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2873 +       if (!vroot_dev)
2874 +               goto out_mem1;
2875 +       memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2876 +
2877 +       disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2878 +       if (!disks)
2879 +               goto out_mem2;
2880 +
2881 +       for (i = 0; i < max_vroot; i++) {
2882 +               disks[i] = alloc_disk(1);
2883 +               if (!disks[i])
2884 +                       goto out_mem3;
2885 +               disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
2886 +               if (!disks[i]->queue)
2887 +                       goto out_mem3;
2888 +       }
2889 +
2890 +       for (i = 0; i < max_vroot; i++) {
2891 +               struct vroot_device *vr = &vroot_dev[i];
2892 +               struct gendisk *disk = disks[i];
2893 +
2894 +               memset(vr, 0, sizeof(*vr));
2895 +               init_MUTEX(&vr->vr_ctl_mutex);
2896 +               vr->vr_number = i;
2897 +               disk->major = VROOT_MAJOR;
2898 +               disk->first_minor = i;
2899 +               disk->fops = &vr_fops;
2900 +               sprintf(disk->disk_name, "vroot%d", i);
2901 +               disk->private_data = vr;
2902 +       }
2903 +
2904 +       err = register_vroot_grb(&__vroot_get_real_bdev);
2905 +       if (err)
2906 +               goto out_mem3;
2907 +
2908 +       for (i = 0; i < max_vroot; i++)
2909 +               add_disk(disks[i]);
2910 +       printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2911 +       return 0;
2912 +
2913 +out_mem3:
2914 +       while (i--)
2915 +               put_disk(disks[i]);
2916 +       kfree(disks);
2917 +out_mem2:
2918 +       kfree(vroot_dev);
2919 +out_mem1:
2920 +       unregister_blkdev(VROOT_MAJOR, "vroot");
2921 +       printk(KERN_ERR "vroot: ran out of memory\n");
2922 +       return err;
2923 +}
2924 +
2925 +void vroot_exit(void)
2926 +{
2927 +       int i;
2928 +
2929 +       if (unregister_vroot_grb(&__vroot_get_real_bdev))
2930 +               printk(KERN_WARNING "vroot: cannot unregister grb\n");
2931 +
2932 +       for (i = 0; i < max_vroot; i++) {
2933 +               del_gendisk(disks[i]);
2934 +               put_disk(disks[i]);
2935 +       }
2936 +       unregister_blkdev(VROOT_MAJOR, "vroot");
2937 +
2938 +       kfree(disks);
2939 +       kfree(vroot_dev);
2940 +}
2941 +
2942 +module_init(vroot_init);
2943 +module_exit(vroot_exit);
2944 +
2945 +#ifndef MODULE
2946 +
2947 +static int __init max_vroot_setup(char *str)
2948 +{
2949 +       max_vroot = simple_strtol(str, NULL, 0);
2950 +       return 1;
2951 +}
2952 +
2953 +__setup("max_vroot=", max_vroot_setup);
2954 +
2955 +#endif
2956 +
2957 diff -NurpP --minimal linux-2.6.34/drivers/char/sysrq.c linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/char/sysrq.c
2958 --- linux-2.6.34/drivers/char/sysrq.c   2010-05-18 15:07:46.000000000 +0200
2959 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/char/sysrq.c      2010-05-18 18:11:22.000000000 +0200
2960 @@ -39,6 +39,7 @@
2961  #include <linux/hrtimer.h>
2962  #include <linux/oom.h>
2963  #include <linux/slab.h>
2964 +#include <linux/vserver/debug.h>
2965  
2966  #include <asm/ptrace.h>
2967  #include <asm/irq_regs.h>
2968 @@ -392,6 +393,21 @@ static struct sysrq_key_op sysrq_unrt_op
2969         .enable_mask    = SYSRQ_ENABLE_RTNICE,
2970  };
2971  
2972 +
2973 +#ifdef CONFIG_VSERVER_DEBUG
2974 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
2975 +{
2976 +       dump_vx_info_inactive((key == 'x')?0:1);
2977 +}
2978 +
2979 +static struct sysrq_key_op sysrq_showvxinfo_op = {
2980 +       .handler        = sysrq_handle_vxinfo,
2981 +       .help_msg       = "conteXt",
2982 +       .action_msg     = "Show Context Info",
2983 +       .enable_mask    = SYSRQ_ENABLE_DUMP,
2984 +};
2985 +#endif
2986 +
2987  /* Key Operations table and lock */
2988  static DEFINE_SPINLOCK(sysrq_key_table_lock);
2989  
2990 @@ -446,7 +462,11 @@ static struct sysrq_key_op *sysrq_key_ta
2991         NULL,                           /* v */
2992         &sysrq_showstate_blocked_op,    /* w */
2993         /* x: May be registered on ppc/powerpc for xmon */
2994 +#ifdef CONFIG_VSERVER_DEBUG
2995 +       &sysrq_showvxinfo_op,           /* x */
2996 +#else
2997         NULL,                           /* x */
2998 +#endif
2999         /* y: May be registered on sparc64 for global register dump */
3000         NULL,                           /* y */
3001         &sysrq_ftrace_dump_op,          /* z */
3002 @@ -461,6 +481,8 @@ static int sysrq_key_table_key2index(int
3003                 retval = key - '0';
3004         else if ((key >= 'a') && (key <= 'z'))
3005                 retval = key + 10 - 'a';
3006 +       else if ((key >= 'A') && (key <= 'Z'))
3007 +               retval = key + 10 - 'A';
3008         else
3009                 retval = -1;
3010         return retval;
3011 diff -NurpP --minimal linux-2.6.34/drivers/char/tty_io.c linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/char/tty_io.c
3012 --- linux-2.6.34/drivers/char/tty_io.c  2010-05-18 15:07:46.000000000 +0200
3013 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/char/tty_io.c     2010-05-18 18:11:22.000000000 +0200
3014 @@ -106,6 +106,7 @@
3015  
3016  #include <linux/kmod.h>
3017  #include <linux/nsproxy.h>
3018 +#include <linux/vs_pid.h>
3019  
3020  #undef TTY_DEBUG_HANGUP
3021  
3022 @@ -1992,7 +1993,8 @@ static int tiocsti(struct tty_struct *tt
3023         char ch, mbz = 0;
3024         struct tty_ldisc *ld;
3025  
3026 -       if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
3027 +       if (((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN)) ||
3028 +               !vx_ccaps(VXC_TIOCSTI))
3029                 return -EPERM;
3030         if (get_user(ch, p))
3031                 return -EFAULT;
3032 @@ -2280,6 +2282,7 @@ static int tiocspgrp(struct tty_struct *
3033                 return -ENOTTY;
3034         if (get_user(pgrp_nr, p))
3035                 return -EFAULT;
3036 +       pgrp_nr = vx_rmap_pid(pgrp_nr);
3037         if (pgrp_nr < 0)
3038                 return -EINVAL;
3039         rcu_read_lock();
3040 diff -NurpP --minimal linux-2.6.34/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/r100_reg_safe.h
3041 --- linux-2.6.34/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3042 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/r100_reg_safe.h    2010-05-18 18:11:22.000000000 +0200
3043 @@ -0,0 +1,28 @@
3044 +static const unsigned r100_reg_safe_bm[102] = {
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 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3051 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3052 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3053 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3054 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3055 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3056 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3057 +       0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3058 +       0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3059 +       0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
3060 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3061 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
3062 +       0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
3063 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3064 +       0xFFFFFFFF, 0xFFFCFFFF, 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, 0xFFFFFFEF,
3071 +};
3072 diff -NurpP --minimal linux-2.6.34/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/r200_reg_safe.h
3073 --- linux-2.6.34/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3074 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/r200_reg_safe.h    2010-05-18 18:11:22.000000000 +0200
3075 @@ -0,0 +1,28 @@
3076 +static const unsigned r200_reg_safe_bm[102] = {
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 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3088 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3089 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3090 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3091 +       0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
3092 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3093 +       0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
3094 +       0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
3095 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3096 +       0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3097 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3098 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3099 +       0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
3100 +       0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
3101 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3102 +       0xFFFFFE3F, 0xFFFFFFEF,
3103 +};
3104 diff -NurpP --minimal linux-2.6.34/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/r300_reg_safe.h
3105 --- linux-2.6.34/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3106 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/r300_reg_safe.h    2010-05-18 18:11:22.000000000 +0200
3107 @@ -0,0 +1,42 @@
3108 +static const unsigned r300_reg_safe_bm[159] = {
3109 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3110 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3111 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3112 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3113 +       0xFFFFFFFF, 0xFFFFFFFF, 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 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3120 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3121 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3122 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3123 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3124 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3125 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3126 +       0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3127 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3128 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3129 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3130 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3131 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3132 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3133 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3134 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3135 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 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 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3142 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3143 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3144 +       0x00000000, 0x0000C100, 0x00000000, 0x00000000,
3145 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3146 +       0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
3147 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3148 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3149 +};
3150 diff -NurpP --minimal linux-2.6.34/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/r420_reg_safe.h
3151 --- linux-2.6.34/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3152 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/r420_reg_safe.h    2010-05-18 18:11:22.000000000 +0200
3153 @@ -0,0 +1,42 @@
3154 +static const unsigned r420_reg_safe_bm[159] = {
3155 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3156 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
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 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3166 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3167 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3168 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3169 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3170 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3171 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3172 +       0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3173 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3174 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3175 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 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 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3182 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3183 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3184 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3185 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3186 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3187 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3188 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3189 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3190 +       0x00000000, 0x00000100, 0x00000000, 0x00000000,
3191 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3192 +       0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3193 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3194 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3195 +};
3196 diff -NurpP --minimal linux-2.6.34/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/rn50_reg_safe.h
3197 --- linux-2.6.34/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3198 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/rn50_reg_safe.h    2010-05-18 18:11:22.000000000 +0200
3199 @@ -0,0 +1,28 @@
3200 +static const unsigned rn50_reg_safe_bm[102] = {
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 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3212 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3213 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3214 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3215 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3216 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3217 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3218 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3219 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3220 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3221 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3222 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3223 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3224 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3225 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3226 +       0xFFFFFFFF, 0xFFFFFFFF,
3227 +};
3228 diff -NurpP --minimal linux-2.6.34/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/rs600_reg_safe.h
3229 --- linux-2.6.34/drivers/gpu/drm/radeon/rs600_reg_safe.h        1970-01-01 01:00:00.000000000 +0100
3230 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/rs600_reg_safe.h   2010-05-18 18:11:22.000000000 +0200
3231 @@ -0,0 +1,57 @@
3232 +static const unsigned rs600_reg_safe_bm[219] = {
3233 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3234 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3235 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3236 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3237 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3238 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3239 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3240 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3241 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3242 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3243 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3244 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3245 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3246 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3247 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3248 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3249 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3250 +       0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3251 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3252 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3253 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3254 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3255 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3256 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3257 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3258 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3259 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3260 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3261 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3262 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3263 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3264 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3265 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3266 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3267 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3268 +       0x00000000, 0x00000100, 0x00000000, 0x00000000,
3269 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3270 +       0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3271 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3272 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
3273 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3274 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3275 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3276 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3277 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3278 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3279 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3280 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3281 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3282 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3283 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3284 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3285 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3286 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3287 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3288 +};
3289 diff -NurpP --minimal linux-2.6.34/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/rv515_reg_safe.h
3290 --- linux-2.6.34/drivers/gpu/drm/radeon/rv515_reg_safe.h        1970-01-01 01:00:00.000000000 +0100
3291 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/gpu/drm/radeon/rv515_reg_safe.h   2010-05-18 18:11:22.000000000 +0200
3292 @@ -0,0 +1,57 @@
3293 +static const unsigned rv515_reg_safe_bm[219] = {
3294 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3295 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3296 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3297 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3298 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3299 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3300 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3301 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3302 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3303 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3304 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3305 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3306 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3307 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3308 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3309 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3310 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3311 +       0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3312 +       0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
3313 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3314 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3315 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3316 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3317 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3318 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3319 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3320 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3321 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3322 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3323 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3324 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3325 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3326 +       0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
3327 +       0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
3328 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3329 +       0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
3330 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3331 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
3332 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3333 +       0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
3334 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3335 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3336 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3337 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3338 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3339 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3340 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3341 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3342 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3343 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3344 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3345 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3346 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3347 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3348 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3349 +};
3350 diff -NurpP --minimal linux-2.6.34/drivers/infiniband/core/addr.c linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/infiniband/core/addr.c
3351 --- linux-2.6.34/drivers/infiniband/core/addr.c 2010-05-18 15:07:46.000000000 +0200
3352 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/infiniband/core/addr.c    2010-05-18 18:11:22.000000000 +0200
3353 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
3354  
3355         if (ipv6_addr_any(&fl.fl6_src)) {
3356                 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
3357 -                                        &fl.fl6_dst, 0, &fl.fl6_src);
3358 +                                        &fl.fl6_dst, 0, &fl.fl6_src, NULL);
3359                 if (ret)
3360                         goto put;
3361  
3362 diff -NurpP --minimal linux-2.6.34/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/infiniband/hw/ipath/ipath_user_pages.c
3363 --- linux-2.6.34/drivers/infiniband/hw/ipath/ipath_user_pages.c 2010-05-18 15:07:46.000000000 +0200
3364 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/infiniband/hw/ipath/ipath_user_pages.c    2010-05-19 03:10:18.000000000 +0200
3365 @@ -35,6 +35,7 @@
3366  #include <linux/device.h>
3367  #include <linux/slab.h>
3368  #include <linux/sched.h>
3369 +#include <linux/vs_memory.h>
3370  
3371  #include "ipath_kernel.h"
3372  
3373 diff -NurpP --minimal linux-2.6.34/drivers/md/dm.c linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/md/dm.c
3374 --- linux-2.6.34/drivers/md/dm.c        2010-05-18 15:07:47.000000000 +0200
3375 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/md/dm.c   2010-05-18 18:11:22.000000000 +0200
3376 @@ -19,6 +19,7 @@
3377  #include <linux/slab.h>
3378  #include <linux/idr.h>
3379  #include <linux/hdreg.h>
3380 +#include <linux/vs_base.h>
3381  
3382  #include <trace/events/block.h>
3383  
3384 @@ -119,6 +120,7 @@ struct mapped_device {
3385         rwlock_t map_lock;
3386         atomic_t holders;
3387         atomic_t open_count;
3388 +       xid_t xid;
3389  
3390         unsigned long flags;
3391  
3392 @@ -337,6 +339,7 @@ int dm_deleting_md(struct mapped_device 
3393  static int dm_blk_open(struct block_device *bdev, fmode_t mode)
3394  {
3395         struct mapped_device *md;
3396 +       int ret = -ENXIO;
3397  
3398         spin_lock(&_minor_lock);
3399  
3400 @@ -345,18 +348,19 @@ static int dm_blk_open(struct block_devi
3401                 goto out;
3402  
3403         if (test_bit(DMF_FREEING, &md->flags) ||
3404 -           dm_deleting_md(md)) {
3405 -               md = NULL;
3406 +           dm_deleting_md(md))
3407 +               goto out;
3408 +
3409 +       ret = -EACCES;
3410 +       if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
3411                 goto out;
3412 -       }
3413  
3414         dm_get(md);
3415         atomic_inc(&md->open_count);
3416 -
3417 +       ret = 0;
3418  out:
3419         spin_unlock(&_minor_lock);
3420 -
3421 -       return md ? 0 : -ENXIO;
3422 +       return ret;
3423  }
3424  
3425  static int dm_blk_close(struct gendisk *disk, fmode_t mode)
3426 @@ -574,6 +578,14 @@ int dm_set_geometry(struct mapped_device
3427         return 0;
3428  }
3429  
3430 +/*
3431 + * Get the xid associated with a dm device
3432 + */
3433 +xid_t dm_get_xid(struct mapped_device *md)
3434 +{
3435 +       return md->xid;
3436 +}
3437 +
3438  /*-----------------------------------------------------------------
3439   * CRUD START:
3440   *   A more elegant soln is in the works that uses the queue
3441 @@ -1886,6 +1898,7 @@ static struct mapped_device *alloc_dev(i
3442         INIT_LIST_HEAD(&md->uevent_list);
3443         spin_lock_init(&md->uevent_lock);
3444  
3445 +       md->xid = vx_current_xid();
3446         md->queue = blk_init_queue(dm_request_fn, NULL);
3447         if (!md->queue)
3448                 goto bad_queue;
3449 diff -NurpP --minimal linux-2.6.34/drivers/md/dm.h linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/md/dm.h
3450 --- linux-2.6.34/drivers/md/dm.h        2010-05-18 15:07:47.000000000 +0200
3451 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/md/dm.h   2010-05-18 18:11:22.000000000 +0200
3452 @@ -41,6 +41,8 @@ struct dm_dev_internal {
3453  struct dm_table;
3454  struct dm_md_mempools;
3455  
3456 +xid_t dm_get_xid(struct mapped_device *md);
3457 +
3458  /*-----------------------------------------------------------------
3459   * Internal table functions.
3460   *---------------------------------------------------------------*/
3461 diff -NurpP --minimal linux-2.6.34/drivers/md/dm-ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/md/dm-ioctl.c
3462 --- linux-2.6.34/drivers/md/dm-ioctl.c  2010-05-18 15:07:47.000000000 +0200
3463 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/md/dm-ioctl.c     2010-05-18 18:11:22.000000000 +0200
3464 @@ -16,6 +16,7 @@
3465  #include <linux/dm-ioctl.h>
3466  #include <linux/hdreg.h>
3467  #include <linux/compat.h>
3468 +#include <linux/vs_context.h>
3469  
3470  #include <asm/uaccess.h>
3471  
3472 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
3473         unsigned int h = hash_str(str);
3474  
3475         list_for_each_entry (hc, _name_buckets + h, name_list)
3476 -               if (!strcmp(hc->name, str)) {
3477 +               if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3478 +                       !strcmp(hc->name, str)) {
3479                         dm_get(hc->md);
3480                         return hc;
3481                 }
3482 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
3483         unsigned int h = hash_str(str);
3484  
3485         list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
3486 -               if (!strcmp(hc->uuid, str)) {
3487 +               if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3488 +                       !strcmp(hc->uuid, str)) {
3489                         dm_get(hc->md);
3490                         return hc;
3491                 }
3492 @@ -365,6 +368,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl 
3493  
3494  static int remove_all(struct dm_ioctl *param, size_t param_size)
3495  {
3496 +       if (!vx_check(0, VS_ADMIN))
3497 +               return -EPERM;
3498 +
3499         dm_hash_remove_all(1);
3500         param->data_size = 0;
3501         return 0;
3502 @@ -412,6 +418,8 @@ static int list_devices(struct dm_ioctl 
3503          */
3504         for (i = 0; i < NUM_BUCKETS; i++) {
3505                 list_for_each_entry (hc, _name_buckets + i, name_list) {
3506 +                       if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3507 +                               continue;
3508                         needed += sizeof(struct dm_name_list);
3509                         needed += strlen(hc->name) + 1;
3510                         needed += ALIGN_MASK;
3511 @@ -435,6 +443,8 @@ static int list_devices(struct dm_ioctl 
3512          */
3513         for (i = 0; i < NUM_BUCKETS; i++) {
3514                 list_for_each_entry (hc, _name_buckets + i, name_list) {
3515 +                       if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3516 +                               continue;
3517                         if (old_nl)
3518                                 old_nl->next = (uint32_t) ((void *) nl -
3519                                                            (void *) old_nl);
3520 @@ -669,10 +679,11 @@ static struct hash_cell *__find_device_h
3521         if (!md)
3522                 goto out;
3523  
3524 -       mdptr = dm_get_mdptr(md);
3525 +       if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
3526 +               mdptr = dm_get_mdptr(md);
3527 +
3528         if (!mdptr)
3529                 dm_put(md);
3530 -
3531  out:
3532         return mdptr;
3533  }
3534 @@ -1514,8 +1525,8 @@ static int ctl_ioctl(uint command, struc
3535         ioctl_fn fn = NULL;
3536         size_t param_size;
3537  
3538 -       /* only root can play with this */
3539 -       if (!capable(CAP_SYS_ADMIN))
3540 +       /* only root and certain contexts can play with this */
3541 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
3542                 return -EACCES;
3543  
3544         if (_IOC_TYPE(command) != DM_IOCTL)
3545 diff -NurpP --minimal linux-2.6.34/drivers/net/tun.c linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/net/tun.c
3546 --- linux-2.6.34/drivers/net/tun.c      2010-05-18 15:07:48.000000000 +0200
3547 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/drivers/net/tun.c 2010-05-18 18:11:22.000000000 +0200
3548 @@ -62,6 +62,7 @@
3549  #include <linux/nsproxy.h>
3550  #include <linux/virtio_net.h>
3551  #include <linux/rcupdate.h>
3552 +#include <linux/vs_network.h>
3553  #include <net/net_namespace.h>
3554  #include <net/netns/generic.h>
3555  #include <net/rtnetlink.h>
3556 @@ -103,6 +104,7 @@ struct tun_struct {
3557         unsigned int            flags;
3558         uid_t                   owner;
3559         gid_t                   group;
3560 +       nid_t                   nid;
3561  
3562         struct net_device       *dev;
3563         struct fasync_struct    *fasync;
3564 @@ -838,6 +840,7 @@ static void tun_setup(struct net_device 
3565  
3566         tun->owner = -1;
3567         tun->group = -1;
3568 +       tun->nid = current->nid;
3569  
3570         dev->ethtool_ops = &tun_ethtool_ops;
3571         dev->destructor = tun_free_netdev;
3572 @@ -986,7 +989,7 @@ static int tun_set_iff(struct net *net, 
3573  
3574                 if (((tun->owner != -1 && cred->euid != tun->owner) ||
3575                      (tun->group != -1 && !in_egroup_p(tun->group))) &&
3576 -                   !capable(CAP_NET_ADMIN))
3577 +               !cap_raised(current_cap(), CAP_NET_ADMIN))
3578                         return -EPERM;
3579                 err = security_tun_dev_attach(tun->socket.sk);
3580                 if (err < 0)
3581 @@ -1000,7 +1003,7 @@ static int tun_set_iff(struct net *net, 
3582                 char *name;
3583                 unsigned long flags = 0;
3584  
3585 -               if (!capable(CAP_NET_ADMIN))
3586 +               if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
3587                         return -EPERM;
3588                 err = security_tun_dev_create();
3589                 if (err < 0)
3590 @@ -1068,6 +1071,9 @@ static int tun_set_iff(struct net *net, 
3591  
3592                 sk->sk_destruct = tun_sock_destruct;
3593  
3594 +               if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
3595 +                       return -EPERM;
3596 +
3597                 err = tun_attach(tun, file);
3598                 if (err < 0)
3599                         goto failed;
3600 @@ -1258,6 +1264,16 @@ static long __tun_chr_ioctl(struct file 
3601                 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
3602                 break;
3603  
3604 +       case TUNSETNID:
3605 +               if (!capable(CAP_CONTEXT))
3606 +                       return -EPERM;
3607 +
3608 +               /* Set nid owner of the device */
3609 +               tun->nid = (nid_t) arg;
3610 +
3611 +               DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
3612 +               break;
3613 +
3614         case TUNSETLINK:
3615                 /* Only allow setting the type when the interface is down */
3616                 if (tun->dev->flags & IFF_UP) {
3617 diff -NurpP --minimal linux-2.6.34/fs/attr.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/attr.c
3618 --- linux-2.6.34/fs/attr.c      2010-05-18 15:07:51.000000000 +0200
3619 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/attr.c 2010-05-18 18:11:22.000000000 +0200
3620 @@ -13,6 +13,9 @@
3621  #include <linux/fsnotify.h>
3622  #include <linux/fcntl.h>
3623  #include <linux/security.h>
3624 +#include <linux/proc_fs.h>
3625 +#include <linux/devpts_fs.h>
3626 +#include <linux/vs_tag.h>
3627  
3628  /* Taken over from the old code... */
3629  
3630 @@ -54,6 +57,10 @@ int inode_change_ok(const struct inode *
3631                 if (!is_owner_or_cap(inode))
3632                         goto error;
3633         }
3634 +
3635 +       if (dx_permission(inode, MAY_WRITE))
3636 +               goto error;
3637 +
3638  fine:
3639         retval = 0;
3640  error:
3641 @@ -119,6 +126,8 @@ int inode_setattr(struct inode * inode, 
3642                 inode->i_uid = attr->ia_uid;
3643         if (ia_valid & ATTR_GID)
3644                 inode->i_gid = attr->ia_gid;
3645 +       if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3646 +               inode->i_tag = attr->ia_tag;
3647         if (ia_valid & ATTR_ATIME)
3648                 inode->i_atime = timespec_trunc(attr->ia_atime,
3649                                                 inode->i_sb->s_time_gran);
3650 @@ -149,7 +158,8 @@ int notify_change(struct dentry * dentry
3651         struct timespec now;
3652         unsigned int ia_valid = attr->ia_valid;
3653  
3654 -       if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
3655 +       if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
3656 +               ATTR_TAG | ATTR_TIMES_SET)) {
3657                 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
3658                         return -EPERM;
3659         }
3660 diff -NurpP --minimal linux-2.6.34/fs/binfmt_aout.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/binfmt_aout.c
3661 --- linux-2.6.34/fs/binfmt_aout.c       2010-05-18 15:07:51.000000000 +0200
3662 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/binfmt_aout.c  2010-05-18 18:11:22.000000000 +0200
3663 @@ -25,6 +25,7 @@
3664  #include <linux/init.h>
3665  #include <linux/coredump.h>
3666  #include <linux/slab.h>
3667 +#include <linux/vs_memory.h>
3668  
3669  #include <asm/system.h>
3670  #include <asm/uaccess.h>
3671 diff -NurpP --minimal linux-2.6.34/fs/binfmt_elf.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/binfmt_elf.c
3672 --- linux-2.6.34/fs/binfmt_elf.c        2010-05-18 15:07:51.000000000 +0200
3673 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/binfmt_elf.c   2010-05-18 18:11:22.000000000 +0200
3674 @@ -32,6 +32,7 @@
3675  #include <linux/elf.h>
3676  #include <linux/utsname.h>
3677  #include <linux/coredump.h>
3678 +#include <linux/vs_memory.h>
3679  #include <asm/uaccess.h>
3680  #include <asm/param.h>
3681  #include <asm/page.h>
3682 diff -NurpP --minimal linux-2.6.34/fs/binfmt_flat.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/binfmt_flat.c
3683 --- linux-2.6.34/fs/binfmt_flat.c       2010-05-18 15:07:51.000000000 +0200
3684 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/binfmt_flat.c  2010-05-18 18:11:22.000000000 +0200
3685 @@ -35,6 +35,7 @@
3686  #include <linux/init.h>
3687  #include <linux/flat.h>
3688  #include <linux/syscalls.h>
3689 +#include <linux/vs_memory.h>
3690  
3691  #include <asm/byteorder.h>
3692  #include <asm/system.h>
3693 diff -NurpP --minimal linux-2.6.34/fs/binfmt_som.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/binfmt_som.c
3694 --- linux-2.6.34/fs/binfmt_som.c        2010-02-25 11:52:04.000000000 +0100
3695 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/binfmt_som.c   2010-05-18 18:11:22.000000000 +0200
3696 @@ -28,6 +28,7 @@
3697  #include <linux/shm.h>
3698  #include <linux/personality.h>
3699  #include <linux/init.h>
3700 +#include <linux/vs_memory.h>
3701  
3702  #include <asm/uaccess.h>
3703  #include <asm/pgtable.h>
3704 diff -NurpP --minimal linux-2.6.34/fs/block_dev.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/block_dev.c
3705 --- linux-2.6.34/fs/block_dev.c 2010-05-18 15:07:51.000000000 +0200
3706 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/block_dev.c    2010-05-18 18:11:22.000000000 +0200
3707 @@ -26,6 +26,7 @@
3708  #include <linux/namei.h>
3709  #include <linux/log2.h>
3710  #include <linux/kmemleak.h>
3711 +#include <linux/vs_device.h>
3712  #include <asm/uaccess.h>
3713  #include "internal.h"
3714  
3715 @@ -574,6 +575,7 @@ struct block_device *bdget(dev_t dev)
3716                 bdev->bd_invalidated = 0;
3717                 inode->i_mode = S_IFBLK;
3718                 inode->i_rdev = dev;
3719 +               inode->i_mdev = dev;
3720                 inode->i_bdev = bdev;
3721                 inode->i_data.a_ops = &def_blk_aops;
3722                 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
3723 @@ -620,6 +622,11 @@ EXPORT_SYMBOL(bdput);
3724  static struct block_device *bd_acquire(struct inode *inode)
3725  {
3726         struct block_device *bdev;
3727 +       dev_t mdev;
3728 +
3729 +       if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
3730 +               return NULL;
3731 +       inode->i_mdev = mdev;
3732  
3733         spin_lock(&bdev_lock);
3734         bdev = inode->i_bdev;
3735 @@ -630,7 +637,7 @@ static struct block_device *bd_acquire(s
3736         }
3737         spin_unlock(&bdev_lock);
3738  
3739 -       bdev = bdget(inode->i_rdev);
3740 +       bdev = bdget(mdev);
3741         if (bdev) {
3742                 spin_lock(&bdev_lock);
3743                 if (!inode->i_bdev) {
3744 diff -NurpP --minimal linux-2.6.34/fs/btrfs/ctree.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/btrfs/ctree.h
3745 --- linux-2.6.34/fs/btrfs/ctree.h       2010-05-18 15:07:51.000000000 +0200
3746 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/btrfs/ctree.h  2010-05-18 18:11:22.000000000 +0200
3747 @@ -550,11 +550,14 @@ struct btrfs_inode_item {
3748         /* modification sequence number for NFS */
3749         __le64 sequence;
3750  
3751 +       __le16 tag;
3752         /*
3753          * a little future expansion, for more than this we can
3754          * just grow the inode item and version it
3755          */
3756 -       __le64 reserved[4];
3757 +       __le16 reserved16;
3758 +       __le32 reserved32;
3759 +       __le64 reserved[3];
3760         struct btrfs_timespec atime;
3761         struct btrfs_timespec ctime;
3762         struct btrfs_timespec mtime;
3763 @@ -1165,6 +1168,8 @@ struct btrfs_root {
3764  #define BTRFS_MOUNT_DISCARD            (1 << 10)
3765  #define BTRFS_MOUNT_FORCE_COMPRESS      (1 << 11)
3766  
3767 +#define BTRFS_MOUNT_TAGGED             (1 << 24)
3768 +
3769  #define btrfs_clear_opt(o, opt)                ((o) &= ~BTRFS_MOUNT_##opt)
3770  #define btrfs_set_opt(o, opt)          ((o) |= BTRFS_MOUNT_##opt)
3771  #define btrfs_test_opt(root, opt)      ((root)->fs_info->mount_opt & \
3772 @@ -1385,6 +1390,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
3773  BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
3774  BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
3775  BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
3776 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
3777  BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
3778  BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
3779  BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
3780 @@ -1446,6 +1452,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct 
3781  
3782  BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
3783  
3784 +#define BTRFS_INODE_IXUNLINK           (1 << 24)
3785 +#define BTRFS_INODE_BARRIER            (1 << 25)
3786 +#define BTRFS_INODE_COW                        (1 << 26)
3787 +
3788  
3789  BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
3790  
3791 @@ -2359,6 +2369,7 @@ extern const struct dentry_operations bt
3792  long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3793  void btrfs_update_iflags(struct inode *inode);
3794  void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
3795 +int btrfs_sync_flags(struct inode *inode, int, int);
3796  
3797  /* file.c */
3798  int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync);
3799 diff -NurpP --minimal linux-2.6.34/fs/btrfs/disk-io.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/btrfs/disk-io.c
3800 --- linux-2.6.34/fs/btrfs/disk-io.c     2010-05-18 15:07:51.000000000 +0200
3801 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/btrfs/disk-io.c        2010-05-18 18:11:22.000000000 +0200
3802 @@ -1718,6 +1718,9 @@ struct btrfs_root *open_ctree(struct sup
3803                 goto fail_iput;
3804         }
3805  
3806 +       if (btrfs_test_opt(tree_root, TAGGED))
3807 +               sb->s_flags |= MS_TAGGED;
3808 +
3809         features = btrfs_super_incompat_flags(disk_super) &
3810                 ~BTRFS_FEATURE_INCOMPAT_SUPP;
3811         if (features) {
3812 diff -NurpP --minimal linux-2.6.34/fs/btrfs/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/btrfs/inode.c
3813 --- linux-2.6.34/fs/btrfs/inode.c       2010-05-18 15:07:51.000000000 +0200
3814 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/btrfs/inode.c  2010-05-18 18:11:22.000000000 +0200
3815 @@ -37,6 +37,8 @@
3816  #include <linux/posix_acl.h>
3817  #include <linux/falloc.h>
3818  #include <linux/slab.h>
3819 +#include <linux/vs_tag.h>
3820 +
3821  #include "compat.h"
3822  #include "ctree.h"
3823  #include "disk-io.h"
3824 @@ -2227,6 +2229,8 @@ static void btrfs_read_locked_inode(stru
3825         int maybe_acls;
3826         u64 alloc_group_block;
3827         u32 rdev;
3828 +       uid_t uid;
3829 +       gid_t gid;
3830         int ret;
3831  
3832         path = btrfs_alloc_path();
3833 @@ -2243,8 +2247,13 @@ static void btrfs_read_locked_inode(stru
3834  
3835         inode->i_mode = btrfs_inode_mode(leaf, inode_item);
3836         inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
3837 -       inode->i_uid = btrfs_inode_uid(leaf, inode_item);
3838 -       inode->i_gid = btrfs_inode_gid(leaf, inode_item);
3839 +
3840 +       uid = btrfs_inode_uid(leaf, inode_item);
3841 +       gid = btrfs_inode_gid(leaf, inode_item);
3842 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3843 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3844 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3845 +               btrfs_inode_tag(leaf, inode_item));
3846         btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
3847  
3848         tspec = btrfs_inode_atime(inode_item);
3849 @@ -2326,8 +2335,15 @@ static void fill_inode_item(struct btrfs
3850                             struct btrfs_inode_item *item,
3851                             struct inode *inode)
3852  {
3853 -       btrfs_set_inode_uid(leaf, item, inode->i_uid);
3854 -       btrfs_set_inode_gid(leaf, item, inode->i_gid);
3855 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3856 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3857 +
3858 +       btrfs_set_inode_uid(leaf, item, uid);
3859 +       btrfs_set_inode_gid(leaf, item, gid);
3860 +#ifdef CONFIG_TAGGING_INTERN
3861 +       btrfs_set_inode_tag(leaf, item, inode->i_tag);
3862 +#endif
3863 +
3864         btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
3865         btrfs_set_inode_mode(leaf, item, inode->i_mode);
3866         btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
3867 @@ -4130,6 +4146,7 @@ static struct inode *btrfs_new_inode(str
3868         } else
3869                 inode->i_gid = current_fsgid();
3870  
3871 +       inode->i_tag = dx_current_fstag(root->fs_info->sb);
3872         inode->i_mode = mode;
3873         inode->i_ino = objectid;
3874         inode_set_bytes(inode, 0);
3875 @@ -5938,6 +5955,7 @@ static const struct inode_operations btr
3876         .listxattr      = btrfs_listxattr,
3877         .removexattr    = btrfs_removexattr,
3878         .permission     = btrfs_permission,
3879 +       .sync_flags     = btrfs_sync_flags,
3880  };
3881  static const struct inode_operations btrfs_dir_ro_inode_operations = {
3882         .lookup         = btrfs_lookup,
3883 @@ -6013,6 +6031,7 @@ static const struct inode_operations btr
3884         .permission     = btrfs_permission,
3885         .fallocate      = btrfs_fallocate,
3886         .fiemap         = btrfs_fiemap,
3887 +       .sync_flags     = btrfs_sync_flags,
3888  };
3889  static const struct inode_operations btrfs_special_inode_operations = {
3890         .getattr        = btrfs_getattr,
3891 diff -NurpP --minimal linux-2.6.34/fs/btrfs/ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/btrfs/ioctl.c
3892 --- linux-2.6.34/fs/btrfs/ioctl.c       2010-05-18 15:07:51.000000000 +0200
3893 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/btrfs/ioctl.c  2010-05-18 18:11:22.000000000 +0200
3894 @@ -68,10 +68,13 @@ static unsigned int btrfs_flags_to_ioctl
3895  {
3896         unsigned int iflags = 0;
3897  
3898 -       if (flags & BTRFS_INODE_SYNC)
3899 -               iflags |= FS_SYNC_FL;
3900         if (flags & BTRFS_INODE_IMMUTABLE)
3901                 iflags |= FS_IMMUTABLE_FL;
3902 +       if (flags & BTRFS_INODE_IXUNLINK)
3903 +               iflags |= FS_IXUNLINK_FL;
3904 +
3905 +       if (flags & BTRFS_INODE_SYNC)
3906 +               iflags |= FS_SYNC_FL;
3907         if (flags & BTRFS_INODE_APPEND)
3908                 iflags |= FS_APPEND_FL;
3909         if (flags & BTRFS_INODE_NODUMP)
3910 @@ -81,28 +84,78 @@ static unsigned int btrfs_flags_to_ioctl
3911         if (flags & BTRFS_INODE_DIRSYNC)
3912                 iflags |= FS_DIRSYNC_FL;
3913  
3914 +       if (flags & BTRFS_INODE_BARRIER)
3915 +               iflags |= FS_BARRIER_FL;
3916 +       if (flags & BTRFS_INODE_COW)
3917 +               iflags |= FS_COW_FL;
3918         return iflags;
3919  }
3920  
3921  /*
3922 - * Update inode->i_flags based on the btrfs internal flags.
3923 + * Update inode->i_(v)flags based on the btrfs internal flags.
3924   */
3925  void btrfs_update_iflags(struct inode *inode)
3926  {
3927         struct btrfs_inode *ip = BTRFS_I(inode);
3928  
3929 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3930 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3931 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3932  
3933 -       if (ip->flags & BTRFS_INODE_SYNC)
3934 -               inode->i_flags |= S_SYNC;
3935         if (ip->flags & BTRFS_INODE_IMMUTABLE)
3936                 inode->i_flags |= S_IMMUTABLE;
3937 +       if (ip->flags & BTRFS_INODE_IXUNLINK)
3938 +               inode->i_flags |= S_IXUNLINK;
3939 +
3940 +       if (ip->flags & BTRFS_INODE_SYNC)
3941 +               inode->i_flags |= S_SYNC;
3942         if (ip->flags & BTRFS_INODE_APPEND)
3943                 inode->i_flags |= S_APPEND;
3944         if (ip->flags & BTRFS_INODE_NOATIME)
3945                 inode->i_flags |= S_NOATIME;
3946         if (ip->flags & BTRFS_INODE_DIRSYNC)
3947                 inode->i_flags |= S_DIRSYNC;
3948 +
3949 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
3950 +
3951 +       if (ip->flags & BTRFS_INODE_BARRIER)
3952 +               inode->i_vflags |= V_BARRIER;
3953 +       if (ip->flags & BTRFS_INODE_COW)
3954 +               inode->i_vflags |= V_COW;
3955 +}
3956 +
3957 +/*
3958 + * Update btrfs internal flags from inode->i_(v)flags.
3959 + */
3960 +void btrfs_update_flags(struct inode *inode)
3961 +{
3962 +       struct btrfs_inode *ip = BTRFS_I(inode);
3963 +
3964 +       unsigned int flags = inode->i_flags;
3965 +       unsigned int vflags = inode->i_vflags;
3966 +
3967 +       ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
3968 +                       BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
3969 +                       BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
3970 +                       BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
3971 +
3972 +       if (flags & S_IMMUTABLE)
3973 +               ip->flags |= BTRFS_INODE_IMMUTABLE;
3974 +       if (flags & S_IXUNLINK)
3975 +               ip->flags |= BTRFS_INODE_IXUNLINK;
3976 +
3977 +       if (flags & S_SYNC)
3978 +               ip->flags |= BTRFS_INODE_SYNC;
3979 +       if (flags & S_APPEND)
3980 +               ip->flags |= BTRFS_INODE_APPEND;
3981 +       if (flags & S_NOATIME)
3982 +               ip->flags |= BTRFS_INODE_NOATIME;
3983 +       if (flags & S_DIRSYNC)
3984 +               ip->flags |= BTRFS_INODE_DIRSYNC;
3985 +
3986 +       if (vflags & V_BARRIER)
3987 +               ip->flags |= BTRFS_INODE_BARRIER;
3988 +       if (vflags & V_COW)
3989 +               ip->flags |= BTRFS_INODE_COW;
3990  }
3991  
3992  /*
3993 @@ -120,7 +173,7 @@ void btrfs_inherit_iflags(struct inode *
3994         flags = BTRFS_I(dir)->flags;
3995  
3996         if (S_ISREG(inode->i_mode))
3997 -               flags &= ~BTRFS_INODE_DIRSYNC;
3998 +               flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
3999         else if (!S_ISDIR(inode->i_mode))
4000                 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
4001  
4002 @@ -128,6 +181,30 @@ void btrfs_inherit_iflags(struct inode *
4003         btrfs_update_iflags(inode);
4004  }
4005  
4006 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
4007 +{
4008 +       struct btrfs_inode *ip = BTRFS_I(inode);
4009 +       struct btrfs_root *root = ip->root;
4010 +       struct btrfs_trans_handle *trans;
4011 +       int ret;
4012 +
4013 +       trans = btrfs_join_transaction(root, 1);
4014 +       BUG_ON(!trans);
4015 +
4016 +       inode->i_flags = flags;
4017 +       inode->i_vflags = vflags;
4018 +       btrfs_update_flags(inode);
4019 +
4020 +       ret = btrfs_update_inode(trans, root, inode);
4021 +       BUG_ON(ret);
4022 +
4023 +       btrfs_update_iflags(inode);
4024 +       inode->i_ctime = CURRENT_TIME;
4025 +       btrfs_end_transaction(trans, root);
4026 +
4027 +       return 0;
4028 +}
4029 +
4030  static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
4031  {
4032         struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
4033 @@ -150,6 +227,7 @@ static int btrfs_ioctl_setflags(struct f
4034         if (copy_from_user(&flags, arg, sizeof(flags)))
4035                 return -EFAULT;
4036  
4037 +       /* maybe add FS_IXUNLINK_FL ? */
4038         if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
4039                       FS_NOATIME_FL | FS_NODUMP_FL | \
4040                       FS_SYNC_FL | FS_DIRSYNC_FL))
4041 @@ -162,7 +240,8 @@ static int btrfs_ioctl_setflags(struct f
4042  
4043         flags = btrfs_mask_flags(inode->i_mode, flags);
4044         oldflags = btrfs_flags_to_ioctl(ip->flags);
4045 -       if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
4046 +       if ((flags ^ oldflags) & (FS_APPEND_FL |
4047 +               FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
4048                 if (!capable(CAP_LINUX_IMMUTABLE)) {
4049                         ret = -EPERM;
4050                         goto out_unlock;
4051 @@ -173,14 +252,19 @@ static int btrfs_ioctl_setflags(struct f
4052         if (ret)
4053                 goto out_unlock;
4054  
4055 -       if (flags & FS_SYNC_FL)
4056 -               ip->flags |= BTRFS_INODE_SYNC;
4057 -       else
4058 -               ip->flags &= ~BTRFS_INODE_SYNC;
4059         if (flags & FS_IMMUTABLE_FL)
4060                 ip->flags |= BTRFS_INODE_IMMUTABLE;
4061         else
4062                 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
4063 +       if (flags & FS_IXUNLINK_FL)
4064 +               ip->flags |= BTRFS_INODE_IXUNLINK;
4065 +       else
4066 +               ip->flags &= ~BTRFS_INODE_IXUNLINK;
4067 +
4068 +       if (flags & FS_SYNC_FL)
4069 +               ip->flags |= BTRFS_INODE_SYNC;
4070 +       else
4071 +               ip->flags &= ~BTRFS_INODE_SYNC;
4072         if (flags & FS_APPEND_FL)
4073                 ip->flags |= BTRFS_INODE_APPEND;
4074         else
4075 diff -NurpP --minimal linux-2.6.34/fs/btrfs/super.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/btrfs/super.c
4076 --- linux-2.6.34/fs/btrfs/super.c       2010-05-18 15:07:51.000000000 +0200
4077 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/btrfs/super.c  2010-05-18 18:11:22.000000000 +0200
4078 @@ -68,7 +68,7 @@ enum {
4079         Opt_nodatacow, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, Opt_ssd,
4080         Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress,
4081         Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
4082 -       Opt_discard, Opt_err,
4083 +       Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
4084  };
4085  
4086  static match_table_t tokens = {
4087 @@ -92,6 +92,9 @@ static match_table_t tokens = {
4088         {Opt_flushoncommit, "flushoncommit"},
4089         {Opt_ratio, "metadata_ratio=%d"},
4090         {Opt_discard, "discard"},
4091 +       {Opt_tag, "tag"},
4092 +       {Opt_notag, "notag"},
4093 +       {Opt_tagid, "tagid=%u"},
4094         {Opt_err, NULL},
4095  };
4096  
4097 @@ -235,6 +238,22 @@ int btrfs_parse_options(struct btrfs_roo
4098                 case Opt_discard:
4099                         btrfs_set_opt(info->mount_opt, DISCARD);
4100                         break;
4101 +#ifndef CONFIG_TAGGING_NONE
4102 +               case Opt_tag:
4103 +                       printk(KERN_INFO "btrfs: use tagging\n");
4104 +                       btrfs_set_opt(info->mount_opt, TAGGED);
4105 +                       break;
4106 +               case Opt_notag:
4107 +                       printk(KERN_INFO "btrfs: disabled tagging\n");
4108 +                       btrfs_clear_opt(info->mount_opt, TAGGED);
4109 +                       break;
4110 +#endif
4111 +#ifdef CONFIG_PROPAGATE
4112 +               case Opt_tagid:
4113 +                       /* use args[0] */
4114 +                       btrfs_set_opt(info->mount_opt, TAGGED);
4115 +                       break;
4116 +#endif
4117                 case Opt_err:
4118                         printk(KERN_INFO "btrfs: unrecognized mount option "
4119                                "'%s'\n", p);
4120 @@ -679,6 +698,12 @@ static int btrfs_remount(struct super_bl
4121         if (ret)
4122                 return -EINVAL;
4123  
4124 +       if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4125 +               printk("btrfs: %s: tagging not permitted on remount.\n",
4126 +                       sb->s_id);
4127 +               return -EINVAL;
4128 +       }
4129 +
4130         if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
4131                 return 0;
4132  
4133 diff -NurpP --minimal linux-2.6.34/fs/char_dev.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/char_dev.c
4134 --- linux-2.6.34/fs/char_dev.c  2009-12-03 20:02:51.000000000 +0100
4135 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/char_dev.c     2010-05-18 18:11:22.000000000 +0200
4136 @@ -20,6 +20,8 @@
4137  #include <linux/cdev.h>
4138  #include <linux/mutex.h>
4139  #include <linux/backing-dev.h>
4140 +#include <linux/vs_context.h>
4141 +#include <linux/vs_device.h>
4142  
4143  #include "internal.h"
4144  
4145 @@ -368,14 +370,21 @@ static int chrdev_open(struct inode *ino
4146         struct cdev *p;
4147         struct cdev *new = NULL;
4148         int ret = 0;
4149 +       dev_t mdev;
4150 +
4151 +       if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
4152 +               return -EPERM;
4153 +       inode->i_mdev = mdev;
4154  
4155         spin_lock(&cdev_lock);
4156         p = inode->i_cdev;
4157         if (!p) {
4158                 struct kobject *kobj;
4159                 int idx;
4160 +
4161                 spin_unlock(&cdev_lock);
4162 -               kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
4163 +
4164 +               kobj = kobj_lookup(cdev_map, mdev, &idx);
4165                 if (!kobj)
4166                         return -ENXIO;
4167                 new = container_of(kobj, struct cdev, kobj);
4168 diff -NurpP --minimal linux-2.6.34/fs/dcache.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/dcache.c
4169 --- linux-2.6.34/fs/dcache.c    2010-05-18 15:07:51.000000000 +0200
4170 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/dcache.c       2010-05-18 18:11:22.000000000 +0200
4171 @@ -33,6 +33,7 @@
4172  #include <linux/bootmem.h>
4173  #include <linux/fs_struct.h>
4174  #include <linux/hardirq.h>
4175 +#include <linux/vs_limit.h>
4176  #include "internal.h"
4177  
4178  int sysctl_vfs_cache_pressure __read_mostly = 100;
4179 @@ -230,6 +231,8 @@ repeat:
4180                 return;
4181         }
4182  
4183 +       vx_dentry_dec(dentry);
4184 +
4185         /*
4186          * AV: ->d_delete() is _NOT_ allowed to block now.
4187          */
4188 @@ -323,6 +326,7 @@ static inline struct dentry * __dget_loc
4189  {
4190         atomic_inc(&dentry->d_count);
4191         dentry_lru_del_init(dentry);
4192 +       vx_dentry_inc(dentry);
4193         return dentry;
4194  }
4195  
4196 @@ -927,6 +931,9 @@ struct dentry *d_alloc(struct dentry * p
4197         struct dentry *dentry;
4198         char *dname;
4199  
4200 +       if (!vx_dentry_avail(1))
4201 +               return NULL;
4202 +
4203         dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
4204         if (!dentry)
4205                 return NULL;
4206 @@ -972,6 +979,7 @@ struct dentry *d_alloc(struct dentry * p
4207         if (parent)
4208                 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
4209         dentry_stat.nr_dentry++;
4210 +       vx_dentry_inc(dentry);
4211         spin_unlock(&dcache_lock);
4212  
4213         return dentry;
4214 @@ -1421,6 +1429,7 @@ struct dentry * __d_lookup(struct dentry
4215                 }
4216  
4217                 atomic_inc(&dentry->d_count);
4218 +               vx_dentry_inc(dentry);
4219                 found = dentry;
4220                 spin_unlock(&dentry->d_lock);
4221                 break;
4222 diff -NurpP --minimal linux-2.6.34/fs/devpts/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/devpts/inode.c
4223 --- linux-2.6.34/fs/devpts/inode.c      2010-05-18 15:07:51.000000000 +0200
4224 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/devpts/inode.c 2010-05-18 18:11:22.000000000 +0200
4225 @@ -25,6 +25,7 @@
4226  #include <linux/parser.h>
4227  #include <linux/fsnotify.h>
4228  #include <linux/seq_file.h>
4229 +#include <linux/vs_base.h>
4230  
4231  #define DEVPTS_DEFAULT_MODE 0600
4232  /*
4233 @@ -36,6 +37,20 @@
4234  #define DEVPTS_DEFAULT_PTMX_MODE 0000
4235  #define PTMX_MINOR     2
4236  
4237 +static int devpts_permission(struct inode *inode, int mask)
4238 +{
4239 +       int ret = -EACCES;
4240 +
4241 +       /* devpts is xid tagged */
4242 +       if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
4243 +               ret = generic_permission(inode, mask, NULL);
4244 +       return ret;
4245 +}
4246 +
4247 +static struct inode_operations devpts_file_inode_operations = {
4248 +       .permission     = devpts_permission,
4249 +};
4250 +
4251  extern int pty_limit;                  /* Config limit on Unix98 ptys */
4252  static DEFINE_MUTEX(allocated_ptys_lock);
4253  
4254 @@ -263,6 +278,25 @@ static int devpts_show_options(struct se
4255         return 0;
4256  }
4257  
4258 +static int devpts_filter(struct dentry *de)
4259 +{
4260 +       /* devpts is xid tagged */
4261 +       return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
4262 +}
4263 +
4264 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
4265 +{
4266 +       return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
4267 +}
4268 +
4269 +static struct file_operations devpts_dir_operations = {
4270 +       .open           = dcache_dir_open,
4271 +       .release        = dcache_dir_close,
4272 +       .llseek         = dcache_dir_lseek,
4273 +       .read           = generic_read_dir,
4274 +       .readdir        = devpts_readdir,
4275 +};
4276 +
4277  static const struct super_operations devpts_sops = {
4278         .statfs         = simple_statfs,
4279         .remount_fs     = devpts_remount,
4280 @@ -302,12 +336,15 @@ devpts_fill_super(struct super_block *s,
4281         inode = new_inode(s);
4282         if (!inode)
4283                 goto free_fsi;
4284 +
4285         inode->i_ino = 1;
4286         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4287         inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
4288         inode->i_op = &simple_dir_inode_operations;
4289 -       inode->i_fop = &simple_dir_operations;
4290 +       inode->i_fop = &devpts_dir_operations;
4291         inode->i_nlink = 2;
4292 +       /* devpts is xid tagged */
4293 +       inode->i_tag = (tag_t)vx_current_xid();
4294  
4295         s->s_root = d_alloc_root(inode);
4296         if (s->s_root)
4297 @@ -498,6 +535,9 @@ int devpts_pty_new(struct inode *ptmx_in
4298         inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
4299         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4300         init_special_inode(inode, S_IFCHR|opts->mode, device);
4301 +       /* devpts is xid tagged */
4302 +       inode->i_tag = (tag_t)vx_current_xid();
4303 +       inode->i_op = &devpts_file_inode_operations;
4304         inode->i_private = tty;
4305         tty->driver_data = inode;
4306  
4307 diff -NurpP --minimal linux-2.6.34/fs/exec.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/exec.c
4308 --- linux-2.6.34/fs/exec.c      2010-05-18 15:07:51.000000000 +0200
4309 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/exec.c 2010-05-19 03:10:18.000000000 +0200
4310 @@ -1502,7 +1502,7 @@ static int format_corename(char *corenam
4311                         /* UNIX time of coredump */
4312                         case 't': {
4313                                 struct timeval tv;
4314 -                               do_gettimeofday(&tv);
4315 +                               vx_gettimeofday(&tv);
4316                                 rc = snprintf(out_ptr, out_end - out_ptr,
4317                                               "%lu", tv.tv_sec);
4318                                 if (rc > out_end - out_ptr)
4319 diff -NurpP --minimal linux-2.6.34/fs/ext2/balloc.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/balloc.c
4320 --- linux-2.6.34/fs/ext2/balloc.c       2010-05-18 15:07:51.000000000 +0200
4321 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/balloc.c  2010-05-18 18:11:22.000000000 +0200
4322 @@ -702,7 +702,6 @@ ext2_try_to_allocate(struct super_block 
4323                         start = 0;
4324                 end = EXT2_BLOCKS_PER_GROUP(sb);
4325         }
4326 -
4327         BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
4328  
4329  repeat:
4330 diff -NurpP --minimal linux-2.6.34/fs/ext2/ext2.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/ext2.h
4331 --- linux-2.6.34/fs/ext2/ext2.h 2010-05-18 15:07:51.000000000 +0200
4332 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/ext2.h    2010-05-18 18:11:22.000000000 +0200
4333 @@ -131,6 +131,7 @@ extern int ext2_fiemap(struct inode *ino
4334  int __ext2_write_begin(struct file *file, struct address_space *mapping,
4335                 loff_t pos, unsigned len, unsigned flags,
4336                 struct page **pagep, void **fsdata);
4337 +extern int ext2_sync_flags(struct inode *, int, int);
4338  
4339  /* ioctl.c */
4340  extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
4341 diff -NurpP --minimal linux-2.6.34/fs/ext2/file.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/file.c
4342 --- linux-2.6.34/fs/ext2/file.c 2010-05-18 15:07:51.000000000 +0200
4343 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/file.c    2010-05-18 18:11:22.000000000 +0200
4344 @@ -105,4 +105,5 @@ const struct inode_operations ext2_file_
4345         .setattr        = ext2_setattr,
4346         .check_acl      = ext2_check_acl,
4347         .fiemap         = ext2_fiemap,
4348 +       .sync_flags     = ext2_sync_flags,
4349  };
4350 diff -NurpP --minimal linux-2.6.34/fs/ext2/ialloc.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/ialloc.c
4351 --- linux-2.6.34/fs/ext2/ialloc.c       2010-05-18 15:07:51.000000000 +0200
4352 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/ialloc.c  2010-05-18 18:11:22.000000000 +0200
4353 @@ -17,6 +17,7 @@
4354  #include <linux/backing-dev.h>
4355  #include <linux/buffer_head.h>
4356  #include <linux/random.h>
4357 +#include <linux/vs_tag.h>
4358  #include "ext2.h"
4359  #include "xattr.h"
4360  #include "acl.h"
4361 @@ -560,6 +561,7 @@ got:
4362         } else
4363                 inode->i_gid = current_fsgid();
4364         inode->i_mode = mode;
4365 +       inode->i_tag = dx_current_fstag(sb);
4366  
4367         inode->i_ino = ino;
4368         inode->i_blocks = 0;
4369 diff -NurpP --minimal linux-2.6.34/fs/ext2/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/inode.c
4370 --- linux-2.6.34/fs/ext2/inode.c        2010-05-18 15:07:51.000000000 +0200
4371 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/inode.c   2010-05-18 18:11:22.000000000 +0200
4372 @@ -33,6 +33,7 @@
4373  #include <linux/mpage.h>
4374  #include <linux/fiemap.h>
4375  #include <linux/namei.h>
4376 +#include <linux/vs_tag.h>
4377  #include "ext2.h"
4378  #include "acl.h"
4379  #include "xip.h"
4380 @@ -1046,7 +1047,7 @@ void ext2_truncate(struct inode *inode)
4381                 return;
4382         if (ext2_inode_is_fast_symlink(inode))
4383                 return;
4384 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4385 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4386                 return;
4387  
4388         blocksize = inode->i_sb->s_blocksize;
4389 @@ -1184,36 +1185,61 @@ void ext2_set_inode_flags(struct inode *
4390  {
4391         unsigned int flags = EXT2_I(inode)->i_flags;
4392  
4393 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4394 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4395 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4396 +
4397 +
4398 +       if (flags & EXT2_IMMUTABLE_FL)
4399 +               inode->i_flags |= S_IMMUTABLE;
4400 +       if (flags & EXT2_IXUNLINK_FL)
4401 +               inode->i_flags |= S_IXUNLINK;
4402 +
4403         if (flags & EXT2_SYNC_FL)
4404                 inode->i_flags |= S_SYNC;
4405         if (flags & EXT2_APPEND_FL)
4406                 inode->i_flags |= S_APPEND;
4407 -       if (flags & EXT2_IMMUTABLE_FL)
4408 -               inode->i_flags |= S_IMMUTABLE;
4409         if (flags & EXT2_NOATIME_FL)
4410                 inode->i_flags |= S_NOATIME;
4411         if (flags & EXT2_DIRSYNC_FL)
4412                 inode->i_flags |= S_DIRSYNC;
4413 +
4414 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
4415 +
4416 +       if (flags & EXT2_BARRIER_FL)
4417 +               inode->i_vflags |= V_BARRIER;
4418 +       if (flags & EXT2_COW_FL)
4419 +               inode->i_vflags |= V_COW;
4420  }
4421  
4422  /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
4423  void ext2_get_inode_flags(struct ext2_inode_info *ei)
4424  {
4425         unsigned int flags = ei->vfs_inode.i_flags;
4426 +       unsigned int vflags = ei->vfs_inode.i_vflags;
4427 +
4428 +       ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
4429 +                       EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
4430 +                       EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
4431 +                       EXT2_BARRIER_FL | EXT2_COW_FL);
4432 +
4433 +       if (flags & S_IMMUTABLE)
4434 +               ei->i_flags |= EXT2_IMMUTABLE_FL;
4435 +       if (flags & S_IXUNLINK)
4436 +               ei->i_flags |= EXT2_IXUNLINK_FL;
4437  
4438 -       ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
4439 -                       EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
4440         if (flags & S_SYNC)
4441                 ei->i_flags |= EXT2_SYNC_FL;
4442         if (flags & S_APPEND)
4443                 ei->i_flags |= EXT2_APPEND_FL;
4444 -       if (flags & S_IMMUTABLE)
4445 -               ei->i_flags |= EXT2_IMMUTABLE_FL;
4446         if (flags & S_NOATIME)
4447                 ei->i_flags |= EXT2_NOATIME_FL;
4448         if (flags & S_DIRSYNC)
4449                 ei->i_flags |= EXT2_DIRSYNC_FL;
4450 +
4451 +       if (vflags & V_BARRIER)
4452 +               ei->i_flags |= EXT2_BARRIER_FL;
4453 +       if (vflags & V_COW)
4454 +               ei->i_flags |= EXT2_COW_FL;
4455  }
4456  
4457  struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
4458 @@ -1223,6 +1249,8 @@ struct inode *ext2_iget (struct super_bl
4459         struct ext2_inode *raw_inode;
4460         struct inode *inode;
4461         long ret = -EIO;
4462 +       uid_t uid;
4463 +       gid_t gid;
4464         int n;
4465  
4466         inode = iget_locked(sb, ino);
4467 @@ -1241,12 +1269,17 @@ struct inode *ext2_iget (struct super_bl
4468         }
4469  
4470         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4471 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4472 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4473 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4474 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4475         if (!(test_opt (inode->i_sb, NO_UID32))) {
4476 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4477 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4478 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4479 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4480         }
4481 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4482 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4483 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4484 +               le16_to_cpu(raw_inode->i_raw_tag));
4485 +
4486         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4487         inode->i_size = le32_to_cpu(raw_inode->i_size);
4488         inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4489 @@ -1344,8 +1377,8 @@ static int __ext2_write_inode(struct ino
4490         struct ext2_inode_info *ei = EXT2_I(inode);
4491         struct super_block *sb = inode->i_sb;
4492         ino_t ino = inode->i_ino;
4493 -       uid_t uid = inode->i_uid;
4494 -       gid_t gid = inode->i_gid;
4495 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4496 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4497         struct buffer_head * bh;
4498         struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
4499         int n;
4500 @@ -1381,6 +1414,9 @@ static int __ext2_write_inode(struct ino
4501                 raw_inode->i_uid_high = 0;
4502                 raw_inode->i_gid_high = 0;
4503         }
4504 +#ifdef CONFIG_TAGGING_INTERN
4505 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4506 +#endif
4507         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4508         raw_inode->i_size = cpu_to_le32(inode->i_size);
4509         raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4510 @@ -1470,7 +1506,8 @@ int ext2_setattr(struct dentry *dentry, 
4511         if (iattr->ia_valid & ATTR_SIZE)
4512                 dquot_initialize(inode);
4513         if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4514 -           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4515 +           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4516 +           (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4517                 error = dquot_transfer(inode, iattr);
4518                 if (error)
4519                         return error;
4520 diff -NurpP --minimal linux-2.6.34/fs/ext2/ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/ioctl.c
4521 --- linux-2.6.34/fs/ext2/ioctl.c        2009-09-10 15:26:21.000000000 +0200
4522 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/ioctl.c   2010-05-18 18:11:22.000000000 +0200
4523 @@ -17,6 +17,16 @@
4524  #include <asm/uaccess.h>
4525  
4526  
4527 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
4528 +{
4529 +       inode->i_flags = flags;
4530 +       inode->i_vflags = vflags;
4531 +       ext2_get_inode_flags(EXT2_I(inode));
4532 +       inode->i_ctime = CURRENT_TIME_SEC;
4533 +       mark_inode_dirty(inode);
4534 +       return 0;
4535 +}
4536 +
4537  long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4538  {
4539         struct inode *inode = filp->f_dentry->d_inode;
4540 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
4541  
4542                 flags = ext2_mask_flags(inode->i_mode, flags);
4543  
4544 +               if (IS_BARRIER(inode)) {
4545 +                       vxwprintk_task(1, "messing with the barrier.");
4546 +                       return -EACCES;
4547 +               }
4548 +
4549                 mutex_lock(&inode->i_mutex);
4550                 /* Is it quota file? Do not allow user to mess with it */
4551                 if (IS_NOQUOTA(inode)) {
4552 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
4553                  *
4554                  * This test looks nicer. Thanks to Pauline Middelink
4555                  */
4556 -               if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
4557 +               if ((oldflags & EXT2_IMMUTABLE_FL) ||
4558 +                       ((flags ^ oldflags) & (EXT2_APPEND_FL |
4559 +                       EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
4560                         if (!capable(CAP_LINUX_IMMUTABLE)) {
4561                                 mutex_unlock(&inode->i_mutex);
4562                                 ret = -EPERM;
4563 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
4564                         }
4565                 }
4566  
4567 -               flags = flags & EXT2_FL_USER_MODIFIABLE;
4568 +               flags &= EXT2_FL_USER_MODIFIABLE;
4569                 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
4570                 ei->i_flags = flags;
4571                 mutex_unlock(&inode->i_mutex);
4572 diff -NurpP --minimal linux-2.6.34/fs/ext2/namei.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/namei.c
4573 --- linux-2.6.34/fs/ext2/namei.c        2010-05-18 15:07:51.000000000 +0200
4574 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/namei.c   2010-05-18 18:11:22.000000000 +0200
4575 @@ -32,6 +32,7 @@
4576  
4577  #include <linux/pagemap.h>
4578  #include <linux/quotaops.h>
4579 +#include <linux/vs_tag.h>
4580  #include "ext2.h"
4581  #include "xattr.h"
4582  #include "acl.h"
4583 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
4584                                 return ERR_PTR(-EIO);
4585                         } else {
4586                                 return ERR_CAST(inode);
4587 +               dx_propagate_tag(nd, inode);
4588                         }
4589                 }
4590         }
4591 @@ -418,6 +420,7 @@ const struct inode_operations ext2_dir_i
4592  #endif
4593         .setattr        = ext2_setattr,
4594         .check_acl      = ext2_check_acl,
4595 +       .sync_flags     = ext2_sync_flags,
4596  };
4597  
4598  const struct inode_operations ext2_special_inode_operations = {
4599 diff -NurpP --minimal linux-2.6.34/fs/ext2/super.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/super.c
4600 --- linux-2.6.34/fs/ext2/super.c        2010-05-18 15:07:51.000000000 +0200
4601 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext2/super.c   2010-05-18 18:11:22.000000000 +0200
4602 @@ -384,7 +384,8 @@ enum {
4603         Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
4604         Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
4605         Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
4606 -       Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
4607 +       Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
4608 +       Opt_tag, Opt_notag, Opt_tagid
4609  };
4610  
4611  static const match_table_t tokens = {
4612 @@ -412,6 +413,9 @@ static const match_table_t tokens = {
4613         {Opt_acl, "acl"},
4614         {Opt_noacl, "noacl"},
4615         {Opt_xip, "xip"},
4616 +       {Opt_tag, "tag"},
4617 +       {Opt_notag, "notag"},
4618 +       {Opt_tagid, "tagid=%u"},
4619         {Opt_grpquota, "grpquota"},
4620         {Opt_ignore, "noquota"},
4621         {Opt_quota, "quota"},
4622 @@ -482,6 +486,20 @@ static int parse_options(char *options, 
4623                 case Opt_nouid32:
4624                         set_opt (sbi->s_mount_opt, NO_UID32);
4625                         break;
4626 +#ifndef CONFIG_TAGGING_NONE
4627 +               case Opt_tag:
4628 +                       set_opt (sbi->s_mount_opt, TAGGED);
4629 +                       break;
4630 +               case Opt_notag:
4631 +                       clear_opt (sbi->s_mount_opt, TAGGED);
4632 +                       break;
4633 +#endif
4634 +#ifdef CONFIG_PROPAGATE
4635 +               case Opt_tagid:
4636 +                       /* use args[0] */
4637 +                       set_opt (sbi->s_mount_opt, TAGGED);
4638 +                       break;
4639 +#endif
4640                 case Opt_nocheck:
4641                         clear_opt (sbi->s_mount_opt, CHECK);
4642                         break;
4643 @@ -838,6 +856,8 @@ static int ext2_fill_super(struct super_
4644         if (!parse_options((char *) data, sb))
4645                 goto failed_mount;
4646  
4647 +       if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
4648 +               sb->s_flags |= MS_TAGGED;
4649         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4650                 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
4651                  MS_POSIXACL : 0);
4652 @@ -1231,6 +1251,14 @@ static int ext2_remount (struct super_bl
4653                 goto restore_opts;
4654         }
4655  
4656 +       if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
4657 +               !(sb->s_flags & MS_TAGGED)) {
4658 +               printk("EXT2-fs: %s: tagging not permitted on remount.\n",
4659 +                      sb->s_id);
4660 +               err = -EINVAL;
4661 +               goto restore_opts;
4662 +       }
4663 +
4664         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4665                 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4666  
4667 diff -NurpP --minimal linux-2.6.34/fs/ext3/file.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/file.c
4668 --- linux-2.6.34/fs/ext3/file.c 2010-05-18 15:07:51.000000000 +0200
4669 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/file.c    2010-05-18 18:11:22.000000000 +0200
4670 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
4671  #endif
4672         .check_acl      = ext3_check_acl,
4673         .fiemap         = ext3_fiemap,
4674 +       .sync_flags     = ext3_sync_flags,
4675  };
4676  
4677 diff -NurpP --minimal linux-2.6.34/fs/ext3/ialloc.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/ialloc.c
4678 --- linux-2.6.34/fs/ext3/ialloc.c       2010-05-18 15:07:51.000000000 +0200
4679 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/ialloc.c  2010-05-18 18:11:22.000000000 +0200
4680 @@ -23,6 +23,7 @@
4681  #include <linux/buffer_head.h>
4682  #include <linux/random.h>
4683  #include <linux/bitops.h>
4684 +#include <linux/vs_tag.h>
4685  
4686  #include <asm/byteorder.h>
4687  
4688 @@ -548,6 +549,7 @@ got:
4689         } else
4690                 inode->i_gid = current_fsgid();
4691         inode->i_mode = mode;
4692 +       inode->i_tag = dx_current_fstag(sb);
4693  
4694         inode->i_ino = ino;
4695         /* This is the optimal IO size (for stat), not the fs block size */
4696 diff -NurpP --minimal linux-2.6.34/fs/ext3/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/inode.c
4697 --- linux-2.6.34/fs/ext3/inode.c        2010-05-18 15:07:51.000000000 +0200
4698 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/inode.c   2010-05-18 18:11:22.000000000 +0200
4699 @@ -38,6 +38,7 @@
4700  #include <linux/bio.h>
4701  #include <linux/fiemap.h>
4702  #include <linux/namei.h>
4703 +#include <linux/vs_tag.h>
4704  #include "xattr.h"
4705  #include "acl.h"
4706  
4707 @@ -2354,7 +2355,7 @@ static void ext3_free_branches(handle_t 
4708  
4709  int ext3_can_truncate(struct inode *inode)
4710  {
4711 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4712 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4713                 return 0;
4714         if (S_ISREG(inode->i_mode))
4715                 return 1;
4716 @@ -2739,36 +2740,60 @@ void ext3_set_inode_flags(struct inode *
4717  {
4718         unsigned int flags = EXT3_I(inode)->i_flags;
4719  
4720 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4721 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4722 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4723 +
4724 +       if (flags & EXT3_IMMUTABLE_FL)
4725 +               inode->i_flags |= S_IMMUTABLE;
4726 +       if (flags & EXT3_IXUNLINK_FL)
4727 +               inode->i_flags |= S_IXUNLINK;
4728 +
4729         if (flags & EXT3_SYNC_FL)
4730                 inode->i_flags |= S_SYNC;
4731         if (flags & EXT3_APPEND_FL)
4732                 inode->i_flags |= S_APPEND;
4733 -       if (flags & EXT3_IMMUTABLE_FL)
4734 -               inode->i_flags |= S_IMMUTABLE;
4735         if (flags & EXT3_NOATIME_FL)
4736                 inode->i_flags |= S_NOATIME;
4737         if (flags & EXT3_DIRSYNC_FL)
4738                 inode->i_flags |= S_DIRSYNC;
4739 +
4740 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
4741 +
4742 +       if (flags & EXT3_BARRIER_FL)
4743 +               inode->i_vflags |= V_BARRIER;
4744 +       if (flags & EXT3_COW_FL)
4745 +               inode->i_vflags |= V_COW;
4746  }
4747  
4748  /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
4749  void ext3_get_inode_flags(struct ext3_inode_info *ei)
4750  {
4751         unsigned int flags = ei->vfs_inode.i_flags;
4752 +       unsigned int vflags = ei->vfs_inode.i_vflags;
4753 +
4754 +       ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
4755 +                       EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
4756 +                       EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
4757 +                       EXT3_BARRIER_FL | EXT3_COW_FL);
4758 +
4759 +       if (flags & S_IMMUTABLE)
4760 +               ei->i_flags |= EXT3_IMMUTABLE_FL;
4761 +       if (flags & S_IXUNLINK)
4762 +               ei->i_flags |= EXT3_IXUNLINK_FL;
4763  
4764 -       ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
4765 -                       EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
4766         if (flags & S_SYNC)
4767                 ei->i_flags |= EXT3_SYNC_FL;
4768         if (flags & S_APPEND)
4769                 ei->i_flags |= EXT3_APPEND_FL;
4770 -       if (flags & S_IMMUTABLE)
4771 -               ei->i_flags |= EXT3_IMMUTABLE_FL;
4772         if (flags & S_NOATIME)
4773                 ei->i_flags |= EXT3_NOATIME_FL;
4774         if (flags & S_DIRSYNC)
4775                 ei->i_flags |= EXT3_DIRSYNC_FL;
4776 +
4777 +       if (vflags & V_BARRIER)
4778 +               ei->i_flags |= EXT3_BARRIER_FL;
4779 +       if (vflags & V_COW)
4780 +               ei->i_flags |= EXT3_COW_FL;
4781  }
4782  
4783  struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
4784 @@ -2782,6 +2807,8 @@ struct inode *ext3_iget(struct super_blo
4785         transaction_t *transaction;
4786         long ret;
4787         int block;
4788 +       uid_t uid;
4789 +       gid_t gid;
4790  
4791         inode = iget_locked(sb, ino);
4792         if (!inode)
4793 @@ -2798,12 +2825,17 @@ struct inode *ext3_iget(struct super_blo
4794         bh = iloc.bh;
4795         raw_inode = ext3_raw_inode(&iloc);
4796         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4797 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4798 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4799 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4800 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4801         if(!(test_opt (inode->i_sb, NO_UID32))) {
4802 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4803 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4804 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4805 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4806         }
4807 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4808 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4809 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4810 +               le16_to_cpu(raw_inode->i_raw_tag));
4811 +
4812         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4813         inode->i_size = le32_to_cpu(raw_inode->i_size);
4814         inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4815 @@ -2958,6 +2990,8 @@ static int ext3_do_update_inode(handle_t
4816         struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
4817         struct ext3_inode_info *ei = EXT3_I(inode);
4818         struct buffer_head *bh = iloc->bh;
4819 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4820 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4821         int err = 0, rc, block;
4822  
4823  again:
4824 @@ -2972,29 +3006,32 @@ again:
4825         ext3_get_inode_flags(ei);
4826         raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4827         if(!(test_opt(inode->i_sb, NO_UID32))) {
4828 -               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4829 -               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4830 +               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4831 +               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4832  /*
4833   * Fix up interoperability with old kernels. Otherwise, old inodes get
4834   * re-used with the upper 16 bits of the uid/gid intact
4835   */
4836                 if(!ei->i_dtime) {
4837                         raw_inode->i_uid_high =
4838 -                               cpu_to_le16(high_16_bits(inode->i_uid));
4839 +                               cpu_to_le16(high_16_bits(uid));
4840                         raw_inode->i_gid_high =
4841 -                               cpu_to_le16(high_16_bits(inode->i_gid));
4842 +                               cpu_to_le16(high_16_bits(gid));
4843                 } else {
4844                         raw_inode->i_uid_high = 0;
4845                         raw_inode->i_gid_high = 0;
4846                 }
4847         } else {
4848                 raw_inode->i_uid_low =
4849 -                       cpu_to_le16(fs_high2lowuid(inode->i_uid));
4850 +                       cpu_to_le16(fs_high2lowuid(uid));
4851                 raw_inode->i_gid_low =
4852 -                       cpu_to_le16(fs_high2lowgid(inode->i_gid));
4853 +                       cpu_to_le16(fs_high2lowgid(gid));
4854                 raw_inode->i_uid_high = 0;
4855                 raw_inode->i_gid_high = 0;
4856         }
4857 +#ifdef CONFIG_TAGGING_INTERN
4858 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4859 +#endif
4860         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4861         raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4862         raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4863 @@ -3154,7 +3191,8 @@ int ext3_setattr(struct dentry *dentry, 
4864         if (ia_valid & ATTR_SIZE)
4865                 dquot_initialize(inode);
4866         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4867 -               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4868 +               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4869 +               (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4870                 handle_t *handle;
4871  
4872                 /* (user+group)*(old+new) structure, inode write (sb,
4873 @@ -3176,6 +3214,8 @@ int ext3_setattr(struct dentry *dentry, 
4874                         inode->i_uid = attr->ia_uid;
4875                 if (attr->ia_valid & ATTR_GID)
4876                         inode->i_gid = attr->ia_gid;
4877 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4878 +                       inode->i_tag = attr->ia_tag;
4879                 error = ext3_mark_inode_dirty(handle, inode);
4880                 ext3_journal_stop(handle);
4881         }
4882 diff -NurpP --minimal linux-2.6.34/fs/ext3/ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/ioctl.c
4883 --- linux-2.6.34/fs/ext3/ioctl.c        2009-06-11 17:13:03.000000000 +0200
4884 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/ioctl.c   2010-05-18 18:11:22.000000000 +0200
4885 @@ -8,6 +8,7 @@
4886   */
4887  
4888  #include <linux/fs.h>
4889 +#include <linux/mount.h>
4890  #include <linux/jbd.h>
4891  #include <linux/capability.h>
4892  #include <linux/ext3_fs.h>
4893 @@ -17,6 +18,34 @@
4894  #include <linux/compat.h>
4895  #include <asm/uaccess.h>
4896  
4897 +
4898 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
4899 +{
4900 +       handle_t *handle = NULL;
4901 +       struct ext3_iloc iloc;
4902 +       int err;
4903 +
4904 +       handle = ext3_journal_start(inode, 1);
4905 +       if (IS_ERR(handle))
4906 +               return PTR_ERR(handle);
4907 +
4908 +       if (IS_SYNC(inode))
4909 +               handle->h_sync = 1;
4910 +       err = ext3_reserve_inode_write(handle, inode, &iloc);
4911 +       if (err)
4912 +               goto flags_err;
4913 +
4914 +       inode->i_flags = flags;
4915 +       inode->i_vflags = vflags;
4916 +       ext3_get_inode_flags(EXT3_I(inode));
4917 +       inode->i_ctime = CURRENT_TIME_SEC;
4918 +
4919 +       err = ext3_mark_iloc_dirty(handle, inode, &iloc);
4920 +flags_err:
4921 +       ext3_journal_stop(handle);
4922 +       return err;
4923 +}
4924 +
4925  long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4926  {
4927         struct inode *inode = filp->f_dentry->d_inode;
4928 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
4929  
4930                 flags = ext3_mask_flags(inode->i_mode, flags);
4931  
4932 +               if (IS_BARRIER(inode)) {
4933 +                       vxwprintk_task(1, "messing with the barrier.");
4934 +                       return -EACCES;
4935 +               }
4936 +
4937                 mutex_lock(&inode->i_mutex);
4938  
4939                 /* Is it quota file? Do not allow user to mess with it */
4940 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
4941                  *
4942                  * This test looks nicer. Thanks to Pauline Middelink
4943                  */
4944 -               if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
4945 +               if ((oldflags & EXT3_IMMUTABLE_FL) ||
4946 +                       ((flags ^ oldflags) & (EXT3_APPEND_FL |
4947 +                       EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
4948                         if (!capable(CAP_LINUX_IMMUTABLE))
4949                                 goto flags_out;
4950                 }
4951 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
4952                 if (err)
4953                         goto flags_err;
4954  
4955 -               flags = flags & EXT3_FL_USER_MODIFIABLE;
4956 +               flags &= EXT3_FL_USER_MODIFIABLE;
4957                 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
4958                 ei->i_flags = flags;
4959  
4960 diff -NurpP --minimal linux-2.6.34/fs/ext3/namei.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/namei.c
4961 --- linux-2.6.34/fs/ext3/namei.c        2010-05-18 15:07:51.000000000 +0200
4962 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/namei.c   2010-05-18 18:11:22.000000000 +0200
4963 @@ -36,6 +36,7 @@
4964  #include <linux/quotaops.h>
4965  #include <linux/buffer_head.h>
4966  #include <linux/bio.h>
4967 +#include <linux/vs_tag.h>
4968  
4969  #include "namei.h"
4970  #include "xattr.h"
4971 @@ -912,6 +913,7 @@ restart:
4972                                 if (bh)
4973                                         ll_rw_block(READ_META, 1, &bh);
4974                         }
4975 +               dx_propagate_tag(nd, inode);
4976                 }
4977                 if ((bh = bh_use[ra_ptr++]) == NULL)
4978                         goto next;
4979 @@ -2466,6 +2468,7 @@ const struct inode_operations ext3_dir_i
4980         .removexattr    = generic_removexattr,
4981  #endif
4982         .check_acl      = ext3_check_acl,
4983 +       .sync_flags     = ext3_sync_flags,
4984  };
4985  
4986  const struct inode_operations ext3_special_inode_operations = {
4987 diff -NurpP --minimal linux-2.6.34/fs/ext3/super.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/super.c
4988 --- linux-2.6.34/fs/ext3/super.c        2010-05-18 15:07:51.000000000 +0200
4989 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext3/super.c   2010-05-18 18:11:22.000000000 +0200
4990 @@ -811,7 +811,7 @@ enum {
4991         Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4992         Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
4993         Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
4994 -       Opt_usrquota, Opt_grpquota
4995 +       Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
4996  };
4997  
4998  static const match_table_t tokens = {
4999 @@ -866,6 +866,9 @@ static const match_table_t tokens = {
5000         {Opt_usrquota, "usrquota"},
5001         {Opt_barrier, "barrier=%u"},
5002         {Opt_resize, "resize"},
5003 +       {Opt_tag, "tag"},
5004 +       {Opt_notag, "notag"},
5005 +       {Opt_tagid, "tagid=%u"},
5006         {Opt_err, NULL},
5007  };
5008  
5009 @@ -1014,6 +1017,20 @@ static int parse_options (char *options,
5010                 case Opt_nouid32:
5011                         set_opt (sbi->s_mount_opt, NO_UID32);
5012                         break;
5013 +#ifndef CONFIG_TAGGING_NONE
5014 +               case Opt_tag:
5015 +                       set_opt (sbi->s_mount_opt, TAGGED);
5016 +                       break;
5017 +               case Opt_notag:
5018 +                       clear_opt (sbi->s_mount_opt, TAGGED);
5019 +                       break;
5020 +#endif
5021 +#ifdef CONFIG_PROPAGATE
5022 +               case Opt_tagid:
5023 +                       /* use args[0] */
5024 +                       set_opt (sbi->s_mount_opt, TAGGED);
5025 +                       break;
5026 +#endif
5027                 case Opt_nocheck:
5028                         clear_opt (sbi->s_mount_opt, CHECK);
5029                         break;
5030 @@ -1694,6 +1711,9 @@ static int ext3_fill_super (struct super
5031                             NULL, 0))
5032                 goto failed_mount;
5033  
5034 +       if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
5035 +               sb->s_flags |= MS_TAGGED;
5036 +
5037         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5038                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5039  
5040 @@ -2565,6 +2585,14 @@ static int ext3_remount (struct super_bl
5041         if (test_opt(sb, ABORT))
5042                 ext3_abort(sb, __func__, "Abort forced by user");
5043  
5044 +       if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
5045 +               !(sb->s_flags & MS_TAGGED)) {
5046 +               printk("EXT3-fs: %s: tagging not permitted on remount.\n",
5047 +                       sb->s_id);
5048 +               err = -EINVAL;
5049 +               goto restore_opts;
5050 +       }
5051 +
5052         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5053                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5054  
5055 diff -NurpP --minimal linux-2.6.34/fs/ext4/ext4.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/ext4.h
5056 --- linux-2.6.34/fs/ext4/ext4.h 2010-05-18 15:07:51.000000000 +0200
5057 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/ext4.h    2010-05-18 18:11:22.000000000 +0200
5058 @@ -292,8 +292,12 @@ struct flex_groups {
5059  #define EXT4_EXTENTS_FL                        0x00080000 /* Inode uses extents */
5060  #define EXT4_EA_INODE_FL               0x00200000 /* Inode used for large EA */
5061  #define EXT4_EOFBLOCKS_FL              0x00400000 /* Blocks allocated beyond EOF */
5062 +#define EXT4_IXUNLINK_FL               0x08000000 /* Immutable invert on unlink */
5063  #define EXT4_RESERVED_FL               0x80000000 /* reserved for ext4 lib */
5064  
5065 +#define EXT4_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
5066 +#define EXT4_COW_FL                    0x20000000 /* Copy on Write marker */
5067 +
5068  #define EXT4_FL_USER_VISIBLE           0x004BDFFF /* User visible flags */
5069  #define EXT4_FL_USER_MODIFIABLE                0x004B80FF /* User modifiable flags */
5070  
5071 @@ -470,7 +474,8 @@ struct ext4_inode {
5072                         __le16  l_i_file_acl_high;
5073                         __le16  l_i_uid_high;   /* these 2 fields */
5074                         __le16  l_i_gid_high;   /* were reserved2[0] */
5075 -                       __u32   l_i_reserved2;
5076 +                       __le16  l_i_tag;        /* Context Tag */
5077 +                       __u16   l_i_reserved2;
5078                 } linux2;
5079                 struct {
5080                         __le16  h_i_reserved1;  /* Obsoleted fragment number/size which are removed in ext4 */
5081 @@ -584,6 +589,7 @@ do {                                                                               \
5082  #define i_gid_low      i_gid
5083  #define i_uid_high     osd2.linux2.l_i_uid_high
5084  #define i_gid_high     osd2.linux2.l_i_gid_high
5085 +#define i_raw_tag      osd2.linux2.l_i_tag
5086  #define i_reserved2    osd2.linux2.l_i_reserved2
5087  
5088  #elif defined(__GNU__)
5089 @@ -763,6 +769,7 @@ struct ext4_inode_info {
5090  #define EXT4_MOUNT_JOURNAL_CHECKSUM    0x800000 /* Journal checksums */
5091  #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT        0x1000000 /* Journal Async Commit */
5092  #define EXT4_MOUNT_I_VERSION            0x2000000 /* i_version support */
5093 +#define EXT4_MOUNT_TAGGED              0x4000000 /* Enable Context Tags */
5094  #define EXT4_MOUNT_DELALLOC            0x8000000 /* Delalloc support */
5095  #define EXT4_MOUNT_DATA_ERR_ABORT      0x10000000 /* Abort on file data write */
5096  #define EXT4_MOUNT_BLOCK_VALIDITY      0x20000000 /* Block validity checking */
5097 @@ -1787,6 +1794,7 @@ extern int ext4_get_blocks(handle_t *han
5098                            struct buffer_head *bh, int flags);
5099  extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
5100                         __u64 start, __u64 len);
5101 +extern int ext4_sync_flags(struct inode *, int, int);
5102  /* move_extent.c */
5103  extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
5104                              __u64 start_orig, __u64 start_donor,
5105 diff -NurpP --minimal linux-2.6.34/fs/ext4/file.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/file.c
5106 --- linux-2.6.34/fs/ext4/file.c 2010-05-18 15:07:51.000000000 +0200
5107 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/file.c    2010-05-18 18:11:22.000000000 +0200
5108 @@ -160,5 +160,6 @@ const struct inode_operations ext4_file_
5109         .check_acl      = ext4_check_acl,
5110         .fallocate      = ext4_fallocate,
5111         .fiemap         = ext4_fiemap,
5112 +       .sync_flags     = ext4_sync_flags,
5113  };
5114  
5115 diff -NurpP --minimal linux-2.6.34/fs/ext4/ialloc.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/ialloc.c
5116 --- linux-2.6.34/fs/ext4/ialloc.c       2010-05-18 15:07:51.000000000 +0200
5117 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/ialloc.c  2010-05-18 18:11:22.000000000 +0200
5118 @@ -22,6 +22,7 @@
5119  #include <linux/random.h>
5120  #include <linux/bitops.h>
5121  #include <linux/blkdev.h>
5122 +#include <linux/vs_tag.h>
5123  #include <asm/byteorder.h>
5124  
5125  #include "ext4.h"
5126 @@ -989,6 +990,7 @@ got:
5127         } else
5128                 inode->i_gid = current_fsgid();
5129         inode->i_mode = mode;
5130 +       inode->i_tag = dx_current_fstag(sb);
5131  
5132         inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb);
5133         /* This is the optimal IO size (for stat), not the fs block size */
5134 diff -NurpP --minimal linux-2.6.34/fs/ext4/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/inode.c
5135 --- linux-2.6.34/fs/ext4/inode.c        2010-05-18 15:07:51.000000000 +0200
5136 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/inode.c   2010-05-18 18:11:22.000000000 +0200
5137 @@ -40,6 +40,7 @@
5138  #include <linux/workqueue.h>
5139  #include <linux/kernel.h>
5140  #include <linux/slab.h>
5141 +#include <linux/vs_tag.h>
5142  
5143  #include "ext4_jbd2.h"
5144  #include "xattr.h"
5145 @@ -4555,7 +4556,7 @@ static void ext4_free_branches(handle_t 
5146  
5147  int ext4_can_truncate(struct inode *inode)
5148  {
5149 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5150 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5151                 return 0;
5152         if (S_ISREG(inode->i_mode))
5153                 return 1;
5154 @@ -4906,36 +4907,60 @@ void ext4_set_inode_flags(struct inode *
5155  {
5156         unsigned int flags = EXT4_I(inode)->i_flags;
5157  
5158 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5159 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5160 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5161 +
5162 +       if (flags & EXT4_IMMUTABLE_FL)
5163 +               inode->i_flags |= S_IMMUTABLE;
5164 +       if (flags & EXT4_IXUNLINK_FL)
5165 +               inode->i_flags |= S_IXUNLINK;
5166 +
5167         if (flags & EXT4_SYNC_FL)
5168                 inode->i_flags |= S_SYNC;
5169         if (flags & EXT4_APPEND_FL)
5170                 inode->i_flags |= S_APPEND;
5171 -       if (flags & EXT4_IMMUTABLE_FL)
5172 -               inode->i_flags |= S_IMMUTABLE;
5173         if (flags & EXT4_NOATIME_FL)
5174                 inode->i_flags |= S_NOATIME;
5175         if (flags & EXT4_DIRSYNC_FL)
5176                 inode->i_flags |= S_DIRSYNC;
5177 +
5178 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
5179 +
5180 +       if (flags & EXT4_BARRIER_FL)
5181 +               inode->i_vflags |= V_BARRIER;
5182 +       if (flags & EXT4_COW_FL)
5183 +               inode->i_vflags |= V_COW;
5184  }
5185  
5186  /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
5187  void ext4_get_inode_flags(struct ext4_inode_info *ei)
5188  {
5189         unsigned int flags = ei->vfs_inode.i_flags;
5190 +       unsigned int vflags = ei->vfs_inode.i_vflags;
5191 +
5192 +       ei->i_flags &= ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
5193 +                       EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
5194 +                       EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
5195 +                       EXT4_BARRIER_FL | EXT4_COW_FL);
5196 +
5197 +       if (flags & S_IMMUTABLE)
5198 +               ei->i_flags |= EXT4_IMMUTABLE_FL;
5199 +       if (flags & S_IXUNLINK)
5200 +               ei->i_flags |= EXT4_IXUNLINK_FL;
5201  
5202 -       ei->i_flags &= ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
5203 -                       EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|EXT4_DIRSYNC_FL);
5204         if (flags & S_SYNC)
5205                 ei->i_flags |= EXT4_SYNC_FL;
5206         if (flags & S_APPEND)
5207                 ei->i_flags |= EXT4_APPEND_FL;
5208 -       if (flags & S_IMMUTABLE)
5209 -               ei->i_flags |= EXT4_IMMUTABLE_FL;
5210         if (flags & S_NOATIME)
5211                 ei->i_flags |= EXT4_NOATIME_FL;
5212         if (flags & S_DIRSYNC)
5213                 ei->i_flags |= EXT4_DIRSYNC_FL;
5214 +
5215 +       if (vflags & V_BARRIER)
5216 +               ei->i_flags |= EXT4_BARRIER_FL;
5217 +       if (vflags & V_COW)
5218 +               ei->i_flags |= EXT4_COW_FL;
5219  }
5220  
5221  static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
5222 @@ -4970,6 +4995,8 @@ struct inode *ext4_iget(struct super_blo
5223         journal_t *journal = EXT4_SB(sb)->s_journal;
5224         long ret;
5225         int block;
5226 +       uid_t uid;
5227 +       gid_t gid;
5228  
5229         inode = iget_locked(sb, ino);
5230         if (!inode)
5231 @@ -4985,12 +5012,16 @@ struct inode *ext4_iget(struct super_blo
5232                 goto bad_inode;
5233         raw_inode = ext4_raw_inode(&iloc);
5234         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
5235 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5236 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5237 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5238 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5239         if (!(test_opt(inode->i_sb, NO_UID32))) {
5240 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5241 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5242 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5243 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5244         }
5245 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5246 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5247 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5248 +               le16_to_cpu(raw_inode->i_raw_tag));
5249         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
5250  
5251         ei->i_state_flags = 0;
5252 @@ -5210,6 +5241,8 @@ static int ext4_do_update_inode(handle_t
5253         struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
5254         struct ext4_inode_info *ei = EXT4_I(inode);
5255         struct buffer_head *bh = iloc->bh;
5256 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5257 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5258         int err = 0, rc, block;
5259  
5260         /* For fields not not tracking in the in-memory inode,
5261 @@ -5220,29 +5253,32 @@ static int ext4_do_update_inode(handle_t
5262         ext4_get_inode_flags(ei);
5263         raw_inode->i_mode = cpu_to_le16(inode->i_mode);
5264         if (!(test_opt(inode->i_sb, NO_UID32))) {
5265 -               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
5266 -               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
5267 +               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
5268 +               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
5269  /*
5270   * Fix up interoperability with old kernels. Otherwise, old inodes get
5271   * re-used with the upper 16 bits of the uid/gid intact
5272   */
5273                 if (!ei->i_dtime) {
5274                         raw_inode->i_uid_high =
5275 -                               cpu_to_le16(high_16_bits(inode->i_uid));
5276 +                               cpu_to_le16(high_16_bits(uid));
5277                         raw_inode->i_gid_high =
5278 -                               cpu_to_le16(high_16_bits(inode->i_gid));
5279 +                               cpu_to_le16(high_16_bits(gid));
5280                 } else {
5281                         raw_inode->i_uid_high = 0;
5282                         raw_inode->i_gid_high = 0;
5283                 }
5284         } else {
5285                 raw_inode->i_uid_low =
5286 -                       cpu_to_le16(fs_high2lowuid(inode->i_uid));
5287 +                       cpu_to_le16(fs_high2lowuid(uid));
5288                 raw_inode->i_gid_low =
5289 -                       cpu_to_le16(fs_high2lowgid(inode->i_gid));
5290 +                       cpu_to_le16(fs_high2lowgid(gid));
5291                 raw_inode->i_uid_high = 0;
5292                 raw_inode->i_gid_high = 0;
5293         }
5294 +#ifdef CONFIG_TAGGING_INTERN
5295 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
5296 +#endif
5297         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
5298  
5299         EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
5300 @@ -5428,7 +5464,8 @@ int ext4_setattr(struct dentry *dentry, 
5301         if (ia_valid & ATTR_SIZE)
5302                 dquot_initialize(inode);
5303         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
5304 -               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
5305 +               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
5306 +               (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
5307                 handle_t *handle;
5308  
5309                 /* (user+group)*(old+new) structure, inode write (sb,
5310 @@ -5450,6 +5487,8 @@ int ext4_setattr(struct dentry *dentry, 
5311                         inode->i_uid = attr->ia_uid;
5312                 if (attr->ia_valid & ATTR_GID)
5313                         inode->i_gid = attr->ia_gid;
5314 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5315 +                       inode->i_tag = attr->ia_tag;
5316                 error = ext4_mark_inode_dirty(handle, inode);
5317                 ext4_journal_stop(handle);
5318         }
5319 diff -NurpP --minimal linux-2.6.34/fs/ext4/ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/ioctl.c
5320 --- linux-2.6.34/fs/ext4/ioctl.c        2010-05-18 15:07:51.000000000 +0200
5321 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/ioctl.c   2010-05-18 18:11:22.000000000 +0200
5322 @@ -14,10 +14,39 @@
5323  #include <linux/compat.h>
5324  #include <linux/mount.h>
5325  #include <linux/file.h>
5326 +#include <linux/vs_tag.h>
5327  #include <asm/uaccess.h>
5328  #include "ext4_jbd2.h"
5329  #include "ext4.h"
5330  
5331 +
5332 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
5333 +{
5334 +       handle_t *handle = NULL;
5335 +       struct ext4_iloc iloc;
5336 +       int err;
5337 +
5338 +       handle = ext4_journal_start(inode, 1);
5339 +       if (IS_ERR(handle))
5340 +               return PTR_ERR(handle);
5341 +
5342 +       if (IS_SYNC(inode))
5343 +               ext4_handle_sync(handle);
5344 +       err = ext4_reserve_inode_write(handle, inode, &iloc);
5345 +       if (err)
5346 +               goto flags_err;
5347 +
5348 +       inode->i_flags = flags;
5349 +       inode->i_vflags = vflags;
5350 +       ext4_get_inode_flags(EXT4_I(inode));
5351 +       inode->i_ctime = ext4_current_time(inode);
5352 +
5353 +       err = ext4_mark_iloc_dirty(handle, inode, &iloc);
5354 +flags_err:
5355 +       ext4_journal_stop(handle);
5356 +       return err;
5357 +}
5358 +
5359  long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5360  {
5361         struct inode *inode = filp->f_dentry->d_inode;
5362 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
5363  
5364                 flags = ext4_mask_flags(inode->i_mode, flags);
5365  
5366 +               if (IS_BARRIER(inode)) {
5367 +                       vxwprintk_task(1, "messing with the barrier.");
5368 +                       return -EACCES;
5369 +               }
5370 +
5371                 err = -EPERM;
5372                 mutex_lock(&inode->i_mutex);
5373                 /* Is it quota file? Do not allow user to mess with it */
5374 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
5375                  *
5376                  * This test looks nicer. Thanks to Pauline Middelink
5377                  */
5378 -               if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
5379 +               if ((oldflags & EXT4_IMMUTABLE_FL) ||
5380 +                       ((flags ^ oldflags) & (EXT4_APPEND_FL |
5381 +                       EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
5382                         if (!capable(CAP_LINUX_IMMUTABLE))
5383                                 goto flags_out;
5384                 }
5385 diff -NurpP --minimal linux-2.6.34/fs/ext4/namei.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/namei.c
5386 --- linux-2.6.34/fs/ext4/namei.c        2010-05-18 15:07:51.000000000 +0200
5387 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/namei.c   2010-05-18 18:11:22.000000000 +0200
5388 @@ -34,6 +34,7 @@
5389  #include <linux/quotaops.h>
5390  #include <linux/buffer_head.h>
5391  #include <linux/bio.h>
5392 +#include <linux/vs_tag.h>
5393  #include "ext4.h"
5394  #include "ext4_jbd2.h"
5395  
5396 @@ -937,6 +938,7 @@ restart:
5397                                 if (bh)
5398                                         ll_rw_block(READ_META, 1, &bh);
5399                         }
5400 +               dx_propagate_tag(nd, inode);
5401                 }
5402                 if ((bh = bh_use[ra_ptr++]) == NULL)
5403                         goto next;
5404 @@ -2551,6 +2553,7 @@ const struct inode_operations ext4_dir_i
5405  #endif
5406         .check_acl      = ext4_check_acl,
5407         .fiemap         = ext4_fiemap,
5408 +       .sync_flags     = ext4_sync_flags,
5409  };
5410  
5411  const struct inode_operations ext4_special_inode_operations = {
5412 diff -NurpP --minimal linux-2.6.34/fs/ext4/super.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/super.c
5413 --- linux-2.6.34/fs/ext4/super.c        2010-05-18 15:07:51.000000000 +0200
5414 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ext4/super.c   2010-05-18 18:11:22.000000000 +0200
5415 @@ -1156,6 +1156,7 @@ enum {
5416         Opt_inode_readahead_blks, Opt_journal_ioprio,
5417         Opt_dioread_nolock, Opt_dioread_lock,
5418         Opt_discard, Opt_nodiscard,
5419 +       Opt_tag, Opt_notag, Opt_tagid
5420  };
5421  
5422  static const match_table_t tokens = {
5423 @@ -1226,6 +1227,9 @@ static const match_table_t tokens = {
5424         {Opt_dioread_lock, "dioread_lock"},
5425         {Opt_discard, "discard"},
5426         {Opt_nodiscard, "nodiscard"},
5427 +       {Opt_tag, "tag"},
5428 +       {Opt_notag, "notag"},
5429 +       {Opt_tagid, "tagid=%u"},
5430         {Opt_err, NULL},
5431  };
5432  
5433 @@ -1394,6 +1398,20 @@ static int parse_options(char *options, 
5434                 case Opt_nouid32:
5435                         set_opt(sbi->s_mount_opt, NO_UID32);
5436                         break;
5437 +#ifndef CONFIG_TAGGING_NONE
5438 +               case Opt_tag:
5439 +                       set_opt (sbi->s_mount_opt, TAGGED);
5440 +                       break;
5441 +               case Opt_notag:
5442 +                       clear_opt (sbi->s_mount_opt, TAGGED);
5443 +                       break;
5444 +#endif
5445 +#ifdef CONFIG_PROPAGATE
5446 +               case Opt_tagid:
5447 +                       /* use args[0] */
5448 +                       set_opt (sbi->s_mount_opt, TAGGED);
5449 +                       break;
5450 +#endif
5451                 case Opt_debug:
5452                         set_opt(sbi->s_mount_opt, DEBUG);
5453                         break;
5454 @@ -2560,6 +2578,9 @@ static int ext4_fill_super(struct super_
5455                            &journal_ioprio, NULL, 0))
5456                 goto failed_mount;
5457  
5458 +       if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
5459 +               sb->s_flags |= MS_TAGGED;
5460 +
5461         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5462                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5463  
5464 @@ -3612,6 +3633,14 @@ static int ext4_remount(struct super_blo
5465         if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
5466                 ext4_abort(sb, __func__, "Abort forced by user");
5467  
5468 +       if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
5469 +               !(sb->s_flags & MS_TAGGED)) {
5470 +               printk("EXT4-fs: %s: tagging not permitted on remount.\n",
5471 +                       sb->s_id);
5472 +               err = -EINVAL;
5473 +               goto restore_opts;
5474 +       }
5475 +
5476         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5477                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5478  
5479 diff -NurpP --minimal linux-2.6.34/fs/fcntl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/fcntl.c
5480 --- linux-2.6.34/fs/fcntl.c     2010-05-18 15:07:51.000000000 +0200
5481 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/fcntl.c        2010-05-18 18:11:22.000000000 +0200
5482 @@ -19,6 +19,7 @@
5483  #include <linux/signal.h>
5484  #include <linux/rcupdate.h>
5485  #include <linux/pid_namespace.h>
5486 +#include <linux/vs_limit.h>
5487  
5488  #include <asm/poll.h>
5489  #include <asm/siginfo.h>
5490 @@ -102,6 +103,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
5491  
5492         if (tofree)
5493                 filp_close(tofree, files);
5494 +       else
5495 +               vx_openfd_inc(newfd);   /* fd was unused */
5496  
5497         return newfd;
5498  
5499 @@ -426,6 +429,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
5500         filp = fget(fd);
5501         if (!filp)
5502                 goto out;
5503 +       if (!vx_files_avail(1))
5504 +               goto out;
5505  
5506         err = security_file_fcntl(filp, cmd, arg);
5507         if (err) {
5508 diff -NurpP --minimal linux-2.6.34/fs/file.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/file.c
5509 --- linux-2.6.34/fs/file.c      2010-05-18 15:07:51.000000000 +0200
5510 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/file.c 2010-05-18 18:11:22.000000000 +0200
5511 @@ -20,6 +20,7 @@
5512  #include <linux/spinlock.h>
5513  #include <linux/rcupdate.h>
5514  #include <linux/workqueue.h>
5515 +#include <linux/vs_limit.h>
5516  
5517  struct fdtable_defer {
5518         spinlock_t lock;
5519 @@ -368,6 +369,8 @@ struct files_struct *dup_fd(struct files
5520                 struct file *f = *old_fds++;
5521                 if (f) {
5522                         get_file(f);
5523 +                       /* TODO: sum it first for check and performance */
5524 +                       vx_openfd_inc(open_files - i);
5525                 } else {
5526                         /*
5527                          * The fd may be claimed in the fd bitmap but not yet
5528 @@ -476,6 +479,7 @@ repeat:
5529         else
5530                 FD_CLR(fd, fdt->close_on_exec);
5531         error = fd;
5532 +       vx_openfd_inc(fd);
5533  #if 1
5534         /* Sanity check */
5535         if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
5536 diff -NurpP --minimal linux-2.6.34/fs/file_table.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/file_table.c
5537 --- linux-2.6.34/fs/file_table.c        2010-05-18 15:07:51.000000000 +0200
5538 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/file_table.c   2010-05-18 18:11:22.000000000 +0200
5539 @@ -22,6 +22,8 @@
5540  #include <linux/sysctl.h>
5541  #include <linux/percpu_counter.h>
5542  #include <linux/ima.h>
5543 +#include <linux/vs_limit.h>
5544 +#include <linux/vs_context.h>
5545  
5546  #include <asm/atomic.h>
5547  
5548 @@ -133,6 +135,8 @@ struct file *get_empty_filp(void)
5549         spin_lock_init(&f->f_lock);
5550         eventpoll_init_file(f);
5551         /* f->f_version: 0 */
5552 +       f->f_xid = vx_current_xid();
5553 +       vx_files_inc(f);
5554         return f;
5555  
5556  over:
5557 @@ -258,6 +262,8 @@ void __fput(struct file *file)
5558                 cdev_put(inode->i_cdev);
5559         fops_put(file->f_op);
5560         put_pid(file->f_owner.pid);
5561 +       vx_files_dec(file);
5562 +       file->f_xid = 0;
5563         file_kill(file);
5564         if (file->f_mode & FMODE_WRITE)
5565                 drop_file_write_access(file);
5566 @@ -325,6 +331,8 @@ void put_filp(struct file *file)
5567  {
5568         if (atomic_long_dec_and_test(&file->f_count)) {
5569                 security_file_free(file);
5570 +               vx_files_dec(file);
5571 +               file->f_xid = 0;
5572                 file_kill(file);
5573                 file_free(file);
5574         }
5575 diff -NurpP --minimal linux-2.6.34/fs/fs_struct.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/fs_struct.c
5576 --- linux-2.6.34/fs/fs_struct.c 2009-06-11 17:13:04.000000000 +0200
5577 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/fs_struct.c    2010-05-18 18:11:22.000000000 +0200
5578 @@ -4,6 +4,7 @@
5579  #include <linux/path.h>
5580  #include <linux/slab.h>
5581  #include <linux/fs_struct.h>
5582 +#include <linux/vserver/global.h>
5583  
5584  /*
5585   * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
5586 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
5587  {
5588         path_put(&fs->root);
5589         path_put(&fs->pwd);
5590 +       atomic_dec(&vs_global_fs);
5591         kmem_cache_free(fs_cachep, fs);
5592  }
5593  
5594 @@ -112,6 +114,7 @@ struct fs_struct *copy_fs_struct(struct 
5595                 fs->pwd = old->pwd;
5596                 path_get(&old->pwd);
5597                 read_unlock(&old->lock);
5598 +               atomic_inc(&vs_global_fs);
5599         }
5600         return fs;
5601  }
5602 diff -NurpP --minimal linux-2.6.34/fs/gfs2/file.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/gfs2/file.c
5603 --- linux-2.6.34/fs/gfs2/file.c 2010-05-18 15:07:51.000000000 +0200
5604 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/gfs2/file.c    2010-05-18 18:11:22.000000000 +0200
5605 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
5606         [7] = GFS2_DIF_NOATIME,
5607         [12] = GFS2_DIF_EXHASH,
5608         [14] = GFS2_DIF_INHERIT_JDATA,
5609 +       [27] = GFS2_DIF_IXUNLINK,
5610 +       [26] = GFS2_DIF_BARRIER,
5611 +       [29] = GFS2_DIF_COW,
5612  };
5613  
5614  static const u32 gfs2_to_fsflags[32] = {
5615 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
5616         [gfs2fl_NoAtime] = FS_NOATIME_FL,
5617         [gfs2fl_ExHash] = FS_INDEX_FL,
5618         [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
5619 +       [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
5620 +       [gfs2fl_Barrier] = FS_BARRIER_FL,
5621 +       [gfs2fl_Cow] = FS_COW_FL,
5622  };
5623  
5624  static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
5625 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
5626  {
5627         struct gfs2_inode *ip = GFS2_I(inode);
5628         unsigned int flags = inode->i_flags;
5629 +       unsigned int vflags = inode->i_vflags;
5630 +
5631 +       flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5632 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5633  
5634 -       flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5635         if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
5636                 flags |= S_IMMUTABLE;
5637 +       if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
5638 +               flags |= S_IXUNLINK;
5639 +
5640         if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
5641                 flags |= S_APPEND;
5642         if (ip->i_diskflags & GFS2_DIF_NOATIME)
5643 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
5644         if (ip->i_diskflags & GFS2_DIF_SYNC)
5645                 flags |= S_SYNC;
5646         inode->i_flags = flags;
5647 +
5648 +       vflags &= ~(V_BARRIER | V_COW);
5649 +
5650 +       if (ip->i_diskflags & GFS2_DIF_BARRIER)
5651 +               vflags |= V_BARRIER;
5652 +       if (ip->i_diskflags & GFS2_DIF_COW)
5653 +               vflags |= V_COW;
5654 +       inode->i_vflags = vflags;
5655 +}
5656 +
5657 +void gfs2_get_inode_flags(struct inode *inode)
5658 +{
5659 +       struct gfs2_inode *ip = GFS2_I(inode);
5660 +       unsigned int flags = inode->i_flags;
5661 +       unsigned int vflags = inode->i_vflags;
5662 +
5663 +       ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
5664 +                       GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
5665 +                       GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
5666 +                       GFS2_DIF_BARRIER | GFS2_DIF_COW);
5667 +
5668 +       if (flags & S_IMMUTABLE)
5669 +               ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
5670 +       if (flags & S_IXUNLINK)
5671 +               ip->i_diskflags |= GFS2_DIF_IXUNLINK;
5672 +
5673 +       if (flags & S_APPEND)
5674 +               ip->i_diskflags |= GFS2_DIF_APPENDONLY;
5675 +       if (flags & S_NOATIME)
5676 +               ip->i_diskflags |= GFS2_DIF_NOATIME;
5677 +       if (flags & S_SYNC)
5678 +               ip->i_diskflags |= GFS2_DIF_SYNC;
5679 +
5680 +       if (vflags & V_BARRIER)
5681 +               ip->i_diskflags |= GFS2_DIF_BARRIER;
5682 +       if (vflags & V_COW)
5683 +               ip->i_diskflags |= GFS2_DIF_COW;
5684  }
5685  
5686  /* Flags that can be set by user space */
5687 @@ -286,6 +335,37 @@ static int gfs2_set_flags(struct file *f
5688         return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
5689  }
5690  
5691 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
5692 +{
5693 +       struct gfs2_inode *ip = GFS2_I(inode);
5694 +       struct gfs2_sbd *sdp = GFS2_SB(inode);
5695 +       struct buffer_head *bh;
5696 +       struct gfs2_holder gh;
5697 +       int error;
5698 +
5699 +       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
5700 +       if (error)
5701 +               return error;
5702 +       error = gfs2_trans_begin(sdp, RES_DINODE, 0);
5703 +       if (error)
5704 +               goto out;
5705 +       error = gfs2_meta_inode_buffer(ip, &bh);
5706 +       if (error)
5707 +               goto out_trans_end;
5708 +       gfs2_trans_add_bh(ip->i_gl, bh, 1);
5709 +       inode->i_flags = flags;
5710 +       inode->i_vflags = vflags;
5711 +       gfs2_get_inode_flags(inode);
5712 +       gfs2_dinode_out(ip, bh->b_data);
5713 +       brelse(bh);
5714 +       gfs2_set_aops(inode);
5715 +out_trans_end:
5716 +       gfs2_trans_end(sdp);
5717 +out:
5718 +       gfs2_glock_dq_uninit(&gh);
5719 +       return error;
5720 +}
5721 +
5722  static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5723  {
5724         switch(cmd) {
5725 diff -NurpP --minimal linux-2.6.34/fs/gfs2/inode.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/gfs2/inode.h
5726 --- linux-2.6.34/fs/gfs2/inode.h        2009-09-10 15:26:22.000000000 +0200
5727 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/gfs2/inode.h   2010-05-18 18:11:22.000000000 +0200
5728 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
5729  extern const struct file_operations gfs2_dir_fops_nolock;
5730  
5731  extern void gfs2_set_inode_flags(struct inode *inode);
5732 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
5733   
5734  #ifdef CONFIG_GFS2_FS_LOCKING_DLM
5735  extern const struct file_operations gfs2_file_fops;
5736 diff -NurpP --minimal linux-2.6.34/fs/gfs2/ops_inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/gfs2/ops_inode.c
5737 --- linux-2.6.34/fs/gfs2/ops_inode.c    2010-05-18 15:07:51.000000000 +0200
5738 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/gfs2/ops_inode.c       2010-05-18 18:11:22.000000000 +0200
5739 @@ -1343,6 +1343,7 @@ const struct inode_operations gfs2_file_
5740         .listxattr = gfs2_listxattr,
5741         .removexattr = gfs2_removexattr,
5742         .fiemap = gfs2_fiemap,
5743 +       .sync_flags = gfs2_sync_flags,
5744  };
5745  
5746  const struct inode_operations gfs2_dir_iops = {
5747 @@ -1363,6 +1364,7 @@ const struct inode_operations gfs2_dir_i
5748         .listxattr = gfs2_listxattr,
5749         .removexattr = gfs2_removexattr,
5750         .fiemap = gfs2_fiemap,
5751 +       .sync_flags = gfs2_sync_flags,
5752  };
5753  
5754  const struct inode_operations gfs2_symlink_iops = {
5755 diff -NurpP --minimal linux-2.6.34/fs/hfsplus/ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/hfsplus/ioctl.c
5756 --- linux-2.6.34/fs/hfsplus/ioctl.c     2008-12-25 00:26:37.000000000 +0100
5757 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/hfsplus/ioctl.c        2010-05-18 18:11:22.000000000 +0200
5758 @@ -17,6 +17,7 @@
5759  #include <linux/mount.h>
5760  #include <linux/sched.h>
5761  #include <linux/xattr.h>
5762 +#include <linux/mount.h>
5763  #include <asm/uaccess.h>
5764  #include "hfsplus_fs.h"
5765  
5766 diff -NurpP --minimal linux-2.6.34/fs/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/inode.c
5767 --- linux-2.6.34/fs/inode.c     2010-05-18 15:07:52.000000000 +0200
5768 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/inode.c        2010-05-18 18:11:22.000000000 +0200
5769 @@ -131,6 +131,9 @@ int inode_init_always(struct super_block
5770         struct address_space *const mapping = &inode->i_data;
5771  
5772         inode->i_sb = sb;
5773 +
5774 +       /* essential because of inode slab reuse */
5775 +       inode->i_tag = 0;
5776         inode->i_blkbits = sb->s_blocksize_bits;
5777         inode->i_flags = 0;
5778         atomic_set(&inode->i_count, 1);
5779 @@ -151,6 +154,7 @@ int inode_init_always(struct super_block
5780         inode->i_bdev = NULL;
5781         inode->i_cdev = NULL;
5782         inode->i_rdev = 0;
5783 +       inode->i_mdev = 0;
5784         inode->dirtied_when = 0;
5785  
5786         if (security_inode_alloc(inode))
5787 @@ -296,6 +300,8 @@ void __iget(struct inode *inode)
5788         inodes_stat.nr_unused--;
5789  }
5790  
5791 +EXPORT_SYMBOL_GPL(__iget);
5792 +
5793  /**
5794   * clear_inode - clear an inode
5795   * @inode: inode to clear
5796 @@ -1597,9 +1603,11 @@ void init_special_inode(struct inode *in
5797         if (S_ISCHR(mode)) {
5798                 inode->i_fop = &def_chr_fops;
5799                 inode->i_rdev = rdev;
5800 +               inode->i_mdev = rdev;
5801         } else if (S_ISBLK(mode)) {
5802                 inode->i_fop = &def_blk_fops;
5803                 inode->i_rdev = rdev;
5804 +               inode->i_mdev = rdev;
5805         } else if (S_ISFIFO(mode))
5806                 inode->i_fop = &def_fifo_fops;
5807         else if (S_ISSOCK(mode))
5808 diff -NurpP --minimal linux-2.6.34/fs/ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ioctl.c
5809 --- linux-2.6.34/fs/ioctl.c     2010-05-18 15:07:52.000000000 +0200
5810 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ioctl.c        2010-05-18 18:11:22.000000000 +0200
5811 @@ -16,6 +16,9 @@
5812  #include <linux/writeback.h>
5813  #include <linux/buffer_head.h>
5814  #include <linux/falloc.h>
5815 +#include <linux/proc_fs.h>
5816 +#include <linux/vserver/inode.h>
5817 +#include <linux/vs_tag.h>
5818  
5819  #include <asm/ioctls.h>
5820  
5821 diff -NurpP --minimal linux-2.6.34/fs/ioprio.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ioprio.c
5822 --- linux-2.6.34/fs/ioprio.c    2010-05-18 15:07:52.000000000 +0200
5823 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ioprio.c       2010-05-18 18:11:22.000000000 +0200
5824 @@ -27,6 +27,7 @@
5825  #include <linux/syscalls.h>
5826  #include <linux/security.h>
5827  #include <linux/pid_namespace.h>
5828 +#include <linux/vs_base.h>
5829  
5830  int set_task_ioprio(struct task_struct *task, int ioprio)
5831  {
5832 @@ -124,6 +125,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which, 
5833                         else
5834                                 pgrp = find_vpid(who);
5835                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5836 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5837 +                                       continue;
5838                                 ret = set_task_ioprio(p, ioprio);
5839                                 if (ret)
5840                                         break;
5841 @@ -213,6 +216,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which, 
5842                         else
5843                                 pgrp = find_vpid(who);
5844                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5845 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5846 +                                       continue;
5847                                 tmpio = get_task_ioprio(p);
5848                                 if (tmpio < 0)
5849                                         continue;
5850 diff -NurpP --minimal linux-2.6.34/fs/jfs/file.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/file.c
5851 --- linux-2.6.34/fs/jfs/file.c  2010-05-18 15:07:52.000000000 +0200
5852 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/file.c     2010-05-18 18:11:22.000000000 +0200
5853 @@ -101,7 +101,8 @@ int jfs_setattr(struct dentry *dentry, s
5854         if (iattr->ia_valid & ATTR_SIZE)
5855                 dquot_initialize(inode);
5856         if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5857 -           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5858 +           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5859 +           (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5860                 rc = dquot_transfer(inode, iattr);
5861                 if (rc)
5862                         return rc;
5863 @@ -125,6 +126,7 @@ const struct inode_operations jfs_file_i
5864  #ifdef CONFIG_JFS_POSIX_ACL
5865         .check_acl      = jfs_check_acl,
5866  #endif
5867 +       .sync_flags     = jfs_sync_flags,
5868  };
5869  
5870  const struct file_operations jfs_file_operations = {
5871 diff -NurpP --minimal linux-2.6.34/fs/jfs/ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/ioctl.c
5872 --- linux-2.6.34/fs/jfs/ioctl.c 2008-12-25 00:26:37.000000000 +0100
5873 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/ioctl.c    2010-05-18 18:11:22.000000000 +0200
5874 @@ -11,6 +11,7 @@
5875  #include <linux/mount.h>
5876  #include <linux/time.h>
5877  #include <linux/sched.h>
5878 +#include <linux/mount.h>
5879  #include <asm/current.h>
5880  #include <asm/uaccess.h>
5881  
5882 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
5883  }
5884  
5885  
5886 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
5887 +{
5888 +       inode->i_flags = flags;
5889 +       inode->i_vflags = vflags;
5890 +       jfs_get_inode_flags(JFS_IP(inode));
5891 +       inode->i_ctime = CURRENT_TIME_SEC;
5892 +       mark_inode_dirty(inode);
5893 +       return 0;
5894 +}
5895 +
5896  long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5897  {
5898         struct inode *inode = filp->f_dentry->d_inode;
5899 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
5900                 if (!S_ISDIR(inode->i_mode))
5901                         flags &= ~JFS_DIRSYNC_FL;
5902  
5903 +               if (IS_BARRIER(inode)) {
5904 +                       vxwprintk_task(1, "messing with the barrier.");
5905 +                       return -EACCES;
5906 +               }
5907 +
5908                 /* Is it quota file? Do not allow user to mess with it */
5909                 if (IS_NOQUOTA(inode)) {
5910                         err = -EPERM;
5911 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
5912                  * the relevant capability.
5913                  */
5914                 if ((oldflags & JFS_IMMUTABLE_FL) ||
5915 -                       ((flags ^ oldflags) &
5916 -                       (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5917 +                       ((flags ^ oldflags) & (JFS_APPEND_FL |
5918 +                       JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
5919                         if (!capable(CAP_LINUX_IMMUTABLE)) {
5920                                 mutex_unlock(&inode->i_mutex);
5921                                 err = -EPERM;
5922 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
5923                         }
5924                 }
5925  
5926 -               flags = flags & JFS_FL_USER_MODIFIABLE;
5927 +               flags &= JFS_FL_USER_MODIFIABLE;
5928                 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
5929                 jfs_inode->mode2 = flags;
5930  
5931 diff -NurpP --minimal linux-2.6.34/fs/jfs/jfs_dinode.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/jfs_dinode.h
5932 --- linux-2.6.34/fs/jfs/jfs_dinode.h    2008-12-25 00:26:37.000000000 +0100
5933 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/jfs_dinode.h       2010-05-18 18:11:22.000000000 +0200
5934 @@ -161,9 +161,13 @@ struct dinode {
5935  
5936  #define JFS_APPEND_FL          0x01000000 /* writes to file may only append */
5937  #define JFS_IMMUTABLE_FL       0x02000000 /* Immutable file */
5938 +#define JFS_IXUNLINK_FL                0x08000000 /* Immutable invert on unlink */
5939  
5940 -#define JFS_FL_USER_VISIBLE    0x03F80000
5941 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
5942 +#define JFS_BARRIER_FL         0x04000000 /* Barrier for chroot() */
5943 +#define JFS_COW_FL             0x20000000 /* Copy on Write marker */
5944 +
5945 +#define JFS_FL_USER_VISIBLE    0x07F80000
5946 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
5947  #define JFS_FL_INHERIT         0x03C80000
5948  
5949  /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5950 diff -NurpP --minimal linux-2.6.34/fs/jfs/jfs_filsys.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/jfs_filsys.h
5951 --- linux-2.6.34/fs/jfs/jfs_filsys.h    2008-12-25 00:26:37.000000000 +0100
5952 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/jfs_filsys.h       2010-05-18 18:11:22.000000000 +0200
5953 @@ -263,6 +263,7 @@
5954  #define JFS_NAME_MAX   255
5955  #define JFS_PATH_MAX   BPSIZE
5956  
5957 +#define JFS_TAGGED             0x00800000      /* Context Tagging */
5958  
5959  /*
5960   *     file system state (superblock state)
5961 diff -NurpP --minimal linux-2.6.34/fs/jfs/jfs_imap.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/jfs_imap.c
5962 --- linux-2.6.34/fs/jfs/jfs_imap.c      2010-05-18 15:07:52.000000000 +0200
5963 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/jfs_imap.c 2010-05-18 18:11:22.000000000 +0200
5964 @@ -46,6 +46,7 @@
5965  #include <linux/pagemap.h>
5966  #include <linux/quotaops.h>
5967  #include <linux/slab.h>
5968 +#include <linux/vs_tag.h>
5969  
5970  #include "jfs_incore.h"
5971  #include "jfs_inode.h"
5972 @@ -3060,6 +3061,8 @@ static int copy_from_dinode(struct dinod
5973  {
5974         struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5975         struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5976 +       uid_t uid;
5977 +       gid_t gid;
5978  
5979         jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5980         jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5981 @@ -3080,14 +3083,18 @@ static int copy_from_dinode(struct dinod
5982         }
5983         ip->i_nlink = le32_to_cpu(dip->di_nlink);
5984  
5985 -       jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
5986 +       uid = le32_to_cpu(dip->di_uid);
5987 +       gid = le32_to_cpu(dip->di_gid);
5988 +       ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
5989 +
5990 +       jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
5991         if (sbi->uid == -1)
5992                 ip->i_uid = jfs_ip->saved_uid;
5993         else {
5994                 ip->i_uid = sbi->uid;
5995         }
5996  
5997 -       jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
5998 +       jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
5999         if (sbi->gid == -1)
6000                 ip->i_gid = jfs_ip->saved_gid;
6001         else {
6002 @@ -3152,14 +3159,12 @@ static void copy_to_dinode(struct dinode
6003         dip->di_size = cpu_to_le64(ip->i_size);
6004         dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
6005         dip->di_nlink = cpu_to_le32(ip->i_nlink);
6006 -       if (sbi->uid == -1)
6007 -               dip->di_uid = cpu_to_le32(ip->i_uid);
6008 -       else
6009 -               dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
6010 -       if (sbi->gid == -1)
6011 -               dip->di_gid = cpu_to_le32(ip->i_gid);
6012 -       else
6013 -               dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
6014 +
6015 +       dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
6016 +               (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
6017 +       dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
6018 +               (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
6019 +
6020         jfs_get_inode_flags(jfs_ip);
6021         /*
6022          * mode2 is only needed for storing the higher order bits.
6023 diff -NurpP --minimal linux-2.6.34/fs/jfs/jfs_inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/jfs_inode.c
6024 --- linux-2.6.34/fs/jfs/jfs_inode.c     2010-05-18 15:07:52.000000000 +0200
6025 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/jfs_inode.c        2010-05-18 18:11:22.000000000 +0200
6026 @@ -18,6 +18,7 @@
6027  
6028  #include <linux/fs.h>
6029  #include <linux/quotaops.h>
6030 +#include <linux/vs_tag.h>
6031  #include "jfs_incore.h"
6032  #include "jfs_inode.h"
6033  #include "jfs_filsys.h"
6034 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
6035  {
6036         unsigned int flags = JFS_IP(inode)->mode2;
6037  
6038 -       inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
6039 -               S_NOATIME | S_DIRSYNC | S_SYNC);
6040 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6041 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6042  
6043         if (flags & JFS_IMMUTABLE_FL)
6044                 inode->i_flags |= S_IMMUTABLE;
6045 +       if (flags & JFS_IXUNLINK_FL)
6046 +               inode->i_flags |= S_IXUNLINK;
6047 +
6048 +       if (flags & JFS_SYNC_FL)
6049 +               inode->i_flags |= S_SYNC;
6050         if (flags & JFS_APPEND_FL)
6051                 inode->i_flags |= S_APPEND;
6052         if (flags & JFS_NOATIME_FL)
6053                 inode->i_flags |= S_NOATIME;
6054         if (flags & JFS_DIRSYNC_FL)
6055                 inode->i_flags |= S_DIRSYNC;
6056 -       if (flags & JFS_SYNC_FL)
6057 -               inode->i_flags |= S_SYNC;
6058 +
6059 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
6060 +
6061 +       if (flags & JFS_BARRIER_FL)
6062 +               inode->i_vflags |= V_BARRIER;
6063 +       if (flags & JFS_COW_FL)
6064 +               inode->i_vflags |= V_COW;
6065  }
6066  
6067  void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
6068  {
6069         unsigned int flags = jfs_ip->vfs_inode.i_flags;
6070 +       unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
6071 +
6072 +       jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
6073 +                          JFS_APPEND_FL | JFS_NOATIME_FL |
6074 +                          JFS_DIRSYNC_FL | JFS_SYNC_FL |
6075 +                          JFS_BARRIER_FL | JFS_COW_FL);
6076  
6077 -       jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
6078 -                          JFS_DIRSYNC_FL | JFS_SYNC_FL);
6079         if (flags & S_IMMUTABLE)
6080                 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
6081 +       if (flags & S_IXUNLINK)
6082 +               jfs_ip->mode2 |= JFS_IXUNLINK_FL;
6083 +
6084         if (flags & S_APPEND)
6085                 jfs_ip->mode2 |= JFS_APPEND_FL;
6086         if (flags & S_NOATIME)
6087 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
6088                 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
6089         if (flags & S_SYNC)
6090                 jfs_ip->mode2 |= JFS_SYNC_FL;
6091 +
6092 +       if (vflags & V_BARRIER)
6093 +               jfs_ip->mode2 |= JFS_BARRIER_FL;
6094 +       if (vflags & V_COW)
6095 +               jfs_ip->mode2 |= JFS_COW_FL;
6096  }
6097  
6098  /*
6099 @@ -105,6 +128,7 @@ struct inode *ialloc(struct inode *paren
6100                         mode |= S_ISGID;
6101         } else
6102                 inode->i_gid = current_fsgid();
6103 +       inode->i_tag = dx_current_fstag(sb);
6104  
6105         /*
6106          * New inodes need to save sane values on disk when
6107 diff -NurpP --minimal linux-2.6.34/fs/jfs/jfs_inode.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/jfs_inode.h
6108 --- linux-2.6.34/fs/jfs/jfs_inode.h     2010-05-18 15:07:52.000000000 +0200
6109 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/jfs_inode.h        2010-05-18 18:11:22.000000000 +0200
6110 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
6111  extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
6112         int fh_len, int fh_type);
6113  extern void jfs_set_inode_flags(struct inode *);
6114 +extern int jfs_sync_flags(struct inode *, int, int);
6115  extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
6116  extern int jfs_setattr(struct dentry *, struct iattr *);
6117  
6118 diff -NurpP --minimal linux-2.6.34/fs/jfs/namei.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/namei.c
6119 --- linux-2.6.34/fs/jfs/namei.c 2010-05-18 15:07:52.000000000 +0200
6120 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/namei.c    2010-05-18 18:11:22.000000000 +0200
6121 @@ -21,6 +21,7 @@
6122  #include <linux/ctype.h>
6123  #include <linux/quotaops.h>
6124  #include <linux/exportfs.h>
6125 +#include <linux/vs_tag.h>
6126  #include "jfs_incore.h"
6127  #include "jfs_superblock.h"
6128  #include "jfs_inode.h"
6129 @@ -1491,6 +1492,7 @@ static struct dentry *jfs_lookup(struct 
6130                 return ERR_CAST(ip);
6131         }
6132  
6133 +       dx_propagate_tag(nd, ip);
6134         dentry = d_splice_alias(ip, dentry);
6135  
6136         if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
6137 @@ -1560,6 +1562,7 @@ const struct inode_operations jfs_dir_in
6138  #ifdef CONFIG_JFS_POSIX_ACL
6139         .check_acl      = jfs_check_acl,
6140  #endif
6141 +       .sync_flags     = jfs_sync_flags,
6142  };
6143  
6144  const struct file_operations jfs_dir_operations = {
6145 diff -NurpP --minimal linux-2.6.34/fs/jfs/super.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/super.c
6146 --- linux-2.6.34/fs/jfs/super.c 2010-05-18 15:07:52.000000000 +0200
6147 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/jfs/super.c    2010-05-18 18:11:22.000000000 +0200
6148 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
6149  enum {
6150         Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
6151         Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
6152 -       Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
6153 +       Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
6154 +       Opt_tag, Opt_notag, Opt_tagid
6155  };
6156  
6157  static const match_table_t tokens = {
6158 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
6159         {Opt_resize, "resize=%u"},
6160         {Opt_resize_nosize, "resize"},
6161         {Opt_errors, "errors=%s"},
6162 +       {Opt_tag, "tag"},
6163 +       {Opt_notag, "notag"},
6164 +       {Opt_tagid, "tagid=%u"},
6165 +       {Opt_tag, "tagxid"},
6166         {Opt_ignore, "noquota"},
6167         {Opt_ignore, "quota"},
6168         {Opt_usrquota, "usrquota"},
6169 @@ -342,6 +347,20 @@ static int parse_options(char *options, 
6170                         }
6171                         break;
6172                 }
6173 +#ifndef CONFIG_TAGGING_NONE
6174 +               case Opt_tag:
6175 +                       *flag |= JFS_TAGGED;
6176 +                       break;
6177 +               case Opt_notag:
6178 +                       *flag &= JFS_TAGGED;
6179 +                       break;
6180 +#endif
6181 +#ifdef CONFIG_PROPAGATE
6182 +               case Opt_tagid:
6183 +                       /* use args[0] */
6184 +                       *flag |= JFS_TAGGED;
6185 +                       break;
6186 +#endif
6187                 default:
6188                         printk("jfs: Unrecognized mount option \"%s\" "
6189                                         " or missing value\n", p);
6190 @@ -372,6 +391,12 @@ static int jfs_remount(struct super_bloc
6191         if (!parse_options(data, sb, &newLVSize, &flag)) {
6192                 return -EINVAL;
6193         }
6194 +       if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
6195 +               printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
6196 +                       sb->s_id);
6197 +               return -EINVAL;
6198 +       }
6199 +
6200         lock_kernel();
6201         if (newLVSize) {
6202                 if (sb->s_flags & MS_RDONLY) {
6203 @@ -453,6 +478,9 @@ static int jfs_fill_super(struct super_b
6204  #ifdef CONFIG_JFS_POSIX_ACL
6205         sb->s_flags |= MS_POSIXACL;
6206  #endif
6207 +       /* map mount option tagxid */
6208 +       if (sbi->flag & JFS_TAGGED)
6209 +               sb->s_flags |= MS_TAGGED;
6210  
6211         if (newLVSize) {
6212                 printk(KERN_ERR "resize option for remount only\n");
6213 diff -NurpP --minimal linux-2.6.34/fs/libfs.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/libfs.c
6214 --- linux-2.6.34/fs/libfs.c     2010-05-18 15:07:52.000000000 +0200
6215 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/libfs.c        2010-05-18 18:11:22.000000000 +0200
6216 @@ -128,7 +128,8 @@ static inline unsigned char dt_type(stru
6217   * both impossible due to the lock on directory.
6218   */
6219  
6220 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6221 +static inline int do_dcache_readdir_filter(struct file *filp,
6222 +       void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6223  {
6224         struct dentry *dentry = filp->f_path.dentry;
6225         struct dentry *cursor = filp->private_data;
6226 @@ -161,6 +162,8 @@ int dcache_readdir(struct file * filp, v
6227                                 next = list_entry(p, struct dentry, d_u.d_child);
6228                                 if (d_unhashed(next) || !next->d_inode)
6229                                         continue;
6230 +                               if (filter && !filter(next))
6231 +                                       continue;
6232  
6233                                 spin_unlock(&dcache_lock);
6234                                 if (filldir(dirent, next->d_name.name, 
6235 @@ -179,6 +182,18 @@ int dcache_readdir(struct file * filp, v
6236         return 0;
6237  }
6238  
6239 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6240 +{
6241 +       return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6242 +}
6243 +
6244 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6245 +       int (*filter)(struct dentry *))
6246 +{
6247 +       return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6248 +}
6249 +
6250 +
6251  ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6252  {
6253         return -EISDIR;
6254 @@ -844,6 +859,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6255  EXPORT_SYMBOL(dcache_dir_lseek);
6256  EXPORT_SYMBOL(dcache_dir_open);
6257  EXPORT_SYMBOL(dcache_readdir);
6258 +EXPORT_SYMBOL(dcache_readdir_filter);
6259  EXPORT_SYMBOL(generic_read_dir);
6260  EXPORT_SYMBOL(get_sb_pseudo);
6261  EXPORT_SYMBOL(simple_write_begin);
6262 diff -NurpP --minimal linux-2.6.34/fs/locks.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/locks.c
6263 --- linux-2.6.34/fs/locks.c     2010-05-18 15:07:52.000000000 +0200
6264 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/locks.c        2010-05-18 18:11:22.000000000 +0200
6265 @@ -127,6 +127,8 @@
6266  #include <linux/time.h>
6267  #include <linux/rcupdate.h>
6268  #include <linux/pid_namespace.h>
6269 +#include <linux/vs_base.h>
6270 +#include <linux/vs_limit.h>
6271  
6272  #include <asm/uaccess.h>
6273  
6274 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
6275  /* Allocate an empty lock structure. */
6276  static struct file_lock *locks_alloc_lock(void)
6277  {
6278 +       if (!vx_locks_avail(1))
6279 +               return NULL;
6280         return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6281  }
6282  
6283 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
6284         BUG_ON(!list_empty(&fl->fl_block));
6285         BUG_ON(!list_empty(&fl->fl_link));
6286  
6287 +       vx_locks_dec(fl);
6288         locks_release_private(fl);
6289         kmem_cache_free(filelock_cache, fl);
6290  }
6291 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
6292         fl->fl_start = fl->fl_end = 0;
6293         fl->fl_ops = NULL;
6294         fl->fl_lmops = NULL;
6295 +       fl->fl_xid = -1;
6296  }
6297  
6298  EXPORT_SYMBOL(locks_init_lock);
6299 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
6300         new->fl_file = fl->fl_file;
6301         new->fl_ops = fl->fl_ops;
6302         new->fl_lmops = fl->fl_lmops;
6303 +       new->fl_xid = fl->fl_xid;
6304  
6305         locks_copy_private(new, fl);
6306  }
6307 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
6308         fl->fl_flags = FL_FLOCK;
6309         fl->fl_type = type;
6310         fl->fl_end = OFFSET_MAX;
6311 +
6312 +       vxd_assert(filp->f_xid == vx_current_xid(),
6313 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6314 +       fl->fl_xid = filp->f_xid;
6315 +       vx_locks_inc(fl);
6316         
6317         *lock = fl;
6318         return 0;
6319 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
6320  
6321         fl->fl_owner = current->files;
6322         fl->fl_pid = current->tgid;
6323 +       fl->fl_xid = vx_current_xid();
6324  
6325         fl->fl_file = filp;
6326         fl->fl_flags = FL_LEASE;
6327 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
6328         if (fl == NULL)
6329                 return ERR_PTR(error);
6330  
6331 +       fl->fl_xid = vx_current_xid();
6332 +       if (filp)
6333 +               vxd_assert(filp->f_xid == fl->fl_xid,
6334 +                       "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6335 +       vx_locks_inc(fl);
6336         error = lease_init(filp, type, fl);
6337         if (error) {
6338                 locks_free_lock(fl);
6339 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
6340         if (found)
6341                 cond_resched();
6342  
6343 +       new_fl->fl_xid = -1;
6344  find_conflict:
6345         for_each_lock(inode, before) {
6346                 struct file_lock *fl = *before;
6347 @@ -790,6 +809,7 @@ find_conflict:
6348                 goto out;
6349         locks_copy_lock(new_fl, request);
6350         locks_insert_lock(before, new_fl);
6351 +       vx_locks_inc(new_fl);
6352         new_fl = NULL;
6353         error = 0;
6354  
6355 @@ -800,7 +820,8 @@ out:
6356         return error;
6357  }
6358  
6359 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6360 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6361 +       struct file_lock *conflock, xid_t xid)
6362  {
6363         struct file_lock *fl;
6364         struct file_lock *new_fl = NULL;
6365 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
6366         struct file_lock **before;
6367         int error, added = 0;
6368  
6369 +       vxd_assert(xid == vx_current_xid(),
6370 +               "xid(%d) == current(%d)", xid, vx_current_xid());
6371         /*
6372          * We may need two file_lock structures for this operation,
6373          * so we get them in advance to avoid races.
6374 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
6375             (request->fl_type != F_UNLCK ||
6376              request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6377                 new_fl = locks_alloc_lock();
6378 +               new_fl->fl_xid = xid;
6379 +               vx_locks_inc(new_fl);
6380                 new_fl2 = locks_alloc_lock();
6381 +               new_fl2->fl_xid = xid;
6382 +               vx_locks_inc(new_fl2);
6383         }
6384  
6385         lock_kernel();
6386 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
6387  int posix_lock_file(struct file *filp, struct file_lock *fl,
6388                         struct file_lock *conflock)
6389  {
6390 -       return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6391 +       return __posix_lock_file(filp->f_path.dentry->d_inode,
6392 +               fl, conflock, filp->f_xid);
6393  }
6394  EXPORT_SYMBOL(posix_lock_file);
6395  
6396 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
6397         fl.fl_end = offset + count - 1;
6398  
6399         for (;;) {
6400 -               error = __posix_lock_file(inode, &fl, NULL);
6401 +               error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6402                 if (error != FILE_LOCK_DEFERRED)
6403                         break;
6404                 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
6405 @@ -1425,6 +1453,7 @@ int generic_setlease(struct file *filp, 
6406  
6407         locks_copy_lock(new_fl, lease);
6408         locks_insert_lock(before, new_fl);
6409 +       vx_locks_inc(new_fl);
6410  
6411         *flp = new_fl;
6412         return 0;
6413 @@ -1780,6 +1809,11 @@ int fcntl_setlk(unsigned int fd, struct 
6414         if (file_lock == NULL)
6415                 return -ENOLCK;
6416  
6417 +       vxd_assert(filp->f_xid == vx_current_xid(),
6418 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6419 +       file_lock->fl_xid = filp->f_xid;
6420 +       vx_locks_inc(file_lock);
6421 +
6422         /*
6423          * This might block, so we do it before checking the inode.
6424          */
6425 @@ -1898,6 +1932,11 @@ int fcntl_setlk64(unsigned int fd, struc
6426         if (file_lock == NULL)
6427                 return -ENOLCK;
6428  
6429 +       vxd_assert(filp->f_xid == vx_current_xid(),
6430 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6431 +       file_lock->fl_xid = filp->f_xid;
6432 +       vx_locks_inc(file_lock);
6433 +
6434         /*
6435          * This might block, so we do it before checking the inode.
6436          */
6437 @@ -2163,8 +2202,11 @@ static int locks_show(struct seq_file *f
6438  
6439         lock_get_status(f, fl, (long)f->private, "");
6440  
6441 -       list_for_each_entry(bfl, &fl->fl_block, fl_block)
6442 +       list_for_each_entry(bfl, &fl->fl_block, fl_block) {
6443 +               if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6444 +                       continue;
6445                 lock_get_status(f, bfl, (long)f->private, " ->");
6446 +       }
6447  
6448         f->private++;
6449         return 0;
6450 diff -NurpP --minimal linux-2.6.34/fs/namei.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/namei.c
6451 --- linux-2.6.34/fs/namei.c     2010-05-18 15:07:52.000000000 +0200
6452 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/namei.c        2010-05-21 14:17:04.000000000 +0200
6453 @@ -32,6 +32,14 @@
6454  #include <linux/fcntl.h>
6455  #include <linux/device_cgroup.h>
6456  #include <linux/fs_struct.h>
6457 +#include <linux/proc_fs.h>
6458 +#include <linux/vserver/inode.h>
6459 +#include <linux/vs_base.h>
6460 +#include <linux/vs_tag.h>
6461 +#include <linux/vs_cowbl.h>
6462 +#include <linux/vs_device.h>
6463 +#include <linux/vs_context.h>
6464 +#include <linux/pid_namespace.h>
6465  #include <asm/uaccess.h>
6466  
6467  #include "internal.h"
6468 @@ -166,6 +174,77 @@ void putname(const char *name)
6469  EXPORT_SYMBOL(putname);
6470  #endif
6471  
6472 +static inline int dx_barrier(const struct inode *inode)
6473 +{
6474 +       if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
6475 +               vxwprintk_task(1, "did hit the barrier.");
6476 +               return 1;
6477 +       }
6478 +       return 0;
6479 +}
6480 +
6481 +static int __dx_permission(const struct inode *inode, int mask)
6482 +{
6483 +       if (dx_barrier(inode))
6484 +               return -EACCES;
6485 +
6486 +       if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6487 +               /* devpts is xid tagged */
6488 +               if (S_ISDIR(inode->i_mode) ||
6489 +                   vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
6490 +                       return 0;
6491 +       }
6492 +       else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6493 +               struct proc_dir_entry *de = PDE(inode);
6494 +
6495 +               if (de && !vx_hide_check(0, de->vx_flags))
6496 +                       goto out;
6497 +
6498 +               if ((mask & (MAY_WRITE | MAY_APPEND))) {
6499 +                       struct pid *pid;
6500 +                       struct task_struct *tsk;
6501 +
6502 +                       if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
6503 +                           vx_flags(VXF_STATE_SETUP, 0))
6504 +                               return 0;
6505 +
6506 +                       pid = PROC_I(inode)->pid;
6507 +                       if (!pid)
6508 +                               goto out;
6509 +
6510 +                       tsk = pid_task(pid, PIDTYPE_PID);
6511 +                       vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
6512 +                                 tsk, (tsk ? vx_task_xid(tsk) : 0));
6513 +                       if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
6514 +                               return 0;
6515 +               }
6516 +               else {
6517 +                       /* FIXME: Should we block some entries here? */
6518 +                       return 0;
6519 +               }
6520 +       }
6521 +       else {
6522 +               if (dx_notagcheck(inode->i_sb) ||
6523 +                   dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
6524 +                            DX_IDENT))
6525 +                       return 0;
6526 +       }
6527 +
6528 +out:
6529 +       return -EACCES;
6530 +}
6531 +
6532 +int dx_permission(const struct inode *inode, int mask)
6533 +{
6534 +       int ret = __dx_permission(inode, mask);
6535 +       if (unlikely(ret)) {
6536 +               vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
6537 +                       mask, inode->i_sb->s_id, inode, inode->i_tag,
6538 +                       inode->i_ino);
6539 +       }
6540 +       return ret;
6541 +}
6542 +
6543  /*
6544   * This does basic POSIX ACL permission checking
6545   */
6546 @@ -266,10 +345,14 @@ int inode_permission(struct inode *inode
6547                 /*
6548                  * Nobody gets write access to an immutable file.
6549                  */
6550 -               if (IS_IMMUTABLE(inode))
6551 +               if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6552                         return -EACCES;
6553         }
6554  
6555 +       retval = dx_permission(inode, mask);
6556 +       if (retval)
6557 +               return retval;
6558 +
6559         if (inode->i_op->permission)
6560                 retval = inode->i_op->permission(inode, mask);
6561         else
6562 @@ -464,6 +547,9 @@ static int exec_permission(struct inode 
6563  {
6564         int ret;
6565  
6566 +       if (dx_barrier(inode))
6567 +               return -EACCES;
6568 +
6569         if (inode->i_op->permission) {
6570                 ret = inode->i_op->permission(inode, MAY_EXEC);
6571                 if (!ret)
6572 @@ -676,7 +762,8 @@ static __always_inline void follow_dotdo
6573  
6574                 if (nd->path.dentry == nd->root.dentry &&
6575                     nd->path.mnt == nd->root.mnt) {
6576 -                       break;
6577 +                       /* for sane '/' avoid follow_mount() */
6578 +                       return;
6579                 }
6580                 if (nd->path.dentry != nd->path.mnt->mnt_root) {
6581                         /* rare case of legitimate dget_parent()... */
6582 @@ -700,7 +787,7 @@ static int do_lookup(struct nameidata *n
6583  {
6584         struct vfsmount *mnt = nd->path.mnt;
6585         struct dentry *dentry, *parent;
6586 -       struct inode *dir;
6587 +       struct inode *dir, *inode;
6588         /*
6589          * See if the low-level filesystem might want
6590          * to use its own hash..
6591 @@ -716,12 +803,26 @@ static int do_lookup(struct nameidata *n
6592                 goto need_lookup;
6593         if (dentry->d_op && dentry->d_op->d_revalidate)
6594                 goto need_revalidate;
6595 +
6596 +       inode = dentry->d_inode;
6597 +       if (!inode)
6598 +               goto done;
6599 +
6600 +       if (__dx_permission(inode, MAY_ACCESS))
6601 +               goto hidden;
6602  done:
6603         path->mnt = mnt;
6604         path->dentry = dentry;
6605         __follow_mount(path);
6606         return 0;
6607  
6608 +hidden:
6609 +       vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] Â»%s/%.*s«.",
6610 +               inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
6611 +               vxd_path(&nd->path), name->len, name->name);
6612 +       dput(dentry);
6613 +       return -ENOENT;
6614 +
6615  need_lookup:
6616         parent = nd->path.dentry;
6617         dir = parent->d_inode;
6618 @@ -1325,7 +1426,7 @@ static int may_delete(struct inode *dir,
6619         if (IS_APPEND(dir))
6620                 return -EPERM;
6621         if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6622 -           IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6623 +               IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6624                 return -EPERM;
6625         if (isdir) {
6626                 if (!S_ISDIR(victim->d_inode->i_mode))
6627 @@ -1448,6 +1549,14 @@ int may_open(struct path *path, int acc_
6628                 break;
6629         }
6630  
6631 +#ifdef CONFIG_VSERVER_COWBL
6632 +       if (IS_COW(inode) && (flag & FMODE_WRITE)) {
6633 +               if (IS_COW_LINK(inode))
6634 +                       return -EMLINK;
6635 +               inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
6636 +               mark_inode_dirty(inode);
6637 +       }
6638 +#endif
6639         error = inode_permission(inode, acc_mode);
6640         if (error)
6641                 return error;
6642 @@ -1557,7 +1666,8 @@ static int open_will_truncate(int flag, 
6643  }
6644  
6645  static struct file *finish_open(struct nameidata *nd,
6646 -                               int open_flag, int acc_mode)
6647 +                               int open_flag, int acc_mode,
6648 +                               const char *pathname)
6649  {
6650         struct file *filp;
6651         int will_truncate;
6652 @@ -1570,6 +1680,23 @@ static struct file *finish_open(struct n
6653                         goto exit;
6654         }
6655         error = may_open(&nd->path, acc_mode, open_flag);
6656 +#ifdef CONFIG_VSERVER_COWBL
6657 +       if (error == -EMLINK) {
6658 +               struct dentry *dentry;
6659 +               dentry = cow_break_link(pathname);
6660 +               if (IS_ERR(dentry)) {
6661 +                       error = PTR_ERR(dentry);
6662 +                       goto exit_cow;
6663 +               }
6664 +               dput(dentry);
6665 +               if (will_truncate)
6666 +                       mnt_drop_write(nd->path.mnt);
6667 +               release_open_intent(nd);
6668 +               path_put(&nd->path);
6669 +               return ERR_PTR(-EMLINK);
6670 +       }
6671 +exit_cow:
6672 +#endif
6673         if (error) {
6674                 if (will_truncate)
6675                         mnt_drop_write(nd->path.mnt);
6676 @@ -1738,7 +1865,7 @@ static struct file *do_last(struct namei
6677         if (S_ISDIR(path->dentry->d_inode->i_mode))
6678                 goto exit;
6679  ok:
6680 -       filp = finish_open(nd, open_flag, acc_mode);
6681 +       filp = finish_open(nd, open_flag, acc_mode, pathname);
6682         return filp;
6683  
6684  exit_mutex_unlock:
6685 @@ -1767,7 +1894,11 @@ struct file *do_filp_open(int dfd, const
6686         int count = 0;
6687         int flag = open_to_namei_flags(open_flag);
6688         int force_reval = 0;
6689 -
6690 +#ifdef CONFIG_VSERVER_COWBL
6691 +       int rflag = flag;
6692 +       int rmode = mode;
6693 +restart:
6694 +#endif
6695         if (!(open_flag & O_CREAT))
6696                 mode = 0;
6697  
6698 @@ -1833,6 +1964,13 @@ reval:
6699         if (!(open_flag & O_NOFOLLOW))
6700                 nd.flags |= LOOKUP_FOLLOW;
6701         filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
6702 +#ifdef CONFIG_VSERVER_COWBL
6703 +       if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
6704 +               flag = rflag;
6705 +               mode = rmode;
6706 +               goto restart;
6707 +       }
6708 +#endif
6709         while (unlikely(!filp)) { /* trailing symlink */
6710                 struct path holder;
6711                 struct inode *inode = path.dentry->d_inode;
6712 @@ -1871,6 +2009,13 @@ reval:
6713                 holder = path;
6714                 nd.flags &= ~LOOKUP_PARENT;
6715                 filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
6716 +#ifdef CONFIG_VSERVER_COWBL
6717 +               if (unlikely(IS_ERR(filp) && PTR_ERR(filp) == -EMLINK)) {
6718 +                       flag = rflag;
6719 +                       mode = rmode;
6720 +                       goto restart;
6721 +               }
6722 +#endif
6723                 if (inode->i_op->put_link)
6724                         inode->i_op->put_link(holder.dentry, &nd, cookie);
6725                 path_put(&holder);
6726 @@ -1971,9 +2116,17 @@ int vfs_mknod(struct inode *dir, struct 
6727         if (error)
6728                 return error;
6729  
6730 -       if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
6731 +       if (!(S_ISCHR(mode) || S_ISBLK(mode)))
6732 +               goto okay;
6733 +
6734 +       if (!capable(CAP_MKNOD))
6735                 return -EPERM;
6736  
6737 +       if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
6738 +               return -EPERM;
6739 +       if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
6740 +               return -EPERM;
6741 +okay:
6742         if (!dir->i_op->mknod)
6743                 return -EPERM;
6744  
6745 @@ -2438,7 +2591,7 @@ int vfs_link(struct dentry *old_dentry, 
6746         /*
6747          * A link to an append-only or immutable file cannot be created.
6748          */
6749 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6750 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6751                 return -EPERM;
6752         if (!dir->i_op->link)
6753                 return -EPERM;
6754 @@ -2810,6 +2963,219 @@ int vfs_follow_link(struct nameidata *nd
6755         return __vfs_follow_link(nd, link);
6756  }
6757  
6758 +
6759 +#ifdef CONFIG_VSERVER_COWBL
6760 +
6761 +#include <linux/file.h>
6762 +
6763 +static inline
6764 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6765 +{
6766 +       loff_t ppos = 0;
6767 +
6768 +       return do_splice_direct(in, &ppos, out, len, 0);
6769 +}
6770 +
6771 +struct dentry *cow_break_link(const char *pathname)
6772 +{
6773 +       int ret, mode, pathlen, redo = 0;
6774 +       struct nameidata old_nd, dir_nd;
6775 +       struct path old_path, new_path;
6776 +       struct dentry *dir, *res = NULL;
6777 +       struct file *old_file;
6778 +       struct file *new_file;
6779 +       char *to, *path, pad='\251';
6780 +       loff_t size;
6781 +
6782 +       vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6783 +       path = kmalloc(PATH_MAX, GFP_KERNEL);
6784 +       ret = -ENOMEM;
6785 +       if (!path)
6786 +               goto out;
6787 +
6788 +       /* old_nd will have refs to dentry and mnt */
6789 +       ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6790 +       vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6791 +       if (ret < 0)
6792 +               goto out_free_path;
6793 +
6794 +       old_path = old_nd.path;
6795 +       mode = old_path.dentry->d_inode->i_mode;
6796 +
6797 +       to = d_path(&old_path, path, PATH_MAX-2);
6798 +       pathlen = strlen(to);
6799 +       vxdprintk(VXD_CBIT(misc, 2), "old path Â»%s« [»%.*s«:%d]", to,
6800 +               old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6801 +               old_path.dentry->d_name.len);
6802 +
6803 +       to[pathlen + 1] = 0;
6804 +retry:
6805 +       to[pathlen] = pad--;
6806 +       ret = -EMLINK;
6807 +       if (pad <= '\240')
6808 +               goto out_rel_old;
6809 +
6810 +       vxdprintk(VXD_CBIT(misc, 1), "temp copy Â»%s«", to);
6811 +       /* dir_nd will have refs to dentry and mnt */
6812 +       ret = path_lookup(to,
6813 +               LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6814 +       vxdprintk(VXD_CBIT(misc, 2),
6815 +               "path_lookup(new): %d", ret);
6816 +       if (ret < 0)
6817 +               goto retry;
6818 +
6819 +       /* this puppy downs the inode mutex */
6820 +       new_path.dentry = lookup_create(&dir_nd, 0);
6821 +       if (!new_path.dentry || IS_ERR(new_path.dentry)) {
6822 +               vxdprintk(VXD_CBIT(misc, 2),
6823 +                       "lookup_create(new): %p", new_path.dentry);
6824 +               mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
6825 +               path_put(&dir_nd.path);
6826 +               goto retry;
6827 +       }
6828 +       vxdprintk(VXD_CBIT(misc, 2),
6829 +               "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
6830 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6831 +               new_path.dentry->d_name.len);
6832 +       dir = dir_nd.path.dentry;
6833 +
6834 +       ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
6835 +       vxdprintk(VXD_CBIT(misc, 2),
6836 +               "vfs_create(new): %d", ret);
6837 +       if (ret == -EEXIST) {
6838 +               mutex_unlock(&dir->d_inode->i_mutex);
6839 +               dput(new_path.dentry);
6840 +               path_put(&dir_nd.path);
6841 +               goto retry;
6842 +       }
6843 +       else if (ret < 0)
6844 +               goto out_unlock_new;
6845 +
6846 +       /* drop out early, ret passes ENOENT */
6847 +       ret = -ENOENT;
6848 +       if ((redo = d_unhashed(old_path.dentry)))
6849 +               goto out_unlock_new;
6850 +
6851 +       new_path.mnt = dir_nd.path.mnt;
6852 +       dget(old_path.dentry);
6853 +       mntget(old_path.mnt);
6854 +       /* this one cleans up the dentry/mnt in case of failure */
6855 +       old_file = dentry_open(old_path.dentry, old_path.mnt,
6856 +               O_RDONLY, current_cred());
6857 +       vxdprintk(VXD_CBIT(misc, 2),
6858 +               "dentry_open(old): %p", old_file);
6859 +       if (!old_file || IS_ERR(old_file)) {
6860 +               res = IS_ERR(old_file) ? (void *) old_file : res;
6861 +               goto out_unlock_new;
6862 +       }
6863 +
6864 +       dget(new_path.dentry);
6865 +       mntget(new_path.mnt);
6866 +       /* this one cleans up the dentry/mnt in case of failure */
6867 +       new_file = dentry_open(new_path.dentry, new_path.mnt,
6868 +               O_WRONLY, current_cred());
6869 +       vxdprintk(VXD_CBIT(misc, 2),
6870 +               "dentry_open(new): %p", new_file);
6871 +
6872 +       ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
6873 +       if (!new_file || IS_ERR(new_file))
6874 +               goto out_fput_old;
6875 +
6876 +       size = i_size_read(old_file->f_dentry->d_inode);
6877 +       ret = do_cow_splice(old_file, new_file, size);
6878 +       vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
6879 +       if (ret < 0) {
6880 +               goto out_fput_both;
6881 +       } else if (ret < size) {
6882 +               ret = -ENOSPC;
6883 +               goto out_fput_both;
6884 +       } else {
6885 +               struct inode *old_inode = old_path.dentry->d_inode;
6886 +               struct inode *new_inode = new_path.dentry->d_inode;
6887 +               struct iattr attr = {
6888 +                       .ia_uid = old_inode->i_uid,
6889 +                       .ia_gid = old_inode->i_gid,
6890 +                       .ia_valid = ATTR_UID | ATTR_GID
6891 +                       };
6892 +
6893 +               ret = inode_setattr(new_inode, &attr);
6894 +               if (ret)
6895 +                       goto out_fput_both;
6896 +       }
6897 +
6898 +       mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6899 +
6900 +       /* drop out late */
6901 +       ret = -ENOENT;
6902 +       if ((redo = d_unhashed(old_path.dentry)))
6903 +               goto out_unlock;
6904 +
6905 +       vxdprintk(VXD_CBIT(misc, 2),
6906 +               "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
6907 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6908 +               new_path.dentry->d_name.len,
6909 +               old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6910 +               old_path.dentry->d_name.len);
6911 +       ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
6912 +               old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
6913 +       vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
6914 +       res = new_path.dentry;
6915 +
6916 +out_unlock:
6917 +       mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6918 +
6919 +out_fput_both:
6920 +       vxdprintk(VXD_CBIT(misc, 3),
6921 +               "fput(new_file=%p[#%ld])", new_file,
6922 +               atomic_long_read(&new_file->f_count));
6923 +       fput(new_file);
6924 +
6925 +out_fput_old:
6926 +       vxdprintk(VXD_CBIT(misc, 3),
6927 +               "fput(old_file=%p[#%ld])", old_file,
6928 +               atomic_long_read(&old_file->f_count));
6929 +       fput(old_file);
6930 +
6931 +out_unlock_new:
6932 +       mutex_unlock(&dir->d_inode->i_mutex);
6933 +       if (!ret)
6934 +               goto out_redo;
6935 +
6936 +       /* error path cleanup */
6937 +       vfs_unlink(dir->d_inode, new_path.dentry);
6938 +       dput(new_path.dentry);
6939 +
6940 +out_redo:
6941 +       if (!redo)
6942 +               goto out_rel_both;
6943 +       /* lookup dentry once again */
6944 +       path_put(&old_nd.path);
6945 +       ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6946 +       if (ret)
6947 +               goto out_rel_both;
6948 +
6949 +       new_path.dentry = old_nd.path.dentry;
6950 +       vxdprintk(VXD_CBIT(misc, 2),
6951 +               "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
6952 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6953 +               new_path.dentry->d_name.len);
6954 +       dget(new_path.dentry);
6955 +       res = new_path.dentry;
6956 +
6957 +out_rel_both:
6958 +       path_put(&dir_nd.path);
6959 +out_rel_old:
6960 +       path_put(&old_nd.path);
6961 +out_free_path:
6962 +       kfree(path);
6963 +out:
6964 +       if (ret)
6965 +               res = ERR_PTR(ret);
6966 +       return res;
6967 +}
6968 +
6969 +#endif
6970 +
6971  /* get the link contents into pagecache */
6972  static char *page_getlink(struct dentry * dentry, struct page **ppage)
6973  {
6974 diff -NurpP --minimal linux-2.6.34/fs/namespace.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/namespace.c
6975 --- linux-2.6.34/fs/namespace.c 2010-05-18 15:07:52.000000000 +0200
6976 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/namespace.c    2010-05-18 18:11:22.000000000 +0200
6977 @@ -29,6 +29,11 @@
6978  #include <linux/log2.h>
6979  #include <linux/idr.h>
6980  #include <linux/fs_struct.h>
6981 +#include <linux/vs_base.h>
6982 +#include <linux/vs_context.h>
6983 +#include <linux/vs_tag.h>
6984 +#include <linux/vserver/space.h>
6985 +#include <linux/vserver/global.h>
6986  #include <asm/uaccess.h>
6987  #include <asm/unistd.h>
6988  #include "pnode.h"
6989 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
6990                 mnt->mnt_root = dget(root);
6991                 mnt->mnt_mountpoint = mnt->mnt_root;
6992                 mnt->mnt_parent = mnt;
6993 +               mnt->mnt_tag = old->mnt_tag;
6994  
6995                 if (flag & CL_SLAVE) {
6996                         list_add(&mnt->mnt_slave, &old->mnt_slave_list);
6997 @@ -661,6 +667,31 @@ static inline void mangle(struct seq_fil
6998         seq_escape(m, s, " \t\n\\");
6999  }
7000  
7001 +static int mnt_is_reachable(struct vfsmount *mnt)
7002 +{
7003 +       struct path root;
7004 +       struct dentry *point;
7005 +       int ret;
7006 +
7007 +       if (mnt == mnt->mnt_ns->root)
7008 +               return 1;
7009 +
7010 +       spin_lock(&vfsmount_lock);
7011 +       root = current->fs->root;
7012 +       point = root.dentry;
7013 +
7014 +       while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
7015 +               point = mnt->mnt_mountpoint;
7016 +               mnt = mnt->mnt_parent;
7017 +       }
7018 +
7019 +       ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
7020 +
7021 +       spin_unlock(&vfsmount_lock);
7022 +
7023 +       return ret;
7024 +}
7025 +
7026  /*
7027   * Simple .show_options callback for filesystems which don't want to
7028   * implement more complex mount option showing.
7029 @@ -763,6 +794,8 @@ static int show_sb_opts(struct seq_file 
7030                 { MS_SYNCHRONOUS, ",sync" },
7031                 { MS_DIRSYNC, ",dirsync" },
7032                 { MS_MANDLOCK, ",mand" },
7033 +               { MS_TAGGED, ",tag" },
7034 +               { MS_NOTAGCHECK, ",notagcheck" },
7035                 { 0, NULL }
7036         };
7037         const struct proc_fs_info *fs_infop;
7038 @@ -810,10 +843,20 @@ static int show_vfsmnt(struct seq_file *
7039         int err = 0;
7040         struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
7041  
7042 -       mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7043 -       seq_putc(m, ' ');
7044 -       seq_path(m, &mnt_path, " \t\n\\");
7045 -       seq_putc(m, ' ');
7046 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
7047 +               return SEQ_SKIP;
7048 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7049 +               return SEQ_SKIP;
7050 +
7051 +       if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7052 +               mnt == current->fs->root.mnt) {
7053 +               seq_puts(m, "/dev/root / ");
7054 +       } else {
7055 +               mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7056 +               seq_putc(m, ' ');
7057 +               seq_path(m, &mnt_path, " \t\n\\");
7058 +               seq_putc(m, ' ');
7059 +       }
7060         show_type(m, mnt->mnt_sb);
7061         seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
7062         err = show_sb_opts(m, mnt->mnt_sb);
7063 @@ -843,6 +886,11 @@ static int show_mountinfo(struct seq_fil
7064         struct path root = p->root;
7065         int err = 0;
7066  
7067 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
7068 +               return SEQ_SKIP;
7069 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7070 +               return SEQ_SKIP;
7071 +
7072         seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
7073                    MAJOR(sb->s_dev), MINOR(sb->s_dev));
7074         seq_dentry(m, mnt->mnt_root, " \t\n\\");
7075 @@ -901,17 +949,27 @@ static int show_vfsstat(struct seq_file 
7076         struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
7077         int err = 0;
7078  
7079 -       /* device */
7080 -       if (mnt->mnt_devname) {
7081 -               seq_puts(m, "device ");
7082 -               mangle(m, mnt->mnt_devname);
7083 -       } else
7084 -               seq_puts(m, "no device");
7085 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
7086 +               return SEQ_SKIP;
7087 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7088 +               return SEQ_SKIP;
7089  
7090 -       /* mount point */
7091 -       seq_puts(m, " mounted on ");
7092 -       seq_path(m, &mnt_path, " \t\n\\");
7093 -       seq_putc(m, ' ');
7094 +       if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7095 +               mnt == current->fs->root.mnt) {
7096 +               seq_puts(m, "device /dev/root mounted on / ");
7097 +       } else {
7098 +               /* device */
7099 +               if (mnt->mnt_devname) {
7100 +                       seq_puts(m, "device ");
7101 +                       mangle(m, mnt->mnt_devname);
7102 +               } else
7103 +                       seq_puts(m, "no device");
7104 +
7105 +               /* mount point */
7106 +               seq_puts(m, " mounted on ");
7107 +               seq_path(m, &mnt_path, " \t\n\\");
7108 +               seq_putc(m, ' ');
7109 +       }
7110  
7111         /* file system type */
7112         seq_puts(m, "with fstype ");
7113 @@ -1154,7 +1212,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
7114                 goto dput_and_out;
7115  
7116         retval = -EPERM;
7117 -       if (!capable(CAP_SYS_ADMIN))
7118 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7119                 goto dput_and_out;
7120  
7121         retval = do_umount(path.mnt, flags);
7122 @@ -1180,7 +1238,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
7123  
7124  static int mount_is_safe(struct path *path)
7125  {
7126 -       if (capable(CAP_SYS_ADMIN))
7127 +       if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7128                 return 0;
7129         return -EPERM;
7130  #ifdef notyet
7131 @@ -1459,7 +1517,7 @@ static int do_change_type(struct path *p
7132         int type = flag & ~MS_REC;
7133         int err = 0;
7134  
7135 -       if (!capable(CAP_SYS_ADMIN))
7136 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
7137                 return -EPERM;
7138  
7139         if (path->dentry != path->mnt->mnt_root)
7140 @@ -1486,11 +1544,13 @@ static int do_change_type(struct path *p
7141   * do loopback mount.
7142   */
7143  static int do_loopback(struct path *path, char *old_name,
7144 -                               int recurse)
7145 +       tag_t tag, unsigned long flags, int mnt_flags)
7146  {
7147         struct path old_path;
7148         struct vfsmount *mnt = NULL;
7149         int err = mount_is_safe(path);
7150 +       int recurse = flags & MS_REC;
7151 +
7152         if (err)
7153                 return err;
7154         if (!old_name || !*old_name)
7155 @@ -1524,6 +1584,7 @@ static int do_loopback(struct path *path
7156                 spin_unlock(&vfsmount_lock);
7157                 release_mounts(&umount_list);
7158         }
7159 +       mnt->mnt_flags = mnt_flags;
7160  
7161  out:
7162         up_write(&namespace_sem);
7163 @@ -1554,12 +1615,12 @@ static int change_mount_flags(struct vfs
7164   * on it - tough luck.
7165   */
7166  static int do_remount(struct path *path, int flags, int mnt_flags,
7167 -                     void *data)
7168 +       void *data, xid_t xid)
7169  {
7170         int err;
7171         struct super_block *sb = path->mnt->mnt_sb;
7172  
7173 -       if (!capable(CAP_SYS_ADMIN))
7174 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7175                 return -EPERM;
7176  
7177         if (!check_mnt(path->mnt))
7178 @@ -1605,7 +1666,7 @@ static int do_move_mount(struct path *pa
7179         struct path old_path, parent_path;
7180         struct vfsmount *p;
7181         int err = 0;
7182 -       if (!capable(CAP_SYS_ADMIN))
7183 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7184                 return -EPERM;
7185         if (!old_name || !*old_name)
7186                 return -EINVAL;
7187 @@ -1687,7 +1748,7 @@ static int do_new_mount(struct path *pat
7188                 return -EINVAL;
7189  
7190         /* we need capabilities... */
7191 -       if (!capable(CAP_SYS_ADMIN))
7192 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7193                 return -EPERM;
7194  
7195         lock_kernel();
7196 @@ -1953,6 +2014,7 @@ long do_mount(char *dev_name, char *dir_
7197         struct path path;
7198         int retval = 0;
7199         int mnt_flags = 0;
7200 +       tag_t tag = 0;
7201  
7202         /* Discard magic */
7203         if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7204 @@ -1980,6 +2042,12 @@ long do_mount(char *dev_name, char *dir_
7205         if (!(flags & MS_NOATIME))
7206                 mnt_flags |= MNT_RELATIME;
7207  
7208 +       if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
7209 +               /* FIXME: bind and re-mounts get the tag flag? */
7210 +               if (flags & (MS_BIND|MS_REMOUNT))
7211 +                       flags |= MS_TAGID;
7212 +       }
7213 +
7214         /* Separate the per-mountpoint flags */
7215         if (flags & MS_NOSUID)
7216                 mnt_flags |= MNT_NOSUID;
7217 @@ -1996,15 +2064,17 @@ long do_mount(char *dev_name, char *dir_
7218         if (flags & MS_RDONLY)
7219                 mnt_flags |= MNT_READONLY;
7220  
7221 +       if (!capable(CAP_SYS_ADMIN))
7222 +               mnt_flags |= MNT_NODEV;
7223         flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
7224                    MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
7225                    MS_STRICTATIME);
7226  
7227         if (flags & MS_REMOUNT)
7228                 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
7229 -                                   data_page);
7230 +                                   data_page, tag);
7231         else if (flags & MS_BIND)
7232 -               retval = do_loopback(&path, dev_name, flags & MS_REC);
7233 +               retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
7234         else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7235                 retval = do_change_type(&path, flags);
7236         else if (flags & MS_MOVE)
7237 @@ -2083,6 +2153,7 @@ static struct mnt_namespace *dup_mnt_ns(
7238                 q = next_mnt(q, new_ns->root);
7239         }
7240         up_write(&namespace_sem);
7241 +       atomic_inc(&vs_global_mnt_ns);
7242  
7243         if (rootmnt)
7244                 mntput(rootmnt);
7245 @@ -2227,9 +2298,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
7246         down_write(&namespace_sem);
7247         mutex_lock(&old.dentry->d_inode->i_mutex);
7248         error = -EINVAL;
7249 -       if (IS_MNT_SHARED(old.mnt) ||
7250 +       if ((IS_MNT_SHARED(old.mnt) ||
7251                 IS_MNT_SHARED(new.mnt->mnt_parent) ||
7252 -               IS_MNT_SHARED(root.mnt->mnt_parent))
7253 +               IS_MNT_SHARED(root.mnt->mnt_parent)) &&
7254 +               !vx_flags(VXF_STATE_SETUP, 0))
7255                 goto out2;
7256         if (!check_mnt(root.mnt))
7257                 goto out2;
7258 @@ -2361,6 +2433,7 @@ void put_mnt_ns(struct mnt_namespace *ns
7259         spin_unlock(&vfsmount_lock);
7260         up_write(&namespace_sem);
7261         release_mounts(&umount_list);
7262 +       atomic_dec(&vs_global_mnt_ns);
7263         kfree(ns);
7264  }
7265  EXPORT_SYMBOL(put_mnt_ns);
7266 diff -NurpP --minimal linux-2.6.34/fs/nfs/client.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/client.c
7267 --- linux-2.6.34/fs/nfs/client.c        2010-05-18 15:07:52.000000000 +0200
7268 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/client.c   2010-05-18 18:11:22.000000000 +0200
7269 @@ -739,6 +739,9 @@ static int nfs_init_server_rpcclient(str
7270         if (server->flags & NFS_MOUNT_SOFT)
7271                 server->client->cl_softrtry = 1;
7272  
7273 +       server->client->cl_tag = 0;
7274 +       if (server->flags & NFS_MOUNT_TAGGED)
7275 +               server->client->cl_tag = 1;
7276         return 0;
7277  }
7278  
7279 @@ -910,6 +913,10 @@ static void nfs_server_set_fsinfo(struct
7280                 server->acdirmin = server->acdirmax = 0;
7281         }
7282  
7283 +       /* FIXME: needs fsinfo
7284 +       if (server->flags & NFS_MOUNT_TAGGED)
7285 +               sb->s_flags |= MS_TAGGED;       */
7286 +
7287         server->maxfilesize = fsinfo->maxfilesize;
7288  
7289         /* We're airborne Set socket buffersize */
7290 diff -NurpP --minimal linux-2.6.34/fs/nfs/dir.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/dir.c
7291 --- linux-2.6.34/fs/nfs/dir.c   2010-05-18 15:07:52.000000000 +0200
7292 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/dir.c      2010-05-18 18:11:22.000000000 +0200
7293 @@ -33,6 +33,7 @@
7294  #include <linux/namei.h>
7295  #include <linux/mount.h>
7296  #include <linux/sched.h>
7297 +#include <linux/vs_tag.h>
7298  
7299  #include "nfs4_fs.h"
7300  #include "delegation.h"
7301 @@ -951,6 +952,7 @@ static struct dentry *nfs_lookup(struct 
7302         if (IS_ERR(res))
7303                 goto out_unblock_sillyrename;
7304  
7305 +       dx_propagate_tag(nd, inode);
7306  no_entry:
7307         res = d_materialise_unique(dentry, inode);
7308         if (res != NULL) {
7309 diff -NurpP --minimal linux-2.6.34/fs/nfs/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/inode.c
7310 --- linux-2.6.34/fs/nfs/inode.c 2010-05-18 15:07:52.000000000 +0200
7311 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/inode.c    2010-05-18 18:11:22.000000000 +0200
7312 @@ -37,6 +37,7 @@
7313  #include <linux/inet.h>
7314  #include <linux/nfs_xdr.h>
7315  #include <linux/slab.h>
7316 +#include <linux/vs_tag.h>
7317  
7318  #include <asm/system.h>
7319  #include <asm/uaccess.h>
7320 @@ -260,6 +261,8 @@ nfs_fhget(struct super_block *sb, struct
7321         if (inode->i_state & I_NEW) {
7322                 struct nfs_inode *nfsi = NFS_I(inode);
7323                 unsigned long now = jiffies;
7324 +               uid_t uid;
7325 +               gid_t gid;
7326  
7327                 /* We set i_ino for the few things that still rely on it,
7328                  * such as stat(2) */
7329 @@ -308,8 +311,8 @@ nfs_fhget(struct super_block *sb, struct
7330                 nfsi->change_attr = 0;
7331                 inode->i_size = 0;
7332                 inode->i_nlink = 0;
7333 -               inode->i_uid = -2;
7334 -               inode->i_gid = -2;
7335 +               uid = -2;
7336 +               gid = -2;
7337                 inode->i_blocks = 0;
7338                 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
7339  
7340 @@ -346,13 +349,13 @@ nfs_fhget(struct super_block *sb, struct
7341                 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
7342                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
7343                 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
7344 -                       inode->i_uid = fattr->uid;
7345 +                       uid = fattr->uid;
7346                 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
7347                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7348                                 | NFS_INO_INVALID_ACCESS
7349                                 | NFS_INO_INVALID_ACL;
7350                 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
7351 -                       inode->i_gid = fattr->gid;
7352 +                       gid = fattr->gid;
7353                 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
7354                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7355                                 | NFS_INO_INVALID_ACCESS
7356 @@ -365,6 +368,11 @@ nfs_fhget(struct super_block *sb, struct
7357                          */
7358                         inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
7359                 }
7360 +               inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7361 +               inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7362 +               inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7363 +                               /* maybe fattr->xid someday */
7364 +
7365                 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
7366                 nfsi->attrtimeo_timestamp = now;
7367                 nfsi->access_cache = RB_ROOT;
7368 @@ -477,6 +485,8 @@ void nfs_setattr_update_inode(struct ino
7369                         inode->i_uid = attr->ia_uid;
7370                 if ((attr->ia_valid & ATTR_GID) != 0)
7371                         inode->i_gid = attr->ia_gid;
7372 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7373 +                       inode->i_tag = attr->ia_tag;
7374                 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7375                 spin_unlock(&inode->i_lock);
7376         }
7377 @@ -838,6 +848,9 @@ static int nfs_check_inode_attributes(st
7378         struct nfs_inode *nfsi = NFS_I(inode);
7379         loff_t cur_size, new_isize;
7380         unsigned long invalid = 0;
7381 +       uid_t uid;
7382 +       gid_t gid;
7383 +       tag_t tag;
7384  
7385  
7386         /* Has the inode gone and changed behind our back? */
7387 @@ -861,13 +874,18 @@ static int nfs_check_inode_attributes(st
7388                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7389         }
7390  
7391 +       uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7392 +       gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7393 +       tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7394 +
7395         /* Have any file permissions changed? */
7396         if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
7397                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7398 -       if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
7399 +       if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
7400                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7401 -       if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
7402 +       if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
7403                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7404 +               /* maybe check for tag too? */
7405  
7406         /* Has the link count changed? */
7407         if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
7408 @@ -1082,6 +1100,9 @@ static int nfs_update_inode(struct inode
7409         unsigned long invalid = 0;
7410         unsigned long now = jiffies;
7411         unsigned long save_cache_validity;
7412 +       uid_t uid;
7413 +       gid_t gid;
7414 +       tag_t tag;
7415  
7416         dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7417                         __func__, inode->i_sb->s_id, inode->i_ino,
7418 @@ -1184,6 +1205,9 @@ static int nfs_update_inode(struct inode
7419                                 | NFS_INO_REVAL_PAGECACHE
7420                                 | NFS_INO_REVAL_FORCED);
7421  
7422 +       uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7423 +       gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7424 +       tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7425  
7426         if (fattr->valid & NFS_ATTR_FATTR_ATIME)
7427                 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7428 @@ -1205,9 +1229,9 @@ static int nfs_update_inode(struct inode
7429                                 | NFS_INO_REVAL_FORCED);
7430  
7431         if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
7432 -               if (inode->i_uid != fattr->uid) {
7433 +               if (uid != fattr->uid) {
7434                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7435 -                       inode->i_uid = fattr->uid;
7436 +                       uid = fattr->uid;
7437                 }
7438         } else if (server->caps & NFS_CAP_OWNER)
7439                 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7440 @@ -1216,9 +1240,9 @@ static int nfs_update_inode(struct inode
7441                                 | NFS_INO_REVAL_FORCED);
7442  
7443         if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
7444 -               if (inode->i_gid != fattr->gid) {
7445 +               if (gid != fattr->gid) {
7446                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7447 -                       inode->i_gid = fattr->gid;
7448 +                       gid = fattr->gid;
7449                 }
7450         } else if (server->caps & NFS_CAP_OWNER_GROUP)
7451                 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7452 @@ -1226,6 +1250,10 @@ static int nfs_update_inode(struct inode
7453                                 | NFS_INO_INVALID_ACL
7454                                 | NFS_INO_REVAL_FORCED);
7455  
7456 +       inode->i_uid = uid;
7457 +       inode->i_gid = gid;
7458 +       inode->i_tag = tag;
7459 +
7460         if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
7461                 if (inode->i_nlink != fattr->nlink) {
7462                         invalid |= NFS_INO_INVALID_ATTR;
7463 diff -NurpP --minimal linux-2.6.34/fs/nfs/nfs3xdr.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/nfs3xdr.c
7464 --- linux-2.6.34/fs/nfs/nfs3xdr.c       2010-05-18 15:07:52.000000000 +0200
7465 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/nfs3xdr.c  2010-05-18 18:11:22.000000000 +0200
7466 @@ -20,6 +20,7 @@
7467  #include <linux/nfs3.h>
7468  #include <linux/nfs_fs.h>
7469  #include <linux/nfsacl.h>
7470 +#include <linux/vs_tag.h>
7471  #include "internal.h"
7472  
7473  #define NFSDBG_FACILITY                NFSDBG_XDR
7474 @@ -175,7 +176,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7475  }
7476  
7477  static inline __be32 *
7478 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7479 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7480  {
7481         if (attr->ia_valid & ATTR_MODE) {
7482                 *p++ = xdr_one;
7483 @@ -183,15 +184,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7484         } else {
7485                 *p++ = xdr_zero;
7486         }
7487 -       if (attr->ia_valid & ATTR_UID) {
7488 +       if (attr->ia_valid & ATTR_UID ||
7489 +               (tag && (attr->ia_valid & ATTR_TAG))) {
7490                 *p++ = xdr_one;
7491 -               *p++ = htonl(attr->ia_uid);
7492 +               *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7493         } else {
7494                 *p++ = xdr_zero;
7495         }
7496 -       if (attr->ia_valid & ATTR_GID) {
7497 +       if (attr->ia_valid & ATTR_GID ||
7498 +               (tag && (attr->ia_valid & ATTR_TAG))) {
7499                 *p++ = xdr_one;
7500 -               *p++ = htonl(attr->ia_gid);
7501 +               *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7502         } else {
7503                 *p++ = xdr_zero;
7504         }
7505 @@ -278,7 +281,8 @@ static int
7506  nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7507  {
7508         p = xdr_encode_fhandle(p, args->fh);
7509 -       p = xdr_encode_sattr(p, args->sattr);
7510 +       p = xdr_encode_sattr(p, args->sattr,
7511 +               req->rq_task->tk_client->cl_tag);
7512         *p++ = htonl(args->guard);
7513         if (args->guard)
7514                 p = xdr_encode_time3(p, &args->guardtime);
7515 @@ -383,7 +387,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7516                 *p++ = args->verifier[0];
7517                 *p++ = args->verifier[1];
7518         } else
7519 -               p = xdr_encode_sattr(p, args->sattr);
7520 +               p = xdr_encode_sattr(p, args->sattr,
7521 +                       req->rq_task->tk_client->cl_tag);
7522  
7523         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7524         return 0;
7525 @@ -397,7 +402,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7526  {
7527         p = xdr_encode_fhandle(p, args->fh);
7528         p = xdr_encode_array(p, args->name, args->len);
7529 -       p = xdr_encode_sattr(p, args->sattr);
7530 +       p = xdr_encode_sattr(p, args->sattr,
7531 +               req->rq_task->tk_client->cl_tag);
7532         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7533         return 0;
7534  }
7535 @@ -410,7 +416,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7536  {
7537         p = xdr_encode_fhandle(p, args->fromfh);
7538         p = xdr_encode_array(p, args->fromname, args->fromlen);
7539 -       p = xdr_encode_sattr(p, args->sattr);
7540 +       p = xdr_encode_sattr(p, args->sattr,
7541 +               req->rq_task->tk_client->cl_tag);
7542         *p++ = htonl(args->pathlen);
7543         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7544  
7545 @@ -428,7 +435,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7546         p = xdr_encode_fhandle(p, args->fh);
7547         p = xdr_encode_array(p, args->name, args->len);
7548         *p++ = htonl(args->type);
7549 -       p = xdr_encode_sattr(p, args->sattr);
7550 +       p = xdr_encode_sattr(p, args->sattr,
7551 +               req->rq_task->tk_client->cl_tag);
7552         if (args->type == NF3CHR || args->type == NF3BLK) {
7553                 *p++ = htonl(MAJOR(args->rdev));
7554                 *p++ = htonl(MINOR(args->rdev));
7555 diff -NurpP --minimal linux-2.6.34/fs/nfs/nfsroot.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/nfsroot.c
7556 --- linux-2.6.34/fs/nfs/nfsroot.c       2009-09-10 15:26:23.000000000 +0200
7557 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/nfsroot.c  2010-05-18 18:11:22.000000000 +0200
7558 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0;             /
7559  enum {
7560         /* Options that take integer arguments */
7561         Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7562 -       Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7563 +       Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7564         /* Options that take no arguments */
7565         Opt_soft, Opt_hard, Opt_intr,
7566         Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac, 
7567         Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7568 -       Opt_acl, Opt_noacl,
7569 +       Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7570         /* Error token */
7571         Opt_err
7572  };
7573 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
7574         {Opt_tcp, "tcp"},
7575         {Opt_acl, "acl"},
7576         {Opt_noacl, "noacl"},
7577 +       {Opt_tag, "tag"},
7578 +       {Opt_notag, "notag"},
7579 +       {Opt_tagid, "tagid=%u"},
7580         {Opt_err, NULL}
7581         
7582  };
7583 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
7584                         case Opt_noacl:
7585                                 nfs_data.flags |= NFS_MOUNT_NOACL;
7586                                 break;
7587 +#ifndef CONFIG_TAGGING_NONE
7588 +                       case Opt_tag:
7589 +                               nfs_data.flags |= NFS_MOUNT_TAGGED;
7590 +                               break;
7591 +                       case Opt_notag:
7592 +                               nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7593 +                               break;
7594 +#endif
7595 +#ifdef CONFIG_PROPAGATE
7596 +                       case Opt_tagid:
7597 +                               /* use args[0] */
7598 +                               nfs_data.flags |= NFS_MOUNT_TAGGED;
7599 +                               break;
7600 +#endif
7601                         default:
7602                                 printk(KERN_WARNING "Root-NFS: unknown "
7603                                         "option: %s\n", p);
7604 diff -NurpP --minimal linux-2.6.34/fs/nfs/super.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/super.c
7605 --- linux-2.6.34/fs/nfs/super.c 2010-05-18 15:07:52.000000000 +0200
7606 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfs/super.c    2010-05-18 18:11:22.000000000 +0200
7607 @@ -54,6 +54,7 @@
7608  #include <linux/nfs_xdr.h>
7609  #include <linux/magic.h>
7610  #include <linux/parser.h>
7611 +#include <linux/vs_tag.h>
7612  
7613  #include <asm/system.h>
7614  #include <asm/uaccess.h>
7615 @@ -586,6 +587,7 @@ static void nfs_show_mount_options(struc
7616                 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7617                 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
7618                 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
7619 +               { NFS_MOUNT_TAGGED, ",tag", "" },
7620                 { 0, NULL, NULL }
7621         };
7622         const struct proc_nfs_info *nfs_infop;
7623 diff -NurpP --minimal linux-2.6.34/fs/nfsd/auth.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfsd/auth.c
7624 --- linux-2.6.34/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
7625 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfsd/auth.c    2010-05-18 18:11:22.000000000 +0200
7626 @@ -1,6 +1,7 @@
7627  /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
7628  
7629  #include <linux/sched.h>
7630 +#include <linux/vs_tag.h>
7631  #include "nfsd.h"
7632  #include "auth.h"
7633  
7634 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7635  
7636         new->fsuid = rqstp->rq_cred.cr_uid;
7637         new->fsgid = rqstp->rq_cred.cr_gid;
7638 +       /* FIXME: this desperately needs a tag :)
7639 +       new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7640 +                       */
7641  
7642         rqgi = rqstp->rq_cred.cr_group_info;
7643  
7644 diff -NurpP --minimal linux-2.6.34/fs/nfsd/nfs3xdr.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfsd/nfs3xdr.c
7645 --- linux-2.6.34/fs/nfsd/nfs3xdr.c      2010-02-25 11:52:05.000000000 +0100
7646 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfsd/nfs3xdr.c 2010-05-18 18:11:22.000000000 +0200
7647 @@ -7,6 +7,7 @@
7648   */
7649  
7650  #include <linux/namei.h>
7651 +#include <linux/vs_tag.h>
7652  #include "xdr3.h"
7653  #include "auth.h"
7654  
7655 @@ -95,6 +96,8 @@ static __be32 *
7656  decode_sattr3(__be32 *p, struct iattr *iap)
7657  {
7658         u32     tmp;
7659 +       uid_t   uid = 0;
7660 +       gid_t   gid = 0;
7661  
7662         iap->ia_valid = 0;
7663  
7664 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7665         }
7666         if (*p++) {
7667                 iap->ia_valid |= ATTR_UID;
7668 -               iap->ia_uid = ntohl(*p++);
7669 +               uid = ntohl(*p++);
7670         }
7671         if (*p++) {
7672                 iap->ia_valid |= ATTR_GID;
7673 -               iap->ia_gid = ntohl(*p++);
7674 +               gid = ntohl(*p++);
7675         }
7676 +       iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7677 +       iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7678 +       iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7679         if (*p++) {
7680                 u64     newsize;
7681  
7682 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
7683         *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7684         *p++ = htonl((u32) stat->mode);
7685         *p++ = htonl((u32) stat->nlink);
7686 -       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7687 -       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7688 +       *p++ = htonl((u32) nfsd_ruid(rqstp,
7689 +               TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7690 +               stat->uid, stat->tag)));
7691 +       *p++ = htonl((u32) nfsd_rgid(rqstp,
7692 +               TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7693 +               stat->gid, stat->tag)));
7694         if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7695                 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7696         } else {
7697 diff -NurpP --minimal linux-2.6.34/fs/nfsd/nfs4xdr.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfsd/nfs4xdr.c
7698 --- linux-2.6.34/fs/nfsd/nfs4xdr.c      2010-05-18 15:07:52.000000000 +0200
7699 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfsd/nfs4xdr.c 2010-05-18 18:11:22.000000000 +0200
7700 @@ -47,6 +47,7 @@
7701  #include <linux/nfsd_idmap.h>
7702  #include <linux/nfs4_acl.h>
7703  #include <linux/sunrpc/svcauth_gss.h>
7704 +#include <linux/vs_tag.h>
7705  
7706  #include "xdr4.h"
7707  #include "vfs.h"
7708 @@ -2043,14 +2044,18 @@ out_acl:
7709                 WRITE32(stat.nlink);
7710         }
7711         if (bmval1 & FATTR4_WORD1_OWNER) {
7712 -               status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7713 +               status = nfsd4_encode_user(rqstp,
7714 +                       TAGINO_UID(DX_TAG(dentry->d_inode),
7715 +                       stat.uid, stat.tag), &p, &buflen);
7716                 if (status == nfserr_resource)
7717                         goto out_resource;
7718                 if (status)
7719                         goto out;
7720         }
7721         if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7722 -               status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7723 +               status = nfsd4_encode_group(rqstp,
7724 +                       TAGINO_GID(DX_TAG(dentry->d_inode),
7725 +                       stat.gid, stat.tag), &p, &buflen);
7726                 if (status == nfserr_resource)
7727                         goto out_resource;
7728                 if (status)
7729 diff -NurpP --minimal linux-2.6.34/fs/nfsd/nfsxdr.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfsd/nfsxdr.c
7730 --- linux-2.6.34/fs/nfsd/nfsxdr.c       2010-02-25 11:52:05.000000000 +0100
7731 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/nfsd/nfsxdr.c  2010-05-18 18:11:22.000000000 +0200
7732 @@ -6,6 +6,7 @@
7733  
7734  #include "xdr.h"
7735  #include "auth.h"
7736 +#include <linux/vs_tag.h>
7737  
7738  #define NFSDDBG_FACILITY               NFSDDBG_XDR
7739  
7740 @@ -88,6 +89,8 @@ static __be32 *
7741  decode_sattr(__be32 *p, struct iattr *iap)
7742  {
7743         u32     tmp, tmp1;
7744 +       uid_t   uid = 0;
7745 +       gid_t   gid = 0;
7746  
7747         iap->ia_valid = 0;
7748  
7749 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7750         }
7751         if ((tmp = ntohl(*p++)) != (u32)-1) {
7752                 iap->ia_valid |= ATTR_UID;
7753 -               iap->ia_uid = tmp;
7754 +               uid = tmp;
7755         }
7756         if ((tmp = ntohl(*p++)) != (u32)-1) {
7757                 iap->ia_valid |= ATTR_GID;
7758 -               iap->ia_gid = tmp;
7759 +               gid = tmp;
7760         }
7761 +       iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7762 +       iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7763 +       iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7764         if ((tmp = ntohl(*p++)) != (u32)-1) {
7765                 iap->ia_valid |= ATTR_SIZE;
7766                 iap->ia_size = tmp;
7767 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7768         *p++ = htonl(nfs_ftypes[type >> 12]);
7769         *p++ = htonl((u32) stat->mode);
7770         *p++ = htonl((u32) stat->nlink);
7771 -       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7772 -       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7773 +       *p++ = htonl((u32) nfsd_ruid(rqstp,
7774 +               TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7775 +       *p++ = htonl((u32) nfsd_rgid(rqstp,
7776 +               TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7777  
7778         if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7779                 *p++ = htonl(NFS_MAXPATHLEN);
7780 diff -NurpP --minimal linux-2.6.34/fs/ocfs2/dlmglue.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/dlmglue.c
7781 --- linux-2.6.34/fs/ocfs2/dlmglue.c     2010-05-18 15:07:52.000000000 +0200
7782 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/dlmglue.c        2010-05-18 18:11:22.000000000 +0200
7783 @@ -2114,6 +2114,7 @@ static void __ocfs2_stuff_meta_lvb(struc
7784         lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
7785         lvb->lvb_iuid      = cpu_to_be32(inode->i_uid);
7786         lvb->lvb_igid      = cpu_to_be32(inode->i_gid);
7787 +       lvb->lvb_itag      = cpu_to_be16(inode->i_tag);
7788         lvb->lvb_imode     = cpu_to_be16(inode->i_mode);
7789         lvb->lvb_inlink    = cpu_to_be16(inode->i_nlink);
7790         lvb->lvb_iatime_packed  =
7791 @@ -2168,6 +2169,7 @@ static void ocfs2_refresh_inode_from_lvb
7792  
7793         inode->i_uid     = be32_to_cpu(lvb->lvb_iuid);
7794         inode->i_gid     = be32_to_cpu(lvb->lvb_igid);
7795 +       inode->i_tag     = be16_to_cpu(lvb->lvb_itag);
7796         inode->i_mode    = be16_to_cpu(lvb->lvb_imode);
7797         inode->i_nlink   = be16_to_cpu(lvb->lvb_inlink);
7798         ocfs2_unpack_timespec(&inode->i_atime,
7799 diff -NurpP --minimal linux-2.6.34/fs/ocfs2/dlmglue.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/dlmglue.h
7800 --- linux-2.6.34/fs/ocfs2/dlmglue.h     2009-12-03 20:02:53.000000000 +0100
7801 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/dlmglue.h        2010-05-18 18:11:22.000000000 +0200
7802 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
7803         __be16       lvb_inlink;
7804         __be32       lvb_iattr;
7805         __be32       lvb_igeneration;
7806 -       __be32       lvb_reserved2;
7807 +       __be16       lvb_itag;
7808 +       __be16       lvb_reserved2;
7809  };
7810  
7811  #define OCFS2_QINFO_LVB_VERSION 1
7812 diff -NurpP --minimal linux-2.6.34/fs/ocfs2/file.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/file.c
7813 --- linux-2.6.34/fs/ocfs2/file.c        2010-05-18 15:07:52.000000000 +0200
7814 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/file.c   2010-05-18 18:11:22.000000000 +0200
7815 @@ -963,13 +963,15 @@ int ocfs2_setattr(struct dentry *dentry,
7816                 mlog(0, "uid change: %d\n", attr->ia_uid);
7817         if (attr->ia_valid & ATTR_GID)
7818                 mlog(0, "gid change: %d\n", attr->ia_gid);
7819 +       if (attr->ia_valid & ATTR_TAG)
7820 +               mlog(0, "tag change: %d\n", attr->ia_tag);
7821         if (attr->ia_valid & ATTR_SIZE)
7822                 mlog(0, "size change...\n");
7823         if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
7824                 mlog(0, "time change...\n");
7825  
7826  #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
7827 -                          | ATTR_GID | ATTR_UID | ATTR_MODE)
7828 +                          | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
7829         if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
7830                 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
7831                 return 0;
7832 diff -NurpP --minimal linux-2.6.34/fs/ocfs2/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/inode.c
7833 --- linux-2.6.34/fs/ocfs2/inode.c       2010-05-18 15:07:52.000000000 +0200
7834 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/inode.c  2010-05-18 18:11:22.000000000 +0200
7835 @@ -28,6 +28,7 @@
7836  #include <linux/highmem.h>
7837  #include <linux/pagemap.h>
7838  #include <linux/quotaops.h>
7839 +#include <linux/vs_tag.h>
7840  
7841  #include <asm/byteorder.h>
7842  
7843 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode 
7844  {
7845         unsigned int flags = OCFS2_I(inode)->ip_attr;
7846  
7847 -       inode->i_flags &= ~(S_IMMUTABLE |
7848 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
7849                 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
7850  
7851         if (flags & OCFS2_IMMUTABLE_FL)
7852                 inode->i_flags |= S_IMMUTABLE;
7853 +       if (flags & OCFS2_IXUNLINK_FL)
7854 +               inode->i_flags |= S_IXUNLINK;
7855  
7856         if (flags & OCFS2_SYNC_FL)
7857                 inode->i_flags |= S_SYNC;
7858 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode 
7859                 inode->i_flags |= S_NOATIME;
7860         if (flags & OCFS2_DIRSYNC_FL)
7861                 inode->i_flags |= S_DIRSYNC;
7862 +
7863 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
7864 +
7865 +       if (flags & OCFS2_BARRIER_FL)
7866 +               inode->i_vflags |= V_BARRIER;
7867 +       if (flags & OCFS2_COW_FL)
7868 +               inode->i_vflags |= V_COW;
7869  }
7870  
7871  /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
7872  void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
7873  {
7874         unsigned int flags = oi->vfs_inode.i_flags;
7875 +       unsigned int vflags = oi->vfs_inode.i_vflags;
7876 +
7877 +       oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
7878 +                       OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
7879 +                       OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
7880 +                       OCFS2_BARRIER_FL | OCFS2_COW_FL);
7881 +
7882 +       if (flags & S_IMMUTABLE)
7883 +               oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7884 +       if (flags & S_IXUNLINK)
7885 +               oi->ip_attr |= OCFS2_IXUNLINK_FL;
7886  
7887 -       oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
7888 -                       OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
7889         if (flags & S_SYNC)
7890                 oi->ip_attr |= OCFS2_SYNC_FL;
7891         if (flags & S_APPEND)
7892                 oi->ip_attr |= OCFS2_APPEND_FL;
7893 -       if (flags & S_IMMUTABLE)
7894 -               oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7895         if (flags & S_NOATIME)
7896                 oi->ip_attr |= OCFS2_NOATIME_FL;
7897         if (flags & S_DIRSYNC)
7898                 oi->ip_attr |= OCFS2_DIRSYNC_FL;
7899 +
7900 +       if (vflags & V_BARRIER)
7901 +               oi->ip_attr |= OCFS2_BARRIER_FL;
7902 +       if (vflags & V_COW)
7903 +               oi->ip_attr |= OCFS2_COW_FL;
7904  }
7905  
7906  struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
7907 @@ -245,6 +267,8 @@ void ocfs2_populate_inode(struct inode *
7908         struct super_block *sb;
7909         struct ocfs2_super *osb;
7910         int use_plocks = 1;
7911 +       uid_t uid;
7912 +       gid_t gid;
7913  
7914         mlog_entry("(0x%p, size:%llu)\n", inode,
7915                    (unsigned long long)le64_to_cpu(fe->i_size));
7916 @@ -276,8 +300,12 @@ void ocfs2_populate_inode(struct inode *
7917         inode->i_generation = le32_to_cpu(fe->i_generation);
7918         inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
7919         inode->i_mode = le16_to_cpu(fe->i_mode);
7920 -       inode->i_uid = le32_to_cpu(fe->i_uid);
7921 -       inode->i_gid = le32_to_cpu(fe->i_gid);
7922 +       uid = le32_to_cpu(fe->i_uid);
7923 +       gid = le32_to_cpu(fe->i_gid);
7924 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7925 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7926 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7927 +               /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7928  
7929         /* Fast symlinks will have i_size but no allocated clusters. */
7930         if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
7931 diff -NurpP --minimal linux-2.6.34/fs/ocfs2/inode.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/inode.h
7932 --- linux-2.6.34/fs/ocfs2/inode.h       2010-05-18 15:07:52.000000000 +0200
7933 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/inode.h  2010-05-18 18:11:22.000000000 +0200
7934 @@ -152,6 +152,7 @@ struct buffer_head *ocfs2_bread(struct i
7935  
7936  void ocfs2_set_inode_flags(struct inode *inode);
7937  void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
7938 +int ocfs2_sync_flags(struct inode *inode, int, int);
7939  
7940  static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
7941  {
7942 diff -NurpP --minimal linux-2.6.34/fs/ocfs2/ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/ioctl.c
7943 --- linux-2.6.34/fs/ocfs2/ioctl.c       2010-02-25 11:52:06.000000000 +0100
7944 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/ioctl.c  2010-05-18 18:11:22.000000000 +0200
7945 @@ -43,7 +43,41 @@ static int ocfs2_get_inode_attr(struct i
7946         return status;
7947  }
7948  
7949 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7950 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
7951 +{
7952 +       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7953 +       struct buffer_head *bh = NULL;
7954 +       handle_t *handle = NULL;
7955 +       int status;
7956 +
7957 +       status = ocfs2_inode_lock(inode, &bh, 1);
7958 +       if (status < 0) {
7959 +               mlog_errno(status);
7960 +               return status;
7961 +       }
7962 +       handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7963 +       if (IS_ERR(handle)) {
7964 +               status = PTR_ERR(handle);
7965 +               mlog_errno(status);
7966 +               goto bail_unlock;
7967 +       }
7968 +
7969 +       inode->i_flags = flags;
7970 +       inode->i_vflags = vflags;
7971 +       ocfs2_get_inode_flags(OCFS2_I(inode));
7972 +
7973 +       status = ocfs2_mark_inode_dirty(handle, inode, bh);
7974 +       if (status < 0)
7975 +               mlog_errno(status);
7976 +
7977 +       ocfs2_commit_trans(osb, handle);
7978 +bail_unlock:
7979 +       ocfs2_inode_unlock(inode, 1);
7980 +       brelse(bh);
7981 +       return status;
7982 +}
7983 +
7984 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7985                                 unsigned mask)
7986  {
7987         struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
7988 @@ -68,6 +102,11 @@ static int ocfs2_set_inode_attr(struct i
7989         if (!S_ISDIR(inode->i_mode))
7990                 flags &= ~OCFS2_DIRSYNC_FL;
7991  
7992 +       if (IS_BARRIER(inode)) {
7993 +               vxwprintk_task(1, "messing with the barrier.");
7994 +               goto bail_unlock;
7995 +       }
7996 +
7997         handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7998         if (IS_ERR(handle)) {
7999                 status = PTR_ERR(handle);
8000 @@ -109,6 +148,7 @@ bail:
8001         return status;
8002  }
8003  
8004 +
8005  long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
8006  {
8007         struct inode *inode = filp->f_path.dentry->d_inode;
8008 diff -NurpP --minimal linux-2.6.34/fs/ocfs2/namei.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/namei.c
8009 --- linux-2.6.34/fs/ocfs2/namei.c       2010-05-18 15:07:52.000000000 +0200
8010 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/namei.c  2010-05-18 18:11:22.000000000 +0200
8011 @@ -41,6 +41,7 @@
8012  #include <linux/slab.h>
8013  #include <linux/highmem.h>
8014  #include <linux/quotaops.h>
8015 +#include <linux/vs_tag.h>
8016  
8017  #define MLOG_MASK_PREFIX ML_NAMEI
8018  #include <cluster/masklog.h>
8019 @@ -490,6 +491,7 @@ static int ocfs2_mknod_locked(struct ocf
8020         u64 fe_blkno = 0;
8021         u16 suballoc_bit;
8022         u16 feat;
8023 +       tag_t tag;
8024  
8025         *new_fe_bh = NULL;
8026  
8027 @@ -533,8 +535,11 @@ static int ocfs2_mknod_locked(struct ocf
8028         fe->i_blkno = cpu_to_le64(fe_blkno);
8029         fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
8030         fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
8031 -       fe->i_uid = cpu_to_le32(inode->i_uid);
8032 -       fe->i_gid = cpu_to_le32(inode->i_gid);
8033 +
8034 +       tag = dx_current_fstag(osb->sb);
8035 +       fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
8036 +       fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
8037 +       inode->i_tag = tag;
8038         fe->i_mode = cpu_to_le16(inode->i_mode);
8039         if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
8040                 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
8041 diff -NurpP --minimal linux-2.6.34/fs/ocfs2/ocfs2_fs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/ocfs2_fs.h
8042 --- linux-2.6.34/fs/ocfs2/ocfs2_fs.h    2010-05-18 15:07:52.000000000 +0200
8043 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/ocfs2_fs.h       2010-05-18 18:11:22.000000000 +0200
8044 @@ -231,18 +231,23 @@
8045  #define OCFS2_HAS_REFCOUNT_FL   (0x0010)
8046  
8047  /* Inode attributes, keep in sync with EXT2 */
8048 -#define OCFS2_SECRM_FL         (0x00000001)    /* Secure deletion */
8049 -#define OCFS2_UNRM_FL          (0x00000002)    /* Undelete */
8050 -#define OCFS2_COMPR_FL         (0x00000004)    /* Compress file */
8051 -#define OCFS2_SYNC_FL          (0x00000008)    /* Synchronous updates */
8052 -#define OCFS2_IMMUTABLE_FL     (0x00000010)    /* Immutable file */
8053 -#define OCFS2_APPEND_FL                (0x00000020)    /* writes to file may only append */
8054 -#define OCFS2_NODUMP_FL                (0x00000040)    /* do not dump file */
8055 -#define OCFS2_NOATIME_FL       (0x00000080)    /* do not update atime */
8056 -#define OCFS2_DIRSYNC_FL       (0x00010000)    /* dirsync behaviour (directories only) */
8057 +#define OCFS2_SECRM_FL         FS_SECRM_FL     /* Secure deletion */
8058 +#define OCFS2_UNRM_FL          FS_UNRM_FL      /* Undelete */
8059 +#define OCFS2_COMPR_FL         FS_COMPR_FL     /* Compress file */
8060 +#define OCFS2_SYNC_FL          FS_SYNC_FL      /* Synchronous updates */
8061 +#define OCFS2_IMMUTABLE_FL     FS_IMMUTABLE_FL /* Immutable file */
8062 +#define OCFS2_APPEND_FL                FS_APPEND_FL    /* writes to file may only append */
8063 +#define OCFS2_NODUMP_FL                FS_NODUMP_FL    /* do not dump file */
8064 +#define OCFS2_NOATIME_FL       FS_NOATIME_FL   /* do not update atime */
8065  
8066 -#define OCFS2_FL_VISIBLE       (0x000100FF)    /* User visible flags */
8067 -#define OCFS2_FL_MODIFIABLE    (0x000100FF)    /* User modifiable flags */
8068 +#define OCFS2_DIRSYNC_FL       FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
8069 +#define OCFS2_IXUNLINK_FL      FS_IXUNLINK_FL  /* Immutable invert on unlink */
8070 +
8071 +#define OCFS2_BARRIER_FL       FS_BARRIER_FL   /* Barrier for chroot() */
8072 +#define OCFS2_COW_FL           FS_COW_FL       /* Copy on Write marker */
8073 +
8074 +#define OCFS2_FL_VISIBLE       (0x010300FF)    /* User visible flags */
8075 +#define OCFS2_FL_MODIFIABLE    (0x010300FF)    /* User modifiable flags */
8076  
8077  /*
8078   * Extent record flags (e_node.leaf.flags)
8079 diff -NurpP --minimal linux-2.6.34/fs/ocfs2/ocfs2.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/ocfs2.h
8080 --- linux-2.6.34/fs/ocfs2/ocfs2.h       2010-05-18 15:07:52.000000000 +0200
8081 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/ocfs2.h  2010-05-18 18:11:22.000000000 +0200
8082 @@ -255,6 +255,7 @@ enum ocfs2_mount_options
8083                                                    control lists */
8084         OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
8085         OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
8086 +       OCFS2_MOUNT_TAGGED = 1 << 12, /* use tagging */
8087  };
8088  
8089  #define OCFS2_OSB_SOFT_RO                      0x0001
8090 diff -NurpP --minimal linux-2.6.34/fs/ocfs2/super.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/super.c
8091 --- linux-2.6.34/fs/ocfs2/super.c       2010-05-18 15:07:52.000000000 +0200
8092 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/ocfs2/super.c  2010-05-18 18:11:22.000000000 +0200
8093 @@ -176,6 +176,7 @@ enum {
8094         Opt_noacl,
8095         Opt_usrquota,
8096         Opt_grpquota,
8097 +       Opt_tag, Opt_notag, Opt_tagid,
8098         Opt_err,
8099  };
8100  
8101 @@ -202,6 +203,9 @@ static const match_table_t tokens = {
8102         {Opt_noacl, "noacl"},
8103         {Opt_usrquota, "usrquota"},
8104         {Opt_grpquota, "grpquota"},
8105 +       {Opt_tag, "tag"},
8106 +       {Opt_notag, "notag"},
8107 +       {Opt_tagid, "tagid=%u"},
8108         {Opt_err, NULL}
8109  };
8110  
8111 @@ -612,6 +616,13 @@ static int ocfs2_remount(struct super_bl
8112                 goto out;
8113         }
8114  
8115 +       if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
8116 +           (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
8117 +               ret = -EINVAL;
8118 +               mlog(ML_ERROR, "Cannot change tagging on remount\n");
8119 +               goto out;
8120 +       }
8121 +
8122         if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
8123             (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
8124                 ret = -EINVAL;
8125 @@ -1142,6 +1153,9 @@ static int ocfs2_fill_super(struct super
8126  
8127         ocfs2_complete_mount_recovery(osb);
8128  
8129 +       if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
8130 +               sb->s_flags |= MS_TAGGED;
8131 +
8132         if (ocfs2_mount_local(osb))
8133                 snprintf(nodestr, sizeof(nodestr), "local");
8134         else
8135 @@ -1433,6 +1447,20 @@ static int ocfs2_parse_options(struct su
8136                         mopt->mount_opt |= OCFS2_MOUNT_NO_POSIX_ACL;
8137                         mopt->mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
8138                         break;
8139 +#ifndef CONFIG_TAGGING_NONE
8140 +               case Opt_tag:
8141 +                       mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8142 +                       break;
8143 +               case Opt_notag:
8144 +                       mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
8145 +                       break;
8146 +#endif
8147 +#ifdef CONFIG_PROPAGATE
8148 +               case Opt_tagid:
8149 +                       /* use args[0] */
8150 +                       mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8151 +                       break;
8152 +#endif
8153                 default:
8154                         mlog(ML_ERROR,
8155                              "Unrecognized mount option \"%s\" "
8156 diff -NurpP --minimal linux-2.6.34/fs/open.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/open.c
8157 --- linux-2.6.34/fs/open.c      2010-05-18 15:07:52.000000000 +0200
8158 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/open.c 2010-05-19 01:49:29.000000000 +0200
8159 @@ -30,6 +30,11 @@
8160  #include <linux/falloc.h>
8161  #include <linux/fs_struct.h>
8162  #include <linux/ima.h>
8163 +#include <linux/vs_base.h>
8164 +#include <linux/vs_limit.h>
8165 +#include <linux/vs_tag.h>
8166 +#include <linux/vs_cowbl.h>
8167 +#include <linux/vserver/dlimit.h>
8168  
8169  #include "internal.h"
8170  
8171 @@ -38,16 +43,20 @@ int vfs_statfs(struct dentry *dentry, st
8172         int retval = -ENODEV;
8173  
8174         if (dentry) {
8175 +               struct super_block *sb = dentry->d_sb;
8176 +
8177                 retval = -ENOSYS;
8178 -               if (dentry->d_sb->s_op->statfs) {
8179 +               if (sb->s_op->statfs) {
8180                         memset(buf, 0, sizeof(*buf));
8181                         retval = security_sb_statfs(dentry);
8182                         if (retval)
8183                                 return retval;
8184 -                       retval = dentry->d_sb->s_op->statfs(dentry, buf);
8185 +                       retval = sb->s_op->statfs(dentry, buf);
8186                         if (retval == 0 && buf->f_frsize == 0)
8187                                 buf->f_frsize = buf->f_bsize;
8188                 }
8189 +               if (!vx_check(0, VS_ADMIN|VS_WATCH))
8190 +                       vx_vsi_statfs(sb, buf);
8191         }
8192         return retval;
8193  }
8194 @@ -647,6 +656,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
8195         error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
8196         if (error)
8197                 goto out;
8198 +
8199 +       error = cow_check_and_break(&path);
8200 +       if (error)
8201 +               goto dput_and_out;
8202         inode = path.dentry->d_inode;
8203  
8204         error = mnt_want_write(path.mnt);
8205 @@ -684,11 +697,11 @@ static int chown_common(struct path *pat
8206         newattrs.ia_valid =  ATTR_CTIME;
8207         if (user != (uid_t) -1) {
8208                 newattrs.ia_valid |= ATTR_UID;
8209 -               newattrs.ia_uid = user;
8210 +               newattrs.ia_uid = dx_map_uid(user);
8211         }
8212         if (group != (gid_t) -1) {
8213                 newattrs.ia_valid |= ATTR_GID;
8214 -               newattrs.ia_gid = group;
8215 +               newattrs.ia_gid = dx_map_gid(group);
8216         }
8217         if (!S_ISDIR(inode->i_mode))
8218                 newattrs.ia_valid |=
8219 @@ -713,6 +726,10 @@ SYSCALL_DEFINE3(chown, const char __user
8220         error = mnt_want_write(path.mnt);
8221         if (error)
8222                 goto out_release;
8223 +#ifdef CONFIG_VSERVER_COWBL
8224 +       error = cow_check_and_break(&path);
8225 +       if (!error)
8226 +#endif
8227         error = chown_common(&path, user, group);
8228         mnt_drop_write(path.mnt);
8229  out_release:
8230 @@ -738,6 +755,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
8231         error = mnt_want_write(path.mnt);
8232         if (error)
8233                 goto out_release;
8234 +#ifdef CONFIG_VSERVER_COWBL
8235 +       error = cow_check_and_break(&path);
8236 +       if (!error)
8237 +#endif
8238         error = chown_common(&path, user, group);
8239         mnt_drop_write(path.mnt);
8240  out_release:
8241 @@ -757,6 +778,10 @@ SYSCALL_DEFINE3(lchown, const char __use
8242         error = mnt_want_write(path.mnt);
8243         if (error)
8244                 goto out_release;
8245 +#ifdef CONFIG_VSERVER_COWBL
8246 +       error = cow_check_and_break(&path);
8247 +       if (!error)
8248 +#endif
8249         error = chown_common(&path, user, group);
8250         mnt_drop_write(path.mnt);
8251  out_release:
8252 @@ -1003,6 +1028,7 @@ static void __put_unused_fd(struct files
8253         __FD_CLR(fd, fdt->open_fds);
8254         if (fd < files->next_fd)
8255                 files->next_fd = fd;
8256 +       vx_openfd_dec(fd);
8257  }
8258  
8259  void put_unused_fd(unsigned int fd)
8260 diff -NurpP --minimal linux-2.6.34/fs/proc/array.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/array.c
8261 --- linux-2.6.34/fs/proc/array.c        2010-05-18 15:07:52.000000000 +0200
8262 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/array.c   2010-05-18 18:13:43.000000000 +0200
8263 @@ -81,6 +81,8 @@
8264  #include <linux/pid_namespace.h>
8265  #include <linux/ptrace.h>
8266  #include <linux/tracehook.h>
8267 +#include <linux/vs_context.h>
8268 +#include <linux/vs_network.h>
8269  
8270  #include <asm/pgtable.h>
8271  #include <asm/processor.h>
8272 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
8273         rcu_read_lock();
8274         ppid = pid_alive(p) ?
8275                 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
8276 +       if (unlikely(vx_current_initpid(p->pid)))
8277 +               ppid = 0;
8278 +
8279         tpid = 0;
8280         if (pid_alive(p)) {
8281                 struct task_struct *tracer = tracehook_tracer_task(p);
8282 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
8283  }
8284  
8285  static void render_cap_t(struct seq_file *m, const char *header,
8286 -                       kernel_cap_t *a)
8287 +                       struct vx_info *vxi, kernel_cap_t *a)
8288  {
8289         unsigned __capi;
8290  
8291 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
8292         cap_bset        = cred->cap_bset;
8293         rcu_read_unlock();
8294  
8295 -       render_cap_t(m, "CapInh:\t", &cap_inheritable);
8296 -       render_cap_t(m, "CapPrm:\t", &cap_permitted);
8297 -       render_cap_t(m, "CapEff:\t", &cap_effective);
8298 -       render_cap_t(m, "CapBnd:\t", &cap_bset);
8299 +       /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
8300 +       render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
8301 +       render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
8302 +       render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
8303 +       render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
8304  }
8305  
8306  static inline void task_context_switch_counts(struct seq_file *m,
8307 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
8308         seq_printf(m, "\n");
8309  }
8310  
8311 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8312 +                       struct pid *pid, struct task_struct *task)
8313 +{
8314 +       seq_printf(m,   "Proxy:\t%p(%c)\n"
8315 +                       "Count:\t%u\n"
8316 +                       "uts:\t%p(%c)\n"
8317 +                       "ipc:\t%p(%c)\n"
8318 +                       "mnt:\t%p(%c)\n"
8319 +                       "pid:\t%p(%c)\n"
8320 +                       "net:\t%p(%c)\n",
8321 +                       task->nsproxy,
8322 +                       (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
8323 +                       atomic_read(&task->nsproxy->count),
8324 +                       task->nsproxy->uts_ns,
8325 +                       (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
8326 +                       task->nsproxy->ipc_ns,
8327 +                       (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
8328 +                       task->nsproxy->mnt_ns,
8329 +                       (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
8330 +                       task->nsproxy->pid_ns,
8331 +                       (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
8332 +                       task->nsproxy->net_ns,
8333 +                       (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
8334 +       return 0;
8335 +}
8336 +
8337 +void task_vs_id(struct seq_file *m, struct task_struct *task)
8338 +{
8339 +       if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8340 +               return;
8341 +
8342 +       seq_printf(m, "VxID: %d\n", vx_task_xid(task));
8343 +       seq_printf(m, "NxID: %d\n", nx_task_nid(task));
8344 +}
8345 +
8346 +
8347  int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
8348                         struct pid *pid, struct task_struct *task)
8349  {
8350 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m, 
8351         task_cap(m, task);
8352         task_cpus_allowed(m, task);
8353         cpuset_task_status_allowed(m, task);
8354 +       task_vs_id(m, task);
8355  #if defined(CONFIG_S390)
8356         task_show_regs(m, task);
8357  #endif
8358 @@ -465,6 +508,17 @@ static int do_task_stat(struct seq_file 
8359         /* convert nsec -> ticks */
8360         start_time = nsec_to_clock_t(start_time);
8361  
8362 +       /* fixup start time for virt uptime */
8363 +       if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8364 +               unsigned long long bias =
8365 +                       current->vx_info->cvirt.bias_clock;
8366 +
8367 +               if (start_time > bias)
8368 +                       start_time -= bias;
8369 +               else
8370 +                       start_time = 0;
8371 +       }
8372 +
8373         seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
8374  %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8375  %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
8376 diff -NurpP --minimal linux-2.6.34/fs/proc/base.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/base.c
8377 --- linux-2.6.34/fs/proc/base.c 2010-05-18 15:07:52.000000000 +0200
8378 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/base.c    2010-05-18 18:11:22.000000000 +0200
8379 @@ -82,6 +82,8 @@
8380  #include <linux/pid_namespace.h>
8381  #include <linux/fs_struct.h>
8382  #include <linux/slab.h>
8383 +#include <linux/vs_context.h>
8384 +#include <linux/vs_network.h>
8385  #include "internal.h"
8386  
8387  /* NOTE:
8388 @@ -1043,12 +1045,17 @@ static ssize_t oom_adjust_write(struct f
8389                 return -ESRCH;
8390         }
8391  
8392 -       if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
8393 +       if (oom_adjust < task->signal->oom_adj &&
8394 +               !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
8395                 unlock_task_sighand(task, &flags);
8396                 put_task_struct(task);
8397                 return -EACCES;
8398         }
8399  
8400 +       /* prevent guest processes from circumventing the oom killer */
8401 +       if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
8402 +               oom_adjust = OOM_ADJUST_MIN;
8403 +
8404         task->signal->oom_adj = oom_adjust;
8405  
8406         unlock_task_sighand(task, &flags);
8407 @@ -1088,7 +1095,7 @@ static ssize_t proc_loginuid_write(struc
8408         ssize_t length;
8409         uid_t loginuid;
8410  
8411 -       if (!capable(CAP_AUDIT_CONTROL))
8412 +       if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
8413                 return -EPERM;
8414  
8415         rcu_read_lock();
8416 @@ -1523,6 +1530,8 @@ static struct inode *proc_pid_make_inode
8417                 inode->i_gid = cred->egid;
8418                 rcu_read_unlock();
8419         }
8420 +       /* procfs is xid tagged */
8421 +       inode->i_tag = (tag_t)vx_task_xid(task);
8422         security_task_to_inode(task, inode);
8423  
8424  out:
8425 @@ -2073,6 +2082,13 @@ static struct dentry *proc_pident_lookup
8426         if (!task)
8427                 goto out_no_task;
8428  
8429 +       /* TODO: maybe we can come up with a generic approach? */
8430 +       if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8431 +               (dentry->d_name.len == 5) &&
8432 +               (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8433 +               !memcmp(dentry->d_name.name, "ninfo", 5)))
8434 +               goto out;
8435 +
8436         /*
8437          * Yes, it does not scale. And it should not. Don't add
8438          * new entries into /proc/<tgid>/ without very good reasons.
8439 @@ -2478,7 +2494,7 @@ out_iput:
8440  static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8441  {
8442         struct dentry *error;
8443 -       struct task_struct *task = get_proc_task(dir);
8444 +       struct task_struct *task = get_proc_task_real(dir);
8445         const struct pid_entry *p, *last;
8446  
8447         error = ERR_PTR(-ENOENT);
8448 @@ -2568,6 +2584,9 @@ static int proc_pid_personality(struct s
8449  static const struct file_operations proc_task_operations;
8450  static const struct inode_operations proc_task_inode_operations;
8451  
8452 +extern int proc_pid_vx_info(struct task_struct *, char *);
8453 +extern int proc_pid_nx_info(struct task_struct *, char *);
8454 +
8455  static const struct pid_entry tgid_base_stuff[] = {
8456         DIR("task",       S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
8457         DIR("fd",         S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
8458 @@ -2627,6 +2646,8 @@ static const struct pid_entry tgid_base_
8459  #ifdef CONFIG_CGROUPS
8460         REG("cgroup",  S_IRUGO, proc_cgroup_operations),
8461  #endif
8462 +       INF("vinfo",      S_IRUGO, proc_pid_vx_info),
8463 +       INF("ninfo",      S_IRUGO, proc_pid_nx_info),
8464         INF("oom_score",  S_IRUGO, proc_oom_score),
8465         REG("oom_adj",    S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
8466  #ifdef CONFIG_AUDITSYSCALL
8467 @@ -2642,6 +2663,7 @@ static const struct pid_entry tgid_base_
8468  #ifdef CONFIG_TASK_IO_ACCOUNTING
8469         INF("io",       S_IRUGO, proc_tgid_io_accounting),
8470  #endif
8471 +       ONE("nsproxy",  S_IRUGO, proc_pid_nsproxy),
8472  };
8473  
8474  static int proc_tgid_base_readdir(struct file * filp,
8475 @@ -2833,7 +2855,7 @@ retry:
8476         iter.task = NULL;
8477         pid = find_ge_pid(iter.tgid, ns);
8478         if (pid) {
8479 -               iter.tgid = pid_nr_ns(pid, ns);
8480 +               iter.tgid = pid_unmapped_nr_ns(pid, ns);
8481                 iter.task = pid_task(pid, PIDTYPE_PID);
8482                 /* What we to know is if the pid we have find is the
8483                  * pid of a thread_group_leader.  Testing for task
8484 @@ -2863,7 +2885,7 @@ static int proc_pid_fill_cache(struct fi
8485         struct tgid_iter iter)
8486  {
8487         char name[PROC_NUMBUF];
8488 -       int len = snprintf(name, sizeof(name), "%d", iter.tgid);
8489 +       int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
8490         return proc_fill_cache(filp, dirent, filldir, name, len,
8491                                 proc_pid_instantiate, iter.task, NULL);
8492  }
8493 @@ -2872,7 +2894,7 @@ static int proc_pid_fill_cache(struct fi
8494  int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8495  {
8496         unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8497 -       struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8498 +       struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8499         struct tgid_iter iter;
8500         struct pid_namespace *ns;
8501  
8502 @@ -2892,6 +2914,8 @@ int proc_pid_readdir(struct file * filp,
8503              iter.task;
8504              iter.tgid += 1, iter = next_tgid(ns, iter)) {
8505                 filp->f_pos = iter.tgid + TGID_OFFSET;
8506 +               if (!vx_proc_task_visible(iter.task))
8507 +                       continue;
8508                 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
8509                         put_task_struct(iter.task);
8510                         goto out;
8511 @@ -3039,6 +3063,8 @@ static struct dentry *proc_task_lookup(s
8512         tid = name_to_int(dentry);
8513         if (tid == ~0U)
8514                 goto out;
8515 +       if (vx_current_initpid(tid))
8516 +               goto out;
8517  
8518         ns = dentry->d_sb->s_fs_info;
8519         rcu_read_lock();
8520 diff -NurpP --minimal linux-2.6.34/fs/proc/generic.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/generic.c
8521 --- linux-2.6.34/fs/proc/generic.c      2010-05-18 15:07:52.000000000 +0200
8522 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/generic.c 2010-05-18 18:11:22.000000000 +0200
8523 @@ -21,6 +21,7 @@
8524  #include <linux/bitops.h>
8525  #include <linux/spinlock.h>
8526  #include <linux/completion.h>
8527 +#include <linux/vserver/inode.h>
8528  #include <asm/uaccess.h>
8529  
8530  #include "internal.h"
8531 @@ -433,6 +434,8 @@ struct dentry *proc_lookup_de(struct pro
8532         for (de = de->subdir; de ; de = de->next) {
8533                 if (de->namelen != dentry->d_name.len)
8534                         continue;
8535 +                       if (!vx_hide_check(0, de->vx_flags))
8536 +                               continue;
8537                 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8538                         unsigned int ino;
8539  
8540 @@ -441,6 +444,8 @@ struct dentry *proc_lookup_de(struct pro
8541                         spin_unlock(&proc_subdir_lock);
8542                         error = -EINVAL;
8543                         inode = proc_get_inode(dir->i_sb, ino, de);
8544 +                               /* generic proc entries belong to the host */
8545 +                               inode->i_tag = 0;
8546                         goto out_unlock;
8547                 }
8548         }
8549 @@ -518,6 +523,8 @@ int proc_readdir_de(struct proc_dir_entr
8550  
8551                                 /* filldir passes info to user space */
8552                                 pde_get(de);
8553 +                               if (!vx_hide_check(0, de->vx_flags))
8554 +                                       goto skip;
8555                                 spin_unlock(&proc_subdir_lock);
8556                                 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8557                                             de->low_ino, de->mode >> 12) < 0) {
8558 @@ -525,6 +532,7 @@ int proc_readdir_de(struct proc_dir_entr
8559                                         goto out;
8560                                 }
8561                                 spin_lock(&proc_subdir_lock);
8562 +                       skip:
8563                                 filp->f_pos++;
8564                                 next = de->next;
8565                                 pde_put(de);
8566 @@ -639,6 +647,7 @@ static struct proc_dir_entry *__proc_cre
8567         ent->nlink = nlink;
8568         atomic_set(&ent->count, 1);
8569         ent->pde_users = 0;
8570 +       ent->vx_flags = IATTR_PROC_DEFAULT;
8571         spin_lock_init(&ent->pde_unload_lock);
8572         ent->pde_unload_completion = NULL;
8573         INIT_LIST_HEAD(&ent->pde_openers);
8574 @@ -662,7 +671,8 @@ struct proc_dir_entry *proc_symlink(cons
8575                                 kfree(ent->data);
8576                                 kfree(ent);
8577                                 ent = NULL;
8578 -                       }
8579 +                       } else
8580 +                               ent->vx_flags = IATTR_PROC_SYMLINK;
8581                 } else {
8582                         kfree(ent);
8583                         ent = NULL;
8584 diff -NurpP --minimal linux-2.6.34/fs/proc/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/inode.c
8585 --- linux-2.6.34/fs/proc/inode.c        2010-05-18 15:07:52.000000000 +0200
8586 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/inode.c   2010-05-18 18:11:22.000000000 +0200
8587 @@ -437,6 +437,8 @@ struct inode *proc_get_inode(struct supe
8588                         inode->i_uid = de->uid;
8589                         inode->i_gid = de->gid;
8590                 }
8591 +               if (de->vx_flags)
8592 +                       PROC_I(inode)->vx_flags = de->vx_flags;
8593                 if (de->size)
8594                         inode->i_size = de->size;
8595                 if (de->nlink)
8596 diff -NurpP --minimal linux-2.6.34/fs/proc/internal.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/internal.h
8597 --- linux-2.6.34/fs/proc/internal.h     2010-02-25 11:52:06.000000000 +0100
8598 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/internal.h        2010-05-18 18:11:22.000000000 +0200
8599 @@ -10,6 +10,7 @@
8600   */
8601  
8602  #include <linux/proc_fs.h>
8603 +#include <linux/vs_pid.h>
8604  
8605  extern struct proc_dir_entry proc_root;
8606  #ifdef CONFIG_PROC_SYSCTL
8607 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
8608                                 struct pid *pid, struct task_struct *task);
8609  extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
8610                                 struct pid *pid, struct task_struct *task);
8611 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8612 +                               struct pid *pid, struct task_struct *task);
8613 +
8614  extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
8615  
8616  extern const struct file_operations proc_maps_operations;
8617 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
8618         return PROC_I(inode)->pid;
8619  }
8620  
8621 -static inline struct task_struct *get_proc_task(struct inode *inode)
8622 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
8623  {
8624         return get_pid_task(proc_pid(inode), PIDTYPE_PID);
8625  }
8626  
8627 +static inline struct task_struct *get_proc_task(struct inode *inode)
8628 +{
8629 +       return vx_get_proc_task(inode, proc_pid(inode));
8630 +}
8631 +
8632  static inline int proc_fd(struct inode *inode)
8633  {
8634         return PROC_I(inode)->fd;
8635 diff -NurpP --minimal linux-2.6.34/fs/proc/loadavg.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/loadavg.c
8636 --- linux-2.6.34/fs/proc/loadavg.c      2009-09-10 15:26:23.000000000 +0200
8637 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/loadavg.c 2010-05-18 18:11:22.000000000 +0200
8638 @@ -12,15 +12,27 @@
8639  
8640  static int loadavg_proc_show(struct seq_file *m, void *v)
8641  {
8642 +       unsigned long running;
8643 +       unsigned int threads;
8644         unsigned long avnrun[3];
8645  
8646         get_avenrun(avnrun, FIXED_1/200, 0);
8647  
8648 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
8649 +               struct vx_info *vxi = current_vx_info();
8650 +
8651 +               running = atomic_read(&vxi->cvirt.nr_running);
8652 +               threads = atomic_read(&vxi->cvirt.nr_threads);
8653 +       } else {
8654 +               running = nr_running();
8655 +               threads = nr_threads;
8656 +       }
8657 +
8658         seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
8659                 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
8660                 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
8661                 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
8662 -               nr_running(), nr_threads,
8663 +               running, threads,
8664                 task_active_pid_ns(current)->last_pid);
8665         return 0;
8666  }
8667 diff -NurpP --minimal linux-2.6.34/fs/proc/meminfo.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/meminfo.c
8668 --- linux-2.6.34/fs/proc/meminfo.c      2009-12-03 20:02:53.000000000 +0100
8669 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/meminfo.c 2010-05-18 18:11:22.000000000 +0200
8670 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
8671         allowed = ((totalram_pages - hugetlb_total_pages())
8672                 * sysctl_overcommit_ratio / 100) + total_swap_pages;
8673  
8674 -       cached = global_page_state(NR_FILE_PAGES) -
8675 +       cached = vx_flags(VXF_VIRT_MEM, 0) ?
8676 +               vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
8677                         total_swapcache_pages - i.bufferram;
8678         if (cached < 0)
8679                 cached = 0;
8680 diff -NurpP --minimal linux-2.6.34/fs/proc/root.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/root.c
8681 --- linux-2.6.34/fs/proc/root.c 2010-05-18 15:07:52.000000000 +0200
8682 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/root.c    2010-05-18 18:11:22.000000000 +0200
8683 @@ -18,9 +18,14 @@
8684  #include <linux/bitops.h>
8685  #include <linux/mount.h>
8686  #include <linux/pid_namespace.h>
8687 +#include <linux/vserver/inode.h>
8688  
8689  #include "internal.h"
8690  
8691 +struct proc_dir_entry *proc_virtual;
8692 +
8693 +extern void proc_vx_init(void);
8694 +
8695  static int proc_test_super(struct super_block *sb, void *data)
8696  {
8697         return sb->s_fs_info == data;
8698 @@ -136,6 +141,7 @@ void __init proc_root_init(void)
8699  #endif
8700         proc_mkdir("bus", NULL);
8701         proc_sys_init();
8702 +       proc_vx_init();
8703  }
8704  
8705  static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
8706 @@ -203,6 +209,7 @@ struct proc_dir_entry proc_root = {
8707         .proc_iops      = &proc_root_inode_operations, 
8708         .proc_fops      = &proc_root_operations,
8709         .parent         = &proc_root,
8710 +       .vx_flags       = IATTR_ADMIN | IATTR_WATCH,
8711  };
8712  
8713  int pid_ns_prepare_proc(struct pid_namespace *ns)
8714 diff -NurpP --minimal linux-2.6.34/fs/proc/uptime.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/uptime.c
8715 --- linux-2.6.34/fs/proc/uptime.c       2009-12-03 20:02:53.000000000 +0100
8716 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/proc/uptime.c  2010-05-18 18:11:22.000000000 +0200
8717 @@ -4,22 +4,22 @@
8718  #include <linux/sched.h>
8719  #include <linux/seq_file.h>
8720  #include <linux/time.h>
8721 -#include <linux/kernel_stat.h>
8722 +#include <linux/vserver/cvirt.h>
8723  #include <asm/cputime.h>
8724  
8725  static int uptime_proc_show(struct seq_file *m, void *v)
8726  {
8727         struct timespec uptime;
8728         struct timespec idle;
8729 -       int i;
8730 -       cputime_t idletime = cputime_zero;
8731 -
8732 -       for_each_possible_cpu(i)
8733 -               idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
8734 +       cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
8735  
8736         do_posix_clock_monotonic_gettime(&uptime);
8737         monotonic_to_bootbased(&uptime);
8738         cputime_to_timespec(idletime, &idle);
8739 +
8740 +       if (vx_flags(VXF_VIRT_UPTIME, 0))
8741 +               vx_vsi_uptime(&uptime, &idle);
8742 +
8743         seq_printf(m, "%lu.%02lu %lu.%02lu\n",
8744                         (unsigned long) uptime.tv_sec,
8745                         (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
8746 diff -NurpP --minimal linux-2.6.34/fs/quota/quota.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/quota/quota.c
8747 --- linux-2.6.34/fs/quota/quota.c       2010-05-18 15:07:52.000000000 +0200
8748 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/quota/quota.c  2010-05-18 18:11:22.000000000 +0200
8749 @@ -8,6 +8,7 @@
8750  #include <linux/fs.h>
8751  #include <linux/namei.h>
8752  #include <linux/slab.h>
8753 +#include <linux/vs_context.h>
8754  #include <asm/current.h>
8755  #include <asm/uaccess.h>
8756  #include <linux/kernel.h>
8757 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
8758                         break;
8759                 /*FALLTHROUGH*/
8760         default:
8761 -               if (!capable(CAP_SYS_ADMIN))
8762 +               if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8763                         return -EPERM;
8764         }
8765  
8766 @@ -275,6 +276,46 @@ static int do_quotactl(struct super_bloc
8767         }
8768  }
8769  
8770 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8771 +
8772 +#include <linux/vroot.h>
8773 +#include <linux/major.h>
8774 +#include <linux/module.h>
8775 +#include <linux/kallsyms.h>
8776 +#include <linux/vserver/debug.h>
8777 +
8778 +static vroot_grb_func *vroot_get_real_bdev = NULL;
8779 +
8780 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
8781 +
8782 +int register_vroot_grb(vroot_grb_func *func) {
8783 +       int ret = -EBUSY;
8784 +
8785 +       spin_lock(&vroot_grb_lock);
8786 +       if (!vroot_get_real_bdev) {
8787 +               vroot_get_real_bdev = func;
8788 +               ret = 0;
8789 +       }
8790 +       spin_unlock(&vroot_grb_lock);
8791 +       return ret;
8792 +}
8793 +EXPORT_SYMBOL(register_vroot_grb);
8794 +
8795 +int unregister_vroot_grb(vroot_grb_func *func) {
8796 +       int ret = -EINVAL;
8797 +
8798 +       spin_lock(&vroot_grb_lock);
8799 +       if (vroot_get_real_bdev) {
8800 +               vroot_get_real_bdev = NULL;
8801 +               ret = 0;
8802 +       }
8803 +       spin_unlock(&vroot_grb_lock);
8804 +       return ret;
8805 +}
8806 +EXPORT_SYMBOL(unregister_vroot_grb);
8807 +
8808 +#endif
8809 +
8810  /*
8811   * look up a superblock on which quota ops will be performed
8812   * - use the name of a block device to find the superblock thereon
8813 @@ -292,6 +333,22 @@ static struct super_block *quotactl_bloc
8814         putname(tmp);
8815         if (IS_ERR(bdev))
8816                 return ERR_CAST(bdev);
8817 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8818 +       if (bdev && bdev->bd_inode &&
8819 +                       imajor(bdev->bd_inode) == VROOT_MAJOR) {
8820 +               struct block_device *bdnew = (void *)-EINVAL;
8821 +
8822 +               if (vroot_get_real_bdev)
8823 +                       bdnew = vroot_get_real_bdev(bdev);
8824 +               else
8825 +                       vxdprintk(VXD_CBIT(misc, 0),
8826 +                                       "vroot_get_real_bdev not set");
8827 +               bdput(bdev);
8828 +               if (IS_ERR(bdnew))
8829 +                       return ERR_PTR(PTR_ERR(bdnew));
8830 +               bdev = bdnew;
8831 +       }
8832 +#endif
8833         sb = get_super(bdev);
8834         bdput(bdev);
8835         if (!sb)
8836 diff -NurpP --minimal linux-2.6.34/fs/reiserfs/file.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/file.c
8837 --- linux-2.6.34/fs/reiserfs/file.c     2010-05-18 15:07:52.000000000 +0200
8838 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/file.c        2010-05-18 18:11:22.000000000 +0200
8839 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
8840         .listxattr = reiserfs_listxattr,
8841         .removexattr = reiserfs_removexattr,
8842         .permission = reiserfs_permission,
8843 +       .sync_flags = reiserfs_sync_flags,
8844  };
8845 diff -NurpP --minimal linux-2.6.34/fs/reiserfs/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/inode.c
8846 --- linux-2.6.34/fs/reiserfs/inode.c    2010-05-18 15:07:52.000000000 +0200
8847 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/inode.c       2010-05-18 18:11:22.000000000 +0200
8848 @@ -19,6 +19,7 @@
8849  #include <linux/writeback.h>
8850  #include <linux/quotaops.h>
8851  #include <linux/swap.h>
8852 +#include <linux/vs_tag.h>
8853  
8854  int reiserfs_commit_write(struct file *f, struct page *page,
8855                           unsigned from, unsigned to);
8856 @@ -1125,6 +1126,8 @@ static void init_inode(struct inode *ino
8857         struct buffer_head *bh;
8858         struct item_head *ih;
8859         __u32 rdev;
8860 +       uid_t uid;
8861 +       gid_t gid;
8862         //int version = ITEM_VERSION_1;
8863  
8864         bh = PATH_PLAST_BUFFER(path);
8865 @@ -1146,12 +1149,13 @@ static void init_inode(struct inode *ino
8866                     (struct stat_data_v1 *)B_I_PITEM(bh, ih);
8867                 unsigned long blocks;
8868  
8869 +               uid = sd_v1_uid(sd);
8870 +               gid = sd_v1_gid(sd);
8871 +
8872                 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
8873                 set_inode_sd_version(inode, STAT_DATA_V1);
8874                 inode->i_mode = sd_v1_mode(sd);
8875                 inode->i_nlink = sd_v1_nlink(sd);
8876 -               inode->i_uid = sd_v1_uid(sd);
8877 -               inode->i_gid = sd_v1_gid(sd);
8878                 inode->i_size = sd_v1_size(sd);
8879                 inode->i_atime.tv_sec = sd_v1_atime(sd);
8880                 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
8881 @@ -1193,11 +1197,12 @@ static void init_inode(struct inode *ino
8882                 // (directories and symlinks)
8883                 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
8884  
8885 +               uid    = sd_v2_uid(sd);
8886 +               gid    = sd_v2_gid(sd);
8887 +
8888                 inode->i_mode = sd_v2_mode(sd);
8889                 inode->i_nlink = sd_v2_nlink(sd);
8890 -               inode->i_uid = sd_v2_uid(sd);
8891                 inode->i_size = sd_v2_size(sd);
8892 -               inode->i_gid = sd_v2_gid(sd);
8893                 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
8894                 inode->i_atime.tv_sec = sd_v2_atime(sd);
8895                 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
8896 @@ -1227,6 +1232,10 @@ static void init_inode(struct inode *ino
8897                 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
8898         }
8899  
8900 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8901 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8902 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
8903 +
8904         pathrelse(path);
8905         if (S_ISREG(inode->i_mode)) {
8906                 inode->i_op = &reiserfs_file_inode_operations;
8907 @@ -1249,13 +1258,15 @@ static void init_inode(struct inode *ino
8908  static void inode2sd(void *sd, struct inode *inode, loff_t size)
8909  {
8910         struct stat_data *sd_v2 = (struct stat_data *)sd;
8911 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
8912 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
8913         __u16 flags;
8914  
8915 +       set_sd_v2_uid(sd_v2, uid);
8916 +       set_sd_v2_gid(sd_v2, gid);
8917         set_sd_v2_mode(sd_v2, inode->i_mode);
8918         set_sd_v2_nlink(sd_v2, inode->i_nlink);
8919 -       set_sd_v2_uid(sd_v2, inode->i_uid);
8920         set_sd_v2_size(sd_v2, size);
8921 -       set_sd_v2_gid(sd_v2, inode->i_gid);
8922         set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
8923         set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
8924         set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
8925 @@ -2856,14 +2867,19 @@ int reiserfs_commit_write(struct file *f
8926  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
8927  {
8928         if (reiserfs_attrs(inode->i_sb)) {
8929 -               if (sd_attrs & REISERFS_SYNC_FL)
8930 -                       inode->i_flags |= S_SYNC;
8931 -               else
8932 -                       inode->i_flags &= ~S_SYNC;
8933                 if (sd_attrs & REISERFS_IMMUTABLE_FL)
8934                         inode->i_flags |= S_IMMUTABLE;
8935                 else
8936                         inode->i_flags &= ~S_IMMUTABLE;
8937 +               if (sd_attrs & REISERFS_IXUNLINK_FL)
8938 +                       inode->i_flags |= S_IXUNLINK;
8939 +               else
8940 +                       inode->i_flags &= ~S_IXUNLINK;
8941 +
8942 +               if (sd_attrs & REISERFS_SYNC_FL)
8943 +                       inode->i_flags |= S_SYNC;
8944 +               else
8945 +                       inode->i_flags &= ~S_SYNC;
8946                 if (sd_attrs & REISERFS_APPEND_FL)
8947                         inode->i_flags |= S_APPEND;
8948                 else
8949 @@ -2876,6 +2892,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
8950                         REISERFS_I(inode)->i_flags |= i_nopack_mask;
8951                 else
8952                         REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
8953 +
8954 +               if (sd_attrs & REISERFS_BARRIER_FL)
8955 +                       inode->i_vflags |= V_BARRIER;
8956 +               else
8957 +                       inode->i_vflags &= ~V_BARRIER;
8958 +               if (sd_attrs & REISERFS_COW_FL)
8959 +                       inode->i_vflags |= V_COW;
8960 +               else
8961 +                       inode->i_vflags &= ~V_COW;
8962         }
8963  }
8964  
8965 @@ -2886,6 +2911,11 @@ void i_attrs_to_sd_attrs(struct inode *i
8966                         *sd_attrs |= REISERFS_IMMUTABLE_FL;
8967                 else
8968                         *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
8969 +               if (inode->i_flags & S_IXUNLINK)
8970 +                       *sd_attrs |= REISERFS_IXUNLINK_FL;
8971 +               else
8972 +                       *sd_attrs &= ~REISERFS_IXUNLINK_FL;
8973 +
8974                 if (inode->i_flags & S_SYNC)
8975                         *sd_attrs |= REISERFS_SYNC_FL;
8976                 else
8977 @@ -2898,6 +2928,15 @@ void i_attrs_to_sd_attrs(struct inode *i
8978                         *sd_attrs |= REISERFS_NOTAIL_FL;
8979                 else
8980                         *sd_attrs &= ~REISERFS_NOTAIL_FL;
8981 +
8982 +               if (inode->i_vflags & V_BARRIER)
8983 +                       *sd_attrs |= REISERFS_BARRIER_FL;
8984 +               else
8985 +                       *sd_attrs &= ~REISERFS_BARRIER_FL;
8986 +               if (inode->i_vflags & V_COW)
8987 +                       *sd_attrs |= REISERFS_COW_FL;
8988 +               else
8989 +                       *sd_attrs &= ~REISERFS_COW_FL;
8990         }
8991  }
8992  
8993 @@ -3121,9 +3160,11 @@ int reiserfs_setattr(struct dentry *dent
8994         }
8995  
8996         error = inode_change_ok(inode, attr);
8997 +
8998         if (!error) {
8999                 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
9000 -                   (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
9001 +                   (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
9002 +                   (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
9003                         error = reiserfs_chown_xattrs(inode, attr);
9004  
9005                         if (!error) {
9006 @@ -3152,6 +3193,9 @@ int reiserfs_setattr(struct dentry *dent
9007                                         inode->i_uid = attr->ia_uid;
9008                                 if (attr->ia_valid & ATTR_GID)
9009                                         inode->i_gid = attr->ia_gid;
9010 +                               if ((attr->ia_valid & ATTR_TAG) &&
9011 +                                       IS_TAGGED(inode))
9012 +                                       inode->i_tag = attr->ia_tag;
9013                                 mark_inode_dirty(inode);
9014                                 error =
9015                                     journal_end(&th, inode->i_sb, jbegin_count);
9016 diff -NurpP --minimal linux-2.6.34/fs/reiserfs/ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/ioctl.c
9017 --- linux-2.6.34/fs/reiserfs/ioctl.c    2010-02-25 11:52:06.000000000 +0100
9018 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/ioctl.c       2010-05-18 18:11:22.000000000 +0200
9019 @@ -7,11 +7,27 @@
9020  #include <linux/mount.h>
9021  #include <linux/reiserfs_fs.h>
9022  #include <linux/time.h>
9023 +#include <linux/mount.h>
9024  #include <asm/uaccess.h>
9025  #include <linux/pagemap.h>
9026  #include <linux/smp_lock.h>
9027  #include <linux/compat.h>
9028  
9029 +
9030 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
9031 +{
9032 +       __u16 sd_attrs = 0;
9033 +
9034 +       inode->i_flags = flags;
9035 +       inode->i_vflags = vflags;
9036 +
9037 +       i_attrs_to_sd_attrs(inode, &sd_attrs);
9038 +       REISERFS_I(inode)->i_attrs = sd_attrs;
9039 +       inode->i_ctime = CURRENT_TIME_SEC;
9040 +       mark_inode_dirty(inode);
9041 +       return 0;
9042 +}
9043 +
9044  /*
9045   * reiserfs_ioctl - handler for ioctl for inode
9046   * supported commands:
9047 @@ -23,7 +39,7 @@
9048  long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
9049  {
9050         struct inode *inode = filp->f_path.dentry->d_inode;
9051 -       unsigned int flags;
9052 +       unsigned int flags, oldflags;
9053         int err = 0;
9054  
9055         reiserfs_write_lock(inode->i_sb);
9056 @@ -48,6 +64,7 @@ long reiserfs_ioctl(struct file *filp, u
9057  
9058                 flags = REISERFS_I(inode)->i_attrs;
9059                 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
9060 +               flags &= REISERFS_FL_USER_VISIBLE;
9061                 err = put_user(flags, (int __user *)arg);
9062                 break;
9063         case REISERFS_IOC_SETFLAGS:{
9064 @@ -68,6 +85,10 @@ long reiserfs_ioctl(struct file *filp, u
9065                                 err = -EFAULT;
9066                                 goto setflags_out;
9067                         }
9068 +                       if (IS_BARRIER(inode)) {
9069 +                               vxwprintk_task(1, "messing with the barrier.");
9070 +                               return -EACCES;
9071 +                       }
9072                         /*
9073                          * Is it quota file? Do not allow user to mess with it
9074                          */
9075 @@ -92,6 +113,10 @@ long reiserfs_ioctl(struct file *filp, u
9076                                         goto setflags_out;
9077                                 }
9078                         }
9079 +
9080 +                       oldflags = REISERFS_I(inode)->i_attrs;
9081 +                       flags &= REISERFS_FL_USER_MODIFIABLE;
9082 +                       flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
9083                         sd_attrs_to_i_attrs(flags, inode);
9084                         REISERFS_I(inode)->i_attrs = flags;
9085                         inode->i_ctime = CURRENT_TIME_SEC;
9086 diff -NurpP --minimal linux-2.6.34/fs/reiserfs/namei.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/namei.c
9087 --- linux-2.6.34/fs/reiserfs/namei.c    2010-05-18 15:07:52.000000000 +0200
9088 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/namei.c       2010-05-18 18:11:22.000000000 +0200
9089 @@ -18,6 +18,7 @@
9090  #include <linux/reiserfs_acl.h>
9091  #include <linux/reiserfs_xattr.h>
9092  #include <linux/quotaops.h>
9093 +#include <linux/vs_tag.h>
9094  
9095  #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; }
9096  #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
9097 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
9098         if (retval == IO_ERROR) {
9099                 return ERR_PTR(-EIO);
9100         }
9101 +               dx_propagate_tag(nd, inode);
9102  
9103         return d_splice_alias(inode, dentry);
9104  }
9105 @@ -578,6 +580,7 @@ static int new_inode_init(struct inode *
9106         } else {
9107                 inode->i_gid = current_fsgid();
9108         }
9109 +       inode->i_tag = dx_current_fstag(inode->i_sb);
9110         dquot_initialize(inode);
9111         return 0;
9112  }
9113 @@ -1542,6 +1545,7 @@ const struct inode_operations reiserfs_d
9114         .listxattr = reiserfs_listxattr,
9115         .removexattr = reiserfs_removexattr,
9116         .permission = reiserfs_permission,
9117 +       .sync_flags = reiserfs_sync_flags,
9118  };
9119  
9120  /*
9121 diff -NurpP --minimal linux-2.6.34/fs/reiserfs/super.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/super.c
9122 --- linux-2.6.34/fs/reiserfs/super.c    2010-05-18 15:07:52.000000000 +0200
9123 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/super.c       2010-05-18 18:11:22.000000000 +0200
9124 @@ -887,6 +887,14 @@ static int reiserfs_parse_options(struct
9125                 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9126                 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9127  #endif
9128 +#ifndef CONFIG_TAGGING_NONE
9129 +               {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9130 +               {"tag",.setmask = 1 << REISERFS_TAGGED},
9131 +               {"notag",.clrmask = 1 << REISERFS_TAGGED},
9132 +#endif
9133 +#ifdef CONFIG_PROPAGATE
9134 +               {"tag",.arg_required = 'T',.values = NULL},
9135 +#endif
9136  #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9137                 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9138                 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9139 @@ -1196,6 +1204,14 @@ static int reiserfs_remount(struct super
9140         handle_quota_files(s, qf_names, &qfmt);
9141  #endif
9142  
9143 +       if ((mount_options & (1 << REISERFS_TAGGED)) &&
9144 +               !(s->s_flags & MS_TAGGED)) {
9145 +               reiserfs_warning(s, "super-vs01",
9146 +                       "reiserfs: tagging not permitted on remount.");
9147 +               err = -EINVAL;
9148 +               goto out_err;
9149 +       }
9150 +
9151         handle_attrs(s);
9152  
9153         /* Add options that are safe here */
9154 @@ -1672,6 +1688,10 @@ static int reiserfs_fill_super(struct su
9155                 goto error;
9156         }
9157  
9158 +       /* map mount option tagxid */
9159 +       if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9160 +               s->s_flags |= MS_TAGGED;
9161 +
9162         rs = SB_DISK_SUPER_BLOCK(s);
9163         /* Let's do basic sanity check to verify that underlying device is not
9164            smaller than the filesystem. If the check fails then abort and scream,
9165 diff -NurpP --minimal linux-2.6.34/fs/reiserfs/xattr.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/xattr.c
9166 --- linux-2.6.34/fs/reiserfs/xattr.c    2010-05-18 15:07:52.000000000 +0200
9167 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/reiserfs/xattr.c       2010-05-18 18:11:22.000000000 +0200
9168 @@ -40,6 +40,7 @@
9169  #include <linux/errno.h>
9170  #include <linux/gfp.h>
9171  #include <linux/fs.h>
9172 +#include <linux/mount.h>
9173  #include <linux/file.h>
9174  #include <linux/pagemap.h>
9175  #include <linux/xattr.h>
9176 diff -NurpP --minimal linux-2.6.34/fs/stat.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/stat.c
9177 --- linux-2.6.34/fs/stat.c      2010-02-25 11:52:06.000000000 +0100
9178 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/stat.c 2010-05-18 18:11:22.000000000 +0200
9179 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9180         stat->nlink = inode->i_nlink;
9181         stat->uid = inode->i_uid;
9182         stat->gid = inode->i_gid;
9183 +       stat->tag = inode->i_tag;
9184         stat->rdev = inode->i_rdev;
9185         stat->atime = inode->i_atime;
9186         stat->mtime = inode->i_mtime;
9187 diff -NurpP --minimal linux-2.6.34/fs/super.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/super.c
9188 --- linux-2.6.34/fs/super.c     2010-05-18 15:07:52.000000000 +0200
9189 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/super.c        2010-05-18 18:15:42.000000000 +0200
9190 @@ -38,6 +38,9 @@
9191  #include <linux/mutex.h>
9192  #include <linux/file.h>
9193  #include <linux/backing-dev.h>
9194 +#include <linux/devpts_fs.h>
9195 +#include <linux/proc_fs.h>
9196 +#include <linux/vs_context.h>
9197  #include <asm/uaccess.h>
9198  #include "internal.h"
9199  
9200 @@ -928,12 +931,18 @@ struct vfsmount *
9201  vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9202  {
9203         struct vfsmount *mnt;
9204 +       struct super_block *sb;
9205         char *secdata = NULL;
9206         int error;
9207  
9208         if (!type)
9209                 return ERR_PTR(-ENODEV);
9210  
9211 +       error = -EPERM;
9212 +       if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9213 +               !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9214 +               goto out;
9215 +
9216         error = -ENOMEM;
9217         mnt = alloc_vfsmnt(name);
9218         if (!mnt)
9219 @@ -955,10 +964,18 @@ vfs_kern_mount(struct file_system_type *
9220         error = type->get_sb(type, flags, name, data, mnt);
9221         if (error < 0)
9222                 goto out_free_secdata;
9223 -       BUG_ON(!mnt->mnt_sb);
9224 -       WARN_ON(!mnt->mnt_sb->s_bdi);
9225 +
9226 +       sb = mnt->mnt_sb;
9227 +       BUG_ON(!sb);
9228 +       WARN_ON(!sb->s_bdi);
9229  
9230 -       error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
9231 +       error = -EPERM;
9232 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9233 +               (sb->s_magic != PROC_SUPER_MAGIC) &&
9234 +               (sb->s_magic != DEVPTS_SUPER_MAGIC))
9235 +               goto out_sb;
9236 +
9237 +       error = security_sb_kern_mount(sb, flags, secdata);
9238         if (error)
9239                 goto out_sb;
9240  
9241 diff -NurpP --minimal linux-2.6.34/fs/sysfs/mount.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/sysfs/mount.c
9242 --- linux-2.6.34/fs/sysfs/mount.c       2010-05-18 15:07:52.000000000 +0200
9243 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/sysfs/mount.c  2010-05-18 18:11:22.000000000 +0200
9244 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
9245  
9246         sb->s_blocksize = PAGE_CACHE_SIZE;
9247         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9248 -       sb->s_magic = SYSFS_MAGIC;
9249 +       sb->s_magic = SYSFS_SUPER_MAGIC;
9250         sb->s_op = &sysfs_ops;
9251         sb->s_time_gran = 1;
9252  
9253 diff -NurpP --minimal linux-2.6.34/fs/utimes.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/utimes.c
9254 --- linux-2.6.34/fs/utimes.c    2009-03-24 14:22:37.000000000 +0100
9255 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/utimes.c       2010-05-18 18:11:22.000000000 +0200
9256 @@ -8,6 +8,8 @@
9257  #include <linux/stat.h>
9258  #include <linux/utime.h>
9259  #include <linux/syscalls.h>
9260 +#include <linux/mount.h>
9261 +#include <linux/vs_cowbl.h>
9262  #include <asm/uaccess.h>
9263  #include <asm/unistd.h>
9264  
9265 diff -NurpP --minimal linux-2.6.34/fs/xattr.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xattr.c
9266 --- linux-2.6.34/fs/xattr.c     2010-02-25 11:52:06.000000000 +0100
9267 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xattr.c        2010-05-18 18:11:22.000000000 +0200
9268 @@ -18,6 +18,7 @@
9269  #include <linux/module.h>
9270  #include <linux/fsnotify.h>
9271  #include <linux/audit.h>
9272 +#include <linux/mount.h>
9273  #include <asm/uaccess.h>
9274  
9275  
9276 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
9277          * The trusted.* namespace can only be accessed by a privileged user.
9278          */
9279         if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
9280 -               return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
9281 +               return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
9282  
9283         /* In user.* namespace, only regular files and directories can have
9284          * extended attributes. For sticky directories, only the owner and
9285 diff -NurpP --minimal linux-2.6.34/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/linux-2.6/xfs_ioctl.c
9286 --- linux-2.6.34/fs/xfs/linux-2.6/xfs_ioctl.c   2010-05-18 15:07:52.000000000 +0200
9287 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/linux-2.6/xfs_ioctl.c      2010-05-18 18:11:22.000000000 +0200
9288 @@ -34,7 +34,6 @@
9289  #include "xfs_dir2_sf.h"
9290  #include "xfs_dinode.h"
9291  #include "xfs_inode.h"
9292 -#include "xfs_ioctl.h"
9293  #include "xfs_btree.h"
9294  #include "xfs_ialloc.h"
9295  #include "xfs_rtalloc.h"
9296 @@ -744,6 +743,10 @@ xfs_merge_ioc_xflags(
9297                 xflags |= XFS_XFLAG_IMMUTABLE;
9298         else
9299                 xflags &= ~XFS_XFLAG_IMMUTABLE;
9300 +       if (flags & FS_IXUNLINK_FL)
9301 +               xflags |= XFS_XFLAG_IXUNLINK;
9302 +       else
9303 +               xflags &= ~XFS_XFLAG_IXUNLINK;
9304         if (flags & FS_APPEND_FL)
9305                 xflags |= XFS_XFLAG_APPEND;
9306         else
9307 @@ -772,6 +775,8 @@ xfs_di2lxflags(
9308  
9309         if (di_flags & XFS_DIFLAG_IMMUTABLE)
9310                 flags |= FS_IMMUTABLE_FL;
9311 +       if (di_flags & XFS_DIFLAG_IXUNLINK)
9312 +               flags |= FS_IXUNLINK_FL;
9313         if (di_flags & XFS_DIFLAG_APPEND)
9314                 flags |= FS_APPEND_FL;
9315         if (di_flags & XFS_DIFLAG_SYNC)
9316 @@ -830,6 +835,8 @@ xfs_set_diflags(
9317         di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
9318         if (xflags & XFS_XFLAG_IMMUTABLE)
9319                 di_flags |= XFS_DIFLAG_IMMUTABLE;
9320 +       if (xflags & XFS_XFLAG_IXUNLINK)
9321 +               di_flags |= XFS_DIFLAG_IXUNLINK;
9322         if (xflags & XFS_XFLAG_APPEND)
9323                 di_flags |= XFS_DIFLAG_APPEND;
9324         if (xflags & XFS_XFLAG_SYNC)
9325 @@ -872,6 +879,10 @@ xfs_diflags_to_linux(
9326                 inode->i_flags |= S_IMMUTABLE;
9327         else
9328                 inode->i_flags &= ~S_IMMUTABLE;
9329 +       if (xflags & XFS_XFLAG_IXUNLINK)
9330 +               inode->i_flags |= S_IXUNLINK;
9331 +       else
9332 +               inode->i_flags &= ~S_IXUNLINK;
9333         if (xflags & XFS_XFLAG_APPEND)
9334                 inode->i_flags |= S_APPEND;
9335         else
9336 @@ -1348,10 +1359,18 @@ xfs_file_ioctl(
9337         case XFS_IOC_FSGETXATTRA:
9338                 return xfs_ioc_fsgetxattr(ip, 1, arg);
9339         case XFS_IOC_FSSETXATTR:
9340 +               if (IS_BARRIER(inode)) {
9341 +                       vxwprintk_task(1, "messing with the barrier.");
9342 +                       return -XFS_ERROR(EACCES);
9343 +               }
9344                 return xfs_ioc_fssetxattr(ip, filp, arg);
9345         case XFS_IOC_GETXFLAGS:
9346                 return xfs_ioc_getxflags(ip, arg);
9347         case XFS_IOC_SETXFLAGS:
9348 +               if (IS_BARRIER(inode)) {
9349 +                       vxwprintk_task(1, "messing with the barrier.");
9350 +                       return -XFS_ERROR(EACCES);
9351 +               }
9352                 return xfs_ioc_setxflags(ip, filp, arg);
9353  
9354         case XFS_IOC_FSSETDM: {
9355 diff -NurpP --minimal linux-2.6.34/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/linux-2.6/xfs_ioctl.h
9356 --- linux-2.6.34/fs/xfs/linux-2.6/xfs_ioctl.h   2010-05-18 15:07:52.000000000 +0200
9357 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/linux-2.6/xfs_ioctl.h      2010-05-18 18:11:22.000000000 +0200
9358 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
9359         void __user             *uhandle,
9360         u32                     hlen);
9361  
9362 +extern int
9363 +xfs_sync_flags(
9364 +       struct inode            *inode,
9365 +       int                     flags,
9366 +       int                     vflags);
9367 +
9368  extern long
9369  xfs_file_ioctl(
9370         struct file             *filp,
9371 diff -NurpP --minimal linux-2.6.34/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/linux-2.6/xfs_iops.c
9372 --- linux-2.6.34/fs/xfs/linux-2.6/xfs_iops.c    2010-05-18 15:07:52.000000000 +0200
9373 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/linux-2.6/xfs_iops.c       2010-05-18 18:11:22.000000000 +0200
9374 @@ -36,6 +36,7 @@
9375  #include "xfs_attr_sf.h"
9376  #include "xfs_dinode.h"
9377  #include "xfs_inode.h"
9378 +#include "xfs_ioctl.h"
9379  #include "xfs_bmap.h"
9380  #include "xfs_btree.h"
9381  #include "xfs_ialloc.h"
9382 @@ -57,6 +58,7 @@
9383  #include <linux/falloc.h>
9384  #include <linux/fiemap.h>
9385  #include <linux/slab.h>
9386 +#include <linux/vs_tag.h>
9387  
9388  /*
9389   * Bring the timestamps in the XFS inode uptodate.
9390 @@ -507,6 +509,7 @@ xfs_vn_getattr(
9391         stat->nlink = ip->i_d.di_nlink;
9392         stat->uid = ip->i_d.di_uid;
9393         stat->gid = ip->i_d.di_gid;
9394 +       stat->tag = ip->i_d.di_tag;
9395         stat->ino = ip->i_ino;
9396         stat->atime = inode->i_atime;
9397         stat->mtime = inode->i_mtime;
9398 @@ -698,6 +701,7 @@ static const struct inode_operations xfs
9399         .listxattr              = xfs_vn_listxattr,
9400         .fallocate              = xfs_vn_fallocate,
9401         .fiemap                 = xfs_vn_fiemap,
9402 +       .sync_flags             = xfs_sync_flags,
9403  };
9404  
9405  static const struct inode_operations xfs_dir_inode_operations = {
9406 @@ -723,6 +727,7 @@ static const struct inode_operations xfs
9407         .getxattr               = generic_getxattr,
9408         .removexattr            = generic_removexattr,
9409         .listxattr              = xfs_vn_listxattr,
9410 +       .sync_flags             = xfs_sync_flags,
9411  };
9412  
9413  static const struct inode_operations xfs_dir_ci_inode_operations = {
9414 @@ -772,6 +777,10 @@ xfs_diflags_to_iflags(
9415                 inode->i_flags |= S_IMMUTABLE;
9416         else
9417                 inode->i_flags &= ~S_IMMUTABLE;
9418 +       if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
9419 +               inode->i_flags |= S_IXUNLINK;
9420 +       else
9421 +               inode->i_flags &= ~S_IXUNLINK;
9422         if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
9423                 inode->i_flags |= S_APPEND;
9424         else
9425 @@ -784,6 +793,15 @@ xfs_diflags_to_iflags(
9426                 inode->i_flags |= S_NOATIME;
9427         else
9428                 inode->i_flags &= ~S_NOATIME;
9429 +
9430 +       if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
9431 +               inode->i_vflags |= V_BARRIER;
9432 +       else
9433 +               inode->i_vflags &= ~V_BARRIER;
9434 +       if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
9435 +               inode->i_vflags |= V_COW;
9436 +       else
9437 +               inode->i_vflags &= ~V_COW;
9438  }
9439  
9440  /*
9441 @@ -812,6 +830,7 @@ xfs_setup_inode(
9442         inode->i_nlink  = ip->i_d.di_nlink;
9443         inode->i_uid    = ip->i_d.di_uid;
9444         inode->i_gid    = ip->i_d.di_gid;
9445 +       inode->i_tag    = ip->i_d.di_tag;
9446  
9447         switch (inode->i_mode & S_IFMT) {
9448         case S_IFBLK:
9449 diff -NurpP --minimal linux-2.6.34/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/linux-2.6/xfs_linux.h
9450 --- linux-2.6.34/fs/xfs/linux-2.6/xfs_linux.h   2010-05-18 15:07:52.000000000 +0200
9451 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/linux-2.6/xfs_linux.h      2010-05-18 18:11:22.000000000 +0200
9452 @@ -117,6 +117,7 @@
9453  
9454  #define current_cpu()          (raw_smp_processor_id())
9455  #define current_pid()          (current->pid)
9456 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
9457  #define current_test_flags(f)  (current->flags & (f))
9458  #define current_set_flags_nested(sp, f)                \
9459                 (*(sp) = current->flags, current->flags |= (f))
9460 diff -NurpP --minimal linux-2.6.34/fs/xfs/linux-2.6/xfs_super.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/linux-2.6/xfs_super.c
9461 --- linux-2.6.34/fs/xfs/linux-2.6/xfs_super.c   2010-05-18 15:07:52.000000000 +0200
9462 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/linux-2.6/xfs_super.c      2010-05-18 18:11:22.000000000 +0200
9463 @@ -119,6 +119,9 @@ mempool_t *xfs_ioend_pool;
9464  #define MNTOPT_DMAPI   "dmapi"         /* DMI enabled (DMAPI / XDSM) */
9465  #define MNTOPT_XDSM    "xdsm"          /* DMI enabled (DMAPI / XDSM) */
9466  #define MNTOPT_DMI     "dmi"           /* DMI enabled (DMAPI / XDSM) */
9467 +#define MNTOPT_TAGXID  "tagxid"        /* context tagging for inodes */
9468 +#define MNTOPT_TAGGED  "tag"           /* context tagging for inodes */
9469 +#define MNTOPT_NOTAGTAG        "notag"         /* do not use context tagging */
9470  
9471  /*
9472   * Table driven mount option parser.
9473 @@ -127,10 +130,14 @@ mempool_t *xfs_ioend_pool;
9474   * in the future, too.
9475   */
9476  enum {
9477 +       Opt_tag, Opt_notag,
9478         Opt_barrier, Opt_nobarrier, Opt_err
9479  };
9480  
9481  static const match_table_t tokens = {
9482 +       {Opt_tag, "tagxid"},
9483 +       {Opt_tag, "tag"},
9484 +       {Opt_notag, "notag"},
9485         {Opt_barrier, "barrier"},
9486         {Opt_nobarrier, "nobarrier"},
9487         {Opt_err, NULL}
9488 @@ -384,6 +391,19 @@ xfs_parseargs(
9489                 } else if (!strcmp(this_char, "irixsgid")) {
9490                         cmn_err(CE_WARN,
9491         "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
9492 +#ifndef CONFIG_TAGGING_NONE
9493 +               } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9494 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9495 +               } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
9496 +                       mp->m_flags &= ~XFS_MOUNT_TAGGED;
9497 +               } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
9498 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9499 +#endif
9500 +#ifdef CONFIG_PROPAGATE
9501 +               } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9502 +                       /* use value */
9503 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9504 +#endif
9505                 } else {
9506                         cmn_err(CE_WARN,
9507                                 "XFS: unknown mount option [%s].", this_char);
9508 @@ -1363,6 +1383,16 @@ xfs_fs_remount(
9509                 case Opt_nobarrier:
9510                         mp->m_flags &= ~XFS_MOUNT_BARRIER;
9511                         break;
9512 +               case Opt_tag:
9513 +                       if (!(sb->s_flags & MS_TAGGED)) {
9514 +                               printk(KERN_INFO
9515 +                                       "XFS: %s: tagging not permitted on remount.\n",
9516 +                                       sb->s_id);
9517 +                               return -EINVAL;
9518 +                       }
9519 +                       break;
9520 +               case Opt_notag:
9521 +                       break;
9522                 default:
9523                         /*
9524                          * Logically we would return an error here to prevent
9525 @@ -1597,6 +1627,9 @@ xfs_fs_fill_super(
9526  
9527         XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
9528  
9529 +       if (mp->m_flags & XFS_MOUNT_TAGGED)
9530 +               sb->s_flags |= MS_TAGGED;
9531 +
9532         sb->s_magic = XFS_SB_MAGIC;
9533         sb->s_blocksize = mp->m_sb.sb_blocksize;
9534         sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
9535 diff -NurpP --minimal linux-2.6.34/fs/xfs/xfs_dinode.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_dinode.h
9536 --- linux-2.6.34/fs/xfs/xfs_dinode.h    2009-06-11 17:13:09.000000000 +0200
9537 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_dinode.h       2010-05-18 18:11:22.000000000 +0200
9538 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
9539         __be32          di_gid;         /* owner's group id */
9540         __be32          di_nlink;       /* number of links to file */
9541         __be16          di_projid;      /* owner's project id */
9542 -       __u8            di_pad[8];      /* unused, zeroed space */
9543 +       __be16          di_tag;         /* context tagging */
9544 +       __be16          di_vflags;      /* vserver specific flags */
9545 +       __u8            di_pad[4];      /* unused, zeroed space */
9546         __be16          di_flushiter;   /* incremented on flush */
9547         xfs_timestamp_t di_atime;       /* time last accessed */
9548         xfs_timestamp_t di_mtime;       /* time last modified */
9549 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
9550  #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
9551  #define XFS_DIFLAG_NODEFRAG_BIT     13 /* do not reorganize/defragment */
9552  #define XFS_DIFLAG_FILESTREAM_BIT   14  /* use filestream allocator */
9553 +#define XFS_DIFLAG_IXUNLINK_BIT     15 /* Immutable inver on unlink */
9554 +
9555  #define XFS_DIFLAG_REALTIME      (1 << XFS_DIFLAG_REALTIME_BIT)
9556  #define XFS_DIFLAG_PREALLOC      (1 << XFS_DIFLAG_PREALLOC_BIT)
9557  #define XFS_DIFLAG_NEWRTBM       (1 << XFS_DIFLAG_NEWRTBM_BIT)
9558 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
9559  #define XFS_DIFLAG_EXTSZINHERIT  (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
9560  #define XFS_DIFLAG_NODEFRAG      (1 << XFS_DIFLAG_NODEFRAG_BIT)
9561  #define XFS_DIFLAG_FILESTREAM    (1 << XFS_DIFLAG_FILESTREAM_BIT)
9562 +#define XFS_DIFLAG_IXUNLINK      (1 << XFS_DIFLAG_IXUNLINK_BIT)
9563  
9564  #ifdef CONFIG_XFS_RT
9565  #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
9566 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
9567          XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
9568          XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
9569          XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
9570 -        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
9571 +        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
9572 +        XFS_DIFLAG_IXUNLINK)
9573 +
9574 +#define XFS_DIVFLAG_BARRIER    0x01
9575 +#define XFS_DIVFLAG_COW                0x02
9576  
9577  #endif /* __XFS_DINODE_H__ */
9578 diff -NurpP --minimal linux-2.6.34/fs/xfs/xfs_fs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_fs.h
9579 --- linux-2.6.34/fs/xfs/xfs_fs.h        2010-05-18 15:07:52.000000000 +0200
9580 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_fs.h   2010-05-18 18:11:22.000000000 +0200
9581 @@ -67,6 +67,9 @@ struct fsxattr {
9582  #define XFS_XFLAG_EXTSZINHERIT 0x00001000      /* inherit inode extent size */
9583  #define XFS_XFLAG_NODEFRAG     0x00002000      /* do not defragment */
9584  #define XFS_XFLAG_FILESTREAM   0x00004000      /* use filestream allocator */
9585 +#define XFS_XFLAG_IXUNLINK     0x00008000      /* immutable invert on unlink */
9586 +#define XFS_XFLAG_BARRIER      0x10000000      /* chroot() barrier */
9587 +#define XFS_XFLAG_COW          0x20000000      /* copy on write mark */
9588  #define XFS_XFLAG_HASATTR      0x80000000      /* no DIFLAG for this   */
9589  
9590  /*
9591 @@ -293,7 +296,8 @@ typedef struct xfs_bstat {
9592         __u32           bs_gen;         /* generation count             */
9593         __u16           bs_projid;      /* project id                   */
9594         __u16           bs_forkoff;     /* inode fork offset in bytes   */
9595 -       unsigned char   bs_pad[12];     /* pad space, unused            */
9596 +       __u16           bs_tag;         /* context tagging              */
9597 +       unsigned char   bs_pad[10];     /* pad space, unused            */
9598         __u32           bs_dmevmask;    /* DMIG event mask              */
9599         __u16           bs_dmstate;     /* DMIG state info              */
9600         __u16           bs_aextents;    /* attribute number of extents  */
9601 diff -NurpP --minimal linux-2.6.34/fs/xfs/xfs_ialloc.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_ialloc.c
9602 --- linux-2.6.34/fs/xfs/xfs_ialloc.c    2010-05-18 15:07:52.000000000 +0200
9603 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_ialloc.c       2010-05-18 18:11:22.000000000 +0200
9604 @@ -41,7 +41,6 @@
9605  #include "xfs_error.h"
9606  #include "xfs_bmap.h"
9607  
9608 -
9609  /*
9610   * Allocation group level functions.
9611   */
9612 diff -NurpP --minimal linux-2.6.34/fs/xfs/xfs_inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_inode.c
9613 --- linux-2.6.34/fs/xfs/xfs_inode.c     2010-05-18 15:07:52.000000000 +0200
9614 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_inode.c        2010-05-18 18:11:22.000000000 +0200
9615 @@ -249,6 +249,7 @@ xfs_inotobp(
9616         return 0;
9617  }
9618  
9619 +#include <linux/vs_tag.h>
9620  
9621  /*
9622   * This routine is called to map an inode to the buffer containing
9623 @@ -654,15 +655,25 @@ xfs_iformat_btree(
9624  STATIC void
9625  xfs_dinode_from_disk(
9626         xfs_icdinode_t          *to,
9627 -       xfs_dinode_t            *from)
9628 +       xfs_dinode_t            *from,
9629 +       int tagged)
9630  {
9631 +       uint32_t uid, gid, tag;
9632 +
9633         to->di_magic = be16_to_cpu(from->di_magic);
9634         to->di_mode = be16_to_cpu(from->di_mode);
9635         to->di_version = from ->di_version;
9636         to->di_format = from->di_format;
9637         to->di_onlink = be16_to_cpu(from->di_onlink);
9638 -       to->di_uid = be32_to_cpu(from->di_uid);
9639 -       to->di_gid = be32_to_cpu(from->di_gid);
9640 +
9641 +       uid = be32_to_cpu(from->di_uid);
9642 +       gid = be32_to_cpu(from->di_gid);
9643 +       tag = be16_to_cpu(from->di_tag);
9644 +
9645 +       to->di_uid = INOTAG_UID(tagged, uid, gid);
9646 +       to->di_gid = INOTAG_GID(tagged, uid, gid);
9647 +       to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
9648 +
9649         to->di_nlink = be32_to_cpu(from->di_nlink);
9650         to->di_projid = be16_to_cpu(from->di_projid);
9651         memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
9652 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
9653         to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
9654         to->di_dmstate  = be16_to_cpu(from->di_dmstate);
9655         to->di_flags    = be16_to_cpu(from->di_flags);
9656 +       to->di_vflags   = be16_to_cpu(from->di_vflags);
9657         to->di_gen      = be32_to_cpu(from->di_gen);
9658  }
9659  
9660  void
9661  xfs_dinode_to_disk(
9662         xfs_dinode_t            *to,
9663 -       xfs_icdinode_t          *from)
9664 +       xfs_icdinode_t          *from,
9665 +       int tagged)
9666  {
9667         to->di_magic = cpu_to_be16(from->di_magic);
9668         to->di_mode = cpu_to_be16(from->di_mode);
9669         to->di_version = from ->di_version;
9670         to->di_format = from->di_format;
9671         to->di_onlink = cpu_to_be16(from->di_onlink);
9672 -       to->di_uid = cpu_to_be32(from->di_uid);
9673 -       to->di_gid = cpu_to_be32(from->di_gid);
9674 +
9675 +       to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
9676 +       to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
9677 +       to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
9678 +
9679         to->di_nlink = cpu_to_be32(from->di_nlink);
9680         to->di_projid = cpu_to_be16(from->di_projid);
9681         memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
9682 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
9683         to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
9684         to->di_dmstate = cpu_to_be16(from->di_dmstate);
9685         to->di_flags = cpu_to_be16(from->di_flags);
9686 +       to->di_vflags = cpu_to_be16(from->di_vflags);
9687         to->di_gen = cpu_to_be32(from->di_gen);
9688  }
9689  
9690  STATIC uint
9691  _xfs_dic2xflags(
9692 -       __uint16_t              di_flags)
9693 +       __uint16_t              di_flags,
9694 +       __uint16_t              di_vflags)
9695  {
9696         uint                    flags = 0;
9697  
9698 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
9699                         flags |= XFS_XFLAG_PREALLOC;
9700                 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9701                         flags |= XFS_XFLAG_IMMUTABLE;
9702 +               if (di_flags & XFS_DIFLAG_IXUNLINK)
9703 +                       flags |= XFS_XFLAG_IXUNLINK;
9704                 if (di_flags & XFS_DIFLAG_APPEND)
9705                         flags |= XFS_XFLAG_APPEND;
9706                 if (di_flags & XFS_DIFLAG_SYNC)
9707 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
9708                         flags |= XFS_XFLAG_FILESTREAM;
9709         }
9710  
9711 +       if (di_vflags & XFS_DIVFLAG_BARRIER)
9712 +               flags |= FS_BARRIER_FL;
9713 +       if (di_vflags & XFS_DIVFLAG_COW)
9714 +               flags |= FS_COW_FL;
9715         return flags;
9716  }
9717  
9718 @@ -767,7 +791,7 @@ xfs_ip2xflags(
9719  {
9720         xfs_icdinode_t          *dic = &ip->i_d;
9721  
9722 -       return _xfs_dic2xflags(dic->di_flags) |
9723 +       return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
9724                                 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
9725  }
9726  
9727 @@ -775,7 +799,8 @@ uint
9728  xfs_dic2xflags(
9729         xfs_dinode_t            *dip)
9730  {
9731 -       return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
9732 +       return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
9733 +                               be16_to_cpu(dip->di_vflags)) |
9734                                 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
9735  }
9736  
9737 @@ -811,7 +836,6 @@ xfs_iread(
9738         if (error)
9739                 return error;
9740         dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
9741 -
9742         /*
9743          * If we got something that isn't an inode it means someone
9744          * (nfs or dmi) has a stale handle.
9745 @@ -836,7 +860,8 @@ xfs_iread(
9746          * Otherwise, just get the truly permanent information.
9747          */
9748         if (dip->di_mode) {
9749 -               xfs_dinode_from_disk(&ip->i_d, dip);
9750 +               xfs_dinode_from_disk(&ip->i_d, dip,
9751 +                       mp->m_flags & XFS_MOUNT_TAGGED);
9752                 error = xfs_iformat(ip, dip);
9753                 if (error)  {
9754  #ifdef DEBUG
9755 @@ -1036,6 +1061,7 @@ xfs_ialloc(
9756         ASSERT(ip->i_d.di_nlink == nlink);
9757         ip->i_d.di_uid = current_fsuid();
9758         ip->i_d.di_gid = current_fsgid();
9759 +       ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
9760         ip->i_d.di_projid = prid;
9761         memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
9762  
9763 @@ -1096,6 +1122,7 @@ xfs_ialloc(
9764         ip->i_d.di_dmevmask = 0;
9765         ip->i_d.di_dmstate = 0;
9766         ip->i_d.di_flags = 0;
9767 +       ip->i_d.di_vflags = 0;
9768         flags = XFS_ILOG_CORE;
9769         switch (mode & S_IFMT) {
9770         case S_IFIFO:
9771 @@ -2137,6 +2164,7 @@ xfs_ifree(
9772         }
9773         ip->i_d.di_mode = 0;            /* mark incore inode as free */
9774         ip->i_d.di_flags = 0;
9775 +       ip->i_d.di_vflags = 0;
9776         ip->i_d.di_dmevmask = 0;
9777         ip->i_d.di_forkoff = 0;         /* mark the attr fork not in use */
9778         ip->i_df.if_ext_max =
9779 @@ -3006,7 +3034,8 @@ xfs_iflush_int(
9780          * because if the inode is dirty at all the core must
9781          * be.
9782          */
9783 -       xfs_dinode_to_disk(dip, &ip->i_d);
9784 +       xfs_dinode_to_disk(dip, &ip->i_d,
9785 +               mp->m_flags & XFS_MOUNT_TAGGED);
9786  
9787         /* Wrap, we never let the log put out DI_MAX_FLUSH */
9788         if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
9789 diff -NurpP --minimal linux-2.6.34/fs/xfs/xfs_inode.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_inode.h
9790 --- linux-2.6.34/fs/xfs/xfs_inode.h     2010-05-18 15:07:52.000000000 +0200
9791 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_inode.h        2010-05-18 18:11:22.000000000 +0200
9792 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
9793         __uint32_t      di_gid;         /* owner's group id */
9794         __uint32_t      di_nlink;       /* number of links to file */
9795         __uint16_t      di_projid;      /* owner's project id */
9796 -       __uint8_t       di_pad[8];      /* unused, zeroed space */
9797 +       __uint16_t      di_tag;         /* context tagging */
9798 +       __uint16_t      di_vflags;      /* vserver specific flags */
9799 +       __uint8_t       di_pad[4];      /* unused, zeroed space */
9800         __uint16_t      di_flushiter;   /* incremented on flush */
9801         xfs_ictimestamp_t di_atime;     /* time last accessed */
9802         xfs_ictimestamp_t di_mtime;     /* time last modified */
9803 @@ -511,7 +513,7 @@ int         xfs_itobp(struct xfs_mount *, struc
9804  int            xfs_iread(struct xfs_mount *, struct xfs_trans *,
9805                           struct xfs_inode *, xfs_daddr_t, uint);
9806  void           xfs_dinode_to_disk(struct xfs_dinode *,
9807 -                                  struct xfs_icdinode *);
9808 +                                  struct xfs_icdinode *, int);
9809  void           xfs_idestroy_fork(struct xfs_inode *, int);
9810  void           xfs_idata_realloc(struct xfs_inode *, int, int);
9811  void           xfs_iroot_realloc(struct xfs_inode *, int, int);
9812 diff -NurpP --minimal linux-2.6.34/fs/xfs/xfs_itable.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_itable.c
9813 --- linux-2.6.34/fs/xfs/xfs_itable.c    2010-05-18 15:07:52.000000000 +0200
9814 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_itable.c       2010-05-18 18:11:22.000000000 +0200
9815 @@ -84,6 +84,7 @@ xfs_bulkstat_one_iget(
9816         buf->bs_mode = dic->di_mode;
9817         buf->bs_uid = dic->di_uid;
9818         buf->bs_gid = dic->di_gid;
9819 +       buf->bs_tag = dic->di_tag;
9820         buf->bs_size = dic->di_size;
9821  
9822         /*
9823 diff -NurpP --minimal linux-2.6.34/fs/xfs/xfs_log_recover.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_log_recover.c
9824 --- linux-2.6.34/fs/xfs/xfs_log_recover.c       2010-05-18 15:07:52.000000000 +0200
9825 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_log_recover.c  2010-05-18 18:11:22.000000000 +0200
9826 @@ -2404,7 +2404,8 @@ xlog_recover_do_inode_trans(
9827         }
9828  
9829         /* The core is in in-core format */
9830 -       xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
9831 +       xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
9832 +               mp->m_flags & XFS_MOUNT_TAGGED);
9833  
9834         /* the rest is in on-disk format */
9835         if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
9836 diff -NurpP --minimal linux-2.6.34/fs/xfs/xfs_mount.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_mount.h
9837 --- linux-2.6.34/fs/xfs/xfs_mount.h     2010-05-18 15:07:52.000000000 +0200
9838 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_mount.h        2010-05-18 18:11:22.000000000 +0200
9839 @@ -301,6 +301,7 @@ typedef struct xfs_mount {
9840                                                    allocator */
9841  #define XFS_MOUNT_NOATTR2      (1ULL << 25)    /* disable use of attr2 format */
9842  
9843 +#define XFS_MOUNT_TAGGED       (1ULL << 31)    /* context tagging */
9844  
9845  /*
9846   * Default minimum read and write sizes.
9847 diff -NurpP --minimal linux-2.6.34/fs/xfs/xfs_vnodeops.c linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_vnodeops.c
9848 --- linux-2.6.34/fs/xfs/xfs_vnodeops.c  2010-05-18 15:07:52.000000000 +0200
9849 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_vnodeops.c     2010-05-18 18:11:22.000000000 +0200
9850 @@ -55,6 +55,80 @@
9851  #include "xfs_vnodeops.h"
9852  #include "xfs_trace.h"
9853  
9854 +
9855 +STATIC void
9856 +xfs_get_inode_flags(
9857 +       xfs_inode_t     *ip)
9858 +{
9859 +       struct inode    *inode = VFS_I(ip);
9860 +       unsigned int    flags = inode->i_flags;
9861 +       unsigned int    vflags = inode->i_vflags;
9862 +
9863 +       if (flags & S_IMMUTABLE)
9864 +               ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
9865 +       else
9866 +               ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
9867 +       if (flags & S_IXUNLINK)
9868 +               ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
9869 +       else
9870 +               ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
9871 +
9872 +       if (vflags & V_BARRIER)
9873 +               ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
9874 +       else
9875 +               ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
9876 +       if (vflags & V_COW)
9877 +               ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
9878 +       else
9879 +               ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
9880 +}
9881 +
9882 +int
9883 +xfs_sync_flags(
9884 +       struct inode            *inode,
9885 +       int                     flags,
9886 +       int                     vflags)
9887 +{
9888 +       struct xfs_inode        *ip = XFS_I(inode);
9889 +       struct xfs_mount        *mp = ip->i_mount;
9890 +       struct xfs_trans        *tp;
9891 +       unsigned int            lock_flags = 0;
9892 +       int                     code;
9893 +
9894 +       tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
9895 +       code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
9896 +       if (code)
9897 +               goto error_out;
9898 +
9899 +       lock_flags = XFS_ILOCK_EXCL;
9900 +       xfs_ilock(ip, lock_flags);
9901 +
9902 +       xfs_trans_ijoin(tp, ip, lock_flags);
9903 +       xfs_trans_ihold(tp, ip);
9904 +
9905 +       inode->i_flags = flags;
9906 +       inode->i_vflags = vflags;
9907 +       xfs_get_inode_flags(ip);
9908 +
9909 +       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
9910 +       xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
9911 +
9912 +       XFS_STATS_INC(xs_ig_attrchg);
9913 +
9914 +       if (mp->m_flags & XFS_MOUNT_WSYNC)
9915 +               xfs_trans_set_sync(tp);
9916 +       code = xfs_trans_commit(tp, 0);
9917 +       xfs_iunlock(ip, lock_flags);
9918 +       return code;
9919 +
9920 +error_out:
9921 +       xfs_trans_cancel(tp, 0);
9922 +       if (lock_flags)
9923 +               xfs_iunlock(ip, lock_flags);
9924 +       return code;
9925 +}
9926 +
9927 +
9928  int
9929  xfs_setattr(
9930         struct xfs_inode        *ip,
9931 @@ -70,6 +144,7 @@ xfs_setattr(
9932         uint                    commit_flags=0;
9933         uid_t                   uid=0, iuid=0;
9934         gid_t                   gid=0, igid=0;
9935 +       tag_t                   tag=0, itag=0;
9936         struct xfs_dquot        *udqp, *gdqp, *olddquot1, *olddquot2;
9937         int                     need_iolock = 1;
9938  
9939 @@ -162,7 +237,7 @@ xfs_setattr(
9940         /*
9941          * Change file ownership.  Must be the owner or privileged.
9942          */
9943 -       if (mask & (ATTR_UID|ATTR_GID)) {
9944 +       if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9945                 /*
9946                  * These IDs could have changed since we last looked at them.
9947                  * But, we're assured that if the ownership did change
9948 @@ -171,8 +246,10 @@ xfs_setattr(
9949                  */
9950                 iuid = ip->i_d.di_uid;
9951                 igid = ip->i_d.di_gid;
9952 +               itag = ip->i_d.di_tag;
9953                 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
9954                 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
9955 +               tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
9956  
9957                 /*
9958                  * Do a quota reservation only if uid/gid is actually
9959 @@ -180,7 +257,8 @@ xfs_setattr(
9960                  */
9961                 if (XFS_IS_QUOTA_RUNNING(mp) &&
9962                     ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
9963 -                    (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
9964 +                    (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
9965 +                    (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
9966                         ASSERT(tp);
9967                         code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
9968                                                 capable(CAP_FOWNER) ?
9969 @@ -341,7 +419,7 @@ xfs_setattr(
9970         /*
9971          * Change file ownership.  Must be the owner or privileged.
9972          */
9973 -       if (mask & (ATTR_UID|ATTR_GID)) {
9974 +       if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9975                 /*
9976                  * CAP_FSETID overrides the following restrictions:
9977                  *
9978 @@ -357,6 +435,10 @@ xfs_setattr(
9979                  * Change the ownerships and register quota modifications
9980                  * in the transaction.
9981                  */
9982 +               if (itag != tag) {
9983 +                       ip->i_d.di_tag = tag;
9984 +                       inode->i_tag = tag;
9985 +               }
9986                 if (iuid != uid) {
9987                         if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
9988                                 ASSERT(mask & ATTR_UID);
9989 diff -NurpP --minimal linux-2.6.34/fs/xfs/xfs_vnodeops.h linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_vnodeops.h
9990 --- linux-2.6.34/fs/xfs/xfs_vnodeops.h  2010-05-18 15:07:52.000000000 +0200
9991 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/fs/xfs/xfs_vnodeops.h     2010-05-18 18:11:22.000000000 +0200
9992 @@ -14,6 +14,7 @@ struct xfs_inode;
9993  struct xfs_iomap;
9994  
9995  
9996 +int xfs_sync_xflags(struct xfs_inode *ip);
9997  int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
9998  #define        XFS_ATTR_DMI            0x01    /* invocation from a DMI function */
9999  #define        XFS_ATTR_NONBLOCK       0x02    /* return EAGAIN if operation would block */
10000 diff -NurpP --minimal linux-2.6.34/include/asm-generic/tlb.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/asm-generic/tlb.h
10001 --- linux-2.6.34/include/asm-generic/tlb.h      2009-09-10 15:26:24.000000000 +0200
10002 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/asm-generic/tlb.h 2010-05-18 18:11:22.000000000 +0200
10003 @@ -14,6 +14,7 @@
10004  #define _ASM_GENERIC__TLB_H
10005  
10006  #include <linux/swap.h>
10007 +#include <linux/vs_memory.h>
10008  #include <asm/pgalloc.h>
10009  #include <asm/tlbflush.h>
10010  
10011 diff -NurpP --minimal linux-2.6.34/include/linux/capability.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/capability.h
10012 --- linux-2.6.34/include/linux/capability.h     2010-02-25 11:52:07.000000000 +0100
10013 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/capability.h        2010-05-18 18:11:22.000000000 +0200
10014 @@ -283,6 +283,7 @@ struct cpu_vfs_cap_data {
10015     arbitrary SCSI commands */
10016  /* Allow setting encryption key on loopback filesystem */
10017  /* Allow setting zone reclaim policy */
10018 +/* Allow the selection of a security context */
10019  
10020  #define CAP_SYS_ADMIN        21
10021  
10022 @@ -355,7 +356,13 @@ struct cpu_vfs_cap_data {
10023  
10024  #define CAP_MAC_ADMIN        33
10025  
10026 -#define CAP_LAST_CAP         CAP_MAC_ADMIN
10027 +/* Allow context manipulations */
10028 +/* Allow changing context info on files */
10029 +
10030 +#define CAP_CONTEXT         34
10031 +
10032 +
10033 +#define CAP_LAST_CAP         CAP_CONTEXT
10034  
10035  #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
10036  
10037 diff -NurpP --minimal linux-2.6.34/include/linux/devpts_fs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/devpts_fs.h
10038 --- linux-2.6.34/include/linux/devpts_fs.h      2008-12-25 00:26:37.000000000 +0100
10039 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/devpts_fs.h 2010-05-18 18:11:22.000000000 +0200
10040 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
10041  
10042  #endif
10043  
10044 -
10045  #endif /* _LINUX_DEVPTS_FS_H */
10046 diff -NurpP --minimal linux-2.6.34/include/linux/ext2_fs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/ext2_fs.h
10047 --- linux-2.6.34/include/linux/ext2_fs.h        2010-02-25 11:52:07.000000000 +0100
10048 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/ext2_fs.h   2010-05-18 18:11:22.000000000 +0200
10049 @@ -189,8 +189,12 @@ struct ext2_group_desc
10050  #define EXT2_NOTAIL_FL                 FS_NOTAIL_FL    /* file tail should not be merged */
10051  #define EXT2_DIRSYNC_FL                        FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
10052  #define EXT2_TOPDIR_FL                 FS_TOPDIR_FL    /* Top of directory hierarchies*/
10053 +#define EXT2_IXUNLINK_FL               FS_IXUNLINK_FL  /* Immutable invert on unlink */
10054  #define EXT2_RESERVED_FL               FS_RESERVED_FL  /* reserved for ext2 lib */
10055  
10056 +#define EXT2_BARRIER_FL                        FS_BARRIER_FL   /* Barrier for chroot() */
10057 +#define EXT2_COW_FL                    FS_COW_FL       /* Copy on Write marker */
10058 +
10059  #define EXT2_FL_USER_VISIBLE           FS_FL_USER_VISIBLE      /* User visible flags */
10060  #define EXT2_FL_USER_MODIFIABLE                FS_FL_USER_MODIFIABLE   /* User modifiable flags */
10061  
10062 @@ -274,7 +278,8 @@ struct ext2_inode {
10063                         __u16   i_pad1;
10064                         __le16  l_i_uid_high;   /* these 2 fields    */
10065                         __le16  l_i_gid_high;   /* were reserved2[0] */
10066 -                       __u32   l_i_reserved2;
10067 +                       __le16  l_i_tag;        /* Context Tag */
10068 +                       __u16   l_i_reserved2;
10069                 } linux2;
10070                 struct {
10071                         __u8    h_i_frag;       /* Fragment number */
10072 @@ -303,6 +308,7 @@ struct ext2_inode {
10073  #define i_gid_low      i_gid
10074  #define i_uid_high     osd2.linux2.l_i_uid_high
10075  #define i_gid_high     osd2.linux2.l_i_gid_high
10076 +#define i_raw_tag      osd2.linux2.l_i_tag
10077  #define i_reserved2    osd2.linux2.l_i_reserved2
10078  #endif
10079  
10080 @@ -347,6 +353,7 @@ struct ext2_inode {
10081  #define EXT2_MOUNT_USRQUOTA            0x020000  /* user quota */
10082  #define EXT2_MOUNT_GRPQUOTA            0x040000  /* group quota */
10083  #define EXT2_MOUNT_RESERVATION         0x080000  /* Preallocation */
10084 +#define EXT2_MOUNT_TAGGED              (1<<24)   /* Enable Context Tags */
10085  
10086  
10087  #define clear_opt(o, opt)              o &= ~EXT2_MOUNT_##opt
10088 diff -NurpP --minimal linux-2.6.34/include/linux/ext3_fs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/ext3_fs.h
10089 --- linux-2.6.34/include/linux/ext3_fs.h        2010-05-18 15:07:52.000000000 +0200
10090 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/ext3_fs.h   2010-05-18 18:11:22.000000000 +0200
10091 @@ -173,10 +173,14 @@ struct ext3_group_desc
10092  #define EXT3_NOTAIL_FL                 0x00008000 /* file tail should not be merged */
10093  #define EXT3_DIRSYNC_FL                        0x00010000 /* dirsync behaviour (directories only) */
10094  #define EXT3_TOPDIR_FL                 0x00020000 /* Top of directory hierarchies*/
10095 +#define EXT3_IXUNLINK_FL               0x08000000 /* Immutable invert on unlink */
10096  #define EXT3_RESERVED_FL               0x80000000 /* reserved for ext3 lib */
10097  
10098 -#define EXT3_FL_USER_VISIBLE           0x0003DFFF /* User visible flags */
10099 -#define EXT3_FL_USER_MODIFIABLE                0x000380FF /* User modifiable flags */
10100 +#define EXT3_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
10101 +#define EXT3_COW_FL                    0x20000000 /* Copy on Write marker */
10102 +
10103 +#define EXT3_FL_USER_VISIBLE           0x0103DFFF /* User visible flags */
10104 +#define EXT3_FL_USER_MODIFIABLE                0x010380FF /* User modifiable flags */
10105  
10106  /* Flags that should be inherited by new inodes from their parent. */
10107  #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
10108 @@ -312,7 +316,8 @@ struct ext3_inode {
10109                         __u16   i_pad1;
10110                         __le16  l_i_uid_high;   /* these 2 fields    */
10111                         __le16  l_i_gid_high;   /* were reserved2[0] */
10112 -                       __u32   l_i_reserved2;
10113 +                       __le16  l_i_tag;        /* Context Tag */
10114 +                       __u16   l_i_reserved2;
10115                 } linux2;
10116                 struct {
10117                         __u8    h_i_frag;       /* Fragment number */
10118 @@ -343,6 +348,7 @@ struct ext3_inode {
10119  #define i_gid_low      i_gid
10120  #define i_uid_high     osd2.linux2.l_i_uid_high
10121  #define i_gid_high     osd2.linux2.l_i_gid_high
10122 +#define i_raw_tag      osd2.linux2.l_i_tag
10123  #define i_reserved2    osd2.linux2.l_i_reserved2
10124  
10125  #elif defined(__GNU__)
10126 @@ -406,6 +412,7 @@ struct ext3_inode {
10127  #define EXT3_MOUNT_GRPQUOTA            0x200000 /* "old" group quota */
10128  #define EXT3_MOUNT_DATA_ERR_ABORT      0x400000 /* Abort on file data write
10129                                                   * error in ordered mode */
10130 +#define EXT3_MOUNT_TAGGED              (1<<24) /* Enable Context Tags */
10131  
10132  /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
10133  #ifndef _LINUX_EXT2_FS_H
10134 @@ -909,6 +916,7 @@ extern void ext3_get_inode_flags(struct 
10135  extern void ext3_set_aops(struct inode *inode);
10136  extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
10137                        u64 start, u64 len);
10138 +extern int ext3_sync_flags(struct inode *, int, int);
10139  
10140  /* ioctl.c */
10141  extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
10142 diff -NurpP --minimal linux-2.6.34/include/linux/fs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/fs.h
10143 --- linux-2.6.34/include/linux/fs.h     2010-05-18 15:07:52.000000000 +0200
10144 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/fs.h        2010-05-18 18:11:22.000000000 +0200
10145 @@ -209,6 +209,9 @@ struct inodes_stat_t {
10146  #define MS_KERNMOUNT   (1<<22) /* this is a kern_mount call */
10147  #define MS_I_VERSION   (1<<23) /* Update inode I_version field */
10148  #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
10149 +#define MS_TAGGED      (1<<25) /* use generic inode tagging */
10150 +#define MS_TAGID       (1<<26) /* use specific tag for this mount */
10151 +#define MS_NOTAGCHECK  (1<<27) /* don't check tags */
10152  #define MS_ACTIVE      (1<<30)
10153  #define MS_NOUSER      (1<<31)
10154  
10155 @@ -235,6 +238,14 @@ struct inodes_stat_t {
10156  #define S_NOCMTIME     128     /* Do not update file c/mtime */
10157  #define S_SWAPFILE     256     /* Do not truncate: swapon got its bmaps */
10158  #define S_PRIVATE      512     /* Inode is fs-internal */
10159 +#define S_IXUNLINK     1024    /* Immutable Invert on unlink */
10160 +
10161 +/* Linux-VServer related Inode flags */
10162 +
10163 +#define V_VALID                1
10164 +#define V_XATTR                2
10165 +#define V_BARRIER      4       /* Barrier for chroot() */
10166 +#define V_COW          8       /* Copy on Write */
10167  
10168  /*
10169   * Note that nosuid etc flags are inode-specific: setting some file-system
10170 @@ -257,12 +268,15 @@ struct inodes_stat_t {
10171  #define IS_DIRSYNC(inode)      (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
10172                                         ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
10173  #define IS_MANDLOCK(inode)     __IS_FLG(inode, MS_MANDLOCK)
10174 -#define IS_NOATIME(inode)   __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10175 -#define IS_I_VERSION(inode)   __IS_FLG(inode, MS_I_VERSION)
10176 +#define IS_NOATIME(inode)      __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10177 +#define IS_I_VERSION(inode)    __IS_FLG(inode, MS_I_VERSION)
10178 +#define IS_TAGGED(inode)       __IS_FLG(inode, MS_TAGGED)
10179  
10180  #define IS_NOQUOTA(inode)      ((inode)->i_flags & S_NOQUOTA)
10181  #define IS_APPEND(inode)       ((inode)->i_flags & S_APPEND)
10182  #define IS_IMMUTABLE(inode)    ((inode)->i_flags & S_IMMUTABLE)
10183 +#define IS_IXUNLINK(inode)     ((inode)->i_flags & S_IXUNLINK)
10184 +#define IS_IXORUNLINK(inode)   ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
10185  #define IS_POSIXACL(inode)     __IS_FLG(inode, MS_POSIXACL)
10186  
10187  #define IS_DEADDIR(inode)      ((inode)->i_flags & S_DEAD)
10188 @@ -270,6 +284,16 @@ struct inodes_stat_t {
10189  #define IS_SWAPFILE(inode)     ((inode)->i_flags & S_SWAPFILE)
10190  #define IS_PRIVATE(inode)      ((inode)->i_flags & S_PRIVATE)
10191  
10192 +#define IS_BARRIER(inode)      (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
10193 +
10194 +#ifdef CONFIG_VSERVER_COWBL
10195 +#  define IS_COW(inode)                (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
10196 +#  define IS_COW_LINK(inode)   (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
10197 +#else
10198 +#  define IS_COW(inode)                (0)
10199 +#  define IS_COW_LINK(inode)   (0)
10200 +#endif
10201 +
10202  /* the read-only stuff doesn't really belong here, but any other place is
10203     probably as bad and I don't want to create yet another include file. */
10204  
10205 @@ -352,11 +376,14 @@ struct inodes_stat_t {
10206  #define FS_TOPDIR_FL                   0x00020000 /* Top of directory hierarchies*/
10207  #define FS_EXTENT_FL                   0x00080000 /* Extents */
10208  #define FS_DIRECTIO_FL                 0x00100000 /* Use direct i/o */
10209 +#define FS_IXUNLINK_FL                 0x08000000 /* Immutable invert on unlink */
10210  #define FS_RESERVED_FL                 0x80000000 /* reserved for ext2 lib */
10211  
10212 -#define FS_FL_USER_VISIBLE             0x0003DFFF /* User visible flags */
10213 -#define FS_FL_USER_MODIFIABLE          0x000380FF /* User modifiable flags */
10214 +#define FS_BARRIER_FL                  0x04000000 /* Barrier for chroot() */
10215 +#define FS_COW_FL                      0x20000000 /* Copy on Write marker */
10216  
10217 +#define FS_FL_USER_VISIBLE             0x0103DFFF /* User visible flags */
10218 +#define FS_FL_USER_MODIFIABLE          0x010380FF /* User modifiable flags */
10219  
10220  #define SYNC_FILE_RANGE_WAIT_BEFORE    1
10221  #define SYNC_FILE_RANGE_WRITE          2
10222 @@ -438,6 +465,7 @@ typedef void (dio_iodone_t)(struct kiocb
10223  #define ATTR_KILL_PRIV (1 << 14)
10224  #define ATTR_OPEN      (1 << 15) /* Truncating from open(O_TRUNC) */
10225  #define ATTR_TIMES_SET (1 << 16)
10226 +#define ATTR_TAG       (1 << 17)
10227  
10228  /*
10229   * This is the Inode Attributes structure, used for notify_change().  It
10230 @@ -453,6 +481,7 @@ struct iattr {
10231         umode_t         ia_mode;
10232         uid_t           ia_uid;
10233         gid_t           ia_gid;
10234 +       tag_t           ia_tag;
10235         loff_t          ia_size;
10236         struct timespec ia_atime;
10237         struct timespec ia_mtime;
10238 @@ -466,6 +495,9 @@ struct iattr {
10239         struct file     *ia_file;
10240  };
10241  
10242 +#define ATTR_FLAG_BARRIER      512     /* Barrier for chroot() */
10243 +#define ATTR_FLAG_IXUNLINK     1024    /* Immutable invert on unlink */
10244 +
10245  /*
10246   * Includes for diskquotas.
10247   */
10248 @@ -731,7 +763,9 @@ struct inode {
10249         unsigned int            i_nlink;
10250         uid_t                   i_uid;
10251         gid_t                   i_gid;
10252 +       tag_t                   i_tag;
10253         dev_t                   i_rdev;
10254 +       dev_t                   i_mdev;
10255         unsigned int            i_blkbits;
10256         u64                     i_version;
10257         loff_t                  i_size;
10258 @@ -778,7 +812,8 @@ struct inode {
10259         unsigned long           i_state;
10260         unsigned long           dirtied_when;   /* jiffies of first dirtying */
10261  
10262 -       unsigned int            i_flags;
10263 +       unsigned short          i_flags;
10264 +       unsigned short          i_vflags;
10265  
10266         atomic_t                i_writecount;
10267  #ifdef CONFIG_SECURITY
10268 @@ -866,12 +901,12 @@ static inline void i_size_write(struct i
10269  
10270  static inline unsigned iminor(const struct inode *inode)
10271  {
10272 -       return MINOR(inode->i_rdev);
10273 +       return MINOR(inode->i_mdev);
10274  }
10275  
10276  static inline unsigned imajor(const struct inode *inode)
10277  {
10278 -       return MAJOR(inode->i_rdev);
10279 +       return MAJOR(inode->i_mdev);
10280  }
10281  
10282  extern struct block_device *I_BDEV(struct inode *inode);
10283 @@ -930,6 +965,7 @@ struct file {
10284         loff_t                  f_pos;
10285         struct fown_struct      f_owner;
10286         const struct cred       *f_cred;
10287 +       xid_t                   f_xid;
10288         struct file_ra_state    f_ra;
10289  
10290         u64                     f_version;
10291 @@ -1071,6 +1107,7 @@ struct file_lock {
10292         struct file *fl_file;
10293         loff_t fl_start;
10294         loff_t fl_end;
10295 +       xid_t fl_xid;
10296  
10297         struct fasync_struct *  fl_fasync; /* for lease break notifications */
10298         unsigned long fl_break_time;    /* for nonblocking lease breaks */
10299 @@ -1534,6 +1571,7 @@ struct inode_operations {
10300         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
10301         ssize_t (*listxattr) (struct dentry *, char *, size_t);
10302         int (*removexattr) (struct dentry *, const char *);
10303 +       int (*sync_flags) (struct inode *, int, int);
10304         void (*truncate_range)(struct inode *, loff_t, loff_t);
10305         long (*fallocate)(struct inode *inode, int mode, loff_t offset,
10306                           loff_t len);
10307 @@ -1554,6 +1592,7 @@ extern ssize_t vfs_readv(struct file *, 
10308                 unsigned long, loff_t *);
10309  extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
10310                 unsigned long, loff_t *);
10311 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
10312  
10313  struct super_operations {
10314         struct inode *(*alloc_inode)(struct super_block *sb);
10315 @@ -2334,6 +2373,7 @@ extern int dcache_dir_open(struct inode 
10316  extern int dcache_dir_close(struct inode *, struct file *);
10317  extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
10318  extern int dcache_readdir(struct file *, void *, filldir_t);
10319 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
10320  extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
10321  extern int simple_statfs(struct dentry *, struct kstatfs *);
10322  extern int simple_link(struct dentry *, struct inode *, struct dentry *);
10323 diff -NurpP --minimal linux-2.6.34/include/linux/gfs2_ondisk.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/gfs2_ondisk.h
10324 --- linux-2.6.34/include/linux/gfs2_ondisk.h    2010-05-18 15:07:52.000000000 +0200
10325 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/gfs2_ondisk.h       2010-05-18 18:11:22.000000000 +0200
10326 @@ -211,6 +211,9 @@ enum {
10327         gfs2fl_NoAtime          = 7,
10328         gfs2fl_Sync             = 8,
10329         gfs2fl_System           = 9,
10330 +       gfs2fl_IXUnlink         = 16,
10331 +       gfs2fl_Barrier          = 17,
10332 +       gfs2fl_Cow              = 18,
10333         gfs2fl_TruncInProg      = 29,
10334         gfs2fl_InheritDirectio  = 30,
10335         gfs2fl_InheritJdata     = 31,
10336 @@ -227,6 +230,9 @@ enum {
10337  #define GFS2_DIF_NOATIME               0x00000080
10338  #define GFS2_DIF_SYNC                  0x00000100
10339  #define GFS2_DIF_SYSTEM                        0x00000200 /* New in gfs2 */
10340 +#define GFS2_DIF_IXUNLINK              0x00010000
10341 +#define GFS2_DIF_BARRIER               0x00020000
10342 +#define GFS2_DIF_COW                   0x00040000
10343  #define GFS2_DIF_TRUNC_IN_PROG         0x20000000 /* New in gfs2 */
10344  #define GFS2_DIF_INHERIT_DIRECTIO      0x40000000
10345  #define GFS2_DIF_INHERIT_JDATA         0x80000000
10346 diff -NurpP --minimal linux-2.6.34/include/linux/if_tun.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/if_tun.h
10347 --- linux-2.6.34/include/linux/if_tun.h 2010-05-18 15:07:52.000000000 +0200
10348 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/if_tun.h    2010-05-18 18:11:22.000000000 +0200
10349 @@ -51,6 +51,7 @@
10350  #define TUNSETSNDBUF   _IOW('T', 212, int)
10351  #define TUNATTACHFILTER _IOW('T', 213, struct sock_fprog)
10352  #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
10353 +#define TUNSETNID     _IOW('T', 215, int)
10354  
10355  /* TUNSETIFF ifr flags */
10356  #define IFF_TUN                0x0001
10357 diff -NurpP --minimal linux-2.6.34/include/linux/init_task.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/init_task.h
10358 --- linux-2.6.34/include/linux/init_task.h      2010-05-18 15:07:52.000000000 +0200
10359 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/init_task.h 2010-05-18 18:11:22.000000000 +0200
10360 @@ -172,6 +172,10 @@ extern struct cred init_cred;
10361         INIT_FTRACE_GRAPH                                               \
10362         INIT_TRACE_RECURSION                                            \
10363         INIT_TASK_RCU_PREEMPT(tsk)                                      \
10364 +       .xid            = 0,                                            \
10365 +       .vx_info        = NULL,                                         \
10366 +       .nid            = 0,                                            \
10367 +       .nx_info        = NULL,                                         \
10368  }
10369  
10370  
10371 diff -NurpP --minimal linux-2.6.34/include/linux/ipc.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/ipc.h
10372 --- linux-2.6.34/include/linux/ipc.h    2009-12-03 20:02:55.000000000 +0100
10373 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/ipc.h       2010-05-18 18:11:22.000000000 +0200
10374 @@ -91,6 +91,7 @@ struct kern_ipc_perm
10375         key_t           key;
10376         uid_t           uid;
10377         gid_t           gid;
10378 +       xid_t           xid;
10379         uid_t           cuid;
10380         gid_t           cgid;
10381         mode_t          mode; 
10382 diff -NurpP --minimal linux-2.6.34/include/linux/Kbuild linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/Kbuild
10383 --- linux-2.6.34/include/linux/Kbuild   2010-05-18 15:07:52.000000000 +0200
10384 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/Kbuild      2010-05-18 18:11:22.000000000 +0200
10385 @@ -386,5 +386,8 @@ unifdef-y += xattr.h
10386  unifdef-y += xfrm.h
10387  
10388  objhdr-y += version.h
10389 +
10390 +header-y += vserver/
10391  header-y += wimax.h
10392  header-y += wimax/
10393 +
10394 diff -NurpP --minimal linux-2.6.34/include/linux/loop.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/loop.h
10395 --- linux-2.6.34/include/linux/loop.h   2009-09-10 15:26:25.000000000 +0200
10396 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/loop.h      2010-05-18 18:11:22.000000000 +0200
10397 @@ -45,6 +45,7 @@ struct loop_device {
10398         struct loop_func_table *lo_encryption;
10399         __u32           lo_init[2];
10400         uid_t           lo_key_owner;   /* Who set the key */
10401 +       xid_t           lo_xid;
10402         int             (*ioctl)(struct loop_device *, int cmd, 
10403                                  unsigned long arg); 
10404  
10405 diff -NurpP --minimal linux-2.6.34/include/linux/magic.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/magic.h
10406 --- linux-2.6.34/include/linux/magic.h  2010-05-18 15:07:52.000000000 +0200
10407 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/magic.h     2010-05-18 18:11:22.000000000 +0200
10408 @@ -3,7 +3,7 @@
10409  
10410  #define ADFS_SUPER_MAGIC       0xadf5
10411  #define AFFS_SUPER_MAGIC       0xadff
10412 -#define AFS_SUPER_MAGIC                0x5346414F
10413 +#define AFS_SUPER_MAGIC                0x5346414F
10414  #define AUTOFS_SUPER_MAGIC     0x0187
10415  #define CODA_SUPER_MAGIC       0x73757245
10416  #define CRAMFS_MAGIC           0x28cd3d45      /* some random number */
10417 @@ -38,6 +38,7 @@
10418  #define NFS_SUPER_MAGIC                0x6969
10419  #define OPENPROM_SUPER_MAGIC   0x9fa1
10420  #define PROC_SUPER_MAGIC       0x9fa0
10421 +#define DEVPTS_SUPER_MAGIC     0x1cd1
10422  #define QNX4_SUPER_MAGIC       0x002f          /* qnx4 fs detection */
10423  
10424  #define REISERFS_SUPER_MAGIC   0x52654973      /* used by gcc */
10425 diff -NurpP --minimal linux-2.6.34/include/linux/major.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/major.h
10426 --- linux-2.6.34/include/linux/major.h  2009-09-10 15:26:25.000000000 +0200
10427 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/major.h     2010-05-18 18:11:22.000000000 +0200
10428 @@ -15,6 +15,7 @@
10429  #define HD_MAJOR               IDE0_MAJOR
10430  #define PTY_SLAVE_MAJOR                3
10431  #define TTY_MAJOR              4
10432 +#define VROOT_MAJOR            4
10433  #define TTYAUX_MAJOR           5
10434  #define LP_MAJOR               6
10435  #define VCS_MAJOR              7
10436 diff -NurpP --minimal linux-2.6.34/include/linux/memcontrol.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/memcontrol.h
10437 --- linux-2.6.34/include/linux/memcontrol.h     2010-05-18 15:07:52.000000000 +0200
10438 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/memcontrol.h        2010-05-18 18:11:22.000000000 +0200
10439 @@ -76,6 +76,13 @@ int task_in_mem_cgroup(struct task_struc
10440  extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
10441  extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
10442  
10443 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
10444 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
10445 +
10446 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
10447 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
10448 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
10449 +
10450  static inline
10451  int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
10452  {
10453 diff -NurpP --minimal linux-2.6.34/include/linux/mm_types.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/mm_types.h
10454 --- linux-2.6.34/include/linux/mm_types.h       2010-05-18 15:07:52.000000000 +0200
10455 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/mm_types.h  2010-05-18 18:11:22.000000000 +0200
10456 @@ -269,6 +269,7 @@ struct mm_struct {
10457  
10458         /* Architecture-specific MM context */
10459         mm_context_t context;
10460 +       struct vx_info *mm_vx_info;
10461  
10462         /* Swap token stuff */
10463         /*
10464 diff -NurpP --minimal linux-2.6.34/include/linux/mount.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/mount.h
10465 --- linux-2.6.34/include/linux/mount.h  2010-05-18 15:07:52.000000000 +0200
10466 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/mount.h     2010-05-18 18:11:22.000000000 +0200
10467 @@ -47,6 +47,9 @@ struct mnt_namespace;
10468  
10469  #define MNT_INTERNAL   0x4000
10470  
10471 +#define MNT_TAGID      0x10000
10472 +#define MNT_NOTAG      0x20000
10473 +
10474  struct vfsmount {
10475         struct list_head mnt_hash;
10476         struct vfsmount *mnt_parent;    /* fs we are mounted on */
10477 @@ -81,6 +84,7 @@ struct vfsmount {
10478  #else
10479         int mnt_writers;
10480  #endif
10481 +       tag_t mnt_tag;                  /* tagging used for vfsmount */
10482  };
10483  
10484  static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
10485 diff -NurpP --minimal linux-2.6.34/include/linux/net.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/net.h
10486 --- linux-2.6.34/include/linux/net.h    2010-05-18 15:07:52.000000000 +0200
10487 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/net.h       2010-05-18 18:11:22.000000000 +0200
10488 @@ -70,6 +70,7 @@ struct net;
10489  #define SOCK_NOSPACE           2
10490  #define SOCK_PASSCRED          3
10491  #define SOCK_PASSSEC           4
10492 +#define SOCK_USER_SOCKET       5
10493  
10494  #ifndef ARCH_HAS_SOCKET_TYPES
10495  /**
10496 diff -NurpP --minimal linux-2.6.34/include/linux/nfs_mount.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/nfs_mount.h
10497 --- linux-2.6.34/include/linux/nfs_mount.h      2009-03-24 14:22:43.000000000 +0100
10498 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/nfs_mount.h 2010-05-18 18:11:22.000000000 +0200
10499 @@ -63,7 +63,8 @@ struct nfs_mount_data {
10500  #define NFS_MOUNT_SECFLAVOUR   0x2000  /* 5 */
10501  #define NFS_MOUNT_NORDIRPLUS   0x4000  /* 5 */
10502  #define NFS_MOUNT_UNSHARED     0x8000  /* 5 */
10503 -#define NFS_MOUNT_FLAGMASK     0xFFFF
10504 +#define NFS_MOUNT_TAGGED       0x10000 /* context tagging */
10505 +#define NFS_MOUNT_FLAGMASK     0x1FFFF
10506  
10507  /* The following are for internal use only */
10508  #define NFS_MOUNT_LOOKUP_CACHE_NONEG   0x10000
10509 diff -NurpP --minimal linux-2.6.34/include/linux/nsproxy.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/nsproxy.h
10510 --- linux-2.6.34/include/linux/nsproxy.h        2009-06-11 17:13:17.000000000 +0200
10511 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/nsproxy.h   2010-05-18 18:11:22.000000000 +0200
10512 @@ -3,6 +3,7 @@
10513  
10514  #include <linux/spinlock.h>
10515  #include <linux/sched.h>
10516 +#include <linux/vserver/debug.h>
10517  
10518  struct mnt_namespace;
10519  struct uts_namespace;
10520 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
10521  }
10522  
10523  int copy_namespaces(unsigned long flags, struct task_struct *tsk);
10524 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
10525  void exit_task_namespaces(struct task_struct *tsk);
10526  void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
10527  void free_nsproxy(struct nsproxy *ns);
10528  int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
10529         struct fs_struct *);
10530  
10531 -static inline void put_nsproxy(struct nsproxy *ns)
10532 +#define        get_nsproxy(n)  __get_nsproxy(n, __FILE__, __LINE__)
10533 +
10534 +static inline void __get_nsproxy(struct nsproxy *ns,
10535 +       const char *_file, int _line)
10536  {
10537 -       if (atomic_dec_and_test(&ns->count)) {
10538 -               free_nsproxy(ns);
10539 -       }
10540 +       vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
10541 +               ns, atomic_read(&ns->count), _file, _line);
10542 +       atomic_inc(&ns->count);
10543  }
10544  
10545 -static inline void get_nsproxy(struct nsproxy *ns)
10546 +#define        put_nsproxy(n)  __put_nsproxy(n, __FILE__, __LINE__)
10547 +
10548 +static inline void __put_nsproxy(struct nsproxy *ns,
10549 +       const char *_file, int _line)
10550  {
10551 -       atomic_inc(&ns->count);
10552 +       vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
10553 +               ns, atomic_read(&ns->count), _file, _line);
10554 +       if (atomic_dec_and_test(&ns->count)) {
10555 +               free_nsproxy(ns);
10556 +       }
10557  }
10558  
10559  #ifdef CONFIG_CGROUP_NS
10560 diff -NurpP --minimal linux-2.6.34/include/linux/pid.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/pid.h
10561 --- linux-2.6.34/include/linux/pid.h    2009-03-24 14:22:43.000000000 +0100
10562 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/pid.h       2010-05-18 18:11:22.000000000 +0200
10563 @@ -8,7 +8,8 @@ enum pid_type
10564         PIDTYPE_PID,
10565         PIDTYPE_PGID,
10566         PIDTYPE_SID,
10567 -       PIDTYPE_MAX
10568 +       PIDTYPE_MAX,
10569 +       PIDTYPE_REALPID
10570  };
10571  
10572  /*
10573 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
10574  }
10575  
10576  pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
10577 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
10578  pid_t pid_vnr(struct pid *pid);
10579  
10580  #define do_each_pid_task(pid, type, task)                              \
10581 diff -NurpP --minimal linux-2.6.34/include/linux/proc_fs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/proc_fs.h
10582 --- linux-2.6.34/include/linux/proc_fs.h        2009-12-03 20:02:56.000000000 +0100
10583 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/proc_fs.h   2010-05-18 18:11:22.000000000 +0200
10584 @@ -56,6 +56,7 @@ struct proc_dir_entry {
10585         nlink_t nlink;
10586         uid_t uid;
10587         gid_t gid;
10588 +       int vx_flags;
10589         loff_t size;
10590         const struct inode_operations *proc_iops;
10591         /*
10592 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void 
10593  extern void kclist_add(struct kcore_list *, void *, size_t, int type);
10594  #endif
10595  
10596 +struct vx_info;
10597 +struct nx_info;
10598 +
10599  union proc_op {
10600         int (*proc_get_link)(struct inode *, struct path *);
10601         int (*proc_read)(struct task_struct *task, char *page);
10602         int (*proc_show)(struct seq_file *m,
10603                 struct pid_namespace *ns, struct pid *pid,
10604                 struct task_struct *task);
10605 +       int (*proc_vs_read)(char *page);
10606 +       int (*proc_vxi_read)(struct vx_info *vxi, char *page);
10607 +       int (*proc_nxi_read)(struct nx_info *nxi, char *page);
10608  };
10609  
10610  struct ctl_table_header;
10611 @@ -263,6 +270,7 @@ struct ctl_table;
10612  
10613  struct proc_inode {
10614         struct pid *pid;
10615 +       int vx_flags;
10616         int fd;
10617         union proc_op op;
10618         struct proc_dir_entry *pde;
10619 diff -NurpP --minimal linux-2.6.34/include/linux/quotaops.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/quotaops.h
10620 --- linux-2.6.34/include/linux/quotaops.h       2010-05-18 15:07:52.000000000 +0200
10621 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/quotaops.h  2010-05-18 18:11:22.000000000 +0200
10622 @@ -8,6 +8,7 @@
10623  #define _LINUX_QUOTAOPS_
10624  
10625  #include <linux/fs.h>
10626 +#include <linux/vs_dlimit.h>
10627  
10628  static inline struct quota_info *sb_dqopt(struct super_block *sb)
10629  {
10630 diff -NurpP --minimal linux-2.6.34/include/linux/reboot.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/reboot.h
10631 --- linux-2.6.34/include/linux/reboot.h 2010-05-18 15:07:52.000000000 +0200
10632 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/reboot.h    2010-05-18 18:11:22.000000000 +0200
10633 @@ -33,6 +33,7 @@
10634  #define        LINUX_REBOOT_CMD_RESTART2       0xA1B2C3D4
10635  #define        LINUX_REBOOT_CMD_SW_SUSPEND     0xD000FCE2
10636  #define        LINUX_REBOOT_CMD_KEXEC          0x45584543
10637 +#define        LINUX_REBOOT_CMD_OOM            0xDEADBEEF
10638  
10639  
10640  #ifdef __KERNEL__
10641 diff -NurpP --minimal linux-2.6.34/include/linux/reiserfs_fs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/reiserfs_fs.h
10642 --- linux-2.6.34/include/linux/reiserfs_fs.h    2010-05-18 15:07:52.000000000 +0200
10643 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/reiserfs_fs.h       2010-05-18 18:11:22.000000000 +0200
10644 @@ -977,6 +977,11 @@ struct stat_data_v1 {
10645  #define REISERFS_COMPR_FL     FS_COMPR_FL
10646  #define REISERFS_NOTAIL_FL    FS_NOTAIL_FL
10647  
10648 +/* unfortunately reiserfs sdattr is only 16 bit */
10649 +#define REISERFS_IXUNLINK_FL  (FS_IXUNLINK_FL >> 16)
10650 +#define REISERFS_BARRIER_FL   (FS_BARRIER_FL >> 16)
10651 +#define REISERFS_COW_FL       (FS_COW_FL >> 16)
10652 +
10653  /* persistent flags that file inherits from the parent directory */
10654  #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL |        \
10655                                 REISERFS_SYNC_FL |      \
10656 @@ -986,6 +991,9 @@ struct stat_data_v1 {
10657                                 REISERFS_COMPR_FL |     \
10658                                 REISERFS_NOTAIL_FL )
10659  
10660 +#define REISERFS_FL_USER_VISIBLE       0x80FF
10661 +#define REISERFS_FL_USER_MODIFIABLE    0x80FF
10662 +
10663  /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10664     address blocks) */
10665  struct stat_data {
10666 @@ -2071,6 +2079,7 @@ static inline void reiserfs_update_sd(st
10667  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10668  void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10669  int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10670 +int reiserfs_sync_flags(struct inode *inode, int, int);
10671  
10672  /* namei.c */
10673  void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
10674 diff -NurpP --minimal linux-2.6.34/include/linux/reiserfs_fs_sb.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/reiserfs_fs_sb.h
10675 --- linux-2.6.34/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
10676 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/reiserfs_fs_sb.h    2010-05-18 18:11:22.000000000 +0200
10677 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
10678         REISERFS_EXPOSE_PRIVROOT,
10679         REISERFS_BARRIER_NONE,
10680         REISERFS_BARRIER_FLUSH,
10681 +       REISERFS_TAGGED,
10682  
10683         /* Actions on error */
10684         REISERFS_ERROR_PANIC,
10685 diff -NurpP --minimal linux-2.6.34/include/linux/sched.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/sched.h
10686 --- linux-2.6.34/include/linux/sched.h  2010-05-18 15:07:52.000000000 +0200
10687 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/sched.h     2010-05-18 18:11:22.000000000 +0200
10688 @@ -1352,6 +1352,14 @@ struct task_struct {
10689  #endif
10690         seccomp_t seccomp;
10691  
10692 +/* vserver context data */
10693 +       struct vx_info *vx_info;
10694 +       struct nx_info *nx_info;
10695 +
10696 +       xid_t xid;
10697 +       nid_t nid;
10698 +       tag_t tag;
10699 +
10700  /* Thread group tracking */
10701         u32 parent_exec_id;
10702         u32 self_exec_id;
10703 @@ -1584,6 +1592,11 @@ struct pid_namespace;
10704  pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
10705                         struct pid_namespace *ns);
10706  
10707 +#include <linux/vserver/base.h>
10708 +#include <linux/vserver/context.h>
10709 +#include <linux/vserver/debug.h>
10710 +#include <linux/vserver/pid.h>
10711 +
10712  static inline pid_t task_pid_nr(struct task_struct *tsk)
10713  {
10714         return tsk->pid;
10715 @@ -1597,7 +1610,8 @@ static inline pid_t task_pid_nr_ns(struc
10716  
10717  static inline pid_t task_pid_vnr(struct task_struct *tsk)
10718  {
10719 -       return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10720 +       // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10721 +       return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
10722  }
10723  
10724  
10725 @@ -1610,7 +1624,7 @@ pid_t task_tgid_nr_ns(struct task_struct
10726  
10727  static inline pid_t task_tgid_vnr(struct task_struct *tsk)
10728  {
10729 -       return pid_vnr(task_tgid(tsk));
10730 +       return vx_map_tgid(pid_vnr(task_tgid(tsk)));
10731  }
10732  
10733  
10734 diff -NurpP --minimal linux-2.6.34/include/linux/shmem_fs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/shmem_fs.h
10735 --- linux-2.6.34/include/linux/shmem_fs.h       2010-02-25 11:52:08.000000000 +0100
10736 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/shmem_fs.h  2010-05-18 18:11:22.000000000 +0200
10737 @@ -8,6 +8,9 @@
10738  
10739  #define SHMEM_NR_DIRECT 16
10740  
10741 +#define TMPFS_SUPER_MAGIC      0x01021994
10742 +
10743 +
10744  struct shmem_inode_info {
10745         spinlock_t              lock;
10746         unsigned long           flags;
10747 diff -NurpP --minimal linux-2.6.34/include/linux/stat.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/stat.h
10748 --- linux-2.6.34/include/linux/stat.h   2008-12-25 00:26:37.000000000 +0100
10749 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/stat.h      2010-05-18 18:11:22.000000000 +0200
10750 @@ -66,6 +66,7 @@ struct kstat {
10751         unsigned int    nlink;
10752         uid_t           uid;
10753         gid_t           gid;
10754 +       tag_t           tag;
10755         dev_t           rdev;
10756         loff_t          size;
10757         struct timespec  atime;
10758 diff -NurpP --minimal linux-2.6.34/include/linux/sunrpc/auth.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/sunrpc/auth.h
10759 --- linux-2.6.34/include/linux/sunrpc/auth.h    2009-12-03 20:02:56.000000000 +0100
10760 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/sunrpc/auth.h       2010-05-18 18:11:22.000000000 +0200
10761 @@ -25,6 +25,7 @@
10762  struct auth_cred {
10763         uid_t   uid;
10764         gid_t   gid;
10765 +       tag_t   tag;
10766         struct group_info *group_info;
10767         unsigned char machine_cred : 1;
10768  };
10769 diff -NurpP --minimal linux-2.6.34/include/linux/sunrpc/clnt.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/sunrpc/clnt.h
10770 --- linux-2.6.34/include/linux/sunrpc/clnt.h    2009-12-03 20:02:56.000000000 +0100
10771 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/sunrpc/clnt.h       2010-05-18 18:11:22.000000000 +0200
10772 @@ -49,7 +49,8 @@ struct rpc_clnt {
10773         unsigned int            cl_softrtry : 1,/* soft timeouts */
10774                                 cl_discrtry : 1,/* disconnect before retry */
10775                                 cl_autobind : 1,/* use getport() */
10776 -                               cl_chatty   : 1;/* be verbose */
10777 +                               cl_chatty   : 1,/* be verbose */
10778 +                               cl_tag      : 1;/* context tagging */
10779  
10780         struct rpc_rtt *        cl_rtt;         /* RTO estimator data */
10781         const struct rpc_timeout *cl_timeout;   /* Timeout strategy */
10782 diff -NurpP --minimal linux-2.6.34/include/linux/syscalls.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/syscalls.h
10783 --- linux-2.6.34/include/linux/syscalls.h       2010-05-18 15:07:52.000000000 +0200
10784 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/syscalls.h  2010-05-18 18:11:22.000000000 +0200
10785 @@ -500,6 +500,8 @@ asmlinkage long sys_symlink(const char _
10786  asmlinkage long sys_unlink(const char __user *pathname);
10787  asmlinkage long sys_rename(const char __user *oldname,
10788                                 const char __user *newname);
10789 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
10790 +                               umode_t mode);
10791  asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
10792  asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
10793  
10794 diff -NurpP --minimal linux-2.6.34/include/linux/sysctl.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/sysctl.h
10795 --- linux-2.6.34/include/linux/sysctl.h 2010-05-18 15:07:52.000000000 +0200
10796 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/sysctl.h    2010-05-18 18:11:22.000000000 +0200
10797 @@ -60,6 +60,7 @@ enum
10798         CTL_ABI=9,              /* Binary emulation */
10799         CTL_CPU=10,             /* CPU stuff (speed scaling, etc) */
10800         CTL_ARLAN=254,          /* arlan wireless driver */
10801 +       CTL_VSERVER=4242,       /* Linux-VServer debug */
10802         CTL_S390DBF=5677,       /* s390 debug */
10803         CTL_SUNRPC=7249,        /* sunrpc debug */
10804         CTL_PM=9899,            /* frv power management */
10805 @@ -94,6 +95,7 @@ enum
10806  
10807         KERN_PANIC=15,          /* int: panic timeout */
10808         KERN_REALROOTDEV=16,    /* real root device to mount after initrd */
10809 +       KERN_VSHELPER=17,       /* string: path to vshelper policy agent */
10810  
10811         KERN_SPARC_REBOOT=21,   /* reboot command on Sparc */
10812         KERN_CTLALTDEL=22,      /* int: allow ctl-alt-del to reboot */
10813 diff -NurpP --minimal linux-2.6.34/include/linux/sysfs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/sysfs.h
10814 --- linux-2.6.34/include/linux/sysfs.h  2010-05-18 15:07:52.000000000 +0200
10815 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/sysfs.h     2010-05-18 18:11:22.000000000 +0200
10816 @@ -18,6 +18,8 @@
10817  #include <linux/lockdep.h>
10818  #include <asm/atomic.h>
10819  
10820 +#define SYSFS_SUPER_MAGIC      0x62656572
10821 +
10822  struct kobject;
10823  struct module;
10824  
10825 diff -NurpP --minimal linux-2.6.34/include/linux/time.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/time.h
10826 --- linux-2.6.34/include/linux/time.h   2010-02-25 11:52:08.000000000 +0100
10827 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/time.h      2010-05-18 18:11:22.000000000 +0200
10828 @@ -238,6 +238,9 @@ static __always_inline void timespec_add
10829         a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
10830         a->tv_nsec = ns;
10831  }
10832 +
10833 +#include <linux/vs_time.h>
10834 +
10835  #endif /* __KERNEL__ */
10836  
10837  #define NFDBITS                        __NFDBITS
10838 diff -NurpP --minimal linux-2.6.34/include/linux/types.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/types.h
10839 --- linux-2.6.34/include/linux/types.h  2009-09-10 15:26:26.000000000 +0200
10840 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/types.h     2010-05-18 18:11:22.000000000 +0200
10841 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t      uid_t;
10842  typedef __kernel_gid32_t       gid_t;
10843  typedef __kernel_uid16_t        uid16_t;
10844  typedef __kernel_gid16_t        gid16_t;
10845 +typedef unsigned int           xid_t;
10846 +typedef unsigned int           nid_t;
10847 +typedef unsigned int           tag_t;
10848  
10849  typedef unsigned long          uintptr_t;
10850  
10851 diff -NurpP --minimal linux-2.6.34/include/linux/vroot.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vroot.h
10852 --- linux-2.6.34/include/linux/vroot.h  1970-01-01 01:00:00.000000000 +0100
10853 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vroot.h     2010-05-18 18:11:22.000000000 +0200
10854 @@ -0,0 +1,51 @@
10855 +
10856 +/*
10857 + * include/linux/vroot.h
10858 + *
10859 + * written by Herbert Pötzl, 9/11/2002
10860 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
10861 + *
10862 + * Copyright (C) 2002-2007 by Herbert Pötzl.
10863 + * Redistribution of this file is permitted under the
10864 + * GNU General Public License.
10865 + */
10866 +
10867 +#ifndef _LINUX_VROOT_H
10868 +#define _LINUX_VROOT_H
10869 +
10870 +
10871 +#ifdef __KERNEL__
10872 +
10873 +/* Possible states of device */
10874 +enum {
10875 +       Vr_unbound,
10876 +       Vr_bound,
10877 +};
10878 +
10879 +struct vroot_device {
10880 +       int             vr_number;
10881 +       int             vr_refcnt;
10882 +
10883 +       struct semaphore        vr_ctl_mutex;
10884 +       struct block_device    *vr_device;
10885 +       int                     vr_state;
10886 +};
10887 +
10888 +
10889 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
10890 +
10891 +extern int register_vroot_grb(vroot_grb_func *);
10892 +extern int unregister_vroot_grb(vroot_grb_func *);
10893 +
10894 +#endif /* __KERNEL__ */
10895 +
10896 +#define MAX_VROOT_DEFAULT      8
10897 +
10898 +/*
10899 + * IOCTL commands --- we will commandeer 0x56 ('V')
10900 + */
10901 +
10902 +#define VROOT_SET_DEV          0x5600
10903 +#define VROOT_CLR_DEV          0x5601
10904 +
10905 +#endif /* _LINUX_VROOT_H */
10906 diff -NurpP --minimal linux-2.6.34/include/linux/vs_base.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_base.h
10907 --- linux-2.6.34/include/linux/vs_base.h        1970-01-01 01:00:00.000000000 +0100
10908 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_base.h   2010-05-18 18:11:22.000000000 +0200
10909 @@ -0,0 +1,10 @@
10910 +#ifndef _VS_BASE_H
10911 +#define _VS_BASE_H
10912 +
10913 +#include "vserver/base.h"
10914 +#include "vserver/check.h"
10915 +#include "vserver/debug.h"
10916 +
10917 +#else
10918 +#warning duplicate inclusion
10919 +#endif
10920 diff -NurpP --minimal linux-2.6.34/include/linux/vs_context.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_context.h
10921 --- linux-2.6.34/include/linux/vs_context.h     1970-01-01 01:00:00.000000000 +0100
10922 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_context.h        2010-05-18 18:11:22.000000000 +0200
10923 @@ -0,0 +1,242 @@
10924 +#ifndef _VS_CONTEXT_H
10925 +#define _VS_CONTEXT_H
10926 +
10927 +#include "vserver/base.h"
10928 +#include "vserver/check.h"
10929 +#include "vserver/context.h"
10930 +#include "vserver/history.h"
10931 +#include "vserver/debug.h"
10932 +
10933 +#include <linux/sched.h>
10934 +
10935 +
10936 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
10937 +
10938 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
10939 +       const char *_file, int _line, void *_here)
10940 +{
10941 +       if (!vxi)
10942 +               return NULL;
10943 +
10944 +       vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
10945 +               vxi, vxi ? vxi->vx_id : 0,
10946 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10947 +               _file, _line);
10948 +       __vxh_get_vx_info(vxi, _here);
10949 +
10950 +       atomic_inc(&vxi->vx_usecnt);
10951 +       return vxi;
10952 +}
10953 +
10954 +
10955 +extern void free_vx_info(struct vx_info *);
10956 +
10957 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
10958 +
10959 +static inline void __put_vx_info(struct vx_info *vxi,
10960 +       const char *_file, int _line, void *_here)
10961 +{
10962 +       if (!vxi)
10963 +               return;
10964 +
10965 +       vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
10966 +               vxi, vxi ? vxi->vx_id : 0,
10967 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10968 +               _file, _line);
10969 +       __vxh_put_vx_info(vxi, _here);
10970 +
10971 +       if (atomic_dec_and_test(&vxi->vx_usecnt))
10972 +               free_vx_info(vxi);
10973 +}
10974 +
10975 +
10976 +#define init_vx_info(p, i) \
10977 +       __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10978 +
10979 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10980 +       const char *_file, int _line, void *_here)
10981 +{
10982 +       if (vxi) {
10983 +               vxlprintk(VXD_CBIT(xid, 3),
10984 +                       "init_vx_info(%p[#%d.%d])",
10985 +                       vxi, vxi ? vxi->vx_id : 0,
10986 +                       vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10987 +                       _file, _line);
10988 +               __vxh_init_vx_info(vxi, vxp, _here);
10989 +
10990 +               atomic_inc(&vxi->vx_usecnt);
10991 +       }
10992 +       *vxp = vxi;
10993 +}
10994 +
10995 +
10996 +#define set_vx_info(p, i) \
10997 +       __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10998 +
10999 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11000 +       const char *_file, int _line, void *_here)
11001 +{
11002 +       struct vx_info *vxo;
11003 +
11004 +       if (!vxi)
11005 +               return;
11006 +
11007 +       vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
11008 +               vxi, vxi ? vxi->vx_id : 0,
11009 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11010 +               _file, _line);
11011 +       __vxh_set_vx_info(vxi, vxp, _here);
11012 +
11013 +       atomic_inc(&vxi->vx_usecnt);
11014 +       vxo = xchg(vxp, vxi);
11015 +       BUG_ON(vxo);
11016 +}
11017 +
11018 +
11019 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
11020 +
11021 +static inline void __clr_vx_info(struct vx_info **vxp,
11022 +       const char *_file, int _line, void *_here)
11023 +{
11024 +       struct vx_info *vxo;
11025 +
11026 +       vxo = xchg(vxp, NULL);
11027 +       if (!vxo)
11028 +               return;
11029 +
11030 +       vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
11031 +               vxo, vxo ? vxo->vx_id : 0,
11032 +               vxo ? atomic_read(&vxo->vx_usecnt) : 0,
11033 +               _file, _line);
11034 +       __vxh_clr_vx_info(vxo, vxp, _here);
11035 +
11036 +       if (atomic_dec_and_test(&vxo->vx_usecnt))
11037 +               free_vx_info(vxo);
11038 +}
11039 +
11040 +
11041 +#define claim_vx_info(v, p) \
11042 +       __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11043 +
11044 +static inline void __claim_vx_info(struct vx_info *vxi,
11045 +       struct task_struct *task,
11046 +       const char *_file, int _line, void *_here)
11047 +{
11048 +       vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
11049 +               vxi, vxi ? vxi->vx_id : 0,
11050 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11051 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11052 +               task, _file, _line);
11053 +       __vxh_claim_vx_info(vxi, task, _here);
11054 +
11055 +       atomic_inc(&vxi->vx_tasks);
11056 +}
11057 +
11058 +
11059 +extern void unhash_vx_info(struct vx_info *);
11060 +
11061 +#define release_vx_info(v, p) \
11062 +       __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11063 +
11064 +static inline void __release_vx_info(struct vx_info *vxi,
11065 +       struct task_struct *task,
11066 +       const char *_file, int _line, void *_here)
11067 +{
11068 +       vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
11069 +               vxi, vxi ? vxi->vx_id : 0,
11070 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11071 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11072 +               task, _file, _line);
11073 +       __vxh_release_vx_info(vxi, task, _here);
11074 +
11075 +       might_sleep();
11076 +
11077 +       if (atomic_dec_and_test(&vxi->vx_tasks))
11078 +               unhash_vx_info(vxi);
11079 +}
11080 +
11081 +
11082 +#define task_get_vx_info(p) \
11083 +       __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
11084 +
11085 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
11086 +       const char *_file, int _line, void *_here)
11087 +{
11088 +       struct vx_info *vxi;
11089 +
11090 +       task_lock(p);
11091 +       vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
11092 +               p, _file, _line);
11093 +       vxi = __get_vx_info(p->vx_info, _file, _line, _here);
11094 +       task_unlock(p);
11095 +       return vxi;
11096 +}
11097 +
11098 +
11099 +static inline void __wakeup_vx_info(struct vx_info *vxi)
11100 +{
11101 +       if (waitqueue_active(&vxi->vx_wait))
11102 +               wake_up_interruptible(&vxi->vx_wait);
11103 +}
11104 +
11105 +
11106 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
11107 +
11108 +static inline void __enter_vx_info(struct vx_info *vxi,
11109 +       struct vx_info_save *vxis, const char *_file, int _line)
11110 +{
11111 +       vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
11112 +               vxi, vxi ? vxi->vx_id : 0, vxis, current,
11113 +               current->xid, current->vx_info, _file, _line);
11114 +       vxis->vxi = xchg(&current->vx_info, vxi);
11115 +       vxis->xid = current->xid;
11116 +       current->xid = vxi ? vxi->vx_id : 0;
11117 +}
11118 +
11119 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
11120 +
11121 +static inline void __leave_vx_info(struct vx_info_save *vxis,
11122 +       const char *_file, int _line)
11123 +{
11124 +       vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
11125 +               vxis, vxis->xid, vxis->vxi, current,
11126 +               current->xid, current->vx_info, _file, _line);
11127 +       (void)xchg(&current->vx_info, vxis->vxi);
11128 +       current->xid = vxis->xid;
11129 +}
11130 +
11131 +
11132 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
11133 +{
11134 +       vxis->vxi = xchg(&current->vx_info, NULL);
11135 +       vxis->xid = xchg(&current->xid, (xid_t)0);
11136 +}
11137 +
11138 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
11139 +{
11140 +       (void)xchg(&current->xid, vxis->xid);
11141 +       (void)xchg(&current->vx_info, vxis->vxi);
11142 +}
11143 +
11144 +#define task_is_init(p) \
11145 +       __task_is_init(p, __FILE__, __LINE__, __HERE__)
11146 +
11147 +static inline int __task_is_init(struct task_struct *p,
11148 +       const char *_file, int _line, void *_here)
11149 +{
11150 +       int is_init = is_global_init(p);
11151 +
11152 +       task_lock(p);
11153 +       if (p->vx_info)
11154 +               is_init = p->vx_info->vx_initpid == p->pid;
11155 +       task_unlock(p);
11156 +       return is_init;
11157 +}
11158 +
11159 +extern void exit_vx_info(struct task_struct *, int);
11160 +extern void exit_vx_info_early(struct task_struct *, int);
11161 +
11162 +
11163 +#else
11164 +#warning duplicate inclusion
11165 +#endif
11166 diff -NurpP --minimal linux-2.6.34/include/linux/vs_cowbl.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_cowbl.h
11167 --- linux-2.6.34/include/linux/vs_cowbl.h       1970-01-01 01:00:00.000000000 +0100
11168 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_cowbl.h  2010-05-19 02:44:39.000000000 +0200
11169 @@ -0,0 +1,48 @@
11170 +#ifndef _VS_COWBL_H
11171 +#define _VS_COWBL_H
11172 +
11173 +#include <linux/fs.h>
11174 +#include <linux/dcache.h>
11175 +#include <linux/namei.h>
11176 +#include <linux/slab.h>
11177 +
11178 +extern struct dentry *cow_break_link(const char *pathname);
11179 +
11180 +static inline int cow_check_and_break(struct path *path)
11181 +{
11182 +       struct inode *inode = path->dentry->d_inode;
11183 +       int error = 0;
11184 +
11185 +       /* do we need this check? */
11186 +       if (IS_RDONLY(inode))
11187 +               return -EROFS;
11188 +
11189 +       if (IS_COW(inode)) {
11190 +               if (IS_COW_LINK(inode)) {
11191 +                       struct dentry *new_dentry, *old_dentry = path->dentry;
11192 +                       char *pp, *buf;
11193 +
11194 +                       buf = kmalloc(PATH_MAX, GFP_KERNEL);
11195 +                       if (!buf) {
11196 +                               return -ENOMEM;
11197 +                       }
11198 +                       pp = d_path(path, buf, PATH_MAX);
11199 +                       new_dentry = cow_break_link(pp);
11200 +                       kfree(buf);
11201 +                       if (!IS_ERR(new_dentry)) {
11202 +                               path->dentry = new_dentry;
11203 +                               dput(old_dentry);
11204 +                       } else
11205 +                               error = PTR_ERR(new_dentry);
11206 +               } else {
11207 +                       inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
11208 +                       inode->i_ctime = CURRENT_TIME;
11209 +                       mark_inode_dirty(inode);
11210 +               }
11211 +       }
11212 +       return error;
11213 +}
11214 +
11215 +#else
11216 +#warning duplicate inclusion
11217 +#endif
11218 diff -NurpP --minimal linux-2.6.34/include/linux/vs_cvirt.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_cvirt.h
11219 --- linux-2.6.34/include/linux/vs_cvirt.h       1970-01-01 01:00:00.000000000 +0100
11220 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_cvirt.h  2010-05-18 18:11:22.000000000 +0200
11221 @@ -0,0 +1,50 @@
11222 +#ifndef _VS_CVIRT_H
11223 +#define _VS_CVIRT_H
11224 +
11225 +#include "vserver/cvirt.h"
11226 +#include "vserver/context.h"
11227 +#include "vserver/base.h"
11228 +#include "vserver/check.h"
11229 +#include "vserver/debug.h"
11230 +
11231 +
11232 +static inline void vx_activate_task(struct task_struct *p)
11233 +{
11234 +       struct vx_info *vxi;
11235 +
11236 +       if ((vxi = p->vx_info)) {
11237 +               vx_update_load(vxi);
11238 +               atomic_inc(&vxi->cvirt.nr_running);
11239 +       }
11240 +}
11241 +
11242 +static inline void vx_deactivate_task(struct task_struct *p)
11243 +{
11244 +       struct vx_info *vxi;
11245 +
11246 +       if ((vxi = p->vx_info)) {
11247 +               vx_update_load(vxi);
11248 +               atomic_dec(&vxi->cvirt.nr_running);
11249 +       }
11250 +}
11251 +
11252 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11253 +{
11254 +       struct vx_info *vxi;
11255 +
11256 +       if ((vxi = p->vx_info))
11257 +               atomic_inc(&vxi->cvirt.nr_uninterruptible);
11258 +}
11259 +
11260 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11261 +{
11262 +       struct vx_info *vxi;
11263 +
11264 +       if ((vxi = p->vx_info))
11265 +               atomic_dec(&vxi->cvirt.nr_uninterruptible);
11266 +}
11267 +
11268 +
11269 +#else
11270 +#warning duplicate inclusion
11271 +#endif
11272 diff -NurpP --minimal linux-2.6.34/include/linux/vs_device.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_device.h
11273 --- linux-2.6.34/include/linux/vs_device.h      1970-01-01 01:00:00.000000000 +0100
11274 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_device.h 2010-05-18 18:11:22.000000000 +0200
11275 @@ -0,0 +1,45 @@
11276 +#ifndef _VS_DEVICE_H
11277 +#define _VS_DEVICE_H
11278 +
11279 +#include "vserver/base.h"
11280 +#include "vserver/device.h"
11281 +#include "vserver/debug.h"
11282 +
11283 +
11284 +#ifdef CONFIG_VSERVER_DEVICE
11285 +
11286 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
11287 +
11288 +#define vs_device_perm(v, d, m, p) \
11289 +       ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
11290 +
11291 +#else
11292 +
11293 +static inline
11294 +int vs_map_device(struct vx_info *vxi,
11295 +       dev_t device, dev_t *target, umode_t mode)
11296 +{
11297 +       if (target)
11298 +               *target = device;
11299 +       return ~0;
11300 +}
11301 +
11302 +#define vs_device_perm(v, d, m, p) ((p) == (p))
11303 +
11304 +#endif
11305 +
11306 +
11307 +#define vs_map_chrdev(d, t, p) \
11308 +       ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
11309 +#define vs_map_blkdev(d, t, p) \
11310 +       ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
11311 +
11312 +#define vs_chrdev_perm(d, p) \
11313 +       vs_device_perm(current_vx_info(), d, S_IFCHR, p)
11314 +#define vs_blkdev_perm(d, p) \
11315 +       vs_device_perm(current_vx_info(), d, S_IFBLK, p)
11316 +
11317 +
11318 +#else
11319 +#warning duplicate inclusion
11320 +#endif
11321 diff -NurpP --minimal linux-2.6.34/include/linux/vs_dlimit.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_dlimit.h
11322 --- linux-2.6.34/include/linux/vs_dlimit.h      1970-01-01 01:00:00.000000000 +0100
11323 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_dlimit.h 2010-05-18 18:11:22.000000000 +0200
11324 @@ -0,0 +1,215 @@
11325 +#ifndef _VS_DLIMIT_H
11326 +#define _VS_DLIMIT_H
11327 +
11328 +#include <linux/fs.h>
11329 +
11330 +#include "vserver/dlimit.h"
11331 +#include "vserver/base.h"
11332 +#include "vserver/debug.h"
11333 +
11334 +
11335 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11336 +
11337 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11338 +       const char *_file, int _line)
11339 +{
11340 +       if (!dli)
11341 +               return NULL;
11342 +       vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11343 +               dli, dli ? dli->dl_tag : 0,
11344 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11345 +               _file, _line);
11346 +       atomic_inc(&dli->dl_usecnt);
11347 +       return dli;
11348 +}
11349 +
11350 +
11351 +#define free_dl_info(i) \
11352 +       call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11353 +
11354 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11355 +
11356 +static inline void __put_dl_info(struct dl_info *dli,
11357 +       const char *_file, int _line)
11358 +{
11359 +       if (!dli)
11360 +               return;
11361 +       vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11362 +               dli, dli ? dli->dl_tag : 0,
11363 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11364 +               _file, _line);
11365 +       if (atomic_dec_and_test(&dli->dl_usecnt))
11366 +               free_dl_info(dli);
11367 +}
11368 +
11369 +
11370 +#define __dlimit_char(d)       ((d) ? '*' : ' ')
11371 +
11372 +static inline int __dl_alloc_space(struct super_block *sb,
11373 +       tag_t tag, dlsize_t nr, const char *file, int line)
11374 +{
11375 +       struct dl_info *dli = NULL;
11376 +       int ret = 0;
11377 +
11378 +       if (nr == 0)
11379 +               goto out;
11380 +       dli = locate_dl_info(sb, tag);
11381 +       if (!dli)
11382 +               goto out;
11383 +
11384 +       spin_lock(&dli->dl_lock);
11385 +       ret = (dli->dl_space_used + nr > dli->dl_space_total);
11386 +       if (!ret)
11387 +               dli->dl_space_used += nr;
11388 +       spin_unlock(&dli->dl_lock);
11389 +       put_dl_info(dli);
11390 +out:
11391 +       vxlprintk(VXD_CBIT(dlim, 1),
11392 +               "ALLOC (%p,#%d)%c %lld bytes (%d)",
11393 +               sb, tag, __dlimit_char(dli), (long long)nr,
11394 +               ret, file, line);
11395 +       return ret;
11396 +}
11397 +
11398 +static inline void __dl_free_space(struct super_block *sb,
11399 +       tag_t tag, dlsize_t nr, const char *_file, int _line)
11400 +{
11401 +       struct dl_info *dli = NULL;
11402 +
11403 +       if (nr == 0)
11404 +               goto out;
11405 +       dli = locate_dl_info(sb, tag);
11406 +       if (!dli)
11407 +               goto out;
11408 +
11409 +       spin_lock(&dli->dl_lock);
11410 +       if (dli->dl_space_used > nr)
11411 +               dli->dl_space_used -= nr;
11412 +       else
11413 +               dli->dl_space_used = 0;
11414 +       spin_unlock(&dli->dl_lock);
11415 +       put_dl_info(dli);
11416 +out:
11417 +       vxlprintk(VXD_CBIT(dlim, 1),
11418 +               "FREE  (%p,#%d)%c %lld bytes",
11419 +               sb, tag, __dlimit_char(dli), (long long)nr,
11420 +               _file, _line);
11421 +}
11422 +
11423 +static inline int __dl_alloc_inode(struct super_block *sb,
11424 +       tag_t tag, const char *_file, int _line)
11425 +{
11426 +       struct dl_info *dli;
11427 +       int ret = 0;
11428 +
11429 +       dli = locate_dl_info(sb, tag);
11430 +       if (!dli)
11431 +               goto out;
11432 +
11433 +       spin_lock(&dli->dl_lock);
11434 +       dli->dl_inodes_used++;
11435 +       ret = (dli->dl_inodes_used > dli->dl_inodes_total);
11436 +       spin_unlock(&dli->dl_lock);
11437 +       put_dl_info(dli);
11438 +out:
11439 +       vxlprintk(VXD_CBIT(dlim, 0),
11440 +               "ALLOC (%p,#%d)%c inode (%d)",
11441 +               sb, tag, __dlimit_char(dli), ret, _file, _line);
11442 +       return ret;
11443 +}
11444 +
11445 +static inline void __dl_free_inode(struct super_block *sb,
11446 +       tag_t tag, const char *_file, int _line)
11447 +{
11448 +       struct dl_info *dli;
11449 +
11450 +       dli = locate_dl_info(sb, tag);
11451 +       if (!dli)
11452 +               goto out;
11453 +
11454 +       spin_lock(&dli->dl_lock);
11455 +       if (dli->dl_inodes_used > 1)
11456 +               dli->dl_inodes_used--;
11457 +       else
11458 +               dli->dl_inodes_used = 0;
11459 +       spin_unlock(&dli->dl_lock);
11460 +       put_dl_info(dli);
11461 +out:
11462 +       vxlprintk(VXD_CBIT(dlim, 0),
11463 +               "FREE  (%p,#%d)%c inode",
11464 +               sb, tag, __dlimit_char(dli), _file, _line);
11465 +}
11466 +
11467 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11468 +       unsigned long long *free_blocks, unsigned long long *root_blocks,
11469 +       const char *_file, int _line)
11470 +{
11471 +       struct dl_info *dli;
11472 +       uint64_t broot, bfree;
11473 +
11474 +       dli = locate_dl_info(sb, tag);
11475 +       if (!dli)
11476 +               return;
11477 +
11478 +       spin_lock(&dli->dl_lock);
11479 +       broot = (dli->dl_space_total -
11480 +               (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11481 +               >> sb->s_blocksize_bits;
11482 +       bfree = (dli->dl_space_total - dli->dl_space_used)
11483 +                       >> sb->s_blocksize_bits;
11484 +       spin_unlock(&dli->dl_lock);
11485 +
11486 +       vxlprintk(VXD_CBIT(dlim, 2),
11487 +               "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11488 +               (long long)bfree, (long long)broot,
11489 +               *free_blocks, *root_blocks, dli->dl_nrlmult,
11490 +               _file, _line);
11491 +       if (free_blocks) {
11492 +               if (*free_blocks > bfree)
11493 +                       *free_blocks = bfree;
11494 +       }
11495 +       if (root_blocks) {
11496 +               if (*root_blocks > broot)
11497 +                       *root_blocks = broot;
11498 +       }
11499 +       put_dl_info(dli);
11500 +}
11501 +
11502 +#define dl_prealloc_space(in, bytes) \
11503 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11504 +               __FILE__, __LINE__ )
11505 +
11506 +#define dl_alloc_space(in, bytes) \
11507 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11508 +               __FILE__, __LINE__ )
11509 +
11510 +#define dl_reserve_space(in, bytes) \
11511 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11512 +               __FILE__, __LINE__ )
11513 +
11514 +#define dl_claim_space(in, bytes) (0)
11515 +
11516 +#define dl_release_space(in, bytes) \
11517 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11518 +               __FILE__, __LINE__ )
11519 +
11520 +#define dl_free_space(in, bytes) \
11521 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11522 +               __FILE__, __LINE__ )
11523 +
11524 +
11525 +
11526 +#define dl_alloc_inode(in) \
11527 +       __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11528 +
11529 +#define dl_free_inode(in) \
11530 +       __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11531 +
11532 +
11533 +#define dl_adjust_block(sb, tag, fb, rb) \
11534 +       __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11535 +
11536 +
11537 +#else
11538 +#warning duplicate inclusion
11539 +#endif
11540 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/base.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/base.h
11541 --- linux-2.6.34/include/linux/vserver/base.h   1970-01-01 01:00:00.000000000 +0100
11542 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/base.h      2010-05-18 18:11:22.000000000 +0200
11543 @@ -0,0 +1,170 @@
11544 +#ifndef _VX_BASE_H
11545 +#define _VX_BASE_H
11546 +
11547 +
11548 +/* context state changes */
11549 +
11550 +enum {
11551 +       VSC_STARTUP = 1,
11552 +       VSC_SHUTDOWN,
11553 +
11554 +       VSC_NETUP,
11555 +       VSC_NETDOWN,
11556 +};
11557 +
11558 +
11559 +
11560 +#define vx_task_xid(t) ((t)->xid)
11561 +
11562 +#define vx_current_xid() vx_task_xid(current)
11563 +
11564 +#define current_vx_info() (current->vx_info)
11565 +
11566 +
11567 +#define nx_task_nid(t) ((t)->nid)
11568 +
11569 +#define nx_current_nid() nx_task_nid(current)
11570 +
11571 +#define current_nx_info() (current->nx_info)
11572 +
11573 +
11574 +/* generic flag merging */
11575 +
11576 +#define vs_check_flags(v, m, f)        (((v) & (m)) ^ (f))
11577 +
11578 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11579 +
11580 +#define vs_mask_mask(v, f, m)  (((v) & ~(m)) | ((v) & (f) & (m)))
11581 +
11582 +#define vs_check_bit(v, n)     ((v) & (1LL << (n)))
11583 +
11584 +
11585 +/* context flags */
11586 +
11587 +#define __vx_flags(v)  ((v) ? (v)->vx_flags : 0)
11588 +
11589 +#define vx_current_flags()     __vx_flags(current_vx_info())
11590 +
11591 +#define vx_info_flags(v, m, f) \
11592 +       vs_check_flags(__vx_flags(v), m, f)
11593 +
11594 +#define task_vx_flags(t, m, f) \
11595 +       ((t) && vx_info_flags((t)->vx_info, m, f))
11596 +
11597 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11598 +
11599 +
11600 +/* context caps */
11601 +
11602 +#define __vx_ccaps(v)  ((v) ? (v)->vx_ccaps : 0)
11603 +
11604 +#define vx_current_ccaps()     __vx_ccaps(current_vx_info())
11605 +
11606 +#define vx_info_ccaps(v, c)    (__vx_ccaps(v) & (c))
11607 +
11608 +#define vx_ccaps(c)    vx_info_ccaps(current_vx_info(), (c))
11609 +
11610 +
11611 +
11612 +/* network flags */
11613 +
11614 +#define __nx_flags(n)  ((n) ? (n)->nx_flags : 0)
11615 +
11616 +#define nx_current_flags()     __nx_flags(current_nx_info())
11617 +
11618 +#define nx_info_flags(n, m, f) \
11619 +       vs_check_flags(__nx_flags(n), m, f)
11620 +
11621 +#define task_nx_flags(t, m, f) \
11622 +       ((t) && nx_info_flags((t)->nx_info, m, f))
11623 +
11624 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11625 +
11626 +
11627 +/* network caps */
11628 +
11629 +#define __nx_ncaps(n)  ((n) ? (n)->nx_ncaps : 0)
11630 +
11631 +#define nx_current_ncaps()     __nx_ncaps(current_nx_info())
11632 +
11633 +#define nx_info_ncaps(n, c)    (__nx_ncaps(n) & (c))
11634 +
11635 +#define nx_ncaps(c)    nx_info_ncaps(current_nx_info(), c)
11636 +
11637 +
11638 +/* context mask capabilities */
11639 +
11640 +#define __vx_mcaps(v)  ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11641 +
11642 +#define vx_info_mcaps(v, c)    (__vx_mcaps(v) & (c))
11643 +
11644 +#define vx_mcaps(c)    vx_info_mcaps(current_vx_info(), c)
11645 +
11646 +
11647 +/* context bcap mask */
11648 +
11649 +#define __vx_bcaps(v)          ((v)->vx_bcaps)
11650 +
11651 +#define vx_current_bcaps()     __vx_bcaps(current_vx_info())
11652 +
11653 +
11654 +/* mask given bcaps */
11655 +
11656 +#define vx_info_mbcaps(v, c)   ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11657 +
11658 +#define vx_mbcaps(c)           vx_info_mbcaps(current_vx_info(), c)
11659 +
11660 +
11661 +/* masked cap_bset */
11662 +
11663 +#define vx_info_cap_bset(v)    vx_info_mbcaps(v, current->cap_bset)
11664 +
11665 +#define vx_current_cap_bset()  vx_info_cap_bset(current_vx_info())
11666 +
11667 +#if 0
11668 +#define vx_info_mbcap(v, b) \
11669 +       (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11670 +       vx_info_bcaps(v, b) : (b))
11671 +
11672 +#define task_vx_mbcap(t, b) \
11673 +       vx_info_mbcap((t)->vx_info, (t)->b)
11674 +
11675 +#define vx_mbcap(b)    task_vx_mbcap(current, b)
11676 +#endif
11677 +
11678 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11679 +
11680 +#define vx_capable(b, c) (capable(b) || \
11681 +       (cap_raised(current_cap(), b) && vx_ccaps(c)))
11682 +
11683 +#define nx_capable(b, c) (capable(b) || \
11684 +       (cap_raised(current_cap(), b) && nx_ncaps(c)))
11685 +
11686 +#define vx_task_initpid(t, n) \
11687 +       ((t)->vx_info && \
11688 +       ((t)->vx_info->vx_initpid == (n)))
11689 +
11690 +#define vx_current_initpid(n)  vx_task_initpid(current, n)
11691 +
11692 +
11693 +/* context unshare mask */
11694 +
11695 +#define __vx_umask(v)          ((v)->vx_umask)
11696 +
11697 +#define vx_current_umask()     __vx_umask(current_vx_info())
11698 +
11699 +#define vx_can_unshare(b, f) (capable(b) || \
11700 +       (cap_raised(current_cap(), b) && \
11701 +       !((f) & ~vx_current_umask())))
11702 +
11703 +
11704 +#define __vx_state(v)  ((v) ? ((v)->vx_state) : 0)
11705 +
11706 +#define vx_info_state(v, m)    (__vx_state(v) & (m))
11707 +
11708 +
11709 +#define __nx_state(n)  ((n) ? ((n)->nx_state) : 0)
11710 +
11711 +#define nx_info_state(n, m)    (__nx_state(n) & (m))
11712 +
11713 +#endif
11714 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/cacct_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cacct_cmd.h
11715 --- linux-2.6.34/include/linux/vserver/cacct_cmd.h      1970-01-01 01:00:00.000000000 +0100
11716 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cacct_cmd.h 2010-05-18 18:11:22.000000000 +0200
11717 @@ -0,0 +1,23 @@
11718 +#ifndef _VX_CACCT_CMD_H
11719 +#define _VX_CACCT_CMD_H
11720 +
11721 +
11722 +/* virtual host info name commands */
11723 +
11724 +#define VCMD_sock_stat         VC_CMD(VSTAT, 5, 0)
11725 +
11726 +struct vcmd_sock_stat_v0 {
11727 +       uint32_t field;
11728 +       uint32_t count[3];
11729 +       uint64_t total[3];
11730 +};
11731 +
11732 +
11733 +#ifdef __KERNEL__
11734 +
11735 +#include <linux/compiler.h>
11736 +
11737 +extern int vc_sock_stat(struct vx_info *, void __user *);
11738 +
11739 +#endif /* __KERNEL__ */
11740 +#endif /* _VX_CACCT_CMD_H */
11741 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/cacct_def.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cacct_def.h
11742 --- linux-2.6.34/include/linux/vserver/cacct_def.h      1970-01-01 01:00:00.000000000 +0100
11743 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cacct_def.h 2010-05-18 18:11:22.000000000 +0200
11744 @@ -0,0 +1,43 @@
11745 +#ifndef _VX_CACCT_DEF_H
11746 +#define _VX_CACCT_DEF_H
11747 +
11748 +#include <asm/atomic.h>
11749 +#include <linux/vserver/cacct.h>
11750 +
11751 +
11752 +struct _vx_sock_acc {
11753 +       atomic_long_t count;
11754 +       atomic_long_t total;
11755 +};
11756 +
11757 +/* context sub struct */
11758 +
11759 +struct _vx_cacct {
11760 +       struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11761 +       atomic_t slab[8];
11762 +       atomic_t page[6][8];
11763 +};
11764 +
11765 +#ifdef CONFIG_VSERVER_DEBUG
11766 +
11767 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11768 +{
11769 +       int i, j;
11770 +
11771 +       printk("\t_vx_cacct:");
11772 +       for (i = 0; i < 6; i++) {
11773 +               struct _vx_sock_acc *ptr = cacct->sock[i];
11774 +
11775 +               printk("\t [%d] =", i);
11776 +               for (j = 0; j < 3; j++) {
11777 +                       printk(" [%d] = %8lu, %8lu", j,
11778 +                               atomic_long_read(&ptr[j].count),
11779 +                               atomic_long_read(&ptr[j].total));
11780 +               }
11781 +               printk("\n");
11782 +       }
11783 +}
11784 +
11785 +#endif
11786 +
11787 +#endif /* _VX_CACCT_DEF_H */
11788 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/cacct.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cacct.h
11789 --- linux-2.6.34/include/linux/vserver/cacct.h  1970-01-01 01:00:00.000000000 +0100
11790 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cacct.h     2010-05-18 18:11:22.000000000 +0200
11791 @@ -0,0 +1,15 @@
11792 +#ifndef _VX_CACCT_H
11793 +#define _VX_CACCT_H
11794 +
11795 +
11796 +enum sock_acc_field {
11797 +       VXA_SOCK_UNSPEC = 0,
11798 +       VXA_SOCK_UNIX,
11799 +       VXA_SOCK_INET,
11800 +       VXA_SOCK_INET6,
11801 +       VXA_SOCK_PACKET,
11802 +       VXA_SOCK_OTHER,
11803 +       VXA_SOCK_SIZE   /* array size */
11804 +};
11805 +
11806 +#endif /* _VX_CACCT_H */
11807 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/cacct_int.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cacct_int.h
11808 --- linux-2.6.34/include/linux/vserver/cacct_int.h      1970-01-01 01:00:00.000000000 +0100
11809 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cacct_int.h 2010-05-18 18:11:22.000000000 +0200
11810 @@ -0,0 +1,21 @@
11811 +#ifndef _VX_CACCT_INT_H
11812 +#define _VX_CACCT_INT_H
11813 +
11814 +
11815 +#ifdef __KERNEL__
11816 +
11817 +static inline
11818 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11819 +{
11820 +       return atomic_long_read(&cacct->sock[type][pos].count);
11821 +}
11822 +
11823 +
11824 +static inline
11825 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11826 +{
11827 +       return atomic_long_read(&cacct->sock[type][pos].total);
11828 +}
11829 +
11830 +#endif /* __KERNEL__ */
11831 +#endif /* _VX_CACCT_INT_H */
11832 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/check.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/check.h
11833 --- linux-2.6.34/include/linux/vserver/check.h  1970-01-01 01:00:00.000000000 +0100
11834 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/check.h     2010-05-18 18:11:22.000000000 +0200
11835 @@ -0,0 +1,89 @@
11836 +#ifndef _VS_CHECK_H
11837 +#define _VS_CHECK_H
11838 +
11839 +
11840 +#define MAX_S_CONTEXT  65535   /* Arbitrary limit */
11841 +
11842 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11843 +#define MIN_D_CONTEXT  49152   /* dynamic contexts start here */
11844 +#else
11845 +#define MIN_D_CONTEXT  65536
11846 +#endif
11847 +
11848 +/* check conditions */
11849 +
11850 +#define VS_ADMIN       0x0001
11851 +#define VS_WATCH       0x0002
11852 +#define VS_HIDE                0x0004
11853 +#define VS_HOSTID      0x0008
11854 +
11855 +#define VS_IDENT       0x0010
11856 +#define VS_EQUIV       0x0020
11857 +#define VS_PARENT      0x0040
11858 +#define VS_CHILD       0x0080
11859 +
11860 +#define VS_ARG_MASK    0x00F0
11861 +
11862 +#define VS_DYNAMIC     0x0100
11863 +#define VS_STATIC      0x0200
11864 +
11865 +#define VS_ATR_MASK    0x0F00
11866 +
11867 +#ifdef CONFIG_VSERVER_PRIVACY
11868 +#define VS_ADMIN_P     (0)
11869 +#define VS_WATCH_P     (0)
11870 +#else
11871 +#define VS_ADMIN_P     VS_ADMIN
11872 +#define VS_WATCH_P     VS_WATCH
11873 +#endif
11874 +
11875 +#define VS_HARDIRQ     0x1000
11876 +#define VS_SOFTIRQ     0x2000
11877 +#define VS_IRQ         0x4000
11878 +
11879 +#define VS_IRQ_MASK    0xF000
11880 +
11881 +#include <linux/hardirq.h>
11882 +
11883 +/*
11884 + * check current context for ADMIN/WATCH and
11885 + * optionally against supplied argument
11886 + */
11887 +static inline int __vs_check(int cid, int id, unsigned int mode)
11888 +{
11889 +       if (mode & VS_ARG_MASK) {
11890 +               if ((mode & VS_IDENT) && (id == cid))
11891 +                       return 1;
11892 +       }
11893 +       if (mode & VS_ATR_MASK) {
11894 +               if ((mode & VS_DYNAMIC) &&
11895 +                       (id >= MIN_D_CONTEXT) &&
11896 +                       (id <= MAX_S_CONTEXT))
11897 +                       return 1;
11898 +               if ((mode & VS_STATIC) &&
11899 +                       (id > 1) && (id < MIN_D_CONTEXT))
11900 +                       return 1;
11901 +       }
11902 +       if (mode & VS_IRQ_MASK) {
11903 +               if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11904 +                       return 1;
11905 +               if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11906 +                       return 1;
11907 +               if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11908 +                       return 1;
11909 +       }
11910 +       return (((mode & VS_ADMIN) && (cid == 0)) ||
11911 +               ((mode & VS_WATCH) && (cid == 1)) ||
11912 +               ((mode & VS_HOSTID) && (id == 0)));
11913 +}
11914 +
11915 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11916 +
11917 +#define vx_weak_check(c, m)    ((m) ? vx_check(c, m) : 1)
11918 +
11919 +
11920 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11921 +
11922 +#define nx_weak_check(c, m)    ((m) ? nx_check(c, m) : 1)
11923 +
11924 +#endif
11925 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/context_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/context_cmd.h
11926 --- linux-2.6.34/include/linux/vserver/context_cmd.h    1970-01-01 01:00:00.000000000 +0100
11927 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/context_cmd.h       2010-05-18 18:11:22.000000000 +0200
11928 @@ -0,0 +1,145 @@
11929 +#ifndef _VX_CONTEXT_CMD_H
11930 +#define _VX_CONTEXT_CMD_H
11931 +
11932 +
11933 +/* vinfo commands */
11934 +
11935 +#define VCMD_task_xid          VC_CMD(VINFO, 1, 0)
11936 +
11937 +#ifdef __KERNEL__
11938 +extern int vc_task_xid(uint32_t);
11939 +
11940 +#endif /* __KERNEL__ */
11941 +
11942 +#define VCMD_vx_info           VC_CMD(VINFO, 5, 0)
11943 +
11944 +struct vcmd_vx_info_v0 {
11945 +       uint32_t xid;
11946 +       uint32_t initpid;
11947 +       /* more to come */
11948 +};
11949 +
11950 +#ifdef __KERNEL__
11951 +extern int vc_vx_info(struct vx_info *, void __user *);
11952 +
11953 +#endif /* __KERNEL__ */
11954 +
11955 +#define VCMD_ctx_stat          VC_CMD(VSTAT, 0, 0)
11956 +
11957 +struct vcmd_ctx_stat_v0 {
11958 +       uint32_t usecnt;
11959 +       uint32_t tasks;
11960 +       /* more to come */
11961 +};
11962 +
11963 +#ifdef __KERNEL__
11964 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11965 +
11966 +#endif /* __KERNEL__ */
11967 +
11968 +/* context commands */
11969 +
11970 +#define VCMD_ctx_create_v0     VC_CMD(VPROC, 1, 0)
11971 +#define VCMD_ctx_create                VC_CMD(VPROC, 1, 1)
11972 +
11973 +struct vcmd_ctx_create {
11974 +       uint64_t flagword;
11975 +};
11976 +
11977 +#define VCMD_ctx_migrate_v0    VC_CMD(PROCMIG, 1, 0)
11978 +#define VCMD_ctx_migrate       VC_CMD(PROCMIG, 1, 1)
11979 +
11980 +struct vcmd_ctx_migrate {
11981 +       uint64_t flagword;
11982 +};
11983 +
11984 +#ifdef __KERNEL__
11985 +extern int vc_ctx_create(uint32_t, void __user *);
11986 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11987 +
11988 +#endif /* __KERNEL__ */
11989 +
11990 +
11991 +/* flag commands */
11992 +
11993 +#define VCMD_get_cflags                VC_CMD(FLAGS, 1, 0)
11994 +#define VCMD_set_cflags                VC_CMD(FLAGS, 2, 0)
11995 +
11996 +struct vcmd_ctx_flags_v0 {
11997 +       uint64_t flagword;
11998 +       uint64_t mask;
11999 +};
12000 +
12001 +#ifdef __KERNEL__
12002 +extern int vc_get_cflags(struct vx_info *, void __user *);
12003 +extern int vc_set_cflags(struct vx_info *, void __user *);
12004 +
12005 +#endif /* __KERNEL__ */
12006 +
12007 +
12008 +/* context caps commands */
12009 +
12010 +#define VCMD_get_ccaps         VC_CMD(FLAGS, 3, 1)
12011 +#define VCMD_set_ccaps         VC_CMD(FLAGS, 4, 1)
12012 +
12013 +struct vcmd_ctx_caps_v1 {
12014 +       uint64_t ccaps;
12015 +       uint64_t cmask;
12016 +};
12017 +
12018 +#ifdef __KERNEL__
12019 +extern int vc_get_ccaps(struct vx_info *, void __user *);
12020 +extern int vc_set_ccaps(struct vx_info *, void __user *);
12021 +
12022 +#endif /* __KERNEL__ */
12023 +
12024 +
12025 +/* bcaps commands */
12026 +
12027 +#define VCMD_get_bcaps         VC_CMD(FLAGS, 9, 0)
12028 +#define VCMD_set_bcaps         VC_CMD(FLAGS, 10, 0)
12029 +
12030 +struct vcmd_bcaps {
12031 +       uint64_t bcaps;
12032 +       uint64_t bmask;
12033 +};
12034 +
12035 +#ifdef __KERNEL__
12036 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12037 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12038 +
12039 +#endif /* __KERNEL__ */
12040 +
12041 +
12042 +/* umask commands */
12043 +
12044 +#define VCMD_get_umask         VC_CMD(FLAGS, 13, 0)
12045 +#define VCMD_set_umask         VC_CMD(FLAGS, 14, 0)
12046 +
12047 +struct vcmd_umask {
12048 +       uint64_t umask;
12049 +       uint64_t mask;
12050 +};
12051 +
12052 +#ifdef __KERNEL__
12053 +extern int vc_get_umask(struct vx_info *, void __user *);
12054 +extern int vc_set_umask(struct vx_info *, void __user *);
12055 +
12056 +#endif /* __KERNEL__ */
12057 +
12058 +
12059 +/* OOM badness */
12060 +
12061 +#define VCMD_get_badness       VC_CMD(MEMCTRL, 5, 0)
12062 +#define VCMD_set_badness       VC_CMD(MEMCTRL, 6, 0)
12063 +
12064 +struct vcmd_badness_v0 {
12065 +       int64_t bias;
12066 +};
12067 +
12068 +#ifdef __KERNEL__
12069 +extern int vc_get_badness(struct vx_info *, void __user *);
12070 +extern int vc_set_badness(struct vx_info *, void __user *);
12071 +
12072 +#endif /* __KERNEL__ */
12073 +#endif /* _VX_CONTEXT_CMD_H */
12074 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/context.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/context.h
12075 --- linux-2.6.34/include/linux/vserver/context.h        1970-01-01 01:00:00.000000000 +0100
12076 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/context.h   2010-05-18 18:11:22.000000000 +0200
12077 @@ -0,0 +1,184 @@
12078 +#ifndef _VX_CONTEXT_H
12079 +#define _VX_CONTEXT_H
12080 +
12081 +#include <linux/types.h>
12082 +#include <linux/capability.h>
12083 +
12084 +
12085 +/* context flags */
12086 +
12087 +#define VXF_INFO_SCHED         0x00000002
12088 +#define VXF_INFO_NPROC         0x00000004
12089 +#define VXF_INFO_PRIVATE       0x00000008
12090 +
12091 +#define VXF_INFO_INIT          0x00000010
12092 +#define VXF_INFO_HIDE          0x00000020
12093 +#define VXF_INFO_ULIMIT                0x00000040
12094 +#define VXF_INFO_NSPACE                0x00000080
12095 +
12096 +#define VXF_SCHED_HARD         0x00000100
12097 +#define VXF_SCHED_PRIO         0x00000200
12098 +#define VXF_SCHED_PAUSE                0x00000400
12099 +
12100 +#define VXF_VIRT_MEM           0x00010000
12101 +#define VXF_VIRT_UPTIME                0x00020000
12102 +#define VXF_VIRT_CPU           0x00040000
12103 +#define VXF_VIRT_LOAD          0x00080000
12104 +#define VXF_VIRT_TIME          0x00100000
12105 +
12106 +#define VXF_HIDE_MOUNT         0x01000000
12107 +/* was VXF_HIDE_NETIF          0x02000000 */
12108 +#define VXF_HIDE_VINFO         0x04000000
12109 +
12110 +#define VXF_STATE_SETUP                (1ULL << 32)
12111 +#define VXF_STATE_INIT         (1ULL << 33)
12112 +#define VXF_STATE_ADMIN                (1ULL << 34)
12113 +
12114 +#define VXF_SC_HELPER          (1ULL << 36)
12115 +#define VXF_REBOOT_KILL                (1ULL << 37)
12116 +#define VXF_PERSISTENT         (1ULL << 38)
12117 +
12118 +#define VXF_FORK_RSS           (1ULL << 48)
12119 +#define VXF_PROLIFIC           (1ULL << 49)
12120 +
12121 +#define VXF_IGNEG_NICE         (1ULL << 52)
12122 +
12123 +#define VXF_ONE_TIME           (0x0007ULL << 32)
12124 +
12125 +#define VXF_INIT_SET           (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12126 +
12127 +
12128 +/* context migration */
12129 +
12130 +#define VXM_SET_INIT           0x00000001
12131 +#define VXM_SET_REAPER         0x00000002
12132 +
12133 +/* context caps */
12134 +
12135 +#define VXC_CAP_MASK           0x00000000
12136 +
12137 +#define VXC_SET_UTSNAME                0x00000001
12138 +#define VXC_SET_RLIMIT         0x00000002
12139 +#define VXC_FS_SECURITY                0x00000004
12140 +#define VXC_FS_TRUSTED         0x00000008
12141 +#define VXC_TIOCSTI            0x00000010
12142 +
12143 +/* was VXC_RAW_ICMP            0x00000100 */
12144 +#define VXC_SYSLOG             0x00001000
12145 +#define VXC_OOM_ADJUST         0x00002000
12146 +#define VXC_AUDIT_CONTROL      0x00004000
12147 +
12148 +#define VXC_SECURE_MOUNT       0x00010000
12149 +#define VXC_SECURE_REMOUNT     0x00020000
12150 +#define VXC_BINARY_MOUNT       0x00040000
12151 +
12152 +#define VXC_QUOTA_CTL          0x00100000
12153 +#define VXC_ADMIN_MAPPER       0x00200000
12154 +#define VXC_ADMIN_CLOOP                0x00400000
12155 +
12156 +#define VXC_KTHREAD            0x01000000
12157 +#define VXC_NAMESPACE          0x02000000
12158 +
12159 +
12160 +#ifdef __KERNEL__
12161 +
12162 +#include <linux/list.h>
12163 +#include <linux/spinlock.h>
12164 +#include <linux/rcupdate.h>
12165 +
12166 +#include "limit_def.h"
12167 +#include "sched_def.h"
12168 +#include "cvirt_def.h"
12169 +#include "cacct_def.h"
12170 +#include "device_def.h"
12171 +
12172 +#define VX_SPACES      2
12173 +
12174 +struct _vx_info_pc {
12175 +       struct _vx_sched_pc sched_pc;
12176 +       struct _vx_cvirt_pc cvirt_pc;
12177 +};
12178 +
12179 +struct vx_info {
12180 +       struct hlist_node vx_hlist;             /* linked list of contexts */
12181 +       xid_t vx_id;                            /* context id */
12182 +       atomic_t vx_usecnt;                     /* usage count */
12183 +       atomic_t vx_tasks;                      /* tasks count */
12184 +       struct vx_info *vx_parent;              /* parent context */
12185 +       int vx_state;                           /* context state */
12186 +
12187 +       unsigned long vx_nsmask[VX_SPACES];     /* assignment mask */
12188 +       struct nsproxy *vx_nsproxy[VX_SPACES];  /* private namespaces */
12189 +       struct fs_struct *vx_fs[VX_SPACES];     /* private namespace fs */
12190 +
12191 +       uint64_t vx_flags;                      /* context flags */
12192 +       uint64_t vx_ccaps;                      /* context caps (vserver) */
12193 +       kernel_cap_t vx_bcaps;                  /* bounding caps (system) */
12194 +       unsigned long vx_umask;                 /* unshare mask (guest) */
12195 +
12196 +       struct task_struct *vx_reaper;          /* guest reaper process */
12197 +       pid_t vx_initpid;                       /* PID of guest init */
12198 +       int64_t vx_badness_bias;                /* OOM points bias */
12199 +
12200 +       struct _vx_limit limit;                 /* vserver limits */
12201 +       struct _vx_sched sched;                 /* vserver scheduler */
12202 +       struct _vx_cvirt cvirt;                 /* virtual/bias stuff */
12203 +       struct _vx_cacct cacct;                 /* context accounting */
12204 +
12205 +       struct _vx_device dmap;                 /* default device map targets */
12206 +
12207 +#ifndef CONFIG_SMP
12208 +       struct _vx_info_pc info_pc;             /* per cpu data */
12209 +#else
12210 +       struct _vx_info_pc *ptr_pc;             /* per cpu array */
12211 +#endif
12212 +
12213 +       wait_queue_head_t vx_wait;              /* context exit waitqueue */
12214 +       int reboot_cmd;                         /* last sys_reboot() cmd */
12215 +       int exit_code;                          /* last process exit code */
12216 +
12217 +       char vx_name[65];                       /* vserver name */
12218 +};
12219 +
12220 +#ifndef CONFIG_SMP
12221 +#define        vx_ptr_pc(vxi)          (&(vxi)->info_pc)
12222 +#define        vx_per_cpu(vxi, v, id)  vx_ptr_pc(vxi)->v
12223 +#else
12224 +#define        vx_ptr_pc(vxi)          ((vxi)->ptr_pc)
12225 +#define        vx_per_cpu(vxi, v, id)  per_cpu_ptr(vx_ptr_pc(vxi), id)->v
12226 +#endif
12227 +
12228 +#define        vx_cpu(vxi, v)          vx_per_cpu(vxi, v, smp_processor_id())
12229 +
12230 +
12231 +struct vx_info_save {
12232 +       struct vx_info *vxi;
12233 +       xid_t xid;
12234 +};
12235 +
12236 +
12237 +/* status flags */
12238 +
12239 +#define VXS_HASHED     0x0001
12240 +#define VXS_PAUSED     0x0010
12241 +#define VXS_SHUTDOWN   0x0100
12242 +#define VXS_HELPER     0x1000
12243 +#define VXS_RELEASED   0x8000
12244 +
12245 +
12246 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
12247 +extern void release_vx_info(struct vx_info *, struct task_struct *);
12248 +
12249 +extern struct vx_info *lookup_vx_info(int);
12250 +extern struct vx_info *lookup_or_create_vx_info(int);
12251 +
12252 +extern int get_xid_list(int, unsigned int *, int);
12253 +extern int xid_is_hashed(xid_t);
12254 +
12255 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
12256 +
12257 +extern long vs_state_change(struct vx_info *, unsigned int);
12258 +
12259 +
12260 +#endif /* __KERNEL__ */
12261 +#endif /* _VX_CONTEXT_H */
12262 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/cvirt_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cvirt_cmd.h
12263 --- linux-2.6.34/include/linux/vserver/cvirt_cmd.h      1970-01-01 01:00:00.000000000 +0100
12264 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cvirt_cmd.h 2010-05-18 18:11:22.000000000 +0200
12265 @@ -0,0 +1,53 @@
12266 +#ifndef _VX_CVIRT_CMD_H
12267 +#define _VX_CVIRT_CMD_H
12268 +
12269 +
12270 +/* virtual host info name commands */
12271 +
12272 +#define VCMD_set_vhi_name      VC_CMD(VHOST, 1, 0)
12273 +#define VCMD_get_vhi_name      VC_CMD(VHOST, 2, 0)
12274 +
12275 +struct vcmd_vhi_name_v0 {
12276 +       uint32_t field;
12277 +       char name[65];
12278 +};
12279 +
12280 +
12281 +enum vhi_name_field {
12282 +       VHIN_CONTEXT = 0,
12283 +       VHIN_SYSNAME,
12284 +       VHIN_NODENAME,
12285 +       VHIN_RELEASE,
12286 +       VHIN_VERSION,
12287 +       VHIN_MACHINE,
12288 +       VHIN_DOMAINNAME,
12289 +};
12290 +
12291 +
12292 +#ifdef __KERNEL__
12293 +
12294 +#include <linux/compiler.h>
12295 +
12296 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12297 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12298 +
12299 +#endif /* __KERNEL__ */
12300 +
12301 +#define VCMD_virt_stat         VC_CMD(VSTAT, 3, 0)
12302 +
12303 +struct vcmd_virt_stat_v0 {
12304 +       uint64_t offset;
12305 +       uint64_t uptime;
12306 +       uint32_t nr_threads;
12307 +       uint32_t nr_running;
12308 +       uint32_t nr_uninterruptible;
12309 +       uint32_t nr_onhold;
12310 +       uint32_t nr_forks;
12311 +       uint32_t load[3];
12312 +};
12313 +
12314 +#ifdef __KERNEL__
12315 +extern int vc_virt_stat(struct vx_info *, void __user *);
12316 +
12317 +#endif /* __KERNEL__ */
12318 +#endif /* _VX_CVIRT_CMD_H */
12319 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/cvirt_def.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cvirt_def.h
12320 --- linux-2.6.34/include/linux/vserver/cvirt_def.h      1970-01-01 01:00:00.000000000 +0100
12321 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cvirt_def.h 2010-05-18 18:11:22.000000000 +0200
12322 @@ -0,0 +1,80 @@
12323 +#ifndef _VX_CVIRT_DEF_H
12324 +#define _VX_CVIRT_DEF_H
12325 +
12326 +#include <linux/jiffies.h>
12327 +#include <linux/spinlock.h>
12328 +#include <linux/wait.h>
12329 +#include <linux/time.h>
12330 +#include <asm/atomic.h>
12331 +
12332 +
12333 +struct _vx_usage_stat {
12334 +       uint64_t user;
12335 +       uint64_t nice;
12336 +       uint64_t system;
12337 +       uint64_t softirq;
12338 +       uint64_t irq;
12339 +       uint64_t idle;
12340 +       uint64_t iowait;
12341 +};
12342 +
12343 +struct _vx_syslog {
12344 +       wait_queue_head_t log_wait;
12345 +       spinlock_t logbuf_lock;         /* lock for the log buffer */
12346 +
12347 +       unsigned long log_start;        /* next char to be read by syslog() */
12348 +       unsigned long con_start;        /* next char to be sent to consoles */
12349 +       unsigned long log_end;  /* most-recently-written-char + 1 */
12350 +       unsigned long logged_chars;     /* #chars since last read+clear operation */
12351 +
12352 +       char log_buf[1024];
12353 +};
12354 +
12355 +
12356 +/* context sub struct */
12357 +
12358 +struct _vx_cvirt {
12359 +       atomic_t nr_threads;            /* number of current threads */
12360 +       atomic_t nr_running;            /* number of running threads */
12361 +       atomic_t nr_uninterruptible;    /* number of uninterruptible threads */
12362 +
12363 +       atomic_t nr_onhold;             /* processes on hold */
12364 +       uint32_t onhold_last;           /* jiffies when put on hold */
12365 +
12366 +       struct timeval bias_tv;         /* time offset to the host */
12367 +       struct timespec bias_idle;
12368 +       struct timespec bias_uptime;    /* context creation point */
12369 +       uint64_t bias_clock;            /* offset in clock_t */
12370 +
12371 +       spinlock_t load_lock;           /* lock for the load averages */
12372 +       atomic_t load_updates;          /* nr of load updates done so far */
12373 +       uint32_t load_last;             /* last time load was calculated */
12374 +       uint32_t load[3];               /* load averages 1,5,15 */
12375 +
12376 +       atomic_t total_forks;           /* number of forks so far */
12377 +
12378 +       struct _vx_syslog syslog;
12379 +};
12380 +
12381 +struct _vx_cvirt_pc {
12382 +       struct _vx_usage_stat cpustat;
12383 +};
12384 +
12385 +
12386 +#ifdef CONFIG_VSERVER_DEBUG
12387 +
12388 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12389 +{
12390 +       printk("\t_vx_cvirt:\n");
12391 +       printk("\t threads: %4d, %4d, %4d, %4d\n",
12392 +               atomic_read(&cvirt->nr_threads),
12393 +               atomic_read(&cvirt->nr_running),
12394 +               atomic_read(&cvirt->nr_uninterruptible),
12395 +               atomic_read(&cvirt->nr_onhold));
12396 +       /* add rest here */
12397 +       printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12398 +}
12399 +
12400 +#endif
12401 +
12402 +#endif /* _VX_CVIRT_DEF_H */
12403 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/cvirt.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cvirt.h
12404 --- linux-2.6.34/include/linux/vserver/cvirt.h  1970-01-01 01:00:00.000000000 +0100
12405 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/cvirt.h     2010-05-18 18:11:22.000000000 +0200
12406 @@ -0,0 +1,20 @@
12407 +#ifndef _VX_CVIRT_H
12408 +#define _VX_CVIRT_H
12409 +
12410 +
12411 +#ifdef __KERNEL__
12412 +
12413 +struct timespec;
12414 +
12415 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12416 +
12417 +
12418 +struct vx_info;
12419 +
12420 +void vx_update_load(struct vx_info *);
12421 +
12422 +
12423 +int vx_do_syslog(int, char __user *, int);
12424 +
12425 +#endif /* __KERNEL__ */
12426 +#endif /* _VX_CVIRT_H */
12427 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/debug_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/debug_cmd.h
12428 --- linux-2.6.34/include/linux/vserver/debug_cmd.h      1970-01-01 01:00:00.000000000 +0100
12429 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/debug_cmd.h 2010-05-18 18:11:22.000000000 +0200
12430 @@ -0,0 +1,58 @@
12431 +#ifndef _VX_DEBUG_CMD_H
12432 +#define _VX_DEBUG_CMD_H
12433 +
12434 +
12435 +/* debug commands */
12436 +
12437 +#define VCMD_dump_history      VC_CMD(DEBUG, 1, 0)
12438 +
12439 +#define VCMD_read_history      VC_CMD(DEBUG, 5, 0)
12440 +#define VCMD_read_monitor      VC_CMD(DEBUG, 6, 0)
12441 +
12442 +struct  vcmd_read_history_v0 {
12443 +       uint32_t index;
12444 +       uint32_t count;
12445 +       char __user *data;
12446 +};
12447 +
12448 +struct  vcmd_read_monitor_v0 {
12449 +       uint32_t index;
12450 +       uint32_t count;
12451 +       char __user *data;
12452 +};
12453 +
12454 +
12455 +#ifdef __KERNEL__
12456 +
12457 +#ifdef CONFIG_COMPAT
12458 +
12459 +#include <asm/compat.h>
12460 +
12461 +struct vcmd_read_history_v0_x32 {
12462 +       uint32_t index;
12463 +       uint32_t count;
12464 +       compat_uptr_t data_ptr;
12465 +};
12466 +
12467 +struct vcmd_read_monitor_v0_x32 {
12468 +       uint32_t index;
12469 +       uint32_t count;
12470 +       compat_uptr_t data_ptr;
12471 +};
12472 +
12473 +#endif  /* CONFIG_COMPAT */
12474 +
12475 +extern int vc_dump_history(uint32_t);
12476 +
12477 +extern int vc_read_history(uint32_t, void __user *);
12478 +extern int vc_read_monitor(uint32_t, void __user *);
12479 +
12480 +#ifdef CONFIG_COMPAT
12481 +
12482 +extern int vc_read_history_x32(uint32_t, void __user *);
12483 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12484 +
12485 +#endif  /* CONFIG_COMPAT */
12486 +
12487 +#endif /* __KERNEL__ */
12488 +#endif /* _VX_DEBUG_CMD_H */
12489 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/debug.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/debug.h
12490 --- linux-2.6.34/include/linux/vserver/debug.h  1970-01-01 01:00:00.000000000 +0100
12491 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/debug.h     2010-05-18 18:11:22.000000000 +0200
12492 @@ -0,0 +1,127 @@
12493 +#ifndef _VX_DEBUG_H
12494 +#define _VX_DEBUG_H
12495 +
12496 +
12497 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12498 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12499 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12500 +
12501 +#define VXD_DEV(d)     (d), (d)->bd_inode->i_ino,              \
12502 +                       imajor((d)->bd_inode), iminor((d)->bd_inode)
12503 +#define VXF_DEV                "%p[%lu,%d:%d]"
12504 +
12505 +
12506 +#define vxd_path(p)                                            \
12507 +       ({ static char _buffer[PATH_MAX];                       \
12508 +          d_path(p, _buffer, sizeof(_buffer)); })
12509 +
12510 +#define vxd_cond_path(n)                                       \
12511 +       ((n) ? vxd_path(&(n)->path) : "<null>" )
12512 +
12513 +
12514 +#ifdef CONFIG_VSERVER_DEBUG
12515 +
12516 +extern unsigned int vx_debug_switch;
12517 +extern unsigned int vx_debug_xid;
12518 +extern unsigned int vx_debug_nid;
12519 +extern unsigned int vx_debug_tag;
12520 +extern unsigned int vx_debug_net;
12521 +extern unsigned int vx_debug_limit;
12522 +extern unsigned int vx_debug_cres;
12523 +extern unsigned int vx_debug_dlim;
12524 +extern unsigned int vx_debug_quota;
12525 +extern unsigned int vx_debug_cvirt;
12526 +extern unsigned int vx_debug_space;
12527 +extern unsigned int vx_debug_misc;
12528 +
12529 +
12530 +#define VX_LOGLEVEL    "vxD: "
12531 +#define VX_PROC_FMT    "%p: "
12532 +#define VX_PROCESS     current
12533 +
12534 +#define vxdprintk(c, f, x...)                                  \
12535 +       do {                                                    \
12536 +               if (c)                                          \
12537 +                       printk(VX_LOGLEVEL VX_PROC_FMT f "\n",  \
12538 +                               VX_PROCESS , ##x);              \
12539 +       } while (0)
12540 +
12541 +#define vxlprintk(c, f, x...)                                  \
12542 +       do {                                                    \
12543 +               if (c)                                          \
12544 +                       printk(VX_LOGLEVEL f " @%s:%d\n", x);   \
12545 +       } while (0)
12546 +
12547 +#define vxfprintk(c, f, x...)                                  \
12548 +       do {                                                    \
12549 +               if (c)                                          \
12550 +                       printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12551 +       } while (0)
12552 +
12553 +
12554 +struct vx_info;
12555 +
12556 +void dump_vx_info(struct vx_info *, int);
12557 +void dump_vx_info_inactive(int);
12558 +
12559 +#else  /* CONFIG_VSERVER_DEBUG */
12560 +
12561 +#define vx_debug_switch 0
12562 +#define vx_debug_xid   0
12563 +#define vx_debug_nid   0
12564 +#define vx_debug_tag   0
12565 +#define vx_debug_net   0
12566 +#define vx_debug_limit 0
12567 +#define vx_debug_cres  0
12568 +#define vx_debug_dlim  0
12569 +#define vx_debug_cvirt 0
12570 +
12571 +#define vxdprintk(x...) do { } while (0)
12572 +#define vxlprintk(x...) do { } while (0)
12573 +#define vxfprintk(x...) do { } while (0)
12574 +
12575 +#endif /* CONFIG_VSERVER_DEBUG */
12576 +
12577 +
12578 +#ifdef CONFIG_VSERVER_WARN
12579 +
12580 +#define VX_WARNLEVEL   KERN_WARNING "vxW: "
12581 +#define VX_WARN_TASK   "[»%s«,%u:#%u|%u|%u] "
12582 +#define VX_WARN_XID    "[xid #%u] "
12583 +#define VX_WARN_NID    "[nid #%u] "
12584 +#define VX_WARN_TAG    "[tag #%u] "
12585 +
12586 +#define vxwprintk(c, f, x...)                                  \
12587 +       do {                                                    \
12588 +               if (c)                                          \
12589 +                       printk(VX_WARNLEVEL f "\n", ##x);       \
12590 +       } while (0)
12591 +
12592 +#else  /* CONFIG_VSERVER_WARN */
12593 +
12594 +#define vxwprintk(x...) do { } while (0)
12595 +
12596 +#endif /* CONFIG_VSERVER_WARN */
12597 +
12598 +#define vxwprintk_task(c, f, x...)                             \
12599 +       vxwprintk(c, VX_WARN_TASK f,                            \
12600 +               current->comm, current->pid,                    \
12601 +               current->xid, current->nid, current->tag, ##x)
12602 +#define vxwprintk_xid(c, f, x...)                              \
12603 +       vxwprintk(c, VX_WARN_XID f, current->xid, x)
12604 +#define vxwprintk_nid(c, f, x...)                              \
12605 +       vxwprintk(c, VX_WARN_NID f, current->nid, x)
12606 +#define vxwprintk_tag(c, f, x...)                              \
12607 +       vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12608 +
12609 +#ifdef CONFIG_VSERVER_DEBUG
12610 +#define vxd_assert_lock(l)     assert_spin_locked(l)
12611 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12612 +       "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12613 +#else
12614 +#define vxd_assert_lock(l)     do { } while (0)
12615 +#define vxd_assert(c, f, x...) do { } while (0)
12616 +#endif
12617 +
12618 +
12619 +#endif /* _VX_DEBUG_H */
12620 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/device_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/device_cmd.h
12621 --- linux-2.6.34/include/linux/vserver/device_cmd.h     1970-01-01 01:00:00.000000000 +0100
12622 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/device_cmd.h        2010-05-18 18:11:22.000000000 +0200
12623 @@ -0,0 +1,44 @@
12624 +#ifndef _VX_DEVICE_CMD_H
12625 +#define _VX_DEVICE_CMD_H
12626 +
12627 +
12628 +/*  device vserver commands */
12629 +
12630 +#define VCMD_set_mapping       VC_CMD(DEVICE, 1, 0)
12631 +#define VCMD_unset_mapping     VC_CMD(DEVICE, 2, 0)
12632 +
12633 +struct vcmd_set_mapping_v0 {
12634 +       const char __user *device;
12635 +       const char __user *target;
12636 +       uint32_t flags;
12637 +};
12638 +
12639 +
12640 +#ifdef __KERNEL__
12641 +
12642 +#ifdef CONFIG_COMPAT
12643 +
12644 +#include <asm/compat.h>
12645 +
12646 +struct vcmd_set_mapping_v0_x32 {
12647 +       compat_uptr_t device_ptr;
12648 +       compat_uptr_t target_ptr;
12649 +       uint32_t flags;
12650 +};
12651 +
12652 +#endif /* CONFIG_COMPAT */
12653 +
12654 +#include <linux/compiler.h>
12655 +
12656 +extern int vc_set_mapping(struct vx_info *, void __user *);
12657 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12658 +
12659 +#ifdef CONFIG_COMPAT
12660 +
12661 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12662 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12663 +
12664 +#endif /* CONFIG_COMPAT */
12665 +
12666 +#endif /* __KERNEL__ */
12667 +#endif /* _VX_DEVICE_CMD_H */
12668 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/device_def.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/device_def.h
12669 --- linux-2.6.34/include/linux/vserver/device_def.h     1970-01-01 01:00:00.000000000 +0100
12670 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/device_def.h        2010-05-18 18:11:22.000000000 +0200
12671 @@ -0,0 +1,17 @@
12672 +#ifndef _VX_DEVICE_DEF_H
12673 +#define _VX_DEVICE_DEF_H
12674 +
12675 +#include <linux/types.h>
12676 +
12677 +struct vx_dmap_target {
12678 +       dev_t target;
12679 +       uint32_t flags;
12680 +};
12681 +
12682 +struct _vx_device {
12683 +#ifdef CONFIG_VSERVER_DEVICE
12684 +       struct vx_dmap_target targets[2];
12685 +#endif
12686 +};
12687 +
12688 +#endif /* _VX_DEVICE_DEF_H */
12689 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/device.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/device.h
12690 --- linux-2.6.34/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
12691 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/device.h    2010-05-18 18:11:22.000000000 +0200
12692 @@ -0,0 +1,15 @@
12693 +#ifndef _VX_DEVICE_H
12694 +#define _VX_DEVICE_H
12695 +
12696 +
12697 +#define DATTR_CREATE   0x00000001
12698 +#define DATTR_OPEN     0x00000002
12699 +
12700 +#define DATTR_REMAP    0x00000010
12701 +
12702 +#define DATTR_MASK     0x00000013
12703 +
12704 +
12705 +#else  /* _VX_DEVICE_H */
12706 +#warning duplicate inclusion
12707 +#endif /* _VX_DEVICE_H */
12708 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/dlimit_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/dlimit_cmd.h
12709 --- linux-2.6.34/include/linux/vserver/dlimit_cmd.h     1970-01-01 01:00:00.000000000 +0100
12710 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/dlimit_cmd.h        2010-05-18 18:11:22.000000000 +0200
12711 @@ -0,0 +1,109 @@
12712 +#ifndef _VX_DLIMIT_CMD_H
12713 +#define _VX_DLIMIT_CMD_H
12714 +
12715 +
12716 +/*  dlimit vserver commands */
12717 +
12718 +#define VCMD_add_dlimit                VC_CMD(DLIMIT, 1, 0)
12719 +#define VCMD_rem_dlimit                VC_CMD(DLIMIT, 2, 0)
12720 +
12721 +#define VCMD_set_dlimit                VC_CMD(DLIMIT, 5, 0)
12722 +#define VCMD_get_dlimit                VC_CMD(DLIMIT, 6, 0)
12723 +
12724 +struct vcmd_ctx_dlimit_base_v0 {
12725 +       const char __user *name;
12726 +       uint32_t flags;
12727 +};
12728 +
12729 +struct vcmd_ctx_dlimit_v0 {
12730 +       const char __user *name;
12731 +       uint32_t space_used;                    /* used space in kbytes */
12732 +       uint32_t space_total;                   /* maximum space in kbytes */
12733 +       uint32_t inodes_used;                   /* used inodes */
12734 +       uint32_t inodes_total;                  /* maximum inodes */
12735 +       uint32_t reserved;                      /* reserved for root in % */
12736 +       uint32_t flags;
12737 +};
12738 +
12739 +#define CDLIM_UNSET            ((uint32_t)0UL)
12740 +#define CDLIM_INFINITY         ((uint32_t)~0UL)
12741 +#define CDLIM_KEEP             ((uint32_t)~1UL)
12742 +
12743 +#define DLIME_UNIT     0
12744 +#define DLIME_KILO     1
12745 +#define DLIME_MEGA     2
12746 +#define DLIME_GIGA     3
12747 +
12748 +#define DLIMF_SHIFT    0x10
12749 +
12750 +#define DLIMS_USED     0
12751 +#define DLIMS_TOTAL    2
12752 +
12753 +static inline
12754 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12755 +{
12756 +       int exp = (flags & DLIMF_SHIFT) ?
12757 +               (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12758 +       return ((uint64_t)val) << (10 * exp);
12759 +}
12760 +
12761 +static inline
12762 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12763 +{
12764 +       int exp = 0;
12765 +
12766 +       if (*flags & DLIMF_SHIFT) {
12767 +               while (val > (1LL << 32) && (exp < 3)) {
12768 +                       val >>= 10;
12769 +                       exp++;
12770 +               }
12771 +               *flags &= ~(DLIME_GIGA << shift);
12772 +               *flags |= exp << shift;
12773 +       } else
12774 +               val >>= 10;
12775 +       return val;
12776 +}
12777 +
12778 +#ifdef __KERNEL__
12779 +
12780 +#ifdef CONFIG_COMPAT
12781 +
12782 +#include <asm/compat.h>
12783 +
12784 +struct vcmd_ctx_dlimit_base_v0_x32 {
12785 +       compat_uptr_t name_ptr;
12786 +       uint32_t flags;
12787 +};
12788 +
12789 +struct vcmd_ctx_dlimit_v0_x32 {
12790 +       compat_uptr_t name_ptr;
12791 +       uint32_t space_used;                    /* used space in kbytes */
12792 +       uint32_t space_total;                   /* maximum space in kbytes */
12793 +       uint32_t inodes_used;                   /* used inodes */
12794 +       uint32_t inodes_total;                  /* maximum inodes */
12795 +       uint32_t reserved;                      /* reserved for root in % */
12796 +       uint32_t flags;
12797 +};
12798 +
12799 +#endif /* CONFIG_COMPAT */
12800 +
12801 +#include <linux/compiler.h>
12802 +
12803 +extern int vc_add_dlimit(uint32_t, void __user *);
12804 +extern int vc_rem_dlimit(uint32_t, void __user *);
12805 +
12806 +extern int vc_set_dlimit(uint32_t, void __user *);
12807 +extern int vc_get_dlimit(uint32_t, void __user *);
12808 +
12809 +#ifdef CONFIG_COMPAT
12810 +
12811 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12812 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12813 +
12814 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12815 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12816 +
12817 +#endif /* CONFIG_COMPAT */
12818 +
12819 +#endif /* __KERNEL__ */
12820 +#endif /* _VX_DLIMIT_CMD_H */
12821 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/dlimit.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/dlimit.h
12822 --- linux-2.6.34/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12823 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/dlimit.h    2010-05-18 18:11:22.000000000 +0200
12824 @@ -0,0 +1,54 @@
12825 +#ifndef _VX_DLIMIT_H
12826 +#define _VX_DLIMIT_H
12827 +
12828 +#include "switch.h"
12829 +
12830 +
12831 +#ifdef __KERNEL__
12832 +
12833 +/*      keep in sync with CDLIM_INFINITY       */
12834 +
12835 +#define DLIM_INFINITY          (~0ULL)
12836 +
12837 +#include <linux/spinlock.h>
12838 +#include <linux/rcupdate.h>
12839 +
12840 +struct super_block;
12841 +
12842 +struct dl_info {
12843 +       struct hlist_node dl_hlist;             /* linked list of contexts */
12844 +       struct rcu_head dl_rcu;                 /* the rcu head */
12845 +       tag_t dl_tag;                           /* context tag */
12846 +       atomic_t dl_usecnt;                     /* usage count */
12847 +       atomic_t dl_refcnt;                     /* reference count */
12848 +
12849 +       struct super_block *dl_sb;              /* associated superblock */
12850 +
12851 +       spinlock_t dl_lock;                     /* protect the values */
12852 +
12853 +       unsigned long long dl_space_used;       /* used space in bytes */
12854 +       unsigned long long dl_space_total;      /* maximum space in bytes */
12855 +       unsigned long dl_inodes_used;           /* used inodes */
12856 +       unsigned long dl_inodes_total;          /* maximum inodes */
12857 +
12858 +       unsigned int dl_nrlmult;                /* non root limit mult */
12859 +};
12860 +
12861 +struct rcu_head;
12862 +
12863 +extern void rcu_free_dl_info(struct rcu_head *);
12864 +extern void unhash_dl_info(struct dl_info *);
12865 +
12866 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12867 +
12868 +
12869 +struct kstatfs;
12870 +
12871 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12872 +
12873 +typedef uint64_t dlsize_t;
12874 +
12875 +#endif /* __KERNEL__ */
12876 +#else  /* _VX_DLIMIT_H */
12877 +#warning duplicate inclusion
12878 +#endif /* _VX_DLIMIT_H */
12879 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/global.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/global.h
12880 --- linux-2.6.34/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12881 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/global.h    2010-05-18 18:11:22.000000000 +0200
12882 @@ -0,0 +1,19 @@
12883 +#ifndef _VX_GLOBAL_H
12884 +#define _VX_GLOBAL_H
12885 +
12886 +
12887 +extern atomic_t vx_global_ctotal;
12888 +extern atomic_t vx_global_cactive;
12889 +
12890 +extern atomic_t nx_global_ctotal;
12891 +extern atomic_t nx_global_cactive;
12892 +
12893 +extern atomic_t vs_global_nsproxy;
12894 +extern atomic_t vs_global_fs;
12895 +extern atomic_t vs_global_mnt_ns;
12896 +extern atomic_t vs_global_uts_ns;
12897 +extern atomic_t vs_global_user_ns;
12898 +extern atomic_t vs_global_pid_ns;
12899 +
12900 +
12901 +#endif /* _VX_GLOBAL_H */
12902 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/history.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/history.h
12903 --- linux-2.6.34/include/linux/vserver/history.h        1970-01-01 01:00:00.000000000 +0100
12904 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/history.h   2010-05-18 18:11:22.000000000 +0200
12905 @@ -0,0 +1,197 @@
12906 +#ifndef _VX_HISTORY_H
12907 +#define _VX_HISTORY_H
12908 +
12909 +
12910 +enum {
12911 +       VXH_UNUSED = 0,
12912 +       VXH_THROW_OOPS = 1,
12913 +
12914 +       VXH_GET_VX_INFO,
12915 +       VXH_PUT_VX_INFO,
12916 +       VXH_INIT_VX_INFO,
12917 +       VXH_SET_VX_INFO,
12918 +       VXH_CLR_VX_INFO,
12919 +       VXH_CLAIM_VX_INFO,
12920 +       VXH_RELEASE_VX_INFO,
12921 +       VXH_ALLOC_VX_INFO,
12922 +       VXH_DEALLOC_VX_INFO,
12923 +       VXH_HASH_VX_INFO,
12924 +       VXH_UNHASH_VX_INFO,
12925 +       VXH_LOC_VX_INFO,
12926 +       VXH_LOOKUP_VX_INFO,
12927 +       VXH_CREATE_VX_INFO,
12928 +};
12929 +
12930 +struct _vxhe_vxi {
12931 +       struct vx_info *ptr;
12932 +       unsigned xid;
12933 +       unsigned usecnt;
12934 +       unsigned tasks;
12935 +};
12936 +
12937 +struct _vxhe_set_clr {
12938 +       void *data;
12939 +};
12940 +
12941 +struct _vxhe_loc_lookup {
12942 +       unsigned arg;
12943 +};
12944 +
12945 +struct _vx_hist_entry {
12946 +       void *loc;
12947 +       unsigned short seq;
12948 +       unsigned short type;
12949 +       struct _vxhe_vxi vxi;
12950 +       union {
12951 +               struct _vxhe_set_clr sc;
12952 +               struct _vxhe_loc_lookup ll;
12953 +       };
12954 +};
12955 +
12956 +#ifdef CONFIG_VSERVER_HISTORY
12957 +
12958 +extern unsigned volatile int vxh_active;
12959 +
12960 +struct _vx_hist_entry *vxh_advance(void *loc);
12961 +
12962 +
12963 +static inline
12964 +void   __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12965 +{
12966 +       entry->vxi.ptr = vxi;
12967 +       if (vxi) {
12968 +               entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12969 +               entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12970 +               entry->vxi.xid = vxi->vx_id;
12971 +       }
12972 +}
12973 +
12974 +
12975 +#define        __HERE__ current_text_addr()
12976 +
12977 +#define __VXH_BODY(__type, __data, __here)     \
12978 +       struct _vx_hist_entry *entry;           \
12979 +                                               \
12980 +       preempt_disable();                      \
12981 +       entry = vxh_advance(__here);            \
12982 +       __data;                                 \
12983 +       entry->type = __type;                   \
12984 +       preempt_enable();
12985 +
12986 +
12987 +       /* pass vxi only */
12988 +
12989 +#define __VXH_SMPL                             \
12990 +       __vxh_copy_vxi(entry, vxi)
12991 +
12992 +static inline
12993 +void   __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12994 +{
12995 +       __VXH_BODY(__type, __VXH_SMPL, __here)
12996 +}
12997 +
12998 +       /* pass vxi and data (void *) */
12999 +
13000 +#define __VXH_DATA                             \
13001 +       __vxh_copy_vxi(entry, vxi);             \
13002 +       entry->sc.data = data
13003 +
13004 +static inline
13005 +void   __vxh_data(struct vx_info *vxi, void *data,
13006 +                       int __type, void *__here)
13007 +{
13008 +       __VXH_BODY(__type, __VXH_DATA, __here)
13009 +}
13010 +
13011 +       /* pass vxi and arg (long) */
13012 +
13013 +#define __VXH_LONG                             \
13014 +       __vxh_copy_vxi(entry, vxi);             \
13015 +       entry->ll.arg = arg
13016 +
13017 +static inline
13018 +void   __vxh_long(struct vx_info *vxi, long arg,
13019 +                       int __type, void *__here)
13020 +{
13021 +       __VXH_BODY(__type, __VXH_LONG, __here)
13022 +}
13023 +
13024 +
13025 +static inline
13026 +void   __vxh_throw_oops(void *__here)
13027 +{
13028 +       __VXH_BODY(VXH_THROW_OOPS, {}, __here);
13029 +       /* prevent further acquisition */
13030 +       vxh_active = 0;
13031 +}
13032 +
13033 +
13034 +#define vxh_throw_oops()       __vxh_throw_oops(__HERE__);
13035 +
13036 +#define __vxh_get_vx_info(v, h)        __vxh_smpl(v, VXH_GET_VX_INFO, h);
13037 +#define __vxh_put_vx_info(v, h)        __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13038 +
13039 +#define __vxh_init_vx_info(v, d, h) \
13040 +       __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13041 +#define __vxh_set_vx_info(v, d, h) \
13042 +       __vxh_data(v, d, VXH_SET_VX_INFO, h);
13043 +#define __vxh_clr_vx_info(v, d, h) \
13044 +       __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13045 +
13046 +#define __vxh_claim_vx_info(v, d, h) \
13047 +       __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13048 +#define __vxh_release_vx_info(v, d, h) \
13049 +       __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13050 +
13051 +#define vxh_alloc_vx_info(v) \
13052 +       __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13053 +#define vxh_dealloc_vx_info(v) \
13054 +       __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13055 +
13056 +#define vxh_hash_vx_info(v) \
13057 +       __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13058 +#define vxh_unhash_vx_info(v) \
13059 +       __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13060 +
13061 +#define vxh_loc_vx_info(v, l) \
13062 +       __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13063 +#define vxh_lookup_vx_info(v, l) \
13064 +       __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13065 +#define vxh_create_vx_info(v, l) \
13066 +       __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13067 +
13068 +extern void vxh_dump_history(void);
13069 +
13070 +
13071 +#else  /* CONFIG_VSERVER_HISTORY */
13072 +
13073 +#define        __HERE__        0
13074 +
13075 +#define vxh_throw_oops()               do { } while (0)
13076 +
13077 +#define __vxh_get_vx_info(v, h)                do { } while (0)
13078 +#define __vxh_put_vx_info(v, h)                do { } while (0)
13079 +
13080 +#define __vxh_init_vx_info(v, d, h)    do { } while (0)
13081 +#define __vxh_set_vx_info(v, d, h)     do { } while (0)
13082 +#define __vxh_clr_vx_info(v, d, h)     do { } while (0)
13083 +
13084 +#define __vxh_claim_vx_info(v, d, h)   do { } while (0)
13085 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13086 +
13087 +#define vxh_alloc_vx_info(v)           do { } while (0)
13088 +#define vxh_dealloc_vx_info(v)         do { } while (0)
13089 +
13090 +#define vxh_hash_vx_info(v)            do { } while (0)
13091 +#define vxh_unhash_vx_info(v)          do { } while (0)
13092 +
13093 +#define vxh_loc_vx_info(v, l)          do { } while (0)
13094 +#define vxh_lookup_vx_info(v, l)       do { } while (0)
13095 +#define vxh_create_vx_info(v, l)       do { } while (0)
13096 +
13097 +#define vxh_dump_history()             do { } while (0)
13098 +
13099 +
13100 +#endif /* CONFIG_VSERVER_HISTORY */
13101 +
13102 +#endif /* _VX_HISTORY_H */
13103 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/inode_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/inode_cmd.h
13104 --- linux-2.6.34/include/linux/vserver/inode_cmd.h      1970-01-01 01:00:00.000000000 +0100
13105 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/inode_cmd.h 2010-05-18 18:11:22.000000000 +0200
13106 @@ -0,0 +1,59 @@
13107 +#ifndef _VX_INODE_CMD_H
13108 +#define _VX_INODE_CMD_H
13109 +
13110 +
13111 +/*  inode vserver commands */
13112 +
13113 +#define VCMD_get_iattr         VC_CMD(INODE, 1, 1)
13114 +#define VCMD_set_iattr         VC_CMD(INODE, 2, 1)
13115 +
13116 +#define VCMD_fget_iattr                VC_CMD(INODE, 3, 0)
13117 +#define VCMD_fset_iattr                VC_CMD(INODE, 4, 0)
13118 +
13119 +struct vcmd_ctx_iattr_v1 {
13120 +       const char __user *name;
13121 +       uint32_t tag;
13122 +       uint32_t flags;
13123 +       uint32_t mask;
13124 +};
13125 +
13126 +struct vcmd_ctx_fiattr_v0 {
13127 +       uint32_t tag;
13128 +       uint32_t flags;
13129 +       uint32_t mask;
13130 +};
13131 +
13132 +
13133 +#ifdef __KERNEL__
13134 +
13135 +
13136 +#ifdef CONFIG_COMPAT
13137 +
13138 +#include <asm/compat.h>
13139 +
13140 +struct vcmd_ctx_iattr_v1_x32 {
13141 +       compat_uptr_t name_ptr;
13142 +       uint32_t tag;
13143 +       uint32_t flags;
13144 +       uint32_t mask;
13145 +};
13146 +
13147 +#endif /* CONFIG_COMPAT */
13148 +
13149 +#include <linux/compiler.h>
13150 +
13151 +extern int vc_get_iattr(void __user *);
13152 +extern int vc_set_iattr(void __user *);
13153 +
13154 +extern int vc_fget_iattr(uint32_t, void __user *);
13155 +extern int vc_fset_iattr(uint32_t, void __user *);
13156 +
13157 +#ifdef CONFIG_COMPAT
13158 +
13159 +extern int vc_get_iattr_x32(void __user *);
13160 +extern int vc_set_iattr_x32(void __user *);
13161 +
13162 +#endif /* CONFIG_COMPAT */
13163 +
13164 +#endif /* __KERNEL__ */
13165 +#endif /* _VX_INODE_CMD_H */
13166 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/inode.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/inode.h
13167 --- linux-2.6.34/include/linux/vserver/inode.h  1970-01-01 01:00:00.000000000 +0100
13168 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/inode.h     2010-05-18 18:11:22.000000000 +0200
13169 @@ -0,0 +1,39 @@
13170 +#ifndef _VX_INODE_H
13171 +#define _VX_INODE_H
13172 +
13173 +
13174 +#define IATTR_TAG      0x01000000
13175 +
13176 +#define IATTR_ADMIN    0x00000001
13177 +#define IATTR_WATCH    0x00000002
13178 +#define IATTR_HIDE     0x00000004
13179 +#define IATTR_FLAGS    0x00000007
13180 +
13181 +#define IATTR_BARRIER  0x00010000
13182 +#define IATTR_IXUNLINK 0x00020000
13183 +#define IATTR_IMMUTABLE 0x00040000
13184 +#define IATTR_COW      0x00080000
13185 +
13186 +#ifdef __KERNEL__
13187 +
13188 +
13189 +#ifdef CONFIG_VSERVER_PROC_SECURE
13190 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN | IATTR_HIDE )
13191 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
13192 +#else
13193 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN )
13194 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
13195 +#endif
13196 +
13197 +#define vx_hide_check(c, m)    (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
13198 +
13199 +#endif /* __KERNEL__ */
13200 +
13201 +/* inode ioctls */
13202 +
13203 +#define FIOC_GETXFLG   _IOR('x', 5, long)
13204 +#define FIOC_SETXFLG   _IOW('x', 6, long)
13205 +
13206 +#else  /* _VX_INODE_H */
13207 +#warning duplicate inclusion
13208 +#endif /* _VX_INODE_H */
13209 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/Kbuild linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/Kbuild
13210 --- linux-2.6.34/include/linux/vserver/Kbuild   1970-01-01 01:00:00.000000000 +0100
13211 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/Kbuild      2010-05-18 18:11:22.000000000 +0200
13212 @@ -0,0 +1,8 @@
13213 +
13214 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
13215 +       cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
13216 +       inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
13217 +       debug_cmd.h device_cmd.h
13218 +
13219 +unifdef-y += switch.h network.h monitor.h inode.h device.h
13220 +
13221 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/limit_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/limit_cmd.h
13222 --- linux-2.6.34/include/linux/vserver/limit_cmd.h      1970-01-01 01:00:00.000000000 +0100
13223 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/limit_cmd.h 2010-05-18 18:11:22.000000000 +0200
13224 @@ -0,0 +1,71 @@
13225 +#ifndef _VX_LIMIT_CMD_H
13226 +#define _VX_LIMIT_CMD_H
13227 +
13228 +
13229 +/*  rlimit vserver commands */
13230 +
13231 +#define VCMD_get_rlimit                VC_CMD(RLIMIT, 1, 0)
13232 +#define VCMD_set_rlimit                VC_CMD(RLIMIT, 2, 0)
13233 +#define VCMD_get_rlimit_mask   VC_CMD(RLIMIT, 3, 0)
13234 +#define VCMD_reset_hits                VC_CMD(RLIMIT, 7, 0)
13235 +#define VCMD_reset_minmax      VC_CMD(RLIMIT, 9, 0)
13236 +
13237 +struct vcmd_ctx_rlimit_v0 {
13238 +       uint32_t id;
13239 +       uint64_t minimum;
13240 +       uint64_t softlimit;
13241 +       uint64_t maximum;
13242 +};
13243 +
13244 +struct vcmd_ctx_rlimit_mask_v0 {
13245 +       uint32_t minimum;
13246 +       uint32_t softlimit;
13247 +       uint32_t maximum;
13248 +};
13249 +
13250 +#define VCMD_rlimit_stat       VC_CMD(VSTAT, 1, 0)
13251 +
13252 +struct vcmd_rlimit_stat_v0 {
13253 +       uint32_t id;
13254 +       uint32_t hits;
13255 +       uint64_t value;
13256 +       uint64_t minimum;
13257 +       uint64_t maximum;
13258 +};
13259 +
13260 +#define CRLIM_UNSET            (0ULL)
13261 +#define CRLIM_INFINITY         (~0ULL)
13262 +#define CRLIM_KEEP             (~1ULL)
13263 +
13264 +#ifdef __KERNEL__
13265 +
13266 +#ifdef CONFIG_IA32_EMULATION
13267 +
13268 +struct vcmd_ctx_rlimit_v0_x32 {
13269 +       uint32_t id;
13270 +       uint64_t minimum;
13271 +       uint64_t softlimit;
13272 +       uint64_t maximum;
13273 +} __attribute__ ((packed));
13274 +
13275 +#endif /* CONFIG_IA32_EMULATION */
13276 +
13277 +#include <linux/compiler.h>
13278 +
13279 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13280 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13281 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13282 +extern int vc_reset_hits(struct vx_info *, void __user *);
13283 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13284 +
13285 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13286 +
13287 +#ifdef CONFIG_IA32_EMULATION
13288 +
13289 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13290 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13291 +
13292 +#endif /* CONFIG_IA32_EMULATION */
13293 +
13294 +#endif /* __KERNEL__ */
13295 +#endif /* _VX_LIMIT_CMD_H */
13296 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/limit_def.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/limit_def.h
13297 --- linux-2.6.34/include/linux/vserver/limit_def.h      1970-01-01 01:00:00.000000000 +0100
13298 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/limit_def.h 2010-05-18 18:11:22.000000000 +0200
13299 @@ -0,0 +1,47 @@
13300 +#ifndef _VX_LIMIT_DEF_H
13301 +#define _VX_LIMIT_DEF_H
13302 +
13303 +#include <asm/atomic.h>
13304 +#include <asm/resource.h>
13305 +
13306 +#include "limit.h"
13307 +
13308 +
13309 +struct _vx_res_limit {
13310 +       rlim_t soft;            /* Context soft limit */
13311 +       rlim_t hard;            /* Context hard limit */
13312 +
13313 +       rlim_atomic_t rcur;     /* Current value */
13314 +       rlim_t rmin;            /* Context minimum */
13315 +       rlim_t rmax;            /* Context maximum */
13316 +
13317 +       atomic_t lhit;          /* Limit hits */
13318 +};
13319 +
13320 +/* context sub struct */
13321 +
13322 +struct _vx_limit {
13323 +       struct _vx_res_limit res[NUM_LIMITS];
13324 +};
13325 +
13326 +#ifdef CONFIG_VSERVER_DEBUG
13327 +
13328 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13329 +{
13330 +       int i;
13331 +
13332 +       printk("\t_vx_limit:");
13333 +       for (i = 0; i < NUM_LIMITS; i++) {
13334 +               printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13335 +                       i, (unsigned long)__rlim_get(limit, i),
13336 +                       (unsigned long)__rlim_rmin(limit, i),
13337 +                       (unsigned long)__rlim_rmax(limit, i),
13338 +                       (long)__rlim_soft(limit, i),
13339 +                       (long)__rlim_hard(limit, i),
13340 +                       atomic_read(&__rlim_lhit(limit, i)));
13341 +       }
13342 +}
13343 +
13344 +#endif
13345 +
13346 +#endif /* _VX_LIMIT_DEF_H */
13347 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/limit.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/limit.h
13348 --- linux-2.6.34/include/linux/vserver/limit.h  1970-01-01 01:00:00.000000000 +0100
13349 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/limit.h     2010-05-18 18:11:22.000000000 +0200
13350 @@ -0,0 +1,71 @@
13351 +#ifndef _VX_LIMIT_H
13352 +#define _VX_LIMIT_H
13353 +
13354 +#define VLIMIT_NSOCK   16
13355 +#define VLIMIT_OPENFD  17
13356 +#define VLIMIT_ANON    18
13357 +#define VLIMIT_SHMEM   19
13358 +#define VLIMIT_SEMARY  20
13359 +#define VLIMIT_NSEMS   21
13360 +#define VLIMIT_DENTRY  22
13361 +#define VLIMIT_MAPPED  23
13362 +
13363 +
13364 +#ifdef __KERNEL__
13365 +
13366 +#define        VLIM_NOCHECK    ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13367 +
13368 +/*     keep in sync with CRLIM_INFINITY */
13369 +
13370 +#define        VLIM_INFINITY   (~0ULL)
13371 +
13372 +#include <asm/atomic.h>
13373 +#include <asm/resource.h>
13374 +
13375 +#ifndef RLIM_INFINITY
13376 +#warning RLIM_INFINITY is undefined
13377 +#endif
13378 +
13379 +#define __rlim_val(l, r, v)    ((l)->res[r].v)
13380 +
13381 +#define __rlim_soft(l, r)      __rlim_val(l, r, soft)
13382 +#define __rlim_hard(l, r)      __rlim_val(l, r, hard)
13383 +
13384 +#define __rlim_rcur(l, r)      __rlim_val(l, r, rcur)
13385 +#define __rlim_rmin(l, r)      __rlim_val(l, r, rmin)
13386 +#define __rlim_rmax(l, r)      __rlim_val(l, r, rmax)
13387 +
13388 +#define __rlim_lhit(l, r)      __rlim_val(l, r, lhit)
13389 +#define __rlim_hit(l, r)       atomic_inc(&__rlim_lhit(l, r))
13390 +
13391 +typedef atomic_long_t rlim_atomic_t;
13392 +typedef unsigned long rlim_t;
13393 +
13394 +#define __rlim_get(l, r)       atomic_long_read(&__rlim_rcur(l, r))
13395 +#define __rlim_set(l, r, v)    atomic_long_set(&__rlim_rcur(l, r), v)
13396 +#define __rlim_inc(l, r)       atomic_long_inc(&__rlim_rcur(l, r))
13397 +#define __rlim_dec(l, r)       atomic_long_dec(&__rlim_rcur(l, r))
13398 +#define __rlim_add(l, r, v)    atomic_long_add(v, &__rlim_rcur(l, r))
13399 +#define __rlim_sub(l, r, v)    atomic_long_sub(v, &__rlim_rcur(l, r))
13400 +
13401 +
13402 +#if    (RLIM_INFINITY == VLIM_INFINITY)
13403 +#define        VX_VLIM(r) ((long long)(long)(r))
13404 +#define        VX_RLIM(v) ((rlim_t)(v))
13405 +#else
13406 +#define        VX_VLIM(r) (((r) == RLIM_INFINITY) \
13407 +               ? VLIM_INFINITY : (long long)(r))
13408 +#define        VX_RLIM(v) (((v) == VLIM_INFINITY) \
13409 +               ? RLIM_INFINITY : (rlim_t)(v))
13410 +#endif
13411 +
13412 +struct sysinfo;
13413 +
13414 +void vx_vsi_meminfo(struct sysinfo *);
13415 +void vx_vsi_swapinfo(struct sysinfo *);
13416 +long vx_vsi_cached(struct sysinfo *);
13417 +
13418 +#define NUM_LIMITS     24
13419 +
13420 +#endif /* __KERNEL__ */
13421 +#endif /* _VX_LIMIT_H */
13422 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/limit_int.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/limit_int.h
13423 --- linux-2.6.34/include/linux/vserver/limit_int.h      1970-01-01 01:00:00.000000000 +0100
13424 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/limit_int.h 2010-05-18 18:11:22.000000000 +0200
13425 @@ -0,0 +1,198 @@
13426 +#ifndef _VX_LIMIT_INT_H
13427 +#define _VX_LIMIT_INT_H
13428 +
13429 +#include "context.h"
13430 +
13431 +#ifdef __KERNEL__
13432 +
13433 +#define VXD_RCRES_COND(r)      VXD_CBIT(cres, r)
13434 +#define VXD_RLIMIT_COND(r)     VXD_CBIT(limit, r)
13435 +
13436 +extern const char *vlimit_name[NUM_LIMITS];
13437 +
13438 +static inline void __vx_acc_cres(struct vx_info *vxi,
13439 +       int res, int dir, void *_data, char *_file, int _line)
13440 +{
13441 +       if (VXD_RCRES_COND(res))
13442 +               vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13443 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13444 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13445 +                       (dir > 0) ? "++" : "--", _data, _file, _line);
13446 +       if (!vxi)
13447 +               return;
13448 +
13449 +       if (dir > 0)
13450 +               __rlim_inc(&vxi->limit, res);
13451 +       else
13452 +               __rlim_dec(&vxi->limit, res);
13453 +}
13454 +
13455 +static inline void __vx_add_cres(struct vx_info *vxi,
13456 +       int res, int amount, void *_data, char *_file, int _line)
13457 +{
13458 +       if (VXD_RCRES_COND(res))
13459 +               vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13460 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13461 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13462 +                       amount, _data, _file, _line);
13463 +       if (amount == 0)
13464 +               return;
13465 +       if (!vxi)
13466 +               return;
13467 +       __rlim_add(&vxi->limit, res, amount);
13468 +}
13469 +
13470 +static inline
13471 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13472 +{
13473 +       int cond = (value > __rlim_rmax(limit, res));
13474 +
13475 +       if (cond)
13476 +               __rlim_rmax(limit, res) = value;
13477 +       return cond;
13478 +}
13479 +
13480 +static inline
13481 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13482 +{
13483 +       int cond = (value < __rlim_rmin(limit, res));
13484 +
13485 +       if (cond)
13486 +               __rlim_rmin(limit, res) = value;
13487 +       return cond;
13488 +}
13489 +
13490 +static inline
13491 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13492 +{
13493 +       if (!__vx_cres_adjust_max(limit, res, value))
13494 +               __vx_cres_adjust_min(limit, res, value);
13495 +}
13496 +
13497 +
13498 +/*     return values:
13499 +        +1 ... no limit hit
13500 +        -1 ... over soft limit
13501 +         0 ... over hard limit         */
13502 +
13503 +static inline int __vx_cres_avail(struct vx_info *vxi,
13504 +       int res, int num, char *_file, int _line)
13505 +{
13506 +       struct _vx_limit *limit;
13507 +       rlim_t value;
13508 +
13509 +       if (VXD_RLIMIT_COND(res))
13510 +               vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13511 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13512 +                       (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13513 +                       (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13514 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13515 +                       num, _file, _line);
13516 +       if (!vxi)
13517 +               return 1;
13518 +
13519 +       limit = &vxi->limit;
13520 +       value = __rlim_get(limit, res);
13521 +
13522 +       if (!__vx_cres_adjust_max(limit, res, value))
13523 +               __vx_cres_adjust_min(limit, res, value);
13524 +
13525 +       if (num == 0)
13526 +               return 1;
13527 +
13528 +       if (__rlim_soft(limit, res) == RLIM_INFINITY)
13529 +               return -1;
13530 +       if (value + num <= __rlim_soft(limit, res))
13531 +               return -1;
13532 +
13533 +       if (__rlim_hard(limit, res) == RLIM_INFINITY)
13534 +               return 1;
13535 +       if (value + num <= __rlim_hard(limit, res))
13536 +               return 1;
13537 +
13538 +       __rlim_hit(limit, res);
13539 +       return 0;
13540 +}
13541 +
13542 +
13543 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13544 +
13545 +static inline
13546 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13547 +{
13548 +       rlim_t value, sum = 0;
13549 +       int res;
13550 +
13551 +       while ((res = *array++)) {
13552 +               value = __rlim_get(limit, res);
13553 +               __vx_cres_fixup(limit, res, value);
13554 +               sum += value;
13555 +       }
13556 +       return sum;
13557 +}
13558 +
13559 +static inline
13560 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13561 +{
13562 +       rlim_t value = __vx_cres_array_sum(limit, array + 1);
13563 +       int res = *array;
13564 +
13565 +       if (value == __rlim_get(limit, res))
13566 +               return value;
13567 +
13568 +       __rlim_set(limit, res, value);
13569 +       /* now adjust min/max */
13570 +       if (!__vx_cres_adjust_max(limit, res, value))
13571 +               __vx_cres_adjust_min(limit, res, value);
13572 +
13573 +       return value;
13574 +}
13575 +
13576 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13577 +       const int *array, int num, char *_file, int _line)
13578 +{
13579 +       struct _vx_limit *limit;
13580 +       rlim_t value = 0;
13581 +       int res;
13582 +
13583 +       if (num == 0)
13584 +               return 1;
13585 +       if (!vxi)
13586 +               return 1;
13587 +
13588 +       limit = &vxi->limit;
13589 +       res = *array;
13590 +       value = __vx_cres_array_sum(limit, array + 1);
13591 +
13592 +       __rlim_set(limit, res, value);
13593 +       __vx_cres_fixup(limit, res, value);
13594 +
13595 +       return __vx_cres_avail(vxi, res, num, _file, _line);
13596 +}
13597 +
13598 +
13599 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13600 +{
13601 +       rlim_t value;
13602 +       int res;
13603 +
13604 +       /* complex resources first */
13605 +       if ((id < 0) || (id == RLIMIT_RSS))
13606 +               __vx_cres_array_fixup(limit, VLA_RSS);
13607 +
13608 +       for (res = 0; res < NUM_LIMITS; res++) {
13609 +               if ((id > 0) && (res != id))
13610 +                       continue;
13611 +
13612 +               value = __rlim_get(limit, res);
13613 +               __vx_cres_fixup(limit, res, value);
13614 +
13615 +               /* not supposed to happen, maybe warn? */
13616 +               if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13617 +                       __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13618 +       }
13619 +}
13620 +
13621 +
13622 +#endif /* __KERNEL__ */
13623 +#endif /* _VX_LIMIT_INT_H */
13624 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/monitor.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/monitor.h
13625 --- linux-2.6.34/include/linux/vserver/monitor.h        1970-01-01 01:00:00.000000000 +0100
13626 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/monitor.h   2010-05-18 18:11:22.000000000 +0200
13627 @@ -0,0 +1,96 @@
13628 +#ifndef _VX_MONITOR_H
13629 +#define _VX_MONITOR_H
13630 +
13631 +#include <linux/types.h>
13632 +
13633 +enum {
13634 +       VXM_UNUSED = 0,
13635 +
13636 +       VXM_SYNC = 0x10,
13637 +
13638 +       VXM_UPDATE = 0x20,
13639 +       VXM_UPDATE_1,
13640 +       VXM_UPDATE_2,
13641 +
13642 +       VXM_RQINFO_1 = 0x24,
13643 +       VXM_RQINFO_2,
13644 +
13645 +       VXM_ACTIVATE = 0x40,
13646 +       VXM_DEACTIVATE,
13647 +       VXM_IDLE,
13648 +
13649 +       VXM_HOLD = 0x44,
13650 +       VXM_UNHOLD,
13651 +
13652 +       VXM_MIGRATE = 0x48,
13653 +       VXM_RESCHED,
13654 +
13655 +       /* all other bits are flags */
13656 +       VXM_SCHED = 0x80,
13657 +};
13658 +
13659 +struct _vxm_update_1 {
13660 +       uint32_t tokens_max;
13661 +       uint32_t fill_rate;
13662 +       uint32_t interval;
13663 +};
13664 +
13665 +struct _vxm_update_2 {
13666 +       uint32_t tokens_min;
13667 +       uint32_t fill_rate;
13668 +       uint32_t interval;
13669 +};
13670 +
13671 +struct _vxm_rqinfo_1 {
13672 +       uint16_t running;
13673 +       uint16_t onhold;
13674 +       uint16_t iowait;
13675 +       uint16_t uintr;
13676 +       uint32_t idle_tokens;
13677 +};
13678 +
13679 +struct _vxm_rqinfo_2 {
13680 +       uint32_t norm_time;
13681 +       uint32_t idle_time;
13682 +       uint32_t idle_skip;
13683 +};
13684 +
13685 +struct _vxm_sched {
13686 +       uint32_t tokens;
13687 +       uint32_t norm_time;
13688 +       uint32_t idle_time;
13689 +};
13690 +
13691 +struct _vxm_task {
13692 +       uint16_t pid;
13693 +       uint16_t state;
13694 +};
13695 +
13696 +struct _vxm_event {
13697 +       uint32_t jif;
13698 +       union {
13699 +               uint32_t seq;
13700 +               uint32_t sec;
13701 +       };
13702 +       union {
13703 +               uint32_t tokens;
13704 +               uint32_t nsec;
13705 +               struct _vxm_task tsk;
13706 +       };
13707 +};
13708 +
13709 +struct _vx_mon_entry {
13710 +       uint16_t type;
13711 +       uint16_t xid;
13712 +       union {
13713 +               struct _vxm_event ev;
13714 +               struct _vxm_sched sd;
13715 +               struct _vxm_update_1 u1;
13716 +               struct _vxm_update_2 u2;
13717 +               struct _vxm_rqinfo_1 q1;
13718 +               struct _vxm_rqinfo_2 q2;
13719 +       };
13720 +};
13721 +
13722 +
13723 +#endif /* _VX_MONITOR_H */
13724 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/network_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/network_cmd.h
13725 --- linux-2.6.34/include/linux/vserver/network_cmd.h    1970-01-01 01:00:00.000000000 +0100
13726 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/network_cmd.h       2010-05-18 18:11:22.000000000 +0200
13727 @@ -0,0 +1,150 @@
13728 +#ifndef _VX_NETWORK_CMD_H
13729 +#define _VX_NETWORK_CMD_H
13730 +
13731 +
13732 +/* vinfo commands */
13733 +
13734 +#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
13735 +
13736 +#ifdef __KERNEL__
13737 +extern int vc_task_nid(uint32_t);
13738 +
13739 +#endif /* __KERNEL__ */
13740 +
13741 +#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
13742 +
13743 +struct vcmd_nx_info_v0 {
13744 +       uint32_t nid;
13745 +       /* more to come */
13746 +};
13747 +
13748 +#ifdef __KERNEL__
13749 +extern int vc_nx_info(struct nx_info *, void __user *);
13750 +
13751 +#endif /* __KERNEL__ */
13752 +
13753 +#include <linux/in.h>
13754 +#include <linux/in6.h>
13755 +
13756 +#define VCMD_net_create_v0     VC_CMD(VNET, 1, 0)
13757 +#define VCMD_net_create                VC_CMD(VNET, 1, 1)
13758 +
13759 +struct  vcmd_net_create {
13760 +       uint64_t flagword;
13761 +};
13762 +
13763 +#define VCMD_net_migrate       VC_CMD(NETMIG, 1, 0)
13764 +
13765 +#define VCMD_net_add           VC_CMD(NETALT, 1, 0)
13766 +#define VCMD_net_remove                VC_CMD(NETALT, 2, 0)
13767 +
13768 +struct vcmd_net_addr_v0 {
13769 +       uint16_t type;
13770 +       uint16_t count;
13771 +       struct in_addr ip[4];
13772 +       struct in_addr mask[4];
13773 +};
13774 +
13775 +#define VCMD_net_add_ipv4      VC_CMD(NETALT, 1, 1)
13776 +#define VCMD_net_remove_ipv4   VC_CMD(NETALT, 2, 1)
13777 +
13778 +struct vcmd_net_addr_ipv4_v1 {
13779 +       uint16_t type;
13780 +       uint16_t flags;
13781 +       struct in_addr ip;
13782 +       struct in_addr mask;
13783 +};
13784 +
13785 +#define VCMD_net_add_ipv6      VC_CMD(NETALT, 3, 1)
13786 +#define VCMD_net_remove_ipv6   VC_CMD(NETALT, 4, 1)
13787 +
13788 +struct vcmd_net_addr_ipv6_v1 {
13789 +       uint16_t type;
13790 +       uint16_t flags;
13791 +       uint32_t prefix;
13792 +       struct in6_addr ip;
13793 +       struct in6_addr mask;
13794 +};
13795 +
13796 +#define VCMD_add_match_ipv4    VC_CMD(NETALT, 5, 0)
13797 +#define VCMD_get_match_ipv4    VC_CMD(NETALT, 6, 0)
13798 +
13799 +struct vcmd_match_ipv4_v0 {
13800 +       uint16_t type;
13801 +       uint16_t flags;
13802 +       uint16_t parent;
13803 +       uint16_t prefix;
13804 +       struct in_addr ip;
13805 +       struct in_addr ip2;
13806 +       struct in_addr mask;
13807 +};
13808 +
13809 +#define VCMD_add_match_ipv6    VC_CMD(NETALT, 7, 0)
13810 +#define VCMD_get_match_ipv6    VC_CMD(NETALT, 8, 0)
13811 +
13812 +struct vcmd_match_ipv6_v0 {
13813 +       uint16_t type;
13814 +       uint16_t flags;
13815 +       uint16_t parent;
13816 +       uint16_t prefix;
13817 +       struct in6_addr ip;
13818 +       struct in6_addr ip2;
13819 +       struct in6_addr mask;
13820 +};
13821 +
13822 +
13823 +#ifdef __KERNEL__
13824 +extern int vc_net_create(uint32_t, void __user *);
13825 +extern int vc_net_migrate(struct nx_info *, void __user *);
13826 +
13827 +extern int vc_net_add(struct nx_info *, void __user *);
13828 +extern int vc_net_remove(struct nx_info *, void __user *);
13829 +
13830 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13831 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
13832 +
13833 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13834 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13835 +
13836 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13837 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13838 +
13839 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13840 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13841 +
13842 +#endif /* __KERNEL__ */
13843 +
13844 +
13845 +/* flag commands */
13846 +
13847 +#define VCMD_get_nflags                VC_CMD(FLAGS, 5, 0)
13848 +#define VCMD_set_nflags                VC_CMD(FLAGS, 6, 0)
13849 +
13850 +struct vcmd_net_flags_v0 {
13851 +       uint64_t flagword;
13852 +       uint64_t mask;
13853 +};
13854 +
13855 +#ifdef __KERNEL__
13856 +extern int vc_get_nflags(struct nx_info *, void __user *);
13857 +extern int vc_set_nflags(struct nx_info *, void __user *);
13858 +
13859 +#endif /* __KERNEL__ */
13860 +
13861 +
13862 +/* network caps commands */
13863 +
13864 +#define VCMD_get_ncaps         VC_CMD(FLAGS, 7, 0)
13865 +#define VCMD_set_ncaps         VC_CMD(FLAGS, 8, 0)
13866 +
13867 +struct vcmd_net_caps_v0 {
13868 +       uint64_t ncaps;
13869 +       uint64_t cmask;
13870 +};
13871 +
13872 +#ifdef __KERNEL__
13873 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13874 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13875 +
13876 +#endif /* __KERNEL__ */
13877 +#endif /* _VX_CONTEXT_CMD_H */
13878 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/network.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/network.h
13879 --- linux-2.6.34/include/linux/vserver/network.h        1970-01-01 01:00:00.000000000 +0100
13880 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/network.h   2010-05-18 18:11:22.000000000 +0200
13881 @@ -0,0 +1,146 @@
13882 +#ifndef _VX_NETWORK_H
13883 +#define _VX_NETWORK_H
13884 +
13885 +#include <linux/types.h>
13886 +
13887 +
13888 +#define MAX_N_CONTEXT  65535   /* Arbitrary limit */
13889 +
13890 +
13891 +/* network flags */
13892 +
13893 +#define NXF_INFO_PRIVATE       0x00000008
13894 +
13895 +#define NXF_SINGLE_IP          0x00000100
13896 +#define NXF_LBACK_REMAP                0x00000200
13897 +#define NXF_LBACK_ALLOW                0x00000400
13898 +
13899 +#define NXF_HIDE_NETIF         0x02000000
13900 +#define NXF_HIDE_LBACK         0x04000000
13901 +
13902 +#define NXF_STATE_SETUP                (1ULL << 32)
13903 +#define NXF_STATE_ADMIN                (1ULL << 34)
13904 +
13905 +#define NXF_SC_HELPER          (1ULL << 36)
13906 +#define NXF_PERSISTENT         (1ULL << 38)
13907 +
13908 +#define NXF_ONE_TIME           (0x0005ULL << 32)
13909 +
13910 +
13911 +#define        NXF_INIT_SET            (__nxf_init_set())
13912 +
13913 +static inline uint64_t __nxf_init_set(void) {
13914 +       return    NXF_STATE_ADMIN
13915 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13916 +               | NXF_LBACK_REMAP
13917 +               | NXF_HIDE_LBACK
13918 +#endif
13919 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13920 +               | NXF_SINGLE_IP
13921 +#endif
13922 +               | NXF_HIDE_NETIF;
13923 +}
13924 +
13925 +
13926 +/* network caps */
13927 +
13928 +#define NXC_TUN_CREATE         0x00000001
13929 +
13930 +#define NXC_RAW_ICMP           0x00000100
13931 +
13932 +
13933 +/* address types */
13934 +
13935 +#define NXA_TYPE_IPV4          0x0001
13936 +#define NXA_TYPE_IPV6          0x0002
13937 +
13938 +#define NXA_TYPE_NONE          0x0000
13939 +#define NXA_TYPE_ANY           0x00FF
13940 +
13941 +#define NXA_TYPE_ADDR          0x0010
13942 +#define NXA_TYPE_MASK          0x0020
13943 +#define NXA_TYPE_RANGE         0x0040
13944 +
13945 +#define NXA_MASK_ALL           (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13946 +
13947 +#define NXA_MOD_BCAST          0x0100
13948 +#define NXA_MOD_LBACK          0x0200
13949 +
13950 +#define NXA_LOOPBACK           0x1000
13951 +
13952 +#define NXA_MASK_BIND          (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13953 +#define NXA_MASK_SHOW          (NXA_MASK_ALL | NXA_LOOPBACK)
13954 +
13955 +#ifdef __KERNEL__
13956 +
13957 +#include <linux/list.h>
13958 +#include <linux/spinlock.h>
13959 +#include <linux/rcupdate.h>
13960 +#include <linux/in.h>
13961 +#include <linux/in6.h>
13962 +#include <asm/atomic.h>
13963 +
13964 +struct nx_addr_v4 {
13965 +       struct nx_addr_v4 *next;
13966 +       struct in_addr ip[2];
13967 +       struct in_addr mask;
13968 +       uint16_t type;
13969 +       uint16_t flags;
13970 +};
13971 +
13972 +struct nx_addr_v6 {
13973 +       struct nx_addr_v6 *next;
13974 +       struct in6_addr ip;
13975 +       struct in6_addr mask;
13976 +       uint32_t prefix;
13977 +       uint16_t type;
13978 +       uint16_t flags;
13979 +};
13980 +
13981 +struct nx_info {
13982 +       struct hlist_node nx_hlist;     /* linked list of nxinfos */
13983 +       nid_t nx_id;                    /* vnet id */
13984 +       atomic_t nx_usecnt;             /* usage count */
13985 +       atomic_t nx_tasks;              /* tasks count */
13986 +       int nx_state;                   /* context state */
13987 +
13988 +       uint64_t nx_flags;              /* network flag word */
13989 +       uint64_t nx_ncaps;              /* network capabilities */
13990 +
13991 +       struct in_addr v4_lback;        /* Loopback address */
13992 +       struct in_addr v4_bcast;        /* Broadcast address */
13993 +       struct nx_addr_v4 v4;           /* First/Single ipv4 address */
13994 +#ifdef CONFIG_IPV6
13995 +       struct nx_addr_v6 v6;           /* First/Single ipv6 address */
13996 +#endif
13997 +       char nx_name[65];               /* network context name */
13998 +};
13999 +
14000 +
14001 +/* status flags */
14002 +
14003 +#define NXS_HASHED      0x0001
14004 +#define NXS_SHUTDOWN    0x0100
14005 +#define NXS_RELEASED    0x8000
14006 +
14007 +extern struct nx_info *lookup_nx_info(int);
14008 +
14009 +extern int get_nid_list(int, unsigned int *, int);
14010 +extern int nid_is_hashed(nid_t);
14011 +
14012 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
14013 +
14014 +extern long vs_net_change(struct nx_info *, unsigned int);
14015 +
14016 +struct sock;
14017 +
14018 +
14019 +#define NX_IPV4(n)     ((n)->v4.type != NXA_TYPE_NONE)
14020 +#ifdef  CONFIG_IPV6
14021 +#define NX_IPV6(n)     ((n)->v6.type != NXA_TYPE_NONE)
14022 +#else
14023 +#define NX_IPV6(n)     (0)
14024 +#endif
14025 +
14026 +#endif /* __KERNEL__ */
14027 +#endif /* _VX_NETWORK_H */
14028 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/percpu.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/percpu.h
14029 --- linux-2.6.34/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
14030 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/percpu.h    2010-05-18 18:11:22.000000000 +0200
14031 @@ -0,0 +1,14 @@
14032 +#ifndef _VX_PERCPU_H
14033 +#define _VX_PERCPU_H
14034 +
14035 +#include "cvirt_def.h"
14036 +#include "sched_def.h"
14037 +
14038 +struct _vx_percpu {
14039 +       struct _vx_cvirt_pc cvirt;
14040 +       struct _vx_sched_pc sched;
14041 +};
14042 +
14043 +#define        PERCPU_PERCTX   (sizeof(struct _vx_percpu))
14044 +
14045 +#endif /* _VX_PERCPU_H */
14046 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/pid.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/pid.h
14047 --- linux-2.6.34/include/linux/vserver/pid.h    1970-01-01 01:00:00.000000000 +0100
14048 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/pid.h       2010-05-18 18:11:22.000000000 +0200
14049 @@ -0,0 +1,51 @@
14050 +#ifndef _VSERVER_PID_H
14051 +#define _VSERVER_PID_H
14052 +
14053 +/* pid faking stuff */
14054 +
14055 +#define vx_info_map_pid(v, p) \
14056 +       __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
14057 +#define vx_info_map_tgid(v,p)  vx_info_map_pid(v,p)
14058 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
14059 +#define vx_map_tgid(p) vx_map_pid(p)
14060 +
14061 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
14062 +       const char *func, const char *file, int line)
14063 +{
14064 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14065 +               vxfprintk(VXD_CBIT(cvirt, 2),
14066 +                       "vx_map_tgid: %p/%llx: %d -> %d",
14067 +                       vxi, (long long)vxi->vx_flags, pid,
14068 +                       (pid && pid == vxi->vx_initpid) ? 1 : pid,
14069 +                       func, file, line);
14070 +               if (pid == 0)
14071 +                       return 0;
14072 +               if (pid == vxi->vx_initpid)
14073 +                       return 1;
14074 +       }
14075 +       return pid;
14076 +}
14077 +
14078 +#define vx_info_rmap_pid(v, p) \
14079 +       __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
14080 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
14081 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
14082 +
14083 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
14084 +       const char *func, const char *file, int line)
14085 +{
14086 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14087 +               vxfprintk(VXD_CBIT(cvirt, 2),
14088 +                       "vx_rmap_tgid: %p/%llx: %d -> %d",
14089 +                       vxi, (long long)vxi->vx_flags, pid,
14090 +                       (pid == 1) ? vxi->vx_initpid : pid,
14091 +                       func, file, line);
14092 +               if ((pid == 1) && vxi->vx_initpid)
14093 +                       return vxi->vx_initpid;
14094 +               if (pid == vxi->vx_initpid)
14095 +                       return ~0U;
14096 +       }
14097 +       return pid;
14098 +}
14099 +
14100 +#endif
14101 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/sched_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/sched_cmd.h
14102 --- linux-2.6.34/include/linux/vserver/sched_cmd.h      1970-01-01 01:00:00.000000000 +0100
14103 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/sched_cmd.h 2010-05-18 18:11:22.000000000 +0200
14104 @@ -0,0 +1,108 @@
14105 +#ifndef _VX_SCHED_CMD_H
14106 +#define _VX_SCHED_CMD_H
14107 +
14108 +
14109 +/*  sched vserver commands */
14110 +
14111 +#define VCMD_set_sched_v2      VC_CMD(SCHED, 1, 2)
14112 +#define VCMD_set_sched_v3      VC_CMD(SCHED, 1, 3)
14113 +#define VCMD_set_sched_v4      VC_CMD(SCHED, 1, 4)
14114 +
14115 +struct vcmd_set_sched_v2 {
14116 +       int32_t fill_rate;
14117 +       int32_t interval;
14118 +       int32_t tokens;
14119 +       int32_t tokens_min;
14120 +       int32_t tokens_max;
14121 +       uint64_t cpu_mask;
14122 +};
14123 +
14124 +struct vcmd_set_sched_v3 {
14125 +       uint32_t set_mask;
14126 +       int32_t fill_rate;
14127 +       int32_t interval;
14128 +       int32_t tokens;
14129 +       int32_t tokens_min;
14130 +       int32_t tokens_max;
14131 +       int32_t priority_bias;
14132 +};
14133 +
14134 +struct vcmd_set_sched_v4 {
14135 +       uint32_t set_mask;
14136 +       int32_t fill_rate;
14137 +       int32_t interval;
14138 +       int32_t tokens;
14139 +       int32_t tokens_min;
14140 +       int32_t tokens_max;
14141 +       int32_t prio_bias;
14142 +       int32_t cpu_id;
14143 +       int32_t bucket_id;
14144 +};
14145 +
14146 +#define VCMD_set_sched         VC_CMD(SCHED, 1, 5)
14147 +#define VCMD_get_sched         VC_CMD(SCHED, 2, 5)
14148 +
14149 +struct vcmd_sched_v5 {
14150 +       uint32_t mask;
14151 +       int32_t cpu_id;
14152 +       int32_t bucket_id;
14153 +       int32_t fill_rate[2];
14154 +       int32_t interval[2];
14155 +       int32_t tokens;
14156 +       int32_t tokens_min;
14157 +       int32_t tokens_max;
14158 +       int32_t prio_bias;
14159 +};
14160 +
14161 +#define VXSM_FILL_RATE         0x0001
14162 +#define VXSM_INTERVAL          0x0002
14163 +#define VXSM_FILL_RATE2                0x0004
14164 +#define VXSM_INTERVAL2         0x0008
14165 +#define VXSM_TOKENS            0x0010
14166 +#define VXSM_TOKENS_MIN                0x0020
14167 +#define VXSM_TOKENS_MAX                0x0040
14168 +#define VXSM_PRIO_BIAS         0x0100
14169 +
14170 +#define VXSM_IDLE_TIME         0x0200
14171 +#define VXSM_FORCE             0x0400
14172 +
14173 +#define        VXSM_V3_MASK            0x0173
14174 +#define        VXSM_SET_MASK           0x01FF
14175 +
14176 +#define VXSM_CPU_ID            0x1000
14177 +#define VXSM_BUCKET_ID         0x2000
14178 +
14179 +#define VXSM_MSEC              0x4000
14180 +
14181 +#define SCHED_KEEP             (-2)    /* only for v2 */
14182 +
14183 +#ifdef __KERNEL__
14184 +
14185 +#include <linux/compiler.h>
14186 +
14187 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
14188 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
14189 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
14190 +extern int vc_set_sched(struct vx_info *, void __user *);
14191 +extern int vc_get_sched(struct vx_info *, void __user *);
14192 +
14193 +#endif /* __KERNEL__ */
14194 +
14195 +#define VCMD_sched_info                VC_CMD(SCHED, 3, 0)
14196 +
14197 +struct vcmd_sched_info {
14198 +       int32_t cpu_id;
14199 +       int32_t bucket_id;
14200 +       uint64_t user_msec;
14201 +       uint64_t sys_msec;
14202 +       uint64_t hold_msec;
14203 +       uint32_t token_usec;
14204 +       int32_t vavavoom;
14205 +};
14206 +
14207 +#ifdef __KERNEL__
14208 +
14209 +extern int vc_sched_info(struct vx_info *, void __user *);
14210 +
14211 +#endif /* __KERNEL__ */
14212 +#endif /* _VX_SCHED_CMD_H */
14213 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/sched_def.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/sched_def.h
14214 --- linux-2.6.34/include/linux/vserver/sched_def.h      1970-01-01 01:00:00.000000000 +0100
14215 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/sched_def.h 2010-05-18 18:11:22.000000000 +0200
14216 @@ -0,0 +1,68 @@
14217 +#ifndef _VX_SCHED_DEF_H
14218 +#define _VX_SCHED_DEF_H
14219 +
14220 +#include <linux/spinlock.h>
14221 +#include <linux/jiffies.h>
14222 +#include <linux/cpumask.h>
14223 +#include <asm/atomic.h>
14224 +#include <asm/param.h>
14225 +
14226 +
14227 +/* context sub struct */
14228 +
14229 +struct _vx_sched {
14230 +       spinlock_t tokens_lock;         /* lock for token bucket */
14231 +
14232 +       int tokens;                     /* number of CPU tokens */
14233 +       int fill_rate[2];               /* Fill rate: add X tokens... */
14234 +       int interval[2];                /* Divisor:   per Y jiffies   */
14235 +       int tokens_min;                 /* Limit:     minimum for unhold */
14236 +       int tokens_max;                 /* Limit:     no more than N tokens */
14237 +
14238 +       int prio_bias;                  /* bias offset for priority */
14239 +
14240 +       unsigned update_mask;           /* which features should be updated */
14241 +       cpumask_t update;               /* CPUs which should update */
14242 +};
14243 +
14244 +struct _vx_sched_pc {
14245 +       int tokens;                     /* number of CPU tokens */
14246 +       int flags;                      /* bucket flags */
14247 +
14248 +       int fill_rate[2];               /* Fill rate: add X tokens... */
14249 +       int interval[2];                /* Divisor:   per Y jiffies   */
14250 +       int tokens_min;                 /* Limit:     minimum for unhold */
14251 +       int tokens_max;                 /* Limit:     no more than N tokens */
14252 +
14253 +       int prio_bias;                  /* bias offset for priority */
14254 +       int vavavoom;                   /* last calculated vavavoom */
14255 +
14256 +       unsigned long norm_time;        /* last time accounted */
14257 +       unsigned long idle_time;        /* non linear time for fair sched */
14258 +       unsigned long token_time;       /* token time for accounting */
14259 +       unsigned long onhold;           /* jiffies when put on hold */
14260 +
14261 +       uint64_t user_ticks;            /* token tick events */
14262 +       uint64_t sys_ticks;             /* token tick events */
14263 +       uint64_t hold_ticks;            /* token ticks paused */
14264 +};
14265 +
14266 +
14267 +#define VXSF_ONHOLD    0x0001
14268 +#define VXSF_IDLE_TIME 0x0100
14269 +
14270 +#ifdef CONFIG_VSERVER_DEBUG
14271 +
14272 +static inline void __dump_vx_sched(struct _vx_sched *sched)
14273 +{
14274 +       printk("\t_vx_sched:\n");
14275 +       printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
14276 +               sched->fill_rate[0], sched->interval[0],
14277 +               sched->fill_rate[1], sched->interval[1],
14278 +               sched->tokens_min, sched->tokens_max);
14279 +       printk("\t priority = %4d\n", sched->prio_bias);
14280 +}
14281 +
14282 +#endif
14283 +
14284 +#endif /* _VX_SCHED_DEF_H */
14285 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/sched.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/sched.h
14286 --- linux-2.6.34/include/linux/vserver/sched.h  1970-01-01 01:00:00.000000000 +0100
14287 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/sched.h     2010-05-18 18:11:22.000000000 +0200
14288 @@ -0,0 +1,26 @@
14289 +#ifndef _VX_SCHED_H
14290 +#define _VX_SCHED_H
14291 +
14292 +
14293 +#ifdef __KERNEL__
14294 +
14295 +struct timespec;
14296 +
14297 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14298 +
14299 +
14300 +struct vx_info;
14301 +
14302 +void vx_update_load(struct vx_info *);
14303 +
14304 +
14305 +int vx_tokens_recalc(struct _vx_sched_pc *,
14306 +       unsigned long *, unsigned long *, int [2]);
14307 +
14308 +void vx_update_sched_param(struct _vx_sched *sched,
14309 +       struct _vx_sched_pc *sched_pc);
14310 +
14311 +#endif /* __KERNEL__ */
14312 +#else  /* _VX_SCHED_H */
14313 +#warning duplicate inclusion
14314 +#endif /* _VX_SCHED_H */
14315 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/signal_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/signal_cmd.h
14316 --- linux-2.6.34/include/linux/vserver/signal_cmd.h     1970-01-01 01:00:00.000000000 +0100
14317 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/signal_cmd.h        2010-05-18 18:11:22.000000000 +0200
14318 @@ -0,0 +1,43 @@
14319 +#ifndef _VX_SIGNAL_CMD_H
14320 +#define _VX_SIGNAL_CMD_H
14321 +
14322 +
14323 +/*  signalling vserver commands */
14324 +
14325 +#define VCMD_ctx_kill          VC_CMD(PROCTRL, 1, 0)
14326 +#define VCMD_wait_exit         VC_CMD(EVENT, 99, 0)
14327 +
14328 +struct vcmd_ctx_kill_v0 {
14329 +       int32_t pid;
14330 +       int32_t sig;
14331 +};
14332 +
14333 +struct vcmd_wait_exit_v0 {
14334 +       int32_t reboot_cmd;
14335 +       int32_t exit_code;
14336 +};
14337 +
14338 +#ifdef __KERNEL__
14339 +
14340 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14341 +extern int vc_wait_exit(struct vx_info *, void __user *);
14342 +
14343 +#endif /* __KERNEL__ */
14344 +
14345 +/*  process alteration commands */
14346 +
14347 +#define VCMD_get_pflags                VC_CMD(PROCALT, 5, 0)
14348 +#define VCMD_set_pflags                VC_CMD(PROCALT, 6, 0)
14349 +
14350 +struct vcmd_pflags_v0 {
14351 +       uint32_t flagword;
14352 +       uint32_t mask;
14353 +};
14354 +
14355 +#ifdef __KERNEL__
14356 +
14357 +extern int vc_get_pflags(uint32_t pid, void __user *);
14358 +extern int vc_set_pflags(uint32_t pid, void __user *);
14359 +
14360 +#endif /* __KERNEL__ */
14361 +#endif /* _VX_SIGNAL_CMD_H */
14362 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/signal.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/signal.h
14363 --- linux-2.6.34/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
14364 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/signal.h    2010-05-18 18:11:22.000000000 +0200
14365 @@ -0,0 +1,14 @@
14366 +#ifndef _VX_SIGNAL_H
14367 +#define _VX_SIGNAL_H
14368 +
14369 +
14370 +#ifdef __KERNEL__
14371 +
14372 +struct vx_info;
14373 +
14374 +int vx_info_kill(struct vx_info *, int, int);
14375 +
14376 +#endif /* __KERNEL__ */
14377 +#else  /* _VX_SIGNAL_H */
14378 +#warning duplicate inclusion
14379 +#endif /* _VX_SIGNAL_H */
14380 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/space_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/space_cmd.h
14381 --- linux-2.6.34/include/linux/vserver/space_cmd.h      1970-01-01 01:00:00.000000000 +0100
14382 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/space_cmd.h 2010-05-18 18:11:22.000000000 +0200
14383 @@ -0,0 +1,38 @@
14384 +#ifndef _VX_SPACE_CMD_H
14385 +#define _VX_SPACE_CMD_H
14386 +
14387 +
14388 +#define VCMD_enter_space_v0    VC_CMD(PROCALT, 1, 0)
14389 +#define VCMD_enter_space_v1    VC_CMD(PROCALT, 1, 1)
14390 +#define VCMD_enter_space       VC_CMD(PROCALT, 1, 2)
14391 +
14392 +#define VCMD_set_space_v0      VC_CMD(PROCALT, 3, 0)
14393 +#define VCMD_set_space_v1      VC_CMD(PROCALT, 3, 1)
14394 +#define VCMD_set_space         VC_CMD(PROCALT, 3, 2)
14395 +
14396 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14397 +
14398 +#define VCMD_get_space_mask    VC_CMD(VSPACE, 0, 1)
14399 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14400 +
14401 +
14402 +struct vcmd_space_mask_v1 {
14403 +       uint64_t mask;
14404 +};
14405 +
14406 +struct vcmd_space_mask_v2 {
14407 +       uint64_t mask;
14408 +       uint32_t index;
14409 +};
14410 +
14411 +
14412 +#ifdef __KERNEL__
14413 +
14414 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14415 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14416 +extern int vc_enter_space(struct vx_info *, void __user *);
14417 +extern int vc_set_space(struct vx_info *, void __user *);
14418 +extern int vc_get_space_mask(void __user *, int);
14419 +
14420 +#endif /* __KERNEL__ */
14421 +#endif /* _VX_SPACE_CMD_H */
14422 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/space.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/space.h
14423 --- linux-2.6.34/include/linux/vserver/space.h  1970-01-01 01:00:00.000000000 +0100
14424 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/space.h     2010-05-18 18:11:22.000000000 +0200
14425 @@ -0,0 +1,12 @@
14426 +#ifndef _VX_SPACE_H
14427 +#define _VX_SPACE_H
14428 +
14429 +#include <linux/types.h>
14430 +
14431 +struct vx_info;
14432 +
14433 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14434 +
14435 +#else  /* _VX_SPACE_H */
14436 +#warning duplicate inclusion
14437 +#endif /* _VX_SPACE_H */
14438 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/switch.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/switch.h
14439 --- linux-2.6.34/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
14440 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/switch.h    2010-05-18 18:11:22.000000000 +0200
14441 @@ -0,0 +1,98 @@
14442 +#ifndef _VX_SWITCH_H
14443 +#define _VX_SWITCH_H
14444 +
14445 +#include <linux/types.h>
14446 +
14447 +
14448 +#define VC_CATEGORY(c)         (((c) >> 24) & 0x3F)
14449 +#define VC_COMMAND(c)          (((c) >> 16) & 0xFF)
14450 +#define VC_VERSION(c)          ((c) & 0xFFF)
14451 +
14452 +#define VC_CMD(c, i, v)                ((((VC_CAT_ ## c) & 0x3F) << 24) \
14453 +                               | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14454 +
14455 +/*
14456 +
14457 +  Syscall Matrix V2.8
14458 +
14459 +        |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14460 +        |STATS  |DESTROY|ALTER  |CHANGE |LIMIT  |TEST   | |       |       |
14461 +        |INFO   |SETUP  |       |MOVE   |       |       | |       |       |
14462 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14463 +  SYSTEM |VERSION|VSETUP |VHOST  |       |       |       | |DEVICE |       |
14464 +  HOST   |     00|     01|     02|     03|     04|     05| |     06|     07|
14465 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14466 +  CPU    |       |VPROC  |PROCALT|PROCMIG|PROCTRL|       | |SCHED. |       |
14467 +  PROCESS|     08|     09|     10|     11|     12|     13| |     14|     15|
14468 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14469 +  MEMORY |       |       |       |       |MEMCTRL|       | |SWAP   |       |
14470 +        |     16|     17|     18|     19|     20|     21| |     22|     23|
14471 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14472 +  NETWORK|       |VNET   |NETALT |NETMIG |NETCTL |       | |SERIAL |       |
14473 +        |     24|     25|     26|     27|     28|     29| |     30|     31|
14474 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14475 +  DISK   |       |       |       |TAGMIG |DLIMIT |       | |INODE  |       |
14476 +  VFS    |     32|     33|     34|     35|     36|     37| |     38|     39|
14477 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14478 +  OTHER  |VSTAT  |       |       |       |       |       | |VINFO  |       |
14479 +        |     40|     41|     42|     43|     44|     45| |     46|     47|
14480 +  =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14481 +  SPECIAL|EVENT  |       |       |       |FLAGS  |       | |VSPACE |       |
14482 +        |     48|     49|     50|     51|     52|     53| |     54|     55|
14483 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14484 +  SPECIAL|DEBUG  |       |       |       |RLIMIT |SYSCALL| |       |COMPAT |
14485 +        |     56|     57|     58|     59|     60|TEST 61| |     62|     63|
14486 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14487 +
14488 +*/
14489 +
14490 +#define VC_CAT_VERSION         0
14491 +
14492 +#define VC_CAT_VSETUP          1
14493 +#define VC_CAT_VHOST           2
14494 +
14495 +#define VC_CAT_DEVICE          6
14496 +
14497 +#define VC_CAT_VPROC           9
14498 +#define VC_CAT_PROCALT         10
14499 +#define VC_CAT_PROCMIG         11
14500 +#define VC_CAT_PROCTRL         12
14501 +
14502 +#define VC_CAT_SCHED           14
14503 +#define VC_CAT_MEMCTRL         20
14504 +
14505 +#define VC_CAT_VNET            25
14506 +#define VC_CAT_NETALT          26
14507 +#define VC_CAT_NETMIG          27
14508 +#define VC_CAT_NETCTRL         28
14509 +
14510 +#define VC_CAT_TAGMIG          35
14511 +#define VC_CAT_DLIMIT          36
14512 +#define VC_CAT_INODE           38
14513 +
14514 +#define VC_CAT_VSTAT           40
14515 +#define VC_CAT_VINFO           46
14516 +#define VC_CAT_EVENT           48
14517 +
14518 +#define VC_CAT_FLAGS           52
14519 +#define VC_CAT_VSPACE          54
14520 +#define VC_CAT_DEBUG           56
14521 +#define VC_CAT_RLIMIT          60
14522 +
14523 +#define VC_CAT_SYSTEST         61
14524 +#define VC_CAT_COMPAT          63
14525 +
14526 +/*  query version */
14527 +
14528 +#define VCMD_get_version       VC_CMD(VERSION, 0, 0)
14529 +#define VCMD_get_vci           VC_CMD(VERSION, 1, 0)
14530 +
14531 +
14532 +#ifdef __KERNEL__
14533 +
14534 +#include <linux/errno.h>
14535 +
14536 +#endif /* __KERNEL__ */
14537 +
14538 +#endif /* _VX_SWITCH_H */
14539 +
14540 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/tag_cmd.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/tag_cmd.h
14541 --- linux-2.6.34/include/linux/vserver/tag_cmd.h        1970-01-01 01:00:00.000000000 +0100
14542 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/tag_cmd.h   2010-05-18 18:11:22.000000000 +0200
14543 @@ -0,0 +1,22 @@
14544 +#ifndef _VX_TAG_CMD_H
14545 +#define _VX_TAG_CMD_H
14546 +
14547 +
14548 +/* vinfo commands */
14549 +
14550 +#define VCMD_task_tag          VC_CMD(VINFO, 3, 0)
14551 +
14552 +#ifdef __KERNEL__
14553 +extern int vc_task_tag(uint32_t);
14554 +
14555 +#endif /* __KERNEL__ */
14556 +
14557 +/* context commands */
14558 +
14559 +#define VCMD_tag_migrate       VC_CMD(TAGMIG, 1, 0)
14560 +
14561 +#ifdef __KERNEL__
14562 +extern int vc_tag_migrate(uint32_t);
14563 +
14564 +#endif /* __KERNEL__ */
14565 +#endif /* _VX_TAG_CMD_H */
14566 diff -NurpP --minimal linux-2.6.34/include/linux/vserver/tag.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/tag.h
14567 --- linux-2.6.34/include/linux/vserver/tag.h    1970-01-01 01:00:00.000000000 +0100
14568 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vserver/tag.h       2010-05-18 18:11:22.000000000 +0200
14569 @@ -0,0 +1,143 @@
14570 +#ifndef _DX_TAG_H
14571 +#define _DX_TAG_H
14572 +
14573 +#include <linux/types.h>
14574 +
14575 +
14576 +#define DX_TAG(in)     (IS_TAGGED(in))
14577 +
14578 +
14579 +#ifdef CONFIG_TAG_NFSD
14580 +#define DX_TAG_NFSD    1
14581 +#else
14582 +#define DX_TAG_NFSD    0
14583 +#endif
14584 +
14585 +
14586 +#ifdef CONFIG_TAGGING_NONE
14587 +
14588 +#define MAX_UID                0xFFFFFFFF
14589 +#define MAX_GID                0xFFFFFFFF
14590 +
14591 +#define INOTAG_TAG(cond, uid, gid, tag)        (0)
14592 +
14593 +#define TAGINO_UID(cond, uid, tag)     (uid)
14594 +#define TAGINO_GID(cond, gid, tag)     (gid)
14595 +
14596 +#endif
14597 +
14598 +
14599 +#ifdef CONFIG_TAGGING_GID16
14600 +
14601 +#define MAX_UID                0xFFFFFFFF
14602 +#define MAX_GID                0x0000FFFF
14603 +
14604 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14605 +       ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14606 +
14607 +#define TAGINO_UID(cond, uid, tag)     (uid)
14608 +#define TAGINO_GID(cond, gid, tag)     \
14609 +       ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14610 +
14611 +#endif
14612 +
14613 +
14614 +#ifdef CONFIG_TAGGING_ID24
14615 +
14616 +#define MAX_UID                0x00FFFFFF
14617 +#define MAX_GID                0x00FFFFFF
14618 +
14619 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14620 +       ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14621 +
14622 +#define TAGINO_UID(cond, uid, tag)     \
14623 +       ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14624 +#define TAGINO_GID(cond, gid, tag)     \
14625 +       ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14626 +
14627 +#endif
14628 +
14629 +
14630 +#ifdef CONFIG_TAGGING_UID16
14631 +
14632 +#define MAX_UID                0x0000FFFF
14633 +#define MAX_GID                0xFFFFFFFF
14634 +
14635 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14636 +       ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14637 +
14638 +#define TAGINO_UID(cond, uid, tag)     \
14639 +       ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14640 +#define TAGINO_GID(cond, gid, tag)     (gid)
14641 +
14642 +#endif
14643 +
14644 +
14645 +#ifdef CONFIG_TAGGING_INTERN
14646 +
14647 +#define MAX_UID                0xFFFFFFFF
14648 +#define MAX_GID                0xFFFFFFFF
14649 +
14650 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14651 +       ((cond) ? (tag) : 0)
14652 +
14653 +#define TAGINO_UID(cond, uid, tag)     (uid)
14654 +#define TAGINO_GID(cond, gid, tag)     (gid)
14655 +
14656 +#endif
14657 +
14658 +
14659 +#ifndef CONFIG_TAGGING_NONE
14660 +#define dx_current_fstag(sb)   \
14661 +       ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14662 +#else
14663 +#define dx_current_fstag(sb)   (0)
14664 +#endif
14665 +
14666 +#ifndef CONFIG_TAGGING_INTERN
14667 +#define TAGINO_TAG(cond, tag)  (0)
14668 +#else
14669 +#define TAGINO_TAG(cond, tag)  ((cond) ? (tag) : 0)
14670 +#endif
14671 +
14672 +#define INOTAG_UID(cond, uid, gid)     \
14673 +       ((cond) ? ((uid) & MAX_UID) : (uid))
14674 +#define INOTAG_GID(cond, uid, gid)     \
14675 +       ((cond) ? ((gid) & MAX_GID) : (gid))
14676 +
14677 +
14678 +static inline uid_t dx_map_uid(uid_t uid)
14679 +{
14680 +       if ((uid > MAX_UID) && (uid != -1))
14681 +               uid = -2;
14682 +       return (uid & MAX_UID);
14683 +}
14684 +
14685 +static inline gid_t dx_map_gid(gid_t gid)
14686 +{
14687 +       if ((gid > MAX_GID) && (gid != -1))
14688 +               gid = -2;
14689 +       return (gid & MAX_GID);
14690 +}
14691 +
14692 +struct peer_tag {
14693 +       int32_t xid;
14694 +       int32_t nid;
14695 +};
14696 +
14697 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14698 +
14699 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14700 +                unsigned long *flags);
14701 +
14702 +#ifdef CONFIG_PROPAGATE
14703 +
14704 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14705 +
14706 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14707 +
14708 +#else
14709 +#define dx_propagate_tag(n, i) do { } while (0)
14710 +#endif
14711 +
14712 +#endif /* _DX_TAG_H */
14713 diff -NurpP --minimal linux-2.6.34/include/linux/vs_inet6.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_inet6.h
14714 --- linux-2.6.34/include/linux/vs_inet6.h       1970-01-01 01:00:00.000000000 +0100
14715 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_inet6.h  2010-05-18 18:11:22.000000000 +0200
14716 @@ -0,0 +1,246 @@
14717 +#ifndef _VS_INET6_H
14718 +#define _VS_INET6_H
14719 +
14720 +#include "vserver/base.h"
14721 +#include "vserver/network.h"
14722 +#include "vserver/debug.h"
14723 +
14724 +#include <net/ipv6.h>
14725 +
14726 +#define NXAV6(a)       &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
14727 +#define NXAV6_FMT      "[%pI6/%pI6/%d:%04x]"
14728 +
14729 +
14730 +#ifdef CONFIG_IPV6
14731 +
14732 +static inline
14733 +int v6_addr_match(struct nx_addr_v6 *nxa,
14734 +       const struct in6_addr *addr, uint16_t mask)
14735 +{
14736 +       int ret = 0;
14737 +
14738 +       switch (nxa->type & mask) {
14739 +       case NXA_TYPE_MASK:
14740 +               ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
14741 +               break;
14742 +       case NXA_TYPE_ADDR:
14743 +               ret = ipv6_addr_equal(&nxa->ip, addr);
14744 +               break;
14745 +       case NXA_TYPE_ANY:
14746 +               ret = 1;
14747 +               break;
14748 +       }
14749 +       vxdprintk(VXD_CBIT(net, 0),
14750 +               "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
14751 +               nxa, NXAV6(nxa), addr, mask, ret);
14752 +       return ret;
14753 +}
14754 +
14755 +static inline
14756 +int v6_addr_in_nx_info(struct nx_info *nxi,
14757 +       const struct in6_addr *addr, uint16_t mask)
14758 +{
14759 +       struct nx_addr_v6 *nxa;
14760 +       int ret = 1;
14761 +
14762 +       if (!nxi)
14763 +               goto out;
14764 +       for (nxa = &nxi->v6; nxa; nxa = nxa->next)
14765 +               if (v6_addr_match(nxa, addr, mask))
14766 +                       goto out;
14767 +       ret = 0;
14768 +out:
14769 +       vxdprintk(VXD_CBIT(net, 0),
14770 +               "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
14771 +               nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
14772 +       return ret;
14773 +}
14774 +
14775 +static inline
14776 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
14777 +{
14778 +       /* FIXME: needs full range checks */
14779 +       return v6_addr_match(nxa, &addr->ip, mask);
14780 +}
14781 +
14782 +static inline
14783 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
14784 +{
14785 +       struct nx_addr_v6 *ptr;
14786 +
14787 +       for (ptr = &nxi->v6; ptr; ptr = ptr->next)
14788 +               if (v6_nx_addr_match(ptr, nxa, mask))
14789 +                       return 1;
14790 +       return 0;
14791 +}
14792 +
14793 +
14794 +/*
14795 + *     Check if a given address matches for a socket
14796 + *
14797 + *     nxi:            the socket's nx_info if any
14798 + *     addr:           to be verified address
14799 + */
14800 +static inline
14801 +int v6_sock_addr_match (
14802 +       struct nx_info *nxi,
14803 +       struct inet_sock *inet,
14804 +       struct in6_addr *addr)
14805 +{
14806 +       struct sock *sk = &inet->sk;
14807 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
14808 +
14809 +       if (!ipv6_addr_any(addr) &&
14810 +               ipv6_addr_equal(saddr, addr))
14811 +               return 1;
14812 +       if (ipv6_addr_any(saddr))
14813 +               return v6_addr_in_nx_info(nxi, addr, -1);
14814 +       return 0;
14815 +}
14816 +
14817 +/*
14818 + *     check if address is covered by socket
14819 + *
14820 + *     sk:     the socket to check against
14821 + *     addr:   the address in question (must be != 0)
14822 + */
14823 +
14824 +static inline
14825 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
14826 +{
14827 +       struct nx_info *nxi = sk->sk_nx_info;
14828 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
14829 +
14830 +       vxdprintk(VXD_CBIT(net, 5),
14831 +               "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
14832 +               sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
14833 +               (sk->sk_socket?sk->sk_socket->flags:0));
14834 +
14835 +       if (!ipv6_addr_any(saddr)) {    /* direct address match */
14836 +               return v6_addr_match(nxa, saddr, -1);
14837 +       } else if (nxi) {               /* match against nx_info */
14838 +               return v6_nx_addr_in_nx_info(nxi, nxa, -1);
14839 +       } else {                        /* unrestricted any socket */
14840 +               return 1;
14841 +       }
14842 +}
14843 +
14844 +
14845 +/* inet related checks and helpers */
14846 +
14847 +
14848 +struct in_ifaddr;
14849 +struct net_device;
14850 +struct sock;
14851 +
14852 +
14853 +#include <linux/netdevice.h>
14854 +#include <linux/inetdevice.h>
14855 +#include <net/inet_timewait_sock.h>
14856 +
14857 +
14858 +int dev_in_nx_info(struct net_device *, struct nx_info *);
14859 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
14860 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
14861 +
14862 +
14863 +
14864 +static inline
14865 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
14866 +{
14867 +       if (!nxi)
14868 +               return 1;
14869 +       if (!ifa)
14870 +               return 0;
14871 +       return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
14872 +}
14873 +
14874 +static inline
14875 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
14876 +{
14877 +       vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
14878 +               nxi, nxi ? nxi->nx_id : 0, ifa,
14879 +               nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
14880 +
14881 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
14882 +               return 1;
14883 +       if (v6_ifa_in_nx_info(ifa, nxi))
14884 +               return 1;
14885 +       return 0;
14886 +}
14887 +
14888 +
14889 +struct nx_v6_sock_addr {
14890 +       struct in6_addr saddr;  /* Address used for validation */
14891 +       struct in6_addr baddr;  /* Address used for socket bind */
14892 +};
14893 +
14894 +static inline
14895 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
14896 +       struct nx_v6_sock_addr *nsa)
14897 +{
14898 +       // struct sock *sk = &inet->sk;
14899 +       // struct nx_info *nxi = sk->sk_nx_info;
14900 +       struct in6_addr saddr = addr->sin6_addr;
14901 +       struct in6_addr baddr = saddr;
14902 +
14903 +       nsa->saddr = saddr;
14904 +       nsa->baddr = baddr;
14905 +       return 0;
14906 +}
14907 +
14908 +static inline
14909 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
14910 +{
14911 +       // struct sock *sk = &inet->sk;
14912 +       // struct in6_addr *saddr = inet6_rcv_saddr(sk);
14913 +
14914 +       // *saddr = nsa->baddr;
14915 +       // inet->inet_saddr = nsa->baddr;
14916 +}
14917 +
14918 +static inline
14919 +int nx_info_has_v6(struct nx_info *nxi)
14920 +{
14921 +       if (!nxi)
14922 +               return 1;
14923 +       if (NX_IPV6(nxi))
14924 +               return 1;
14925 +       return 0;
14926 +}
14927 +
14928 +#else /* CONFIG_IPV6 */
14929 +
14930 +static inline
14931 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
14932 +{
14933 +       return 1;
14934 +}
14935 +
14936 +
14937 +static inline
14938 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
14939 +{
14940 +       return 1;
14941 +}
14942 +
14943 +static inline
14944 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
14945 +{
14946 +       return 1;
14947 +}
14948 +
14949 +static inline
14950 +int nx_info_has_v6(struct nx_info *nxi)
14951 +{
14952 +       return 0;
14953 +}
14954 +
14955 +#endif /* CONFIG_IPV6 */
14956 +
14957 +#define current_nx_info_has_v6() \
14958 +       nx_info_has_v6(current_nx_info())
14959 +
14960 +#else
14961 +#warning duplicate inclusion
14962 +#endif
14963 diff -NurpP --minimal linux-2.6.34/include/linux/vs_inet.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_inet.h
14964 --- linux-2.6.34/include/linux/vs_inet.h        1970-01-01 01:00:00.000000000 +0100
14965 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_inet.h   2010-05-18 18:11:22.000000000 +0200
14966 @@ -0,0 +1,342 @@
14967 +#ifndef _VS_INET_H
14968 +#define _VS_INET_H
14969 +
14970 +#include "vserver/base.h"
14971 +#include "vserver/network.h"
14972 +#include "vserver/debug.h"
14973 +
14974 +#define IPI_LOOPBACK   htonl(INADDR_LOOPBACK)
14975 +
14976 +#define NXAV4(a)       NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
14977 +                       NIPQUAD((a)->mask), (a)->type
14978 +#define NXAV4_FMT      "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
14979 +
14980 +
14981 +static inline
14982 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
14983 +{
14984 +       __be32 ip = nxa->ip[0].s_addr;
14985 +       __be32 mask = nxa->mask.s_addr;
14986 +       __be32 bcast = ip | ~mask;
14987 +       int ret = 0;
14988 +
14989 +       switch (nxa->type & tmask) {
14990 +       case NXA_TYPE_MASK:
14991 +               ret = (ip == (addr & mask));
14992 +               break;
14993 +       case NXA_TYPE_ADDR:
14994 +               ret = 3;
14995 +               if (addr == ip)
14996 +                       break;
14997 +               /* fall through to broadcast */
14998 +       case NXA_MOD_BCAST:
14999 +               ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
15000 +               break;
15001 +       case NXA_TYPE_RANGE:
15002 +               ret = ((nxa->ip[0].s_addr <= addr) &&
15003 +                       (nxa->ip[1].s_addr > addr));
15004 +               break;
15005 +       case NXA_TYPE_ANY:
15006 +               ret = 2;
15007 +               break;
15008 +       }
15009 +
15010 +       vxdprintk(VXD_CBIT(net, 0),
15011 +               "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
15012 +               nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
15013 +       return ret;
15014 +}
15015 +
15016 +static inline
15017 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
15018 +{
15019 +       struct nx_addr_v4 *nxa;
15020 +       int ret = 1;
15021 +
15022 +       if (!nxi)
15023 +               goto out;
15024 +
15025 +       ret = 2;
15026 +       /* allow 127.0.0.1 when remapping lback */
15027 +       if ((tmask & NXA_LOOPBACK) &&
15028 +               (addr == IPI_LOOPBACK) &&
15029 +               nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15030 +               goto out;
15031 +       ret = 3;
15032 +       /* check for lback address */
15033 +       if ((tmask & NXA_MOD_LBACK) &&
15034 +               (nxi->v4_lback.s_addr == addr))
15035 +               goto out;
15036 +       ret = 4;
15037 +       /* check for broadcast address */
15038 +       if ((tmask & NXA_MOD_BCAST) &&
15039 +               (nxi->v4_bcast.s_addr == addr))
15040 +               goto out;
15041 +       ret = 5;
15042 +       /* check for v4 addresses */
15043 +       for (nxa = &nxi->v4; nxa; nxa = nxa->next)
15044 +               if (v4_addr_match(nxa, addr, tmask))
15045 +                       goto out;
15046 +       ret = 0;
15047 +out:
15048 +       vxdprintk(VXD_CBIT(net, 0),
15049 +               "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
15050 +               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
15051 +       return ret;
15052 +}
15053 +
15054 +static inline
15055 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
15056 +{
15057 +       /* FIXME: needs full range checks */
15058 +       return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
15059 +}
15060 +
15061 +static inline
15062 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
15063 +{
15064 +       struct nx_addr_v4 *ptr;
15065 +
15066 +       for (ptr = &nxi->v4; ptr; ptr = ptr->next)
15067 +               if (v4_nx_addr_match(ptr, nxa, mask))
15068 +                       return 1;
15069 +       return 0;
15070 +}
15071 +
15072 +#include <net/inet_sock.h>
15073 +
15074 +/*
15075 + *     Check if a given address matches for a socket
15076 + *
15077 + *     nxi:            the socket's nx_info if any
15078 + *     addr:           to be verified address
15079 + */
15080 +static inline
15081 +int v4_sock_addr_match (
15082 +       struct nx_info *nxi,
15083 +       struct inet_sock *inet,
15084 +       __be32 addr)
15085 +{
15086 +       __be32 saddr = inet->inet_rcv_saddr;
15087 +       __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
15088 +
15089 +       if (addr && (saddr == addr || bcast == addr))
15090 +               return 1;
15091 +       if (!saddr)
15092 +               return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
15093 +       return 0;
15094 +}
15095 +
15096 +
15097 +/* inet related checks and helpers */
15098 +
15099 +
15100 +struct in_ifaddr;
15101 +struct net_device;
15102 +struct sock;
15103 +
15104 +#ifdef CONFIG_INET
15105 +
15106 +#include <linux/netdevice.h>
15107 +#include <linux/inetdevice.h>
15108 +#include <net/inet_sock.h>
15109 +#include <net/inet_timewait_sock.h>
15110 +
15111 +
15112 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15113 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
15114 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
15115 +
15116 +
15117 +/*
15118 + *     check if address is covered by socket
15119 + *
15120 + *     sk:     the socket to check against
15121 + *     addr:   the address in question (must be != 0)
15122 + */
15123 +
15124 +static inline
15125 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
15126 +{
15127 +       struct nx_info *nxi = sk->sk_nx_info;
15128 +       __be32 saddr = inet_rcv_saddr(sk);
15129 +
15130 +       vxdprintk(VXD_CBIT(net, 5),
15131 +               "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
15132 +               sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
15133 +               (sk->sk_socket?sk->sk_socket->flags:0));
15134 +
15135 +       if (saddr) {            /* direct address match */
15136 +               return v4_addr_match(nxa, saddr, -1);
15137 +       } else if (nxi) {       /* match against nx_info */
15138 +               return v4_nx_addr_in_nx_info(nxi, nxa, -1);
15139 +       } else {                /* unrestricted any socket */
15140 +               return 1;
15141 +       }
15142 +}
15143 +
15144 +
15145 +
15146 +static inline
15147 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
15148 +{
15149 +       vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p Â»%s«) %d",
15150 +               nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
15151 +               nxi ? dev_in_nx_info(dev, nxi) : 0);
15152 +
15153 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15154 +               return 1;
15155 +       if (dev_in_nx_info(dev, nxi))
15156 +               return 1;
15157 +       return 0;
15158 +}
15159 +
15160 +
15161 +static inline
15162 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
15163 +{
15164 +       if (!nxi)
15165 +               return 1;
15166 +       if (!ifa)
15167 +               return 0;
15168 +       return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
15169 +}
15170 +
15171 +static inline
15172 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
15173 +{
15174 +       vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
15175 +               nxi, nxi ? nxi->nx_id : 0, ifa,
15176 +               nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
15177 +
15178 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15179 +               return 1;
15180 +       if (v4_ifa_in_nx_info(ifa, nxi))
15181 +               return 1;
15182 +       return 0;
15183 +}
15184 +
15185 +
15186 +struct nx_v4_sock_addr {
15187 +       __be32 saddr;   /* Address used for validation */
15188 +       __be32 baddr;   /* Address used for socket bind */
15189 +};
15190 +
15191 +static inline
15192 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
15193 +       struct nx_v4_sock_addr *nsa)
15194 +{
15195 +       struct sock *sk = &inet->sk;
15196 +       struct nx_info *nxi = sk->sk_nx_info;
15197 +       __be32 saddr = addr->sin_addr.s_addr;
15198 +       __be32 baddr = saddr;
15199 +
15200 +       vxdprintk(VXD_CBIT(net, 3),
15201 +               "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
15202 +               sk, sk->sk_nx_info, sk->sk_socket,
15203 +               (sk->sk_socket ? sk->sk_socket->flags : 0),
15204 +               NIPQUAD(saddr));
15205 +
15206 +       if (nxi) {
15207 +               if (saddr == INADDR_ANY) {
15208 +                       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
15209 +                               baddr = nxi->v4.ip[0].s_addr;
15210 +               } else if (saddr == IPI_LOOPBACK) {
15211 +                       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15212 +                               baddr = nxi->v4_lback.s_addr;
15213 +               } else {        /* normal address bind */
15214 +                       if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
15215 +                               return -EADDRNOTAVAIL;
15216 +               }
15217 +       }
15218 +
15219 +       vxdprintk(VXD_CBIT(net, 3),
15220 +               "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
15221 +               sk, NIPQUAD(saddr), NIPQUAD(baddr));
15222 +
15223 +       nsa->saddr = saddr;
15224 +       nsa->baddr = baddr;
15225 +       return 0;
15226 +}
15227 +
15228 +static inline
15229 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
15230 +{
15231 +       inet->inet_saddr = nsa->baddr;
15232 +       inet->inet_rcv_saddr = nsa->baddr;
15233 +}
15234 +
15235 +
15236 +/*
15237 + *      helper to simplify inet_lookup_listener
15238 + *
15239 + *      nxi:   the socket's nx_info if any
15240 + *      addr:  to be verified address
15241 + *      saddr: socket address
15242 + */
15243 +static inline int v4_inet_addr_match (
15244 +       struct nx_info *nxi,
15245 +       __be32 addr,
15246 +       __be32 saddr)
15247 +{
15248 +       if (addr && (saddr == addr))
15249 +               return 1;
15250 +       if (!saddr)
15251 +               return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
15252 +       return 0;
15253 +}
15254 +
15255 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
15256 +{
15257 +       if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
15258 +               (addr == nxi->v4_lback.s_addr))
15259 +               return IPI_LOOPBACK;
15260 +       return addr;
15261 +}
15262 +
15263 +static inline
15264 +int nx_info_has_v4(struct nx_info *nxi)
15265 +{
15266 +       if (!nxi)
15267 +               return 1;
15268 +       if (NX_IPV4(nxi))
15269 +               return 1;
15270 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15271 +               return 1;
15272 +       return 0;
15273 +}
15274 +
15275 +#else /* CONFIG_INET */
15276 +
15277 +static inline
15278 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
15279 +{
15280 +       return 1;
15281 +}
15282 +
15283 +static inline
15284 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
15285 +{
15286 +       return 1;
15287 +}
15288 +
15289 +static inline
15290 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
15291 +{
15292 +       return 1;
15293 +}
15294 +
15295 +static inline
15296 +int nx_info_has_v4(struct nx_info *nxi)
15297 +{
15298 +       return 0;
15299 +}
15300 +
15301 +#endif /* CONFIG_INET */
15302 +
15303 +#define current_nx_info_has_v4() \
15304 +       nx_info_has_v4(current_nx_info())
15305 +
15306 +#else
15307 +// #warning duplicate inclusion
15308 +#endif
15309 diff -NurpP --minimal linux-2.6.34/include/linux/vs_limit.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_limit.h
15310 --- linux-2.6.34/include/linux/vs_limit.h       1970-01-01 01:00:00.000000000 +0100
15311 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_limit.h  2010-05-18 18:11:22.000000000 +0200
15312 @@ -0,0 +1,140 @@
15313 +#ifndef _VS_LIMIT_H
15314 +#define _VS_LIMIT_H
15315 +
15316 +#include "vserver/limit.h"
15317 +#include "vserver/base.h"
15318 +#include "vserver/context.h"
15319 +#include "vserver/debug.h"
15320 +#include "vserver/context.h"
15321 +#include "vserver/limit_int.h"
15322 +
15323 +
15324 +#define vx_acc_cres(v, d, p, r) \
15325 +       __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
15326 +
15327 +#define vx_acc_cres_cond(x, d, p, r) \
15328 +       __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15329 +       r, d, p, __FILE__, __LINE__)
15330 +
15331 +
15332 +#define vx_add_cres(v, a, p, r) \
15333 +       __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
15334 +#define vx_sub_cres(v, a, p, r)                vx_add_cres(v, -(a), p, r)
15335 +
15336 +#define vx_add_cres_cond(x, a, p, r) \
15337 +       __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15338 +       r, a, p, __FILE__, __LINE__)
15339 +#define vx_sub_cres_cond(x, a, p, r)   vx_add_cres_cond(x, -(a), p, r)
15340 +
15341 +
15342 +/* process and file limits */
15343 +
15344 +#define vx_nproc_inc(p) \
15345 +       vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
15346 +
15347 +#define vx_nproc_dec(p) \
15348 +       vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
15349 +
15350 +#define vx_files_inc(f) \
15351 +       vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
15352 +
15353 +#define vx_files_dec(f) \
15354 +       vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
15355 +
15356 +#define vx_locks_inc(l) \
15357 +       vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
15358 +
15359 +#define vx_locks_dec(l) \
15360 +       vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
15361 +
15362 +#define vx_openfd_inc(f) \
15363 +       vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
15364 +
15365 +#define vx_openfd_dec(f) \
15366 +       vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
15367 +
15368 +
15369 +#define vx_cres_avail(v, n, r) \
15370 +       __vx_cres_avail(v, r, n, __FILE__, __LINE__)
15371 +
15372 +
15373 +#define vx_nproc_avail(n) \
15374 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
15375 +
15376 +#define vx_files_avail(n) \
15377 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
15378 +
15379 +#define vx_locks_avail(n) \
15380 +       vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
15381 +
15382 +#define vx_openfd_avail(n) \
15383 +       vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
15384 +
15385 +
15386 +/* dentry limits */
15387 +
15388 +#define vx_dentry_inc(d) do {                                          \
15389 +       if (atomic_read(&d->d_count) == 1)                              \
15390 +               vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY);    \
15391 +       } while (0)
15392 +
15393 +#define vx_dentry_dec(d) do {                                          \
15394 +       if (atomic_read(&d->d_count) == 0)                              \
15395 +               vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY);    \
15396 +       } while (0)
15397 +
15398 +#define vx_dentry_avail(n) \
15399 +       vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
15400 +
15401 +
15402 +/* socket limits */
15403 +
15404 +#define vx_sock_inc(s) \
15405 +       vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
15406 +
15407 +#define vx_sock_dec(s) \
15408 +       vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
15409 +
15410 +#define vx_sock_avail(n) \
15411 +       vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
15412 +
15413 +
15414 +/* ipc resource limits */
15415 +
15416 +#define vx_ipcmsg_add(v, u, a) \
15417 +       vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
15418 +
15419 +#define vx_ipcmsg_sub(v, u, a) \
15420 +       vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
15421 +
15422 +#define vx_ipcmsg_avail(v, a) \
15423 +       vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
15424 +
15425 +
15426 +#define vx_ipcshm_add(v, k, a) \
15427 +       vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15428 +
15429 +#define vx_ipcshm_sub(v, k, a) \
15430 +       vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15431 +
15432 +#define vx_ipcshm_avail(v, a) \
15433 +       vx_cres_avail(v, a, VLIMIT_SHMEM)
15434 +
15435 +
15436 +#define vx_semary_inc(a) \
15437 +       vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
15438 +
15439 +#define vx_semary_dec(a) \
15440 +       vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
15441 +
15442 +
15443 +#define vx_nsems_add(a,n) \
15444 +       vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15445 +
15446 +#define vx_nsems_sub(a,n) \
15447 +       vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15448 +
15449 +
15450 +#else
15451 +#warning duplicate inclusion
15452 +#endif
15453 diff -NurpP --minimal linux-2.6.34/include/linux/vs_memory.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_memory.h
15454 --- linux-2.6.34/include/linux/vs_memory.h      1970-01-01 01:00:00.000000000 +0100
15455 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_memory.h 2010-05-19 03:11:07.000000000 +0200
15456 @@ -0,0 +1,58 @@
15457 +#ifndef _VS_MEMORY_H
15458 +#define _VS_MEMORY_H
15459 +
15460 +#include "vserver/limit.h"
15461 +#include "vserver/base.h"
15462 +#include "vserver/context.h"
15463 +#include "vserver/debug.h"
15464 +#include "vserver/context.h"
15465 +#include "vserver/limit_int.h"
15466 +
15467 +enum {
15468 +       VXPT_UNKNOWN = 0,
15469 +       VXPT_ANON,
15470 +       VXPT_NONE,
15471 +       VXPT_FILE,
15472 +       VXPT_SWAP,
15473 +       VXPT_WRITE
15474 +};
15475 +
15476 +#if 0
15477 +#define        vx_page_fault(mm, vma, type, ret)
15478 +#else
15479 +
15480 +static inline
15481 +void __vx_page_fault(struct mm_struct *mm,
15482 +       struct vm_area_struct *vma, int type, int ret)
15483 +{
15484 +       struct vx_info *vxi = mm->mm_vx_info;
15485 +       int what;
15486 +/*
15487 +       static char *page_type[6] =
15488 +               { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
15489 +       static char *page_what[4] =
15490 +               { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
15491 +*/
15492 +
15493 +       if (!vxi)
15494 +               return;
15495 +
15496 +       what = (ret & 0x3);
15497 +
15498 +/*     printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
15499 +               type, what, ret, page_type[type], page_what[what]);
15500 +*/
15501 +       if (ret & VM_FAULT_WRITE)
15502 +               what |= 0x4;
15503 +       atomic_inc(&vxi->cacct.page[type][what]);
15504 +}
15505 +
15506 +#define        vx_page_fault(mm, vma, type, ret)       __vx_page_fault(mm, vma, type, ret)
15507 +#endif
15508 +
15509 +
15510 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
15511 +
15512 +#else
15513 +#warning duplicate inclusion
15514 +#endif
15515 diff -NurpP --minimal linux-2.6.34/include/linux/vs_network.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_network.h
15516 --- linux-2.6.34/include/linux/vs_network.h     1970-01-01 01:00:00.000000000 +0100
15517 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_network.h        2010-05-18 18:11:22.000000000 +0200
15518 @@ -0,0 +1,169 @@
15519 +#ifndef _NX_VS_NETWORK_H
15520 +#define _NX_VS_NETWORK_H
15521 +
15522 +#include "vserver/context.h"
15523 +#include "vserver/network.h"
15524 +#include "vserver/base.h"
15525 +#include "vserver/check.h"
15526 +#include "vserver/debug.h"
15527 +
15528 +#include <linux/sched.h>
15529 +
15530 +
15531 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
15532 +
15533 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
15534 +       const char *_file, int _line)
15535 +{
15536 +       if (!nxi)
15537 +               return NULL;
15538 +
15539 +       vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
15540 +               nxi, nxi ? nxi->nx_id : 0,
15541 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15542 +               _file, _line);
15543 +
15544 +       atomic_inc(&nxi->nx_usecnt);
15545 +       return nxi;
15546 +}
15547 +
15548 +
15549 +extern void free_nx_info(struct nx_info *);
15550 +
15551 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
15552 +
15553 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
15554 +{
15555 +       if (!nxi)
15556 +               return;
15557 +
15558 +       vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
15559 +               nxi, nxi ? nxi->nx_id : 0,
15560 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15561 +               _file, _line);
15562 +
15563 +       if (atomic_dec_and_test(&nxi->nx_usecnt))
15564 +               free_nx_info(nxi);
15565 +}
15566 +
15567 +
15568 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
15569 +
15570 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15571 +               const char *_file, int _line)
15572 +{
15573 +       if (nxi) {
15574 +               vxlprintk(VXD_CBIT(nid, 3),
15575 +                       "init_nx_info(%p[#%d.%d])",
15576 +                       nxi, nxi ? nxi->nx_id : 0,
15577 +                       nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15578 +                       _file, _line);
15579 +
15580 +               atomic_inc(&nxi->nx_usecnt);
15581 +       }
15582 +       *nxp = nxi;
15583 +}
15584 +
15585 +
15586 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
15587 +
15588 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15589 +       const char *_file, int _line)
15590 +{
15591 +       struct nx_info *nxo;
15592 +
15593 +       if (!nxi)
15594 +               return;
15595 +
15596 +       vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
15597 +               nxi, nxi ? nxi->nx_id : 0,
15598 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15599 +               _file, _line);
15600 +
15601 +       atomic_inc(&nxi->nx_usecnt);
15602 +       nxo = xchg(nxp, nxi);
15603 +       BUG_ON(nxo);
15604 +}
15605 +
15606 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
15607 +
15608 +static inline void __clr_nx_info(struct nx_info **nxp,
15609 +       const char *_file, int _line)
15610 +{
15611 +       struct nx_info *nxo;
15612 +
15613 +       nxo = xchg(nxp, NULL);
15614 +       if (!nxo)
15615 +               return;
15616 +
15617 +       vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
15618 +               nxo, nxo ? nxo->nx_id : 0,
15619 +               nxo ? atomic_read(&nxo->nx_usecnt) : 0,
15620 +               _file, _line);
15621 +
15622 +       if (atomic_dec_and_test(&nxo->nx_usecnt))
15623 +               free_nx_info(nxo);
15624 +}
15625 +
15626 +
15627 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
15628 +
15629 +static inline void __claim_nx_info(struct nx_info *nxi,
15630 +       struct task_struct *task, const char *_file, int _line)
15631 +{
15632 +       vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
15633 +               nxi, nxi ? nxi->nx_id : 0,
15634 +               nxi?atomic_read(&nxi->nx_usecnt):0,
15635 +               nxi?atomic_read(&nxi->nx_tasks):0,
15636 +               task, _file, _line);
15637 +
15638 +       atomic_inc(&nxi->nx_tasks);
15639 +}
15640 +
15641 +
15642 +extern void unhash_nx_info(struct nx_info *);
15643 +
15644 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
15645 +
15646 +static inline void __release_nx_info(struct nx_info *nxi,
15647 +       struct task_struct *task, const char *_file, int _line)
15648 +{
15649 +       vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
15650 +               nxi, nxi ? nxi->nx_id : 0,
15651 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15652 +               nxi ? atomic_read(&nxi->nx_tasks) : 0,
15653 +               task, _file, _line);
15654 +
15655 +       might_sleep();
15656 +
15657 +       if (atomic_dec_and_test(&nxi->nx_tasks))
15658 +               unhash_nx_info(nxi);
15659 +}
15660 +
15661 +
15662 +#define task_get_nx_info(i)    __task_get_nx_info(i, __FILE__, __LINE__)
15663 +
15664 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
15665 +       const char *_file, int _line)
15666 +{
15667 +       struct nx_info *nxi;
15668 +
15669 +       task_lock(p);
15670 +       vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
15671 +               p, _file, _line);
15672 +       nxi = __get_nx_info(p->nx_info, _file, _line);
15673 +       task_unlock(p);
15674 +       return nxi;
15675 +}
15676 +
15677 +
15678 +static inline void exit_nx_info(struct task_struct *p)
15679 +{
15680 +       if (p->nx_info)
15681 +               release_nx_info(p->nx_info, p);
15682 +}
15683 +
15684 +
15685 +#else
15686 +#warning duplicate inclusion
15687 +#endif
15688 diff -NurpP --minimal linux-2.6.34/include/linux/vs_pid.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_pid.h
15689 --- linux-2.6.34/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
15690 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_pid.h    2010-05-18 18:11:22.000000000 +0200
15691 @@ -0,0 +1,95 @@
15692 +#ifndef _VS_PID_H
15693 +#define _VS_PID_H
15694 +
15695 +#include "vserver/base.h"
15696 +#include "vserver/check.h"
15697 +#include "vserver/context.h"
15698 +#include "vserver/debug.h"
15699 +#include "vserver/pid.h"
15700 +#include <linux/pid_namespace.h>
15701 +
15702 +
15703 +#define VXF_FAKE_INIT  (VXF_INFO_INIT | VXF_STATE_INIT)
15704 +
15705 +static inline
15706 +int vx_proc_task_visible(struct task_struct *task)
15707 +{
15708 +       if ((task->pid == 1) &&
15709 +               !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
15710 +               /* show a blend through init */
15711 +               goto visible;
15712 +       if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
15713 +               goto visible;
15714 +       return 0;
15715 +visible:
15716 +       return 1;
15717 +}
15718 +
15719 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
15720 +
15721 +#if 0
15722 +
15723 +static inline
15724 +struct task_struct *vx_find_proc_task_by_pid(int pid)
15725 +{
15726 +       struct task_struct *task = find_task_by_real_pid(pid);
15727 +
15728 +       if (task && !vx_proc_task_visible(task)) {
15729 +               vxdprintk(VXD_CBIT(misc, 6),
15730 +                       "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
15731 +                       task, task->xid, task->pid,
15732 +                       current, current->xid, current->pid);
15733 +               task = NULL;
15734 +       }
15735 +       return task;
15736 +}
15737 +
15738 +#endif
15739 +
15740 +static inline
15741 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
15742 +{
15743 +       struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
15744 +
15745 +       if (task && !vx_proc_task_visible(task)) {
15746 +               vxdprintk(VXD_CBIT(misc, 6),
15747 +                       "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
15748 +                       task, task->xid, task->pid,
15749 +                       current, current->xid, current->pid);
15750 +               put_task_struct(task);
15751 +               task = NULL;
15752 +       }
15753 +       return task;
15754 +}
15755 +
15756 +#if 0
15757 +
15758 +static inline
15759 +struct task_struct *vx_child_reaper(struct task_struct *p)
15760 +{
15761 +       struct vx_info *vxi = p->vx_info;
15762 +       struct task_struct *reaper = child_reaper(p);
15763 +
15764 +       if (!vxi)
15765 +               goto out;
15766 +
15767 +       BUG_ON(!p->vx_info->vx_reaper);
15768 +
15769 +       /* child reaper for the guest reaper */
15770 +       if (vxi->vx_reaper == p)
15771 +               goto out;
15772 +
15773 +       reaper = vxi->vx_reaper;
15774 +out:
15775 +       vxdprintk(VXD_CBIT(xid, 7),
15776 +               "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
15777 +               p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
15778 +       return reaper;
15779 +}
15780 +
15781 +#endif
15782 +
15783 +
15784 +#else
15785 +#warning duplicate inclusion
15786 +#endif
15787 diff -NurpP --minimal linux-2.6.34/include/linux/vs_sched.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_sched.h
15788 --- linux-2.6.34/include/linux/vs_sched.h       1970-01-01 01:00:00.000000000 +0100
15789 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_sched.h  2010-05-18 18:11:22.000000000 +0200
15790 @@ -0,0 +1,110 @@
15791 +#ifndef _VS_SCHED_H
15792 +#define _VS_SCHED_H
15793 +
15794 +#include "vserver/base.h"
15795 +#include "vserver/context.h"
15796 +#include "vserver/sched.h"
15797 +
15798 +
15799 +#define VAVAVOOM_RATIO          50
15800 +
15801 +#define MAX_PRIO_BIAS           20
15802 +#define MIN_PRIO_BIAS          -20
15803 +
15804 +
15805 +#ifdef CONFIG_VSERVER_HARDCPU
15806 +
15807 +/*
15808 + * effective_prio - return the priority that is based on the static
15809 + * priority but is modified by bonuses/penalties.
15810 + *
15811 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
15812 + * into a -4 ... 0 ... +4 bonus/penalty range.
15813 + *
15814 + * Additionally, we scale another amount based on the number of
15815 + * CPU tokens currently held by the context, if the process is
15816 + * part of a context (and the appropriate SCHED flag is set).
15817 + * This ranges from -5 ... 0 ... +15, quadratically.
15818 + *
15819 + * So, the total bonus is -9 .. 0 .. +19
15820 + * We use ~50% of the full 0...39 priority range so that:
15821 + *
15822 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
15823 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
15824 + *    unless that context is far exceeding its CPU allocation.
15825 + *
15826 + * Both properties are important to certain workloads.
15827 + */
15828 +static inline
15829 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
15830 +{
15831 +       int vavavoom, max;
15832 +
15833 +       /* lots of tokens = lots of vavavoom
15834 +        *      no tokens = no vavavoom      */
15835 +       if ((vavavoom = sched_pc->tokens) >= 0) {
15836 +               max = sched_pc->tokens_max;
15837 +               vavavoom = max - vavavoom;
15838 +               max = max * max;
15839 +               vavavoom = max_prio * VAVAVOOM_RATIO / 100
15840 +                       * (vavavoom*vavavoom - (max >> 2)) / max;
15841 +               return vavavoom;
15842 +       }
15843 +       return 0;
15844 +}
15845 +
15846 +
15847 +static inline
15848 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
15849 +{
15850 +       struct vx_info *vxi = p->vx_info;
15851 +       struct _vx_sched_pc *sched_pc;
15852 +
15853 +       if (!vxi)
15854 +               return prio;
15855 +
15856 +       sched_pc = &vx_cpu(vxi, sched_pc);
15857 +       if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
15858 +               int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
15859 +
15860 +               sched_pc->vavavoom = vavavoom;
15861 +               prio += vavavoom;
15862 +       }
15863 +       prio += sched_pc->prio_bias;
15864 +       return prio;
15865 +}
15866 +
15867 +#else /* !CONFIG_VSERVER_HARDCPU */
15868 +
15869 +static inline
15870 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
15871 +{
15872 +       struct vx_info *vxi = p->vx_info;
15873 +
15874 +       if (vxi)
15875 +               prio += vx_cpu(vxi, sched_pc).prio_bias;
15876 +       return prio;
15877 +}
15878 +
15879 +#endif /* CONFIG_VSERVER_HARDCPU */
15880 +
15881 +
15882 +static inline void vx_account_user(struct vx_info *vxi,
15883 +       cputime_t cputime, int nice)
15884 +{
15885 +       if (!vxi)
15886 +               return;
15887 +       vx_cpu(vxi, sched_pc).user_ticks += cputime;
15888 +}
15889 +
15890 +static inline void vx_account_system(struct vx_info *vxi,
15891 +       cputime_t cputime, int idle)
15892 +{
15893 +       if (!vxi)
15894 +               return;
15895 +       vx_cpu(vxi, sched_pc).sys_ticks += cputime;
15896 +}
15897 +
15898 +#else
15899 +#warning duplicate inclusion
15900 +#endif
15901 diff -NurpP --minimal linux-2.6.34/include/linux/vs_socket.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_socket.h
15902 --- linux-2.6.34/include/linux/vs_socket.h      1970-01-01 01:00:00.000000000 +0100
15903 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_socket.h 2010-05-18 18:11:22.000000000 +0200
15904 @@ -0,0 +1,67 @@
15905 +#ifndef _VS_SOCKET_H
15906 +#define _VS_SOCKET_H
15907 +
15908 +#include "vserver/debug.h"
15909 +#include "vserver/base.h"
15910 +#include "vserver/cacct.h"
15911 +#include "vserver/context.h"
15912 +#include "vserver/tag.h"
15913 +
15914 +
15915 +/* socket accounting */
15916 +
15917 +#include <linux/socket.h>
15918 +
15919 +static inline int vx_sock_type(int family)
15920 +{
15921 +       switch (family) {
15922 +       case PF_UNSPEC:
15923 +               return VXA_SOCK_UNSPEC;
15924 +       case PF_UNIX:
15925 +               return VXA_SOCK_UNIX;
15926 +       case PF_INET:
15927 +               return VXA_SOCK_INET;
15928 +       case PF_INET6:
15929 +               return VXA_SOCK_INET6;
15930 +       case PF_PACKET:
15931 +               return VXA_SOCK_PACKET;
15932 +       default:
15933 +               return VXA_SOCK_OTHER;
15934 +       }
15935 +}
15936 +
15937 +#define vx_acc_sock(v, f, p, s) \
15938 +       __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
15939 +
15940 +static inline void __vx_acc_sock(struct vx_info *vxi,
15941 +       int family, int pos, int size, char *file, int line)
15942 +{
15943 +       if (vxi) {
15944 +               int type = vx_sock_type(family);
15945 +
15946 +               atomic_long_inc(&vxi->cacct.sock[type][pos].count);
15947 +               atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
15948 +       }
15949 +}
15950 +
15951 +#define vx_sock_recv(sk, s) \
15952 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
15953 +#define vx_sock_send(sk, s) \
15954 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
15955 +#define vx_sock_fail(sk, s) \
15956 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
15957 +
15958 +
15959 +#define sock_vx_init(s) do {           \
15960 +       (s)->sk_xid = 0;                \
15961 +       (s)->sk_vx_info = NULL;         \
15962 +       } while (0)
15963 +
15964 +#define sock_nx_init(s) do {           \
15965 +       (s)->sk_nid = 0;                \
15966 +       (s)->sk_nx_info = NULL;         \
15967 +       } while (0)
15968 +
15969 +#else
15970 +#warning duplicate inclusion
15971 +#endif
15972 diff -NurpP --minimal linux-2.6.34/include/linux/vs_tag.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_tag.h
15973 --- linux-2.6.34/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
15974 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_tag.h    2010-05-18 18:11:22.000000000 +0200
15975 @@ -0,0 +1,47 @@
15976 +#ifndef _VS_TAG_H
15977 +#define _VS_TAG_H
15978 +
15979 +#include <linux/vserver/tag.h>
15980 +
15981 +/* check conditions */
15982 +
15983 +#define DX_ADMIN       0x0001
15984 +#define DX_WATCH       0x0002
15985 +#define DX_HOSTID      0x0008
15986 +
15987 +#define DX_IDENT       0x0010
15988 +
15989 +#define DX_ARG_MASK    0x0010
15990 +
15991 +
15992 +#define dx_task_tag(t) ((t)->tag)
15993 +
15994 +#define dx_current_tag() dx_task_tag(current)
15995 +
15996 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
15997 +
15998 +#define dx_weak_check(c, m)    ((m) ? dx_check(c, m) : 1)
15999 +
16000 +
16001 +/*
16002 + * check current context for ADMIN/WATCH and
16003 + * optionally against supplied argument
16004 + */
16005 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
16006 +{
16007 +       if (mode & DX_ARG_MASK) {
16008 +               if ((mode & DX_IDENT) && (id == cid))
16009 +                       return 1;
16010 +       }
16011 +       return (((mode & DX_ADMIN) && (cid == 0)) ||
16012 +               ((mode & DX_WATCH) && (cid == 1)) ||
16013 +               ((mode & DX_HOSTID) && (id == 0)));
16014 +}
16015 +
16016 +struct inode;
16017 +int dx_permission(const struct inode *inode, int mask);
16018 +
16019 +
16020 +#else
16021 +#warning duplicate inclusion
16022 +#endif
16023 diff -NurpP --minimal linux-2.6.34/include/linux/vs_time.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_time.h
16024 --- linux-2.6.34/include/linux/vs_time.h        1970-01-01 01:00:00.000000000 +0100
16025 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/linux/vs_time.h   2010-05-18 18:11:22.000000000 +0200
16026 @@ -0,0 +1,19 @@
16027 +#ifndef _VS_TIME_H
16028 +#define _VS_TIME_H
16029 +
16030 +
16031 +/* time faking stuff */
16032 +
16033 +#ifdef CONFIG_VSERVER_VTIME
16034 +
16035 +extern void vx_gettimeofday(struct timeval *tv);
16036 +extern int vx_settimeofday(struct timespec *ts);
16037 +
16038 +#else
16039 +#define        vx_gettimeofday(t)      do_gettimeofday(t)
16040 +#define        vx_settimeofday(t)      do_settimeofday(t)
16041 +#endif
16042 +
16043 +#else
16044 +#warning duplicate inclusion
16045 +#endif
16046 diff -NurpP --minimal linux-2.6.34/include/net/addrconf.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/net/addrconf.h
16047 --- linux-2.6.34/include/net/addrconf.h 2010-05-18 15:07:52.000000000 +0200
16048 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/net/addrconf.h    2010-05-18 18:11:22.000000000 +0200
16049 @@ -84,7 +84,8 @@ extern int                    ipv6_dev_get_saddr(struct n
16050                                                struct net_device *dev,
16051                                                const struct in6_addr *daddr,
16052                                                unsigned int srcprefs,
16053 -                                              struct in6_addr *saddr);
16054 +                                              struct in6_addr *saddr,
16055 +                                              struct nx_info *nxi);
16056  extern int                     ipv6_get_lladdr(struct net_device *dev,
16057                                                 struct in6_addr *addr,
16058                                                 unsigned char banned_flags);
16059 diff -NurpP --minimal linux-2.6.34/include/net/af_unix.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/net/af_unix.h
16060 --- linux-2.6.34/include/net/af_unix.h  2008-12-25 00:26:37.000000000 +0100
16061 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/net/af_unix.h     2010-05-18 18:11:22.000000000 +0200
16062 @@ -4,6 +4,7 @@
16063  #include <linux/socket.h>
16064  #include <linux/un.h>
16065  #include <linux/mutex.h>
16066 +#include <linux/vs_base.h>
16067  #include <net/sock.h>
16068  
16069  extern void unix_inflight(struct file *fp);
16070 diff -NurpP --minimal linux-2.6.34/include/net/inet_timewait_sock.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/net/inet_timewait_sock.h
16071 --- linux-2.6.34/include/net/inet_timewait_sock.h       2010-02-25 11:52:08.000000000 +0100
16072 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/net/inet_timewait_sock.h  2010-05-18 18:11:22.000000000 +0200
16073 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
16074  #define tw_hash                        __tw_common.skc_hash
16075  #define tw_prot                        __tw_common.skc_prot
16076  #define tw_net                 __tw_common.skc_net
16077 +#define tw_xid                 __tw_common.skc_xid
16078 +#define tw_vx_info             __tw_common.skc_vx_info
16079 +#define tw_nid                 __tw_common.skc_nid
16080 +#define tw_nx_info             __tw_common.skc_nx_info
16081         int                     tw_timeout;
16082         volatile unsigned char  tw_substate;
16083         /* 3 bits hole, try to pack */
16084 diff -NurpP --minimal linux-2.6.34/include/net/route.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/net/route.h
16085 --- linux-2.6.34/include/net/route.h    2010-05-18 15:07:52.000000000 +0200
16086 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/net/route.h       2010-05-18 18:11:22.000000000 +0200
16087 @@ -132,6 +132,9 @@ static inline void ip_rt_put(struct rtab
16088                 dst_release(&rt->u.dst);
16089  }
16090  
16091 +#include <linux/vs_base.h>
16092 +#include <linux/vs_inet.h>
16093 +
16094  #define IPTOS_RT_MASK  (IPTOS_TOS_MASK & ~3)
16095  
16096  extern const __u8 ip_tos2prio[16];
16097 @@ -141,6 +144,9 @@ static inline char rt_tos2priority(u8 to
16098         return ip_tos2prio[IPTOS_TOS(tos)>>1];
16099  }
16100  
16101 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
16102 +       struct rtable **, struct flowi *);
16103 +
16104  static inline int ip_route_connect(struct rtable **rp, __be32 dst,
16105                                    __be32 src, u32 tos, int oif, u8 protocol,
16106                                    __be16 sport, __be16 dport, struct sock *sk,
16107 @@ -158,11 +164,24 @@ static inline int ip_route_connect(struc
16108  
16109         int err;
16110         struct net *net = sock_net(sk);
16111 +       struct nx_info *nx_info = current_nx_info();
16112  
16113         if (inet_sk(sk)->transparent)
16114                 fl.flags |= FLOWI_FLAG_ANYSRC;
16115  
16116 -       if (!dst || !src) {
16117 +       if (sk)
16118 +               nx_info = sk->sk_nx_info;
16119 +
16120 +       vxdprintk(VXD_CBIT(net, 4),
16121 +               "ip_route_connect(%p) %p,%p;%lx",
16122 +               sk, nx_info, sk->sk_socket,
16123 +               (sk->sk_socket?sk->sk_socket->flags:0));
16124 +
16125 +       err = ip_v4_find_src(net, nx_info, rp, &fl);
16126 +       if (err)
16127 +               return err;
16128 +
16129 +       if (!fl.fl4_dst || !fl.fl4_src) {
16130                 err = __ip_route_output_key(net, rp, &fl);
16131                 if (err)
16132                         return err;
16133 diff -NurpP --minimal linux-2.6.34/include/net/sock.h linux-2.6.34-vs2.3.0.36.30.4.pre6/include/net/sock.h
16134 --- linux-2.6.34/include/net/sock.h     2010-05-18 15:07:53.000000000 +0200
16135 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/include/net/sock.h        2010-05-18 18:11:22.000000000 +0200
16136 @@ -150,6 +150,10 @@ struct sock_common {
16137  #ifdef CONFIG_NET_NS
16138         struct net              *skc_net;
16139  #endif
16140 +       xid_t                   skc_xid;
16141 +       struct vx_info          *skc_vx_info;
16142 +       nid_t                   skc_nid;
16143 +       struct nx_info          *skc_nx_info;
16144  };
16145  
16146  /**
16147 @@ -237,6 +241,10 @@ struct sock {
16148  #define sk_bind_node           __sk_common.skc_bind_node
16149  #define sk_prot                        __sk_common.skc_prot
16150  #define sk_net                 __sk_common.skc_net
16151 +#define sk_xid                 __sk_common.skc_xid
16152 +#define sk_vx_info             __sk_common.skc_vx_info
16153 +#define sk_nid                 __sk_common.skc_nid
16154 +#define sk_nx_info             __sk_common.skc_nx_info
16155         kmemcheck_bitfield_begin(flags);
16156         unsigned int            sk_shutdown  : 2,
16157                                 sk_no_check  : 2,
16158 diff -NurpP --minimal linux-2.6.34/init/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/init/Kconfig
16159 --- linux-2.6.34/init/Kconfig   2010-05-18 15:07:53.000000000 +0200
16160 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/init/Kconfig      2010-05-18 18:11:22.000000000 +0200
16161 @@ -464,6 +464,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
16162  menuconfig CGROUPS
16163         boolean "Control Group support"
16164         depends on EVENTFD
16165 +       default y
16166         help
16167           This option adds support for grouping sets of processes together, for
16168           use with process control subsystems such as Cpusets, CFS, memory
16169 @@ -491,6 +492,7 @@ config CGROUP_DEBUG
16170  config CGROUP_NS
16171         bool "Namespace cgroup subsystem"
16172         depends on CGROUPS
16173 +       default n
16174         help
16175           Provides a simple namespace cgroup subsystem to
16176           provide hierarchical naming of sets of namespaces,
16177 diff -NurpP --minimal linux-2.6.34/init/main.c linux-2.6.34-vs2.3.0.36.30.4.pre6/init/main.c
16178 --- linux-2.6.34/init/main.c    2010-05-18 15:07:53.000000000 +0200
16179 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/init/main.c       2010-05-18 18:11:22.000000000 +0200
16180 @@ -70,6 +70,7 @@
16181  #include <linux/shmem_fs.h>
16182  #include <linux/slab.h>
16183  #include <trace/boot.h>
16184 +#include <linux/vserver/percpu.h>
16185  
16186  #include <asm/io.h>
16187  #include <asm/bugs.h>
16188 diff -NurpP --minimal linux-2.6.34/ipc/mqueue.c linux-2.6.34-vs2.3.0.36.30.4.pre6/ipc/mqueue.c
16189 --- linux-2.6.34/ipc/mqueue.c   2010-05-18 15:07:53.000000000 +0200
16190 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/ipc/mqueue.c      2010-05-18 18:13:21.000000000 +0200
16191 @@ -33,6 +33,8 @@
16192  #include <linux/pid.h>
16193  #include <linux/ipc_namespace.h>
16194  #include <linux/slab.h>
16195 +#include <linux/vs_context.h>
16196 +#include <linux/vs_limit.h>
16197  
16198  #include <net/sock.h>
16199  #include "util.h"
16200 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
16201         struct sigevent notify;
16202         struct pid* notify_owner;
16203         struct user_struct *user;       /* user who created, for accounting */
16204 +       struct vx_info *vxi;
16205         struct sock *notify_sock;
16206         struct sk_buff *notify_cookie;
16207  
16208 @@ -125,6 +128,7 @@ static struct inode *mqueue_get_inode(st
16209                 if (S_ISREG(mode)) {
16210                         struct mqueue_inode_info *info;
16211                         struct task_struct *p = current;
16212 +                       struct vx_info *vxi = p->vx_info;
16213                         unsigned long mq_bytes, mq_msg_tblsz;
16214  
16215                         inode->i_fop = &mqueue_file_operations;
16216 @@ -138,6 +142,7 @@ static struct inode *mqueue_get_inode(st
16217                         info->notify_owner = NULL;
16218                         info->qsize = 0;
16219                         info->user = NULL;      /* set when all is ok */
16220 +                       info->vxi = NULL;
16221                         memset(&info->attr, 0, sizeof(info->attr));
16222                         info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
16223                         info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
16224 @@ -156,16 +161,19 @@ static struct inode *mqueue_get_inode(st
16225                         spin_lock(&mq_lock);
16226                         if (u->mq_bytes + mq_bytes < u->mq_bytes ||
16227                             u->mq_bytes + mq_bytes >
16228 -                           task_rlimit(p, RLIMIT_MSGQUEUE)) {
16229 +                           task_rlimit(p, RLIMIT_MSGQUEUE) ||
16230 +                           !vx_ipcmsg_avail(vxi, mq_bytes)) {
16231                                 spin_unlock(&mq_lock);
16232                                 /* mqueue_delete_inode() releases info->messages */
16233                                 goto out_inode;
16234                         }
16235                         u->mq_bytes += mq_bytes;
16236 +                       vx_ipcmsg_add(vxi, u, mq_bytes);
16237                         spin_unlock(&mq_lock);
16238  
16239                         /* all is ok */
16240                         info->user = get_uid(u);
16241 +                       info->vxi = get_vx_info(vxi);
16242                 } else if (S_ISDIR(mode)) {
16243                         inc_nlink(inode);
16244                         /* Some things misbehave if size == 0 on a directory */
16245 @@ -269,8 +277,11 @@ static void mqueue_delete_inode(struct i
16246             + info->attr.mq_msgsize);
16247         user = info->user;
16248         if (user) {
16249 +               struct vx_info *vxi = info->vxi;
16250 +
16251                 spin_lock(&mq_lock);
16252                 user->mq_bytes -= mq_bytes;
16253 +               vx_ipcmsg_sub(vxi, user, mq_bytes);
16254                 /*
16255                  * get_ns_from_inode() ensures that the
16256                  * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
16257 @@ -280,6 +291,7 @@ static void mqueue_delete_inode(struct i
16258                 if (ipc_ns)
16259                         ipc_ns->mq_queues_count--;
16260                 spin_unlock(&mq_lock);
16261 +               put_vx_info(vxi);
16262                 free_uid(user);
16263         }
16264         if (ipc_ns)
16265 diff -NurpP --minimal linux-2.6.34/ipc/msg.c linux-2.6.34-vs2.3.0.36.30.4.pre6/ipc/msg.c
16266 --- linux-2.6.34/ipc/msg.c      2010-05-18 15:07:53.000000000 +0200
16267 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/ipc/msg.c 2010-05-18 18:11:22.000000000 +0200
16268 @@ -37,6 +37,7 @@
16269  #include <linux/rwsem.h>
16270  #include <linux/nsproxy.h>
16271  #include <linux/ipc_namespace.h>
16272 +#include <linux/vs_base.h>
16273  
16274  #include <asm/current.h>
16275  #include <asm/uaccess.h>
16276 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
16277  
16278         msq->q_perm.mode = msgflg & S_IRWXUGO;
16279         msq->q_perm.key = key;
16280 +       msq->q_perm.xid = vx_current_xid();
16281  
16282         msq->q_perm.security = NULL;
16283         retval = security_msg_queue_alloc(msq);
16284 diff -NurpP --minimal linux-2.6.34/ipc/namespace.c linux-2.6.34-vs2.3.0.36.30.4.pre6/ipc/namespace.c
16285 --- linux-2.6.34/ipc/namespace.c        2009-09-10 15:26:27.000000000 +0200
16286 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/ipc/namespace.c   2010-05-18 18:11:22.000000000 +0200
16287 @@ -11,6 +11,8 @@
16288  #include <linux/slab.h>
16289  #include <linux/fs.h>
16290  #include <linux/mount.h>
16291 +#include <linux/vs_base.h>
16292 +#include <linux/vserver/global.h>
16293  
16294  #include "util.h"
16295  
16296 diff -NurpP --minimal linux-2.6.34/ipc/sem.c linux-2.6.34-vs2.3.0.36.30.4.pre6/ipc/sem.c
16297 --- linux-2.6.34/ipc/sem.c      2010-02-25 11:52:09.000000000 +0100
16298 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/ipc/sem.c 2010-05-18 18:11:22.000000000 +0200
16299 @@ -83,6 +83,8 @@
16300  #include <linux/rwsem.h>
16301  #include <linux/nsproxy.h>
16302  #include <linux/ipc_namespace.h>
16303 +#include <linux/vs_base.h>
16304 +#include <linux/vs_limit.h>
16305  
16306  #include <asm/uaccess.h>
16307  #include "util.h"
16308 @@ -257,6 +259,7 @@ static int newary(struct ipc_namespace *
16309  
16310         sma->sem_perm.mode = (semflg & S_IRWXUGO);
16311         sma->sem_perm.key = key;
16312 +       sma->sem_perm.xid = vx_current_xid();
16313  
16314         sma->sem_perm.security = NULL;
16315         retval = security_sem_alloc(sma);
16316 @@ -272,6 +275,9 @@ static int newary(struct ipc_namespace *
16317                 return id;
16318         }
16319         ns->used_sems += nsems;
16320 +       /* FIXME: obsoleted? */
16321 +       vx_semary_inc(sma);
16322 +       vx_nsems_add(sma, nsems);
16323  
16324         sma->sem_base = (struct sem *) &sma[1];
16325  
16326 @@ -595,6 +601,9 @@ static void freeary(struct ipc_namespace
16327         sem_unlock(sma);
16328  
16329         ns->used_sems -= sma->sem_nsems;
16330 +       /* FIXME: obsoleted? */
16331 +       vx_nsems_sub(sma, sma->sem_nsems);
16332 +       vx_semary_dec(sma);
16333         security_sem_free(sma);
16334         ipc_rcu_putref(sma);
16335  }
16336 diff -NurpP --minimal linux-2.6.34/ipc/shm.c linux-2.6.34-vs2.3.0.36.30.4.pre6/ipc/shm.c
16337 --- linux-2.6.34/ipc/shm.c      2010-05-18 15:07:53.000000000 +0200
16338 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/ipc/shm.c 2010-05-18 18:11:22.000000000 +0200
16339 @@ -39,6 +39,8 @@
16340  #include <linux/nsproxy.h>
16341  #include <linux/mount.h>
16342  #include <linux/ipc_namespace.h>
16343 +#include <linux/vs_context.h>
16344 +#include <linux/vs_limit.h>
16345  
16346  #include <asm/uaccess.h>
16347  
16348 @@ -169,7 +171,12 @@ static void shm_open(struct vm_area_stru
16349   */
16350  static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
16351  {
16352 -       ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16353 +       struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
16354 +       int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16355 +
16356 +       vx_ipcshm_sub(vxi, shp, numpages);
16357 +       ns->shm_tot -= numpages;
16358 +
16359         shm_rmid(ns, shp);
16360         shm_unlock(shp);
16361         if (!is_file_hugepages(shp->shm_file))
16362 @@ -179,6 +186,7 @@ static void shm_destroy(struct ipc_names
16363                                                 shp->mlock_user);
16364         fput (shp->shm_file);
16365         security_shm_free(shp);
16366 +       put_vx_info(vxi);
16367         ipc_rcu_putref(shp);
16368  }
16369  
16370 @@ -352,11 +360,15 @@ static int newseg(struct ipc_namespace *
16371         if (ns->shm_tot + numpages > ns->shm_ctlall)
16372                 return -ENOSPC;
16373  
16374 +       if (!vx_ipcshm_avail(current_vx_info(), numpages))
16375 +               return -ENOSPC;
16376 +
16377         shp = ipc_rcu_alloc(sizeof(*shp));
16378         if (!shp)
16379                 return -ENOMEM;
16380  
16381         shp->shm_perm.key = key;
16382 +       shp->shm_perm.xid = vx_current_xid();
16383         shp->shm_perm.mode = (shmflg & S_IRWXUGO);
16384         shp->mlock_user = NULL;
16385  
16386 @@ -410,6 +422,7 @@ static int newseg(struct ipc_namespace *
16387         ns->shm_tot += numpages;
16388         error = shp->shm_perm.id;
16389         shm_unlock(shp);
16390 +       vx_ipcshm_add(current_vx_info(), key, numpages);
16391         return error;
16392  
16393  no_id:
16394 diff -NurpP --minimal linux-2.6.34/kernel/capability.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/capability.c
16395 --- linux-2.6.34/kernel/capability.c    2010-05-18 15:07:53.000000000 +0200
16396 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/capability.c       2010-05-18 18:11:22.000000000 +0200
16397 @@ -14,6 +14,7 @@
16398  #include <linux/security.h>
16399  #include <linux/syscalls.h>
16400  #include <linux/pid_namespace.h>
16401 +#include <linux/vs_context.h>
16402  #include <asm/uaccess.h>
16403  #include "cred-internals.h"
16404  
16405 @@ -120,6 +121,7 @@ static int cap_validate_magic(cap_user_h
16406         return 0;
16407  }
16408  
16409 +
16410  /*
16411   * The only thing that can change the capabilities of the current
16412   * process is the current process. As such, we can't be in this code
16413 @@ -290,6 +292,8 @@ error:
16414         return ret;
16415  }
16416  
16417 +#include <linux/vserver/base.h>
16418 +
16419  /**
16420   * capable - Determine if the current task has a superior capability in effect
16421   * @cap: The capability to be tested for
16422 @@ -302,6 +306,9 @@ error:
16423   */
16424  int capable(int cap)
16425  {
16426 +       /* here for now so we don't require task locking */
16427 +       if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
16428 +               return 0;
16429         if (unlikely(!cap_valid(cap))) {
16430                 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
16431                 BUG();
16432 diff -NurpP --minimal linux-2.6.34/kernel/compat.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/compat.c
16433 --- linux-2.6.34/kernel/compat.c        2010-05-18 15:07:53.000000000 +0200
16434 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/compat.c   2010-05-18 18:11:22.000000000 +0200
16435 @@ -903,7 +903,7 @@ asmlinkage long compat_sys_time(compat_t
16436         compat_time_t i;
16437         struct timeval tv;
16438  
16439 -       do_gettimeofday(&tv);
16440 +       vx_gettimeofday(&tv);
16441         i = tv.tv_sec;
16442  
16443         if (tloc) {
16444 @@ -928,7 +928,7 @@ asmlinkage long compat_sys_stime(compat_
16445         if (err)
16446                 return err;
16447  
16448 -       do_settimeofday(&tv);
16449 +       vx_settimeofday(&tv);
16450         return 0;
16451  }
16452  
16453 diff -NurpP --minimal linux-2.6.34/kernel/exit.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/exit.c
16454 --- linux-2.6.34/kernel/exit.c  2010-05-18 15:07:53.000000000 +0200
16455 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/exit.c     2010-05-18 18:11:22.000000000 +0200
16456 @@ -48,6 +48,10 @@
16457  #include <linux/fs_struct.h>
16458  #include <linux/init_task.h>
16459  #include <linux/perf_event.h>
16460 +#include <linux/vs_limit.h>
16461 +#include <linux/vs_context.h>
16462 +#include <linux/vs_network.h>
16463 +#include <linux/vs_pid.h>
16464  #include <trace/events/sched.h>
16465  #include <linux/hw_breakpoint.h>
16466  
16467 @@ -495,9 +499,11 @@ static void close_files(struct files_str
16468                                         filp_close(file, files);
16469                                         cond_resched();
16470                                 }
16471 +                               vx_openfd_dec(i);
16472                         }
16473                         i++;
16474                         set >>= 1;
16475 +                       cond_resched();
16476                 }
16477         }
16478  }
16479 @@ -1029,11 +1035,16 @@ NORET_TYPE void do_exit(long code)
16480  
16481         validate_creds_for_do_exit(tsk);
16482  
16483 +       /* needs to stay after exit_notify() */
16484 +       exit_vx_info(tsk, code);
16485 +       exit_nx_info(tsk);
16486 +
16487         preempt_disable();
16488         exit_rcu();
16489         /* causes final put_task_struct in finish_task_switch(). */
16490         tsk->state = TASK_DEAD;
16491         schedule();
16492 +       printk("bad task: %p [%lx]\n", current, current->state);
16493         BUG();
16494         /* Avoid "noreturn function does return".  */
16495         for (;;)
16496 diff -NurpP --minimal linux-2.6.34/kernel/fork.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/fork.c
16497 --- linux-2.6.34/kernel/fork.c  2010-05-18 15:07:53.000000000 +0200
16498 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/fork.c     2010-05-21 23:19:57.000000000 +0200
16499 @@ -65,6 +65,10 @@
16500  #include <linux/perf_event.h>
16501  #include <linux/posix-timers.h>
16502  #include <linux/user-return-notifier.h>
16503 +#include <linux/vs_context.h>
16504 +#include <linux/vs_network.h>
16505 +#include <linux/vs_limit.h>
16506 +#include <linux/vs_memory.h>
16507  
16508  #include <asm/pgtable.h>
16509  #include <asm/pgalloc.h>
16510 @@ -160,6 +164,8 @@ void free_task(struct task_struct *tsk)
16511         account_kernel_stack(tsk->stack, -1);
16512         free_thread_info(tsk->stack);
16513         rt_mutex_debug_task_free(tsk);
16514 +       clr_vx_info(&tsk->vx_info);
16515 +       clr_nx_info(&tsk->nx_info);
16516         ftrace_graph_exit_task(tsk);
16517         free_task_struct(tsk);
16518  }
16519 @@ -476,6 +482,7 @@ static struct mm_struct * mm_init(struct
16520         if (likely(!mm_alloc_pgd(mm))) {
16521                 mm->def_flags = 0;
16522                 mmu_notifier_mm_init(mm);
16523 +               set_vx_info(&mm->mm_vx_info, p->vx_info);
16524                 return mm;
16525         }
16526  
16527 @@ -509,6 +516,7 @@ void __mmdrop(struct mm_struct *mm)
16528         mm_free_pgd(mm);
16529         destroy_context(mm);
16530         mmu_notifier_mm_destroy(mm);
16531 +       clr_vx_info(&mm->mm_vx_info);
16532         free_mm(mm);
16533  }
16534  EXPORT_SYMBOL_GPL(__mmdrop);
16535 @@ -644,6 +652,7 @@ struct mm_struct *dup_mm(struct task_str
16536                 goto fail_nomem;
16537  
16538         memcpy(mm, oldmm, sizeof(*mm));
16539 +       mm->mm_vx_info = NULL;
16540  
16541         /* Initializing for Swap token stuff */
16542         mm->token_priority = 0;
16543 @@ -682,6 +691,7 @@ fail_nocontext:
16544          * If init_new_context() failed, we cannot use mmput() to free the mm
16545          * because it calls destroy_context()
16546          */
16547 +       clr_vx_info(&mm->mm_vx_info);
16548         mm_free_pgd(mm);
16549         free_mm(mm);
16550         return NULL;
16551 @@ -962,6 +972,8 @@ static struct task_struct *copy_process(
16552         int retval;
16553         struct task_struct *p;
16554         int cgroup_callbacks_done = 0;
16555 +       struct vx_info *vxi;
16556 +       struct nx_info *nxi;
16557  
16558         if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
16559                 return ERR_PTR(-EINVAL);
16560 @@ -1008,7 +1020,12 @@ static struct task_struct *copy_process(
16561         DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
16562         DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
16563  #endif
16564 +       init_vx_info(&p->vx_info, current_vx_info());
16565 +       init_nx_info(&p->nx_info, current_nx_info());
16566 +
16567         retval = -EAGAIN;
16568 +       if (!vx_nproc_avail(1))
16569 +               goto bad_fork_free;
16570         if (atomic_read(&p->real_cred->user->processes) >=
16571                         task_rlimit(p, RLIMIT_NPROC)) {
16572                 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
16573 @@ -1275,6 +1292,18 @@ static struct task_struct *copy_process(
16574  
16575         total_forks++;
16576         spin_unlock(&current->sighand->siglock);
16577 +
16578 +       /* p is copy of current */
16579 +       vxi = p->vx_info;
16580 +       if (vxi) {
16581 +               claim_vx_info(vxi, p);
16582 +               atomic_inc(&vxi->cvirt.nr_threads);
16583 +               atomic_inc(&vxi->cvirt.total_forks);
16584 +               vx_nproc_inc(p);
16585 +       }
16586 +       nxi = p->nx_info;
16587 +       if (nxi)
16588 +               claim_nx_info(nxi, p);
16589         write_unlock_irq(&tasklist_lock);
16590         proc_fork_connector(p);
16591         cgroup_post_fork(p);
16592 diff -NurpP --minimal linux-2.6.34/kernel/kthread.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/kthread.c
16593 --- linux-2.6.34/kernel/kthread.c       2010-05-18 15:07:53.000000000 +0200
16594 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/kthread.c  2010-05-18 18:11:22.000000000 +0200
16595 @@ -14,6 +14,7 @@
16596  #include <linux/file.h>
16597  #include <linux/module.h>
16598  #include <linux/mutex.h>
16599 +#include <linux/vs_pid.h>
16600  #include <trace/events/sched.h>
16601  
16602  static DEFINE_SPINLOCK(kthread_create_lock);
16603 diff -NurpP --minimal linux-2.6.34/kernel/Makefile linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/Makefile
16604 --- linux-2.6.34/kernel/Makefile        2010-05-18 15:07:53.000000000 +0200
16605 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/Makefile   2010-05-18 18:11:22.000000000 +0200
16606 @@ -25,6 +25,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
16607  CFLAGS_REMOVE_perf_event.o = -pg
16608  endif
16609  
16610 +obj-y += vserver/
16611  obj-$(CONFIG_FREEZER) += freezer.o
16612  obj-$(CONFIG_PROFILING) += profile.o
16613  obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
16614 diff -NurpP --minimal linux-2.6.34/kernel/nsproxy.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/nsproxy.c
16615 --- linux-2.6.34/kernel/nsproxy.c       2010-05-18 15:07:53.000000000 +0200
16616 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/nsproxy.c  2010-05-18 18:11:22.000000000 +0200
16617 @@ -20,6 +20,8 @@
16618  #include <linux/mnt_namespace.h>
16619  #include <linux/utsname.h>
16620  #include <linux/pid_namespace.h>
16621 +#include <linux/vserver/global.h>
16622 +#include <linux/vserver/debug.h>
16623  #include <net/net_namespace.h>
16624  #include <linux/ipc_namespace.h>
16625  
16626 @@ -43,8 +45,11 @@ static inline struct nsproxy *create_nsp
16627         struct nsproxy *nsproxy;
16628  
16629         nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
16630 -       if (nsproxy)
16631 +       if (nsproxy) {
16632                 atomic_set(&nsproxy->count, 1);
16633 +               atomic_inc(&vs_global_nsproxy);
16634 +       }
16635 +       vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
16636         return nsproxy;
16637  }
16638  
16639 @@ -53,41 +58,52 @@ static inline struct nsproxy *create_nsp
16640   * Return the newly created nsproxy.  Do not attach this to the task,
16641   * leave it to the caller to do proper locking and attach it to task.
16642   */
16643 -static struct nsproxy *create_new_namespaces(unsigned long flags,
16644 -                       struct task_struct *tsk, struct fs_struct *new_fs)
16645 +static struct nsproxy *unshare_namespaces(unsigned long flags,
16646 +                       struct nsproxy *orig, struct fs_struct *new_fs)
16647  {
16648         struct nsproxy *new_nsp;
16649         int err;
16650  
16651 +       vxdprintk(VXD_CBIT(space, 4),
16652 +               "unshare_namespaces(0x%08lx,%p,%p)",
16653 +               flags, orig, new_fs);
16654 +
16655         new_nsp = create_nsproxy();
16656         if (!new_nsp)
16657                 return ERR_PTR(-ENOMEM);
16658  
16659 -       new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
16660 +       new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
16661         if (IS_ERR(new_nsp->mnt_ns)) {
16662                 err = PTR_ERR(new_nsp->mnt_ns);
16663                 goto out_ns;
16664         }
16665  
16666 -       new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
16667 +       new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
16668         if (IS_ERR(new_nsp->uts_ns)) {
16669                 err = PTR_ERR(new_nsp->uts_ns);
16670                 goto out_uts;
16671         }
16672  
16673 -       new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
16674 +       new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
16675         if (IS_ERR(new_nsp->ipc_ns)) {
16676                 err = PTR_ERR(new_nsp->ipc_ns);
16677                 goto out_ipc;
16678         }
16679  
16680 -       new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
16681 +       new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
16682         if (IS_ERR(new_nsp->pid_ns)) {
16683                 err = PTR_ERR(new_nsp->pid_ns);
16684                 goto out_pid;
16685         }
16686  
16687 -       new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
16688 +       /* disabled now?
16689 +       new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
16690 +       if (IS_ERR(new_nsp->user_ns)) {
16691 +               err = PTR_ERR(new_nsp->user_ns);
16692 +               goto out_user;
16693 +       } */
16694 +
16695 +       new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
16696         if (IS_ERR(new_nsp->net_ns)) {
16697                 err = PTR_ERR(new_nsp->net_ns);
16698                 goto out_net;
16699 @@ -112,6 +128,38 @@ out_ns:
16700         return ERR_PTR(err);
16701  }
16702  
16703 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
16704 +                       struct fs_struct *new_fs)
16705 +{
16706 +       return unshare_namespaces(flags, tsk->nsproxy, new_fs);
16707 +}
16708 +
16709 +/*
16710 + * copies the nsproxy, setting refcount to 1, and grabbing a
16711 + * reference to all contained namespaces.
16712 + */
16713 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
16714 +{
16715 +       struct nsproxy *ns = create_nsproxy();
16716 +
16717 +       if (ns) {
16718 +               memcpy(ns, orig, sizeof(struct nsproxy));
16719 +               atomic_set(&ns->count, 1);
16720 +
16721 +               if (ns->mnt_ns)
16722 +                       get_mnt_ns(ns->mnt_ns);
16723 +               if (ns->uts_ns)
16724 +                       get_uts_ns(ns->uts_ns);
16725 +               if (ns->ipc_ns)
16726 +                       get_ipc_ns(ns->ipc_ns);
16727 +               if (ns->pid_ns)
16728 +                       get_pid_ns(ns->pid_ns);
16729 +               if (ns->net_ns)
16730 +                       get_net(ns->net_ns);
16731 +       }
16732 +       return ns;
16733 +}
16734 +
16735  /*
16736   * called from clone.  This now handles copy for nsproxy and all
16737   * namespaces therein.
16738 @@ -119,9 +167,12 @@ out_ns:
16739  int copy_namespaces(unsigned long flags, struct task_struct *tsk)
16740  {
16741         struct nsproxy *old_ns = tsk->nsproxy;
16742 -       struct nsproxy *new_ns;
16743 +       struct nsproxy *new_ns = NULL;
16744         int err = 0;
16745  
16746 +       vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
16747 +               flags, tsk, old_ns);
16748 +
16749         if (!old_ns)
16750                 return 0;
16751  
16752 @@ -131,7 +182,7 @@ int copy_namespaces(unsigned long flags,
16753                                 CLONE_NEWPID | CLONE_NEWNET)))
16754                 return 0;
16755  
16756 -       if (!capable(CAP_SYS_ADMIN)) {
16757 +       if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
16758                 err = -EPERM;
16759                 goto out;
16760         }
16761 @@ -158,6 +209,9 @@ int copy_namespaces(unsigned long flags,
16762  
16763  out:
16764         put_nsproxy(old_ns);
16765 +       vxdprintk(VXD_CBIT(space, 3),
16766 +               "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
16767 +               flags, tsk, old_ns, err, new_ns);
16768         return err;
16769  }
16770  
16771 @@ -171,7 +225,9 @@ void free_nsproxy(struct nsproxy *ns)
16772                 put_ipc_ns(ns->ipc_ns);
16773         if (ns->pid_ns)
16774                 put_pid_ns(ns->pid_ns);
16775 -       put_net(ns->net_ns);
16776 +       if (ns->net_ns)
16777 +               put_net(ns->net_ns);
16778 +       atomic_dec(&vs_global_nsproxy);
16779         kmem_cache_free(nsproxy_cachep, ns);
16780  }
16781  
16782 @@ -184,11 +240,15 @@ int unshare_nsproxy_namespaces(unsigned 
16783  {
16784         int err = 0;
16785  
16786 +       vxdprintk(VXD_CBIT(space, 4),
16787 +               "unshare_nsproxy_namespaces(0x%08lx,[%p])",
16788 +               unshare_flags, current->nsproxy);
16789 +
16790         if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
16791                                CLONE_NEWNET)))
16792                 return 0;
16793  
16794 -       if (!capable(CAP_SYS_ADMIN))
16795 +       if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
16796                 return -EPERM;
16797  
16798         *new_nsp = create_new_namespaces(unshare_flags, current,
16799 diff -NurpP --minimal linux-2.6.34/kernel/pid.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/pid.c
16800 --- linux-2.6.34/kernel/pid.c   2010-05-18 15:07:53.000000000 +0200
16801 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/pid.c      2010-05-18 18:11:22.000000000 +0200
16802 @@ -36,6 +36,7 @@
16803  #include <linux/pid_namespace.h>
16804  #include <linux/init_task.h>
16805  #include <linux/syscalls.h>
16806 +#include <linux/vs_pid.h>
16807  
16808  #define pid_hashfn(nr, ns)     \
16809         hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
16810 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
16811  
16812  struct pid *find_vpid(int nr)
16813  {
16814 -       return find_pid_ns(nr, current->nsproxy->pid_ns);
16815 +       return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
16816  }
16817  EXPORT_SYMBOL_GPL(find_vpid);
16818  
16819 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
16820  struct task_struct *pid_task(struct pid *pid, enum pid_type type)
16821  {
16822         struct task_struct *result = NULL;
16823 +
16824 +       if (type == PIDTYPE_REALPID)
16825 +               type = PIDTYPE_PID;
16826         if (pid) {
16827                 struct hlist_node *first;
16828                 first = rcu_dereference_check(pid->tasks[type].first,
16829 @@ -382,7 +386,7 @@ EXPORT_SYMBOL(pid_task);
16830   */
16831  struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
16832  {
16833 -       return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
16834 +       return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
16835  }
16836  
16837  struct task_struct *find_task_by_vpid(pid_t vnr)
16838 @@ -424,7 +428,7 @@ struct pid *find_get_pid(pid_t nr)
16839  }
16840  EXPORT_SYMBOL_GPL(find_get_pid);
16841  
16842 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16843 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
16844  {
16845         struct upid *upid;
16846         pid_t nr = 0;
16847 @@ -437,6 +441,11 @@ pid_t pid_nr_ns(struct pid *pid, struct 
16848         return nr;
16849  }
16850  
16851 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16852 +{
16853 +       return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
16854 +}
16855 +
16856  pid_t pid_vnr(struct pid *pid)
16857  {
16858         return pid_nr_ns(pid, current->nsproxy->pid_ns);
16859 diff -NurpP --minimal linux-2.6.34/kernel/pid_namespace.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/pid_namespace.c
16860 --- linux-2.6.34/kernel/pid_namespace.c 2010-05-18 15:07:53.000000000 +0200
16861 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/pid_namespace.c    2010-05-18 18:11:22.000000000 +0200
16862 @@ -14,6 +14,7 @@
16863  #include <linux/err.h>
16864  #include <linux/acct.h>
16865  #include <linux/slab.h>
16866 +#include <linux/vserver/global.h>
16867  
16868  #define BITS_PER_PAGE          (PAGE_SIZE*8)
16869  
16870 @@ -87,6 +88,7 @@ static struct pid_namespace *create_pid_
16871                 goto out_free_map;
16872  
16873         kref_init(&ns->kref);
16874 +       atomic_inc(&vs_global_pid_ns);
16875         ns->level = level;
16876         ns->parent = get_pid_ns(parent_pid_ns);
16877  
16878 @@ -112,6 +114,7 @@ static void destroy_pid_namespace(struct
16879  
16880         for (i = 0; i < PIDMAP_ENTRIES; i++)
16881                 kfree(ns->pidmap[i].page);
16882 +       atomic_dec(&vs_global_pid_ns);
16883         kmem_cache_free(pid_ns_cachep, ns);
16884  }
16885  
16886 diff -NurpP --minimal linux-2.6.34/kernel/posix-timers.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/posix-timers.c
16887 --- linux-2.6.34/kernel/posix-timers.c  2010-05-18 15:07:53.000000000 +0200
16888 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/posix-timers.c     2010-05-18 18:11:22.000000000 +0200
16889 @@ -46,6 +46,7 @@
16890  #include <linux/wait.h>
16891  #include <linux/workqueue.h>
16892  #include <linux/module.h>
16893 +#include <linux/vs_context.h>
16894  
16895  /*
16896   * Management arrays for POSIX timers.  Timers are kept in slab memory
16897 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
16898  {
16899         struct task_struct *task;
16900         int shared, ret = -1;
16901 +
16902         /*
16903          * FIXME: if ->sigq is queued we can race with
16904          * dequeue_signal()->do_schedule_next_timer().
16905 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
16906         rcu_read_lock();
16907         task = pid_task(timr->it_pid, PIDTYPE_PID);
16908         if (task) {
16909 +               struct vx_info_save vxis;
16910 +               struct vx_info *vxi;
16911 +
16912 +               vxi = get_vx_info(task->vx_info);
16913 +               enter_vx_info(vxi, &vxis);
16914                 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
16915                 ret = send_sigqueue(timr->sigq, task, shared);
16916 +               leave_vx_info(&vxis);
16917 +               put_vx_info(vxi);
16918         }
16919         rcu_read_unlock();
16920 +
16921         /* If we failed to send the signal the timer stops. */
16922         return ret > 0;
16923  }
16924 diff -NurpP --minimal linux-2.6.34/kernel/printk.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/printk.c
16925 --- linux-2.6.34/kernel/printk.c        2010-05-18 15:07:53.000000000 +0200
16926 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/printk.c   2010-05-18 18:11:22.000000000 +0200
16927 @@ -36,6 +36,7 @@
16928  #include <linux/ratelimit.h>
16929  #include <linux/kmsg_dump.h>
16930  #include <linux/syslog.h>
16931 +#include <linux/vs_cvirt.h>
16932  
16933  #include <asm/uaccess.h>
16934  
16935 @@ -263,18 +264,15 @@ int do_syslog(int type, char __user *buf
16936         unsigned i, j, limit, count;
16937         int do_clear = 0;
16938         char c;
16939 -       int error = 0;
16940 +       int error;
16941  
16942         error = security_syslog(type, from_file);
16943         if (error)
16944                 return error;
16945  
16946 -       switch (type) {
16947 -       case SYSLOG_ACTION_CLOSE:       /* Close log */
16948 -               break;
16949 -       case SYSLOG_ACTION_OPEN:        /* Open log */
16950 -               break;
16951 -       case SYSLOG_ACTION_READ:        /* Read from log */
16952 +       if ((type == SYSLOG_ACTION_READ) ||
16953 +           (type == SYSLOG_ACTION_READ_ALL) ||
16954 +           (type == SYSLOG_ACTION_READ_CLEAR)) {
16955                 error = -EINVAL;
16956                 if (!buf || len < 0)
16957                         goto out;
16958 @@ -285,6 +283,16 @@ int do_syslog(int type, char __user *buf
16959                         error = -EFAULT;
16960                         goto out;
16961                 }
16962 +       }
16963 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
16964 +               return vx_do_syslog(type, buf, len);
16965 +
16966 +       switch (type) {
16967 +       case SYSLOG_ACTION_CLOSE:       /* Close log */
16968 +               break;
16969 +       case SYSLOG_ACTION_OPEN:        /* Open log */
16970 +               break;
16971 +       case SYSLOG_ACTION_READ:        /* Read from log */
16972                 error = wait_event_interruptible(log_wait,
16973                                                         (log_start - log_end));
16974                 if (error)
16975 @@ -311,16 +319,6 @@ int do_syslog(int type, char __user *buf
16976                 /* FALL THRU */
16977         /* Read last kernel messages */
16978         case SYSLOG_ACTION_READ_ALL:
16979 -               error = -EINVAL;
16980 -               if (!buf || len < 0)
16981 -                       goto out;
16982 -               error = 0;
16983 -               if (!len)
16984 -                       goto out;
16985 -               if (!access_ok(VERIFY_WRITE, buf, len)) {
16986 -                       error = -EFAULT;
16987 -                       goto out;
16988 -               }
16989                 count = len;
16990                 if (count > log_buf_len)
16991                         count = log_buf_len;
16992 diff -NurpP --minimal linux-2.6.34/kernel/ptrace.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/ptrace.c
16993 --- linux-2.6.34/kernel/ptrace.c        2010-05-18 15:07:53.000000000 +0200
16994 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/ptrace.c   2010-05-18 18:11:22.000000000 +0200
16995 @@ -23,6 +23,7 @@
16996  #include <linux/syscalls.h>
16997  #include <linux/uaccess.h>
16998  #include <linux/regset.h>
16999 +#include <linux/vs_context.h>
17000  
17001  
17002  /*
17003 @@ -152,6 +153,11 @@ int __ptrace_may_access(struct task_stru
17004                 dumpable = get_dumpable(task->mm);
17005         if (!dumpable && !capable(CAP_SYS_PTRACE))
17006                 return -EPERM;
17007 +       if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
17008 +               return -EPERM;
17009 +       if (!vx_check(task->xid, VS_IDENT) &&
17010 +               !task_vx_flags(task, VXF_STATE_ADMIN, 0))
17011 +               return -EACCES;
17012  
17013         return security_ptrace_access_check(task, mode);
17014  }
17015 @@ -683,6 +689,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
17016                 goto out;
17017         }
17018  
17019 +       ret = -EPERM;
17020 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
17021 +               goto out_put_task_struct;
17022 +
17023         if (request == PTRACE_ATTACH) {
17024                 ret = ptrace_attach(child);
17025                 /*
17026 diff -NurpP --minimal linux-2.6.34/kernel/sched.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/sched.c
17027 --- linux-2.6.34/kernel/sched.c 2010-05-18 15:07:53.000000000 +0200
17028 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/sched.c    2010-05-18 18:11:22.000000000 +0200
17029 @@ -72,6 +72,8 @@
17030  #include <linux/ctype.h>
17031  #include <linux/ftrace.h>
17032  #include <linux/slab.h>
17033 +#include <linux/vs_sched.h>
17034 +#include <linux/vs_cvirt.h>
17035  
17036  #include <asm/tlb.h>
17037  #include <asm/irq_regs.h>
17038 @@ -3035,9 +3037,17 @@ EXPORT_SYMBOL(avenrun);
17039   */
17040  void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
17041  {
17042 -       loads[0] = (avenrun[0] + offset) << shift;
17043 -       loads[1] = (avenrun[1] + offset) << shift;
17044 -       loads[2] = (avenrun[2] + offset) << shift;
17045 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
17046 +               struct vx_info *vxi = current_vx_info();
17047 +
17048 +               loads[0] = (vxi->cvirt.load[0] + offset) << shift;
17049 +               loads[1] = (vxi->cvirt.load[1] + offset) << shift;
17050 +               loads[2] = (vxi->cvirt.load[2] + offset) << shift;
17051 +       } else {
17052 +               loads[0] = (avenrun[0] + offset) << shift;
17053 +               loads[1] = (avenrun[1] + offset) << shift;
17054 +               loads[2] = (avenrun[2] + offset) << shift;
17055 +       }
17056  }
17057  
17058  static unsigned long
17059 @@ -3263,16 +3273,19 @@ void account_user_time(struct task_struc
17060                        cputime_t cputime_scaled)
17061  {
17062         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17063 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17064         cputime64_t tmp;
17065 +       int nice = (TASK_NICE(p) > 0);
17066  
17067         /* Add user time to process. */
17068         p->utime = cputime_add(p->utime, cputime);
17069         p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
17070 +       vx_account_user(vxi, cputime, nice);
17071         account_group_user_time(p, cputime);
17072  
17073         /* Add user time to cpustat. */
17074         tmp = cputime_to_cputime64(cputime);
17075 -       if (TASK_NICE(p) > 0)
17076 +       if (nice)
17077                 cpustat->nice = cputime64_add(cpustat->nice, tmp);
17078         else
17079                 cpustat->user = cputime64_add(cpustat->user, tmp);
17080 @@ -3323,6 +3336,7 @@ void account_system_time(struct task_str
17081                          cputime_t cputime, cputime_t cputime_scaled)
17082  {
17083         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17084 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17085         cputime64_t tmp;
17086  
17087         if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
17088 @@ -3333,6 +3347,7 @@ void account_system_time(struct task_str
17089         /* Add system time to process. */
17090         p->stime = cputime_add(p->stime, cputime);
17091         p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
17092 +       vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
17093         account_group_system_time(p, cputime);
17094  
17095         /* Add system time to cpustat. */
17096 @@ -4398,7 +4413,7 @@ SYSCALL_DEFINE1(nice, int, increment)
17097                 nice = 19;
17098  
17099         if (increment < 0 && !can_nice(current, nice))
17100 -               return -EPERM;
17101 +               return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
17102  
17103         retval = security_task_setnice(current, nice);
17104         if (retval)
17105 diff -NurpP --minimal linux-2.6.34/kernel/sched_fair.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/sched_fair.c
17106 --- linux-2.6.34/kernel/sched_fair.c    2010-05-18 15:07:53.000000000 +0200
17107 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/sched_fair.c       2010-05-18 18:11:22.000000000 +0200
17108 @@ -794,6 +794,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
17109         check_spread(cfs_rq, se);
17110         if (se != cfs_rq->curr)
17111                 __enqueue_entity(cfs_rq, se);
17112 +
17113 +       if (entity_is_task(se))
17114 +               vx_activate_task(task_of(se));
17115  }
17116  
17117  static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
17118 @@ -837,6 +840,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
17119  
17120         if (se != cfs_rq->curr)
17121                 __dequeue_entity(cfs_rq, se);
17122 +       if (entity_is_task(se))
17123 +               vx_deactivate_task(task_of(se));
17124         account_entity_dequeue(cfs_rq, se);
17125         update_min_vruntime(cfs_rq);
17126  
17127 diff -NurpP --minimal linux-2.6.34/kernel/signal.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/signal.c
17128 --- linux-2.6.34/kernel/signal.c        2010-05-18 15:07:53.000000000 +0200
17129 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/signal.c   2010-05-18 18:11:22.000000000 +0200
17130 @@ -28,6 +28,8 @@
17131  #include <linux/freezer.h>
17132  #include <linux/pid_namespace.h>
17133  #include <linux/nsproxy.h>
17134 +#include <linux/vs_context.h>
17135 +#include <linux/vs_pid.h>
17136  #define CREATE_TRACE_POINTS
17137  #include <trace/events/signal.h>
17138  
17139 @@ -646,9 +648,18 @@ static int check_kill_permission(int sig
17140         struct pid *sid;
17141         int error;
17142  
17143 +       vxdprintk(VXD_CBIT(misc, 7),
17144 +               "check_kill_permission(%d,%p,%p[#%u,%u])",
17145 +               sig, info, t, vx_task_xid(t), t->pid);
17146 +
17147         if (!valid_signal(sig))
17148                 return -EINVAL;
17149  
17150 +/*     FIXME: needed? if so, why?
17151 +       if ((info != SEND_SIG_NOINFO) &&
17152 +               (is_si_special(info) || !si_fromuser(info)))
17153 +               goto skip;      */
17154 +
17155         if (!si_fromuser(info))
17156                 return 0;
17157  
17158 @@ -676,6 +687,20 @@ static int check_kill_permission(int sig
17159                 }
17160         }
17161  
17162 +       error = -EPERM;
17163 +       if (t->pid == 1 && current->xid)
17164 +               return error;
17165 +
17166 +       error = -ESRCH;
17167 +       /* FIXME: we shouldn't return ESRCH ever, to avoid
17168 +                 loops, maybe ENOENT or EACCES? */
17169 +       if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17170 +               vxdprintk(current->xid || VXD_CBIT(misc, 7),
17171 +                       "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17172 +                       sig, info, t, vx_task_xid(t), t->pid, current->xid);
17173 +               return error;
17174 +       }
17175 +/* skip: */
17176         return security_task_kill(t, info, sig, 0);
17177  }
17178  
17179 @@ -1164,7 +1189,7 @@ int kill_pid_info(int sig, struct siginf
17180         rcu_read_lock();
17181  retry:
17182         p = pid_task(pid, PIDTYPE_PID);
17183 -       if (p) {
17184 +       if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17185                 error = group_send_sig_info(sig, info, p);
17186                 if (unlikely(error == -ESRCH))
17187                         /*
17188 @@ -1204,7 +1229,7 @@ int kill_pid_info_as_uid(int sig, struct
17189  
17190         rcu_read_lock();
17191         p = pid_task(pid, PIDTYPE_PID);
17192 -       if (!p) {
17193 +       if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17194                 ret = -ESRCH;
17195                 goto out_unlock;
17196         }
17197 @@ -1259,8 +1284,10 @@ static int kill_something_info(int sig, 
17198                 struct task_struct * p;
17199  
17200                 for_each_process(p) {
17201 -                       if (task_pid_vnr(p) > 1 &&
17202 -                                       !same_thread_group(p, current)) {
17203 +                       if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17204 +                               task_pid_vnr(p) > 1 &&
17205 +                               !same_thread_group(p, current) &&
17206 +                               !vx_current_initpid(p->pid)) {
17207                                 int err = group_send_sig_info(sig, info, p);
17208                                 ++count;
17209                                 if (err != -EPERM)
17210 @@ -1927,6 +1954,11 @@ relock:
17211                                 !sig_kernel_only(signr))
17212                         continue;
17213  
17214 +               /* virtual init is protected against user signals */
17215 +               if ((info->si_code == SI_USER) &&
17216 +                       vx_current_initpid(current->pid))
17217 +                       continue;
17218 +
17219                 if (sig_kernel_stop(signr)) {
17220                         /*
17221                          * The default action is to stop all threads in
17222 diff -NurpP --minimal linux-2.6.34/kernel/softirq.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/softirq.c
17223 --- linux-2.6.34/kernel/softirq.c       2010-02-25 11:52:09.000000000 +0100
17224 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/softirq.c  2010-05-18 18:11:22.000000000 +0200
17225 @@ -24,6 +24,7 @@
17226  #include <linux/ftrace.h>
17227  #include <linux/smp.h>
17228  #include <linux/tick.h>
17229 +#include <linux/vs_context.h>
17230  
17231  #define CREATE_TRACE_POINTS
17232  #include <trace/events/irq.h>
17233 diff -NurpP --minimal linux-2.6.34/kernel/sys.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/sys.c
17234 --- linux-2.6.34/kernel/sys.c   2010-05-18 15:07:53.000000000 +0200
17235 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/sys.c      2010-05-18 18:11:22.000000000 +0200
17236 @@ -42,6 +42,7 @@
17237  #include <linux/syscalls.h>
17238  #include <linux/kprobes.h>
17239  #include <linux/user_namespace.h>
17240 +#include <linux/vs_pid.h>
17241  
17242  #include <asm/uaccess.h>
17243  #include <asm/io.h>
17244 @@ -131,7 +132,10 @@ static int set_one_prio(struct task_stru
17245                 goto out;
17246         }
17247         if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17248 -               error = -EACCES;
17249 +               if (vx_flags(VXF_IGNEG_NICE, 0))
17250 +                       error = 0;
17251 +               else
17252 +                       error = -EACCES;
17253                 goto out;
17254         }
17255         no_nice = security_task_setnice(p, niceval);
17256 @@ -181,6 +185,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17257                         else
17258                                 pgrp = task_pgrp(current);
17259                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17260 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17261 +                                       continue;
17262                                 error = set_one_prio(p, niceval, error);
17263                         } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17264                         break;
17265 @@ -244,6 +250,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17266                         else
17267                                 pgrp = task_pgrp(current);
17268                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17269 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17270 +                                       continue;
17271                                 niceval = 20 - task_nice(p);
17272                                 if (niceval > retval)
17273                                         retval = niceval;
17274 @@ -357,6 +365,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
17275  
17276  static DEFINE_MUTEX(reboot_mutex);
17277  
17278 +long vs_reboot(unsigned int, void __user *);
17279 +
17280  /*
17281   * Reboot system call: for obvious reasons only root may call it,
17282   * and even root needs to set up some magic numbers in the registers
17283 @@ -389,6 +399,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17284         if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17285                 cmd = LINUX_REBOOT_CMD_HALT;
17286  
17287 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
17288 +               return vs_reboot(cmd, arg);
17289 +
17290         mutex_lock(&reboot_mutex);
17291         switch (cmd) {
17292         case LINUX_REBOOT_CMD_RESTART:
17293 @@ -1198,7 +1211,7 @@ SYSCALL_DEFINE2(sethostname, char __user
17294         int errno;
17295         char tmp[__NEW_UTS_LEN];
17296  
17297 -       if (!capable(CAP_SYS_ADMIN))
17298 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17299                 return -EPERM;
17300         if (len < 0 || len > __NEW_UTS_LEN)
17301                 return -EINVAL;
17302 @@ -1247,7 +1260,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
17303         int errno;
17304         char tmp[__NEW_UTS_LEN];
17305  
17306 -       if (!capable(CAP_SYS_ADMIN))
17307 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17308                 return -EPERM;
17309         if (len < 0 || len > __NEW_UTS_LEN)
17310                 return -EINVAL;
17311 @@ -1316,7 +1329,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
17312                 return -EINVAL;
17313         old_rlim = current->signal->rlim + resource;
17314         if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17315 -           !capable(CAP_SYS_RESOURCE))
17316 +           !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17317                 return -EPERM;
17318         if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
17319                 return -EPERM;
17320 diff -NurpP --minimal linux-2.6.34/kernel/sysctl_binary.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/sysctl_binary.c
17321 --- linux-2.6.34/kernel/sysctl_binary.c 2010-05-18 15:07:53.000000000 +0200
17322 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/sysctl_binary.c    2010-05-18 18:11:22.000000000 +0200
17323 @@ -72,6 +72,7 @@ static const struct bin_table bin_kern_t
17324  
17325         { CTL_INT,      KERN_PANIC,                     "panic" },
17326         { CTL_INT,      KERN_REALROOTDEV,               "real-root-dev" },
17327 +       { CTL_STR,      KERN_VSHELPER,                  "vshelper" },
17328  
17329         { CTL_STR,      KERN_SPARC_REBOOT,              "reboot-cmd" },
17330         { CTL_INT,      KERN_CTLALTDEL,                 "ctrl-alt-del" },
17331 diff -NurpP --minimal linux-2.6.34/kernel/sysctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/sysctl.c
17332 --- linux-2.6.34/kernel/sysctl.c        2010-05-18 15:07:53.000000000 +0200
17333 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/sysctl.c   2010-05-18 18:11:22.000000000 +0200
17334 @@ -70,6 +70,7 @@
17335  #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
17336  #include <linux/lockdep.h>
17337  #endif
17338 +extern char vshelper_path[];
17339  #ifdef CONFIG_CHR_DEV_SG
17340  #include <scsi/sg.h>
17341  #endif
17342 @@ -543,6 +544,13 @@ static struct ctl_table kern_table[] = {
17343                 .proc_handler   = proc_dostring,
17344         },
17345  #endif
17346 +       {
17347 +               .procname       = "vshelper",
17348 +               .data           = &vshelper_path,
17349 +               .maxlen         = 256,
17350 +               .mode           = 0644,
17351 +               .proc_handler   = &proc_dostring,
17352 +       },
17353  #ifdef CONFIG_CHR_DEV_SG
17354         {
17355                 .procname       = "sg-big-buff",
17356 diff -NurpP --minimal linux-2.6.34/kernel/time.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/time.c
17357 --- linux-2.6.34/kernel/time.c  2010-05-18 15:07:53.000000000 +0200
17358 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/time.c     2010-05-18 18:11:22.000000000 +0200
17359 @@ -62,6 +62,7 @@ EXPORT_SYMBOL(sys_tz);
17360  SYSCALL_DEFINE1(time, time_t __user *, tloc)
17361  {
17362         time_t i = get_seconds();
17363 +/*     FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17364  
17365         if (tloc) {
17366                 if (put_user(i,tloc))
17367 @@ -92,7 +93,7 @@ SYSCALL_DEFINE1(stime, time_t __user *, 
17368         if (err)
17369                 return err;
17370  
17371 -       do_settimeofday(&tv);
17372 +       vx_settimeofday(&tv);
17373         return 0;
17374  }
17375  
17376 @@ -103,7 +104,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
17377  {
17378         if (likely(tv != NULL)) {
17379                 struct timeval ktv;
17380 -               do_gettimeofday(&ktv);
17381 +               vx_gettimeofday(&ktv);
17382                 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17383                         return -EFAULT;
17384         }
17385 @@ -178,7 +179,7 @@ int do_sys_settimeofday(struct timespec 
17386                 /* SMP safe, again the code in arch/foo/time.c should
17387                  * globally block out interrupts when it runs.
17388                  */
17389 -               return do_settimeofday(tv);
17390 +               return vx_settimeofday(tv);
17391         }
17392         return 0;
17393  }
17394 @@ -310,7 +311,7 @@ void getnstimeofday(struct timespec *tv)
17395  {
17396         struct timeval x;
17397  
17398 -       do_gettimeofday(&x);
17399 +       vx_gettimeofday(&x);
17400         tv->tv_sec = x.tv_sec;
17401         tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17402  }
17403 diff -NurpP --minimal linux-2.6.34/kernel/timer.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/timer.c
17404 --- linux-2.6.34/kernel/timer.c 2010-05-18 15:07:53.000000000 +0200
17405 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/timer.c    2010-05-18 18:11:22.000000000 +0200
17406 @@ -40,6 +40,10 @@
17407  #include <linux/perf_event.h>
17408  #include <linux/sched.h>
17409  #include <linux/slab.h>
17410 +#include <linux/vs_base.h>
17411 +#include <linux/vs_cvirt.h>
17412 +#include <linux/vs_pid.h>
17413 +#include <linux/vserver/sched.h>
17414  
17415  #include <asm/uaccess.h>
17416  #include <asm/unistd.h>
17417 @@ -1254,12 +1258,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17418  
17419  #endif
17420  
17421 -#ifndef __alpha__
17422 -
17423 -/*
17424 - * The Alpha uses getxpid, getxuid, and getxgid instead.  Maybe this
17425 - * should be moved into arch/i386 instead?
17426 - */
17427  
17428  /**
17429   * sys_getpid - return the thread group id of the current process
17430 @@ -1288,10 +1286,23 @@ SYSCALL_DEFINE0(getppid)
17431         rcu_read_lock();
17432         pid = task_tgid_vnr(current->real_parent);
17433         rcu_read_unlock();
17434 +       return vx_map_pid(pid);
17435 +}
17436  
17437 -       return pid;
17438 +#ifdef __alpha__
17439 +
17440 +/*
17441 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17442 + */
17443 +
17444 +asmlinkage long do_getxpid(long *ppid)
17445 +{
17446 +       *ppid = sys_getppid();
17447 +       return sys_getpid();
17448  }
17449  
17450 +#else /* _alpha_ */
17451 +
17452  SYSCALL_DEFINE0(getuid)
17453  {
17454         /* Only we change this so SMP safe */
17455 diff -NurpP --minimal linux-2.6.34/kernel/user_namespace.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/user_namespace.c
17456 --- linux-2.6.34/kernel/user_namespace.c        2009-03-24 14:22:45.000000000 +0100
17457 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/user_namespace.c   2010-05-18 18:11:22.000000000 +0200
17458 @@ -10,6 +10,7 @@
17459  #include <linux/slab.h>
17460  #include <linux/user_namespace.h>
17461  #include <linux/cred.h>
17462 +#include <linux/vserver/global.h>
17463  
17464  /*
17465   * Create a new user namespace, deriving the creator from the user in the
17466 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
17467                 return -ENOMEM;
17468  
17469         kref_init(&ns->kref);
17470 +       atomic_inc(&vs_global_user_ns);
17471  
17472         for (n = 0; n < UIDHASH_SZ; ++n)
17473                 INIT_HLIST_HEAD(ns->uidhash_table + n);
17474 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
17475         struct user_namespace *ns =
17476                 container_of(kref, struct user_namespace, kref);
17477  
17478 +       /* FIXME: maybe move into destroyer? */
17479 +       atomic_dec(&vs_global_user_ns);
17480         INIT_WORK(&ns->destroyer, free_user_ns_work);
17481         schedule_work(&ns->destroyer);
17482  }
17483 diff -NurpP --minimal linux-2.6.34/kernel/utsname.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/utsname.c
17484 --- linux-2.6.34/kernel/utsname.c       2009-09-10 15:26:28.000000000 +0200
17485 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/utsname.c  2010-05-18 18:11:22.000000000 +0200
17486 @@ -14,14 +14,17 @@
17487  #include <linux/utsname.h>
17488  #include <linux/err.h>
17489  #include <linux/slab.h>
17490 +#include <linux/vserver/global.h>
17491  
17492  static struct uts_namespace *create_uts_ns(void)
17493  {
17494         struct uts_namespace *uts_ns;
17495  
17496         uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17497 -       if (uts_ns)
17498 +       if (uts_ns) {
17499                 kref_init(&uts_ns->kref);
17500 +               atomic_inc(&vs_global_uts_ns);
17501 +       }
17502         return uts_ns;
17503  }
17504  
17505 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
17506         struct uts_namespace *ns;
17507  
17508         ns = container_of(kref, struct uts_namespace, kref);
17509 +       atomic_dec(&vs_global_uts_ns);
17510         kfree(ns);
17511  }
17512 diff -NurpP --minimal linux-2.6.34/kernel/vserver/cacct.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cacct.c
17513 --- linux-2.6.34/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17514 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cacct.c    2010-05-18 18:11:22.000000000 +0200
17515 @@ -0,0 +1,42 @@
17516 +/*
17517 + *  linux/kernel/vserver/cacct.c
17518 + *
17519 + *  Virtual Server: Context Accounting
17520 + *
17521 + *  Copyright (C) 2006-2007 Herbert Pötzl
17522 + *
17523 + *  V0.01  added accounting stats
17524 + *
17525 + */
17526 +
17527 +#include <linux/types.h>
17528 +#include <linux/vs_context.h>
17529 +#include <linux/vserver/cacct_cmd.h>
17530 +#include <linux/vserver/cacct_int.h>
17531 +
17532 +#include <asm/errno.h>
17533 +#include <asm/uaccess.h>
17534 +
17535 +
17536 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17537 +{
17538 +       struct vcmd_sock_stat_v0 vc_data;
17539 +       int j, field;
17540 +
17541 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17542 +               return -EFAULT;
17543 +
17544 +       field = vc_data.field;
17545 +       if ((field < 0) || (field >= VXA_SOCK_SIZE))
17546 +               return -EINVAL;
17547 +
17548 +       for (j = 0; j < 3; j++) {
17549 +               vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17550 +               vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17551 +       }
17552 +
17553 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17554 +               return -EFAULT;
17555 +       return 0;
17556 +}
17557 +
17558 diff -NurpP --minimal linux-2.6.34/kernel/vserver/cacct_init.h linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cacct_init.h
17559 --- linux-2.6.34/kernel/vserver/cacct_init.h    1970-01-01 01:00:00.000000000 +0100
17560 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cacct_init.h       2010-05-18 18:11:22.000000000 +0200
17561 @@ -0,0 +1,25 @@
17562 +
17563 +
17564 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17565 +{
17566 +       int i, j;
17567 +
17568 +
17569 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
17570 +               for (j = 0; j < 3; j++) {
17571 +                       atomic_long_set(&cacct->sock[i][j].count, 0);
17572 +                       atomic_long_set(&cacct->sock[i][j].total, 0);
17573 +               }
17574 +       }
17575 +       for (i = 0; i < 8; i++)
17576 +               atomic_set(&cacct->slab[i], 0);
17577 +       for (i = 0; i < 5; i++)
17578 +               for (j = 0; j < 4; j++)
17579 +                       atomic_set(&cacct->page[i][j], 0);
17580 +}
17581 +
17582 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17583 +{
17584 +       return;
17585 +}
17586 +
17587 diff -NurpP --minimal linux-2.6.34/kernel/vserver/cacct_proc.h linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cacct_proc.h
17588 --- linux-2.6.34/kernel/vserver/cacct_proc.h    1970-01-01 01:00:00.000000000 +0100
17589 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cacct_proc.h       2010-05-18 18:11:22.000000000 +0200
17590 @@ -0,0 +1,53 @@
17591 +#ifndef _VX_CACCT_PROC_H
17592 +#define _VX_CACCT_PROC_H
17593 +
17594 +#include <linux/vserver/cacct_int.h>
17595 +
17596 +
17597 +#define VX_SOCKA_TOP   \
17598 +       "Type\t    recv #/bytes\t\t   send #/bytes\t\t    fail #/bytes\n"
17599 +
17600 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17601 +{
17602 +       int i, j, length = 0;
17603 +       static char *type[VXA_SOCK_SIZE] = {
17604 +               "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17605 +       };
17606 +
17607 +       length += sprintf(buffer + length, VX_SOCKA_TOP);
17608 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
17609 +               length += sprintf(buffer + length, "%s:", type[i]);
17610 +               for (j = 0; j < 3; j++) {
17611 +                       length += sprintf(buffer + length,
17612 +                               "\t%10lu/%-10lu",
17613 +                               vx_sock_count(cacct, i, j),
17614 +                               vx_sock_total(cacct, i, j));
17615 +               }
17616 +               buffer[length++] = '\n';
17617 +       }
17618 +
17619 +       length += sprintf(buffer + length, "\n");
17620 +       length += sprintf(buffer + length,
17621 +               "slab:\t %8u %8u %8u %8u\n",
17622 +               atomic_read(&cacct->slab[1]),
17623 +               atomic_read(&cacct->slab[4]),
17624 +               atomic_read(&cacct->slab[0]),
17625 +               atomic_read(&cacct->slab[2]));
17626 +
17627 +       length += sprintf(buffer + length, "\n");
17628 +       for (i = 0; i < 5; i++) {
17629 +               length += sprintf(buffer + length,
17630 +                       "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17631 +                       atomic_read(&cacct->page[i][0]),
17632 +                       atomic_read(&cacct->page[i][1]),
17633 +                       atomic_read(&cacct->page[i][2]),
17634 +                       atomic_read(&cacct->page[i][3]),
17635 +                       atomic_read(&cacct->page[i][4]),
17636 +                       atomic_read(&cacct->page[i][5]),
17637 +                       atomic_read(&cacct->page[i][6]),
17638 +                       atomic_read(&cacct->page[i][7]));
17639 +       }
17640 +       return length;
17641 +}
17642 +
17643 +#endif /* _VX_CACCT_PROC_H */
17644 diff -NurpP --minimal linux-2.6.34/kernel/vserver/context.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/context.c
17645 --- linux-2.6.34/kernel/vserver/context.c       1970-01-01 01:00:00.000000000 +0100
17646 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/context.c  2010-05-18 18:11:22.000000000 +0200
17647 @@ -0,0 +1,1058 @@
17648 +/*
17649 + *  linux/kernel/vserver/context.c
17650 + *
17651 + *  Virtual Server: Context Support
17652 + *
17653 + *  Copyright (C) 2003-2007  Herbert Pötzl
17654 + *
17655 + *  V0.01  context helper
17656 + *  V0.02  vx_ctx_kill syscall command
17657 + *  V0.03  replaced context_info calls
17658 + *  V0.04  redesign of struct (de)alloc
17659 + *  V0.05  rlimit basic implementation
17660 + *  V0.06  task_xid and info commands
17661 + *  V0.07  context flags and caps
17662 + *  V0.08  switch to RCU based hash
17663 + *  V0.09  revert to non RCU for now
17664 + *  V0.10  and back to working RCU hash
17665 + *  V0.11  and back to locking again
17666 + *  V0.12  referenced context store
17667 + *  V0.13  separate per cpu data
17668 + *  V0.14  changed vcmds to vxi arg
17669 + *  V0.15  added context stat
17670 + *  V0.16  have __create claim() the vxi
17671 + *  V0.17  removed older and legacy stuff
17672 + *
17673 + */
17674 +
17675 +#include <linux/slab.h>
17676 +#include <linux/types.h>
17677 +#include <linux/security.h>
17678 +#include <linux/pid_namespace.h>
17679 +
17680 +#include <linux/vserver/context.h>
17681 +#include <linux/vserver/network.h>
17682 +#include <linux/vserver/debug.h>
17683 +#include <linux/vserver/limit.h>
17684 +#include <linux/vserver/limit_int.h>
17685 +#include <linux/vserver/space.h>
17686 +#include <linux/init_task.h>
17687 +#include <linux/fs_struct.h>
17688 +
17689 +#include <linux/vs_context.h>
17690 +#include <linux/vs_limit.h>
17691 +#include <linux/vs_pid.h>
17692 +#include <linux/vserver/context_cmd.h>
17693 +
17694 +#include "cvirt_init.h"
17695 +#include "cacct_init.h"
17696 +#include "limit_init.h"
17697 +#include "sched_init.h"
17698 +
17699 +
17700 +atomic_t vx_global_ctotal      = ATOMIC_INIT(0);
17701 +atomic_t vx_global_cactive     = ATOMIC_INIT(0);
17702 +
17703 +
17704 +/*     now inactive context structures */
17705 +
17706 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17707 +
17708 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
17709 +
17710 +
17711 +/*     __alloc_vx_info()
17712 +
17713 +       * allocate an initialized vx_info struct
17714 +       * doesn't make it visible (hash)                        */
17715 +
17716 +static struct vx_info *__alloc_vx_info(xid_t xid)
17717 +{
17718 +       struct vx_info *new = NULL;
17719 +       int cpu, index;
17720 +
17721 +       vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17722 +
17723 +       /* would this benefit from a slab cache? */
17724 +       new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17725 +       if (!new)
17726 +               return 0;
17727 +
17728 +       memset(new, 0, sizeof(struct vx_info));
17729 +#ifdef CONFIG_SMP
17730 +       new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17731 +       if (!new->ptr_pc)
17732 +               goto error;
17733 +#endif
17734 +       new->vx_id = xid;
17735 +       INIT_HLIST_NODE(&new->vx_hlist);
17736 +       atomic_set(&new->vx_usecnt, 0);
17737 +       atomic_set(&new->vx_tasks, 0);
17738 +       new->vx_parent = NULL;
17739 +       new->vx_state = 0;
17740 +       init_waitqueue_head(&new->vx_wait);
17741 +
17742 +       /* prepare reaper */
17743 +       get_task_struct(init_pid_ns.child_reaper);
17744 +       new->vx_reaper = init_pid_ns.child_reaper;
17745 +       new->vx_badness_bias = 0;
17746 +
17747 +       /* rest of init goes here */
17748 +       vx_info_init_limit(&new->limit);
17749 +       vx_info_init_sched(&new->sched);
17750 +       vx_info_init_cvirt(&new->cvirt);
17751 +       vx_info_init_cacct(&new->cacct);
17752 +
17753 +       /* per cpu data structures */
17754 +       for_each_possible_cpu(cpu) {
17755 +               vx_info_init_sched_pc(
17756 +                       &vx_per_cpu(new, sched_pc, cpu), cpu);
17757 +               vx_info_init_cvirt_pc(
17758 +                       &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17759 +       }
17760 +
17761 +       new->vx_flags = VXF_INIT_SET;
17762 +       cap_set_init_eff(new->vx_bcaps);
17763 +       new->vx_ccaps = 0;
17764 +       new->vx_umask = 0;
17765 +
17766 +       new->reboot_cmd = 0;
17767 +       new->exit_code = 0;
17768 +
17769 +       // preconfig fs entries
17770 +       for (index = 0; index < VX_SPACES; index++) {
17771 +               write_lock(&init_fs.lock);
17772 +               init_fs.users++;
17773 +               write_unlock(&init_fs.lock);
17774 +               new->vx_fs[index] = &init_fs;
17775 +       }
17776 +
17777 +       vxdprintk(VXD_CBIT(xid, 0),
17778 +               "alloc_vx_info(%d) = %p", xid, new);
17779 +       vxh_alloc_vx_info(new);
17780 +       atomic_inc(&vx_global_ctotal);
17781 +       return new;
17782 +#ifdef CONFIG_SMP
17783 +error:
17784 +       kfree(new);
17785 +       return 0;
17786 +#endif
17787 +}
17788 +
17789 +/*     __dealloc_vx_info()
17790 +
17791 +       * final disposal of vx_info                             */
17792 +
17793 +static void __dealloc_vx_info(struct vx_info *vxi)
17794 +{
17795 +#ifdef CONFIG_VSERVER_WARN
17796 +       struct vx_info_save vxis;
17797 +       int cpu;
17798 +#endif
17799 +       vxdprintk(VXD_CBIT(xid, 0),
17800 +               "dealloc_vx_info(%p)", vxi);
17801 +       vxh_dealloc_vx_info(vxi);
17802 +
17803 +#ifdef CONFIG_VSERVER_WARN
17804 +       enter_vx_info(vxi, &vxis);
17805 +       vx_info_exit_limit(&vxi->limit);
17806 +       vx_info_exit_sched(&vxi->sched);
17807 +       vx_info_exit_cvirt(&vxi->cvirt);
17808 +       vx_info_exit_cacct(&vxi->cacct);
17809 +
17810 +       for_each_possible_cpu(cpu) {
17811 +               vx_info_exit_sched_pc(
17812 +                       &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17813 +               vx_info_exit_cvirt_pc(
17814 +                       &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17815 +       }
17816 +       leave_vx_info(&vxis);
17817 +#endif
17818 +
17819 +       vxi->vx_id = -1;
17820 +       vxi->vx_state |= VXS_RELEASED;
17821 +
17822 +#ifdef CONFIG_SMP
17823 +       free_percpu(vxi->ptr_pc);
17824 +#endif
17825 +       kfree(vxi);
17826 +       atomic_dec(&vx_global_ctotal);
17827 +}
17828 +
17829 +static void __shutdown_vx_info(struct vx_info *vxi)
17830 +{
17831 +       struct nsproxy *nsproxy;
17832 +       struct fs_struct *fs;
17833 +       int index, kill;
17834 +
17835 +       might_sleep();
17836 +
17837 +       vxi->vx_state |= VXS_SHUTDOWN;
17838 +       vs_state_change(vxi, VSC_SHUTDOWN);
17839 +
17840 +       for (index = 0; index < VX_SPACES; index++) {
17841 +               nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
17842 +               if (nsproxy)
17843 +                       put_nsproxy(nsproxy);
17844 +
17845 +               fs = xchg(&vxi->vx_fs[index], NULL);
17846 +               write_lock(&fs->lock);
17847 +               kill = !--fs->users;
17848 +               write_unlock(&fs->lock);
17849 +               if (kill)
17850 +                       free_fs_struct(fs);
17851 +       }
17852 +}
17853 +
17854 +/* exported stuff */
17855 +
17856 +void free_vx_info(struct vx_info *vxi)
17857 +{
17858 +       unsigned long flags;
17859 +       unsigned index;
17860 +
17861 +       /* check for reference counts first */
17862 +       BUG_ON(atomic_read(&vxi->vx_usecnt));
17863 +       BUG_ON(atomic_read(&vxi->vx_tasks));
17864 +
17865 +       /* context must not be hashed */
17866 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
17867 +
17868 +       /* context shutdown is mandatory */
17869 +       BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17870 +
17871 +       /* nsproxy and fs check */
17872 +       for (index = 0; index < VX_SPACES; index++) {
17873 +               BUG_ON(vxi->vx_nsproxy[index]);
17874 +               BUG_ON(vxi->vx_fs[index]);
17875 +       }
17876 +
17877 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
17878 +       hlist_del(&vxi->vx_hlist);
17879 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17880 +
17881 +       __dealloc_vx_info(vxi);
17882 +}
17883 +
17884 +
17885 +/*     hash table for vx_info hash */
17886 +
17887 +#define VX_HASH_SIZE   13
17888 +
17889 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17890 +       { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17891 +
17892 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
17893 +
17894 +
17895 +static inline unsigned int __hashval(xid_t xid)
17896 +{
17897 +       return (xid % VX_HASH_SIZE);
17898 +}
17899 +
17900 +
17901 +
17902 +/*     __hash_vx_info()
17903 +
17904 +       * add the vxi to the global hash table
17905 +       * requires the hash_lock to be held                     */
17906 +
17907 +static inline void __hash_vx_info(struct vx_info *vxi)
17908 +{
17909 +       struct hlist_head *head;
17910 +
17911 +       vxd_assert_lock(&vx_info_hash_lock);
17912 +       vxdprintk(VXD_CBIT(xid, 4),
17913 +               "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17914 +       vxh_hash_vx_info(vxi);
17915 +
17916 +       /* context must not be hashed */
17917 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
17918 +
17919 +       vxi->vx_state |= VXS_HASHED;
17920 +       head = &vx_info_hash[__hashval(vxi->vx_id)];
17921 +       hlist_add_head(&vxi->vx_hlist, head);
17922 +       atomic_inc(&vx_global_cactive);
17923 +}
17924 +
17925 +/*     __unhash_vx_info()
17926 +
17927 +       * remove the vxi from the global hash table
17928 +       * requires the hash_lock to be held                     */
17929 +
17930 +static inline void __unhash_vx_info(struct vx_info *vxi)
17931 +{
17932 +       unsigned long flags;
17933 +
17934 +       vxd_assert_lock(&vx_info_hash_lock);
17935 +       vxdprintk(VXD_CBIT(xid, 4),
17936 +               "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
17937 +               atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
17938 +       vxh_unhash_vx_info(vxi);
17939 +
17940 +       /* context must be hashed */
17941 +       BUG_ON(!vx_info_state(vxi, VXS_HASHED));
17942 +       /* but without tasks */
17943 +       BUG_ON(atomic_read(&vxi->vx_tasks));
17944 +
17945 +       vxi->vx_state &= ~VXS_HASHED;
17946 +       hlist_del_init(&vxi->vx_hlist);
17947 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
17948 +       hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
17949 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17950 +       atomic_dec(&vx_global_cactive);
17951 +}
17952 +
17953 +
17954 +/*     __lookup_vx_info()
17955 +
17956 +       * requires the hash_lock to be held
17957 +       * doesn't increment the vx_refcnt                       */
17958 +
17959 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
17960 +{
17961 +       struct hlist_head *head = &vx_info_hash[__hashval(xid)];
17962 +       struct hlist_node *pos;
17963 +       struct vx_info *vxi;
17964 +
17965 +       vxd_assert_lock(&vx_info_hash_lock);
17966 +       hlist_for_each(pos, head) {
17967 +               vxi = hlist_entry(pos, struct vx_info, vx_hlist);
17968 +
17969 +               if (vxi->vx_id == xid)
17970 +                       goto found;
17971 +       }
17972 +       vxi = NULL;
17973 +found:
17974 +       vxdprintk(VXD_CBIT(xid, 0),
17975 +               "__lookup_vx_info(#%u): %p[#%u]",
17976 +               xid, vxi, vxi ? vxi->vx_id : 0);
17977 +       vxh_lookup_vx_info(vxi, xid);
17978 +       return vxi;
17979 +}
17980 +
17981 +
17982 +/*     __create_vx_info()
17983 +
17984 +       * create the requested context
17985 +       * get(), claim() and hash it                            */
17986 +
17987 +static struct vx_info *__create_vx_info(int id)
17988 +{
17989 +       struct vx_info *new, *vxi = NULL;
17990 +
17991 +       vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
17992 +
17993 +       if (!(new = __alloc_vx_info(id)))
17994 +               return ERR_PTR(-ENOMEM);
17995 +
17996 +       /* required to make dynamic xids unique */
17997 +       spin_lock(&vx_info_hash_lock);
17998 +
17999 +       /* static context requested */
18000 +       if ((vxi = __lookup_vx_info(id))) {
18001 +               vxdprintk(VXD_CBIT(xid, 0),
18002 +                       "create_vx_info(%d) = %p (already there)", id, vxi);
18003 +               if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18004 +                       vxi = ERR_PTR(-EBUSY);
18005 +               else
18006 +                       vxi = ERR_PTR(-EEXIST);
18007 +               goto out_unlock;
18008 +       }
18009 +       /* new context */
18010 +       vxdprintk(VXD_CBIT(xid, 0),
18011 +               "create_vx_info(%d) = %p (new)", id, new);
18012 +       claim_vx_info(new, NULL);
18013 +       __hash_vx_info(get_vx_info(new));
18014 +       vxi = new, new = NULL;
18015 +
18016 +out_unlock:
18017 +       spin_unlock(&vx_info_hash_lock);
18018 +       vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18019 +       if (new)
18020 +               __dealloc_vx_info(new);
18021 +       return vxi;
18022 +}
18023 +
18024 +
18025 +/*     exported stuff                                          */
18026 +
18027 +
18028 +void unhash_vx_info(struct vx_info *vxi)
18029 +{
18030 +       __shutdown_vx_info(vxi);
18031 +       spin_lock(&vx_info_hash_lock);
18032 +       __unhash_vx_info(vxi);
18033 +       spin_unlock(&vx_info_hash_lock);
18034 +       __wakeup_vx_info(vxi);
18035 +}
18036 +
18037 +
18038 +/*     lookup_vx_info()
18039 +
18040 +       * search for a vx_info and get() it
18041 +       * negative id means current                             */
18042 +
18043 +struct vx_info *lookup_vx_info(int id)
18044 +{
18045 +       struct vx_info *vxi = NULL;
18046 +
18047 +       if (id < 0) {
18048 +               vxi = get_vx_info(current_vx_info());
18049 +       } else if (id > 1) {
18050 +               spin_lock(&vx_info_hash_lock);
18051 +               vxi = get_vx_info(__lookup_vx_info(id));
18052 +               spin_unlock(&vx_info_hash_lock);
18053 +       }
18054 +       return vxi;
18055 +}
18056 +
18057 +/*     xid_is_hashed()
18058 +
18059 +       * verify that xid is still hashed                       */
18060 +
18061 +int xid_is_hashed(xid_t xid)
18062 +{
18063 +       int hashed;
18064 +
18065 +       spin_lock(&vx_info_hash_lock);
18066 +       hashed = (__lookup_vx_info(xid) != NULL);
18067 +       spin_unlock(&vx_info_hash_lock);
18068 +       return hashed;
18069 +}
18070 +
18071 +#ifdef CONFIG_PROC_FS
18072 +
18073 +/*     get_xid_list()
18074 +
18075 +       * get a subset of hashed xids for proc
18076 +       * assumes size is at least one                          */
18077 +
18078 +int get_xid_list(int index, unsigned int *xids, int size)
18079 +{
18080 +       int hindex, nr_xids = 0;
18081 +
18082 +       /* only show current and children */
18083 +       if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18084 +               if (index > 0)
18085 +                       return 0;
18086 +               xids[nr_xids] = vx_current_xid();
18087 +               return 1;
18088 +       }
18089 +
18090 +       for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18091 +               struct hlist_head *head = &vx_info_hash[hindex];
18092 +               struct hlist_node *pos;
18093 +
18094 +               spin_lock(&vx_info_hash_lock);
18095 +               hlist_for_each(pos, head) {
18096 +                       struct vx_info *vxi;
18097 +
18098 +                       if (--index > 0)
18099 +                               continue;
18100 +
18101 +                       vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18102 +                       xids[nr_xids] = vxi->vx_id;
18103 +                       if (++nr_xids >= size) {
18104 +                               spin_unlock(&vx_info_hash_lock);
18105 +                               goto out;
18106 +                       }
18107 +               }
18108 +               /* keep the lock time short */
18109 +               spin_unlock(&vx_info_hash_lock);
18110 +       }
18111 +out:
18112 +       return nr_xids;
18113 +}
18114 +#endif
18115 +
18116 +#ifdef CONFIG_VSERVER_DEBUG
18117 +
18118 +void   dump_vx_info_inactive(int level)
18119 +{
18120 +       struct hlist_node *entry, *next;
18121 +
18122 +       hlist_for_each_safe(entry, next, &vx_info_inactive) {
18123 +               struct vx_info *vxi =
18124 +                       list_entry(entry, struct vx_info, vx_hlist);
18125 +
18126 +               dump_vx_info(vxi, level);
18127 +       }
18128 +}
18129 +
18130 +#endif
18131 +
18132 +#if 0
18133 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18134 +{
18135 +       struct user_struct *new_user, *old_user;
18136 +
18137 +       if (!p || !vxi)
18138 +               BUG();
18139 +
18140 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18141 +               return -EACCES;
18142 +
18143 +       new_user = alloc_uid(vxi->vx_id, p->uid);
18144 +       if (!new_user)
18145 +               return -ENOMEM;
18146 +
18147 +       old_user = p->user;
18148 +       if (new_user != old_user) {
18149 +               atomic_inc(&new_user->processes);
18150 +               atomic_dec(&old_user->processes);
18151 +               p->user = new_user;
18152 +       }
18153 +       free_uid(old_user);
18154 +       return 0;
18155 +}
18156 +#endif
18157 +
18158 +#if 0
18159 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18160 +{
18161 +       // p->cap_effective &= vxi->vx_cap_bset;
18162 +       p->cap_effective =
18163 +               cap_intersect(p->cap_effective, vxi->cap_bset);
18164 +       // p->cap_inheritable &= vxi->vx_cap_bset;
18165 +       p->cap_inheritable =
18166 +               cap_intersect(p->cap_inheritable, vxi->cap_bset);
18167 +       // p->cap_permitted &= vxi->vx_cap_bset;
18168 +       p->cap_permitted =
18169 +               cap_intersect(p->cap_permitted, vxi->cap_bset);
18170 +}
18171 +#endif
18172 +
18173 +
18174 +#include <linux/file.h>
18175 +#include <linux/fdtable.h>
18176 +
18177 +static int vx_openfd_task(struct task_struct *tsk)
18178 +{
18179 +       struct files_struct *files = tsk->files;
18180 +       struct fdtable *fdt;
18181 +       const unsigned long *bptr;
18182 +       int count, total;
18183 +
18184 +       /* no rcu_read_lock() because of spin_lock() */
18185 +       spin_lock(&files->file_lock);
18186 +       fdt = files_fdtable(files);
18187 +       bptr = fdt->open_fds->fds_bits;
18188 +       count = fdt->max_fds / (sizeof(unsigned long) * 8);
18189 +       for (total = 0; count > 0; count--) {
18190 +               if (*bptr)
18191 +                       total += hweight_long(*bptr);
18192 +               bptr++;
18193 +       }
18194 +       spin_unlock(&files->file_lock);
18195 +       return total;
18196 +}
18197 +
18198 +
18199 +/*     for *space compatibility */
18200 +
18201 +asmlinkage long sys_unshare(unsigned long);
18202 +
18203 +/*
18204 + *     migrate task to new context
18205 + *     gets vxi, puts old_vxi on change
18206 + *     optionally unshares namespaces (hack)
18207 + */
18208 +
18209 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18210 +{
18211 +       struct vx_info *old_vxi;
18212 +       int ret = 0;
18213 +
18214 +       if (!p || !vxi)
18215 +               BUG();
18216 +
18217 +       vxdprintk(VXD_CBIT(xid, 5),
18218 +               "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18219 +               vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18220 +
18221 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18222 +               !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18223 +               return -EACCES;
18224 +
18225 +       if (vx_info_state(vxi, VXS_SHUTDOWN))
18226 +               return -EFAULT;
18227 +
18228 +       old_vxi = task_get_vx_info(p);
18229 +       if (old_vxi == vxi)
18230 +               goto out;
18231 +
18232 +//     if (!(ret = vx_migrate_user(p, vxi))) {
18233 +       {
18234 +               int openfd;
18235 +
18236 +               task_lock(p);
18237 +               openfd = vx_openfd_task(p);
18238 +
18239 +               if (old_vxi) {
18240 +                       atomic_dec(&old_vxi->cvirt.nr_threads);
18241 +                       atomic_dec(&old_vxi->cvirt.nr_running);
18242 +                       __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18243 +                       /* FIXME: what about the struct files here? */
18244 +                       __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18245 +                       /* account for the executable */
18246 +                       __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18247 +               }
18248 +               atomic_inc(&vxi->cvirt.nr_threads);
18249 +               atomic_inc(&vxi->cvirt.nr_running);
18250 +               __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18251 +               /* FIXME: what about the struct files here? */
18252 +               __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18253 +               /* account for the executable */
18254 +               __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18255 +
18256 +               if (old_vxi) {
18257 +                       release_vx_info(old_vxi, p);
18258 +                       clr_vx_info(&p->vx_info);
18259 +               }
18260 +               claim_vx_info(vxi, p);
18261 +               set_vx_info(&p->vx_info, vxi);
18262 +               p->xid = vxi->vx_id;
18263 +
18264 +               vxdprintk(VXD_CBIT(xid, 5),
18265 +                       "moved task %p into vxi:%p[#%d]",
18266 +                       p, vxi, vxi->vx_id);
18267 +
18268 +               // vx_mask_cap_bset(vxi, p);
18269 +               task_unlock(p);
18270 +
18271 +               /* hack for *spaces to provide compatibility */
18272 +               if (unshare) {
18273 +                       struct nsproxy *old_nsp, *new_nsp;
18274 +
18275 +                       ret = unshare_nsproxy_namespaces(
18276 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18277 +                               &new_nsp, NULL);
18278 +                       if (ret)
18279 +                               goto out;
18280 +
18281 +                       old_nsp = xchg(&p->nsproxy, new_nsp);
18282 +                       vx_set_space(vxi,
18283 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18284 +                       put_nsproxy(old_nsp);
18285 +               }
18286 +       }
18287 +out:
18288 +       put_vx_info(old_vxi);
18289 +       return ret;
18290 +}
18291 +
18292 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18293 +{
18294 +       struct task_struct *old_reaper;
18295 +
18296 +       if (!vxi)
18297 +               return -EINVAL;
18298 +
18299 +       vxdprintk(VXD_CBIT(xid, 6),
18300 +               "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18301 +               vxi, vxi->vx_id, p, p->xid, p->pid);
18302 +
18303 +       old_reaper = vxi->vx_reaper;
18304 +       if (old_reaper == p)
18305 +               return 0;
18306 +
18307 +       /* set new child reaper */
18308 +       get_task_struct(p);
18309 +       vxi->vx_reaper = p;
18310 +       put_task_struct(old_reaper);
18311 +       return 0;
18312 +}
18313 +
18314 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18315 +{
18316 +       if (!vxi)
18317 +               return -EINVAL;
18318 +
18319 +       vxdprintk(VXD_CBIT(xid, 6),
18320 +               "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18321 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18322 +
18323 +       vxi->vx_flags &= ~VXF_STATE_INIT;
18324 +       // vxi->vx_initpid = p->tgid;
18325 +       vxi->vx_initpid = p->pid;
18326 +       return 0;
18327 +}
18328 +
18329 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18330 +{
18331 +       vxdprintk(VXD_CBIT(xid, 6),
18332 +               "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18333 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18334 +
18335 +       vxi->exit_code = code;
18336 +       vxi->vx_initpid = 0;
18337 +}
18338 +
18339 +
18340 +void vx_set_persistent(struct vx_info *vxi)
18341 +{
18342 +       vxdprintk(VXD_CBIT(xid, 6),
18343 +               "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18344 +
18345 +       get_vx_info(vxi);
18346 +       claim_vx_info(vxi, NULL);
18347 +}
18348 +
18349 +void vx_clear_persistent(struct vx_info *vxi)
18350 +{
18351 +       vxdprintk(VXD_CBIT(xid, 6),
18352 +               "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18353 +
18354 +       release_vx_info(vxi, NULL);
18355 +       put_vx_info(vxi);
18356 +}
18357 +
18358 +void vx_update_persistent(struct vx_info *vxi)
18359 +{
18360 +       if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18361 +               vx_set_persistent(vxi);
18362 +       else
18363 +               vx_clear_persistent(vxi);
18364 +}
18365 +
18366 +
18367 +/*     task must be current or locked          */
18368 +
18369 +void   exit_vx_info(struct task_struct *p, int code)
18370 +{
18371 +       struct vx_info *vxi = p->vx_info;
18372 +
18373 +       if (vxi) {
18374 +               atomic_dec(&vxi->cvirt.nr_threads);
18375 +               vx_nproc_dec(p);
18376 +
18377 +               vxi->exit_code = code;
18378 +               release_vx_info(vxi, p);
18379 +       }
18380 +}
18381 +
18382 +void   exit_vx_info_early(struct task_struct *p, int code)
18383 +{
18384 +       struct vx_info *vxi = p->vx_info;
18385 +
18386 +       if (vxi) {
18387 +               if (vxi->vx_initpid == p->pid)
18388 +                       vx_exit_init(vxi, p, code);
18389 +               if (vxi->vx_reaper == p)
18390 +                       vx_set_reaper(vxi, init_pid_ns.child_reaper);
18391 +       }
18392 +}
18393 +
18394 +
18395 +/* vserver syscall commands below here */
18396 +
18397 +/* taks xid and vx_info functions */
18398 +
18399 +#include <asm/uaccess.h>
18400 +
18401 +
18402 +int vc_task_xid(uint32_t id)
18403 +{
18404 +       xid_t xid;
18405 +
18406 +       if (id) {
18407 +               struct task_struct *tsk;
18408 +
18409 +               read_lock(&tasklist_lock);
18410 +               tsk = find_task_by_real_pid(id);
18411 +               xid = (tsk) ? tsk->xid : -ESRCH;
18412 +               read_unlock(&tasklist_lock);
18413 +       } else
18414 +               xid = vx_current_xid();
18415 +       return xid;
18416 +}
18417 +
18418 +
18419 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18420 +{
18421 +       struct vcmd_vx_info_v0 vc_data;
18422 +
18423 +       vc_data.xid = vxi->vx_id;
18424 +       vc_data.initpid = vxi->vx_initpid;
18425 +
18426 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18427 +               return -EFAULT;
18428 +       return 0;
18429 +}
18430 +
18431 +
18432 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18433 +{
18434 +       struct vcmd_ctx_stat_v0 vc_data;
18435 +
18436 +       vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18437 +       vc_data.tasks = atomic_read(&vxi->vx_tasks);
18438 +
18439 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18440 +               return -EFAULT;
18441 +       return 0;
18442 +}
18443 +
18444 +
18445 +/* context functions */
18446 +
18447 +int vc_ctx_create(uint32_t xid, void __user *data)
18448 +{
18449 +       struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18450 +       struct vx_info *new_vxi;
18451 +       int ret;
18452 +
18453 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18454 +               return -EFAULT;
18455 +
18456 +       if ((xid > MAX_S_CONTEXT) || (xid < 2))
18457 +               return -EINVAL;
18458 +
18459 +       new_vxi = __create_vx_info(xid);
18460 +       if (IS_ERR(new_vxi))
18461 +               return PTR_ERR(new_vxi);
18462 +
18463 +       /* initial flags */
18464 +       new_vxi->vx_flags = vc_data.flagword;
18465 +
18466 +       ret = -ENOEXEC;
18467 +       if (vs_state_change(new_vxi, VSC_STARTUP))
18468 +               goto out;
18469 +
18470 +       ret = vx_migrate_task(current, new_vxi, (!data));
18471 +       if (ret)
18472 +               goto out;
18473 +
18474 +       /* return context id on success */
18475 +       ret = new_vxi->vx_id;
18476 +
18477 +       /* get a reference for persistent contexts */
18478 +       if ((vc_data.flagword & VXF_PERSISTENT))
18479 +               vx_set_persistent(new_vxi);
18480 +out:
18481 +       release_vx_info(new_vxi, NULL);
18482 +       put_vx_info(new_vxi);
18483 +       return ret;
18484 +}
18485 +
18486 +
18487 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18488 +{
18489 +       struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18490 +       int ret;
18491 +
18492 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18493 +               return -EFAULT;
18494 +
18495 +       ret = vx_migrate_task(current, vxi, 0);
18496 +       if (ret)
18497 +               return ret;
18498 +       if (vc_data.flagword & VXM_SET_INIT)
18499 +               ret = vx_set_init(vxi, current);
18500 +       if (ret)
18501 +               return ret;
18502 +       if (vc_data.flagword & VXM_SET_REAPER)
18503 +               ret = vx_set_reaper(vxi, current);
18504 +       return ret;
18505 +}
18506 +
18507 +
18508 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18509 +{
18510 +       struct vcmd_ctx_flags_v0 vc_data;
18511 +
18512 +       vc_data.flagword = vxi->vx_flags;
18513 +
18514 +       /* special STATE flag handling */
18515 +       vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18516 +
18517 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18518 +               return -EFAULT;
18519 +       return 0;
18520 +}
18521 +
18522 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18523 +{
18524 +       struct vcmd_ctx_flags_v0 vc_data;
18525 +       uint64_t mask, trigger;
18526 +
18527 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18528 +               return -EFAULT;
18529 +
18530 +       /* special STATE flag handling */
18531 +       mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18532 +       trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18533 +
18534 +       if (vxi == current_vx_info()) {
18535 +               /* if (trigger & VXF_STATE_SETUP)
18536 +                       vx_mask_cap_bset(vxi, current); */
18537 +               if (trigger & VXF_STATE_INIT) {
18538 +                       int ret;
18539 +
18540 +                       ret = vx_set_init(vxi, current);
18541 +                       if (ret)
18542 +                               return ret;
18543 +                       ret = vx_set_reaper(vxi, current);
18544 +                       if (ret)
18545 +                               return ret;
18546 +               }
18547 +       }
18548 +
18549 +       vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18550 +               vc_data.flagword, mask);
18551 +       if (trigger & VXF_PERSISTENT)
18552 +               vx_update_persistent(vxi);
18553 +
18554 +       return 0;
18555 +}
18556 +
18557 +
18558 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18559 +{
18560 +       uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18561 +
18562 +       // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18563 +       return v;
18564 +}
18565 +
18566 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18567 +{
18568 +       kernel_cap_t c = __cap_empty_set;
18569 +
18570 +       c.cap[0] = v & 0xFFFFFFFF;
18571 +       c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18572 +
18573 +       // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18574 +       return c;
18575 +}
18576 +
18577 +
18578 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18579 +{
18580 +       if (bcaps)
18581 +               *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18582 +       if (ccaps)
18583 +               *ccaps = vxi->vx_ccaps;
18584 +
18585 +       return 0;
18586 +}
18587 +
18588 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18589 +{
18590 +       struct vcmd_ctx_caps_v1 vc_data;
18591 +       int ret;
18592 +
18593 +       ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18594 +       if (ret)
18595 +               return ret;
18596 +       vc_data.cmask = ~0ULL;
18597 +
18598 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18599 +               return -EFAULT;
18600 +       return 0;
18601 +}
18602 +
18603 +static int do_set_caps(struct vx_info *vxi,
18604 +       uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18605 +{
18606 +       uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18607 +
18608 +#if 0
18609 +       printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18610 +               bcaps, bmask, ccaps, cmask);
18611 +#endif
18612 +       vxi->vx_bcaps = cap_t_from_caps(
18613 +               vs_mask_flags(bcold, bcaps, bmask));
18614 +       vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18615 +
18616 +       return 0;
18617 +}
18618 +
18619 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18620 +{
18621 +       struct vcmd_ctx_caps_v1 vc_data;
18622 +
18623 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18624 +               return -EFAULT;
18625 +
18626 +       return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18627 +}
18628 +
18629 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18630 +{
18631 +       struct vcmd_bcaps vc_data;
18632 +       int ret;
18633 +
18634 +       ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18635 +       if (ret)
18636 +               return ret;
18637 +       vc_data.bmask = ~0ULL;
18638 +
18639 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18640 +               return -EFAULT;
18641 +       return 0;
18642 +}
18643 +
18644 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18645 +{
18646 +       struct vcmd_bcaps vc_data;
18647 +
18648 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18649 +               return -EFAULT;
18650 +
18651 +       return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18652 +}
18653 +
18654 +
18655 +int vc_get_umask(struct vx_info *vxi, void __user *data)
18656 +{
18657 +       struct vcmd_umask vc_data;
18658 +
18659 +       vc_data.umask = vxi->vx_umask;
18660 +       vc_data.mask = ~0ULL;
18661 +
18662 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18663 +               return -EFAULT;
18664 +       return 0;
18665 +}
18666 +
18667 +int vc_set_umask(struct vx_info *vxi, void __user *data)
18668 +{
18669 +       struct vcmd_umask vc_data;
18670 +
18671 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18672 +               return -EFAULT;
18673 +
18674 +       vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
18675 +               vc_data.umask, vc_data.mask);
18676 +       return 0;
18677 +}
18678 +
18679 +
18680 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18681 +{
18682 +       struct vcmd_badness_v0 vc_data;
18683 +
18684 +       vc_data.bias = vxi->vx_badness_bias;
18685 +
18686 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18687 +               return -EFAULT;
18688 +       return 0;
18689 +}
18690 +
18691 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18692 +{
18693 +       struct vcmd_badness_v0 vc_data;
18694 +
18695 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18696 +               return -EFAULT;
18697 +
18698 +       vxi->vx_badness_bias = vc_data.bias;
18699 +       return 0;
18700 +}
18701 +
18702 +#include <linux/module.h>
18703 +
18704 +EXPORT_SYMBOL_GPL(free_vx_info);
18705 +
18706 diff -NurpP --minimal linux-2.6.34/kernel/vserver/cvirt.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cvirt.c
18707 --- linux-2.6.34/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18708 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cvirt.c    2010-05-18 18:11:22.000000000 +0200
18709 @@ -0,0 +1,304 @@
18710 +/*
18711 + *  linux/kernel/vserver/cvirt.c
18712 + *
18713 + *  Virtual Server: Context Virtualization
18714 + *
18715 + *  Copyright (C) 2004-2007  Herbert Pötzl
18716 + *
18717 + *  V0.01  broken out from limit.c
18718 + *  V0.02  added utsname stuff
18719 + *  V0.03  changed vcmds to vxi arg
18720 + *
18721 + */
18722 +
18723 +#include <linux/types.h>
18724 +#include <linux/utsname.h>
18725 +#include <linux/vs_cvirt.h>
18726 +#include <linux/vserver/switch.h>
18727 +#include <linux/vserver/cvirt_cmd.h>
18728 +
18729 +#include <asm/uaccess.h>
18730 +
18731 +
18732 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18733 +{
18734 +       struct vx_info *vxi = current_vx_info();
18735 +
18736 +       set_normalized_timespec(uptime,
18737 +               uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18738 +               uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18739 +       if (!idle)
18740 +               return;
18741 +       set_normalized_timespec(idle,
18742 +               idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18743 +               idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18744 +       return;
18745 +}
18746 +
18747 +uint64_t vx_idle_jiffies(void)
18748 +{
18749 +       return init_task.utime + init_task.stime;
18750 +}
18751 +
18752 +
18753 +
18754 +static inline uint32_t __update_loadavg(uint32_t load,
18755 +       int wsize, int delta, int n)
18756 +{
18757 +       unsigned long long calc, prev;
18758 +
18759 +       /* just set it to n */
18760 +       if (unlikely(delta >= wsize))
18761 +               return (n << FSHIFT);
18762 +
18763 +       calc = delta * n;
18764 +       calc <<= FSHIFT;
18765 +       prev = (wsize - delta);
18766 +       prev *= load;
18767 +       calc += prev;
18768 +       do_div(calc, wsize);
18769 +       return calc;
18770 +}
18771 +
18772 +
18773 +void vx_update_load(struct vx_info *vxi)
18774 +{
18775 +       uint32_t now, last, delta;
18776 +       unsigned int nr_running, nr_uninterruptible;
18777 +       unsigned int total;
18778 +       unsigned long flags;
18779 +
18780 +       spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18781 +
18782 +       now = jiffies;
18783 +       last = vxi->cvirt.load_last;
18784 +       delta = now - last;
18785 +
18786 +       if (delta < 5*HZ)
18787 +               goto out;
18788 +
18789 +       nr_running = atomic_read(&vxi->cvirt.nr_running);
18790 +       nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18791 +       total = nr_running + nr_uninterruptible;
18792 +
18793 +       vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18794 +               60*HZ, delta, total);
18795 +       vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18796 +               5*60*HZ, delta, total);
18797 +       vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18798 +               15*60*HZ, delta, total);
18799 +
18800 +       vxi->cvirt.load_last = now;
18801 +out:
18802 +       atomic_inc(&vxi->cvirt.load_updates);
18803 +       spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18804 +}
18805 +
18806 +
18807 +/*
18808 + * Commands to do_syslog:
18809 + *
18810 + *      0 -- Close the log.  Currently a NOP.
18811 + *      1 -- Open the log. Currently a NOP.
18812 + *      2 -- Read from the log.
18813 + *      3 -- Read all messages remaining in the ring buffer.
18814 + *      4 -- Read and clear all messages remaining in the ring buffer
18815 + *      5 -- Clear ring buffer.
18816 + *      6 -- Disable printk's to console
18817 + *      7 -- Enable printk's to console
18818 + *      8 -- Set level of messages printed to console
18819 + *      9 -- Return number of unread characters in the log buffer
18820 + *     10 -- Return size of the log buffer
18821 + */
18822 +int vx_do_syslog(int type, char __user *buf, int len)
18823 +{
18824 +       int error = 0;
18825 +       int do_clear = 0;
18826 +       struct vx_info *vxi = current_vx_info();
18827 +       struct _vx_syslog *log;
18828 +
18829 +       if (!vxi)
18830 +               return -EINVAL;
18831 +       log = &vxi->cvirt.syslog;
18832 +
18833 +       switch (type) {
18834 +       case 0:         /* Close log */
18835 +       case 1:         /* Open log */
18836 +               break;
18837 +       case 2:         /* Read from log */
18838 +               error = wait_event_interruptible(log->log_wait,
18839 +                       (log->log_start - log->log_end));
18840 +               if (error)
18841 +                       break;
18842 +               spin_lock_irq(&log->logbuf_lock);
18843 +               spin_unlock_irq(&log->logbuf_lock);
18844 +               break;
18845 +       case 4:         /* Read/clear last kernel messages */
18846 +               do_clear = 1;
18847 +               /* fall through */
18848 +       case 3:         /* Read last kernel messages */
18849 +               return 0;
18850 +
18851 +       case 5:         /* Clear ring buffer */
18852 +               return 0;
18853 +
18854 +       case 6:         /* Disable logging to console */
18855 +       case 7:         /* Enable logging to console */
18856 +       case 8:         /* Set level of messages printed to console */
18857 +               break;
18858 +
18859 +       case 9:         /* Number of chars in the log buffer */
18860 +               return 0;
18861 +       case 10:        /* Size of the log buffer */
18862 +               return 0;
18863 +       default:
18864 +               error = -EINVAL;
18865 +               break;
18866 +       }
18867 +       return error;
18868 +}
18869 +
18870 +
18871 +/* virtual host info names */
18872 +
18873 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18874 +{
18875 +       struct nsproxy *nsproxy;
18876 +       struct uts_namespace *uts;
18877 +
18878 +       if (id == VHIN_CONTEXT)
18879 +               return vxi->vx_name;
18880 +
18881 +       nsproxy = vxi->vx_nsproxy[0];
18882 +       if (!nsproxy)
18883 +               return NULL;
18884 +
18885 +       uts = nsproxy->uts_ns;
18886 +       if (!uts)
18887 +               return NULL;
18888 +
18889 +       switch (id) {
18890 +       case VHIN_SYSNAME:
18891 +               return uts->name.sysname;
18892 +       case VHIN_NODENAME:
18893 +               return uts->name.nodename;
18894 +       case VHIN_RELEASE:
18895 +               return uts->name.release;
18896 +       case VHIN_VERSION:
18897 +               return uts->name.version;
18898 +       case VHIN_MACHINE:
18899 +               return uts->name.machine;
18900 +       case VHIN_DOMAINNAME:
18901 +               return uts->name.domainname;
18902 +       default:
18903 +               return NULL;
18904 +       }
18905 +       return NULL;
18906 +}
18907 +
18908 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
18909 +{
18910 +       struct vcmd_vhi_name_v0 vc_data;
18911 +       char *name;
18912 +
18913 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18914 +               return -EFAULT;
18915 +
18916 +       name = vx_vhi_name(vxi, vc_data.field);
18917 +       if (!name)
18918 +               return -EINVAL;
18919 +
18920 +       memcpy(name, vc_data.name, 65);
18921 +       return 0;
18922 +}
18923 +
18924 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
18925 +{
18926 +       struct vcmd_vhi_name_v0 vc_data;
18927 +       char *name;
18928 +
18929 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18930 +               return -EFAULT;
18931 +
18932 +       name = vx_vhi_name(vxi, vc_data.field);
18933 +       if (!name)
18934 +               return -EINVAL;
18935 +
18936 +       memcpy(vc_data.name, name, 65);
18937 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18938 +               return -EFAULT;
18939 +       return 0;
18940 +}
18941 +
18942 +
18943 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
18944 +{
18945 +       struct vcmd_virt_stat_v0 vc_data;
18946 +       struct _vx_cvirt *cvirt = &vxi->cvirt;
18947 +       struct timespec uptime;
18948 +
18949 +       do_posix_clock_monotonic_gettime(&uptime);
18950 +       set_normalized_timespec(&uptime,
18951 +               uptime.tv_sec - cvirt->bias_uptime.tv_sec,
18952 +               uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
18953 +
18954 +       vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
18955 +       vc_data.uptime = timespec_to_ns(&uptime);
18956 +       vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
18957 +       vc_data.nr_running = atomic_read(&cvirt->nr_running);
18958 +       vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
18959 +       vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
18960 +       vc_data.nr_forks = atomic_read(&cvirt->total_forks);
18961 +       vc_data.load[0] = cvirt->load[0];
18962 +       vc_data.load[1] = cvirt->load[1];
18963 +       vc_data.load[2] = cvirt->load[2];
18964 +
18965 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18966 +               return -EFAULT;
18967 +       return 0;
18968 +}
18969 +
18970 +
18971 +#ifdef CONFIG_VSERVER_VTIME
18972 +
18973 +/* virtualized time base */
18974 +
18975 +void vx_gettimeofday(struct timeval *tv)
18976 +{
18977 +       struct vx_info *vxi;
18978 +
18979 +       do_gettimeofday(tv);
18980 +       if (!vx_flags(VXF_VIRT_TIME, 0))
18981 +               return;
18982 +
18983 +       vxi = current_vx_info();
18984 +       tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
18985 +       tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
18986 +
18987 +       if (tv->tv_usec >= USEC_PER_SEC) {
18988 +               tv->tv_sec++;
18989 +               tv->tv_usec -= USEC_PER_SEC;
18990 +       } else if (tv->tv_usec < 0) {
18991 +               tv->tv_sec--;
18992 +               tv->tv_usec += USEC_PER_SEC;
18993 +       }
18994 +}
18995 +
18996 +int vx_settimeofday(struct timespec *ts)
18997 +{
18998 +       struct timeval tv;
18999 +       struct vx_info *vxi;
19000 +
19001 +       if (!vx_flags(VXF_VIRT_TIME, 0))
19002 +               return do_settimeofday(ts);
19003 +
19004 +       do_gettimeofday(&tv);
19005 +       vxi = current_vx_info();
19006 +       vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
19007 +       vxi->cvirt.bias_tv.tv_usec =
19008 +               (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
19009 +       return 0;
19010 +}
19011 +
19012 +#endif
19013 +
19014 diff -NurpP --minimal linux-2.6.34/kernel/vserver/cvirt_init.h linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cvirt_init.h
19015 --- linux-2.6.34/kernel/vserver/cvirt_init.h    1970-01-01 01:00:00.000000000 +0100
19016 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cvirt_init.h       2010-05-18 18:11:22.000000000 +0200
19017 @@ -0,0 +1,69 @@
19018 +
19019 +
19020 +extern uint64_t vx_idle_jiffies(void);
19021 +
19022 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19023 +{
19024 +       uint64_t idle_jiffies = vx_idle_jiffies();
19025 +       uint64_t nsuptime;
19026 +
19027 +       do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19028 +       nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19029 +               * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19030 +       cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19031 +       cvirt->bias_tv.tv_sec = 0;
19032 +       cvirt->bias_tv.tv_usec = 0;
19033 +
19034 +       jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19035 +       atomic_set(&cvirt->nr_threads, 0);
19036 +       atomic_set(&cvirt->nr_running, 0);
19037 +       atomic_set(&cvirt->nr_uninterruptible, 0);
19038 +       atomic_set(&cvirt->nr_onhold, 0);
19039 +
19040 +       spin_lock_init(&cvirt->load_lock);
19041 +       cvirt->load_last = jiffies;
19042 +       atomic_set(&cvirt->load_updates, 0);
19043 +       cvirt->load[0] = 0;
19044 +       cvirt->load[1] = 0;
19045 +       cvirt->load[2] = 0;
19046 +       atomic_set(&cvirt->total_forks, 0);
19047 +
19048 +       spin_lock_init(&cvirt->syslog.logbuf_lock);
19049 +       init_waitqueue_head(&cvirt->syslog.log_wait);
19050 +       cvirt->syslog.log_start = 0;
19051 +       cvirt->syslog.log_end = 0;
19052 +       cvirt->syslog.con_start = 0;
19053 +       cvirt->syslog.logged_chars = 0;
19054 +}
19055 +
19056 +static inline
19057 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19058 +{
19059 +       // cvirt_pc->cpustat = { 0 };
19060 +}
19061 +
19062 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19063 +{
19064 +       int value;
19065 +
19066 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19067 +               "!!! cvirt: %p[nr_threads] = %d on exit.",
19068 +               cvirt, value);
19069 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19070 +               "!!! cvirt: %p[nr_running] = %d on exit.",
19071 +               cvirt, value);
19072 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19073 +               "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19074 +               cvirt, value);
19075 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19076 +               "!!! cvirt: %p[nr_onhold] = %d on exit.",
19077 +               cvirt, value);
19078 +       return;
19079 +}
19080 +
19081 +static inline
19082 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19083 +{
19084 +       return;
19085 +}
19086 +
19087 diff -NurpP --minimal linux-2.6.34/kernel/vserver/cvirt_proc.h linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cvirt_proc.h
19088 --- linux-2.6.34/kernel/vserver/cvirt_proc.h    1970-01-01 01:00:00.000000000 +0100
19089 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/cvirt_proc.h       2010-05-18 18:11:22.000000000 +0200
19090 @@ -0,0 +1,135 @@
19091 +#ifndef _VX_CVIRT_PROC_H
19092 +#define _VX_CVIRT_PROC_H
19093 +
19094 +#include <linux/nsproxy.h>
19095 +#include <linux/mnt_namespace.h>
19096 +#include <linux/ipc_namespace.h>
19097 +#include <linux/utsname.h>
19098 +#include <linux/ipc.h>
19099 +
19100 +
19101 +static inline
19102 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19103 +{
19104 +       struct mnt_namespace *ns;
19105 +       struct uts_namespace *uts;
19106 +       struct ipc_namespace *ipc;
19107 +       struct path path;
19108 +       char *pstr, *root;
19109 +       int length = 0;
19110 +
19111 +       if (!nsproxy)
19112 +               goto out;
19113 +
19114 +       length += sprintf(buffer + length,
19115 +               "NSProxy:\t%p [%p,%p,%p]\n",
19116 +               nsproxy, nsproxy->mnt_ns,
19117 +               nsproxy->uts_ns, nsproxy->ipc_ns);
19118 +
19119 +       ns = nsproxy->mnt_ns;
19120 +       if (!ns)
19121 +               goto skip_ns;
19122 +
19123 +       pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19124 +       if (!pstr)
19125 +               goto skip_ns;
19126 +
19127 +       path.mnt = ns->root;
19128 +       path.dentry = ns->root->mnt_root;
19129 +       root = d_path(&path, pstr, PATH_MAX - 2);
19130 +       length += sprintf(buffer + length,
19131 +               "Namespace:\t%p [#%u]\n"
19132 +               "RootPath:\t%s\n",
19133 +               ns, atomic_read(&ns->count),
19134 +               root);
19135 +       kfree(pstr);
19136 +skip_ns:
19137 +
19138 +       uts = nsproxy->uts_ns;
19139 +       if (!uts)
19140 +               goto skip_uts;
19141 +
19142 +       length += sprintf(buffer + length,
19143 +               "SysName:\t%.*s\n"
19144 +               "NodeName:\t%.*s\n"
19145 +               "Release:\t%.*s\n"
19146 +               "Version:\t%.*s\n"
19147 +               "Machine:\t%.*s\n"
19148 +               "DomainName:\t%.*s\n",
19149 +               __NEW_UTS_LEN, uts->name.sysname,
19150 +               __NEW_UTS_LEN, uts->name.nodename,
19151 +               __NEW_UTS_LEN, uts->name.release,
19152 +               __NEW_UTS_LEN, uts->name.version,
19153 +               __NEW_UTS_LEN, uts->name.machine,
19154 +               __NEW_UTS_LEN, uts->name.domainname);
19155 +skip_uts:
19156 +
19157 +       ipc = nsproxy->ipc_ns;
19158 +       if (!ipc)
19159 +               goto skip_ipc;
19160 +
19161 +       length += sprintf(buffer + length,
19162 +               "SEMS:\t\t%d %d %d %d  %d\n"
19163 +               "MSG:\t\t%d %d %d\n"
19164 +               "SHM:\t\t%lu %lu  %d %d\n",
19165 +               ipc->sem_ctls[0], ipc->sem_ctls[1],
19166 +               ipc->sem_ctls[2], ipc->sem_ctls[3],
19167 +               ipc->used_sems,
19168 +               ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19169 +               (unsigned long)ipc->shm_ctlmax,
19170 +               (unsigned long)ipc->shm_ctlall,
19171 +               ipc->shm_ctlmni, ipc->shm_tot);
19172 +skip_ipc:
19173 +out:
19174 +       return length;
19175 +}
19176 +
19177 +
19178 +#include <linux/sched.h>
19179 +
19180 +#define LOAD_INT(x) ((x) >> FSHIFT)
19181 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19182 +
19183 +static inline
19184 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19185 +{
19186 +       int length = 0;
19187 +       int a, b, c;
19188 +
19189 +       length += sprintf(buffer + length,
19190 +               "BiasUptime:\t%lu.%02lu\n",
19191 +               (unsigned long)cvirt->bias_uptime.tv_sec,
19192 +               (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19193 +
19194 +       a = cvirt->load[0] + (FIXED_1 / 200);
19195 +       b = cvirt->load[1] + (FIXED_1 / 200);
19196 +       c = cvirt->load[2] + (FIXED_1 / 200);
19197 +       length += sprintf(buffer + length,
19198 +               "nr_threads:\t%d\n"
19199 +               "nr_running:\t%d\n"
19200 +               "nr_unintr:\t%d\n"
19201 +               "nr_onhold:\t%d\n"
19202 +               "load_updates:\t%d\n"
19203 +               "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19204 +               "total_forks:\t%d\n",
19205 +               atomic_read(&cvirt->nr_threads),
19206 +               atomic_read(&cvirt->nr_running),
19207 +               atomic_read(&cvirt->nr_uninterruptible),
19208 +               atomic_read(&cvirt->nr_onhold),
19209 +               atomic_read(&cvirt->load_updates),
19210 +               LOAD_INT(a), LOAD_FRAC(a),
19211 +               LOAD_INT(b), LOAD_FRAC(b),
19212 +               LOAD_INT(c), LOAD_FRAC(c),
19213 +               atomic_read(&cvirt->total_forks));
19214 +       return length;
19215 +}
19216 +
19217 +static inline
19218 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19219 +       char *buffer, int cpu)
19220 +{
19221 +       int length = 0;
19222 +       return length;
19223 +}
19224 +
19225 +#endif /* _VX_CVIRT_PROC_H */
19226 diff -NurpP --minimal linux-2.6.34/kernel/vserver/debug.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/debug.c
19227 --- linux-2.6.34/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
19228 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/debug.c    2010-05-18 18:11:22.000000000 +0200
19229 @@ -0,0 +1,32 @@
19230 +/*
19231 + *  kernel/vserver/debug.c
19232 + *
19233 + *  Copyright (C) 2005-2007 Herbert Pötzl
19234 + *
19235 + *  V0.01  vx_info dump support
19236 + *
19237 + */
19238 +
19239 +#include <linux/module.h>
19240 +
19241 +#include <linux/vserver/context.h>
19242 +
19243 +
19244 +void   dump_vx_info(struct vx_info *vxi, int level)
19245 +{
19246 +       printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19247 +               atomic_read(&vxi->vx_usecnt),
19248 +               atomic_read(&vxi->vx_tasks),
19249 +               vxi->vx_state);
19250 +       if (level > 0) {
19251 +               __dump_vx_limit(&vxi->limit);
19252 +               __dump_vx_sched(&vxi->sched);
19253 +               __dump_vx_cvirt(&vxi->cvirt);
19254 +               __dump_vx_cacct(&vxi->cacct);
19255 +       }
19256 +       printk("---\n");
19257 +}
19258 +
19259 +
19260 +EXPORT_SYMBOL_GPL(dump_vx_info);
19261 +
19262 diff -NurpP --minimal linux-2.6.34/kernel/vserver/device.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/device.c
19263 --- linux-2.6.34/kernel/vserver/device.c        1970-01-01 01:00:00.000000000 +0100
19264 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/device.c   2010-05-18 18:11:22.000000000 +0200
19265 @@ -0,0 +1,443 @@
19266 +/*
19267 + *  linux/kernel/vserver/device.c
19268 + *
19269 + *  Linux-VServer: Device Support
19270 + *
19271 + *  Copyright (C) 2006  Herbert Pötzl
19272 + *  Copyright (C) 2007  Daniel Hokka Zakrisson
19273 + *
19274 + *  V0.01  device mapping basics
19275 + *  V0.02  added defaults
19276 + *
19277 + */
19278 +
19279 +#include <linux/slab.h>
19280 +#include <linux/rcupdate.h>
19281 +#include <linux/fs.h>
19282 +#include <linux/namei.h>
19283 +#include <linux/hash.h>
19284 +
19285 +#include <asm/errno.h>
19286 +#include <asm/uaccess.h>
19287 +#include <linux/vserver/base.h>
19288 +#include <linux/vserver/debug.h>
19289 +#include <linux/vserver/context.h>
19290 +#include <linux/vserver/device.h>
19291 +#include <linux/vserver/device_cmd.h>
19292 +
19293 +
19294 +#define DMAP_HASH_BITS 4
19295 +
19296 +
19297 +struct vs_mapping {
19298 +       union {
19299 +               struct hlist_node hlist;
19300 +               struct list_head list;
19301 +       } u;
19302 +#define dm_hlist       u.hlist
19303 +#define dm_list                u.list
19304 +       xid_t xid;
19305 +       dev_t device;
19306 +       struct vx_dmap_target target;
19307 +};
19308 +
19309 +
19310 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19311 +
19312 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
19313 +
19314 +static struct vx_dmap_target dmap_defaults[2] = {
19315 +       { .flags = DATTR_OPEN },
19316 +       { .flags = DATTR_OPEN },
19317 +};
19318 +
19319 +
19320 +struct kmem_cache *dmap_cachep __read_mostly;
19321 +
19322 +int __init dmap_cache_init(void)
19323 +{
19324 +       dmap_cachep = kmem_cache_create("dmap_cache",
19325 +               sizeof(struct vs_mapping), 0,
19326 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19327 +       return 0;
19328 +}
19329 +
19330 +__initcall(dmap_cache_init);
19331 +
19332 +
19333 +static inline unsigned int __hashval(dev_t dev, int bits)
19334 +{
19335 +       return hash_long((unsigned long)dev, bits);
19336 +}
19337 +
19338 +
19339 +/*     __hash_mapping()
19340 + *     add the mapping to the hash table
19341 + */
19342 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19343 +{
19344 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19345 +       struct hlist_head *head, *hash = dmap_main_hash;
19346 +       int device = vdm->device;
19347 +
19348 +       spin_lock(hash_lock);
19349 +       vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19350 +               vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19351 +
19352 +       head = &hash[__hashval(device, DMAP_HASH_BITS)];
19353 +       hlist_add_head(&vdm->dm_hlist, head);
19354 +       spin_unlock(hash_lock);
19355 +}
19356 +
19357 +
19358 +static inline int __mode_to_default(umode_t mode)
19359 +{
19360 +       switch (mode) {
19361 +       case S_IFBLK:
19362 +               return 0;
19363 +       case S_IFCHR:
19364 +               return 1;
19365 +       default:
19366 +               BUG();
19367 +       }
19368 +}
19369 +
19370 +
19371 +/*     __set_default()
19372 + *     set a default
19373 + */
19374 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19375 +       struct vx_dmap_target *vdmt)
19376 +{
19377 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19378 +       spin_lock(hash_lock);
19379 +
19380 +       if (vxi)
19381 +               vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19382 +       else
19383 +               dmap_defaults[__mode_to_default(mode)] = *vdmt;
19384 +
19385 +
19386 +       spin_unlock(hash_lock);
19387 +
19388 +       vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19389 +                 vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19390 +}
19391 +
19392 +
19393 +/*     __remove_default()
19394 + *     remove a default
19395 + */
19396 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19397 +{
19398 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19399 +       spin_lock(hash_lock);
19400 +
19401 +       if (vxi)
19402 +               vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19403 +       else    /* remove == reset */
19404 +               dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19405 +
19406 +       spin_unlock(hash_lock);
19407 +       return 0;
19408 +}
19409 +
19410 +
19411 +/*     __find_mapping()
19412 + *     find a mapping in the hash table
19413 + *
19414 + *     caller must hold hash_lock
19415 + */
19416 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19417 +       struct vs_mapping **local, struct vs_mapping **global)
19418 +{
19419 +       struct hlist_head *hash = dmap_main_hash;
19420 +       struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19421 +       struct hlist_node *pos;
19422 +       struct vs_mapping *vdm;
19423 +
19424 +       *local = NULL;
19425 +       if (global)
19426 +               *global = NULL;
19427 +
19428 +       hlist_for_each(pos, head) {
19429 +               vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19430 +
19431 +               if ((vdm->device == device) &&
19432 +                       !((vdm->target.flags ^ mode) & S_IFMT)) {
19433 +                       if (vdm->xid == xid) {
19434 +                               *local = vdm;
19435 +                               return 1;
19436 +                       } else if (global && vdm->xid == 0)
19437 +                               *global = vdm;
19438 +               }
19439 +       }
19440 +
19441 +       if (global && *global)
19442 +               return 0;
19443 +       else
19444 +               return -ENOENT;
19445 +}
19446 +
19447 +
19448 +/*     __lookup_mapping()
19449 + *     find a mapping and store the result in target and flags
19450 + */
19451 +static inline int __lookup_mapping(struct vx_info *vxi,
19452 +       dev_t device, dev_t *target, int *flags, umode_t mode)
19453 +{
19454 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19455 +       struct vs_mapping *vdm, *global;
19456 +       struct vx_dmap_target *vdmt;
19457 +       int ret = 0;
19458 +       xid_t xid = vxi->vx_id;
19459 +       int index;
19460 +
19461 +       spin_lock(hash_lock);
19462 +       if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19463 +               ret = 1;
19464 +               vdmt = &vdm->target;
19465 +               goto found;
19466 +       }
19467 +
19468 +       index = __mode_to_default(mode);
19469 +       if (vxi && vxi->dmap.targets[index].flags) {
19470 +               ret = 2;
19471 +               vdmt = &vxi->dmap.targets[index];
19472 +       } else if (global) {
19473 +               ret = 3;
19474 +               vdmt = &global->target;
19475 +               goto found;
19476 +       } else {
19477 +               ret = 4;
19478 +               vdmt = &dmap_defaults[index];
19479 +       }
19480 +
19481 +found:
19482 +       if (target && (vdmt->flags & DATTR_REMAP))
19483 +               *target = vdmt->target;
19484 +       else if (target)
19485 +               *target = device;
19486 +       if (flags)
19487 +               *flags = vdmt->flags;
19488 +
19489 +       spin_unlock(hash_lock);
19490 +
19491 +       return ret;
19492 +}
19493 +
19494 +
19495 +/*     __remove_mapping()
19496 + *     remove a mapping from the hash table
19497 + */
19498 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19499 +       umode_t mode)
19500 +{
19501 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19502 +       struct vs_mapping *vdm = NULL;
19503 +       int ret = 0;
19504 +
19505 +       spin_lock(hash_lock);
19506 +
19507 +       ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19508 +               NULL);
19509 +       vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19510 +               vxi, vxi ? vxi->vx_id : 0, device, mode);
19511 +       if (ret < 0)
19512 +               goto out;
19513 +       hlist_del(&vdm->dm_hlist);
19514 +
19515 +out:
19516 +       spin_unlock(hash_lock);
19517 +       if (vdm)
19518 +               kmem_cache_free(dmap_cachep, vdm);
19519 +       return ret;
19520 +}
19521 +
19522 +
19523 +
19524 +int vs_map_device(struct vx_info *vxi,
19525 +       dev_t device, dev_t *target, umode_t mode)
19526 +{
19527 +       int ret, flags = DATTR_MASK;
19528 +
19529 +       if (!vxi) {
19530 +               if (target)
19531 +                       *target = device;
19532 +               goto out;
19533 +       }
19534 +       ret = __lookup_mapping(vxi, device, target, &flags, mode);
19535 +       vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19536 +               device, target ? *target : 0, flags, mode, ret);
19537 +out:
19538 +       return (flags & DATTR_MASK);
19539 +}
19540 +
19541 +
19542 +
19543 +static int do_set_mapping(struct vx_info *vxi,
19544 +       dev_t device, dev_t target, int flags, umode_t mode)
19545 +{
19546 +       if (device) {
19547 +               struct vs_mapping *new;
19548 +
19549 +               new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19550 +               if (!new)
19551 +                       return -ENOMEM;
19552 +
19553 +               INIT_HLIST_NODE(&new->dm_hlist);
19554 +               new->device = device;
19555 +               new->target.target = target;
19556 +               new->target.flags = flags | mode;
19557 +               new->xid = (vxi ? vxi->vx_id : 0);
19558 +
19559 +               vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19560 +               __hash_mapping(vxi, new);
19561 +       } else {
19562 +               struct vx_dmap_target new = {
19563 +                       .target = target,
19564 +                       .flags = flags | mode,
19565 +               };
19566 +               __set_default(vxi, mode, &new);
19567 +       }
19568 +       return 0;
19569 +}
19570 +
19571 +
19572 +static int do_unset_mapping(struct vx_info *vxi,
19573 +       dev_t device, dev_t target, int flags, umode_t mode)
19574 +{
19575 +       int ret = -EINVAL;
19576 +
19577 +       if (device) {
19578 +               ret = __remove_mapping(vxi, device, mode);
19579 +               if (ret < 0)
19580 +                       goto out;
19581 +       } else {
19582 +               ret = __remove_default(vxi, mode);
19583 +               if (ret < 0)
19584 +                       goto out;
19585 +       }
19586 +
19587 +out:
19588 +       return ret;
19589 +}
19590 +
19591 +
19592 +static inline int __user_device(const char __user *name, dev_t *dev,
19593 +       umode_t *mode)
19594 +{
19595 +       struct nameidata nd;
19596 +       int ret;
19597 +
19598 +       if (!name) {
19599 +               *dev = 0;
19600 +               return 0;
19601 +       }
19602 +       ret = user_lpath(name, &nd.path);
19603 +       if (ret)
19604 +               return ret;
19605 +       if (nd.path.dentry->d_inode) {
19606 +               *dev = nd.path.dentry->d_inode->i_rdev;
19607 +               *mode = nd.path.dentry->d_inode->i_mode;
19608 +       }
19609 +       path_put(&nd.path);
19610 +       return 0;
19611 +}
19612 +
19613 +static inline int __mapping_mode(dev_t device, dev_t target,
19614 +       umode_t device_mode, umode_t target_mode, umode_t *mode)
19615 +{
19616 +       if (device)
19617 +               *mode = device_mode & S_IFMT;
19618 +       else if (target)
19619 +               *mode = target_mode & S_IFMT;
19620 +       else
19621 +               return -EINVAL;
19622 +
19623 +       /* if both given, device and target mode have to match */
19624 +       if (device && target &&
19625 +               ((device_mode ^ target_mode) & S_IFMT))
19626 +               return -EINVAL;
19627 +       return 0;
19628 +}
19629 +
19630 +
19631 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19632 +       const char __user *target_path, int flags, int set)
19633 +{
19634 +       dev_t device = ~0, target = ~0;
19635 +       umode_t device_mode = 0, target_mode = 0, mode;
19636 +       int ret;
19637 +
19638 +       ret = __user_device(device_path, &device, &device_mode);
19639 +       if (ret)
19640 +               return ret;
19641 +       ret = __user_device(target_path, &target, &target_mode);
19642 +       if (ret)
19643 +               return ret;
19644 +
19645 +       ret = __mapping_mode(device, target,
19646 +               device_mode, target_mode, &mode);
19647 +       if (ret)
19648 +               return ret;
19649 +
19650 +       if (set)
19651 +               return do_set_mapping(vxi, device, target,
19652 +                       flags, mode);
19653 +       else
19654 +               return do_unset_mapping(vxi, device, target,
19655 +                       flags, mode);
19656 +}
19657 +
19658 +
19659 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19660 +{
19661 +       struct vcmd_set_mapping_v0 vc_data;
19662 +
19663 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19664 +               return -EFAULT;
19665 +
19666 +       return do_mapping(vxi, vc_data.device, vc_data.target,
19667 +               vc_data.flags, 1);
19668 +}
19669 +
19670 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19671 +{
19672 +       struct vcmd_set_mapping_v0 vc_data;
19673 +
19674 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19675 +               return -EFAULT;
19676 +
19677 +       return do_mapping(vxi, vc_data.device, vc_data.target,
19678 +               vc_data.flags, 0);
19679 +}
19680 +
19681 +
19682 +#ifdef CONFIG_COMPAT
19683 +
19684 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19685 +{
19686 +       struct vcmd_set_mapping_v0_x32 vc_data;
19687 +
19688 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19689 +               return -EFAULT;
19690 +
19691 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19692 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19693 +}
19694 +
19695 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19696 +{
19697 +       struct vcmd_set_mapping_v0_x32 vc_data;
19698 +
19699 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19700 +               return -EFAULT;
19701 +
19702 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19703 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19704 +}
19705 +
19706 +#endif /* CONFIG_COMPAT */
19707 +
19708 +
19709 diff -NurpP --minimal linux-2.6.34/kernel/vserver/dlimit.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/dlimit.c
19710 --- linux-2.6.34/kernel/vserver/dlimit.c        1970-01-01 01:00:00.000000000 +0100
19711 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/dlimit.c   2010-05-19 01:45:32.000000000 +0200
19712 @@ -0,0 +1,531 @@
19713 +/*
19714 + *  linux/kernel/vserver/dlimit.c
19715 + *
19716 + *  Virtual Server: Context Disk Limits
19717 + *
19718 + *  Copyright (C) 2004-2009  Herbert Pötzl
19719 + *
19720 + *  V0.01  initial version
19721 + *  V0.02  compat32 splitup
19722 + *  V0.03  extended interface
19723 + *
19724 + */
19725 +
19726 +#include <linux/statfs.h>
19727 +#include <linux/sched.h>
19728 +#include <linux/namei.h>
19729 +#include <linux/vs_tag.h>
19730 +#include <linux/vs_dlimit.h>
19731 +#include <linux/vserver/dlimit_cmd.h>
19732 +#include <linux/slab.h>
19733 +// #include <linux/gfp.h>
19734 +
19735 +#include <asm/uaccess.h>
19736 +
19737 +/*     __alloc_dl_info()
19738 +
19739 +       * allocate an initialized dl_info struct
19740 +       * doesn't make it visible (hash)                        */
19741 +
19742 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19743 +{
19744 +       struct dl_info *new = NULL;
19745 +
19746 +       vxdprintk(VXD_CBIT(dlim, 5),
19747 +               "alloc_dl_info(%p,%d)*", sb, tag);
19748 +
19749 +       /* would this benefit from a slab cache? */
19750 +       new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19751 +       if (!new)
19752 +               return 0;
19753 +
19754 +       memset(new, 0, sizeof(struct dl_info));
19755 +       new->dl_tag = tag;
19756 +       new->dl_sb = sb;
19757 +       INIT_RCU_HEAD(&new->dl_rcu);
19758 +       INIT_HLIST_NODE(&new->dl_hlist);
19759 +       spin_lock_init(&new->dl_lock);
19760 +       atomic_set(&new->dl_refcnt, 0);
19761 +       atomic_set(&new->dl_usecnt, 0);
19762 +
19763 +       /* rest of init goes here */
19764 +
19765 +       vxdprintk(VXD_CBIT(dlim, 4),
19766 +               "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19767 +       return new;
19768 +}
19769 +
19770 +/*     __dealloc_dl_info()
19771 +
19772 +       * final disposal of dl_info                             */
19773 +
19774 +static void __dealloc_dl_info(struct dl_info *dli)
19775 +{
19776 +       vxdprintk(VXD_CBIT(dlim, 4),
19777 +               "dealloc_dl_info(%p)", dli);
19778 +
19779 +       dli->dl_hlist.next = LIST_POISON1;
19780 +       dli->dl_tag = -1;
19781 +       dli->dl_sb = 0;
19782 +
19783 +       BUG_ON(atomic_read(&dli->dl_usecnt));
19784 +       BUG_ON(atomic_read(&dli->dl_refcnt));
19785 +
19786 +       kfree(dli);
19787 +}
19788 +
19789 +
19790 +/*     hash table for dl_info hash */
19791 +
19792 +#define DL_HASH_SIZE   13
19793 +
19794 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19795 +
19796 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
19797 +
19798 +
19799 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19800 +{
19801 +       return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19802 +}
19803 +
19804 +
19805 +
19806 +/*     __hash_dl_info()
19807 +
19808 +       * add the dli to the global hash table
19809 +       * requires the hash_lock to be held                     */
19810 +
19811 +static inline void __hash_dl_info(struct dl_info *dli)
19812 +{
19813 +       struct hlist_head *head;
19814 +
19815 +       vxdprintk(VXD_CBIT(dlim, 6),
19816 +               "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19817 +       get_dl_info(dli);
19818 +       head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19819 +       hlist_add_head_rcu(&dli->dl_hlist, head);
19820 +}
19821 +
19822 +/*     __unhash_dl_info()
19823 +
19824 +       * remove the dli from the global hash table
19825 +       * requires the hash_lock to be held                     */
19826 +
19827 +static inline void __unhash_dl_info(struct dl_info *dli)
19828 +{
19829 +       vxdprintk(VXD_CBIT(dlim, 6),
19830 +               "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19831 +       hlist_del_rcu(&dli->dl_hlist);
19832 +       put_dl_info(dli);
19833 +}
19834 +
19835 +
19836 +/*     __lookup_dl_info()
19837 +
19838 +       * requires the rcu_read_lock()
19839 +       * doesn't increment the dl_refcnt                       */
19840 +
19841 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19842 +{
19843 +       struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19844 +       struct hlist_node *pos;
19845 +       struct dl_info *dli;
19846 +
19847 +       hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19848 +
19849 +               if (dli->dl_tag == tag && dli->dl_sb == sb) {
19850 +                       return dli;
19851 +               }
19852 +       }
19853 +       return NULL;
19854 +}
19855 +
19856 +
19857 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19858 +{
19859 +       struct dl_info *dli;
19860 +
19861 +       rcu_read_lock();
19862 +       dli = get_dl_info(__lookup_dl_info(sb, tag));
19863 +       vxdprintk(VXD_CBIT(dlim, 7),
19864 +               "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19865 +       rcu_read_unlock();
19866 +       return dli;
19867 +}
19868 +
19869 +void rcu_free_dl_info(struct rcu_head *head)
19870 +{
19871 +       struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19872 +       int usecnt, refcnt;
19873 +
19874 +       BUG_ON(!dli || !head);
19875 +
19876 +       usecnt = atomic_read(&dli->dl_usecnt);
19877 +       BUG_ON(usecnt < 0);
19878 +
19879 +       refcnt = atomic_read(&dli->dl_refcnt);
19880 +       BUG_ON(refcnt < 0);
19881 +
19882 +       vxdprintk(VXD_CBIT(dlim, 3),
19883 +               "rcu_free_dl_info(%p)", dli);
19884 +       if (!usecnt)
19885 +               __dealloc_dl_info(dli);
19886 +       else
19887 +               printk("!!! rcu didn't free\n");
19888 +}
19889 +
19890 +
19891 +
19892 +
19893 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
19894 +       uint32_t flags, int add)
19895 +{
19896 +       struct path path;
19897 +       int ret;
19898 +
19899 +       ret = user_lpath(name, &path);
19900 +       if (!ret) {
19901 +               struct super_block *sb;
19902 +               struct dl_info *dli;
19903 +
19904 +               ret = -EINVAL;
19905 +               if (!path.dentry->d_inode)
19906 +                       goto out_release;
19907 +               if (!(sb = path.dentry->d_inode->i_sb))
19908 +                       goto out_release;
19909 +
19910 +               if (add) {
19911 +                       dli = __alloc_dl_info(sb, id);
19912 +                       spin_lock(&dl_info_hash_lock);
19913 +
19914 +                       ret = -EEXIST;
19915 +                       if (__lookup_dl_info(sb, id))
19916 +                               goto out_unlock;
19917 +                       __hash_dl_info(dli);
19918 +                       dli = NULL;
19919 +               } else {
19920 +                       spin_lock(&dl_info_hash_lock);
19921 +                       dli = __lookup_dl_info(sb, id);
19922 +
19923 +                       ret = -ESRCH;
19924 +                       if (!dli)
19925 +                               goto out_unlock;
19926 +                       __unhash_dl_info(dli);
19927 +               }
19928 +               ret = 0;
19929 +       out_unlock:
19930 +               spin_unlock(&dl_info_hash_lock);
19931 +               if (add && dli)
19932 +                       __dealloc_dl_info(dli);
19933 +       out_release:
19934 +               path_put(&path);
19935 +       }
19936 +       return ret;
19937 +}
19938 +
19939 +int vc_add_dlimit(uint32_t id, void __user *data)
19940 +{
19941 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
19942 +
19943 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19944 +               return -EFAULT;
19945 +
19946 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
19947 +}
19948 +
19949 +int vc_rem_dlimit(uint32_t id, void __user *data)
19950 +{
19951 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
19952 +
19953 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19954 +               return -EFAULT;
19955 +
19956 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
19957 +}
19958 +
19959 +#ifdef CONFIG_COMPAT
19960 +
19961 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
19962 +{
19963 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19964 +
19965 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19966 +               return -EFAULT;
19967 +
19968 +       return do_addrem_dlimit(id,
19969 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
19970 +}
19971 +
19972 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
19973 +{
19974 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
19975 +
19976 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19977 +               return -EFAULT;
19978 +
19979 +       return do_addrem_dlimit(id,
19980 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
19981 +}
19982 +
19983 +#endif /* CONFIG_COMPAT */
19984 +
19985 +
19986 +static inline
19987 +int do_set_dlimit(uint32_t id, const char __user *name,
19988 +       uint32_t space_used, uint32_t space_total,
19989 +       uint32_t inodes_used, uint32_t inodes_total,
19990 +       uint32_t reserved, uint32_t flags)
19991 +{
19992 +       struct path path;
19993 +       int ret;
19994 +
19995 +       ret = user_lpath(name, &path);
19996 +       if (!ret) {
19997 +               struct super_block *sb;
19998 +               struct dl_info *dli;
19999 +
20000 +               ret = -EINVAL;
20001 +               if (!path.dentry->d_inode)
20002 +                       goto out_release;
20003 +               if (!(sb = path.dentry->d_inode->i_sb))
20004 +                       goto out_release;
20005 +
20006 +               /* sanity checks */
20007 +               if ((reserved != CDLIM_KEEP &&
20008 +                       reserved > 100) ||
20009 +                       (inodes_used != CDLIM_KEEP &&
20010 +                       inodes_used > inodes_total) ||
20011 +                       (space_used != CDLIM_KEEP &&
20012 +                       space_used > space_total))
20013 +                       goto out_release;
20014 +
20015 +               ret = -ESRCH;
20016 +               dli = locate_dl_info(sb, id);
20017 +               if (!dli)
20018 +                       goto out_release;
20019 +
20020 +               spin_lock(&dli->dl_lock);
20021 +
20022 +               if (inodes_used != CDLIM_KEEP)
20023 +                       dli->dl_inodes_used = inodes_used;
20024 +               if (inodes_total != CDLIM_KEEP)
20025 +                       dli->dl_inodes_total = inodes_total;
20026 +               if (space_used != CDLIM_KEEP)
20027 +                       dli->dl_space_used = dlimit_space_32to64(
20028 +                               space_used, flags, DLIMS_USED);
20029 +
20030 +               if (space_total == CDLIM_INFINITY)
20031 +                       dli->dl_space_total = DLIM_INFINITY;
20032 +               else if (space_total != CDLIM_KEEP)
20033 +                       dli->dl_space_total = dlimit_space_32to64(
20034 +                               space_total, flags, DLIMS_TOTAL);
20035 +
20036 +               if (reserved != CDLIM_KEEP)
20037 +                       dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20038 +
20039 +               spin_unlock(&dli->dl_lock);
20040 +
20041 +               put_dl_info(dli);
20042 +               ret = 0;
20043 +
20044 +       out_release:
20045 +               path_put(&path);
20046 +       }
20047 +       return ret;
20048 +}
20049 +
20050 +int vc_set_dlimit(uint32_t id, void __user *data)
20051 +{
20052 +       struct vcmd_ctx_dlimit_v0 vc_data;
20053 +
20054 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20055 +               return -EFAULT;
20056 +
20057 +       return do_set_dlimit(id, vc_data.name,
20058 +               vc_data.space_used, vc_data.space_total,
20059 +               vc_data.inodes_used, vc_data.inodes_total,
20060 +               vc_data.reserved, vc_data.flags);
20061 +}
20062 +
20063 +#ifdef CONFIG_COMPAT
20064 +
20065 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20066 +{
20067 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20068 +
20069 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20070 +               return -EFAULT;
20071 +
20072 +       return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20073 +               vc_data.space_used, vc_data.space_total,
20074 +               vc_data.inodes_used, vc_data.inodes_total,
20075 +               vc_data.reserved, vc_data.flags);
20076 +}
20077 +
20078 +#endif /* CONFIG_COMPAT */
20079 +
20080 +
20081 +static inline
20082 +int do_get_dlimit(uint32_t id, const char __user *name,
20083 +       uint32_t *space_used, uint32_t *space_total,
20084 +       uint32_t *inodes_used, uint32_t *inodes_total,
20085 +       uint32_t *reserved, uint32_t *flags)
20086 +{
20087 +       struct path path;
20088 +       int ret;
20089 +
20090 +       ret = user_lpath(name, &path);
20091 +       if (!ret) {
20092 +               struct super_block *sb;
20093 +               struct dl_info *dli;
20094 +
20095 +               ret = -EINVAL;
20096 +               if (!path.dentry->d_inode)
20097 +                       goto out_release;
20098 +               if (!(sb = path.dentry->d_inode->i_sb))
20099 +                       goto out_release;
20100 +
20101 +               ret = -ESRCH;
20102 +               dli = locate_dl_info(sb, id);
20103 +               if (!dli)
20104 +                       goto out_release;
20105 +
20106 +               spin_lock(&dli->dl_lock);
20107 +               *inodes_used = dli->dl_inodes_used;
20108 +               *inodes_total = dli->dl_inodes_total;
20109 +
20110 +               *space_used = dlimit_space_64to32(
20111 +                       dli->dl_space_used, flags, DLIMS_USED);
20112 +
20113 +               if (dli->dl_space_total == DLIM_INFINITY)
20114 +                       *space_total = CDLIM_INFINITY;
20115 +               else
20116 +                       *space_total = dlimit_space_64to32(
20117 +                               dli->dl_space_total, flags, DLIMS_TOTAL);
20118 +
20119 +               *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20120 +               spin_unlock(&dli->dl_lock);
20121 +
20122 +               put_dl_info(dli);
20123 +               ret = -EFAULT;
20124 +
20125 +               ret = 0;
20126 +       out_release:
20127 +               path_put(&path);
20128 +       }
20129 +       return ret;
20130 +}
20131 +
20132 +
20133 +int vc_get_dlimit(uint32_t id, void __user *data)
20134 +{
20135 +       struct vcmd_ctx_dlimit_v0 vc_data;
20136 +       int ret;
20137 +
20138 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20139 +               return -EFAULT;
20140 +
20141 +       ret = do_get_dlimit(id, vc_data.name,
20142 +               &vc_data.space_used, &vc_data.space_total,
20143 +               &vc_data.inodes_used, &vc_data.inodes_total,
20144 +               &vc_data.reserved, &vc_data.flags);
20145 +       if (ret)
20146 +               return ret;
20147 +
20148 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20149 +               return -EFAULT;
20150 +       return 0;
20151 +}
20152 +
20153 +#ifdef CONFIG_COMPAT
20154 +
20155 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20156 +{
20157 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20158 +       int ret;
20159 +
20160 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20161 +               return -EFAULT;
20162 +
20163 +       ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20164 +               &vc_data.space_used, &vc_data.space_total,
20165 +               &vc_data.inodes_used, &vc_data.inodes_total,
20166 +               &vc_data.reserved, &vc_data.flags);
20167 +       if (ret)
20168 +               return ret;
20169 +
20170 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20171 +               return -EFAULT;
20172 +       return 0;
20173 +}
20174 +
20175 +#endif /* CONFIG_COMPAT */
20176 +
20177 +
20178 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20179 +{
20180 +       struct dl_info *dli;
20181 +       __u64 blimit, bfree, bavail;
20182 +       __u32 ifree;
20183 +
20184 +       dli = locate_dl_info(sb, dx_current_tag());
20185 +       if (!dli)
20186 +               return;
20187 +
20188 +       spin_lock(&dli->dl_lock);
20189 +       if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20190 +               goto no_ilim;
20191 +
20192 +       /* reduce max inodes available to limit */
20193 +       if (buf->f_files > dli->dl_inodes_total)
20194 +               buf->f_files = dli->dl_inodes_total;
20195 +
20196 +       ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20197 +       /* reduce free inodes to min */
20198 +       if (ifree < buf->f_ffree)
20199 +               buf->f_ffree = ifree;
20200 +
20201 +no_ilim:
20202 +       if (dli->dl_space_total == DLIM_INFINITY)
20203 +               goto no_blim;
20204 +
20205 +       blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20206 +
20207 +       if (dli->dl_space_total < dli->dl_space_used)
20208 +               bfree = 0;
20209 +       else
20210 +               bfree = (dli->dl_space_total - dli->dl_space_used)
20211 +                       >> sb->s_blocksize_bits;
20212 +
20213 +       bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20214 +       if (bavail < dli->dl_space_used)
20215 +               bavail = 0;
20216 +       else
20217 +               bavail = (bavail - dli->dl_space_used)
20218 +                       >> sb->s_blocksize_bits;
20219 +
20220 +       /* reduce max space available to limit */
20221 +       if (buf->f_blocks > blimit)
20222 +               buf->f_blocks = blimit;
20223 +
20224 +       /* reduce free space to min */
20225 +       if (bfree < buf->f_bfree)
20226 +               buf->f_bfree = bfree;
20227 +
20228 +       /* reduce avail space to min */
20229 +       if (bavail < buf->f_bavail)
20230 +               buf->f_bavail = bavail;
20231 +
20232 +no_blim:
20233 +       spin_unlock(&dli->dl_lock);
20234 +       put_dl_info(dli);
20235 +
20236 +       return;
20237 +}
20238 +
20239 +#include <linux/module.h>
20240 +
20241 +EXPORT_SYMBOL_GPL(locate_dl_info);
20242 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20243 +
20244 diff -NurpP --minimal linux-2.6.34/kernel/vserver/helper.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/helper.c
20245 --- linux-2.6.34/kernel/vserver/helper.c        1970-01-01 01:00:00.000000000 +0100
20246 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/helper.c   2010-05-18 18:11:22.000000000 +0200
20247 @@ -0,0 +1,223 @@
20248 +/*
20249 + *  linux/kernel/vserver/helper.c
20250 + *
20251 + *  Virtual Context Support
20252 + *
20253 + *  Copyright (C) 2004-2007  Herbert Pötzl
20254 + *
20255 + *  V0.01  basic helper
20256 + *
20257 + */
20258 +
20259 +#include <linux/kmod.h>
20260 +#include <linux/reboot.h>
20261 +#include <linux/vs_context.h>
20262 +#include <linux/vs_network.h>
20263 +#include <linux/vserver/signal.h>
20264 +
20265 +
20266 +char vshelper_path[255] = "/sbin/vshelper";
20267 +
20268 +
20269 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20270 +{
20271 +       int ret;
20272 +
20273 +       if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20274 +               printk( KERN_WARNING
20275 +                       "%s: (%s %s) returned %s with %d\n",
20276 +                       name, argv[1], argv[2],
20277 +                       sync ? "sync" : "async", ret);
20278 +       }
20279 +       vxdprintk(VXD_CBIT(switch, 4),
20280 +               "%s: (%s %s) returned %s with %d",
20281 +               name, argv[1], argv[2], sync ? "sync" : "async", ret);
20282 +       return ret;
20283 +}
20284 +
20285 +/*
20286 + *      vshelper path is set via /proc/sys
20287 + *      invoked by vserver sys_reboot(), with
20288 + *      the following arguments
20289 + *
20290 + *      argv [0] = vshelper_path;
20291 + *      argv [1] = action: "restart", "halt", "poweroff", ...
20292 + *      argv [2] = context identifier
20293 + *
20294 + *      envp [*] = type-specific parameters
20295 + */
20296 +
20297 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20298 +{
20299 +       char id_buf[8], cmd_buf[16];
20300 +       char uid_buf[16], pid_buf[16];
20301 +       int ret;
20302 +
20303 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20304 +       char *envp[] = {"HOME=/", "TERM=linux",
20305 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20306 +                       uid_buf, pid_buf, cmd_buf, 0};
20307 +
20308 +       if (vx_info_state(vxi, VXS_HELPER))
20309 +               return -EAGAIN;
20310 +       vxi->vx_state |= VXS_HELPER;
20311 +
20312 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20313 +
20314 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20315 +       snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20316 +       snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20317 +
20318 +       switch (cmd) {
20319 +       case LINUX_REBOOT_CMD_RESTART:
20320 +               argv[1] = "restart";
20321 +               break;
20322 +
20323 +       case LINUX_REBOOT_CMD_HALT:
20324 +               argv[1] = "halt";
20325 +               break;
20326 +
20327 +       case LINUX_REBOOT_CMD_POWER_OFF:
20328 +               argv[1] = "poweroff";
20329 +               break;
20330 +
20331 +       case LINUX_REBOOT_CMD_SW_SUSPEND:
20332 +               argv[1] = "swsusp";
20333 +               break;
20334 +
20335 +       case LINUX_REBOOT_CMD_OOM:
20336 +               argv[1] = "oom";
20337 +               break;
20338 +
20339 +       default:
20340 +               vxi->vx_state &= ~VXS_HELPER;
20341 +               return 0;
20342 +       }
20343 +
20344 +       ret = do_vshelper(vshelper_path, argv, envp, 0);
20345 +       vxi->vx_state &= ~VXS_HELPER;
20346 +       __wakeup_vx_info(vxi);
20347 +       return (ret) ? -EPERM : 0;
20348 +}
20349 +
20350 +
20351 +long vs_reboot(unsigned int cmd, void __user *arg)
20352 +{
20353 +       struct vx_info *vxi = current_vx_info();
20354 +       long ret = 0;
20355 +
20356 +       vxdprintk(VXD_CBIT(misc, 5),
20357 +               "vs_reboot(%p[#%d],%u)",
20358 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20359 +
20360 +       ret = vs_reboot_helper(vxi, cmd, arg);
20361 +       if (ret)
20362 +               return ret;
20363 +
20364 +       vxi->reboot_cmd = cmd;
20365 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20366 +               switch (cmd) {
20367 +               case LINUX_REBOOT_CMD_RESTART:
20368 +               case LINUX_REBOOT_CMD_HALT:
20369 +               case LINUX_REBOOT_CMD_POWER_OFF:
20370 +                       vx_info_kill(vxi, 0, SIGKILL);
20371 +                       vx_info_kill(vxi, 1, SIGKILL);
20372 +               default:
20373 +                       break;
20374 +               }
20375 +       }
20376 +       return 0;
20377 +}
20378 +
20379 +long vs_oom_action(unsigned int cmd)
20380 +{
20381 +       struct vx_info *vxi = current_vx_info();
20382 +       long ret = 0;
20383 +
20384 +       vxdprintk(VXD_CBIT(misc, 5),
20385 +               "vs_oom_action(%p[#%d],%u)",
20386 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20387 +
20388 +       ret = vs_reboot_helper(vxi, cmd, NULL);
20389 +       if (ret)
20390 +               return ret;
20391 +
20392 +       vxi->reboot_cmd = cmd;
20393 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20394 +               vx_info_kill(vxi, 0, SIGKILL);
20395 +               vx_info_kill(vxi, 1, SIGKILL);
20396 +       }
20397 +       return 0;
20398 +}
20399 +
20400 +/*
20401 + *      argv [0] = vshelper_path;
20402 + *      argv [1] = action: "startup", "shutdown"
20403 + *      argv [2] = context identifier
20404 + *
20405 + *      envp [*] = type-specific parameters
20406 + */
20407 +
20408 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20409 +{
20410 +       char id_buf[8], cmd_buf[16];
20411 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20412 +       char *envp[] = {"HOME=/", "TERM=linux",
20413 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20414 +
20415 +       if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20416 +               return 0;
20417 +
20418 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20419 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20420 +
20421 +       switch (cmd) {
20422 +       case VSC_STARTUP:
20423 +               argv[1] = "startup";
20424 +               break;
20425 +       case VSC_SHUTDOWN:
20426 +               argv[1] = "shutdown";
20427 +               break;
20428 +       default:
20429 +               return 0;
20430 +       }
20431 +
20432 +       return do_vshelper(vshelper_path, argv, envp, 1);
20433 +}
20434 +
20435 +
20436 +/*
20437 + *      argv [0] = vshelper_path;
20438 + *      argv [1] = action: "netup", "netdown"
20439 + *      argv [2] = context identifier
20440 + *
20441 + *      envp [*] = type-specific parameters
20442 + */
20443 +
20444 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20445 +{
20446 +       char id_buf[8], cmd_buf[16];
20447 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20448 +       char *envp[] = {"HOME=/", "TERM=linux",
20449 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20450 +
20451 +       if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20452 +               return 0;
20453 +
20454 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20455 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20456 +
20457 +       switch (cmd) {
20458 +       case VSC_NETUP:
20459 +               argv[1] = "netup";
20460 +               break;
20461 +       case VSC_NETDOWN:
20462 +               argv[1] = "netdown";
20463 +               break;
20464 +       default:
20465 +               return 0;
20466 +       }
20467 +
20468 +       return do_vshelper(vshelper_path, argv, envp, 1);
20469 +}
20470 +
20471 diff -NurpP --minimal linux-2.6.34/kernel/vserver/history.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/history.c
20472 --- linux-2.6.34/kernel/vserver/history.c       1970-01-01 01:00:00.000000000 +0100
20473 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/history.c  2010-05-18 18:11:22.000000000 +0200
20474 @@ -0,0 +1,258 @@
20475 +/*
20476 + *  kernel/vserver/history.c
20477 + *
20478 + *  Virtual Context History Backtrace
20479 + *
20480 + *  Copyright (C) 2004-2007  Herbert Pötzl
20481 + *
20482 + *  V0.01  basic structure
20483 + *  V0.02  hash/unhash and trace
20484 + *  V0.03  preemption fixes
20485 + *
20486 + */
20487 +
20488 +#include <linux/module.h>
20489 +#include <asm/uaccess.h>
20490 +
20491 +#include <linux/vserver/context.h>
20492 +#include <linux/vserver/debug.h>
20493 +#include <linux/vserver/debug_cmd.h>
20494 +#include <linux/vserver/history.h>
20495 +
20496 +
20497 +#ifdef CONFIG_VSERVER_HISTORY
20498 +#define VXH_SIZE       CONFIG_VSERVER_HISTORY_SIZE
20499 +#else
20500 +#define VXH_SIZE       64
20501 +#endif
20502 +
20503 +struct _vx_history {
20504 +       unsigned int counter;
20505 +
20506 +       struct _vx_hist_entry entry[VXH_SIZE + 1];
20507 +};
20508 +
20509 +
20510 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20511 +
20512 +unsigned volatile int vxh_active = 1;
20513 +
20514 +static atomic_t sequence = ATOMIC_INIT(0);
20515 +
20516 +
20517 +/*     vxh_advance()
20518 +
20519 +       * requires disabled preemption                          */
20520 +
20521 +struct _vx_hist_entry *vxh_advance(void *loc)
20522 +{
20523 +       unsigned int cpu = smp_processor_id();
20524 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20525 +       struct _vx_hist_entry *entry;
20526 +       unsigned int index;
20527 +
20528 +       index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20529 +       entry = &hist->entry[index];
20530 +
20531 +       entry->seq = atomic_inc_return(&sequence);
20532 +       entry->loc = loc;
20533 +       return entry;
20534 +}
20535 +
20536 +EXPORT_SYMBOL_GPL(vxh_advance);
20537 +
20538 +
20539 +#define VXH_LOC_FMTS   "(#%04x,*%d):%p"
20540 +
20541 +#define VXH_LOC_ARGS(e)        (e)->seq, cpu, (e)->loc
20542 +
20543 +
20544 +#define VXH_VXI_FMTS   "%p[#%d,%d.%d]"
20545 +
20546 +#define VXH_VXI_ARGS(e)        (e)->vxi.ptr,                           \
20547 +                       (e)->vxi.ptr ? (e)->vxi.xid : 0,        \
20548 +                       (e)->vxi.ptr ? (e)->vxi.usecnt : 0,     \
20549 +                       (e)->vxi.ptr ? (e)->vxi.tasks : 0
20550 +
20551 +void   vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20552 +{
20553 +       switch (e->type) {
20554 +       case VXH_THROW_OOPS:
20555 +               printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20556 +               break;
20557 +
20558 +       case VXH_GET_VX_INFO:
20559 +       case VXH_PUT_VX_INFO:
20560 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20561 +                       VXH_LOC_ARGS(e),
20562 +                       (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20563 +                       VXH_VXI_ARGS(e));
20564 +               break;
20565 +
20566 +       case VXH_INIT_VX_INFO:
20567 +       case VXH_SET_VX_INFO:
20568 +       case VXH_CLR_VX_INFO:
20569 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20570 +                       VXH_LOC_ARGS(e),
20571 +                       (e->type == VXH_INIT_VX_INFO) ? "init" :
20572 +                       ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20573 +                       VXH_VXI_ARGS(e), e->sc.data);
20574 +               break;
20575 +
20576 +       case VXH_CLAIM_VX_INFO:
20577 +       case VXH_RELEASE_VX_INFO:
20578 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20579 +                       VXH_LOC_ARGS(e),
20580 +                       (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20581 +                       VXH_VXI_ARGS(e), e->sc.data);
20582 +               break;
20583 +
20584 +       case VXH_ALLOC_VX_INFO:
20585 +       case VXH_DEALLOC_VX_INFO:
20586 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20587 +                       VXH_LOC_ARGS(e),
20588 +                       (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20589 +                       VXH_VXI_ARGS(e));
20590 +               break;
20591 +
20592 +       case VXH_HASH_VX_INFO:
20593 +       case VXH_UNHASH_VX_INFO:
20594 +               printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20595 +                       VXH_LOC_ARGS(e),
20596 +                       (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20597 +                       VXH_VXI_ARGS(e));
20598 +               break;
20599 +
20600 +       case VXH_LOC_VX_INFO:
20601 +       case VXH_LOOKUP_VX_INFO:
20602 +       case VXH_CREATE_VX_INFO:
20603 +               printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20604 +                       VXH_LOC_ARGS(e),
20605 +                       (e->type == VXH_CREATE_VX_INFO) ? "create" :
20606 +                       ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20607 +                       e->ll.arg, VXH_VXI_ARGS(e));
20608 +               break;
20609 +       }
20610 +}
20611 +
20612 +static void __vxh_dump_history(void)
20613 +{
20614 +       unsigned int i, cpu;
20615 +
20616 +       printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20617 +               atomic_read(&sequence), NR_CPUS);
20618 +
20619 +       for (i = 0; i < VXH_SIZE; i++) {
20620 +               for_each_online_cpu(cpu) {
20621 +                       struct _vx_history *hist =
20622 +                               &per_cpu(vx_history_buffer, cpu);
20623 +                       unsigned int index = (hist->counter - i) % VXH_SIZE;
20624 +                       struct _vx_hist_entry *entry = &hist->entry[index];
20625 +
20626 +                       vxh_dump_entry(entry, cpu);
20627 +               }
20628 +       }
20629 +}
20630 +
20631 +void   vxh_dump_history(void)
20632 +{
20633 +       vxh_active = 0;
20634 +#ifdef CONFIG_SMP
20635 +       local_irq_enable();
20636 +       smp_send_stop();
20637 +       local_irq_disable();
20638 +#endif
20639 +       __vxh_dump_history();
20640 +}
20641 +
20642 +
20643 +/* vserver syscall commands below here */
20644 +
20645 +
20646 +int vc_dump_history(uint32_t id)
20647 +{
20648 +       vxh_active = 0;
20649 +       __vxh_dump_history();
20650 +       vxh_active = 1;
20651 +
20652 +       return 0;
20653 +}
20654 +
20655 +
20656 +int do_read_history(struct __user _vx_hist_entry *data,
20657 +       int cpu, uint32_t *index, uint32_t *count)
20658 +{
20659 +       int pos, ret = 0;
20660 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20661 +       int end = hist->counter;
20662 +       int start = end - VXH_SIZE + 2;
20663 +       int idx = *index;
20664 +
20665 +       /* special case: get current pos */
20666 +       if (!*count) {
20667 +               *index = end;
20668 +               return 0;
20669 +       }
20670 +
20671 +       /* have we lost some data? */
20672 +       if (idx < start)
20673 +               idx = start;
20674 +
20675 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20676 +               struct _vx_hist_entry *entry =
20677 +                       &hist->entry[idx % VXH_SIZE];
20678 +
20679 +               /* send entry to userspace */
20680 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20681 +               if (ret)
20682 +                       break;
20683 +       }
20684 +       /* save new index and count */
20685 +       *index = idx;
20686 +       *count = pos;
20687 +       return ret ? ret : (*index < end);
20688 +}
20689 +
20690 +int vc_read_history(uint32_t id, void __user *data)
20691 +{
20692 +       struct vcmd_read_history_v0 vc_data;
20693 +       int ret;
20694 +
20695 +       if (id >= NR_CPUS)
20696 +               return -EINVAL;
20697 +
20698 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20699 +               return -EFAULT;
20700 +
20701 +       ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20702 +               id, &vc_data.index, &vc_data.count);
20703 +
20704 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20705 +               return -EFAULT;
20706 +       return ret;
20707 +}
20708 +
20709 +#ifdef CONFIG_COMPAT
20710 +
20711 +int vc_read_history_x32(uint32_t id, void __user *data)
20712 +{
20713 +       struct vcmd_read_history_v0_x32 vc_data;
20714 +       int ret;
20715 +
20716 +       if (id >= NR_CPUS)
20717 +               return -EINVAL;
20718 +
20719 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20720 +               return -EFAULT;
20721 +
20722 +       ret = do_read_history((struct __user _vx_hist_entry *)
20723 +               compat_ptr(vc_data.data_ptr),
20724 +               id, &vc_data.index, &vc_data.count);
20725 +
20726 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20727 +               return -EFAULT;
20728 +       return ret;
20729 +}
20730 +
20731 +#endif /* CONFIG_COMPAT */
20732 +
20733 diff -NurpP --minimal linux-2.6.34/kernel/vserver/inet.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/inet.c
20734 --- linux-2.6.34/kernel/vserver/inet.c  1970-01-01 01:00:00.000000000 +0100
20735 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/inet.c     2010-05-18 18:11:22.000000000 +0200
20736 @@ -0,0 +1,225 @@
20737 +
20738 +#include <linux/in.h>
20739 +#include <linux/inetdevice.h>
20740 +#include <linux/vs_inet.h>
20741 +#include <linux/vs_inet6.h>
20742 +#include <linux/vserver/debug.h>
20743 +#include <net/route.h>
20744 +#include <net/addrconf.h>
20745 +
20746 +
20747 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20748 +{
20749 +       int ret = 0;
20750 +
20751 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
20752 +               ret = 1;
20753 +       else {
20754 +               struct nx_addr_v4 *ptr;
20755 +
20756 +               for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20757 +                       if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20758 +                               ret = 1;
20759 +                               break;
20760 +                       }
20761 +               }
20762 +       }
20763 +
20764 +       vxdprintk(VXD_CBIT(net, 2),
20765 +               "nx_v4_addr_conflict(%p,%p): %d",
20766 +               nxi1, nxi2, ret);
20767 +
20768 +       return ret;
20769 +}
20770 +
20771 +
20772 +#ifdef CONFIG_IPV6
20773 +
20774 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20775 +{
20776 +       int ret = 0;
20777 +
20778 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
20779 +               ret = 1;
20780 +       else {
20781 +               struct nx_addr_v6 *ptr;
20782 +
20783 +               for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20784 +                       if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20785 +                               ret = 1;
20786 +                               break;
20787 +                       }
20788 +               }
20789 +       }
20790 +
20791 +       vxdprintk(VXD_CBIT(net, 2),
20792 +               "nx_v6_addr_conflict(%p,%p): %d",
20793 +               nxi1, nxi2, ret);
20794 +
20795 +       return ret;
20796 +}
20797 +
20798 +#endif
20799 +
20800 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20801 +{
20802 +       struct in_device *in_dev;
20803 +       struct in_ifaddr **ifap;
20804 +       struct in_ifaddr *ifa;
20805 +       int ret = 0;
20806 +
20807 +       if (!dev)
20808 +               goto out;
20809 +       in_dev = in_dev_get(dev);
20810 +       if (!in_dev)
20811 +               goto out;
20812 +
20813 +       for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20814 +               ifap = &ifa->ifa_next) {
20815 +               if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20816 +                       ret = 1;
20817 +                       break;
20818 +               }
20819 +       }
20820 +       in_dev_put(in_dev);
20821 +out:
20822 +       return ret;
20823 +}
20824 +
20825 +
20826 +#ifdef CONFIG_IPV6
20827 +
20828 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20829 +{
20830 +       struct inet6_dev *in_dev;
20831 +       struct inet6_ifaddr **ifap;
20832 +       struct inet6_ifaddr *ifa;
20833 +       int ret = 0;
20834 +
20835 +       if (!dev)
20836 +               goto out;
20837 +       in_dev = in6_dev_get(dev);
20838 +       if (!in_dev)
20839 +               goto out;
20840 +
20841 +       for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20842 +               ifap = &ifa->if_next) {
20843 +               if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20844 +                       ret = 1;
20845 +                       break;
20846 +               }
20847 +       }
20848 +       in6_dev_put(in_dev);
20849 +out:
20850 +       return ret;
20851 +}
20852 +
20853 +#endif
20854 +
20855 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20856 +{
20857 +       int ret = 1;
20858 +
20859 +       if (!nxi)
20860 +               goto out;
20861 +       if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20862 +               goto out;
20863 +#ifdef CONFIG_IPV6
20864 +       ret = 2;
20865 +       if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20866 +               goto out;
20867 +#endif
20868 +       ret = 0;
20869 +out:
20870 +       vxdprintk(VXD_CBIT(net, 3),
20871 +               "dev_in_nx_info(%p,%p[#%d]) = %d",
20872 +               dev, nxi, nxi ? nxi->nx_id : 0, ret);
20873 +       return ret;
20874 +}
20875 +
20876 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
20877 +       struct rtable **rp, struct flowi *fl)
20878 +{
20879 +       if (!nxi)
20880 +               return 0;
20881 +
20882 +       /* FIXME: handle lback only case */
20883 +       if (!NX_IPV4(nxi))
20884 +               return -EPERM;
20885 +
20886 +       vxdprintk(VXD_CBIT(net, 4),
20887 +               "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20888 +               nxi, nxi ? nxi->nx_id : 0,
20889 +               NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
20890 +
20891 +       /* single IP is unconditional */
20892 +       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
20893 +               (fl->fl4_src == INADDR_ANY))
20894 +               fl->fl4_src = nxi->v4.ip[0].s_addr;
20895 +
20896 +       if (fl->fl4_src == INADDR_ANY) {
20897 +               struct nx_addr_v4 *ptr;
20898 +               __be32 found = 0;
20899 +               int err;
20900 +
20901 +               err = __ip_route_output_key(net, rp, fl);
20902 +               if (!err) {
20903 +                       found = (*rp)->rt_src;
20904 +                       ip_rt_put(*rp);
20905 +                       vxdprintk(VXD_CBIT(net, 4),
20906 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20907 +                               nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
20908 +                       if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
20909 +                               goto found;
20910 +               }
20911 +
20912 +               for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
20913 +                       __be32 primary = ptr->ip[0].s_addr;
20914 +                       __be32 mask = ptr->mask.s_addr;
20915 +                       __be32 neta = primary & mask;
20916 +
20917 +                       vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
20918 +                               NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
20919 +                               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
20920 +                               NIPQUAD(mask), NIPQUAD(neta));
20921 +                       if ((found & mask) != neta)
20922 +                               continue;
20923 +
20924 +                       fl->fl4_src = primary;
20925 +                       err = __ip_route_output_key(net, rp, fl);
20926 +                       vxdprintk(VXD_CBIT(net, 4),
20927 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
20928 +                               nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
20929 +                       if (!err) {
20930 +                               found = (*rp)->rt_src;
20931 +                               ip_rt_put(*rp);
20932 +                               if (found == primary)
20933 +                                       goto found;
20934 +                       }
20935 +               }
20936 +               /* still no source ip? */
20937 +               found = ipv4_is_loopback(fl->fl4_dst)
20938 +                       ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
20939 +       found:
20940 +               /* assign src ip to flow */
20941 +               fl->fl4_src = found;
20942 +
20943 +       } else {
20944 +               if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
20945 +                       return -EPERM;
20946 +       }
20947 +
20948 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
20949 +               if (ipv4_is_loopback(fl->fl4_dst))
20950 +                       fl->fl4_dst = nxi->v4_lback.s_addr;
20951 +               if (ipv4_is_loopback(fl->fl4_src))
20952 +                       fl->fl4_src = nxi->v4_lback.s_addr;
20953 +       } else if (ipv4_is_loopback(fl->fl4_dst) &&
20954 +               !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
20955 +               return -EPERM;
20956 +
20957 +       return 0;
20958 +}
20959 +
20960 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
20961 +
20962 diff -NurpP --minimal linux-2.6.34/kernel/vserver/init.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/init.c
20963 --- linux-2.6.34/kernel/vserver/init.c  1970-01-01 01:00:00.000000000 +0100
20964 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/init.c     2010-05-18 18:11:22.000000000 +0200
20965 @@ -0,0 +1,45 @@
20966 +/*
20967 + *  linux/kernel/init.c
20968 + *
20969 + *  Virtual Server Init
20970 + *
20971 + *  Copyright (C) 2004-2007  Herbert Pötzl
20972 + *
20973 + *  V0.01  basic structure
20974 + *
20975 + */
20976 +
20977 +#include <linux/init.h>
20978 +
20979 +int    vserver_register_sysctl(void);
20980 +void   vserver_unregister_sysctl(void);
20981 +
20982 +
20983 +static int __init init_vserver(void)
20984 +{
20985 +       int ret = 0;
20986 +
20987 +#ifdef CONFIG_VSERVER_DEBUG
20988 +       vserver_register_sysctl();
20989 +#endif
20990 +       return ret;
20991 +}
20992 +
20993 +
20994 +static void __exit exit_vserver(void)
20995 +{
20996 +
20997 +#ifdef CONFIG_VSERVER_DEBUG
20998 +       vserver_unregister_sysctl();
20999 +#endif
21000 +       return;
21001 +}
21002 +
21003 +/* FIXME: GFP_ZONETYPES gone
21004 +long vx_slab[GFP_ZONETYPES]; */
21005 +long vx_area;
21006 +
21007 +
21008 +module_init(init_vserver);
21009 +module_exit(exit_vserver);
21010 +
21011 diff -NurpP --minimal linux-2.6.34/kernel/vserver/inode.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/inode.c
21012 --- linux-2.6.34/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
21013 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/inode.c    2010-05-18 18:11:22.000000000 +0200
21014 @@ -0,0 +1,433 @@
21015 +/*
21016 + *  linux/kernel/vserver/inode.c
21017 + *
21018 + *  Virtual Server: File System Support
21019 + *
21020 + *  Copyright (C) 2004-2007  Herbert Pötzl
21021 + *
21022 + *  V0.01  separated from vcontext V0.05
21023 + *  V0.02  moved to tag (instead of xid)
21024 + *
21025 + */
21026 +
21027 +#include <linux/tty.h>
21028 +#include <linux/proc_fs.h>
21029 +#include <linux/devpts_fs.h>
21030 +#include <linux/fs.h>
21031 +#include <linux/file.h>
21032 +#include <linux/mount.h>
21033 +#include <linux/parser.h>
21034 +#include <linux/namei.h>
21035 +#include <linux/vserver/inode.h>
21036 +#include <linux/vserver/inode_cmd.h>
21037 +#include <linux/vs_base.h>
21038 +#include <linux/vs_tag.h>
21039 +
21040 +#include <asm/uaccess.h>
21041 +
21042 +
21043 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21044 +{
21045 +       struct proc_dir_entry *entry;
21046 +
21047 +       if (!in || !in->i_sb)
21048 +               return -ESRCH;
21049 +
21050 +       *flags = IATTR_TAG
21051 +               | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21052 +               | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21053 +               | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21054 +               | (IS_COW(in) ? IATTR_COW : 0);
21055 +       *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21056 +
21057 +       if (S_ISDIR(in->i_mode))
21058 +               *mask |= IATTR_BARRIER;
21059 +
21060 +       if (IS_TAGGED(in)) {
21061 +               *tag = in->i_tag;
21062 +               *mask |= IATTR_TAG;
21063 +       }
21064 +
21065 +       switch (in->i_sb->s_magic) {
21066 +       case PROC_SUPER_MAGIC:
21067 +               entry = PROC_I(in)->pde;
21068 +
21069 +               /* check for specific inodes? */
21070 +               if (entry)
21071 +                       *mask |= IATTR_FLAGS;
21072 +               if (entry)
21073 +                       *flags |= (entry->vx_flags & IATTR_FLAGS);
21074 +               else
21075 +                       *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21076 +               break;
21077 +
21078 +       case DEVPTS_SUPER_MAGIC:
21079 +               *tag = in->i_tag;
21080 +               *mask |= IATTR_TAG;
21081 +               break;
21082 +
21083 +       default:
21084 +               break;
21085 +       }
21086 +       return 0;
21087 +}
21088 +
21089 +int vc_get_iattr(void __user *data)
21090 +{
21091 +       struct path path;
21092 +       struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21093 +       int ret;
21094 +
21095 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21096 +               return -EFAULT;
21097 +
21098 +       ret = user_lpath(vc_data.name, &path);
21099 +       if (!ret) {
21100 +               ret = __vc_get_iattr(path.dentry->d_inode,
21101 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21102 +               path_put(&path);
21103 +       }
21104 +       if (ret)
21105 +               return ret;
21106 +
21107 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21108 +               ret = -EFAULT;
21109 +       return ret;
21110 +}
21111 +
21112 +#ifdef CONFIG_COMPAT
21113 +
21114 +int vc_get_iattr_x32(void __user *data)
21115 +{
21116 +       struct path path;
21117 +       struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21118 +       int ret;
21119 +
21120 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21121 +               return -EFAULT;
21122 +
21123 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21124 +       if (!ret) {
21125 +               ret = __vc_get_iattr(path.dentry->d_inode,
21126 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21127 +               path_put(&path);
21128 +       }
21129 +       if (ret)
21130 +               return ret;
21131 +
21132 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21133 +               ret = -EFAULT;
21134 +       return ret;
21135 +}
21136 +
21137 +#endif /* CONFIG_COMPAT */
21138 +
21139 +
21140 +int vc_fget_iattr(uint32_t fd, void __user *data)
21141 +{
21142 +       struct file *filp;
21143 +       struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21144 +       int ret;
21145 +
21146 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21147 +               return -EFAULT;
21148 +
21149 +       filp = fget(fd);
21150 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21151 +               return -EBADF;
21152 +
21153 +       ret = __vc_get_iattr(filp->f_dentry->d_inode,
21154 +               &vc_data.tag, &vc_data.flags, &vc_data.mask);
21155 +
21156 +       fput(filp);
21157 +
21158 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21159 +               ret = -EFAULT;
21160 +       return ret;
21161 +}
21162 +
21163 +
21164 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21165 +{
21166 +       struct inode *in = de->d_inode;
21167 +       int error = 0, is_proc = 0, has_tag = 0;
21168 +       struct iattr attr = { 0 };
21169 +
21170 +       if (!in || !in->i_sb)
21171 +               return -ESRCH;
21172 +
21173 +       is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21174 +       if ((*mask & IATTR_FLAGS) && !is_proc)
21175 +               return -EINVAL;
21176 +
21177 +       has_tag = IS_TAGGED(in) ||
21178 +               (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21179 +       if ((*mask & IATTR_TAG) && !has_tag)
21180 +               return -EINVAL;
21181 +
21182 +       mutex_lock(&in->i_mutex);
21183 +       if (*mask & IATTR_TAG) {
21184 +               attr.ia_tag = *tag;
21185 +               attr.ia_valid |= ATTR_TAG;
21186 +       }
21187 +
21188 +       if (*mask & IATTR_FLAGS) {
21189 +               struct proc_dir_entry *entry = PROC_I(in)->pde;
21190 +               unsigned int iflags = PROC_I(in)->vx_flags;
21191 +
21192 +               iflags = (iflags & ~(*mask & IATTR_FLAGS))
21193 +                       | (*flags & IATTR_FLAGS);
21194 +               PROC_I(in)->vx_flags = iflags;
21195 +               if (entry)
21196 +                       entry->vx_flags = iflags;
21197 +       }
21198 +
21199 +       if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21200 +               IATTR_BARRIER | IATTR_COW)) {
21201 +               int iflags = in->i_flags;
21202 +               int vflags = in->i_vflags;
21203 +
21204 +               if (*mask & IATTR_IMMUTABLE) {
21205 +                       if (*flags & IATTR_IMMUTABLE)
21206 +                               iflags |= S_IMMUTABLE;
21207 +                       else
21208 +                               iflags &= ~S_IMMUTABLE;
21209 +               }
21210 +               if (*mask & IATTR_IXUNLINK) {
21211 +                       if (*flags & IATTR_IXUNLINK)
21212 +                               iflags |= S_IXUNLINK;
21213 +                       else
21214 +                               iflags &= ~S_IXUNLINK;
21215 +               }
21216 +               if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21217 +                       if (*flags & IATTR_BARRIER)
21218 +                               vflags |= V_BARRIER;
21219 +                       else
21220 +                               vflags &= ~V_BARRIER;
21221 +               }
21222 +               if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21223 +                       if (*flags & IATTR_COW)
21224 +                               vflags |= V_COW;
21225 +                       else
21226 +                               vflags &= ~V_COW;
21227 +               }
21228 +               if (in->i_op && in->i_op->sync_flags) {
21229 +                       error = in->i_op->sync_flags(in, iflags, vflags);
21230 +                       if (error)
21231 +                               goto out;
21232 +               }
21233 +       }
21234 +
21235 +       if (attr.ia_valid) {
21236 +               if (in->i_op && in->i_op->setattr)
21237 +                       error = in->i_op->setattr(de, &attr);
21238 +               else {
21239 +                       error = inode_change_ok(in, &attr);
21240 +                       if (!error)
21241 +                               error = inode_setattr(in, &attr);
21242 +               }
21243 +       }
21244 +
21245 +out:
21246 +       mutex_unlock(&in->i_mutex);
21247 +       return error;
21248 +}
21249 +
21250 +int vc_set_iattr(void __user *data)
21251 +{
21252 +       struct path path;
21253 +       struct vcmd_ctx_iattr_v1 vc_data;
21254 +       int ret;
21255 +
21256 +       if (!capable(CAP_LINUX_IMMUTABLE))
21257 +               return -EPERM;
21258 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21259 +               return -EFAULT;
21260 +
21261 +       ret = user_lpath(vc_data.name, &path);
21262 +       if (!ret) {
21263 +               ret = __vc_set_iattr(path.dentry,
21264 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21265 +               path_put(&path);
21266 +       }
21267 +
21268 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21269 +               ret = -EFAULT;
21270 +       return ret;
21271 +}
21272 +
21273 +#ifdef CONFIG_COMPAT
21274 +
21275 +int vc_set_iattr_x32(void __user *data)
21276 +{
21277 +       struct path path;
21278 +       struct vcmd_ctx_iattr_v1_x32 vc_data;
21279 +       int ret;
21280 +
21281 +       if (!capable(CAP_LINUX_IMMUTABLE))
21282 +               return -EPERM;
21283 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21284 +               return -EFAULT;
21285 +
21286 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21287 +       if (!ret) {
21288 +               ret = __vc_set_iattr(path.dentry,
21289 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21290 +               path_put(&path);
21291 +       }
21292 +
21293 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21294 +               ret = -EFAULT;
21295 +       return ret;
21296 +}
21297 +
21298 +#endif /* CONFIG_COMPAT */
21299 +
21300 +int vc_fset_iattr(uint32_t fd, void __user *data)
21301 +{
21302 +       struct file *filp;
21303 +       struct vcmd_ctx_fiattr_v0 vc_data;
21304 +       int ret;
21305 +
21306 +       if (!capable(CAP_LINUX_IMMUTABLE))
21307 +               return -EPERM;
21308 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21309 +               return -EFAULT;
21310 +
21311 +       filp = fget(fd);
21312 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21313 +               return -EBADF;
21314 +
21315 +       ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21316 +               &vc_data.flags, &vc_data.mask);
21317 +
21318 +       fput(filp);
21319 +
21320 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21321 +               return -EFAULT;
21322 +       return ret;
21323 +}
21324 +
21325 +
21326 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21327 +
21328 +static match_table_t tokens = {
21329 +       {Opt_notagcheck, "notagcheck"},
21330 +#ifdef CONFIG_PROPAGATE
21331 +       {Opt_notag, "notag"},
21332 +       {Opt_tag, "tag"},
21333 +       {Opt_tagid, "tagid=%u"},
21334 +#endif
21335 +       {Opt_err, NULL}
21336 +};
21337 +
21338 +
21339 +static void __dx_parse_remove(char *string, char *opt)
21340 +{
21341 +       char *p = strstr(string, opt);
21342 +       char *q = p;
21343 +
21344 +       if (p) {
21345 +               while (*q != '\0' && *q != ',')
21346 +                       q++;
21347 +               while (*q)
21348 +                       *p++ = *q++;
21349 +               while (*p)
21350 +                       *p++ = '\0';
21351 +       }
21352 +}
21353 +
21354 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21355 +                unsigned long *flags)
21356 +{
21357 +       int set = 0;
21358 +       substring_t args[MAX_OPT_ARGS];
21359 +       int token, option = 0;
21360 +       char *s, *p, *opts;
21361 +
21362 +       if (!string)
21363 +               return 0;
21364 +       s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21365 +       if (!s)
21366 +               return 0;
21367 +
21368 +       opts = s;
21369 +       while ((p = strsep(&opts, ",")) != NULL) {
21370 +               token = match_token(p, tokens, args);
21371 +
21372 +               vxdprintk(VXD_CBIT(tag, 7),
21373 +                       "dx_parse_tag(»%s«): %d:#%d",
21374 +                       p, token, option);
21375 +
21376 +               switch (token) {
21377 +#ifdef CONFIG_PROPAGATE
21378 +               case Opt_tag:
21379 +                       if (tag)
21380 +                               *tag = 0;
21381 +                       if (remove)
21382 +                               __dx_parse_remove(s, "tag");
21383 +                       *mnt_flags |= MNT_TAGID;
21384 +                       set |= MNT_TAGID;
21385 +                       break;
21386 +               case Opt_notag:
21387 +                       if (remove)
21388 +                               __dx_parse_remove(s, "notag");
21389 +                       *mnt_flags |= MNT_NOTAG;
21390 +                       set |= MNT_NOTAG;
21391 +                       break;
21392 +               case Opt_tagid:
21393 +                       if (tag && !match_int(args, &option))
21394 +                               *tag = option;
21395 +                       if (remove)
21396 +                               __dx_parse_remove(s, "tagid");
21397 +                       *mnt_flags |= MNT_TAGID;
21398 +                       set |= MNT_TAGID;
21399 +                       break;
21400 +#endif
21401 +               case Opt_notagcheck:
21402 +                       if (remove)
21403 +                               __dx_parse_remove(s, "notagcheck");
21404 +                       *flags |= MS_NOTAGCHECK;
21405 +                       set |= MS_NOTAGCHECK;
21406 +                       break;
21407 +               }
21408 +       }
21409 +       if (set)
21410 +               strcpy(string, s);
21411 +       kfree(s);
21412 +       return set;
21413 +}
21414 +
21415 +#ifdef CONFIG_PROPAGATE
21416 +
21417 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21418 +{
21419 +       tag_t new_tag = 0;
21420 +       struct vfsmount *mnt;
21421 +       int propagate;
21422 +
21423 +       if (!nd)
21424 +               return;
21425 +       mnt = nd->path.mnt;
21426 +       if (!mnt)
21427 +               return;
21428 +
21429 +       propagate = (mnt->mnt_flags & MNT_TAGID);
21430 +       if (propagate)
21431 +               new_tag = mnt->mnt_tag;
21432 +
21433 +       vxdprintk(VXD_CBIT(tag, 7),
21434 +               "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21435 +               inode, inode->i_ino, inode->i_tag,
21436 +               new_tag, (propagate) ? 1 : 0);
21437 +
21438 +       if (propagate)
21439 +               inode->i_tag = new_tag;
21440 +}
21441 +
21442 +#include <linux/module.h>
21443 +
21444 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21445 +
21446 +#endif /* CONFIG_PROPAGATE */
21447 +
21448 diff -NurpP --minimal linux-2.6.34/kernel/vserver/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/Kconfig
21449 --- linux-2.6.34/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
21450 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/Kconfig    2010-05-22 00:54:16.000000000 +0200
21451 @@ -0,0 +1,260 @@
21452 +#
21453 +# Linux VServer configuration
21454 +#
21455 +
21456 +menu "Linux VServer"
21457 +
21458 +config VSERVER_AUTO_LBACK
21459 +       bool    "Automatically Assign Loopback IP"
21460 +       default y
21461 +       help
21462 +         Automatically assign a guest specific loopback
21463 +         IP and add it to the kernel network stack on
21464 +         startup.
21465 +
21466 +config VSERVER_AUTO_SINGLE
21467 +       bool    "Automatic Single IP Special Casing"
21468 +       depends on EXPERIMENTAL
21469 +       default y
21470 +       help
21471 +         This allows network contexts with a single IP to
21472 +         automatically remap 0.0.0.0 bindings to that IP,
21473 +         avoiding further network checks and improving
21474 +         performance.
21475 +
21476 +         (note: such guests do not allow to change the ip
21477 +          on the fly and do not show loopback addresses)
21478 +
21479 +config VSERVER_COWBL
21480 +       bool    "Enable COW Immutable Link Breaking"
21481 +       default y
21482 +       help
21483 +         This enables the COW (Copy-On-Write) link break code.
21484 +         It allows you to treat unified files like normal files
21485 +         when writing to them (which will implicitely break the
21486 +         link and create a copy of the unified file)
21487 +
21488 +config VSERVER_VTIME
21489 +       bool    "Enable Virtualized Guest Time"
21490 +       depends on EXPERIMENTAL
21491 +       default n
21492 +       help
21493 +         This enables per guest time offsets to allow for
21494 +         adjusting the system clock individually per guest.
21495 +         this adds some overhead to the time functions and
21496 +         therefore should not be enabled without good reason.
21497 +
21498 +config VSERVER_DEVICE
21499 +       bool    "Enable Guest Device Mapping"
21500 +       depends on EXPERIMENTAL
21501 +       default n
21502 +       help
21503 +         This enables generic device remapping.
21504 +
21505 +config VSERVER_PROC_SECURE
21506 +       bool    "Enable Proc Security"
21507 +       depends on PROC_FS
21508 +       default y
21509 +       help
21510 +         This configures ProcFS security to initially hide
21511 +         non-process entries for all contexts except the main and
21512 +         spectator context (i.e. for all guests), which is a secure
21513 +         default.
21514 +
21515 +         (note: on 1.2x the entries were visible by default)
21516 +
21517 +config VSERVER_HARDCPU
21518 +       bool    "Enable Hard CPU Limits"
21519 +       default y
21520 +       help
21521 +         Activate the Hard CPU Limits
21522 +
21523 +         This will compile in code that allows the Token Bucket
21524 +         Scheduler to put processes on hold when a context's
21525 +         tokens are depleted (provided that its per-context
21526 +         sched_hard flag is set).
21527 +
21528 +         Processes belonging to that context will not be able
21529 +         to consume CPU resources again until a per-context
21530 +         configured minimum of tokens has been reached.
21531 +
21532 +config VSERVER_IDLETIME
21533 +       bool    "Avoid idle CPUs by skipping Time"
21534 +       depends on VSERVER_HARDCPU
21535 +       default y
21536 +       help
21537 +         This option allows the scheduler to artificially
21538 +         advance time (per cpu) when otherwise the idle
21539 +         task would be scheduled, thus keeping the cpu
21540 +         busy and sharing the available resources among
21541 +         certain contexts.
21542 +
21543 +config VSERVER_IDLELIMIT
21544 +       bool    "Limit the IDLE task"
21545 +       depends on VSERVER_HARDCPU
21546 +       default n
21547 +       help
21548 +         Limit the idle slices, so the the next context
21549 +         will be scheduled as soon as possible.
21550 +
21551 +         This might improve interactivity and latency, but
21552 +         will also marginally increase scheduling overhead.
21553 +
21554 +choice
21555 +       prompt  "Persistent Inode Tagging"
21556 +       default TAGGING_ID24
21557 +       help
21558 +         This adds persistent context information to filesystems
21559 +         mounted with the tagxid option. Tagging is a requirement
21560 +         for per-context disk limits and per-context quota.
21561 +
21562 +
21563 +config TAGGING_NONE
21564 +       bool    "Disabled"
21565 +       help
21566 +         do not store per-context information in inodes.
21567 +
21568 +config TAGGING_UID16
21569 +       bool    "UID16/GID32"
21570 +       help
21571 +         reduces UID to 16 bit, but leaves GID at 32 bit.
21572 +
21573 +config TAGGING_GID16
21574 +       bool    "UID32/GID16"
21575 +       help
21576 +         reduces GID to 16 bit, but leaves UID at 32 bit.
21577 +
21578 +config TAGGING_ID24
21579 +       bool    "UID24/GID24"
21580 +       help
21581 +         uses the upper 8bit from UID and GID for XID tagging
21582 +         which leaves 24bit for UID/GID each, which should be
21583 +         more than sufficient for normal use.
21584 +
21585 +config TAGGING_INTERN
21586 +       bool    "UID32/GID32"
21587 +       help
21588 +         this uses otherwise reserved inode fields in the on
21589 +         disk representation, which limits the use to a few
21590 +         filesystems (currently ext2 and ext3)
21591 +
21592 +endchoice
21593 +
21594 +config TAG_NFSD
21595 +       bool    "Tag NFSD User Auth and Files"
21596 +       default n
21597 +       help
21598 +         Enable this if you do want the in-kernel NFS
21599 +         Server to use the tagging specified above.
21600 +         (will require patched clients too)
21601 +
21602 +config VSERVER_PRIVACY
21603 +       bool    "Honor Privacy Aspects of Guests"
21604 +       default n
21605 +       help
21606 +         When enabled, most context checks will disallow
21607 +         access to structures assigned to a specific context,
21608 +         like ptys or loop devices.
21609 +
21610 +config VSERVER_CONTEXTS
21611 +       int     "Maximum number of Contexts (1-65533)"  if EMBEDDED
21612 +       range 1 65533
21613 +       default "768"   if 64BIT
21614 +       default "256"
21615 +       help
21616 +         This setting will optimize certain data structures
21617 +         and memory allocations according to the expected
21618 +         maximum.
21619 +
21620 +         note: this is not a strict upper limit.
21621 +
21622 +config VSERVER_WARN
21623 +       bool    "VServer Warnings"
21624 +       default y
21625 +       help
21626 +         This enables various runtime warnings, which will
21627 +         notify about potential manipulation attempts or
21628 +         resource shortage. It is generally considered to
21629 +         be a good idea to have that enabled.
21630 +
21631 +config VSERVER_DEBUG
21632 +       bool    "VServer Debugging Code"
21633 +       default n
21634 +       help
21635 +         Set this to yes if you want to be able to activate
21636 +         debugging output at runtime. It adds a very small
21637 +         overhead to all vserver related functions and
21638 +         increases the kernel size by about 20k.
21639 +
21640 +config VSERVER_HISTORY
21641 +       bool    "VServer History Tracing"
21642 +       depends on VSERVER_DEBUG
21643 +       default n
21644 +       help
21645 +         Set this to yes if you want to record the history of
21646 +         linux-vserver activities, so they can be replayed in
21647 +         the event of a kernel panic or oops.
21648 +
21649 +config VSERVER_HISTORY_SIZE
21650 +       int     "Per-CPU History Size (32-65536)"
21651 +       depends on VSERVER_HISTORY
21652 +       range 32 65536
21653 +       default 64
21654 +       help
21655 +         This allows you to specify the number of entries in
21656 +         the per-CPU history buffer.
21657 +
21658 +config VSERVER_MONITOR
21659 +       bool    "VServer Scheduling Monitor"
21660 +       depends on VSERVER_DISABLED
21661 +       default n
21662 +       help
21663 +         Set this to yes if you want to record the scheduling
21664 +         decisions, so that they can be relayed to userspace
21665 +         for detailed analysis.
21666 +
21667 +config VSERVER_MONITOR_SIZE
21668 +       int     "Per-CPU Monitor Queue Size (32-65536)"
21669 +       depends on VSERVER_MONITOR
21670 +       range 32 65536
21671 +       default 1024
21672 +       help
21673 +         This allows you to specify the number of entries in
21674 +         the per-CPU scheduling monitor buffer.
21675 +
21676 +config VSERVER_MONITOR_SYNC
21677 +       int     "Per-CPU Monitor Sync Interval (0-65536)"
21678 +       depends on VSERVER_MONITOR
21679 +       range 0 65536
21680 +       default 256
21681 +       help
21682 +         This allows you to specify the interval in ticks
21683 +         when a time sync entry is inserted.
21684 +
21685 +config VSERVER_LEGACY_MEM
21686 +       bool    "Legacy Memory Limits"
21687 +       default n
21688 +       help
21689 +         This provides fake memory limits to keep
21690 +         older tools happy in the face of memory
21691 +         cgroups
21692 +
21693 +
21694 +endmenu
21695 +
21696 +
21697 +config VSERVER
21698 +       bool
21699 +       default y
21700 +       select NAMESPACES
21701 +       select UTS_NS
21702 +       select IPC_NS
21703 +       select USER_NS
21704 +       select SYSVIPC
21705 +
21706 +config VSERVER_SECURITY
21707 +       bool
21708 +       depends on SECURITY
21709 +       default y
21710 +       select SECURITY_CAPABILITIES
21711 +
21712 diff -NurpP --minimal linux-2.6.34/kernel/vserver/limit.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/limit.c
21713 --- linux-2.6.34/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21714 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/limit.c    2010-05-22 00:52:02.000000000 +0200
21715 @@ -0,0 +1,354 @@
21716 +/*
21717 + *  linux/kernel/vserver/limit.c
21718 + *
21719 + *  Virtual Server: Context Limits
21720 + *
21721 + *  Copyright (C) 2004-2010  Herbert Pötzl
21722 + *
21723 + *  V0.01  broken out from vcontext V0.05
21724 + *  V0.02  changed vcmds to vxi arg
21725 + *  V0.03  added memory cgroup support
21726 + *
21727 + */
21728 +
21729 +#include <linux/sched.h>
21730 +#include <linux/module.h>
21731 +#include <linux/memcontrol.h>
21732 +#include <linux/res_counter.h>
21733 +#include <linux/vs_limit.h>
21734 +#include <linux/vserver/limit.h>
21735 +#include <linux/vserver/limit_cmd.h>
21736 +
21737 +#include <asm/uaccess.h>
21738 +
21739 +
21740 +const char *vlimit_name[NUM_LIMITS] = {
21741 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21742 +       [RLIMIT_RSS]            = "RSS",
21743 +       [RLIMIT_AS]             = "VM",
21744 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21745 +       [RLIMIT_CPU]            = "CPU",
21746 +       [RLIMIT_NPROC]          = "NPROC",
21747 +       [RLIMIT_NOFILE]         = "NOFILE",
21748 +       [RLIMIT_LOCKS]          = "LOCKS",
21749 +       [RLIMIT_SIGPENDING]     = "SIGP",
21750 +       [RLIMIT_MSGQUEUE]       = "MSGQ",
21751 +
21752 +       [VLIMIT_NSOCK]          = "NSOCK",
21753 +       [VLIMIT_OPENFD]         = "OPENFD",
21754 +       [VLIMIT_SHMEM]          = "SHMEM",
21755 +       [VLIMIT_DENTRY]         = "DENTRY",
21756 +};
21757 +
21758 +EXPORT_SYMBOL_GPL(vlimit_name);
21759 +
21760 +#define MASK_ENTRY(x)  (1 << (x))
21761 +
21762 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21763 +               /* minimum */
21764 +       0
21765 +       ,       /* softlimit */
21766 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21767 +       MASK_ENTRY( RLIMIT_RSS          ) |
21768 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21769 +       0
21770 +       ,       /* maximum */
21771 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21772 +       MASK_ENTRY( RLIMIT_RSS          ) |
21773 +       MASK_ENTRY( RLIMIT_AS           ) |
21774 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21775 +       MASK_ENTRY( RLIMIT_NPROC        ) |
21776 +       MASK_ENTRY( RLIMIT_NOFILE       ) |
21777 +       MASK_ENTRY( RLIMIT_LOCKS        ) |
21778 +       MASK_ENTRY( RLIMIT_MSGQUEUE     ) |
21779 +
21780 +       MASK_ENTRY( VLIMIT_NSOCK        ) |
21781 +       MASK_ENTRY( VLIMIT_OPENFD       ) |
21782 +       MASK_ENTRY( VLIMIT_SHMEM        ) |
21783 +       MASK_ENTRY( VLIMIT_DENTRY       ) |
21784 +       0
21785 +};
21786 +               /* accounting only */
21787 +uint32_t account_mask =
21788 +       MASK_ENTRY( VLIMIT_SEMARY       ) |
21789 +       MASK_ENTRY( VLIMIT_NSEMS        ) |
21790 +       MASK_ENTRY( VLIMIT_MAPPED       ) |
21791 +       0;
21792 +
21793 +
21794 +static int is_valid_vlimit(int id)
21795 +{
21796 +       uint32_t mask = vlimit_mask.minimum |
21797 +               vlimit_mask.softlimit | vlimit_mask.maximum;
21798 +       return mask & (1 << id);
21799 +}
21800 +
21801 +static int is_accounted_vlimit(int id)
21802 +{
21803 +       if (is_valid_vlimit(id))
21804 +               return 1;
21805 +       return account_mask & (1 << id);
21806 +}
21807 +
21808 +
21809 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21810 +{
21811 +       rlim_t limit = __rlim_soft(&vxi->limit, id);
21812 +       return VX_VLIM(limit);
21813 +}
21814 +
21815 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21816 +{
21817 +       rlim_t limit = __rlim_hard(&vxi->limit, id);
21818 +       return VX_VLIM(limit);
21819 +}
21820 +
21821 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21822 +       uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21823 +{
21824 +       if (!is_valid_vlimit(id))
21825 +               return -EINVAL;
21826 +
21827 +       if (minimum)
21828 +               *minimum = CRLIM_UNSET;
21829 +       if (softlimit)
21830 +               *softlimit = vc_get_soft(vxi, id);
21831 +       if (maximum)
21832 +               *maximum = vc_get_hard(vxi, id);
21833 +       return 0;
21834 +}
21835 +
21836 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21837 +{
21838 +       struct vcmd_ctx_rlimit_v0 vc_data;
21839 +       int ret;
21840 +
21841 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21842 +               return -EFAULT;
21843 +
21844 +       ret = do_get_rlimit(vxi, vc_data.id,
21845 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21846 +       if (ret)
21847 +               return ret;
21848 +
21849 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21850 +               return -EFAULT;
21851 +       return 0;
21852 +}
21853 +
21854 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21855 +       uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21856 +{
21857 +       if (!is_valid_vlimit(id))
21858 +               return -EINVAL;
21859 +
21860 +       if (maximum != CRLIM_KEEP)
21861 +               __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21862 +       if (softlimit != CRLIM_KEEP)
21863 +               __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21864 +
21865 +       /* clamp soft limit */
21866 +       if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21867 +               __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21868 +
21869 +       return 0;
21870 +}
21871 +
21872 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21873 +{
21874 +       struct vcmd_ctx_rlimit_v0 vc_data;
21875 +
21876 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21877 +               return -EFAULT;
21878 +
21879 +       return do_set_rlimit(vxi, vc_data.id,
21880 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21881 +}
21882 +
21883 +#ifdef CONFIG_IA32_EMULATION
21884 +
21885 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21886 +{
21887 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
21888 +
21889 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21890 +               return -EFAULT;
21891 +
21892 +       return do_set_rlimit(vxi, vc_data.id,
21893 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21894 +}
21895 +
21896 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21897 +{
21898 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
21899 +       int ret;
21900 +
21901 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21902 +               return -EFAULT;
21903 +
21904 +       ret = do_get_rlimit(vxi, vc_data.id,
21905 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21906 +       if (ret)
21907 +               return ret;
21908 +
21909 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21910 +               return -EFAULT;
21911 +       return 0;
21912 +}
21913 +
21914 +#endif /* CONFIG_IA32_EMULATION */
21915 +
21916 +
21917 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21918 +{
21919 +       if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21920 +               return -EFAULT;
21921 +       return 0;
21922 +}
21923 +
21924 +
21925 +static inline void vx_reset_hits(struct _vx_limit *limit)
21926 +{
21927 +       int lim;
21928 +
21929 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
21930 +               atomic_set(&__rlim_lhit(limit, lim), 0);
21931 +       }
21932 +}
21933 +
21934 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
21935 +{
21936 +       vx_reset_hits(&vxi->limit);
21937 +       return 0;
21938 +}
21939 +
21940 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21941 +{
21942 +       rlim_t value;
21943 +       int lim;
21944 +
21945 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
21946 +               value = __rlim_get(limit, lim);
21947 +               __rlim_rmax(limit, lim) = value;
21948 +               __rlim_rmin(limit, lim) = value;
21949 +       }
21950 +}
21951 +
21952 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21953 +{
21954 +       vx_reset_minmax(&vxi->limit);
21955 +       return 0;
21956 +}
21957 +
21958 +
21959 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21960 +{
21961 +       struct vcmd_rlimit_stat_v0 vc_data;
21962 +       struct _vx_limit *limit = &vxi->limit;
21963 +       int id;
21964 +
21965 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21966 +               return -EFAULT;
21967 +
21968 +       id = vc_data.id;
21969 +       if (!is_accounted_vlimit(id))
21970 +               return -EINVAL;
21971 +
21972 +       vx_limit_fixup(limit, id);
21973 +       vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21974 +       vc_data.value = __rlim_get(limit, id);
21975 +       vc_data.minimum = __rlim_rmin(limit, id);
21976 +       vc_data.maximum = __rlim_rmax(limit, id);
21977 +
21978 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21979 +               return -EFAULT;
21980 +       return 0;
21981 +}
21982 +
21983 +
21984 +void vx_vsi_meminfo(struct sysinfo *val)
21985 +{
21986 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21987 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21988 +       u64 res_limit, res_usage;
21989 +
21990 +       if (!mcg)
21991 +               return;
21992 +
21993 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21994 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21995 +
21996 +       if (res_limit != RESOURCE_MAX)
21997 +               val->totalram = (res_limit >> PAGE_SHIFT);
21998 +       val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
21999 +       val->bufferram = 0;
22000 +       val->totalhigh = 0;
22001 +       val->freehigh = 0;
22002 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22003 +       return;
22004 +}
22005 +
22006 +void vx_vsi_swapinfo(struct sysinfo *val)
22007 +{
22008 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22009 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
22010 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22011 +       u64 res_limit, res_usage, memsw_limit, memsw_usage;
22012 +       s64 swap_limit, swap_usage;
22013 +
22014 +       if (!mcg)
22015 +               return;
22016 +
22017 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22018 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22019 +       memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
22020 +       memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
22021 +
22022 +       if (res_limit == RESOURCE_MAX)
22023 +               return;
22024 +
22025 +       swap_limit = memsw_limit - res_limit;
22026 +       if (memsw_limit != RESOURCE_MAX)
22027 +               val->totalswap = swap_limit >> PAGE_SHIFT;
22028 +
22029 +       swap_usage = memsw_usage - res_usage;
22030 +       val->freeswap = (swap_usage < swap_limit) ?
22031 +               val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
22032 +#else  /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22033 +       val->totalswap = 0;
22034 +       val->freeswap = 0;
22035 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22036 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22037 +       return;
22038 +}
22039 +
22040 +long vx_vsi_cached(struct sysinfo *val)
22041 +{
22042 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22043 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22044 +
22045 +       return mem_cgroup_stat_read_cache(mcg);
22046 +#else
22047 +       return 0;
22048 +#endif
22049 +}
22050 +
22051 +
22052 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22053 +{
22054 +       struct vx_info *vxi = mm->mm_vx_info;
22055 +       unsigned long points;
22056 +       rlim_t v, w;
22057 +
22058 +       if (!vxi)
22059 +               return 0;
22060 +
22061 +       points = vxi->vx_badness_bias;
22062 +
22063 +       v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22064 +       w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22065 +       points += (v > w) ? (v - w) : 0;
22066 +
22067 +       return points;
22068 +}
22069 +
22070 diff -NurpP --minimal linux-2.6.34/kernel/vserver/limit_init.h linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/limit_init.h
22071 --- linux-2.6.34/kernel/vserver/limit_init.h    1970-01-01 01:00:00.000000000 +0100
22072 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/limit_init.h       2010-05-18 18:11:22.000000000 +0200
22073 @@ -0,0 +1,31 @@
22074 +
22075 +
22076 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22077 +{
22078 +       int lim;
22079 +
22080 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22081 +               __rlim_soft(limit, lim) = RLIM_INFINITY;
22082 +               __rlim_hard(limit, lim) = RLIM_INFINITY;
22083 +               __rlim_set(limit, lim, 0);
22084 +               atomic_set(&__rlim_lhit(limit, lim), 0);
22085 +               __rlim_rmin(limit, lim) = 0;
22086 +               __rlim_rmax(limit, lim) = 0;
22087 +       }
22088 +}
22089 +
22090 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22091 +{
22092 +       rlim_t value;
22093 +       int lim;
22094 +
22095 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22096 +               if ((1 << lim) & VLIM_NOCHECK)
22097 +                       continue;
22098 +               value = __rlim_get(limit, lim);
22099 +               vxwprintk_xid(value,
22100 +                       "!!! limit: %p[%s,%d] = %ld on exit.",
22101 +                       limit, vlimit_name[lim], lim, (long)value);
22102 +       }
22103 +}
22104 +
22105 diff -NurpP --minimal linux-2.6.34/kernel/vserver/limit_proc.h linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/limit_proc.h
22106 --- linux-2.6.34/kernel/vserver/limit_proc.h    1970-01-01 01:00:00.000000000 +0100
22107 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/limit_proc.h       2010-05-18 18:11:22.000000000 +0200
22108 @@ -0,0 +1,57 @@
22109 +#ifndef _VX_LIMIT_PROC_H
22110 +#define _VX_LIMIT_PROC_H
22111 +
22112 +#include <linux/vserver/limit_int.h>
22113 +
22114 +
22115 +#define VX_LIMIT_FMT   ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22116 +#define VX_LIMIT_TOP   \
22117 +       "Limit\t current\t     min/max\t\t    soft/hard\t\thits\n"
22118 +
22119 +#define VX_LIMIT_ARG(r)                                \
22120 +       (unsigned long)__rlim_get(limit, r),    \
22121 +       (unsigned long)__rlim_rmin(limit, r),   \
22122 +       (unsigned long)__rlim_rmax(limit, r),   \
22123 +       VX_VLIM(__rlim_soft(limit, r)),         \
22124 +       VX_VLIM(__rlim_hard(limit, r)),         \
22125 +       atomic_read(&__rlim_lhit(limit, r))
22126 +
22127 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22128 +{
22129 +       vx_limit_fixup(limit, -1);
22130 +       return sprintf(buffer, VX_LIMIT_TOP
22131 +               "PROC"  VX_LIMIT_FMT
22132 +               "VM"    VX_LIMIT_FMT
22133 +               "VML"   VX_LIMIT_FMT
22134 +               "RSS"   VX_LIMIT_FMT
22135 +               "ANON"  VX_LIMIT_FMT
22136 +               "RMAP"  VX_LIMIT_FMT
22137 +               "FILES" VX_LIMIT_FMT
22138 +               "OFD"   VX_LIMIT_FMT
22139 +               "LOCKS" VX_LIMIT_FMT
22140 +               "SOCK"  VX_LIMIT_FMT
22141 +               "MSGQ"  VX_LIMIT_FMT
22142 +               "SHM"   VX_LIMIT_FMT
22143 +               "SEMA"  VX_LIMIT_FMT
22144 +               "SEMS"  VX_LIMIT_FMT
22145 +               "DENT"  VX_LIMIT_FMT,
22146 +               VX_LIMIT_ARG(RLIMIT_NPROC),
22147 +               VX_LIMIT_ARG(RLIMIT_AS),
22148 +               VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22149 +               VX_LIMIT_ARG(RLIMIT_RSS),
22150 +               VX_LIMIT_ARG(VLIMIT_ANON),
22151 +               VX_LIMIT_ARG(VLIMIT_MAPPED),
22152 +               VX_LIMIT_ARG(RLIMIT_NOFILE),
22153 +               VX_LIMIT_ARG(VLIMIT_OPENFD),
22154 +               VX_LIMIT_ARG(RLIMIT_LOCKS),
22155 +               VX_LIMIT_ARG(VLIMIT_NSOCK),
22156 +               VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22157 +               VX_LIMIT_ARG(VLIMIT_SHMEM),
22158 +               VX_LIMIT_ARG(VLIMIT_SEMARY),
22159 +               VX_LIMIT_ARG(VLIMIT_NSEMS),
22160 +               VX_LIMIT_ARG(VLIMIT_DENTRY));
22161 +}
22162 +
22163 +#endif /* _VX_LIMIT_PROC_H */
22164 +
22165 +
22166 diff -NurpP --minimal linux-2.6.34/kernel/vserver/Makefile linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/Makefile
22167 --- linux-2.6.34/kernel/vserver/Makefile        1970-01-01 01:00:00.000000000 +0100
22168 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/Makefile   2010-05-18 18:11:22.000000000 +0200
22169 @@ -0,0 +1,18 @@
22170 +#
22171 +# Makefile for the Linux vserver routines.
22172 +#
22173 +
22174 +
22175 +obj-y          += vserver.o
22176 +
22177 +vserver-y      := switch.o context.o space.o sched.o network.o inode.o \
22178 +                  limit.o cvirt.o cacct.o signal.o helper.o init.o \
22179 +                  dlimit.o tag.o
22180 +
22181 +vserver-$(CONFIG_INET) += inet.o
22182 +vserver-$(CONFIG_PROC_FS) += proc.o
22183 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
22184 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
22185 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
22186 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
22187 +
22188 diff -NurpP --minimal linux-2.6.34/kernel/vserver/monitor.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/monitor.c
22189 --- linux-2.6.34/kernel/vserver/monitor.c       1970-01-01 01:00:00.000000000 +0100
22190 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/monitor.c  2010-05-18 18:11:22.000000000 +0200
22191 @@ -0,0 +1,138 @@
22192 +/*
22193 + *  kernel/vserver/monitor.c
22194 + *
22195 + *  Virtual Context Scheduler Monitor
22196 + *
22197 + *  Copyright (C) 2006-2007 Herbert Pötzl
22198 + *
22199 + *  V0.01  basic design
22200 + *
22201 + */
22202 +
22203 +#include <linux/module.h>
22204 +#include <linux/jiffies.h>
22205 +#include <asm/uaccess.h>
22206 +#include <asm/atomic.h>
22207 +
22208 +#include <linux/vserver/monitor.h>
22209 +#include <linux/vserver/debug_cmd.h>
22210 +
22211 +
22212 +#ifdef CONFIG_VSERVER_MONITOR
22213 +#define VXM_SIZE       CONFIG_VSERVER_MONITOR_SIZE
22214 +#else
22215 +#define VXM_SIZE       64
22216 +#endif
22217 +
22218 +struct _vx_monitor {
22219 +       unsigned int counter;
22220 +
22221 +       struct _vx_mon_entry entry[VXM_SIZE+1];
22222 +};
22223 +
22224 +
22225 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
22226 +
22227 +unsigned volatile int vxm_active = 1;
22228 +
22229 +static atomic_t sequence = ATOMIC_INIT(0);
22230 +
22231 +
22232 +/*     vxm_advance()
22233 +
22234 +       * requires disabled preemption                          */
22235 +
22236 +struct _vx_mon_entry *vxm_advance(int cpu)
22237 +{
22238 +       struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22239 +       struct _vx_mon_entry *entry;
22240 +       unsigned int index;
22241 +
22242 +       index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
22243 +       entry = &mon->entry[index];
22244 +
22245 +       entry->ev.seq = atomic_inc_return(&sequence);
22246 +       entry->ev.jif = jiffies;
22247 +       return entry;
22248 +}
22249 +
22250 +EXPORT_SYMBOL_GPL(vxm_advance);
22251 +
22252 +
22253 +int do_read_monitor(struct __user _vx_mon_entry *data,
22254 +       int cpu, uint32_t *index, uint32_t *count)
22255 +{
22256 +       int pos, ret = 0;
22257 +       struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22258 +       int end = mon->counter;
22259 +       int start = end - VXM_SIZE + 2;
22260 +       int idx = *index;
22261 +
22262 +       /* special case: get current pos */
22263 +       if (!*count) {
22264 +               *index = end;
22265 +               return 0;
22266 +       }
22267 +
22268 +       /* have we lost some data? */
22269 +       if (idx < start)
22270 +               idx = start;
22271 +
22272 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22273 +               struct _vx_mon_entry *entry =
22274 +                       &mon->entry[idx % VXM_SIZE];
22275 +
22276 +               /* send entry to userspace */
22277 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22278 +               if (ret)
22279 +                       break;
22280 +       }
22281 +       /* save new index and count */
22282 +       *index = idx;
22283 +       *count = pos;
22284 +       return ret ? ret : (*index < end);
22285 +}
22286 +
22287 +int vc_read_monitor(uint32_t id, void __user *data)
22288 +{
22289 +       struct vcmd_read_monitor_v0 vc_data;
22290 +       int ret;
22291 +
22292 +       if (id >= NR_CPUS)
22293 +               return -EINVAL;
22294 +
22295 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22296 +               return -EFAULT;
22297 +
22298 +       ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22299 +               id, &vc_data.index, &vc_data.count);
22300 +
22301 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22302 +               return -EFAULT;
22303 +       return ret;
22304 +}
22305 +
22306 +#ifdef CONFIG_COMPAT
22307 +
22308 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22309 +{
22310 +       struct vcmd_read_monitor_v0_x32 vc_data;
22311 +       int ret;
22312 +
22313 +       if (id >= NR_CPUS)
22314 +               return -EINVAL;
22315 +
22316 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22317 +               return -EFAULT;
22318 +
22319 +       ret = do_read_monitor((struct __user _vx_mon_entry *)
22320 +               compat_ptr(vc_data.data_ptr),
22321 +               id, &vc_data.index, &vc_data.count);
22322 +
22323 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22324 +               return -EFAULT;
22325 +       return ret;
22326 +}
22327 +
22328 +#endif /* CONFIG_COMPAT */
22329 +
22330 diff -NurpP --minimal linux-2.6.34/kernel/vserver/network.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/network.c
22331 --- linux-2.6.34/kernel/vserver/network.c       1970-01-01 01:00:00.000000000 +0100
22332 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/network.c  2010-05-18 18:11:22.000000000 +0200
22333 @@ -0,0 +1,864 @@
22334 +/*
22335 + *  linux/kernel/vserver/network.c
22336 + *
22337 + *  Virtual Server: Network Support
22338 + *
22339 + *  Copyright (C) 2003-2007  Herbert Pötzl
22340 + *
22341 + *  V0.01  broken out from vcontext V0.05
22342 + *  V0.02  cleaned up implementation
22343 + *  V0.03  added equiv nx commands
22344 + *  V0.04  switch to RCU based hash
22345 + *  V0.05  and back to locking again
22346 + *  V0.06  changed vcmds to nxi arg
22347 + *  V0.07  have __create claim() the nxi
22348 + *
22349 + */
22350 +
22351 +#include <linux/err.h>
22352 +#include <linux/slab.h>
22353 +#include <linux/rcupdate.h>
22354 +
22355 +#include <linux/vs_network.h>
22356 +#include <linux/vs_pid.h>
22357 +#include <linux/vserver/network_cmd.h>
22358 +
22359 +
22360 +atomic_t nx_global_ctotal      = ATOMIC_INIT(0);
22361 +atomic_t nx_global_cactive     = ATOMIC_INIT(0);
22362 +
22363 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22364 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22365 +
22366 +
22367 +static int __init init_network(void)
22368 +{
22369 +       nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22370 +               sizeof(struct nx_addr_v4), 0,
22371 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22372 +       nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22373 +               sizeof(struct nx_addr_v6), 0,
22374 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22375 +       return 0;
22376 +}
22377 +
22378 +
22379 +/*     __alloc_nx_addr_v4()                                    */
22380 +
22381 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22382 +{
22383 +       struct nx_addr_v4 *nxa = kmem_cache_alloc(
22384 +               nx_addr_v4_cachep, GFP_KERNEL);
22385 +
22386 +       if (!IS_ERR(nxa))
22387 +               memset(nxa, 0, sizeof(*nxa));
22388 +       return nxa;
22389 +}
22390 +
22391 +/*     __dealloc_nx_addr_v4()                                  */
22392 +
22393 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22394 +{
22395 +       kmem_cache_free(nx_addr_v4_cachep, nxa);
22396 +}
22397 +
22398 +/*     __dealloc_nx_addr_v4_all()                              */
22399 +
22400 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22401 +{
22402 +       while (nxa) {
22403 +               struct nx_addr_v4 *next = nxa->next;
22404 +
22405 +               __dealloc_nx_addr_v4(nxa);
22406 +               nxa = next;
22407 +       }
22408 +}
22409 +
22410 +
22411 +#ifdef CONFIG_IPV6
22412 +
22413 +/*     __alloc_nx_addr_v6()                                    */
22414 +
22415 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22416 +{
22417 +       struct nx_addr_v6 *nxa = kmem_cache_alloc(
22418 +               nx_addr_v6_cachep, GFP_KERNEL);
22419 +
22420 +       if (!IS_ERR(nxa))
22421 +               memset(nxa, 0, sizeof(*nxa));
22422 +       return nxa;
22423 +}
22424 +
22425 +/*     __dealloc_nx_addr_v6()                                  */
22426 +
22427 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22428 +{
22429 +       kmem_cache_free(nx_addr_v6_cachep, nxa);
22430 +}
22431 +
22432 +/*     __dealloc_nx_addr_v6_all()                              */
22433 +
22434 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22435 +{
22436 +       while (nxa) {
22437 +               struct nx_addr_v6 *next = nxa->next;
22438 +
22439 +               __dealloc_nx_addr_v6(nxa);
22440 +               nxa = next;
22441 +       }
22442 +}
22443 +
22444 +#endif /* CONFIG_IPV6 */
22445 +
22446 +/*     __alloc_nx_info()
22447 +
22448 +       * allocate an initialized nx_info struct
22449 +       * doesn't make it visible (hash)                        */
22450 +
22451 +static struct nx_info *__alloc_nx_info(nid_t nid)
22452 +{
22453 +       struct nx_info *new = NULL;
22454 +
22455 +       vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22456 +
22457 +       /* would this benefit from a slab cache? */
22458 +       new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22459 +       if (!new)
22460 +               return 0;
22461 +
22462 +       memset(new, 0, sizeof(struct nx_info));
22463 +       new->nx_id = nid;
22464 +       INIT_HLIST_NODE(&new->nx_hlist);
22465 +       atomic_set(&new->nx_usecnt, 0);
22466 +       atomic_set(&new->nx_tasks, 0);
22467 +       new->nx_state = 0;
22468 +
22469 +       new->nx_flags = NXF_INIT_SET;
22470 +
22471 +       /* rest of init goes here */
22472 +
22473 +       new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22474 +       new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22475 +
22476 +       vxdprintk(VXD_CBIT(nid, 0),
22477 +               "alloc_nx_info(%d) = %p", nid, new);
22478 +       atomic_inc(&nx_global_ctotal);
22479 +       return new;
22480 +}
22481 +
22482 +/*     __dealloc_nx_info()
22483 +
22484 +       * final disposal of nx_info                             */
22485 +
22486 +static void __dealloc_nx_info(struct nx_info *nxi)
22487 +{
22488 +       vxdprintk(VXD_CBIT(nid, 0),
22489 +               "dealloc_nx_info(%p)", nxi);
22490 +
22491 +       nxi->nx_hlist.next = LIST_POISON1;
22492 +       nxi->nx_id = -1;
22493 +
22494 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
22495 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22496 +
22497 +       __dealloc_nx_addr_v4_all(nxi->v4.next);
22498 +
22499 +       nxi->nx_state |= NXS_RELEASED;
22500 +       kfree(nxi);
22501 +       atomic_dec(&nx_global_ctotal);
22502 +}
22503 +
22504 +static void __shutdown_nx_info(struct nx_info *nxi)
22505 +{
22506 +       nxi->nx_state |= NXS_SHUTDOWN;
22507 +       vs_net_change(nxi, VSC_NETDOWN);
22508 +}
22509 +
22510 +/*     exported stuff                                          */
22511 +
22512 +void free_nx_info(struct nx_info *nxi)
22513 +{
22514 +       /* context shutdown is mandatory */
22515 +       BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22516 +
22517 +       /* context must not be hashed */
22518 +       BUG_ON(nxi->nx_state & NXS_HASHED);
22519 +
22520 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
22521 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22522 +
22523 +       __dealloc_nx_info(nxi);
22524 +}
22525 +
22526 +
22527 +void __nx_set_lback(struct nx_info *nxi)
22528 +{
22529 +       int nid = nxi->nx_id;
22530 +       __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22531 +
22532 +       nxi->v4_lback.s_addr = lback;
22533 +}
22534 +
22535 +extern int __nx_inet_add_lback(__be32 addr);
22536 +extern int __nx_inet_del_lback(__be32 addr);
22537 +
22538 +
22539 +/*     hash table for nx_info hash */
22540 +
22541 +#define NX_HASH_SIZE   13
22542 +
22543 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22544 +
22545 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
22546 +
22547 +
22548 +static inline unsigned int __hashval(nid_t nid)
22549 +{
22550 +       return (nid % NX_HASH_SIZE);
22551 +}
22552 +
22553 +
22554 +
22555 +/*     __hash_nx_info()
22556 +
22557 +       * add the nxi to the global hash table
22558 +       * requires the hash_lock to be held                     */
22559 +
22560 +static inline void __hash_nx_info(struct nx_info *nxi)
22561 +{
22562 +       struct hlist_head *head;
22563 +
22564 +       vxd_assert_lock(&nx_info_hash_lock);
22565 +       vxdprintk(VXD_CBIT(nid, 4),
22566 +               "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22567 +
22568 +       /* context must not be hashed */
22569 +       BUG_ON(nx_info_state(nxi, NXS_HASHED));
22570 +
22571 +       nxi->nx_state |= NXS_HASHED;
22572 +       head = &nx_info_hash[__hashval(nxi->nx_id)];
22573 +       hlist_add_head(&nxi->nx_hlist, head);
22574 +       atomic_inc(&nx_global_cactive);
22575 +}
22576 +
22577 +/*     __unhash_nx_info()
22578 +
22579 +       * remove the nxi from the global hash table
22580 +       * requires the hash_lock to be held                     */
22581 +
22582 +static inline void __unhash_nx_info(struct nx_info *nxi)
22583 +{
22584 +       vxd_assert_lock(&nx_info_hash_lock);
22585 +       vxdprintk(VXD_CBIT(nid, 4),
22586 +               "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22587 +               atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22588 +
22589 +       /* context must be hashed */
22590 +       BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22591 +       /* but without tasks */
22592 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22593 +
22594 +       nxi->nx_state &= ~NXS_HASHED;
22595 +       hlist_del(&nxi->nx_hlist);
22596 +       atomic_dec(&nx_global_cactive);
22597 +}
22598 +
22599 +
22600 +/*     __lookup_nx_info()
22601 +
22602 +       * requires the hash_lock to be held
22603 +       * doesn't increment the nx_refcnt                       */
22604 +
22605 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22606 +{
22607 +       struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22608 +       struct hlist_node *pos;
22609 +       struct nx_info *nxi;
22610 +
22611 +       vxd_assert_lock(&nx_info_hash_lock);
22612 +       hlist_for_each(pos, head) {
22613 +               nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22614 +
22615 +               if (nxi->nx_id == nid)
22616 +                       goto found;
22617 +       }
22618 +       nxi = NULL;
22619 +found:
22620 +       vxdprintk(VXD_CBIT(nid, 0),
22621 +               "__lookup_nx_info(#%u): %p[#%u]",
22622 +               nid, nxi, nxi ? nxi->nx_id : 0);
22623 +       return nxi;
22624 +}
22625 +
22626 +
22627 +/*     __create_nx_info()
22628 +
22629 +       * create the requested context
22630 +       * get(), claim() and hash it                            */
22631 +
22632 +static struct nx_info *__create_nx_info(int id)
22633 +{
22634 +       struct nx_info *new, *nxi = NULL;
22635 +
22636 +       vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22637 +
22638 +       if (!(new = __alloc_nx_info(id)))
22639 +               return ERR_PTR(-ENOMEM);
22640 +
22641 +       /* required to make dynamic xids unique */
22642 +       spin_lock(&nx_info_hash_lock);
22643 +
22644 +       /* static context requested */
22645 +       if ((nxi = __lookup_nx_info(id))) {
22646 +               vxdprintk(VXD_CBIT(nid, 0),
22647 +                       "create_nx_info(%d) = %p (already there)", id, nxi);
22648 +               if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22649 +                       nxi = ERR_PTR(-EBUSY);
22650 +               else
22651 +                       nxi = ERR_PTR(-EEXIST);
22652 +               goto out_unlock;
22653 +       }
22654 +       /* new context */
22655 +       vxdprintk(VXD_CBIT(nid, 0),
22656 +               "create_nx_info(%d) = %p (new)", id, new);
22657 +       claim_nx_info(new, NULL);
22658 +       __nx_set_lback(new);
22659 +       __hash_nx_info(get_nx_info(new));
22660 +       nxi = new, new = NULL;
22661 +
22662 +out_unlock:
22663 +       spin_unlock(&nx_info_hash_lock);
22664 +       if (new)
22665 +               __dealloc_nx_info(new);
22666 +       return nxi;
22667 +}
22668 +
22669 +
22670 +
22671 +/*     exported stuff                                          */
22672 +
22673 +
22674 +void unhash_nx_info(struct nx_info *nxi)
22675 +{
22676 +       __shutdown_nx_info(nxi);
22677 +       spin_lock(&nx_info_hash_lock);
22678 +       __unhash_nx_info(nxi);
22679 +       spin_unlock(&nx_info_hash_lock);
22680 +}
22681 +
22682 +/*     lookup_nx_info()
22683 +
22684 +       * search for a nx_info and get() it
22685 +       * negative id means current                             */
22686 +
22687 +struct nx_info *lookup_nx_info(int id)
22688 +{
22689 +       struct nx_info *nxi = NULL;
22690 +
22691 +       if (id < 0) {
22692 +               nxi = get_nx_info(current_nx_info());
22693 +       } else if (id > 1) {
22694 +               spin_lock(&nx_info_hash_lock);
22695 +               nxi = get_nx_info(__lookup_nx_info(id));
22696 +               spin_unlock(&nx_info_hash_lock);
22697 +       }
22698 +       return nxi;
22699 +}
22700 +
22701 +/*     nid_is_hashed()
22702 +
22703 +       * verify that nid is still hashed                       */
22704 +
22705 +int nid_is_hashed(nid_t nid)
22706 +{
22707 +       int hashed;
22708 +
22709 +       spin_lock(&nx_info_hash_lock);
22710 +       hashed = (__lookup_nx_info(nid) != NULL);
22711 +       spin_unlock(&nx_info_hash_lock);
22712 +       return hashed;
22713 +}
22714 +
22715 +
22716 +#ifdef CONFIG_PROC_FS
22717 +
22718 +/*     get_nid_list()
22719 +
22720 +       * get a subset of hashed nids for proc
22721 +       * assumes size is at least one                          */
22722 +
22723 +int get_nid_list(int index, unsigned int *nids, int size)
22724 +{
22725 +       int hindex, nr_nids = 0;
22726 +
22727 +       /* only show current and children */
22728 +       if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22729 +               if (index > 0)
22730 +                       return 0;
22731 +               nids[nr_nids] = nx_current_nid();
22732 +               return 1;
22733 +       }
22734 +
22735 +       for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22736 +               struct hlist_head *head = &nx_info_hash[hindex];
22737 +               struct hlist_node *pos;
22738 +
22739 +               spin_lock(&nx_info_hash_lock);
22740 +               hlist_for_each(pos, head) {
22741 +                       struct nx_info *nxi;
22742 +
22743 +                       if (--index > 0)
22744 +                               continue;
22745 +
22746 +                       nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22747 +                       nids[nr_nids] = nxi->nx_id;
22748 +                       if (++nr_nids >= size) {
22749 +                               spin_unlock(&nx_info_hash_lock);
22750 +                               goto out;
22751 +                       }
22752 +               }
22753 +               /* keep the lock time short */
22754 +               spin_unlock(&nx_info_hash_lock);
22755 +       }
22756 +out:
22757 +       return nr_nids;
22758 +}
22759 +#endif
22760 +
22761 +
22762 +/*
22763 + *     migrate task to new network
22764 + *     gets nxi, puts old_nxi on change
22765 + */
22766 +
22767 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22768 +{
22769 +       struct nx_info *old_nxi;
22770 +       int ret = 0;
22771 +
22772 +       if (!p || !nxi)
22773 +               BUG();
22774 +
22775 +       vxdprintk(VXD_CBIT(nid, 5),
22776 +               "nx_migrate_task(%p,%p[#%d.%d.%d])",
22777 +               p, nxi, nxi->nx_id,
22778 +               atomic_read(&nxi->nx_usecnt),
22779 +               atomic_read(&nxi->nx_tasks));
22780 +
22781 +       if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22782 +               !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22783 +               return -EACCES;
22784 +
22785 +       if (nx_info_state(nxi, NXS_SHUTDOWN))
22786 +               return -EFAULT;
22787 +
22788 +       /* maybe disallow this completely? */
22789 +       old_nxi = task_get_nx_info(p);
22790 +       if (old_nxi == nxi)
22791 +               goto out;
22792 +
22793 +       task_lock(p);
22794 +       if (old_nxi)
22795 +               clr_nx_info(&p->nx_info);
22796 +       claim_nx_info(nxi, p);
22797 +       set_nx_info(&p->nx_info, nxi);
22798 +       p->nid = nxi->nx_id;
22799 +       task_unlock(p);
22800 +
22801 +       vxdprintk(VXD_CBIT(nid, 5),
22802 +               "moved task %p into nxi:%p[#%d]",
22803 +               p, nxi, nxi->nx_id);
22804 +
22805 +       if (old_nxi)
22806 +               release_nx_info(old_nxi, p);
22807 +       ret = 0;
22808 +out:
22809 +       put_nx_info(old_nxi);
22810 +       return ret;
22811 +}
22812 +
22813 +
22814 +void nx_set_persistent(struct nx_info *nxi)
22815 +{
22816 +       vxdprintk(VXD_CBIT(nid, 6),
22817 +               "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22818 +
22819 +       get_nx_info(nxi);
22820 +       claim_nx_info(nxi, NULL);
22821 +}
22822 +
22823 +void nx_clear_persistent(struct nx_info *nxi)
22824 +{
22825 +       vxdprintk(VXD_CBIT(nid, 6),
22826 +               "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22827 +
22828 +       release_nx_info(nxi, NULL);
22829 +       put_nx_info(nxi);
22830 +}
22831 +
22832 +void nx_update_persistent(struct nx_info *nxi)
22833 +{
22834 +       if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22835 +               nx_set_persistent(nxi);
22836 +       else
22837 +               nx_clear_persistent(nxi);
22838 +}
22839 +
22840 +/* vserver syscall commands below here */
22841 +
22842 +/* taks nid and nx_info functions */
22843 +
22844 +#include <asm/uaccess.h>
22845 +
22846 +
22847 +int vc_task_nid(uint32_t id)
22848 +{
22849 +       nid_t nid;
22850 +
22851 +       if (id) {
22852 +               struct task_struct *tsk;
22853 +
22854 +               read_lock(&tasklist_lock);
22855 +               tsk = find_task_by_real_pid(id);
22856 +               nid = (tsk) ? tsk->nid : -ESRCH;
22857 +               read_unlock(&tasklist_lock);
22858 +       } else
22859 +               nid = nx_current_nid();
22860 +       return nid;
22861 +}
22862 +
22863 +
22864 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22865 +{
22866 +       struct vcmd_nx_info_v0 vc_data;
22867 +
22868 +       vc_data.nid = nxi->nx_id;
22869 +
22870 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22871 +               return -EFAULT;
22872 +       return 0;
22873 +}
22874 +
22875 +
22876 +/* network functions */
22877 +
22878 +int vc_net_create(uint32_t nid, void __user *data)
22879 +{
22880 +       struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22881 +       struct nx_info *new_nxi;
22882 +       int ret;
22883 +
22884 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22885 +               return -EFAULT;
22886 +
22887 +       if ((nid > MAX_S_CONTEXT) || (nid < 2))
22888 +               return -EINVAL;
22889 +
22890 +       new_nxi = __create_nx_info(nid);
22891 +       if (IS_ERR(new_nxi))
22892 +               return PTR_ERR(new_nxi);
22893 +
22894 +       /* initial flags */
22895 +       new_nxi->nx_flags = vc_data.flagword;
22896 +
22897 +       ret = -ENOEXEC;
22898 +       if (vs_net_change(new_nxi, VSC_NETUP))
22899 +               goto out;
22900 +
22901 +       ret = nx_migrate_task(current, new_nxi);
22902 +       if (ret)
22903 +               goto out;
22904 +
22905 +       /* return context id on success */
22906 +       ret = new_nxi->nx_id;
22907 +
22908 +       /* get a reference for persistent contexts */
22909 +       if ((vc_data.flagword & NXF_PERSISTENT))
22910 +               nx_set_persistent(new_nxi);
22911 +out:
22912 +       release_nx_info(new_nxi, NULL);
22913 +       put_nx_info(new_nxi);
22914 +       return ret;
22915 +}
22916 +
22917 +
22918 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22919 +{
22920 +       return nx_migrate_task(current, nxi);
22921 +}
22922 +
22923 +
22924 +
22925 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22926 +       uint16_t type, uint16_t flags)
22927 +{
22928 +       struct nx_addr_v4 *nxa = &nxi->v4;
22929 +
22930 +       if (NX_IPV4(nxi)) {
22931 +               /* locate last entry */
22932 +               for (; nxa->next; nxa = nxa->next);
22933 +               nxa->next = __alloc_nx_addr_v4();
22934 +               nxa = nxa->next;
22935 +
22936 +               if (IS_ERR(nxa))
22937 +                       return PTR_ERR(nxa);
22938 +       }
22939 +
22940 +       if (nxi->v4.next)
22941 +               /* remove single ip for ip list */
22942 +               nxi->nx_flags &= ~NXF_SINGLE_IP;
22943 +
22944 +       nxa->ip[0].s_addr = ip;
22945 +       nxa->ip[1].s_addr = ip2;
22946 +       nxa->mask.s_addr = mask;
22947 +       nxa->type = type;
22948 +       nxa->flags = flags;
22949 +       return 0;
22950 +}
22951 +
22952 +
22953 +int vc_net_add(struct nx_info *nxi, void __user *data)
22954 +{
22955 +       struct vcmd_net_addr_v0 vc_data;
22956 +       int index, ret = 0;
22957 +
22958 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22959 +               return -EFAULT;
22960 +
22961 +       switch (vc_data.type) {
22962 +       case NXA_TYPE_IPV4:
22963 +               if ((vc_data.count < 1) || (vc_data.count > 4))
22964 +                       return -EINVAL;
22965 +
22966 +               index = 0;
22967 +               while (index < vc_data.count) {
22968 +                       ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22969 +                               vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22970 +                       if (ret)
22971 +                               return ret;
22972 +                       index++;
22973 +               }
22974 +               ret = index;
22975 +               break;
22976 +
22977 +       case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22978 +               nxi->v4_bcast = vc_data.ip[0];
22979 +               ret = 1;
22980 +               break;
22981 +
22982 +       case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22983 +               nxi->v4_lback = vc_data.ip[0];
22984 +               ret = 1;
22985 +               break;
22986 +
22987 +       default:
22988 +               ret = -EINVAL;
22989 +               break;
22990 +       }
22991 +       return ret;
22992 +}
22993 +
22994 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22995 +{
22996 +       struct vcmd_net_addr_v0 vc_data;
22997 +
22998 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22999 +               return -EFAULT;
23000 +
23001 +       switch (vc_data.type) {
23002 +       case NXA_TYPE_ANY:
23003 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23004 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
23005 +               break;
23006 +
23007 +       default:
23008 +               return -EINVAL;
23009 +       }
23010 +       return 0;
23011 +}
23012 +
23013 +
23014 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
23015 +{
23016 +       struct vcmd_net_addr_ipv4_v1 vc_data;
23017 +
23018 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23019 +               return -EFAULT;
23020 +
23021 +       switch (vc_data.type) {
23022 +       case NXA_TYPE_ADDR:
23023 +       case NXA_TYPE_RANGE:
23024 +       case NXA_TYPE_MASK:
23025 +               return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
23026 +                       vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23027 +
23028 +       case NXA_TYPE_ADDR | NXA_MOD_BCAST:
23029 +               nxi->v4_bcast = vc_data.ip;
23030 +               break;
23031 +
23032 +       case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23033 +               nxi->v4_lback = vc_data.ip;
23034 +               break;
23035 +
23036 +       default:
23037 +               return -EINVAL;
23038 +       }
23039 +       return 0;
23040 +}
23041 +
23042 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
23043 +{
23044 +       struct vcmd_net_addr_ipv4_v1 vc_data;
23045 +
23046 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23047 +               return -EFAULT;
23048 +
23049 +       switch (vc_data.type) {
23050 +/*     case NXA_TYPE_ADDR:
23051 +               break;          */
23052 +
23053 +       case NXA_TYPE_ANY:
23054 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23055 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
23056 +               break;
23057 +
23058 +       default:
23059 +               return -EINVAL;
23060 +       }
23061 +       return 0;
23062 +}
23063 +
23064 +
23065 +#ifdef CONFIG_IPV6
23066 +
23067 +int do_add_v6_addr(struct nx_info *nxi,
23068 +       struct in6_addr *ip, struct in6_addr *mask,
23069 +       uint32_t prefix, uint16_t type, uint16_t flags)
23070 +{
23071 +       struct nx_addr_v6 *nxa = &nxi->v6;
23072 +
23073 +       if (NX_IPV6(nxi)) {
23074 +               /* locate last entry */
23075 +               for (; nxa->next; nxa = nxa->next);
23076 +               nxa->next = __alloc_nx_addr_v6();
23077 +               nxa = nxa->next;
23078 +
23079 +               if (IS_ERR(nxa))
23080 +                       return PTR_ERR(nxa);
23081 +       }
23082 +
23083 +       nxa->ip = *ip;
23084 +       nxa->mask = *mask;
23085 +       nxa->prefix = prefix;
23086 +       nxa->type = type;
23087 +       nxa->flags = flags;
23088 +       return 0;
23089 +}
23090 +
23091 +
23092 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23093 +{
23094 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23095 +
23096 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23097 +               return -EFAULT;
23098 +
23099 +       switch (vc_data.type) {
23100 +       case NXA_TYPE_ADDR:
23101 +       case NXA_TYPE_MASK:
23102 +               return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23103 +                       vc_data.prefix, vc_data.type, vc_data.flags);
23104 +       default:
23105 +               return -EINVAL;
23106 +       }
23107 +       return 0;
23108 +}
23109 +
23110 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23111 +{
23112 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23113 +
23114 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23115 +               return -EFAULT;
23116 +
23117 +       switch (vc_data.type) {
23118 +       case NXA_TYPE_ANY:
23119 +               __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23120 +               memset(&nxi->v6, 0, sizeof(nxi->v6));
23121 +               break;
23122 +
23123 +       default:
23124 +               return -EINVAL;
23125 +       }
23126 +       return 0;
23127 +}
23128 +
23129 +#endif /* CONFIG_IPV6 */
23130 +
23131 +
23132 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23133 +{
23134 +       struct vcmd_net_flags_v0 vc_data;
23135 +
23136 +       vc_data.flagword = nxi->nx_flags;
23137 +
23138 +       /* special STATE flag handling */
23139 +       vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23140 +
23141 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23142 +               return -EFAULT;
23143 +       return 0;
23144 +}
23145 +
23146 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23147 +{
23148 +       struct vcmd_net_flags_v0 vc_data;
23149 +       uint64_t mask, trigger;
23150 +
23151 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23152 +               return -EFAULT;
23153 +
23154 +       /* special STATE flag handling */
23155 +       mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23156 +       trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23157 +
23158 +       nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23159 +               vc_data.flagword, mask);
23160 +       if (trigger & NXF_PERSISTENT)
23161 +               nx_update_persistent(nxi);
23162 +
23163 +       return 0;
23164 +}
23165 +
23166 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23167 +{
23168 +       struct vcmd_net_caps_v0 vc_data;
23169 +
23170 +       vc_data.ncaps = nxi->nx_ncaps;
23171 +       vc_data.cmask = ~0ULL;
23172 +
23173 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23174 +               return -EFAULT;
23175 +       return 0;
23176 +}
23177 +
23178 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23179 +{
23180 +       struct vcmd_net_caps_v0 vc_data;
23181 +
23182 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23183 +               return -EFAULT;
23184 +
23185 +       nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23186 +               vc_data.ncaps, vc_data.cmask);
23187 +       return 0;
23188 +}
23189 +
23190 +
23191 +#include <linux/module.h>
23192 +
23193 +module_init(init_network);
23194 +
23195 +EXPORT_SYMBOL_GPL(free_nx_info);
23196 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23197 +
23198 diff -NurpP --minimal linux-2.6.34/kernel/vserver/proc.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/proc.c
23199 --- linux-2.6.34/kernel/vserver/proc.c  1970-01-01 01:00:00.000000000 +0100
23200 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/proc.c     2010-05-18 18:11:22.000000000 +0200
23201 @@ -0,0 +1,1098 @@
23202 +/*
23203 + *  linux/kernel/vserver/proc.c
23204 + *
23205 + *  Virtual Context Support
23206 + *
23207 + *  Copyright (C) 2003-2007  Herbert Pötzl
23208 + *
23209 + *  V0.01  basic structure
23210 + *  V0.02  adaptation vs1.3.0
23211 + *  V0.03  proc permissions
23212 + *  V0.04  locking/generic
23213 + *  V0.05  next generation procfs
23214 + *  V0.06  inode validation
23215 + *  V0.07  generic rewrite vid
23216 + *  V0.08  remove inode type
23217 + *
23218 + */
23219 +
23220 +#include <linux/proc_fs.h>
23221 +#include <linux/fs_struct.h>
23222 +#include <linux/mount.h>
23223 +#include <asm/unistd.h>
23224 +
23225 +#include <linux/vs_context.h>
23226 +#include <linux/vs_network.h>
23227 +#include <linux/vs_cvirt.h>
23228 +
23229 +#include <linux/in.h>
23230 +#include <linux/inetdevice.h>
23231 +#include <linux/vs_inet.h>
23232 +#include <linux/vs_inet6.h>
23233 +
23234 +#include <linux/vserver/global.h>
23235 +
23236 +#include "cvirt_proc.h"
23237 +#include "cacct_proc.h"
23238 +#include "limit_proc.h"
23239 +#include "sched_proc.h"
23240 +#include "vci_config.h"
23241 +
23242 +
23243 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23244 +{
23245 +       unsigned __capi;
23246 +
23247 +       CAP_FOR_EACH_U32(__capi) {
23248 +               buffer += sprintf(buffer, "%08x",
23249 +                       c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23250 +       }
23251 +       return buffer;
23252 +}
23253 +
23254 +
23255 +static struct proc_dir_entry *proc_virtual;
23256 +
23257 +static struct proc_dir_entry *proc_virtnet;
23258 +
23259 +
23260 +/* first the actual feeds */
23261 +
23262 +
23263 +static int proc_vci(char *buffer)
23264 +{
23265 +       return sprintf(buffer,
23266 +               "VCIVersion:\t%04x:%04x\n"
23267 +               "VCISyscall:\t%d\n"
23268 +               "VCIKernel:\t%08x\n",
23269 +               VCI_VERSION >> 16,
23270 +               VCI_VERSION & 0xFFFF,
23271 +               __NR_vserver,
23272 +               vci_kernel_config());
23273 +}
23274 +
23275 +static int proc_virtual_info(char *buffer)
23276 +{
23277 +       return proc_vci(buffer);
23278 +}
23279 +
23280 +static int proc_virtual_status(char *buffer)
23281 +{
23282 +       return sprintf(buffer,
23283 +               "#CTotal:\t%d\n"
23284 +               "#CActive:\t%d\n"
23285 +               "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23286 +               "#InitTask:\t%d\t%d %d\n",
23287 +               atomic_read(&vx_global_ctotal),
23288 +               atomic_read(&vx_global_cactive),
23289 +               atomic_read(&vs_global_nsproxy),
23290 +               atomic_read(&vs_global_fs),
23291 +               atomic_read(&vs_global_mnt_ns),
23292 +               atomic_read(&vs_global_uts_ns),
23293 +               atomic_read(&nr_ipc_ns),
23294 +               atomic_read(&vs_global_user_ns),
23295 +               atomic_read(&vs_global_pid_ns),
23296 +               atomic_read(&init_task.usage),
23297 +               atomic_read(&init_task.nsproxy->count),
23298 +               init_task.fs->users);
23299 +}
23300 +
23301 +
23302 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23303 +{
23304 +       int length;
23305 +
23306 +       length = sprintf(buffer,
23307 +               "ID:\t%d\n"
23308 +               "Info:\t%p\n"
23309 +               "Init:\t%d\n"
23310 +               "OOM:\t%lld\n",
23311 +               vxi->vx_id,
23312 +               vxi,
23313 +               vxi->vx_initpid,
23314 +               vxi->vx_badness_bias);
23315 +       return length;
23316 +}
23317 +
23318 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23319 +{
23320 +       char *orig = buffer;
23321 +
23322 +       buffer += sprintf(buffer,
23323 +               "UseCnt:\t%d\n"
23324 +               "Tasks:\t%d\n"
23325 +               "Flags:\t%016llx\n",
23326 +               atomic_read(&vxi->vx_usecnt),
23327 +               atomic_read(&vxi->vx_tasks),
23328 +               (unsigned long long)vxi->vx_flags);
23329 +
23330 +       buffer += sprintf(buffer, "BCaps:\t");
23331 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23332 +       buffer += sprintf(buffer, "\n");
23333 +
23334 +       buffer += sprintf(buffer,
23335 +               "CCaps:\t%016llx\n"
23336 +               "Spaces:\t%08lx %08lx\n",
23337 +               (unsigned long long)vxi->vx_ccaps,
23338 +               vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
23339 +       return buffer - orig;
23340 +}
23341 +
23342 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23343 +{
23344 +       return vx_info_proc_limit(&vxi->limit, buffer);
23345 +}
23346 +
23347 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23348 +{
23349 +       int cpu, length;
23350 +
23351 +       length = vx_info_proc_sched(&vxi->sched, buffer);
23352 +       for_each_online_cpu(cpu) {
23353 +               length += vx_info_proc_sched_pc(
23354 +                       &vx_per_cpu(vxi, sched_pc, cpu),
23355 +                       buffer + length, cpu);
23356 +       }
23357 +       return length;
23358 +}
23359 +
23360 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23361 +{
23362 +       return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
23363 +}
23364 +
23365 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23366 +{
23367 +       return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
23368 +}
23369 +
23370 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23371 +{
23372 +       int cpu, length;
23373 +
23374 +       vx_update_load(vxi);
23375 +       length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23376 +       for_each_online_cpu(cpu) {
23377 +               length += vx_info_proc_cvirt_pc(
23378 +                       &vx_per_cpu(vxi, cvirt_pc, cpu),
23379 +                       buffer + length, cpu);
23380 +       }
23381 +       return length;
23382 +}
23383 +
23384 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23385 +{
23386 +       return vx_info_proc_cacct(&vxi->cacct, buffer);
23387 +}
23388 +
23389 +
23390 +static int proc_virtnet_info(char *buffer)
23391 +{
23392 +       return proc_vci(buffer);
23393 +}
23394 +
23395 +static int proc_virtnet_status(char *buffer)
23396 +{
23397 +       return sprintf(buffer,
23398 +               "#CTotal:\t%d\n"
23399 +               "#CActive:\t%d\n",
23400 +               atomic_read(&nx_global_ctotal),
23401 +               atomic_read(&nx_global_cactive));
23402 +}
23403 +
23404 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23405 +{
23406 +       struct nx_addr_v4 *v4a;
23407 +#ifdef CONFIG_IPV6
23408 +       struct nx_addr_v6 *v6a;
23409 +#endif
23410 +       int length, i;
23411 +
23412 +       length = sprintf(buffer,
23413 +               "ID:\t%d\n"
23414 +               "Info:\t%p\n"
23415 +               "Bcast:\t" NIPQUAD_FMT "\n"
23416 +               "Lback:\t" NIPQUAD_FMT "\n",
23417 +               nxi->nx_id,
23418 +               nxi,
23419 +               NIPQUAD(nxi->v4_bcast.s_addr),
23420 +               NIPQUAD(nxi->v4_lback.s_addr));
23421 +
23422 +       if (!NX_IPV4(nxi))
23423 +               goto skip_v4;
23424 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23425 +               length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23426 +                       i, NXAV4(v4a));
23427 +skip_v4:
23428 +#ifdef CONFIG_IPV6
23429 +       if (!NX_IPV6(nxi))
23430 +               goto skip_v6;
23431 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23432 +               length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23433 +                       i, NXAV6(v6a));
23434 +skip_v6:
23435 +#endif
23436 +       return length;
23437 +}
23438 +
23439 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23440 +{
23441 +       int length;
23442 +
23443 +       length = sprintf(buffer,
23444 +               "UseCnt:\t%d\n"
23445 +               "Tasks:\t%d\n"
23446 +               "Flags:\t%016llx\n"
23447 +               "NCaps:\t%016llx\n",
23448 +               atomic_read(&nxi->nx_usecnt),
23449 +               atomic_read(&nxi->nx_tasks),
23450 +               (unsigned long long)nxi->nx_flags,
23451 +               (unsigned long long)nxi->nx_ncaps);
23452 +       return length;
23453 +}
23454 +
23455 +
23456 +
23457 +/* here the inode helpers */
23458 +
23459 +struct vs_entry {
23460 +       int len;
23461 +       char *name;
23462 +       mode_t mode;
23463 +       struct inode_operations *iop;
23464 +       struct file_operations *fop;
23465 +       union proc_op op;
23466 +};
23467 +
23468 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23469 +{
23470 +       struct inode *inode = new_inode(sb);
23471 +
23472 +       if (!inode)
23473 +               goto out;
23474 +
23475 +       inode->i_mode = p->mode;
23476 +       if (p->iop)
23477 +               inode->i_op = p->iop;
23478 +       if (p->fop)
23479 +               inode->i_fop = p->fop;
23480 +
23481 +       inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23482 +       inode->i_flags |= S_IMMUTABLE;
23483 +
23484 +       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23485 +
23486 +       inode->i_uid = 0;
23487 +       inode->i_gid = 0;
23488 +       inode->i_tag = 0;
23489 +out:
23490 +       return inode;
23491 +}
23492 +
23493 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23494 +       struct dentry *dentry, int id, void *ptr)
23495 +{
23496 +       struct vs_entry *p = ptr;
23497 +       struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23498 +       struct dentry *error = ERR_PTR(-EINVAL);
23499 +
23500 +       if (!inode)
23501 +               goto out;
23502 +
23503 +       PROC_I(inode)->op = p->op;
23504 +       PROC_I(inode)->fd = id;
23505 +       d_add(dentry, inode);
23506 +       error = NULL;
23507 +out:
23508 +       return error;
23509 +}
23510 +
23511 +/* Lookups */
23512 +
23513 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23514 +
23515 +/*
23516 + * Fill a directory entry.
23517 + *
23518 + * If possible create the dcache entry and derive our inode number and
23519 + * file type from dcache entry.
23520 + *
23521 + * Since all of the proc inode numbers are dynamically generated, the inode
23522 + * numbers do not exist until the inode is cache.  This means creating the
23523 + * the dcache entry in readdir is necessary to keep the inode numbers
23524 + * reported by readdir in sync with the inode numbers reported
23525 + * by stat.
23526 + */
23527 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23528 +       char *name, int len, instantiate_t instantiate, int id, void *ptr)
23529 +{
23530 +       struct dentry *child, *dir = filp->f_dentry;
23531 +       struct inode *inode;
23532 +       struct qstr qname;
23533 +       ino_t ino = 0;
23534 +       unsigned type = DT_UNKNOWN;
23535 +
23536 +       qname.name = name;
23537 +       qname.len  = len;
23538 +       qname.hash = full_name_hash(name, len);
23539 +
23540 +       child = d_lookup(dir, &qname);
23541 +       if (!child) {
23542 +               struct dentry *new;
23543 +               new = d_alloc(dir, &qname);
23544 +               if (new) {
23545 +                       child = instantiate(dir->d_inode, new, id, ptr);
23546 +                       if (child)
23547 +                               dput(new);
23548 +                       else
23549 +                               child = new;
23550 +               }
23551 +       }
23552 +       if (!child || IS_ERR(child) || !child->d_inode)
23553 +               goto end_instantiate;
23554 +       inode = child->d_inode;
23555 +       if (inode) {
23556 +               ino = inode->i_ino;
23557 +               type = inode->i_mode >> 12;
23558 +       }
23559 +       dput(child);
23560 +end_instantiate:
23561 +       if (!ino)
23562 +               ino = find_inode_number(dir, &qname);
23563 +       if (!ino)
23564 +               ino = 1;
23565 +       return filldir(dirent, name, len, filp->f_pos, ino, type);
23566 +}
23567 +
23568 +
23569 +
23570 +/* get and revalidate vx_info/xid */
23571 +
23572 +static inline
23573 +struct vx_info *get_proc_vx_info(struct inode *inode)
23574 +{
23575 +       return lookup_vx_info(PROC_I(inode)->fd);
23576 +}
23577 +
23578 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23579 +{
23580 +       struct inode *inode = dentry->d_inode;
23581 +       xid_t xid = PROC_I(inode)->fd;
23582 +
23583 +       if (!xid || xid_is_hashed(xid))
23584 +               return 1;
23585 +       d_drop(dentry);
23586 +       return 0;
23587 +}
23588 +
23589 +
23590 +/* get and revalidate nx_info/nid */
23591 +
23592 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23593 +{
23594 +       struct inode *inode = dentry->d_inode;
23595 +       nid_t nid = PROC_I(inode)->fd;
23596 +
23597 +       if (!nid || nid_is_hashed(nid))
23598 +               return 1;
23599 +       d_drop(dentry);
23600 +       return 0;
23601 +}
23602 +
23603 +
23604 +
23605 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23606 +
23607 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23608 +                         size_t count, loff_t *ppos)
23609 +{
23610 +       struct inode *inode = file->f_dentry->d_inode;
23611 +       unsigned long page;
23612 +       ssize_t length = 0;
23613 +
23614 +       if (count > PROC_BLOCK_SIZE)
23615 +               count = PROC_BLOCK_SIZE;
23616 +
23617 +       /* fade that out as soon as stable */
23618 +       WARN_ON(PROC_I(inode)->fd);
23619 +
23620 +       if (!(page = __get_free_page(GFP_KERNEL)))
23621 +               return -ENOMEM;
23622 +
23623 +       BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23624 +       length = PROC_I(inode)->op.proc_vs_read((char *)page);
23625 +
23626 +       if (length >= 0)
23627 +               length = simple_read_from_buffer(buf, count, ppos,
23628 +                       (char *)page, length);
23629 +
23630 +       free_page(page);
23631 +       return length;
23632 +}
23633 +
23634 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23635 +                         size_t count, loff_t *ppos)
23636 +{
23637 +       struct inode *inode = file->f_dentry->d_inode;
23638 +       struct vx_info *vxi = NULL;
23639 +       xid_t xid = PROC_I(inode)->fd;
23640 +       unsigned long page;
23641 +       ssize_t length = 0;
23642 +
23643 +       if (count > PROC_BLOCK_SIZE)
23644 +               count = PROC_BLOCK_SIZE;
23645 +
23646 +       /* fade that out as soon as stable */
23647 +       WARN_ON(!xid);
23648 +       vxi = lookup_vx_info(xid);
23649 +       if (!vxi)
23650 +               goto out;
23651 +
23652 +       length = -ENOMEM;
23653 +       if (!(page = __get_free_page(GFP_KERNEL)))
23654 +               goto out_put;
23655 +
23656 +       BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23657 +       length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23658 +
23659 +       if (length >= 0)
23660 +               length = simple_read_from_buffer(buf, count, ppos,
23661 +                       (char *)page, length);
23662 +
23663 +       free_page(page);
23664 +out_put:
23665 +       put_vx_info(vxi);
23666 +out:
23667 +       return length;
23668 +}
23669 +
23670 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23671 +                         size_t count, loff_t *ppos)
23672 +{
23673 +       struct inode *inode = file->f_dentry->d_inode;
23674 +       struct nx_info *nxi = NULL;
23675 +       nid_t nid = PROC_I(inode)->fd;
23676 +       unsigned long page;
23677 +       ssize_t length = 0;
23678 +
23679 +       if (count > PROC_BLOCK_SIZE)
23680 +               count = PROC_BLOCK_SIZE;
23681 +
23682 +       /* fade that out as soon as stable */
23683 +       WARN_ON(!nid);
23684 +       nxi = lookup_nx_info(nid);
23685 +       if (!nxi)
23686 +               goto out;
23687 +
23688 +       length = -ENOMEM;
23689 +       if (!(page = __get_free_page(GFP_KERNEL)))
23690 +               goto out_put;
23691 +
23692 +       BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23693 +       length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23694 +
23695 +       if (length >= 0)
23696 +               length = simple_read_from_buffer(buf, count, ppos,
23697 +                       (char *)page, length);
23698 +
23699 +       free_page(page);
23700 +out_put:
23701 +       put_nx_info(nxi);
23702 +out:
23703 +       return length;
23704 +}
23705 +
23706 +
23707 +
23708 +/* here comes the lower level */
23709 +
23710 +
23711 +#define NOD(NAME, MODE, IOP, FOP, OP) {        \
23712 +       .len  = sizeof(NAME) - 1,       \
23713 +       .name = (NAME),                 \
23714 +       .mode = MODE,                   \
23715 +       .iop  = IOP,                    \
23716 +       .fop  = FOP,                    \
23717 +       .op   = OP,                     \
23718 +}
23719 +
23720 +
23721 +#define DIR(NAME, MODE, OTYPE)                         \
23722 +       NOD(NAME, (S_IFDIR | (MODE)),                   \
23723 +               &proc_ ## OTYPE ## _inode_operations,   \
23724 +               &proc_ ## OTYPE ## _file_operations, { } )
23725 +
23726 +#define INF(NAME, MODE, OTYPE)                         \
23727 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23728 +               &proc_vs_info_file_operations,          \
23729 +               { .proc_vs_read = &proc_##OTYPE } )
23730 +
23731 +#define VINF(NAME, MODE, OTYPE)                                \
23732 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23733 +               &proc_vx_info_file_operations,          \
23734 +               { .proc_vxi_read = &proc_##OTYPE } )
23735 +
23736 +#define NINF(NAME, MODE, OTYPE)                                \
23737 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23738 +               &proc_nx_info_file_operations,          \
23739 +               { .proc_nxi_read = &proc_##OTYPE } )
23740 +
23741 +
23742 +static struct file_operations proc_vs_info_file_operations = {
23743 +       .read =         proc_vs_info_read,
23744 +};
23745 +
23746 +static struct file_operations proc_vx_info_file_operations = {
23747 +       .read =         proc_vx_info_read,
23748 +};
23749 +
23750 +static struct dentry_operations proc_xid_dentry_operations = {
23751 +       .d_revalidate = proc_xid_revalidate,
23752 +};
23753 +
23754 +static struct vs_entry vx_base_stuff[] = {
23755 +       VINF("info",    S_IRUGO, vxi_info),
23756 +       VINF("status",  S_IRUGO, vxi_status),
23757 +       VINF("limit",   S_IRUGO, vxi_limit),
23758 +       VINF("sched",   S_IRUGO, vxi_sched),
23759 +       VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23760 +       VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23761 +       VINF("cvirt",   S_IRUGO, vxi_cvirt),
23762 +       VINF("cacct",   S_IRUGO, vxi_cacct),
23763 +       {}
23764 +};
23765 +
23766 +
23767 +
23768 +
23769 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23770 +       struct dentry *dentry, int id, void *ptr)
23771 +{
23772 +       dentry->d_op = &proc_xid_dentry_operations;
23773 +       return vs_proc_instantiate(dir, dentry, id, ptr);
23774 +}
23775 +
23776 +static struct dentry *proc_xid_lookup(struct inode *dir,
23777 +       struct dentry *dentry, struct nameidata *nd)
23778 +{
23779 +       struct vs_entry *p = vx_base_stuff;
23780 +       struct dentry *error = ERR_PTR(-ENOENT);
23781 +
23782 +       for (; p->name; p++) {
23783 +               if (p->len != dentry->d_name.len)
23784 +                       continue;
23785 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23786 +                       break;
23787 +       }
23788 +       if (!p->name)
23789 +               goto out;
23790 +
23791 +       error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23792 +out:
23793 +       return error;
23794 +}
23795 +
23796 +static int proc_xid_readdir(struct file *filp,
23797 +       void *dirent, filldir_t filldir)
23798 +{
23799 +       struct dentry *dentry = filp->f_dentry;
23800 +       struct inode *inode = dentry->d_inode;
23801 +       struct vs_entry *p = vx_base_stuff;
23802 +       int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23803 +       int pos, index;
23804 +       u64 ino;
23805 +
23806 +       pos = filp->f_pos;
23807 +       switch (pos) {
23808 +       case 0:
23809 +               ino = inode->i_ino;
23810 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23811 +                       goto out;
23812 +               pos++;
23813 +               /* fall through */
23814 +       case 1:
23815 +               ino = parent_ino(dentry);
23816 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23817 +                       goto out;
23818 +               pos++;
23819 +               /* fall through */
23820 +       default:
23821 +               index = pos - 2;
23822 +               if (index >= size)
23823 +                       goto out;
23824 +               for (p += index; p->name; p++) {
23825 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23826 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
23827 +                               goto out;
23828 +                       pos++;
23829 +               }
23830 +       }
23831 +out:
23832 +       filp->f_pos = pos;
23833 +       return 1;
23834 +}
23835 +
23836 +
23837 +
23838 +static struct file_operations proc_nx_info_file_operations = {
23839 +       .read =         proc_nx_info_read,
23840 +};
23841 +
23842 +static struct dentry_operations proc_nid_dentry_operations = {
23843 +       .d_revalidate = proc_nid_revalidate,
23844 +};
23845 +
23846 +static struct vs_entry nx_base_stuff[] = {
23847 +       NINF("info",    S_IRUGO, nxi_info),
23848 +       NINF("status",  S_IRUGO, nxi_status),
23849 +       {}
23850 +};
23851 +
23852 +
23853 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23854 +       struct dentry *dentry, int id, void *ptr)
23855 +{
23856 +       dentry->d_op = &proc_nid_dentry_operations;
23857 +       return vs_proc_instantiate(dir, dentry, id, ptr);
23858 +}
23859 +
23860 +static struct dentry *proc_nid_lookup(struct inode *dir,
23861 +       struct dentry *dentry, struct nameidata *nd)
23862 +{
23863 +       struct vs_entry *p = nx_base_stuff;
23864 +       struct dentry *error = ERR_PTR(-ENOENT);
23865 +
23866 +       for (; p->name; p++) {
23867 +               if (p->len != dentry->d_name.len)
23868 +                       continue;
23869 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23870 +                       break;
23871 +       }
23872 +       if (!p->name)
23873 +               goto out;
23874 +
23875 +       error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23876 +out:
23877 +       return error;
23878 +}
23879 +
23880 +static int proc_nid_readdir(struct file *filp,
23881 +       void *dirent, filldir_t filldir)
23882 +{
23883 +       struct dentry *dentry = filp->f_dentry;
23884 +       struct inode *inode = dentry->d_inode;
23885 +       struct vs_entry *p = nx_base_stuff;
23886 +       int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23887 +       int pos, index;
23888 +       u64 ino;
23889 +
23890 +       pos = filp->f_pos;
23891 +       switch (pos) {
23892 +       case 0:
23893 +               ino = inode->i_ino;
23894 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23895 +                       goto out;
23896 +               pos++;
23897 +               /* fall through */
23898 +       case 1:
23899 +               ino = parent_ino(dentry);
23900 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23901 +                       goto out;
23902 +               pos++;
23903 +               /* fall through */
23904 +       default:
23905 +               index = pos - 2;
23906 +               if (index >= size)
23907 +                       goto out;
23908 +               for (p += index; p->name; p++) {
23909 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23910 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
23911 +                               goto out;
23912 +                       pos++;
23913 +               }
23914 +       }
23915 +out:
23916 +       filp->f_pos = pos;
23917 +       return 1;
23918 +}
23919 +
23920 +
23921 +#define MAX_MULBY10    ((~0U - 9) / 10)
23922 +
23923 +static inline int atovid(const char *str, int len)
23924 +{
23925 +       int vid, c;
23926 +
23927 +       vid = 0;
23928 +       while (len-- > 0) {
23929 +               c = *str - '0';
23930 +               str++;
23931 +               if (c > 9)
23932 +                       return -1;
23933 +               if (vid >= MAX_MULBY10)
23934 +                       return -1;
23935 +               vid *= 10;
23936 +               vid += c;
23937 +               if (!vid)
23938 +                       return -1;
23939 +       }
23940 +       return vid;
23941 +}
23942 +
23943 +/* now the upper level (virtual) */
23944 +
23945 +
23946 +static struct file_operations proc_xid_file_operations = {
23947 +       .read =         generic_read_dir,
23948 +       .readdir =      proc_xid_readdir,
23949 +};
23950 +
23951 +static struct inode_operations proc_xid_inode_operations = {
23952 +       .lookup =       proc_xid_lookup,
23953 +};
23954 +
23955 +static struct vs_entry vx_virtual_stuff[] = {
23956 +       INF("info",     S_IRUGO, virtual_info),
23957 +       INF("status",   S_IRUGO, virtual_status),
23958 +       DIR(NULL,       S_IRUGO | S_IXUGO, xid),
23959 +};
23960 +
23961 +
23962 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23963 +       struct dentry *dentry, struct nameidata *nd)
23964 +{
23965 +       struct vs_entry *p = vx_virtual_stuff;
23966 +       struct dentry *error = ERR_PTR(-ENOENT);
23967 +       int id = 0;
23968 +
23969 +       for (; p->name; p++) {
23970 +               if (p->len != dentry->d_name.len)
23971 +                       continue;
23972 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23973 +                       break;
23974 +       }
23975 +       if (p->name)
23976 +               goto instantiate;
23977 +
23978 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
23979 +       if ((id < 0) || !xid_is_hashed(id))
23980 +               goto out;
23981 +
23982 +instantiate:
23983 +       error = proc_xid_instantiate(dir, dentry, id, p);
23984 +out:
23985 +       return error;
23986 +}
23987 +
23988 +static struct file_operations proc_nid_file_operations = {
23989 +       .read =         generic_read_dir,
23990 +       .readdir =      proc_nid_readdir,
23991 +};
23992 +
23993 +static struct inode_operations proc_nid_inode_operations = {
23994 +       .lookup =       proc_nid_lookup,
23995 +};
23996 +
23997 +static struct vs_entry nx_virtnet_stuff[] = {
23998 +       INF("info",     S_IRUGO, virtnet_info),
23999 +       INF("status",   S_IRUGO, virtnet_status),
24000 +       DIR(NULL,       S_IRUGO | S_IXUGO, nid),
24001 +};
24002 +
24003 +
24004 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
24005 +       struct dentry *dentry, struct nameidata *nd)
24006 +{
24007 +       struct vs_entry *p = nx_virtnet_stuff;
24008 +       struct dentry *error = ERR_PTR(-ENOENT);
24009 +       int id = 0;
24010 +
24011 +       for (; p->name; p++) {
24012 +               if (p->len != dentry->d_name.len)
24013 +                       continue;
24014 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24015 +                       break;
24016 +       }
24017 +       if (p->name)
24018 +               goto instantiate;
24019 +
24020 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
24021 +       if ((id < 0) || !nid_is_hashed(id))
24022 +               goto out;
24023 +
24024 +instantiate:
24025 +       error = proc_nid_instantiate(dir, dentry, id, p);
24026 +out:
24027 +       return error;
24028 +}
24029 +
24030 +
24031 +#define PROC_MAXVIDS 32
24032 +
24033 +int proc_virtual_readdir(struct file *filp,
24034 +       void *dirent, filldir_t filldir)
24035 +{
24036 +       struct dentry *dentry = filp->f_dentry;
24037 +       struct inode *inode = dentry->d_inode;
24038 +       struct vs_entry *p = vx_virtual_stuff;
24039 +       int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24040 +       int pos, index;
24041 +       unsigned int xid_array[PROC_MAXVIDS];
24042 +       char buf[PROC_NUMBUF];
24043 +       unsigned int nr_xids, i;
24044 +       u64 ino;
24045 +
24046 +       pos = filp->f_pos;
24047 +       switch (pos) {
24048 +       case 0:
24049 +               ino = inode->i_ino;
24050 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24051 +                       goto out;
24052 +               pos++;
24053 +               /* fall through */
24054 +       case 1:
24055 +               ino = parent_ino(dentry);
24056 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24057 +                       goto out;
24058 +               pos++;
24059 +               /* fall through */
24060 +       default:
24061 +               index = pos - 2;
24062 +               if (index >= size)
24063 +                       goto entries;
24064 +               for (p += index; p->name; p++) {
24065 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24066 +                               vs_proc_instantiate, 0, p))
24067 +                               goto out;
24068 +                       pos++;
24069 +               }
24070 +       entries:
24071 +               index = pos - size;
24072 +               p = &vx_virtual_stuff[size - 1];
24073 +               nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24074 +               for (i = 0; i < nr_xids; i++) {
24075 +                       int n, xid = xid_array[i];
24076 +                       unsigned int j = PROC_NUMBUF;
24077 +
24078 +                       n = xid;
24079 +                       do
24080 +                               buf[--j] = '0' + (n % 10);
24081 +                       while (n /= 10);
24082 +
24083 +                       if (proc_fill_cache(filp, dirent, filldir,
24084 +                               buf + j, PROC_NUMBUF - j,
24085 +                               vs_proc_instantiate, xid, p))
24086 +                               goto out;
24087 +                       pos++;
24088 +               }
24089 +       }
24090 +out:
24091 +       filp->f_pos = pos;
24092 +       return 0;
24093 +}
24094 +
24095 +static int proc_virtual_getattr(struct vfsmount *mnt,
24096 +       struct dentry *dentry, struct kstat *stat)
24097 +{
24098 +       struct inode *inode = dentry->d_inode;
24099 +
24100 +       generic_fillattr(inode, stat);
24101 +       stat->nlink = 2 + atomic_read(&vx_global_cactive);
24102 +       return 0;
24103 +}
24104 +
24105 +static struct file_operations proc_virtual_dir_operations = {
24106 +       .read =         generic_read_dir,
24107 +       .readdir =      proc_virtual_readdir,
24108 +};
24109 +
24110 +static struct inode_operations proc_virtual_dir_inode_operations = {
24111 +       .getattr =      proc_virtual_getattr,
24112 +       .lookup =       proc_virtual_lookup,
24113 +};
24114 +
24115 +
24116 +
24117 +
24118 +
24119 +int proc_virtnet_readdir(struct file *filp,
24120 +       void *dirent, filldir_t filldir)
24121 +{
24122 +       struct dentry *dentry = filp->f_dentry;
24123 +       struct inode *inode = dentry->d_inode;
24124 +       struct vs_entry *p = nx_virtnet_stuff;
24125 +       int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24126 +       int pos, index;
24127 +       unsigned int nid_array[PROC_MAXVIDS];
24128 +       char buf[PROC_NUMBUF];
24129 +       unsigned int nr_nids, i;
24130 +       u64 ino;
24131 +
24132 +       pos = filp->f_pos;
24133 +       switch (pos) {
24134 +       case 0:
24135 +               ino = inode->i_ino;
24136 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24137 +                       goto out;
24138 +               pos++;
24139 +               /* fall through */
24140 +       case 1:
24141 +               ino = parent_ino(dentry);
24142 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24143 +                       goto out;
24144 +               pos++;
24145 +               /* fall through */
24146 +       default:
24147 +               index = pos - 2;
24148 +               if (index >= size)
24149 +                       goto entries;
24150 +               for (p += index; p->name; p++) {
24151 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24152 +                               vs_proc_instantiate, 0, p))
24153 +                               goto out;
24154 +                       pos++;
24155 +               }
24156 +       entries:
24157 +               index = pos - size;
24158 +               p = &nx_virtnet_stuff[size - 1];
24159 +               nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24160 +               for (i = 0; i < nr_nids; i++) {
24161 +                       int n, nid = nid_array[i];
24162 +                       unsigned int j = PROC_NUMBUF;
24163 +
24164 +                       n = nid;
24165 +                       do
24166 +                               buf[--j] = '0' + (n % 10);
24167 +                       while (n /= 10);
24168 +
24169 +                       if (proc_fill_cache(filp, dirent, filldir,
24170 +                               buf + j, PROC_NUMBUF - j,
24171 +                               vs_proc_instantiate, nid, p))
24172 +                               goto out;
24173 +                       pos++;
24174 +               }
24175 +       }
24176 +out:
24177 +       filp->f_pos = pos;
24178 +       return 0;
24179 +}
24180 +
24181 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24182 +       struct dentry *dentry, struct kstat *stat)
24183 +{
24184 +       struct inode *inode = dentry->d_inode;
24185 +
24186 +       generic_fillattr(inode, stat);
24187 +       stat->nlink = 2 + atomic_read(&nx_global_cactive);
24188 +       return 0;
24189 +}
24190 +
24191 +static struct file_operations proc_virtnet_dir_operations = {
24192 +       .read =         generic_read_dir,
24193 +       .readdir =      proc_virtnet_readdir,
24194 +};
24195 +
24196 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24197 +       .getattr =      proc_virtnet_getattr,
24198 +       .lookup =       proc_virtnet_lookup,
24199 +};
24200 +
24201 +
24202 +
24203 +void proc_vx_init(void)
24204 +{
24205 +       struct proc_dir_entry *ent;
24206 +
24207 +       ent = proc_mkdir("virtual", 0);
24208 +       if (ent) {
24209 +               ent->proc_fops = &proc_virtual_dir_operations;
24210 +               ent->proc_iops = &proc_virtual_dir_inode_operations;
24211 +       }
24212 +       proc_virtual = ent;
24213 +
24214 +       ent = proc_mkdir("virtnet", 0);
24215 +       if (ent) {
24216 +               ent->proc_fops = &proc_virtnet_dir_operations;
24217 +               ent->proc_iops = &proc_virtnet_dir_inode_operations;
24218 +       }
24219 +       proc_virtnet = ent;
24220 +}
24221 +
24222 +
24223 +
24224 +
24225 +/* per pid info */
24226 +
24227 +
24228 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24229 +{
24230 +       struct vx_info *vxi;
24231 +       char *orig = buffer;
24232 +
24233 +       buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24234 +
24235 +       vxi = task_get_vx_info(p);
24236 +       if (!vxi)
24237 +               goto out;
24238 +
24239 +       buffer += sprintf(buffer, "BCaps:\t");
24240 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24241 +       buffer += sprintf(buffer, "\n");
24242 +       buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24243 +               (unsigned long long)vxi->vx_ccaps);
24244 +       buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24245 +               (unsigned long long)vxi->vx_flags);
24246 +       buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24247 +
24248 +       put_vx_info(vxi);
24249 +out:
24250 +       return buffer - orig;
24251 +}
24252 +
24253 +
24254 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24255 +{
24256 +       struct nx_info *nxi;
24257 +       struct nx_addr_v4 *v4a;
24258 +#ifdef CONFIG_IPV6
24259 +       struct nx_addr_v6 *v6a;
24260 +#endif
24261 +       char *orig = buffer;
24262 +       int i;
24263 +
24264 +       buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24265 +
24266 +       nxi = task_get_nx_info(p);
24267 +       if (!nxi)
24268 +               goto out;
24269 +
24270 +       buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24271 +               (unsigned long long)nxi->nx_ncaps);
24272 +       buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24273 +               (unsigned long long)nxi->nx_flags);
24274 +
24275 +       buffer += sprintf(buffer,
24276 +               "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24277 +               NIPQUAD(nxi->v4_bcast.s_addr));
24278 +       buffer += sprintf (buffer,
24279 +               "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24280 +               NIPQUAD(nxi->v4_lback.s_addr));
24281 +       if (!NX_IPV4(nxi))
24282 +               goto skip_v4;
24283 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24284 +               buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24285 +                       i, NXAV4(v4a));
24286 +skip_v4:
24287 +#ifdef CONFIG_IPV6
24288 +       if (!NX_IPV6(nxi))
24289 +               goto skip_v6;
24290 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24291 +               buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24292 +                       i, NXAV6(v6a));
24293 +skip_v6:
24294 +#endif
24295 +       put_nx_info(nxi);
24296 +out:
24297 +       return buffer - orig;
24298 +}
24299 +
24300 diff -NurpP --minimal linux-2.6.34/kernel/vserver/sched.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/sched.c
24301 --- linux-2.6.34/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
24302 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/sched.c    2010-05-18 18:11:22.000000000 +0200
24303 @@ -0,0 +1,414 @@
24304 +/*
24305 + *  linux/kernel/vserver/sched.c
24306 + *
24307 + *  Virtual Server: Scheduler Support
24308 + *
24309 + *  Copyright (C) 2004-2007  Herbert Pötzl
24310 + *
24311 + *  V0.01  adapted Sam Vilains version to 2.6.3
24312 + *  V0.02  removed legacy interface
24313 + *  V0.03  changed vcmds to vxi arg
24314 + *  V0.04  removed older and legacy interfaces
24315 + *
24316 + */
24317 +
24318 +#include <linux/vs_context.h>
24319 +#include <linux/vs_sched.h>
24320 +#include <linux/vserver/sched_cmd.h>
24321 +
24322 +#include <asm/uaccess.h>
24323 +
24324 +
24325 +#define vxd_check_range(val, min, max) do {            \
24326 +       vxlprintk((val < min) || (val > max),           \
24327 +               "check_range(%ld,%ld,%ld)",             \
24328 +               (long)val, (long)min, (long)max,        \
24329 +               __FILE__, __LINE__);                    \
24330 +       } while (0)
24331 +
24332 +
24333 +void vx_update_sched_param(struct _vx_sched *sched,
24334 +       struct _vx_sched_pc *sched_pc)
24335 +{
24336 +       unsigned int set_mask = sched->update_mask;
24337 +
24338 +       if (set_mask & VXSM_FILL_RATE)
24339 +               sched_pc->fill_rate[0] = sched->fill_rate[0];
24340 +       if (set_mask & VXSM_INTERVAL)
24341 +               sched_pc->interval[0] = sched->interval[0];
24342 +       if (set_mask & VXSM_FILL_RATE2)
24343 +               sched_pc->fill_rate[1] = sched->fill_rate[1];
24344 +       if (set_mask & VXSM_INTERVAL2)
24345 +               sched_pc->interval[1] = sched->interval[1];
24346 +       if (set_mask & VXSM_TOKENS)
24347 +               sched_pc->tokens = sched->tokens;
24348 +       if (set_mask & VXSM_TOKENS_MIN)
24349 +               sched_pc->tokens_min = sched->tokens_min;
24350 +       if (set_mask & VXSM_TOKENS_MAX)
24351 +               sched_pc->tokens_max = sched->tokens_max;
24352 +       if (set_mask & VXSM_PRIO_BIAS)
24353 +               sched_pc->prio_bias = sched->prio_bias;
24354 +
24355 +       if (set_mask & VXSM_IDLE_TIME)
24356 +               sched_pc->flags |= VXSF_IDLE_TIME;
24357 +       else
24358 +               sched_pc->flags &= ~VXSF_IDLE_TIME;
24359 +
24360 +       /* reset time */
24361 +       sched_pc->norm_time = jiffies;
24362 +}
24363 +
24364 +
24365 +/*
24366 + * recalculate the context's scheduling tokens
24367 + *
24368 + * ret > 0 : number of tokens available
24369 + * ret < 0 : on hold, check delta_min[]
24370 + *          -1 only jiffies
24371 + *          -2 also idle time
24372 + *
24373 + */
24374 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24375 +       unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24376 +{
24377 +       long delta;
24378 +       long tokens = 0;
24379 +       int flags = sched_pc->flags;
24380 +
24381 +       /* how much time did pass? */
24382 +       delta = *norm_time - sched_pc->norm_time;
24383 +       // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
24384 +       vxd_check_range(delta, 0, INT_MAX);
24385 +
24386 +       if (delta >= sched_pc->interval[0]) {
24387 +               long tokens, integral;
24388 +
24389 +               /* calc integral token part */
24390 +               tokens = delta / sched_pc->interval[0];
24391 +               integral = tokens * sched_pc->interval[0];
24392 +               tokens *= sched_pc->fill_rate[0];
24393 +#ifdef CONFIG_VSERVER_HARDCPU
24394 +               delta_min[0] = delta - integral;
24395 +               vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24396 +#endif
24397 +               /* advance time */
24398 +               sched_pc->norm_time += delta;
24399 +
24400 +               /* add tokens */
24401 +               sched_pc->tokens += tokens;
24402 +               sched_pc->token_time += tokens;
24403 +       } else
24404 +               delta_min[0] = delta;
24405 +
24406 +#ifdef CONFIG_VSERVER_IDLETIME
24407 +       if (!(flags & VXSF_IDLE_TIME))
24408 +               goto skip_idle;
24409 +
24410 +       /* how much was the idle skip? */
24411 +       delta = *idle_time - sched_pc->idle_time;
24412 +       vxd_check_range(delta, 0, INT_MAX);
24413 +
24414 +       if (delta >= sched_pc->interval[1]) {
24415 +               long tokens, integral;
24416 +
24417 +               /* calc fair share token part */
24418 +               tokens = delta / sched_pc->interval[1];
24419 +               integral = tokens * sched_pc->interval[1];
24420 +               tokens *= sched_pc->fill_rate[1];
24421 +               delta_min[1] = delta - integral;
24422 +               vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24423 +
24424 +               /* advance idle time */
24425 +               sched_pc->idle_time += integral;
24426 +
24427 +               /* add tokens */
24428 +               sched_pc->tokens += tokens;
24429 +               sched_pc->token_time += tokens;
24430 +       } else
24431 +               delta_min[1] = delta;
24432 +skip_idle:
24433 +#endif
24434 +
24435 +       /* clip at maximum */
24436 +       if (sched_pc->tokens > sched_pc->tokens_max)
24437 +               sched_pc->tokens = sched_pc->tokens_max;
24438 +       tokens = sched_pc->tokens;
24439 +
24440 +       if ((flags & VXSF_ONHOLD)) {
24441 +               /* can we unhold? */
24442 +               if (tokens >= sched_pc->tokens_min) {
24443 +                       flags &= ~VXSF_ONHOLD;
24444 +                       sched_pc->hold_ticks +=
24445 +                               *norm_time - sched_pc->onhold;
24446 +               } else
24447 +                       goto on_hold;
24448 +       } else {
24449 +               /* put on hold? */
24450 +               if (tokens <= 0) {
24451 +                       flags |= VXSF_ONHOLD;
24452 +                       sched_pc->onhold = *norm_time;
24453 +                       goto on_hold;
24454 +               }
24455 +       }
24456 +       sched_pc->flags = flags;
24457 +       return tokens;
24458 +
24459 +on_hold:
24460 +       tokens = sched_pc->tokens_min - tokens;
24461 +       sched_pc->flags = flags;
24462 +       // BUG_ON(tokens < 0); probably doesn't hold anymore
24463 +
24464 +#ifdef CONFIG_VSERVER_HARDCPU
24465 +       /* next interval? */
24466 +       if (!sched_pc->fill_rate[0])
24467 +               delta_min[0] = HZ;
24468 +       else if (tokens > sched_pc->fill_rate[0])
24469 +               delta_min[0] += sched_pc->interval[0] *
24470 +                       tokens / sched_pc->fill_rate[0];
24471 +       else
24472 +               delta_min[0] = sched_pc->interval[0] - delta_min[0];
24473 +       vxd_check_range(delta_min[0], 0, INT_MAX);
24474 +
24475 +#ifdef CONFIG_VSERVER_IDLETIME
24476 +       if (!(flags & VXSF_IDLE_TIME))
24477 +               return -1;
24478 +
24479 +       /* next interval? */
24480 +       if (!sched_pc->fill_rate[1])
24481 +               delta_min[1] = HZ;
24482 +       else if (tokens > sched_pc->fill_rate[1])
24483 +               delta_min[1] += sched_pc->interval[1] *
24484 +                       tokens / sched_pc->fill_rate[1];
24485 +       else
24486 +               delta_min[1] = sched_pc->interval[1] - delta_min[1];
24487 +       vxd_check_range(delta_min[1], 0, INT_MAX);
24488 +
24489 +       return -2;
24490 +#else
24491 +       return -1;
24492 +#endif /* CONFIG_VSERVER_IDLETIME */
24493 +#else
24494 +       return 0;
24495 +#endif /* CONFIG_VSERVER_HARDCPU */
24496 +}
24497 +
24498 +static inline unsigned long msec_to_ticks(unsigned long msec)
24499 +{
24500 +       return msecs_to_jiffies(msec);
24501 +}
24502 +
24503 +static inline unsigned long ticks_to_msec(unsigned long ticks)
24504 +{
24505 +       return jiffies_to_msecs(ticks);
24506 +}
24507 +
24508 +static inline unsigned long ticks_to_usec(unsigned long ticks)
24509 +{
24510 +       return jiffies_to_usecs(ticks);
24511 +}
24512 +
24513 +
24514 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
24515 +{
24516 +       unsigned int set_mask = data->mask;
24517 +       unsigned int update_mask;
24518 +       int i, cpu;
24519 +
24520 +       /* Sanity check data values */
24521 +       if (data->tokens_max <= 0)
24522 +               data->tokens_max = HZ;
24523 +       if (data->tokens_min < 0)
24524 +               data->tokens_min = HZ / 3;
24525 +       if (data->tokens_min >= data->tokens_max)
24526 +               data->tokens_min = data->tokens_max;
24527 +
24528 +       if (data->prio_bias > MAX_PRIO_BIAS)
24529 +               data->prio_bias = MAX_PRIO_BIAS;
24530 +       if (data->prio_bias < MIN_PRIO_BIAS)
24531 +               data->prio_bias = MIN_PRIO_BIAS;
24532 +
24533 +       spin_lock(&vxi->sched.tokens_lock);
24534 +
24535 +       /* sync up on delayed updates */
24536 +       for_each_cpu_mask(cpu, vxi->sched.update)
24537 +               vx_update_sched_param(&vxi->sched,
24538 +                       &vx_per_cpu(vxi, sched_pc, cpu));
24539 +
24540 +       if (set_mask & VXSM_FILL_RATE)
24541 +               vxi->sched.fill_rate[0] = data->fill_rate[0];
24542 +       if (set_mask & VXSM_FILL_RATE2)
24543 +               vxi->sched.fill_rate[1] = data->fill_rate[1];
24544 +       if (set_mask & VXSM_INTERVAL)
24545 +               vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
24546 +                       msec_to_ticks(data->interval[0]) : data->interval[0];
24547 +       if (set_mask & VXSM_INTERVAL2)
24548 +               vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
24549 +                       msec_to_ticks(data->interval[1]) : data->interval[1];
24550 +       if (set_mask & VXSM_TOKENS)
24551 +               vxi->sched.tokens = data->tokens;
24552 +       if (set_mask & VXSM_TOKENS_MIN)
24553 +               vxi->sched.tokens_min = data->tokens_min;
24554 +       if (set_mask & VXSM_TOKENS_MAX)
24555 +               vxi->sched.tokens_max = data->tokens_max;
24556 +       if (set_mask & VXSM_PRIO_BIAS)
24557 +               vxi->sched.prio_bias = data->prio_bias;
24558 +
24559 +       /* Sanity check rate/interval */
24560 +       for (i = 0; i < 2; i++) {
24561 +               if (data->fill_rate[i] < 0)
24562 +                       data->fill_rate[i] = 0;
24563 +               if (data->interval[i] <= 0)
24564 +                       data->interval[i] = HZ;
24565 +       }
24566 +
24567 +       update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
24568 +       update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
24569 +       vxi->sched.update_mask = update_mask;
24570 +
24571 +#ifdef CONFIG_SMP
24572 +       rmb();
24573 +       if (set_mask & VXSM_CPU_ID) {
24574 +               vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24575 +               cpus_and(vxi->sched.update, cpu_online_map,
24576 +                       vxi->sched.update);
24577 +       } else
24578 +               vxi->sched.update = cpu_online_map;
24579 +
24580 +       /* forced reload? */
24581 +       if (set_mask & VXSM_FORCE) {
24582 +               for_each_cpu_mask(cpu, vxi->sched.update)
24583 +                       vx_update_sched_param(&vxi->sched,
24584 +                               &vx_per_cpu(vxi, sched_pc, cpu));
24585 +               vxi->sched.update = CPU_MASK_NONE;
24586 +       }
24587 +#else
24588 +       /* on UP we update immediately */
24589 +       vx_update_sched_param(&vxi->sched,
24590 +               &vx_per_cpu(vxi, sched_pc, 0));
24591 +#endif
24592 +
24593 +       spin_unlock(&vxi->sched.tokens_lock);
24594 +       return 0;
24595 +}
24596 +
24597 +
24598 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
24599 +#define COPY_PRI(C) C(prio_bias)
24600 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24601 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]);   \
24602 +                   C(fill_rate[1]); C(interval[1]);
24603 +
24604 +#define COPY_VALUE(name) vc_data.name = data->name
24605 +
24606 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
24607 +{
24608 +       struct vcmd_sched_v5 vc_data;
24609 +
24610 +       vc_data.mask = data->set_mask;
24611 +       COPY_IDS(COPY_VALUE);
24612 +       COPY_PRI(COPY_VALUE);
24613 +       COPY_TOK(COPY_VALUE);
24614 +       vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
24615 +       vc_data.interval[0] = vc_data.interval[1] = data->interval;
24616 +       return do_set_sched(vxi, &vc_data);
24617 +}
24618 +
24619 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
24620 +{
24621 +       struct vcmd_set_sched_v4 vc_data;
24622 +
24623 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24624 +               return -EFAULT;
24625 +
24626 +       return do_set_sched_v4(vxi, &vc_data);
24627 +}
24628 +
24629 +       /* latest interface is v5 */
24630 +
24631 +int vc_set_sched(struct vx_info *vxi, void __user *data)
24632 +{
24633 +       struct vcmd_sched_v5 vc_data;
24634 +
24635 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24636 +               return -EFAULT;
24637 +
24638 +       return do_set_sched(vxi, &vc_data);
24639 +}
24640 +
24641 +
24642 +#define COPY_PRI(C) C(prio_bias)
24643 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
24644 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]);    \
24645 +                   C(fill_rate[1]); C(interval[1]);
24646 +
24647 +#define COPY_VALUE(name) vc_data.name = data->name
24648 +
24649 +
24650 +int vc_get_sched(struct vx_info *vxi, void __user *data)
24651 +{
24652 +       struct vcmd_sched_v5 vc_data;
24653 +
24654 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24655 +               return -EFAULT;
24656 +
24657 +       if (vc_data.mask & VXSM_CPU_ID) {
24658 +               int cpu = vc_data.cpu_id;
24659 +               struct _vx_sched_pc *data;
24660 +
24661 +               if (!cpu_possible(cpu))
24662 +                       return -EINVAL;
24663 +
24664 +               data = &vx_per_cpu(vxi, sched_pc, cpu);
24665 +               COPY_TOK(COPY_VALUE);
24666 +               COPY_PRI(COPY_VALUE);
24667 +               COPY_FRI(COPY_VALUE);
24668 +
24669 +               if (data->flags & VXSF_IDLE_TIME)
24670 +                       vc_data.mask |= VXSM_IDLE_TIME;
24671 +       } else {
24672 +               struct _vx_sched *data = &vxi->sched;
24673 +
24674 +               COPY_TOK(COPY_VALUE);
24675 +               COPY_PRI(COPY_VALUE);
24676 +               COPY_FRI(COPY_VALUE);
24677 +       }
24678 +
24679 +       if (vc_data.mask & VXSM_MSEC) {
24680 +               vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
24681 +               vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
24682 +       }
24683 +
24684 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24685 +               return -EFAULT;
24686 +       return 0;
24687 +}
24688 +
24689 +
24690 +int vc_sched_info(struct vx_info *vxi, void __user *data)
24691 +{
24692 +       struct vcmd_sched_info vc_data;
24693 +       int cpu;
24694 +
24695 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24696 +               return -EFAULT;
24697 +
24698 +       cpu = vc_data.cpu_id;
24699 +       if (!cpu_possible(cpu))
24700 +               return -EINVAL;
24701 +
24702 +       if (vxi) {
24703 +               struct _vx_sched_pc *sched_pc =
24704 +                       &vx_per_cpu(vxi, sched_pc, cpu);
24705 +
24706 +               vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
24707 +               vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
24708 +               vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
24709 +               vc_data.vavavoom = sched_pc->vavavoom;
24710 +       }
24711 +       vc_data.token_usec = ticks_to_usec(1);
24712 +
24713 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24714 +               return -EFAULT;
24715 +       return 0;
24716 +}
24717 +
24718 diff -NurpP --minimal linux-2.6.34/kernel/vserver/sched_init.h linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/sched_init.h
24719 --- linux-2.6.34/kernel/vserver/sched_init.h    1970-01-01 01:00:00.000000000 +0100
24720 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/sched_init.h       2010-05-18 18:11:22.000000000 +0200
24721 @@ -0,0 +1,50 @@
24722 +
24723 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24724 +{
24725 +       static struct lock_class_key tokens_lock_key;
24726 +
24727 +       /* scheduling; hard code starting values as constants */
24728 +       sched->fill_rate[0]     = 1;
24729 +       sched->interval[0]      = 4;
24730 +       sched->fill_rate[1]     = 1;
24731 +       sched->interval[1]      = 8;
24732 +       sched->tokens           = HZ >> 2;
24733 +       sched->tokens_min       = HZ >> 4;
24734 +       sched->tokens_max       = HZ >> 1;
24735 +       sched->tokens_lock      = SPIN_LOCK_UNLOCKED;
24736 +       sched->prio_bias        = 0;
24737 +
24738 +       lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
24739 +}
24740 +
24741 +static inline
24742 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24743 +{
24744 +       sched_pc->fill_rate[0]  = 1;
24745 +       sched_pc->interval[0]   = 4;
24746 +       sched_pc->fill_rate[1]  = 1;
24747 +       sched_pc->interval[1]   = 8;
24748 +       sched_pc->tokens        = HZ >> 2;
24749 +       sched_pc->tokens_min    = HZ >> 4;
24750 +       sched_pc->tokens_max    = HZ >> 1;
24751 +       sched_pc->prio_bias     = 0;
24752 +       sched_pc->vavavoom      = 0;
24753 +       sched_pc->token_time    = 0;
24754 +       sched_pc->idle_time     = 0;
24755 +       sched_pc->norm_time     = jiffies;
24756 +
24757 +       sched_pc->user_ticks = 0;
24758 +       sched_pc->sys_ticks = 0;
24759 +       sched_pc->hold_ticks = 0;
24760 +}
24761 +
24762 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24763 +{
24764 +       return;
24765 +}
24766 +
24767 +static inline
24768 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24769 +{
24770 +       return;
24771 +}
24772 diff -NurpP --minimal linux-2.6.34/kernel/vserver/sched_proc.h linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/sched_proc.h
24773 --- linux-2.6.34/kernel/vserver/sched_proc.h    1970-01-01 01:00:00.000000000 +0100
24774 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/sched_proc.h       2010-05-18 18:11:22.000000000 +0200
24775 @@ -0,0 +1,57 @@
24776 +#ifndef _VX_SCHED_PROC_H
24777 +#define _VX_SCHED_PROC_H
24778 +
24779 +
24780 +static inline
24781 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24782 +{
24783 +       int length = 0;
24784 +
24785 +       length += sprintf(buffer,
24786 +               "FillRate:\t%8d,%d\n"
24787 +               "Interval:\t%8d,%d\n"
24788 +               "TokensMin:\t%8d\n"
24789 +               "TokensMax:\t%8d\n"
24790 +               "PrioBias:\t%8d\n",
24791 +               sched->fill_rate[0],
24792 +               sched->fill_rate[1],
24793 +               sched->interval[0],
24794 +               sched->interval[1],
24795 +               sched->tokens_min,
24796 +               sched->tokens_max,
24797 +               sched->prio_bias);
24798 +       return length;
24799 +}
24800 +
24801 +static inline
24802 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24803 +       char *buffer, int cpu)
24804 +{
24805 +       int length = 0;
24806 +
24807 +       length += sprintf(buffer + length,
24808 +               "cpu %d: %lld %lld %lld %ld %ld", cpu,
24809 +               (unsigned long long)sched_pc->user_ticks,
24810 +               (unsigned long long)sched_pc->sys_ticks,
24811 +               (unsigned long long)sched_pc->hold_ticks,
24812 +               sched_pc->token_time,
24813 +               sched_pc->idle_time);
24814 +       length += sprintf(buffer + length,
24815 +               " %c%c %d %d %d %d/%d %d/%d",
24816 +               (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
24817 +               (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
24818 +               sched_pc->tokens,
24819 +               sched_pc->tokens_min,
24820 +               sched_pc->tokens_max,
24821 +               sched_pc->fill_rate[0],
24822 +               sched_pc->interval[0],
24823 +               sched_pc->fill_rate[1],
24824 +               sched_pc->interval[1]);
24825 +       length += sprintf(buffer + length,
24826 +               " %d %d\n",
24827 +               sched_pc->prio_bias,
24828 +               sched_pc->vavavoom);
24829 +       return length;
24830 +}
24831 +
24832 +#endif /* _VX_SCHED_PROC_H */
24833 diff -NurpP --minimal linux-2.6.34/kernel/vserver/signal.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/signal.c
24834 --- linux-2.6.34/kernel/vserver/signal.c        1970-01-01 01:00:00.000000000 +0100
24835 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/signal.c   2010-05-18 18:11:22.000000000 +0200
24836 @@ -0,0 +1,132 @@
24837 +/*
24838 + *  linux/kernel/vserver/signal.c
24839 + *
24840 + *  Virtual Server: Signal Support
24841 + *
24842 + *  Copyright (C) 2003-2007  Herbert Pötzl
24843 + *
24844 + *  V0.01  broken out from vcontext V0.05
24845 + *  V0.02  changed vcmds to vxi arg
24846 + *  V0.03  adjusted siginfo for kill
24847 + *
24848 + */
24849 +
24850 +#include <asm/uaccess.h>
24851 +
24852 +#include <linux/vs_context.h>
24853 +#include <linux/vs_pid.h>
24854 +#include <linux/vserver/signal_cmd.h>
24855 +
24856 +
24857 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24858 +{
24859 +       int retval, count = 0;
24860 +       struct task_struct *p;
24861 +       struct siginfo *sip = SEND_SIG_PRIV;
24862 +
24863 +       retval = -ESRCH;
24864 +       vxdprintk(VXD_CBIT(misc, 4),
24865 +               "vx_info_kill(%p[#%d],%d,%d)*",
24866 +               vxi, vxi->vx_id, pid, sig);
24867 +       read_lock(&tasklist_lock);
24868 +       switch (pid) {
24869 +       case  0:
24870 +       case -1:
24871 +               for_each_process(p) {
24872 +                       int err = 0;
24873 +
24874 +                       if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24875 +                               (pid && vxi->vx_initpid == p->pid))
24876 +                               continue;
24877 +
24878 +                       err = group_send_sig_info(sig, sip, p);
24879 +                       ++count;
24880 +                       if (err != -EPERM)
24881 +                               retval = err;
24882 +               }
24883 +               break;
24884 +
24885 +       case 1:
24886 +               if (vxi->vx_initpid) {
24887 +                       pid = vxi->vx_initpid;
24888 +                       /* for now, only SIGINT to private init ... */
24889 +                       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24890 +                               /* ... as long as there are tasks left */
24891 +                               (atomic_read(&vxi->vx_tasks) > 1))
24892 +                               sig = SIGINT;
24893 +               }
24894 +               /* fallthrough */
24895 +       default:
24896 +               p = find_task_by_real_pid(pid);
24897 +               if (p) {
24898 +                       if (vx_task_xid(p) == vxi->vx_id)
24899 +                               retval = group_send_sig_info(sig, sip, p);
24900 +               }
24901 +               break;
24902 +       }
24903 +       read_unlock(&tasklist_lock);
24904 +       vxdprintk(VXD_CBIT(misc, 4),
24905 +               "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24906 +               vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24907 +       return retval;
24908 +}
24909 +
24910 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24911 +{
24912 +       struct vcmd_ctx_kill_v0 vc_data;
24913 +
24914 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24915 +               return -EFAULT;
24916 +
24917 +       /* special check to allow guest shutdown */
24918 +       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24919 +               /* forbid killall pid=0 when init is present */
24920 +               (((vc_data.pid < 1) && vxi->vx_initpid) ||
24921 +               (vc_data.pid > 1)))
24922 +               return -EACCES;
24923 +
24924 +       return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24925 +}
24926 +
24927 +
24928 +static int __wait_exit(struct vx_info *vxi)
24929 +{
24930 +       DECLARE_WAITQUEUE(wait, current);
24931 +       int ret = 0;
24932 +
24933 +       add_wait_queue(&vxi->vx_wait, &wait);
24934 +       set_current_state(TASK_INTERRUPTIBLE);
24935 +
24936 +wait:
24937 +       if (vx_info_state(vxi,
24938 +               VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24939 +               goto out;
24940 +       if (signal_pending(current)) {
24941 +               ret = -ERESTARTSYS;
24942 +               goto out;
24943 +       }
24944 +       schedule();
24945 +       goto wait;
24946 +
24947 +out:
24948 +       set_current_state(TASK_RUNNING);
24949 +       remove_wait_queue(&vxi->vx_wait, &wait);
24950 +       return ret;
24951 +}
24952 +
24953 +
24954 +
24955 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24956 +{
24957 +       struct vcmd_wait_exit_v0 vc_data;
24958 +       int ret;
24959 +
24960 +       ret = __wait_exit(vxi);
24961 +       vc_data.reboot_cmd = vxi->reboot_cmd;
24962 +       vc_data.exit_code = vxi->exit_code;
24963 +
24964 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24965 +               ret = -EFAULT;
24966 +       return ret;
24967 +}
24968 +
24969 diff -NurpP --minimal linux-2.6.34/kernel/vserver/space.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/space.c
24970 --- linux-2.6.34/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24971 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/space.c    2010-05-18 18:11:22.000000000 +0200
24972 @@ -0,0 +1,375 @@
24973 +/*
24974 + *  linux/kernel/vserver/space.c
24975 + *
24976 + *  Virtual Server: Context Space Support
24977 + *
24978 + *  Copyright (C) 2003-2007  Herbert Pötzl
24979 + *
24980 + *  V0.01  broken out from context.c 0.07
24981 + *  V0.02  added task locking for namespace
24982 + *  V0.03  broken out vx_enter_namespace
24983 + *  V0.04  added *space support and commands
24984 + *
24985 + */
24986 +
24987 +#include <linux/utsname.h>
24988 +#include <linux/nsproxy.h>
24989 +#include <linux/err.h>
24990 +#include <linux/fs_struct.h>
24991 +#include <asm/uaccess.h>
24992 +
24993 +#include <linux/vs_context.h>
24994 +#include <linux/vserver/space.h>
24995 +#include <linux/vserver/space_cmd.h>
24996 +
24997 +atomic_t vs_global_nsproxy     = ATOMIC_INIT(0);
24998 +atomic_t vs_global_fs          = ATOMIC_INIT(0);
24999 +atomic_t vs_global_mnt_ns      = ATOMIC_INIT(0);
25000 +atomic_t vs_global_uts_ns      = ATOMIC_INIT(0);
25001 +atomic_t vs_global_user_ns     = ATOMIC_INIT(0);
25002 +atomic_t vs_global_pid_ns      = ATOMIC_INIT(0);
25003 +
25004 +
25005 +/* namespace functions */
25006 +
25007 +#include <linux/mnt_namespace.h>
25008 +#include <linux/user_namespace.h>
25009 +#include <linux/pid_namespace.h>
25010 +#include <linux/ipc_namespace.h>
25011 +#include <net/net_namespace.h>
25012 +
25013 +
25014 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
25015 +       .mask = CLONE_FS |
25016 +               CLONE_NEWNS |
25017 +               CLONE_NEWUTS |
25018 +               CLONE_NEWIPC |
25019 +               CLONE_NEWUSER |
25020 +               0
25021 +};
25022 +
25023 +static const struct vcmd_space_mask_v1 space_mask = {
25024 +       .mask = CLONE_FS |
25025 +               CLONE_NEWNS |
25026 +               CLONE_NEWUTS |
25027 +               CLONE_NEWIPC |
25028 +               CLONE_NEWUSER |
25029 +#ifdef CONFIG_PID_NS
25030 +               CLONE_NEWPID |
25031 +#endif
25032 +#ifdef CONFIG_NET_NS
25033 +               CLONE_NEWNET |
25034 +#endif
25035 +               0
25036 +};
25037 +
25038 +static const struct vcmd_space_mask_v1 default_space_mask = {
25039 +       .mask = CLONE_FS |
25040 +               CLONE_NEWNS |
25041 +               CLONE_NEWUTS |
25042 +               CLONE_NEWIPC |
25043 +               CLONE_NEWUSER |
25044 +#ifdef CONFIG_PID_NS
25045 +//             CLONE_NEWPID |
25046 +#endif
25047 +               0
25048 +};
25049 +
25050 +/*
25051 + *     build a new nsproxy mix
25052 + *      assumes that both proxies are 'const'
25053 + *     does not touch nsproxy refcounts
25054 + *     will hold a reference on the result.
25055 + */
25056 +
25057 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
25058 +       struct nsproxy *new_nsproxy, unsigned long mask)
25059 +{
25060 +       struct mnt_namespace *old_ns;
25061 +       struct uts_namespace *old_uts;
25062 +       struct ipc_namespace *old_ipc;
25063 +#ifdef CONFIG_PID_NS
25064 +       struct pid_namespace *old_pid;
25065 +#endif
25066 +#ifdef CONFIG_NET_NS
25067 +       struct net *old_net;
25068 +#endif
25069 +       struct nsproxy *nsproxy;
25070 +
25071 +       nsproxy = copy_nsproxy(old_nsproxy);
25072 +       if (!nsproxy)
25073 +               goto out;
25074 +
25075 +       if (mask & CLONE_NEWNS) {
25076 +               old_ns = nsproxy->mnt_ns;
25077 +               nsproxy->mnt_ns = new_nsproxy->mnt_ns;
25078 +               if (nsproxy->mnt_ns)
25079 +                       get_mnt_ns(nsproxy->mnt_ns);
25080 +       } else
25081 +               old_ns = NULL;
25082 +
25083 +       if (mask & CLONE_NEWUTS) {
25084 +               old_uts = nsproxy->uts_ns;
25085 +               nsproxy->uts_ns = new_nsproxy->uts_ns;
25086 +               if (nsproxy->uts_ns)
25087 +                       get_uts_ns(nsproxy->uts_ns);
25088 +       } else
25089 +               old_uts = NULL;
25090 +
25091 +       if (mask & CLONE_NEWIPC) {
25092 +               old_ipc = nsproxy->ipc_ns;
25093 +               nsproxy->ipc_ns = new_nsproxy->ipc_ns;
25094 +               if (nsproxy->ipc_ns)
25095 +                       get_ipc_ns(nsproxy->ipc_ns);
25096 +       } else
25097 +               old_ipc = NULL;
25098 +
25099 +#ifdef CONFIG_PID_NS
25100 +       if (mask & CLONE_NEWPID) {
25101 +               old_pid = nsproxy->pid_ns;
25102 +               nsproxy->pid_ns = new_nsproxy->pid_ns;
25103 +               if (nsproxy->pid_ns)
25104 +                       get_pid_ns(nsproxy->pid_ns);
25105 +       } else
25106 +               old_pid = NULL;
25107 +#endif
25108 +#ifdef CONFIG_NET_NS
25109 +       if (mask & CLONE_NEWNET) {
25110 +               old_net = nsproxy->net_ns;
25111 +               nsproxy->net_ns = new_nsproxy->net_ns;
25112 +               if (nsproxy->net_ns)
25113 +                       get_net(nsproxy->net_ns);
25114 +       } else
25115 +               old_net = NULL;
25116 +#endif
25117 +       if (old_ns)
25118 +               put_mnt_ns(old_ns);
25119 +       if (old_uts)
25120 +               put_uts_ns(old_uts);
25121 +       if (old_ipc)
25122 +               put_ipc_ns(old_ipc);
25123 +#ifdef CONFIG_PID_NS
25124 +       if (old_pid)
25125 +               put_pid_ns(old_pid);
25126 +#endif
25127 +#ifdef CONFIG_NET_NS
25128 +       if (old_net)
25129 +               put_net(old_net);
25130 +#endif
25131 +out:
25132 +       return nsproxy;
25133 +}
25134 +
25135 +
25136 +/*
25137 + *     merge two nsproxy structs into a new one.
25138 + *     will hold a reference on the result.
25139 + */
25140 +
25141 +static inline
25142 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
25143 +       struct nsproxy *proxy, unsigned long mask)
25144 +{
25145 +       struct nsproxy null_proxy = { .mnt_ns = NULL };
25146 +
25147 +       if (!proxy)
25148 +               return NULL;
25149 +
25150 +       if (mask) {
25151 +               /* vs_mix_nsproxy returns with reference */
25152 +               return vs_mix_nsproxy(old ? old : &null_proxy,
25153 +                       proxy, mask);
25154 +       }
25155 +       get_nsproxy(proxy);
25156 +       return proxy;
25157 +}
25158 +
25159 +
25160 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25161 +{
25162 +       struct nsproxy *proxy, *proxy_cur, *proxy_new;
25163 +       struct fs_struct *fs_cur, *fs = NULL;
25164 +       int ret, kill = 0;
25165 +
25166 +       vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
25167 +               vxi, vxi->vx_id, mask, index);
25168 +
25169 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
25170 +               return -EACCES;
25171 +
25172 +       if (!mask)
25173 +               mask = vxi->vx_nsmask[index];
25174 +
25175 +       if ((mask & vxi->vx_nsmask[index]) != mask)
25176 +               return -EINVAL;
25177 +
25178 +       if (mask & CLONE_FS) {
25179 +               fs = copy_fs_struct(vxi->vx_fs[index]);
25180 +               if (!fs)
25181 +                       return -ENOMEM;
25182 +       }
25183 +       proxy = vxi->vx_nsproxy[index];
25184 +
25185 +       vxdprintk(VXD_CBIT(space, 9),
25186 +               "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
25187 +               vxi, vxi->vx_id, mask, index, proxy, fs);
25188 +
25189 +       task_lock(current);
25190 +       fs_cur = current->fs;
25191 +
25192 +       if (mask & CLONE_FS) {
25193 +               write_lock(&fs_cur->lock);
25194 +               current->fs = fs;
25195 +               kill = !--fs_cur->users;
25196 +               write_unlock(&fs_cur->lock);
25197 +       }
25198 +
25199 +       proxy_cur = current->nsproxy;
25200 +       get_nsproxy(proxy_cur);
25201 +       task_unlock(current);
25202 +
25203 +       if (kill)
25204 +               free_fs_struct(fs_cur);
25205 +
25206 +       proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
25207 +       if (IS_ERR(proxy_new)) {
25208 +               ret = PTR_ERR(proxy_new);
25209 +               goto out_put;
25210 +       }
25211 +
25212 +       proxy_new = xchg(&current->nsproxy, proxy_new);
25213 +       ret = 0;
25214 +
25215 +       if (proxy_new)
25216 +               put_nsproxy(proxy_new);
25217 +out_put:
25218 +       if (proxy_cur)
25219 +               put_nsproxy(proxy_cur);
25220 +       return ret;
25221 +}
25222 +
25223 +
25224 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25225 +{
25226 +       struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25227 +       struct fs_struct *fs_vxi, *fs;
25228 +       int ret, kill = 0;
25229 +
25230 +       vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
25231 +               vxi, vxi->vx_id, mask, index);
25232 +#if 0
25233 +       if (!mask)
25234 +               mask = default_space_mask.mask;
25235 +#endif
25236 +       if ((mask & space_mask.mask) != mask)
25237 +               return -EINVAL;
25238 +
25239 +       proxy_vxi = vxi->vx_nsproxy[index];
25240 +       fs_vxi = vxi->vx_fs[index];
25241 +
25242 +       if (mask & CLONE_FS) {
25243 +               fs = copy_fs_struct(current->fs);
25244 +               if (!fs)
25245 +                       return -ENOMEM;
25246 +       }
25247 +
25248 +       task_lock(current);
25249 +
25250 +       if (mask & CLONE_FS) {
25251 +               write_lock(&fs_vxi->lock);
25252 +               vxi->vx_fs[index] = fs;
25253 +               kill = !--fs_vxi->users;
25254 +               write_unlock(&fs_vxi->lock);
25255 +       }
25256 +
25257 +       proxy_cur = current->nsproxy;
25258 +       get_nsproxy(proxy_cur);
25259 +       task_unlock(current);
25260 +
25261 +       if (kill)
25262 +               free_fs_struct(fs_vxi);
25263 +
25264 +       proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25265 +       if (IS_ERR(proxy_new)) {
25266 +               ret = PTR_ERR(proxy_new);
25267 +               goto out_put;
25268 +       }
25269 +
25270 +       proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
25271 +       vxi->vx_nsmask[index] |= mask;
25272 +       ret = 0;
25273 +
25274 +       if (proxy_new)
25275 +               put_nsproxy(proxy_new);
25276 +out_put:
25277 +       if (proxy_cur)
25278 +               put_nsproxy(proxy_cur);
25279 +       return ret;
25280 +}
25281 +
25282 +
25283 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25284 +{
25285 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25286 +
25287 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25288 +               return -EFAULT;
25289 +
25290 +       return vx_enter_space(vxi, vc_data.mask, 0);
25291 +}
25292 +
25293 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25294 +{
25295 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25296 +
25297 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25298 +               return -EFAULT;
25299 +
25300 +       if (vc_data.index >= VX_SPACES)
25301 +               return -EINVAL;
25302 +
25303 +       return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25304 +}
25305 +
25306 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25307 +{
25308 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25309 +
25310 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25311 +               return -EFAULT;
25312 +
25313 +       return vx_set_space(vxi, vc_data.mask, 0);
25314 +}
25315 +
25316 +int vc_set_space(struct vx_info *vxi, void __user *data)
25317 +{
25318 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25319 +
25320 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25321 +               return -EFAULT;
25322 +
25323 +       if (vc_data.index >= VX_SPACES)
25324 +               return -EINVAL;
25325 +
25326 +       return vx_set_space(vxi, vc_data.mask, vc_data.index);
25327 +}
25328 +
25329 +int vc_get_space_mask(void __user *data, int type)
25330 +{
25331 +       const struct vcmd_space_mask_v1 *mask;
25332 +
25333 +       if (type == 0)
25334 +               mask = &space_mask_v0;
25335 +       else if (type == 1)
25336 +               mask = &space_mask;
25337 +       else
25338 +               mask = &default_space_mask;
25339 +
25340 +       vxdprintk(VXD_CBIT(space, 10),
25341 +               "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25342 +
25343 +       if (copy_to_user(data, mask, sizeof(*mask)))
25344 +               return -EFAULT;
25345 +       return 0;
25346 +}
25347 +
25348 diff -NurpP --minimal linux-2.6.34/kernel/vserver/switch.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/switch.c
25349 --- linux-2.6.34/kernel/vserver/switch.c        1970-01-01 01:00:00.000000000 +0100
25350 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/switch.c   2010-05-18 18:11:22.000000000 +0200
25351 @@ -0,0 +1,546 @@
25352 +/*
25353 + *  linux/kernel/vserver/switch.c
25354 + *
25355 + *  Virtual Server: Syscall Switch
25356 + *
25357 + *  Copyright (C) 2003-2007  Herbert Pötzl
25358 + *
25359 + *  V0.01  syscall switch
25360 + *  V0.02  added signal to context
25361 + *  V0.03  added rlimit functions
25362 + *  V0.04  added iattr, task/xid functions
25363 + *  V0.05  added debug/history stuff
25364 + *  V0.06  added compat32 layer
25365 + *  V0.07  vcmd args and perms
25366 + *  V0.08  added status commands
25367 + *  V0.09  added tag commands
25368 + *  V0.10  added oom bias
25369 + *  V0.11  added device commands
25370 + *
25371 + */
25372 +
25373 +#include <linux/vs_context.h>
25374 +#include <linux/vs_network.h>
25375 +#include <linux/vserver/switch.h>
25376 +
25377 +#include "vci_config.h"
25378 +
25379 +
25380 +static inline
25381 +int vc_get_version(uint32_t id)
25382 +{
25383 +       return VCI_VERSION;
25384 +}
25385 +
25386 +static inline
25387 +int vc_get_vci(uint32_t id)
25388 +{
25389 +       return vci_kernel_config();
25390 +}
25391 +
25392 +#include <linux/vserver/context_cmd.h>
25393 +#include <linux/vserver/cvirt_cmd.h>
25394 +#include <linux/vserver/cacct_cmd.h>
25395 +#include <linux/vserver/limit_cmd.h>
25396 +#include <linux/vserver/network_cmd.h>
25397 +#include <linux/vserver/sched_cmd.h>
25398 +#include <linux/vserver/debug_cmd.h>
25399 +#include <linux/vserver/inode_cmd.h>
25400 +#include <linux/vserver/dlimit_cmd.h>
25401 +#include <linux/vserver/signal_cmd.h>
25402 +#include <linux/vserver/space_cmd.h>
25403 +#include <linux/vserver/tag_cmd.h>
25404 +#include <linux/vserver/device_cmd.h>
25405 +
25406 +#include <linux/vserver/inode.h>
25407 +#include <linux/vserver/dlimit.h>
25408 +
25409 +
25410 +#ifdef CONFIG_COMPAT
25411 +#define __COMPAT(name, id, data, compat)       \
25412 +       (compat) ? name ## _x32(id, data) : name(id, data)
25413 +#define __COMPAT_NO_ID(name, data, compat)     \
25414 +       (compat) ? name ## _x32(data) : name(data)
25415 +#else
25416 +#define __COMPAT(name, id, data, compat)       \
25417 +       name(id, data)
25418 +#define __COMPAT_NO_ID(name, data, compat)     \
25419 +       name(data)
25420 +#endif
25421 +
25422 +
25423 +static inline
25424 +long do_vcmd(uint32_t cmd, uint32_t id,
25425 +       struct vx_info *vxi, struct nx_info *nxi,
25426 +       void __user *data, int compat)
25427 +{
25428 +       switch (cmd) {
25429 +
25430 +       case VCMD_get_version:
25431 +               return vc_get_version(id);
25432 +       case VCMD_get_vci:
25433 +               return vc_get_vci(id);
25434 +
25435 +       case VCMD_task_xid:
25436 +               return vc_task_xid(id);
25437 +       case VCMD_vx_info:
25438 +               return vc_vx_info(vxi, data);
25439 +
25440 +       case VCMD_task_nid:
25441 +               return vc_task_nid(id);
25442 +       case VCMD_nx_info:
25443 +               return vc_nx_info(nxi, data);
25444 +
25445 +       case VCMD_task_tag:
25446 +               return vc_task_tag(id);
25447 +
25448 +       case VCMD_set_space_v1:
25449 +               return vc_set_space_v1(vxi, data);
25450 +       /* this is version 2 */
25451 +       case VCMD_set_space:
25452 +               return vc_set_space(vxi, data);
25453 +
25454 +       case VCMD_get_space_mask_v0:
25455 +               return vc_get_space_mask(data, 0);
25456 +       /* this is version 1 */
25457 +       case VCMD_get_space_mask:
25458 +               return vc_get_space_mask(data, 1);
25459 +
25460 +       case VCMD_get_space_default:
25461 +               return vc_get_space_mask(data, -1);
25462 +
25463 +#ifdef CONFIG_IA32_EMULATION
25464 +       case VCMD_get_rlimit:
25465 +               return __COMPAT(vc_get_rlimit, vxi, data, compat);
25466 +       case VCMD_set_rlimit:
25467 +               return __COMPAT(vc_set_rlimit, vxi, data, compat);
25468 +#else
25469 +       case VCMD_get_rlimit:
25470 +               return vc_get_rlimit(vxi, data);
25471 +       case VCMD_set_rlimit:
25472 +               return vc_set_rlimit(vxi, data);
25473 +#endif
25474 +       case VCMD_get_rlimit_mask:
25475 +               return vc_get_rlimit_mask(id, data);
25476 +       case VCMD_reset_hits:
25477 +               return vc_reset_hits(vxi, data);
25478 +       case VCMD_reset_minmax:
25479 +               return vc_reset_minmax(vxi, data);
25480 +
25481 +       case VCMD_get_vhi_name:
25482 +               return vc_get_vhi_name(vxi, data);
25483 +       case VCMD_set_vhi_name:
25484 +               return vc_set_vhi_name(vxi, data);
25485 +
25486 +       case VCMD_ctx_stat:
25487 +               return vc_ctx_stat(vxi, data);
25488 +       case VCMD_virt_stat:
25489 +               return vc_virt_stat(vxi, data);
25490 +       case VCMD_sock_stat:
25491 +               return vc_sock_stat(vxi, data);
25492 +       case VCMD_rlimit_stat:
25493 +               return vc_rlimit_stat(vxi, data);
25494 +
25495 +       case VCMD_set_cflags:
25496 +               return vc_set_cflags(vxi, data);
25497 +       case VCMD_get_cflags:
25498 +               return vc_get_cflags(vxi, data);
25499 +
25500 +       /* this is version 1 */
25501 +       case VCMD_set_ccaps:
25502 +               return vc_set_ccaps(vxi, data);
25503 +       /* this is version 1 */
25504 +       case VCMD_get_ccaps:
25505 +               return vc_get_ccaps(vxi, data);
25506 +       case VCMD_set_bcaps:
25507 +               return vc_set_bcaps(vxi, data);
25508 +       case VCMD_get_bcaps:
25509 +               return vc_get_bcaps(vxi, data);
25510 +
25511 +       case VCMD_set_badness:
25512 +               return vc_set_badness(vxi, data);
25513 +       case VCMD_get_badness:
25514 +               return vc_get_badness(vxi, data);
25515 +
25516 +       case VCMD_set_nflags:
25517 +               return vc_set_nflags(nxi, data);
25518 +       case VCMD_get_nflags:
25519 +               return vc_get_nflags(nxi, data);
25520 +
25521 +       case VCMD_set_ncaps:
25522 +               return vc_set_ncaps(nxi, data);
25523 +       case VCMD_get_ncaps:
25524 +               return vc_get_ncaps(nxi, data);
25525 +
25526 +       case VCMD_set_sched_v4:
25527 +               return vc_set_sched_v4(vxi, data);
25528 +       /* this is version 5 */
25529 +       case VCMD_set_sched:
25530 +               return vc_set_sched(vxi, data);
25531 +       case VCMD_get_sched:
25532 +               return vc_get_sched(vxi, data);
25533 +       case VCMD_sched_info:
25534 +               return vc_sched_info(vxi, data);
25535 +
25536 +       case VCMD_add_dlimit:
25537 +               return __COMPAT(vc_add_dlimit, id, data, compat);
25538 +       case VCMD_rem_dlimit:
25539 +               return __COMPAT(vc_rem_dlimit, id, data, compat);
25540 +       case VCMD_set_dlimit:
25541 +               return __COMPAT(vc_set_dlimit, id, data, compat);
25542 +       case VCMD_get_dlimit:
25543 +               return __COMPAT(vc_get_dlimit, id, data, compat);
25544 +
25545 +       case VCMD_ctx_kill:
25546 +               return vc_ctx_kill(vxi, data);
25547 +
25548 +       case VCMD_wait_exit:
25549 +               return vc_wait_exit(vxi, data);
25550 +
25551 +       case VCMD_get_iattr:
25552 +               return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25553 +       case VCMD_set_iattr:
25554 +               return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25555 +
25556 +       case VCMD_fget_iattr:
25557 +               return vc_fget_iattr(id, data);
25558 +       case VCMD_fset_iattr:
25559 +               return vc_fset_iattr(id, data);
25560 +
25561 +       case VCMD_enter_space_v0:
25562 +               return vc_enter_space_v1(vxi, NULL);
25563 +       case VCMD_enter_space_v1:
25564 +               return vc_enter_space_v1(vxi, data);
25565 +       /* this is version 2 */
25566 +       case VCMD_enter_space:
25567 +               return vc_enter_space(vxi, data);
25568 +
25569 +       case VCMD_ctx_create_v0:
25570 +               return vc_ctx_create(id, NULL);
25571 +       case VCMD_ctx_create:
25572 +               return vc_ctx_create(id, data);
25573 +       case VCMD_ctx_migrate_v0:
25574 +               return vc_ctx_migrate(vxi, NULL);
25575 +       case VCMD_ctx_migrate:
25576 +               return vc_ctx_migrate(vxi, data);
25577 +
25578 +       case VCMD_net_create_v0:
25579 +               return vc_net_create(id, NULL);
25580 +       case VCMD_net_create:
25581 +               return vc_net_create(id, data);
25582 +       case VCMD_net_migrate:
25583 +               return vc_net_migrate(nxi, data);
25584 +
25585 +       case VCMD_tag_migrate:
25586 +               return vc_tag_migrate(id);
25587 +
25588 +       case VCMD_net_add:
25589 +               return vc_net_add(nxi, data);
25590 +       case VCMD_net_remove:
25591 +               return vc_net_remove(nxi, data);
25592 +
25593 +       case VCMD_net_add_ipv4:
25594 +               return vc_net_add_ipv4(nxi, data);
25595 +       case VCMD_net_remove_ipv4:
25596 +               return vc_net_remove_ipv4(nxi, data);
25597 +#ifdef CONFIG_IPV6
25598 +       case VCMD_net_add_ipv6:
25599 +               return vc_net_add_ipv6(nxi, data);
25600 +       case VCMD_net_remove_ipv6:
25601 +               return vc_net_remove_ipv6(nxi, data);
25602 +#endif
25603 +/*     case VCMD_add_match_ipv4:
25604 +               return vc_add_match_ipv4(nxi, data);
25605 +       case VCMD_get_match_ipv4:
25606 +               return vc_get_match_ipv4(nxi, data);
25607 +#ifdef CONFIG_IPV6
25608 +       case VCMD_add_match_ipv6:
25609 +               return vc_add_match_ipv6(nxi, data);
25610 +       case VCMD_get_match_ipv6:
25611 +               return vc_get_match_ipv6(nxi, data);
25612 +#endif */
25613 +
25614 +#ifdef CONFIG_VSERVER_DEVICE
25615 +       case VCMD_set_mapping:
25616 +               return __COMPAT(vc_set_mapping, vxi, data, compat);
25617 +       case VCMD_unset_mapping:
25618 +               return __COMPAT(vc_unset_mapping, vxi, data, compat);
25619 +#endif
25620 +#ifdef CONFIG_VSERVER_HISTORY
25621 +       case VCMD_dump_history:
25622 +               return vc_dump_history(id);
25623 +       case VCMD_read_history:
25624 +               return __COMPAT(vc_read_history, id, data, compat);
25625 +#endif
25626 +#ifdef CONFIG_VSERVER_MONITOR
25627 +       case VCMD_read_monitor:
25628 +               return __COMPAT(vc_read_monitor, id, data, compat);
25629 +#endif
25630 +       default:
25631 +               vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25632 +                       VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25633 +       }
25634 +       return -ENOSYS;
25635 +}
25636 +
25637 +
25638 +#define        __VCMD(vcmd, _perm, _args, _flags)              \
25639 +       case VCMD_ ## vcmd: perm = _perm;               \
25640 +               args = _args; flags = _flags; break
25641 +
25642 +
25643 +#define VCA_NONE       0x00
25644 +#define VCA_VXI                0x01
25645 +#define VCA_NXI                0x02
25646 +
25647 +#define VCF_NONE       0x00
25648 +#define VCF_INFO       0x01
25649 +#define VCF_ADMIN      0x02
25650 +#define VCF_ARES       0x06    /* includes admin */
25651 +#define VCF_SETUP      0x08
25652 +
25653 +#define VCF_ZIDOK      0x10    /* zero id okay */
25654 +
25655 +
25656 +static inline
25657 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25658 +{
25659 +       long ret;
25660 +       int permit = -1, state = 0;
25661 +       int perm = -1, args = 0, flags = 0;
25662 +       struct vx_info *vxi = NULL;
25663 +       struct nx_info *nxi = NULL;
25664 +
25665 +       switch (cmd) {
25666 +       /* unpriviledged commands */
25667 +       __VCMD(get_version,      0, VCA_NONE,   0);
25668 +       __VCMD(get_vci,          0, VCA_NONE,   0);
25669 +       __VCMD(get_rlimit_mask,  0, VCA_NONE,   0);
25670 +       __VCMD(get_space_mask_v0,0, VCA_NONE,   0);
25671 +       __VCMD(get_space_mask,   0, VCA_NONE,   0);
25672 +       __VCMD(get_space_default,0, VCA_NONE,   0);
25673 +
25674 +       /* info commands */
25675 +       __VCMD(task_xid,         2, VCA_NONE,   0);
25676 +       __VCMD(reset_hits,       2, VCA_VXI,    0);
25677 +       __VCMD(reset_minmax,     2, VCA_VXI,    0);
25678 +       __VCMD(vx_info,          3, VCA_VXI,    VCF_INFO);
25679 +       __VCMD(get_bcaps,        3, VCA_VXI,    VCF_INFO);
25680 +       __VCMD(get_ccaps,        3, VCA_VXI,    VCF_INFO);
25681 +       __VCMD(get_cflags,       3, VCA_VXI,    VCF_INFO);
25682 +       __VCMD(get_badness,      3, VCA_VXI,    VCF_INFO);
25683 +       __VCMD(get_vhi_name,     3, VCA_VXI,    VCF_INFO);
25684 +       __VCMD(get_rlimit,       3, VCA_VXI,    VCF_INFO);
25685 +
25686 +       __VCMD(ctx_stat,         3, VCA_VXI,    VCF_INFO);
25687 +       __VCMD(virt_stat,        3, VCA_VXI,    VCF_INFO);
25688 +       __VCMD(sock_stat,        3, VCA_VXI,    VCF_INFO);
25689 +       __VCMD(rlimit_stat,      3, VCA_VXI,    VCF_INFO);
25690 +
25691 +       __VCMD(task_nid,         2, VCA_NONE,   0);
25692 +       __VCMD(nx_info,          3, VCA_NXI,    VCF_INFO);
25693 +       __VCMD(get_ncaps,        3, VCA_NXI,    VCF_INFO);
25694 +       __VCMD(get_nflags,       3, VCA_NXI,    VCF_INFO);
25695 +
25696 +       __VCMD(task_tag,         2, VCA_NONE,   0);
25697 +
25698 +       __VCMD(get_iattr,        2, VCA_NONE,   0);
25699 +       __VCMD(fget_iattr,       2, VCA_NONE,   0);
25700 +       __VCMD(get_dlimit,       3, VCA_NONE,   VCF_INFO);
25701 +       __VCMD(get_sched,        3, VCA_VXI,    VCF_INFO);
25702 +       __VCMD(sched_info,       3, VCA_VXI,    VCF_INFO | VCF_ZIDOK);
25703 +
25704 +       /* lower admin commands */
25705 +       __VCMD(wait_exit,        4, VCA_VXI,    VCF_INFO);
25706 +       __VCMD(ctx_create_v0,    5, VCA_NONE,   0);
25707 +       __VCMD(ctx_create,       5, VCA_NONE,   0);
25708 +       __VCMD(ctx_migrate_v0,   5, VCA_VXI,    VCF_ADMIN);
25709 +       __VCMD(ctx_migrate,      5, VCA_VXI,    VCF_ADMIN);
25710 +       __VCMD(enter_space_v0,   5, VCA_VXI,    VCF_ADMIN);
25711 +       __VCMD(enter_space_v1,   5, VCA_VXI,    VCF_ADMIN);
25712 +       __VCMD(enter_space,      5, VCA_VXI,    VCF_ADMIN);
25713 +
25714 +       __VCMD(net_create_v0,    5, VCA_NONE,   0);
25715 +       __VCMD(net_create,       5, VCA_NONE,   0);
25716 +       __VCMD(net_migrate,      5, VCA_NXI,    VCF_ADMIN);
25717 +
25718 +       __VCMD(tag_migrate,      5, VCA_NONE,   VCF_ADMIN);
25719 +
25720 +       /* higher admin commands */
25721 +       __VCMD(ctx_kill,         6, VCA_VXI,    VCF_ARES);
25722 +       __VCMD(set_space_v1,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25723 +       __VCMD(set_space,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25724 +
25725 +       __VCMD(set_ccaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25726 +       __VCMD(set_bcaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25727 +       __VCMD(set_cflags,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25728 +       __VCMD(set_badness,      7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25729 +
25730 +       __VCMD(set_vhi_name,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25731 +       __VCMD(set_rlimit,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25732 +       __VCMD(set_sched,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25733 +       __VCMD(set_sched_v4,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25734 +
25735 +       __VCMD(set_ncaps,        7, VCA_NXI,    VCF_ARES | VCF_SETUP);
25736 +       __VCMD(set_nflags,       7, VCA_NXI,    VCF_ARES | VCF_SETUP);
25737 +       __VCMD(net_add,          8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25738 +       __VCMD(net_remove,       8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25739 +       __VCMD(net_add_ipv4,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25740 +       __VCMD(net_remove_ipv4,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25741 +#ifdef CONFIG_IPV6
25742 +       __VCMD(net_add_ipv6,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25743 +       __VCMD(net_remove_ipv6,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25744 +#endif
25745 +       __VCMD(set_iattr,        7, VCA_NONE,   0);
25746 +       __VCMD(fset_iattr,       7, VCA_NONE,   0);
25747 +       __VCMD(set_dlimit,       7, VCA_NONE,   VCF_ARES);
25748 +       __VCMD(add_dlimit,       8, VCA_NONE,   VCF_ARES);
25749 +       __VCMD(rem_dlimit,       8, VCA_NONE,   VCF_ARES);
25750 +
25751 +#ifdef CONFIG_VSERVER_DEVICE
25752 +       __VCMD(set_mapping,      8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
25753 +       __VCMD(unset_mapping,    8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
25754 +#endif
25755 +       /* debug level admin commands */
25756 +#ifdef CONFIG_VSERVER_HISTORY
25757 +       __VCMD(dump_history,     9, VCA_NONE,   0);
25758 +       __VCMD(read_history,     9, VCA_NONE,   0);
25759 +#endif
25760 +#ifdef CONFIG_VSERVER_MONITOR
25761 +       __VCMD(read_monitor,     9, VCA_NONE,   0);
25762 +#endif
25763 +
25764 +       default:
25765 +               perm = -1;
25766 +       }
25767 +
25768 +       vxdprintk(VXD_CBIT(switch, 0),
25769 +               "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25770 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
25771 +               VC_VERSION(cmd), id, data, compat,
25772 +               perm, args, flags);
25773 +
25774 +       ret = -ENOSYS;
25775 +       if (perm < 0)
25776 +               goto out;
25777 +
25778 +       state = 1;
25779 +       if (!capable(CAP_CONTEXT))
25780 +               goto out;
25781 +
25782 +       state = 2;
25783 +       /* moved here from the individual commands */
25784 +       ret = -EPERM;
25785 +       if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25786 +               goto out;
25787 +
25788 +       state = 3;
25789 +       /* vcmd involves resource management  */
25790 +       ret = -EPERM;
25791 +       if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25792 +               goto out;
25793 +
25794 +       state = 4;
25795 +       /* various legacy exceptions */
25796 +       switch (cmd) {
25797 +       /* will go away when spectator is a cap */
25798 +       case VCMD_ctx_migrate_v0:
25799 +       case VCMD_ctx_migrate:
25800 +               if (id == 1) {
25801 +                       current->xid = 1;
25802 +                       ret = 1;
25803 +                       goto out;
25804 +               }
25805 +               break;
25806 +
25807 +       /* will go away when spectator is a cap */
25808 +       case VCMD_net_migrate:
25809 +               if (id == 1) {
25810 +                       current->nid = 1;
25811 +                       ret = 1;
25812 +                       goto out;
25813 +               }
25814 +               break;
25815 +       }
25816 +
25817 +       /* vcmds are fine by default */
25818 +       permit = 1;
25819 +
25820 +       /* admin type vcmds require admin ... */
25821 +       if (flags & VCF_ADMIN)
25822 +               permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25823 +
25824 +       /* ... but setup type vcmds override that */
25825 +       if (!permit && (flags & VCF_SETUP))
25826 +               permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25827 +
25828 +       state = 5;
25829 +       ret = -EPERM;
25830 +       if (!permit)
25831 +               goto out;
25832 +
25833 +       state = 6;
25834 +       if (!id && (flags & VCF_ZIDOK))
25835 +               goto skip_id;
25836 +
25837 +       ret = -ESRCH;
25838 +       if (args & VCA_VXI) {
25839 +               vxi = lookup_vx_info(id);
25840 +               if (!vxi)
25841 +                       goto out;
25842 +
25843 +               if ((flags & VCF_ADMIN) &&
25844 +                       /* special case kill for shutdown */
25845 +                       (cmd != VCMD_ctx_kill) &&
25846 +                       /* can context be administrated? */
25847 +                       !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25848 +                       ret = -EACCES;
25849 +                       goto out_vxi;
25850 +               }
25851 +       }
25852 +       state = 7;
25853 +       if (args & VCA_NXI) {
25854 +               nxi = lookup_nx_info(id);
25855 +               if (!nxi)
25856 +                       goto out_vxi;
25857 +
25858 +               if ((flags & VCF_ADMIN) &&
25859 +                       /* can context be administrated? */
25860 +                       !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25861 +                       ret = -EACCES;
25862 +                       goto out_nxi;
25863 +               }
25864 +       }
25865 +skip_id:
25866 +       state = 8;
25867 +       ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25868 +
25869 +out_nxi:
25870 +       if ((args & VCA_NXI) && nxi)
25871 +               put_nx_info(nxi);
25872 +out_vxi:
25873 +       if ((args & VCA_VXI) && vxi)
25874 +               put_vx_info(vxi);
25875 +out:
25876 +       vxdprintk(VXD_CBIT(switch, 1),
25877 +               "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25878 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
25879 +               VC_VERSION(cmd), ret, ret, state, permit);
25880 +       return ret;
25881 +}
25882 +
25883 +asmlinkage long
25884 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25885 +{
25886 +       return do_vserver(cmd, id, data, 0);
25887 +}
25888 +
25889 +#ifdef CONFIG_COMPAT
25890 +
25891 +asmlinkage long
25892 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25893 +{
25894 +       return do_vserver(cmd, id, data, 1);
25895 +}
25896 +
25897 +#endif /* CONFIG_COMPAT */
25898 diff -NurpP --minimal linux-2.6.34/kernel/vserver/sysctl.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/sysctl.c
25899 --- linux-2.6.34/kernel/vserver/sysctl.c        1970-01-01 01:00:00.000000000 +0100
25900 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/sysctl.c   2010-05-18 18:11:22.000000000 +0200
25901 @@ -0,0 +1,241 @@
25902 +/*
25903 + *  kernel/vserver/sysctl.c
25904 + *
25905 + *  Virtual Context Support
25906 + *
25907 + *  Copyright (C) 2004-2007  Herbert Pötzl
25908 + *
25909 + *  V0.01  basic structure
25910 + *
25911 + */
25912 +
25913 +#include <linux/module.h>
25914 +#include <linux/ctype.h>
25915 +#include <linux/sysctl.h>
25916 +#include <linux/parser.h>
25917 +#include <asm/uaccess.h>
25918 +
25919 +enum {
25920 +       CTL_DEBUG_ERROR         = 0,
25921 +       CTL_DEBUG_SWITCH        = 1,
25922 +       CTL_DEBUG_XID,
25923 +       CTL_DEBUG_NID,
25924 +       CTL_DEBUG_TAG,
25925 +       CTL_DEBUG_NET,
25926 +       CTL_DEBUG_LIMIT,
25927 +       CTL_DEBUG_CRES,
25928 +       CTL_DEBUG_DLIM,
25929 +       CTL_DEBUG_QUOTA,
25930 +       CTL_DEBUG_CVIRT,
25931 +       CTL_DEBUG_SPACE,
25932 +       CTL_DEBUG_MISC,
25933 +};
25934 +
25935 +
25936 +unsigned int vx_debug_switch   = 0;
25937 +unsigned int vx_debug_xid      = 0;
25938 +unsigned int vx_debug_nid      = 0;
25939 +unsigned int vx_debug_tag      = 0;
25940 +unsigned int vx_debug_net      = 0;
25941 +unsigned int vx_debug_limit    = 0;
25942 +unsigned int vx_debug_cres     = 0;
25943 +unsigned int vx_debug_dlim     = 0;
25944 +unsigned int vx_debug_quota    = 0;
25945 +unsigned int vx_debug_cvirt    = 0;
25946 +unsigned int vx_debug_space    = 0;
25947 +unsigned int vx_debug_misc     = 0;
25948 +
25949 +
25950 +static struct ctl_table_header *vserver_table_header;
25951 +static ctl_table vserver_root_table[];
25952 +
25953 +
25954 +void vserver_register_sysctl(void)
25955 +{
25956 +       if (!vserver_table_header) {
25957 +               vserver_table_header = register_sysctl_table(vserver_root_table);
25958 +       }
25959 +
25960 +}
25961 +
25962 +void vserver_unregister_sysctl(void)
25963 +{
25964 +       if (vserver_table_header) {
25965 +               unregister_sysctl_table(vserver_table_header);
25966 +               vserver_table_header = NULL;
25967 +       }
25968 +}
25969 +
25970 +
25971 +static int proc_dodebug(ctl_table *table, int write,
25972 +       void __user *buffer, size_t *lenp, loff_t *ppos)
25973 +{
25974 +       char            tmpbuf[20], *p, c;
25975 +       unsigned int    value;
25976 +       size_t          left, len;
25977 +
25978 +       if ((*ppos && !write) || !*lenp) {
25979 +               *lenp = 0;
25980 +               return 0;
25981 +       }
25982 +
25983 +       left = *lenp;
25984 +
25985 +       if (write) {
25986 +               if (!access_ok(VERIFY_READ, buffer, left))
25987 +                       return -EFAULT;
25988 +               p = (char *)buffer;
25989 +               while (left && __get_user(c, p) >= 0 && isspace(c))
25990 +                       left--, p++;
25991 +               if (!left)
25992 +                       goto done;
25993 +
25994 +               if (left > sizeof(tmpbuf) - 1)
25995 +                       return -EINVAL;
25996 +               if (copy_from_user(tmpbuf, p, left))
25997 +                       return -EFAULT;
25998 +               tmpbuf[left] = '\0';
25999 +
26000 +               for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
26001 +                       value = 10 * value + (*p - '0');
26002 +               if (*p && !isspace(*p))
26003 +                       return -EINVAL;
26004 +               while (left && isspace(*p))
26005 +                       left--, p++;
26006 +               *(unsigned int *)table->data = value;
26007 +       } else {
26008 +               if (!access_ok(VERIFY_WRITE, buffer, left))
26009 +                       return -EFAULT;
26010 +               len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
26011 +               if (len > left)
26012 +                       len = left;
26013 +               if (__copy_to_user(buffer, tmpbuf, len))
26014 +                       return -EFAULT;
26015 +               if ((left -= len) > 0) {
26016 +                       if (put_user('\n', (char *)buffer + len))
26017 +                               return -EFAULT;
26018 +                       left--;
26019 +               }
26020 +       }
26021 +
26022 +done:
26023 +       *lenp -= left;
26024 +       *ppos += *lenp;
26025 +       return 0;
26026 +}
26027 +
26028 +static int zero;
26029 +
26030 +#define        CTL_ENTRY(ctl, name)                            \
26031 +       {                                               \
26032 +               .procname       = #name,                \
26033 +               .data           = &vx_ ## name,         \
26034 +               .maxlen         = sizeof(int),          \
26035 +               .mode           = 0644,                 \
26036 +               .proc_handler   = &proc_dodebug,        \
26037 +               .extra1         = &zero,                \
26038 +               .extra2         = &zero,                \
26039 +       }
26040 +
26041 +static ctl_table vserver_debug_table[] = {
26042 +       CTL_ENTRY(CTL_DEBUG_SWITCH,     debug_switch),
26043 +       CTL_ENTRY(CTL_DEBUG_XID,        debug_xid),
26044 +       CTL_ENTRY(CTL_DEBUG_NID,        debug_nid),
26045 +       CTL_ENTRY(CTL_DEBUG_TAG,        debug_tag),
26046 +       CTL_ENTRY(CTL_DEBUG_NET,        debug_net),
26047 +       CTL_ENTRY(CTL_DEBUG_LIMIT,      debug_limit),
26048 +       CTL_ENTRY(CTL_DEBUG_CRES,       debug_cres),
26049 +       CTL_ENTRY(CTL_DEBUG_DLIM,       debug_dlim),
26050 +       CTL_ENTRY(CTL_DEBUG_QUOTA,      debug_quota),
26051 +       CTL_ENTRY(CTL_DEBUG_CVIRT,      debug_cvirt),
26052 +       CTL_ENTRY(CTL_DEBUG_SPACE,      debug_space),
26053 +       CTL_ENTRY(CTL_DEBUG_MISC,       debug_misc),
26054 +       { 0 }
26055 +};
26056 +
26057 +static ctl_table vserver_root_table[] = {
26058 +       {
26059 +               .procname       = "vserver",
26060 +               .mode           = 0555,
26061 +               .child          = vserver_debug_table
26062 +       },
26063 +       { 0 }
26064 +};
26065 +
26066 +
26067 +static match_table_t tokens = {
26068 +       { CTL_DEBUG_SWITCH,     "switch=%x"     },
26069 +       { CTL_DEBUG_XID,        "xid=%x"        },
26070 +       { CTL_DEBUG_NID,        "nid=%x"        },
26071 +       { CTL_DEBUG_TAG,        "tag=%x"        },
26072 +       { CTL_DEBUG_NET,        "net=%x"        },
26073 +       { CTL_DEBUG_LIMIT,      "limit=%x"      },
26074 +       { CTL_DEBUG_CRES,       "cres=%x"       },
26075 +       { CTL_DEBUG_DLIM,       "dlim=%x"       },
26076 +       { CTL_DEBUG_QUOTA,      "quota=%x"      },
26077 +       { CTL_DEBUG_CVIRT,      "cvirt=%x"      },
26078 +       { CTL_DEBUG_SPACE,      "space=%x"      },
26079 +       { CTL_DEBUG_MISC,       "misc=%x"       },
26080 +       { CTL_DEBUG_ERROR,      NULL            }
26081 +};
26082 +
26083 +#define        HANDLE_CASE(id, name, val)                              \
26084 +       case CTL_DEBUG_ ## id:                                  \
26085 +               vx_debug_ ## name = val;                        \
26086 +               printk("vs_debug_" #name "=0x%x\n", val);       \
26087 +               break
26088 +
26089 +
26090 +static int __init vs_debug_setup(char *str)
26091 +{
26092 +       char *p;
26093 +       int token;
26094 +
26095 +       printk("vs_debug_setup(%s)\n", str);
26096 +       while ((p = strsep(&str, ",")) != NULL) {
26097 +               substring_t args[MAX_OPT_ARGS];
26098 +               unsigned int value;
26099 +
26100 +               if (!*p)
26101 +                       continue;
26102 +
26103 +               token = match_token(p, tokens, args);
26104 +               value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
26105 +
26106 +               switch (token) {
26107 +               HANDLE_CASE(SWITCH, switch, value);
26108 +               HANDLE_CASE(XID,    xid,    value);
26109 +               HANDLE_CASE(NID,    nid,    value);
26110 +               HANDLE_CASE(TAG,    tag,    value);
26111 +               HANDLE_CASE(NET,    net,    value);
26112 +               HANDLE_CASE(LIMIT,  limit,  value);
26113 +               HANDLE_CASE(CRES,   cres,   value);
26114 +               HANDLE_CASE(DLIM,   dlim,   value);
26115 +               HANDLE_CASE(QUOTA,  quota,  value);
26116 +               HANDLE_CASE(CVIRT,  cvirt,  value);
26117 +               HANDLE_CASE(SPACE,  space,  value);
26118 +               HANDLE_CASE(MISC,   misc,   value);
26119 +               default:
26120 +                       return -EINVAL;
26121 +                       break;
26122 +               }
26123 +       }
26124 +       return 1;
26125 +}
26126 +
26127 +__setup("vsdebug=", vs_debug_setup);
26128 +
26129 +
26130 +
26131 +EXPORT_SYMBOL_GPL(vx_debug_switch);
26132 +EXPORT_SYMBOL_GPL(vx_debug_xid);
26133 +EXPORT_SYMBOL_GPL(vx_debug_nid);
26134 +EXPORT_SYMBOL_GPL(vx_debug_net);
26135 +EXPORT_SYMBOL_GPL(vx_debug_limit);
26136 +EXPORT_SYMBOL_GPL(vx_debug_cres);
26137 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
26138 +EXPORT_SYMBOL_GPL(vx_debug_quota);
26139 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
26140 +EXPORT_SYMBOL_GPL(vx_debug_space);
26141 +EXPORT_SYMBOL_GPL(vx_debug_misc);
26142 +
26143 diff -NurpP --minimal linux-2.6.34/kernel/vserver/tag.c linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/tag.c
26144 --- linux-2.6.34/kernel/vserver/tag.c   1970-01-01 01:00:00.000000000 +0100
26145 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/tag.c      2010-05-18 18:11:22.000000000 +0200
26146 @@ -0,0 +1,63 @@
26147 +/*
26148 + *  linux/kernel/vserver/tag.c
26149 + *
26150 + *  Virtual Server: Shallow Tag Space
26151 + *
26152 + *  Copyright (C) 2007  Herbert Pötzl
26153 + *
26154 + *  V0.01  basic implementation
26155 + *
26156 + */
26157 +
26158 +#include <linux/sched.h>
26159 +#include <linux/vserver/debug.h>
26160 +#include <linux/vs_pid.h>
26161 +#include <linux/vs_tag.h>
26162 +
26163 +#include <linux/vserver/tag_cmd.h>
26164 +
26165 +
26166 +int dx_migrate_task(struct task_struct *p, tag_t tag)
26167 +{
26168 +       if (!p)
26169 +               BUG();
26170 +
26171 +       vxdprintk(VXD_CBIT(tag, 5),
26172 +               "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
26173 +
26174 +       task_lock(p);
26175 +       p->tag = tag;
26176 +       task_unlock(p);
26177 +
26178 +       vxdprintk(VXD_CBIT(tag, 5),
26179 +               "moved task %p into [#%d]", p, tag);
26180 +       return 0;
26181 +}
26182 +
26183 +/* vserver syscall commands below here */
26184 +
26185 +/* taks xid and vx_info functions */
26186 +
26187 +
26188 +int vc_task_tag(uint32_t id)
26189 +{
26190 +       tag_t tag;
26191 +
26192 +       if (id) {
26193 +               struct task_struct *tsk;
26194 +               read_lock(&tasklist_lock);
26195 +               tsk = find_task_by_real_pid(id);
26196 +               tag = (tsk) ? tsk->tag : -ESRCH;
26197 +               read_unlock(&tasklist_lock);
26198 +       } else
26199 +               tag = dx_current_tag();
26200 +       return tag;
26201 +}
26202 +
26203 +
26204 +int vc_tag_migrate(uint32_t tag)
26205 +{
26206 +       return dx_migrate_task(current, tag & 0xFFFF);
26207 +}
26208 +
26209 +
26210 diff -NurpP --minimal linux-2.6.34/kernel/vserver/vci_config.h linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/vci_config.h
26211 --- linux-2.6.34/kernel/vserver/vci_config.h    1970-01-01 01:00:00.000000000 +0100
26212 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/kernel/vserver/vci_config.h       2010-05-22 01:16:29.000000000 +0200
26213 @@ -0,0 +1,85 @@
26214 +
26215 +/*  interface version */
26216 +
26217 +#define VCI_VERSION            0x00020306
26218 +
26219 +
26220 +enum {
26221 +       VCI_KCBIT_NO_DYNAMIC = 0,
26222 +
26223 +       VCI_KCBIT_PROC_SECURE = 4,
26224 +       VCI_KCBIT_HARDCPU = 5,
26225 +       VCI_KCBIT_IDLELIMIT = 6,
26226 +       VCI_KCBIT_IDLETIME = 7,
26227 +
26228 +       VCI_KCBIT_COWBL = 8,
26229 +       VCI_KCBIT_FULLCOWBL = 9,
26230 +       VCI_KCBIT_SPACES = 10,
26231 +       VCI_KCBIT_NETV2 = 11,
26232 +       VCI_KCBIT_MEMCG = 12,
26233 +
26234 +       VCI_KCBIT_DEBUG = 16,
26235 +       VCI_KCBIT_HISTORY = 20,
26236 +       VCI_KCBIT_TAGGED = 24,
26237 +       VCI_KCBIT_PPTAG = 28,
26238 +
26239 +       VCI_KCBIT_MORE = 31,
26240 +};
26241 +
26242 +
26243 +static inline uint32_t vci_kernel_config(void)
26244 +{
26245 +       return
26246 +       (1 << VCI_KCBIT_NO_DYNAMIC) |
26247 +
26248 +       /* configured features */
26249 +#ifdef CONFIG_VSERVER_PROC_SECURE
26250 +       (1 << VCI_KCBIT_PROC_SECURE) |
26251 +#endif
26252 +#ifdef CONFIG_VSERVER_HARDCPU
26253 +       (1 << VCI_KCBIT_HARDCPU) |
26254 +#endif
26255 +#ifdef CONFIG_VSERVER_IDLELIMIT
26256 +       (1 << VCI_KCBIT_IDLELIMIT) |
26257 +#endif
26258 +#ifdef CONFIG_VSERVER_IDLETIME
26259 +       (1 << VCI_KCBIT_IDLETIME) |
26260 +#endif
26261 +#ifdef CONFIG_VSERVER_COWBL
26262 +       (1 << VCI_KCBIT_COWBL) |
26263 +       (1 << VCI_KCBIT_FULLCOWBL) |
26264 +#endif
26265 +       (1 << VCI_KCBIT_SPACES) |
26266 +       (1 << VCI_KCBIT_NETV2) |
26267 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
26268 +       (1 << VCI_KCBIT_MEMCG) |
26269 +#endif
26270 +
26271 +       /* debug options */
26272 +#ifdef CONFIG_VSERVER_DEBUG
26273 +       (1 << VCI_KCBIT_DEBUG) |
26274 +#endif
26275 +#ifdef CONFIG_VSERVER_HISTORY
26276 +       (1 << VCI_KCBIT_HISTORY) |
26277 +#endif
26278 +
26279 +       /* inode context tagging */
26280 +#if    defined(CONFIG_TAGGING_NONE)
26281 +       (0 << VCI_KCBIT_TAGGED) |
26282 +#elif  defined(CONFIG_TAGGING_UID16)
26283 +       (1 << VCI_KCBIT_TAGGED) |
26284 +#elif  defined(CONFIG_TAGGING_GID16)
26285 +       (2 << VCI_KCBIT_TAGGED) |
26286 +#elif  defined(CONFIG_TAGGING_ID24)
26287 +       (3 << VCI_KCBIT_TAGGED) |
26288 +#elif  defined(CONFIG_TAGGING_INTERN)
26289 +       (4 << VCI_KCBIT_TAGGED) |
26290 +#elif  defined(CONFIG_TAGGING_RUNTIME)
26291 +       (5 << VCI_KCBIT_TAGGED) |
26292 +#else
26293 +       (7 << VCI_KCBIT_TAGGED) |
26294 +#endif
26295 +       (1 << VCI_KCBIT_PPTAG) |
26296 +       0;
26297 +}
26298 +
26299 diff -NurpP --minimal linux-2.6.34/mm/filemap_xip.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/filemap_xip.c
26300 --- linux-2.6.34/mm/filemap_xip.c       2010-05-18 15:07:53.000000000 +0200
26301 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/filemap_xip.c  2010-05-18 18:11:22.000000000 +0200
26302 @@ -18,6 +18,7 @@
26303  #include <linux/seqlock.h>
26304  #include <linux/mutex.h>
26305  #include <linux/gfp.h>
26306 +#include <linux/vs_memory.h>
26307  #include <asm/tlbflush.h>
26308  #include <asm/io.h>
26309  
26310 diff -NurpP --minimal linux-2.6.34/mm/fremap.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/fremap.c
26311 --- linux-2.6.34/mm/fremap.c    2010-05-18 15:07:53.000000000 +0200
26312 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/fremap.c       2010-05-18 18:11:22.000000000 +0200
26313 @@ -16,6 +16,7 @@
26314  #include <linux/module.h>
26315  #include <linux/syscalls.h>
26316  #include <linux/mmu_notifier.h>
26317 +#include <linux/vs_memory.h>
26318  
26319  #include <asm/mmu_context.h>
26320  #include <asm/cacheflush.h>
26321 diff -NurpP --minimal linux-2.6.34/mm/hugetlb.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/hugetlb.c
26322 --- linux-2.6.34/mm/hugetlb.c   2010-05-18 15:07:53.000000000 +0200
26323 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/hugetlb.c      2010-05-18 18:11:22.000000000 +0200
26324 @@ -25,6 +25,7 @@
26325  
26326  #include <linux/hugetlb.h>
26327  #include <linux/node.h>
26328 +#include <linux/vs_memory.h>
26329  #include "internal.h"
26330  
26331  const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26332 diff -NurpP --minimal linux-2.6.34/mm/memcontrol.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/memcontrol.c
26333 --- linux-2.6.34/mm/memcontrol.c        2010-05-18 15:07:53.000000000 +0200
26334 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/memcontrol.c   2010-05-18 18:11:22.000000000 +0200
26335 @@ -596,6 +596,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26336                                 struct mem_cgroup, css);
26337  }
26338  
26339 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26340 +{
26341 +       return res_counter_read_u64(&mem->res, member);
26342 +}
26343 +
26344 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26345 +{
26346 +       return res_counter_read_u64(&mem->memsw, member);
26347 +}
26348 +
26349 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26350 +{
26351 +       return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_CACHE);
26352 +}
26353 +
26354 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26355 +{
26356 +       return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
26357 +}
26358 +
26359 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26360 +{
26361 +       return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_FILE_MAPPED);
26362 +}
26363 +
26364  static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26365  {
26366         struct mem_cgroup *mem = NULL;
26367 diff -NurpP --minimal linux-2.6.34/mm/memory.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/memory.c
26368 --- linux-2.6.34/mm/memory.c    2010-05-18 15:07:53.000000000 +0200
26369 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/memory.c       2010-05-19 03:16:21.000000000 +0200
26370 @@ -3057,6 +3057,7 @@ static inline int handle_pte_fault(struc
26371  {
26372         pte_t entry;
26373         spinlock_t *ptl;
26374 +       int ret = 0, type = VXPT_UNKNOWN;
26375  
26376         entry = *pte;
26377         if (!pte_present(entry)) {
26378 @@ -3081,9 +3082,12 @@ static inline int handle_pte_fault(struc
26379         if (unlikely(!pte_same(*pte, entry)))
26380                 goto unlock;
26381         if (flags & FAULT_FLAG_WRITE) {
26382 -               if (!pte_write(entry))
26383 -                       return do_wp_page(mm, vma, address,
26384 +               if (!pte_write(entry)) {
26385 +                       ret = do_wp_page(mm, vma, address,
26386                                         pte, pmd, ptl, entry);
26387 +                       type = VXPT_WRITE;
26388 +                       goto out;
26389 +               }
26390                 entry = pte_mkdirty(entry);
26391         }
26392         entry = pte_mkyoung(entry);
26393 @@ -3101,7 +3105,10 @@ static inline int handle_pte_fault(struc
26394         }
26395  unlock:
26396         pte_unmap_unlock(pte, ptl);
26397 -       return 0;
26398 +       ret = 0;
26399 +out:
26400 +       vx_page_fault(mm, vma, type, ret);
26401 +       return ret;
26402  }
26403  
26404  /*
26405 diff -NurpP --minimal linux-2.6.34/mm/mlock.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/mlock.c
26406 --- linux-2.6.34/mm/mlock.c     2010-05-18 15:07:53.000000000 +0200
26407 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/mlock.c        2010-05-19 03:10:18.000000000 +0200
26408 @@ -18,6 +18,7 @@
26409  #include <linux/rmap.h>
26410  #include <linux/mmzone.h>
26411  #include <linux/hugetlb.h>
26412 +#include <linux/vs_memory.h>
26413  
26414  #include "internal.h"
26415  
26416 @@ -471,7 +472,7 @@ static int do_mlock(unsigned long start,
26417  
26418  SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
26419  {
26420 -       unsigned long locked;
26421 +       unsigned long locked, grow;
26422         unsigned long lock_limit;
26423         int error = -ENOMEM;
26424  
26425 @@ -493,6 +494,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26426         /* check against resource limits */
26427         if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
26428                 error = do_mlock(start, len, 1);
26429 +out:
26430         up_write(&current->mm->mmap_sem);
26431         return error;
26432  }
26433 diff -NurpP --minimal linux-2.6.34/mm/mremap.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/mremap.c
26434 --- linux-2.6.34/mm/mremap.c    2010-05-18 15:07:53.000000000 +0200
26435 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/mremap.c       2010-05-19 03:10:18.000000000 +0200
26436 @@ -19,6 +19,7 @@
26437  #include <linux/security.h>
26438  #include <linux/syscalls.h>
26439  #include <linux/mmu_notifier.h>
26440 +#include <linux/vs_memory.h>
26441  
26442  #include <asm/uaccess.h>
26443  #include <asm/cacheflush.h>
26444 diff -NurpP --minimal linux-2.6.34/mm/oom_kill.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/oom_kill.c
26445 --- linux-2.6.34/mm/oom_kill.c  2010-05-18 15:07:53.000000000 +0200
26446 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/oom_kill.c     2010-05-18 18:11:22.000000000 +0200
26447 @@ -28,6 +28,9 @@
26448  #include <linux/notifier.h>
26449  #include <linux/memcontrol.h>
26450  #include <linux/security.h>
26451 +#include <linux/reboot.h>
26452 +#include <linux/vs_memory.h>
26453 +#include <linux/vs_context.h>
26454  
26455  int sysctl_panic_on_oom;
26456  int sysctl_oom_kill_allocating_task;
26457 @@ -187,9 +190,21 @@ unsigned long badness(struct task_struct
26458                         points >>= -(oom_adj);
26459         }
26460  
26461 +       /*
26462 +        * add points for context badness and
26463 +        * reduce badness for processes belonging to
26464 +        * a different context
26465 +        */
26466 +
26467 +       points += vx_badness(p, mm);
26468 +
26469 +       if ((vx_current_xid() > 1) &&
26470 +               vx_current_xid() != vx_task_xid(p))
26471 +               points /= 16;
26472 +
26473  #ifdef DEBUG
26474 -       printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
26475 -       p->pid, p->comm, points);
26476 +       printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
26477 +               task_pid_nr(p), p->xid, p->comm, points);
26478  #endif
26479         return points;
26480  }
26481 @@ -250,6 +265,7 @@ static struct task_struct *select_bad_pr
26482         struct task_struct *p;
26483         struct task_struct *chosen = NULL;
26484         struct timespec uptime;
26485 +       unsigned xid = vx_current_xid();
26486         *ppoints = 0;
26487  
26488         do_posix_clock_monotonic_gettime(&uptime);
26489 @@ -262,11 +278,14 @@ static struct task_struct *select_bad_pr
26490                  */
26491                 if (!p->mm)
26492                         continue;
26493 -               /* skip the init task */
26494 -               if (is_global_init(p))
26495 +               /* skip the init task, global and per guest */
26496 +               if (task_is_init(p))
26497                         continue;
26498                 if (mem && !task_in_mem_cgroup(p, mem))
26499                         continue;
26500 +               /* skip other guest and host processes if oom in guest */
26501 +               if (xid && vx_task_xid(p) != xid)
26502 +                       continue;
26503  
26504                 /*
26505                  * This task already has access to memory reserves and is
26506 @@ -398,9 +417,9 @@ static void __oom_kill_task(struct task_
26507         }
26508  
26509         if (verbose)
26510 -               printk(KERN_ERR "Killed process %d (%s) "
26511 +               printk(KERN_ERR "Killed process %s(%d:#%u) "
26512                        "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
26513 -                      task_pid_nr(p), p->comm,
26514 +                      p->comm, task_pid_nr(p), p->xid,
26515                        K(p->mm->total_vm),
26516                        K(get_mm_counter(p->mm, MM_ANONPAGES)),
26517                        K(get_mm_counter(p->mm, MM_FILEPAGES)));
26518 @@ -453,8 +472,8 @@ static int oom_kill_process(struct task_
26519                 return 0;
26520         }
26521  
26522 -       printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
26523 -                                       message, task_pid_nr(p), p->comm, points);
26524 +       printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
26525 +               message, p->comm, task_pid_nr(p), p->xid, points);
26526  
26527         /* Try to kill a child first */
26528         list_for_each_entry(c, &p->children, sibling) {
26529 @@ -557,6 +576,8 @@ void clear_zonelist_oom(struct zonelist 
26530         spin_unlock(&zone_scan_lock);
26531  }
26532  
26533 +long vs_oom_action(unsigned int);
26534 +
26535  /*
26536   * Must be called with tasklist_lock held for read.
26537   */
26538 @@ -583,7 +604,11 @@ retry:
26539         if (!p) {
26540                 read_unlock(&tasklist_lock);
26541                 dump_header(NULL, gfp_mask, order, NULL);
26542 -               panic("Out of memory and no killable processes...\n");
26543 +               /* avoid panic for guest OOM */
26544 +               if (current->xid)
26545 +                       vs_oom_action(LINUX_REBOOT_CMD_OOM);
26546 +               else
26547 +                       panic("Out of memory and no killable processes...\n");
26548         }
26549  
26550         if (oom_kill_process(p, gfp_mask, order, points, NULL,
26551 diff -NurpP --minimal linux-2.6.34/mm/page_alloc.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/page_alloc.c
26552 --- linux-2.6.34/mm/page_alloc.c        2010-05-18 15:07:53.000000000 +0200
26553 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/page_alloc.c   2010-05-18 18:11:22.000000000 +0200
26554 @@ -49,6 +49,8 @@
26555  #include <linux/debugobjects.h>
26556  #include <linux/kmemleak.h>
26557  #include <linux/memory.h>
26558 +#include <linux/vs_base.h>
26559 +#include <linux/vs_limit.h>
26560  #include <trace/events/kmem.h>
26561  #include <linux/ftrace_event.h>
26562  
26563 @@ -2152,6 +2154,9 @@ void si_meminfo(struct sysinfo *val)
26564         val->totalhigh = totalhigh_pages;
26565         val->freehigh = nr_free_highpages();
26566         val->mem_unit = PAGE_SIZE;
26567 +
26568 +       if (vx_flags(VXF_VIRT_MEM, 0))
26569 +               vx_vsi_meminfo(val);
26570  }
26571  
26572  EXPORT_SYMBOL(si_meminfo);
26573 @@ -2172,6 +2177,9 @@ void si_meminfo_node(struct sysinfo *val
26574         val->freehigh = 0;
26575  #endif
26576         val->mem_unit = PAGE_SIZE;
26577 +
26578 +       if (vx_flags(VXF_VIRT_MEM, 0))
26579 +               vx_vsi_meminfo(val);
26580  }
26581  #endif
26582  
26583 diff -NurpP --minimal linux-2.6.34/mm/rmap.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/rmap.c
26584 --- linux-2.6.34/mm/rmap.c      2010-05-18 15:07:53.000000000 +0200
26585 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/rmap.c 2010-05-18 18:11:22.000000000 +0200
26586 @@ -56,6 +56,7 @@
26587  #include <linux/memcontrol.h>
26588  #include <linux/mmu_notifier.h>
26589  #include <linux/migrate.h>
26590 +#include <linux/vs_memory.h>
26591  
26592  #include <asm/tlbflush.h>
26593  
26594 diff -NurpP --minimal linux-2.6.34/mm/shmem.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/shmem.c
26595 --- linux-2.6.34/mm/shmem.c     2010-02-25 11:52:09.000000000 +0100
26596 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/shmem.c        2010-05-18 18:11:22.000000000 +0200
26597 @@ -1788,7 +1788,7 @@ static int shmem_statfs(struct dentry *d
26598  {
26599         struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26600  
26601 -       buf->f_type = TMPFS_MAGIC;
26602 +       buf->f_type = TMPFS_SUPER_MAGIC;
26603         buf->f_bsize = PAGE_CACHE_SIZE;
26604         buf->f_namelen = NAME_MAX;
26605         spin_lock(&sbinfo->stat_lock);
26606 @@ -2358,7 +2358,7 @@ int shmem_fill_super(struct super_block 
26607         sb->s_maxbytes = SHMEM_MAX_BYTES;
26608         sb->s_blocksize = PAGE_CACHE_SIZE;
26609         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26610 -       sb->s_magic = TMPFS_MAGIC;
26611 +       sb->s_magic = TMPFS_SUPER_MAGIC;
26612         sb->s_op = &shmem_ops;
26613         sb->s_time_gran = 1;
26614  #ifdef CONFIG_TMPFS_POSIX_ACL
26615 diff -NurpP --minimal linux-2.6.34/mm/slab.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/slab.c
26616 --- linux-2.6.34/mm/slab.c      2010-05-18 15:07:53.000000000 +0200
26617 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/slab.c 2010-05-18 18:11:22.000000000 +0200
26618 @@ -431,6 +431,8 @@ static void kmem_list3_init(struct kmem_
26619  #define STATS_INC_FREEMISS(x)  do { } while (0)
26620  #endif
26621  
26622 +#include "slab_vs.h"
26623 +
26624  #if DEBUG
26625  
26626  /*
26627 @@ -3274,6 +3276,7 @@ retry:
26628  
26629         obj = slab_get_obj(cachep, slabp, nodeid);
26630         check_slabp(cachep, slabp);
26631 +       vx_slab_alloc(cachep, flags);
26632         l3->free_objects--;
26633         /* move slabp to correct slabp list: */
26634         list_del(&slabp->list);
26635 @@ -3350,6 +3353,7 @@ __cache_alloc_node(struct kmem_cache *ca
26636         /* ___cache_alloc_node can fall back to other nodes */
26637         ptr = ____cache_alloc_node(cachep, flags, nodeid);
26638    out:
26639 +       vx_slab_alloc(cachep, flags);
26640         local_irq_restore(save_flags);
26641         ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26642         kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
26643 @@ -3536,6 +3540,7 @@ static inline void __cache_free(struct k
26644         check_irq_off();
26645         kmemleak_free_recursive(objp, cachep->flags);
26646         objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
26647 +       vx_slab_free(cachep);
26648  
26649         kmemcheck_slab_free(cachep, objp, obj_size(cachep));
26650  
26651 diff -NurpP --minimal linux-2.6.34/mm/slab_vs.h linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/slab_vs.h
26652 --- linux-2.6.34/mm/slab_vs.h   1970-01-01 01:00:00.000000000 +0100
26653 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/slab_vs.h      2010-05-18 18:11:22.000000000 +0200
26654 @@ -0,0 +1,29 @@
26655 +
26656 +#include <linux/vserver/context.h>
26657 +
26658 +#include <linux/vs_context.h>
26659 +
26660 +static inline
26661 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26662 +{
26663 +       int what = gfp_zone(cachep->gfpflags);
26664 +       struct vx_info *vxi = current_vx_info();
26665 +
26666 +       if (!vxi)
26667 +               return;
26668 +
26669 +       atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
26670 +}
26671 +
26672 +static inline
26673 +void vx_slab_free(struct kmem_cache *cachep)
26674 +{
26675 +       int what = gfp_zone(cachep->gfpflags);
26676 +       struct vx_info *vxi = current_vx_info();
26677 +
26678 +       if (!vxi)
26679 +               return;
26680 +
26681 +       atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
26682 +}
26683 +
26684 diff -NurpP --minimal linux-2.6.34/mm/swapfile.c linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/swapfile.c
26685 --- linux-2.6.34/mm/swapfile.c  2010-05-18 15:07:53.000000000 +0200
26686 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/mm/swapfile.c     2010-05-18 18:11:22.000000000 +0200
26687 @@ -35,6 +35,8 @@
26688  #include <asm/tlbflush.h>
26689  #include <linux/swapops.h>
26690  #include <linux/page_cgroup.h>
26691 +#include <linux/vs_base.h>
26692 +#include <linux/vs_memory.h>
26693  
26694  static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
26695                                  unsigned char);
26696 @@ -1725,6 +1727,16 @@ static int swap_show(struct seq_file *sw
26697  
26698         if (si == SEQ_START_TOKEN) {
26699                 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
26700 +               if (vx_flags(VXF_VIRT_MEM, 0)) {
26701 +                       struct sysinfo si;
26702 +
26703 +                       vx_vsi_swapinfo(&si);
26704 +                       if (si.totalswap < (1 << 10))
26705 +                               return 0;
26706 +                       seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
26707 +                               "hdv0", "partition", si.totalswap >> 10,
26708 +                               (si.totalswap - si.freeswap) >> 10, -1);
26709 +               }
26710                 return 0;
26711         }
26712  
26713 @@ -2108,6 +2120,8 @@ void si_swapinfo(struct sysinfo *val)
26714         val->freeswap = nr_swap_pages + nr_to_be_unused;
26715         val->totalswap = total_swap_pages + nr_to_be_unused;
26716         spin_unlock(&swap_lock);
26717 +       if (vx_flags(VXF_VIRT_MEM, 0))
26718 +               vx_vsi_swapinfo(val);
26719  }
26720  
26721  /*
26722 diff -NurpP --minimal linux-2.6.34/net/core/dev.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/core/dev.c
26723 --- linux-2.6.34/net/core/dev.c 2010-05-18 15:07:53.000000000 +0200
26724 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/core/dev.c    2010-05-18 18:11:22.000000000 +0200
26725 @@ -129,6 +129,7 @@
26726  #include <linux/in.h>
26727  #include <linux/jhash.h>
26728  #include <linux/random.h>
26729 +#include <linux/vs_inet.h>
26730  #include <trace/events/napi.h>
26731  
26732  #include "net-sysfs.h"
26733 @@ -594,7 +595,8 @@ struct net_device *__dev_get_by_name(str
26734         struct hlist_head *head = dev_name_hash(net, name);
26735  
26736         hlist_for_each_entry(dev, p, head, name_hlist)
26737 -               if (!strncmp(dev->name, name, IFNAMSIZ))
26738 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
26739 +                   nx_dev_visible(current_nx_info(), dev))
26740                         return dev;
26741  
26742         return NULL;
26743 @@ -620,7 +622,8 @@ struct net_device *dev_get_by_name_rcu(s
26744         struct hlist_head *head = dev_name_hash(net, name);
26745  
26746         hlist_for_each_entry_rcu(dev, p, head, name_hlist)
26747 -               if (!strncmp(dev->name, name, IFNAMSIZ))
26748 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
26749 +                   nx_dev_visible(current_nx_info(), dev))
26750                         return dev;
26751  
26752         return NULL;
26753 @@ -671,7 +674,8 @@ struct net_device *__dev_get_by_index(st
26754         struct hlist_head *head = dev_index_hash(net, ifindex);
26755  
26756         hlist_for_each_entry(dev, p, head, index_hlist)
26757 -               if (dev->ifindex == ifindex)
26758 +               if ((dev->ifindex == ifindex) &&
26759 +                   nx_dev_visible(current_nx_info(), dev))
26760                         return dev;
26761  
26762         return NULL;
26763 @@ -696,7 +700,8 @@ struct net_device *dev_get_by_index_rcu(
26764         struct hlist_head *head = dev_index_hash(net, ifindex);
26765  
26766         hlist_for_each_entry_rcu(dev, p, head, index_hlist)
26767 -               if (dev->ifindex == ifindex)
26768 +               if ((dev->ifindex == ifindex) &&
26769 +                   nx_dev_visible(current_nx_info(), dev))
26770                         return dev;
26771  
26772         return NULL;
26773 @@ -749,10 +754,12 @@ struct net_device *dev_getbyhwaddr(struc
26774  
26775         ASSERT_RTNL();
26776  
26777 -       for_each_netdev(net, dev)
26778 +       for_each_netdev(net, dev) {
26779                 if (dev->type == type &&
26780 -                   !memcmp(dev->dev_addr, ha, dev->addr_len))
26781 +                   !memcmp(dev->dev_addr, ha, dev->addr_len) &&
26782 +                   nx_dev_visible(current_nx_info(), dev))
26783                         return dev;
26784 +       }
26785  
26786         return NULL;
26787  }
26788 @@ -763,9 +770,11 @@ struct net_device *__dev_getfirstbyhwtyp
26789         struct net_device *dev;
26790  
26791         ASSERT_RTNL();
26792 -       for_each_netdev(net, dev)
26793 -               if (dev->type == type)
26794 +       for_each_netdev(net, dev) {
26795 +               if ((dev->type == type) &&
26796 +                   nx_dev_visible(current_nx_info(), dev))
26797                         return dev;
26798 +       }
26799  
26800         return NULL;
26801  }
26802 @@ -884,6 +893,8 @@ static int __dev_alloc_name(struct net *
26803                                 continue;
26804                         if (i < 0 || i >= max_netdevices)
26805                                 continue;
26806 +                       if (!nx_dev_visible(current_nx_info(), d))
26807 +                               continue;
26808  
26809                         /*  avoid cases where sscanf is not exact inverse of printf */
26810                         snprintf(buf, IFNAMSIZ, name, i);
26811 @@ -3195,6 +3206,8 @@ static int dev_ifconf(struct net *net, c
26812  
26813         total = 0;
26814         for_each_netdev(net, dev) {
26815 +               if (!nx_dev_visible(current_nx_info(), dev))
26816 +                       continue;
26817                 for (i = 0; i < NPROTO; i++) {
26818                         if (gifconf_list[i]) {
26819                                 int done;
26820 @@ -3265,6 +3278,9 @@ static void dev_seq_printf_stats(struct 
26821  {
26822         const struct net_device_stats *stats = dev_get_stats(dev);
26823  
26824 +       if (!nx_dev_visible(current_nx_info(), dev))
26825 +               return;
26826 +
26827         seq_printf(seq, "%6s: %7lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
26828                    "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
26829                    dev->name, stats->rx_bytes, stats->rx_packets,
26830 @@ -5642,7 +5658,6 @@ int dev_change_net_namespace(struct net_
26831         if (dev->dev.parent)
26832                 goto out;
26833  #endif
26834 -
26835         /* Ensure the device has been registrered */
26836         err = -EINVAL;
26837         if (dev->reg_state != NETREG_REGISTERED)
26838 diff -NurpP --minimal linux-2.6.34/net/core/rtnetlink.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/core/rtnetlink.c
26839 --- linux-2.6.34/net/core/rtnetlink.c   2010-05-18 15:07:53.000000000 +0200
26840 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/core/rtnetlink.c      2010-05-18 18:11:22.000000000 +0200
26841 @@ -769,6 +769,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26842                 hlist_for_each_entry(dev, node, head, index_hlist) {
26843                         if (idx < s_idx)
26844                                 goto cont;
26845 +                       if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26846 +                               continue;
26847                         if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26848                                              NETLINK_CB(cb->skb).pid,
26849                                              cb->nlh->nlmsg_seq, 0,
26850 @@ -1420,6 +1422,9 @@ void rtmsg_ifinfo(int type, struct net_d
26851         struct sk_buff *skb;
26852         int err = -ENOBUFS;
26853  
26854 +       if (!nx_dev_visible(current_nx_info(), dev))
26855 +               return;
26856 +
26857         skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26858         if (skb == NULL)
26859                 goto errout;
26860 diff -NurpP --minimal linux-2.6.34/net/core/sock.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/core/sock.c
26861 --- linux-2.6.34/net/core/sock.c        2010-05-18 15:07:53.000000000 +0200
26862 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/core/sock.c   2010-05-18 18:11:22.000000000 +0200
26863 @@ -125,6 +125,10 @@
26864  #include <linux/ipsec.h>
26865  
26866  #include <linux/filter.h>
26867 +#include <linux/vs_socket.h>
26868 +#include <linux/vs_limit.h>
26869 +#include <linux/vs_context.h>
26870 +#include <linux/vs_network.h>
26871  
26872  #ifdef CONFIG_INET
26873  #include <net/tcp.h>
26874 @@ -1012,6 +1016,8 @@ static struct sock *sk_prot_alloc(struct
26875                         goto out_free_sec;
26876                 sk_tx_queue_clear(sk);
26877         }
26878 +               sock_vx_init(sk);
26879 +               sock_nx_init(sk);
26880  
26881         return sk;
26882  
26883 @@ -1092,6 +1098,11 @@ static void __sk_free(struct sock *sk)
26884                        __func__, atomic_read(&sk->sk_omem_alloc));
26885  
26886         put_net(sock_net(sk));
26887 +       vx_sock_dec(sk);
26888 +       clr_vx_info(&sk->sk_vx_info);
26889 +       sk->sk_xid = -1;
26890 +       clr_nx_info(&sk->sk_nx_info);
26891 +       sk->sk_nid = -1;
26892         sk_prot_free(sk->sk_prot_creator, sk);
26893  }
26894  
26895 @@ -1139,6 +1150,8 @@ struct sock *sk_clone(const struct sock 
26896  
26897                 /* SANITY */
26898                 get_net(sock_net(newsk));
26899 +               sock_vx_init(newsk);
26900 +               sock_nx_init(newsk);
26901                 sk_node_init(&newsk->sk_node);
26902                 sock_lock_init(newsk);
26903                 bh_lock_sock(newsk);
26904 @@ -1194,6 +1207,12 @@ struct sock *sk_clone(const struct sock 
26905                 smp_wmb();
26906                 atomic_set(&newsk->sk_refcnt, 2);
26907  
26908 +               set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26909 +               newsk->sk_xid = sk->sk_xid;
26910 +               vx_sock_inc(newsk);
26911 +               set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26912 +               newsk->sk_nid = sk->sk_nid;
26913 +
26914                 /*
26915                  * Increment the counter in the same struct proto as the master
26916                  * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26917 @@ -1923,6 +1942,12 @@ void sock_init_data(struct socket *sock,
26918  
26919         sk->sk_stamp = ktime_set(-1L, 0);
26920  
26921 +       set_vx_info(&sk->sk_vx_info, current_vx_info());
26922 +       sk->sk_xid = vx_current_xid();
26923 +       vx_sock_inc(sk);
26924 +       set_nx_info(&sk->sk_nx_info, current_nx_info());
26925 +       sk->sk_nid = nx_current_nid();
26926 +
26927         /*
26928          * Before updating sk_refcnt, we must commit prior changes to memory
26929          * (Documentation/RCU/rculist_nulls.txt for details)
26930 diff -NurpP --minimal linux-2.6.34/net/ipv4/af_inet.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/af_inet.c
26931 --- linux-2.6.34/net/ipv4/af_inet.c     2010-05-18 15:07:53.000000000 +0200
26932 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/af_inet.c        2010-05-18 18:11:22.000000000 +0200
26933 @@ -116,6 +116,7 @@
26934  #ifdef CONFIG_IP_MROUTE
26935  #include <linux/mroute.h>
26936  #endif
26937 +#include <linux/vs_limit.h>
26938  
26939  
26940  /* The inetsw table contains everything that inet_create needs to
26941 @@ -327,9 +328,13 @@ lookup_protocol:
26942         }
26943  
26944         err = -EPERM;
26945 +       if ((protocol == IPPROTO_ICMP) &&
26946 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
26947 +               goto override;
26948 +
26949         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
26950                 goto out_rcu_unlock;
26951 -
26952 +override:
26953         err = -EAFNOSUPPORT;
26954         if (!inet_netns_ok(net, protocol))
26955                 goto out_rcu_unlock;
26956 @@ -449,6 +454,7 @@ int inet_bind(struct socket *sock, struc
26957         struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26958         struct sock *sk = sock->sk;
26959         struct inet_sock *inet = inet_sk(sk);
26960 +       struct nx_v4_sock_addr nsa;
26961         unsigned short snum;
26962         int chk_addr_ret;
26963         int err;
26964 @@ -462,7 +468,11 @@ int inet_bind(struct socket *sock, struc
26965         if (addr_len < sizeof(struct sockaddr_in))
26966                 goto out;
26967  
26968 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26969 +       err = v4_map_sock_addr(inet, addr, &nsa);
26970 +       if (err)
26971 +               goto out;
26972 +
26973 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26974  
26975         /* Not specified by any standard per-se, however it breaks too
26976          * many applications when removed.  It is unfortunate since
26977 @@ -474,7 +484,7 @@ int inet_bind(struct socket *sock, struc
26978         err = -EADDRNOTAVAIL;
26979         if (!sysctl_ip_nonlocal_bind &&
26980             !(inet->freebind || inet->transparent) &&
26981 -           addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26982 +           nsa.saddr != htonl(INADDR_ANY) &&
26983             chk_addr_ret != RTN_LOCAL &&
26984             chk_addr_ret != RTN_MULTICAST &&
26985             chk_addr_ret != RTN_BROADCAST)
26986 @@ -499,7 +509,7 @@ int inet_bind(struct socket *sock, struc
26987         if (sk->sk_state != TCP_CLOSE || inet->inet_num)
26988                 goto out_release_sock;
26989  
26990 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26991 +       v4_set_sock_addr(inet, &nsa);
26992         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26993                 inet->inet_saddr = 0;  /* Use device */
26994  
26995 @@ -701,11 +711,13 @@ int inet_getname(struct socket *sock, st
26996                      peer == 1))
26997                         return -ENOTCONN;
26998                 sin->sin_port = inet->inet_dport;
26999 -               sin->sin_addr.s_addr = inet->inet_daddr;
27000 +               sin->sin_addr.s_addr =
27001 +                       nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
27002         } else {
27003                 __be32 addr = inet->inet_rcv_saddr;
27004                 if (!addr)
27005                         addr = inet->inet_saddr;
27006 +               addr = nx_map_sock_lback(sk->sk_nx_info, addr);
27007                 sin->sin_port = inet->inet_sport;
27008                 sin->sin_addr.s_addr = addr;
27009         }
27010 diff -NurpP --minimal linux-2.6.34/net/ipv4/devinet.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/devinet.c
27011 --- linux-2.6.34/net/ipv4/devinet.c     2010-05-18 15:07:53.000000000 +0200
27012 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/devinet.c        2010-05-18 18:11:22.000000000 +0200
27013 @@ -417,6 +417,7 @@ struct in_device *inetdev_by_index(struc
27014  }
27015  EXPORT_SYMBOL(inetdev_by_index);
27016  
27017 +
27018  /* Called only from RTNL semaphored context. No locks. */
27019  
27020  struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
27021 @@ -659,6 +660,8 @@ int devinet_ioctl(struct net *net, unsig
27022  
27023         in_dev = __in_dev_get_rtnl(dev);
27024         if (in_dev) {
27025 +               struct nx_info *nxi = current_nx_info();
27026 +
27027                 if (tryaddrmatch) {
27028                         /* Matthias Andree */
27029                         /* compare label and address (4.4BSD style) */
27030 @@ -667,6 +670,8 @@ int devinet_ioctl(struct net *net, unsig
27031                            This is checked above. */
27032                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27033                              ifap = &ifa->ifa_next) {
27034 +                               if (!nx_v4_ifa_visible(nxi, ifa))
27035 +                                       continue;
27036                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
27037                                     sin_orig.sin_addr.s_addr ==
27038                                                         ifa->ifa_address) {
27039 @@ -679,9 +684,12 @@ int devinet_ioctl(struct net *net, unsig
27040                    comparing just the label */
27041                 if (!ifa) {
27042                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27043 -                            ifap = &ifa->ifa_next)
27044 +                            ifap = &ifa->ifa_next) {
27045 +                               if (!nx_v4_ifa_visible(nxi, ifa))
27046 +                                       continue;
27047                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
27048                                         break;
27049 +                       }
27050                 }
27051         }
27052  
27053 @@ -833,6 +841,8 @@ static int inet_gifconf(struct net_devic
27054                 goto out;
27055  
27056         for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
27057 +               if (!nx_v4_ifa_visible(current_nx_info(), ifa))
27058 +                       continue;
27059                 if (!buf) {
27060                         done += sizeof(ifr);
27061                         continue;
27062 @@ -1181,6 +1191,7 @@ static int inet_dump_ifaddr(struct sk_bu
27063         struct net_device *dev;
27064         struct in_device *in_dev;
27065         struct in_ifaddr *ifa;
27066 +       struct sock *sk = skb->sk;
27067         struct hlist_head *head;
27068         struct hlist_node *node;
27069  
27070 @@ -1203,6 +1214,8 @@ static int inet_dump_ifaddr(struct sk_bu
27071  
27072                         for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
27073                              ifa = ifa->ifa_next, ip_idx++) {
27074 +                       if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
27075 +                               continue;
27076                                 if (ip_idx < s_ip_idx)
27077                                         continue;
27078                                 if (inet_fill_ifaddr(skb, ifa,
27079 diff -NurpP --minimal linux-2.6.34/net/ipv4/fib_hash.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/fib_hash.c
27080 --- linux-2.6.34/net/ipv4/fib_hash.c    2010-05-18 15:07:53.000000000 +0200
27081 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/fib_hash.c       2010-05-18 18:11:22.000000000 +0200
27082 @@ -1017,7 +1017,7 @@ static int fib_seq_show(struct seq_file 
27083         prefix  = f->fn_key;
27084         mask    = FZ_MASK(iter->zone);
27085         flags   = fib_flag_trans(fa->fa_type, mask, fi);
27086 -       if (fi)
27087 +       if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
27088                 seq_printf(seq,
27089                          "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
27090                          fi->fib_dev ? fi->fib_dev->name : "*", prefix,
27091 diff -NurpP --minimal linux-2.6.34/net/ipv4/inet_connection_sock.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/inet_connection_sock.c
27092 --- linux-2.6.34/net/ipv4/inet_connection_sock.c        2010-05-18 15:07:53.000000000 +0200
27093 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/inet_connection_sock.c   2010-05-18 18:11:22.000000000 +0200
27094 @@ -49,10 +49,40 @@ void inet_get_local_port_range(int *low,
27095  }
27096  EXPORT_SYMBOL(inet_get_local_port_range);
27097  
27098 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27099 +{
27100 +       __be32  sk1_rcv_saddr = inet_rcv_saddr(sk1),
27101 +               sk2_rcv_saddr = inet_rcv_saddr(sk2);
27102 +
27103 +       if (inet_v6_ipv6only(sk2))
27104 +               return 0;
27105 +
27106 +       if (sk1_rcv_saddr &&
27107 +           sk2_rcv_saddr &&
27108 +           sk1_rcv_saddr == sk2_rcv_saddr)
27109 +               return 1;
27110 +
27111 +       if (sk1_rcv_saddr &&
27112 +           !sk2_rcv_saddr &&
27113 +           v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
27114 +               return 1;
27115 +
27116 +       if (sk2_rcv_saddr &&
27117 +           !sk1_rcv_saddr &&
27118 +           v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
27119 +               return 1;
27120 +
27121 +       if (!sk1_rcv_saddr &&
27122 +           !sk2_rcv_saddr &&
27123 +           nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
27124 +               return 1;
27125 +
27126 +       return 0;
27127 +}
27128 +
27129  int inet_csk_bind_conflict(const struct sock *sk,
27130                            const struct inet_bind_bucket *tb)
27131  {
27132 -       const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27133         struct sock *sk2;
27134         struct hlist_node *node;
27135         int reuse = sk->sk_reuse;
27136 @@ -72,9 +102,7 @@ int inet_csk_bind_conflict(const struct 
27137                      sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27138                         if (!reuse || !sk2->sk_reuse ||
27139                             sk2->sk_state == TCP_LISTEN) {
27140 -                               const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27141 -                               if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27142 -                                   sk2_rcv_saddr == sk_rcv_saddr)
27143 +                               if (ipv4_rcv_saddr_equal(sk, sk2))
27144                                         break;
27145                         }
27146                 }
27147 diff -NurpP --minimal linux-2.6.34/net/ipv4/inet_diag.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/inet_diag.c
27148 --- linux-2.6.34/net/ipv4/inet_diag.c   2010-05-18 15:07:53.000000000 +0200
27149 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/inet_diag.c      2010-05-18 18:11:22.000000000 +0200
27150 @@ -33,6 +33,8 @@
27151  #include <linux/stddef.h>
27152  
27153  #include <linux/inet_diag.h>
27154 +#include <linux/vs_network.h>
27155 +#include <linux/vs_inet.h>
27156  
27157  static const struct inet_diag_handler **inet_diag_table;
27158  
27159 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
27160  
27161         r->id.idiag_sport = inet->inet_sport;
27162         r->id.idiag_dport = inet->inet_dport;
27163 -       r->id.idiag_src[0] = inet->inet_rcv_saddr;
27164 -       r->id.idiag_dst[0] = inet->inet_daddr;
27165 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
27166 +               inet->inet_rcv_saddr);
27167 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
27168 +               inet->inet_daddr);
27169  
27170  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27171         if (r->idiag_family == AF_INET6) {
27172 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
27173         r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
27174         r->id.idiag_sport     = tw->tw_sport;
27175         r->id.idiag_dport     = tw->tw_dport;
27176 -       r->id.idiag_src[0]    = tw->tw_rcv_saddr;
27177 -       r->id.idiag_dst[0]    = tw->tw_daddr;
27178 +       r->id.idiag_src[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
27179 +       r->id.idiag_dst[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
27180         r->idiag_state        = tw->tw_substate;
27181         r->idiag_timer        = 3;
27182         r->idiag_expires      = DIV_ROUND_UP(tmo * 1000, HZ);
27183 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
27184         err = -EINVAL;
27185  
27186         if (req->idiag_family == AF_INET) {
27187 +               /* TODO: lback */
27188                 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
27189                                  req->id.idiag_dport, req->id.idiag_src[0],
27190                                  req->id.idiag_sport, req->id.idiag_if);
27191 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
27192                 } else
27193  #endif
27194                 {
27195 +                       /* TODO: lback */
27196                         entry.saddr = &inet->inet_rcv_saddr;
27197                         entry.daddr = &inet->inet_daddr;
27198                 }
27199 @@ -541,6 +547,7 @@ static int inet_twsk_diag_dump(struct in
27200                 } else
27201  #endif
27202                 {
27203 +                       /* TODO: lback */
27204                         entry.saddr = &tw->tw_rcv_saddr;
27205                         entry.daddr = &tw->tw_daddr;
27206                 }
27207 @@ -587,8 +594,8 @@ static int inet_diag_fill_req(struct sk_
27208  
27209         r->id.idiag_sport = inet->inet_sport;
27210         r->id.idiag_dport = ireq->rmt_port;
27211 -       r->id.idiag_src[0] = ireq->loc_addr;
27212 -       r->id.idiag_dst[0] = ireq->rmt_addr;
27213 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
27214 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
27215         r->idiag_expires = jiffies_to_msecs(tmo);
27216         r->idiag_rqueue = 0;
27217         r->idiag_wqueue = 0;
27218 @@ -658,6 +665,7 @@ static int inet_diag_dump_reqs(struct sk
27219                                 continue;
27220  
27221                         if (bc) {
27222 +                               /* TODO: lback */
27223                                 entry.saddr =
27224  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27225                                         (entry.family == AF_INET6) ?
27226 @@ -728,6 +736,8 @@ static int inet_diag_dump(struct sk_buff
27227                         sk_nulls_for_each(sk, node, &ilb->head) {
27228                                 struct inet_sock *inet = inet_sk(sk);
27229  
27230 +                               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27231 +                                       continue;
27232                                 if (num < s_num) {
27233                                         num++;
27234                                         continue;
27235 @@ -794,6 +804,8 @@ skip_listen_ht:
27236                 sk_nulls_for_each(sk, node, &head->chain) {
27237                         struct inet_sock *inet = inet_sk(sk);
27238  
27239 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27240 +                               continue;
27241                         if (num < s_num)
27242                                 goto next_normal;
27243                         if (!(r->idiag_states & (1 << sk->sk_state)))
27244 @@ -818,6 +830,8 @@ next_normal:
27245                         inet_twsk_for_each(tw, node,
27246                                     &head->twchain) {
27247  
27248 +                               if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27249 +                                       continue;
27250                                 if (num < s_num)
27251                                         goto next_dying;
27252                                 if (r->id.idiag_sport != tw->tw_sport &&
27253 diff -NurpP --minimal linux-2.6.34/net/ipv4/inet_hashtables.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/inet_hashtables.c
27254 --- linux-2.6.34/net/ipv4/inet_hashtables.c     2010-02-25 11:52:10.000000000 +0100
27255 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/inet_hashtables.c        2010-05-18 18:11:22.000000000 +0200
27256 @@ -21,6 +21,7 @@
27257  
27258  #include <net/inet_connection_sock.h>
27259  #include <net/inet_hashtables.h>
27260 +#include <net/route.h>
27261  #include <net/ip.h>
27262  
27263  /*
27264 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
27265                         if (rcv_saddr != daddr)
27266                                 return -1;
27267                         score += 2;
27268 +               } else {
27269 +                       /* block non nx_info ips */
27270 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
27271 +                               daddr, NXA_MASK_BIND))
27272 +                               return -1;
27273                 }
27274                 if (sk->sk_bound_dev_if) {
27275                         if (sk->sk_bound_dev_if != dif)
27276 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
27277   * wildcarded during the search since they can never be otherwise.
27278   */
27279  
27280 -
27281  struct sock *__inet_lookup_listener(struct net *net,
27282                                     struct inet_hashinfo *hashinfo,
27283                                     const __be32 daddr, const unsigned short hnum,
27284 @@ -174,6 +179,7 @@ begin:
27285                         hiscore = score;
27286                 }
27287         }
27288 +
27289         /*
27290          * if the nulls value we got at the end of this lookup is
27291          * not the expected one, we must restart lookup.
27292 diff -NurpP --minimal linux-2.6.34/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/netfilter/nf_nat_helper.c
27293 --- linux-2.6.34/net/ipv4/netfilter/nf_nat_helper.c     2010-05-18 15:07:53.000000000 +0200
27294 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/netfilter/nf_nat_helper.c        2010-05-18 18:11:22.000000000 +0200
27295 @@ -20,6 +20,7 @@
27296  #include <net/route.h>
27297  
27298  #include <linux/netfilter_ipv4.h>
27299 +#include <net/route.h>
27300  #include <net/netfilter/nf_conntrack.h>
27301  #include <net/netfilter/nf_conntrack_helper.h>
27302  #include <net/netfilter/nf_conntrack_ecache.h>
27303 diff -NurpP --minimal linux-2.6.34/net/ipv4/netfilter.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/netfilter.c
27304 --- linux-2.6.34/net/ipv4/netfilter.c   2010-05-18 15:07:53.000000000 +0200
27305 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/netfilter.c      2010-05-18 18:11:22.000000000 +0200
27306 @@ -5,7 +5,7 @@
27307  #include <linux/ip.h>
27308  #include <linux/skbuff.h>
27309  #include <linux/gfp.h>
27310 -#include <net/route.h>
27311 +// #include <net/route.h>
27312  #include <net/xfrm.h>
27313  #include <net/ip.h>
27314  #include <net/netfilter/nf_queue.h>
27315 diff -NurpP --minimal linux-2.6.34/net/ipv4/raw.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/raw.c
27316 --- linux-2.6.34/net/ipv4/raw.c 2010-05-18 15:07:53.000000000 +0200
27317 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/raw.c    2010-05-18 18:11:22.000000000 +0200
27318 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
27319  
27320                 if (net_eq(sock_net(sk), net) && inet->inet_num == num  &&
27321                     !(inet->inet_daddr && inet->inet_daddr != raddr)    &&
27322 -                   !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
27323 +                   v4_sock_addr_match(sk->sk_nx_info, inet, laddr)     &&
27324                     !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27325                         goto found; /* gotcha */
27326         }
27327 @@ -381,6 +381,12 @@ static int raw_send_hdrinc(struct sock *
27328                 icmp_out_count(net, ((struct icmphdr *)
27329                         skb_transport_header(skb))->type);
27330  
27331 +       err = -EPERM;
27332 +       if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27333 +               sk->sk_nx_info &&
27334 +               !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27335 +               goto error_free;
27336 +
27337         err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
27338                       dst_output);
27339         if (err > 0)
27340 @@ -561,6 +567,13 @@ static int raw_sendmsg(struct kiocb *ioc
27341                 }
27342  
27343                 security_sk_classify_flow(sk, &fl);
27344 +               if (sk->sk_nx_info) {
27345 +                       err = ip_v4_find_src(sock_net(sk),
27346 +                               sk->sk_nx_info, &rt, &fl);
27347 +
27348 +                       if (err)
27349 +                               goto done;
27350 +               }
27351                 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
27352         }
27353         if (err)
27354 @@ -633,17 +646,19 @@ static int raw_bind(struct sock *sk, str
27355  {
27356         struct inet_sock *inet = inet_sk(sk);
27357         struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27358 +       struct nx_v4_sock_addr nsa = { 0 };
27359         int ret = -EINVAL;
27360         int chk_addr_ret;
27361  
27362         if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27363                 goto out;
27364 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27365 +       v4_map_sock_addr(inet, addr, &nsa);
27366 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27367         ret = -EADDRNOTAVAIL;
27368 -       if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27369 +       if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27370             chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27371                 goto out;
27372 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
27373 +       v4_set_sock_addr(inet, &nsa);
27374         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27375                 inet->inet_saddr = 0;  /* Use device */
27376         sk_dst_reset(sk);
27377 @@ -695,7 +710,8 @@ static int raw_recvmsg(struct kiocb *ioc
27378         /* Copy the address. */
27379         if (sin) {
27380                 sin->sin_family = AF_INET;
27381 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27382 +               sin->sin_addr.s_addr =
27383 +                       nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27384                 sin->sin_port = 0;
27385                 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27386         }
27387 @@ -873,7 +889,8 @@ static struct sock *raw_get_first(struct
27388                 struct hlist_node *node;
27389  
27390                 sk_for_each(sk, node, &state->h->ht[state->bucket])
27391 -                       if (sock_net(sk) == seq_file_net(seq))
27392 +                       if ((sock_net(sk) == seq_file_net(seq)) &&
27393 +                               nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27394                                 goto found;
27395         }
27396         sk = NULL;
27397 @@ -889,7 +906,8 @@ static struct sock *raw_get_next(struct 
27398                 sk = sk_next(sk);
27399  try_again:
27400                 ;
27401 -       } while (sk && sock_net(sk) != seq_file_net(seq));
27402 +       } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27403 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27404  
27405         if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27406                 sk = sk_head(&state->h->ht[state->bucket]);
27407 @@ -948,7 +966,10 @@ static void raw_sock_seq_show(struct seq
27408  
27409         seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
27410                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
27411 -               i, src, srcp, dest, destp, sp->sk_state,
27412 +               i,
27413 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27414 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27415 +               sp->sk_state,
27416                 sk_wmem_alloc_get(sp),
27417                 sk_rmem_alloc_get(sp),
27418                 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27419 diff -NurpP --minimal linux-2.6.34/net/ipv4/tcp.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/tcp.c
27420 --- linux-2.6.34/net/ipv4/tcp.c 2010-05-18 15:07:53.000000000 +0200
27421 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/tcp.c    2010-05-18 18:11:22.000000000 +0200
27422 @@ -266,6 +266,7 @@
27423  #include <linux/crypto.h>
27424  #include <linux/time.h>
27425  #include <linux/slab.h>
27426 +#include <linux/in.h>
27427  
27428  #include <net/icmp.h>
27429  #include <net/tcp.h>
27430 diff -NurpP --minimal linux-2.6.34/net/ipv4/tcp_ipv4.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/tcp_ipv4.c
27431 --- linux-2.6.34/net/ipv4/tcp_ipv4.c    2010-05-18 15:07:53.000000000 +0200
27432 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/tcp_ipv4.c       2010-05-18 18:11:22.000000000 +0200
27433 @@ -2004,6 +2004,12 @@ static void *listening_get_next(struct s
27434                 req = req->dl_next;
27435                 while (1) {
27436                         while (req) {
27437 +                               vxdprintk(VXD_CBIT(net, 6),
27438 +                                       "sk,req: %p [#%d] (from %d)", req->sk,
27439 +                                       (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27440 +                               if (req->sk &&
27441 +                                       !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27442 +                                       continue;
27443                                 if (req->rsk_ops->family == st->family) {
27444                                         cur = req;
27445                                         goto out;
27446 @@ -2028,6 +2034,10 @@ get_req:
27447         }
27448  get_sk:
27449         sk_nulls_for_each_from(sk, node) {
27450 +               vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27451 +                       sk, sk->sk_nid, nx_current_nid());
27452 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27453 +                       continue;
27454                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
27455                         cur = sk;
27456                         goto out;
27457 @@ -2091,6 +2101,11 @@ static void *established_get_first(struc
27458  
27459                 spin_lock_bh(lock);
27460                 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27461 +                       vxdprintk(VXD_CBIT(net, 6),
27462 +                               "sk,egf: %p [#%d] (from %d)",
27463 +                               sk, sk->sk_nid, nx_current_nid());
27464 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27465 +                               continue;
27466                         if (sk->sk_family != st->family ||
27467                             !net_eq(sock_net(sk), net)) {
27468                                 continue;
27469 @@ -2101,6 +2116,11 @@ static void *established_get_first(struc
27470                 st->state = TCP_SEQ_STATE_TIME_WAIT;
27471                 inet_twsk_for_each(tw, node,
27472                                    &tcp_hashinfo.ehash[st->bucket].twchain) {
27473 +                       vxdprintk(VXD_CBIT(net, 6),
27474 +                               "tw: %p [#%d] (from %d)",
27475 +                               tw, tw->tw_nid, nx_current_nid());
27476 +                       if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27477 +                               continue;
27478                         if (tw->tw_family != st->family ||
27479                             !net_eq(twsk_net(tw), net)) {
27480                                 continue;
27481 @@ -2129,7 +2149,9 @@ static void *established_get_next(struct
27482                 tw = cur;
27483                 tw = tw_next(tw);
27484  get_tw:
27485 -               while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27486 +               while (tw && (tw->tw_family != st->family ||
27487 +                       !net_eq(twsk_net(tw), net) ||
27488 +                       !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27489                         tw = tw_next(tw);
27490                 }
27491                 if (tw) {
27492 @@ -2152,6 +2174,11 @@ get_tw:
27493                 sk = sk_nulls_next(sk);
27494  
27495         sk_nulls_for_each_from(sk, node) {
27496 +               vxdprintk(VXD_CBIT(net, 6),
27497 +                       "sk,egn: %p [#%d] (from %d)",
27498 +                       sk, sk->sk_nid, nx_current_nid());
27499 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27500 +                       continue;
27501                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27502                         goto found;
27503         }
27504 @@ -2303,9 +2330,9 @@ static void get_openreq4(struct sock *sk
27505         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27506                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
27507                 i,
27508 -               ireq->loc_addr,
27509 +               nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27510                 ntohs(inet_sk(sk)->inet_sport),
27511 -               ireq->rmt_addr,
27512 +               nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27513                 ntohs(ireq->rmt_port),
27514                 TCP_SYN_RECV,
27515                 0, 0, /* could print option size, but that is af dependent. */
27516 @@ -2357,7 +2384,10 @@ static void get_tcp4_sock(struct sock *s
27517  
27518         seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
27519                         "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
27520 -               i, src, srcp, dest, destp, sk->sk_state,
27521 +               i,
27522 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27523 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27524 +               sk->sk_state,
27525                 tp->write_seq - tp->snd_una,
27526                 rx_queue,
27527                 timer_active,
27528 @@ -2392,7 +2422,10 @@ static void get_timewait4_sock(struct in
27529  
27530         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27531                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
27532 -               i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
27533 +               i,
27534 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27535 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27536 +               tw->tw_substate, 0, 0,
27537                 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
27538                 atomic_read(&tw->tw_refcnt), tw, len);
27539  }
27540 diff -NurpP --minimal linux-2.6.34/net/ipv4/tcp_minisocks.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/tcp_minisocks.c
27541 --- linux-2.6.34/net/ipv4/tcp_minisocks.c       2010-05-18 15:07:53.000000000 +0200
27542 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/tcp_minisocks.c  2010-05-18 18:11:22.000000000 +0200
27543 @@ -23,6 +23,9 @@
27544  #include <linux/slab.h>
27545  #include <linux/sysctl.h>
27546  #include <linux/workqueue.h>
27547 +#include <linux/vs_limit.h>
27548 +#include <linux/vs_socket.h>
27549 +#include <linux/vs_context.h>
27550  #include <net/tcp.h>
27551  #include <net/inet_common.h>
27552  #include <net/xfrm.h>
27553 @@ -290,6 +293,11 @@ void tcp_time_wait(struct sock *sk, int 
27554                 tcptw->tw_ts_recent     = tp->rx_opt.ts_recent;
27555                 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27556  
27557 +               tw->tw_xid              = sk->sk_xid;
27558 +               tw->tw_vx_info          = NULL;
27559 +               tw->tw_nid              = sk->sk_nid;
27560 +               tw->tw_nx_info          = NULL;
27561 +
27562  #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27563                 if (tw->tw_family == PF_INET6) {
27564                         struct ipv6_pinfo *np = inet6_sk(sk);
27565 diff -NurpP --minimal linux-2.6.34/net/ipv4/udp.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/udp.c
27566 --- linux-2.6.34/net/ipv4/udp.c 2010-05-18 15:07:53.000000000 +0200
27567 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv4/udp.c    2010-05-18 18:11:22.000000000 +0200
27568 @@ -295,14 +295,7 @@ fail:
27569  }
27570  EXPORT_SYMBOL(udp_lib_get_port);
27571  
27572 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27573 -{
27574 -       struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27575 -
27576 -       return  (!ipv6_only_sock(sk2)  &&
27577 -                (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
27578 -                  inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
27579 -}
27580 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27581  
27582  static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
27583                                        unsigned int port)
27584 @@ -337,6 +330,11 @@ static inline int compute_score(struct s
27585                         if (inet->inet_rcv_saddr != daddr)
27586                                 return -1;
27587                         score += 2;
27588 +               } else {
27589 +                       /* block non nx_info ips */
27590 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
27591 +                               daddr, NXA_MASK_BIND))
27592 +                               return -1;
27593                 }
27594                 if (inet->inet_daddr) {
27595                         if (inet->inet_daddr != saddr)
27596 @@ -440,6 +438,7 @@ exact_match:
27597         return result;
27598  }
27599  
27600 +
27601  /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27602   * harder than this. -DaveM
27603   */
27604 @@ -485,6 +484,11 @@ begin:
27605         sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27606                 score = compute_score(sk, net, saddr, hnum, sport,
27607                                       daddr, dport, dif);
27608 +               /* FIXME: disabled?
27609 +               if (score == 9) {
27610 +                       result = sk;
27611 +                       break;
27612 +               } else */
27613                 if (score > badness) {
27614                         result = sk;
27615                         badness = score;
27616 @@ -498,6 +502,7 @@ begin:
27617         if (get_nulls_value(node) != slot)
27618                 goto begin;
27619  
27620 +
27621         if (result) {
27622                 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
27623                         result = NULL;
27624 @@ -507,6 +512,7 @@ begin:
27625                         goto begin;
27626                 }
27627         }
27628 +
27629         rcu_read_unlock();
27630         return result;
27631  }
27632 @@ -549,8 +555,7 @@ static inline struct sock *udp_v4_mcast_
27633                     udp_sk(s)->udp_port_hash != hnum ||
27634                     (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
27635                     (inet->inet_dport != rmt_port && inet->inet_dport) ||
27636 -                   (inet->inet_rcv_saddr &&
27637 -                    inet->inet_rcv_saddr != loc_addr) ||
27638 +                   !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27639                     ipv6_only_sock(s) ||
27640                     (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27641                         continue;
27642 @@ -899,8 +904,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
27643                                                { .sport = inet->inet_sport,
27644                                                  .dport = dport } } };
27645                 struct net *net = sock_net(sk);
27646 +               struct nx_info *nxi = sk->sk_nx_info;
27647  
27648                 security_sk_classify_flow(sk, &fl);
27649 +               err = ip_v4_find_src(net, nxi, &rt, &fl);
27650 +               if (err)
27651 +                       goto out;
27652 +
27653                 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
27654                 if (err) {
27655                         if (err == -ENETUNREACH)
27656 @@ -1180,7 +1190,8 @@ try_again:
27657         if (sin) {
27658                 sin->sin_family = AF_INET;
27659                 sin->sin_port = udp_hdr(skb)->source;
27660 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27661 +               sin->sin_addr.s_addr = nx_map_sock_lback(
27662 +                       skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27663                 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27664         }
27665         if (inet->cmsg_flags)
27666 @@ -1867,6 +1878,8 @@ static struct sock *udp_get_first(struct
27667                 sk_nulls_for_each(sk, node, &hslot->head) {
27668                         if (!net_eq(sock_net(sk), net))
27669                                 continue;
27670 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27671 +                               continue;
27672                         if (sk->sk_family == state->family)
27673                                 goto found;
27674                 }
27675 @@ -1884,7 +1897,9 @@ static struct sock *udp_get_next(struct 
27676  
27677         do {
27678                 sk = sk_nulls_next(sk);
27679 -       } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27680 +       } while (sk && (!net_eq(sock_net(sk), net) ||
27681 +               sk->sk_family != state->family ||
27682 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27683  
27684         if (!sk) {
27685                 if (state->bucket <= state->udp_table->mask)
27686 @@ -1991,7 +2006,10 @@ static void udp4_format_sock(struct sock
27687  
27688         seq_printf(f, "%5d: %08X:%04X %08X:%04X"
27689                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
27690 -               bucket, src, srcp, dest, destp, sp->sk_state,
27691 +               bucket,
27692 +               nx_map_sock_lback(current_nx_info(), src), srcp,
27693 +               nx_map_sock_lback(current_nx_info(), dest), destp,
27694 +               sp->sk_state,
27695                 sk_wmem_alloc_get(sp),
27696                 sk_rmem_alloc_get(sp),
27697                 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
27698 diff -NurpP --minimal linux-2.6.34/net/ipv6/addrconf.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/addrconf.c
27699 --- linux-2.6.34/net/ipv6/addrconf.c    2010-05-18 15:07:53.000000000 +0200
27700 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/addrconf.c       2010-05-18 18:11:22.000000000 +0200
27701 @@ -87,6 +87,8 @@
27702  
27703  #include <linux/proc_fs.h>
27704  #include <linux/seq_file.h>
27705 +#include <linux/vs_network.h>
27706 +#include <linux/vs_inet6.h>
27707  
27708  /* Set to 3 to get tracing... */
27709  #define ACONF_DEBUG 2
27710 @@ -1120,7 +1122,7 @@ out:
27711  
27712  int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27713                        const struct in6_addr *daddr, unsigned int prefs,
27714 -                      struct in6_addr *saddr)
27715 +                      struct in6_addr *saddr, struct nx_info *nxi)
27716  {
27717         struct ipv6_saddr_score scores[2],
27718                                 *score = &scores[0], *hiscore = &scores[1];
27719 @@ -1192,6 +1194,8 @@ int ipv6_dev_get_saddr(struct net *net, 
27720                                                dev->name);
27721                                 continue;
27722                         }
27723 +                       if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27724 +                               continue;
27725  
27726                         score->rule = -1;
27727                         bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27728 @@ -3037,7 +3041,10 @@ static void if6_seq_stop(struct seq_file
27729  static int if6_seq_show(struct seq_file *seq, void *v)
27730  {
27731         struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27732 -       seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27733 +
27734 +       if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27735 +           v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27736 +               seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27737                    &ifp->addr,
27738                    ifp->idev->dev->ifindex,
27739                    ifp->prefix_len,
27740 @@ -3532,6 +3539,11 @@ static int in6_dump_addrs(struct inet6_d
27741         struct ifacaddr6 *ifaca;
27742         int err = 1;
27743         int ip_idx = *p_ip_idx;
27744 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27745 +
27746 +       /* disable ipv6 on non v6 guests */
27747 +       if (nxi && !nx_info_has_v6(nxi))
27748 +               return skb->len;
27749  
27750         read_lock_bh(&idev->lock);
27751         switch (type) {
27752 @@ -3541,6 +3553,8 @@ static int in6_dump_addrs(struct inet6_d
27753                      ifa = ifa->if_next, ip_idx++) {
27754                         if (ip_idx < s_ip_idx)
27755                                 continue;
27756 +                               if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27757 +                                       continue;
27758                         err = inet6_fill_ifaddr(skb, ifa,
27759                                                 NETLINK_CB(cb->skb).pid,
27760                                                 cb->nlh->nlmsg_seq,
27761 @@ -3556,6 +3570,8 @@ static int in6_dump_addrs(struct inet6_d
27762                      ifmca = ifmca->next, ip_idx++) {
27763                         if (ip_idx < s_ip_idx)
27764                                 continue;
27765 +                               if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27766 +                                       continue;
27767                         err = inet6_fill_ifmcaddr(skb, ifmca,
27768                                                   NETLINK_CB(cb->skb).pid,
27769                                                   cb->nlh->nlmsg_seq,
27770 @@ -3571,6 +3587,8 @@ static int in6_dump_addrs(struct inet6_d
27771                      ifaca = ifaca->aca_next, ip_idx++) {
27772                         if (ip_idx < s_ip_idx)
27773                                 continue;
27774 +                               if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27775 +                                       continue;
27776                         err = inet6_fill_ifacaddr(skb, ifaca,
27777                                                   NETLINK_CB(cb->skb).pid,
27778                                                   cb->nlh->nlmsg_seq,
27779 @@ -3899,6 +3917,11 @@ static int inet6_dump_ifinfo(struct sk_b
27780         struct inet6_dev *idev;
27781         struct hlist_head *head;
27782         struct hlist_node *node;
27783 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27784 +
27785 +       /* FIXME: maybe disable ipv6 on non v6 guests?
27786 +       if (skb->sk && skb->sk->sk_vx_info)
27787 +               return skb->len; */
27788  
27789         s_h = cb->args[0];
27790         s_idx = cb->args[1];
27791 @@ -3910,6 +3933,8 @@ static int inet6_dump_ifinfo(struct sk_b
27792                 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
27793                         if (idx < s_idx)
27794                                 goto cont;
27795 +                       if (!v6_dev_in_nx_info(dev, nxi))
27796 +                               goto cont;
27797                         idev = __in6_dev_get(dev);
27798                         if (!idev)
27799                                 goto cont;
27800 diff -NurpP --minimal linux-2.6.34/net/ipv6/af_inet6.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/af_inet6.c
27801 --- linux-2.6.34/net/ipv6/af_inet6.c    2010-05-18 15:07:53.000000000 +0200
27802 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/af_inet6.c       2010-05-18 18:11:22.000000000 +0200
27803 @@ -42,6 +42,8 @@
27804  #include <linux/netdevice.h>
27805  #include <linux/icmpv6.h>
27806  #include <linux/netfilter_ipv6.h>
27807 +#include <linux/vs_inet.h>
27808 +#include <linux/vs_inet6.h>
27809  
27810  #include <net/ip.h>
27811  #include <net/ipv6.h>
27812 @@ -160,9 +162,12 @@ lookup_protocol:
27813         }
27814  
27815         err = -EPERM;
27816 +       if ((protocol == IPPROTO_ICMPV6) &&
27817 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
27818 +               goto override;
27819         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
27820                 goto out_rcu_unlock;
27821 -
27822 +override:
27823         sock->ops = answer->ops;
27824         answer_prot = answer->prot;
27825         answer_no_check = answer->no_check;
27826 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
27827         struct inet_sock *inet = inet_sk(sk);
27828         struct ipv6_pinfo *np = inet6_sk(sk);
27829         struct net *net = sock_net(sk);
27830 +       struct nx_v6_sock_addr nsa;
27831         __be32 v4addr = 0;
27832         unsigned short snum;
27833         int addr_type = 0;
27834 @@ -272,6 +278,11 @@ int inet6_bind(struct socket *sock, stru
27835  
27836         if (addr_len < SIN6_LEN_RFC2133)
27837                 return -EINVAL;
27838 +
27839 +       err = v6_map_sock_addr(inet, addr, &nsa);
27840 +       if (err)
27841 +               return err;
27842 +
27843         addr_type = ipv6_addr_type(&addr->sin6_addr);
27844         if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27845                 return -EINVAL;
27846 @@ -303,6 +314,7 @@ int inet6_bind(struct socket *sock, stru
27847                 /* Reproduce AF_INET checks to make the bindings consitant */
27848                 v4addr = addr->sin6_addr.s6_addr32[3];
27849                 chk_addr_ret = inet_addr_type(net, v4addr);
27850 +
27851                 if (!sysctl_ip_nonlocal_bind &&
27852                     !(inet->freebind || inet->transparent) &&
27853                     v4addr != htonl(INADDR_ANY) &&
27854 @@ -312,6 +324,10 @@ int inet6_bind(struct socket *sock, stru
27855                         err = -EADDRNOTAVAIL;
27856                         goto out;
27857                 }
27858 +               if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27859 +                       err = -EADDRNOTAVAIL;
27860 +                       goto out;
27861 +               }
27862         } else {
27863                 if (addr_type != IPV6_ADDR_ANY) {
27864                         struct net_device *dev = NULL;
27865 @@ -338,6 +354,11 @@ int inet6_bind(struct socket *sock, stru
27866                                 }
27867                         }
27868  
27869 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27870 +                               err = -EADDRNOTAVAIL;
27871 +                               goto out;
27872 +                       }
27873 +
27874                         /* ipv4 addr of the socket is invalid.  Only the
27875                          * unspecified and mapped address have a v4 equivalent.
27876                          */
27877 @@ -353,6 +374,9 @@ int inet6_bind(struct socket *sock, stru
27878                 }
27879         }
27880  
27881 +       /* what's that for? */
27882 +       v6_set_sock_addr(inet, &nsa);
27883 +
27884         inet->inet_rcv_saddr = v4addr;
27885         inet->inet_saddr = v4addr;
27886  
27887 @@ -451,9 +475,11 @@ int inet6_getname(struct socket *sock, s
27888                         return -ENOTCONN;
27889                 sin->sin6_port = inet->inet_dport;
27890                 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27891 +               /* FIXME: remap lback? */
27892                 if (np->sndflow)
27893                         sin->sin6_flowinfo = np->flow_label;
27894         } else {
27895 +               /* FIXME: remap lback? */
27896                 if (ipv6_addr_any(&np->rcv_saddr))
27897                         ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27898                 else
27899 diff -NurpP --minimal linux-2.6.34/net/ipv6/fib6_rules.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/fib6_rules.c
27900 --- linux-2.6.34/net/ipv6/fib6_rules.c  2010-05-18 15:07:53.000000000 +0200
27901 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/fib6_rules.c     2010-05-18 18:11:22.000000000 +0200
27902 @@ -89,7 +89,7 @@ static int fib6_rule_action(struct fib_r
27903                                                ip6_dst_idev(&rt->u.dst)->dev,
27904                                                &flp->fl6_dst,
27905                                                rt6_flags2srcprefs(flags),
27906 -                                              &saddr))
27907 +                                              &saddr, NULL))
27908                                 goto again;
27909                         if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27910                                                r->src.plen))
27911 diff -NurpP --minimal linux-2.6.34/net/ipv6/inet6_hashtables.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/inet6_hashtables.c
27912 --- linux-2.6.34/net/ipv6/inet6_hashtables.c    2010-02-25 11:52:10.000000000 +0100
27913 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/inet6_hashtables.c       2010-05-18 18:11:22.000000000 +0200
27914 @@ -16,6 +16,7 @@
27915  
27916  #include <linux/module.h>
27917  #include <linux/random.h>
27918 +#include <linux/vs_inet6.h>
27919  
27920  #include <net/inet_connection_sock.h>
27921  #include <net/inet_hashtables.h>
27922 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
27923         unsigned int slot = hash & hashinfo->ehash_mask;
27924         struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
27925  
27926 -
27927         rcu_read_lock();
27928  begin:
27929         sk_nulls_for_each_rcu(sk, node, &head->chain) {
27930 @@ -94,7 +94,7 @@ begin:
27931                                 sock_put(sk);
27932                                 goto begin;
27933                         }
27934 -               goto out;
27935 +                       goto out;
27936                 }
27937         }
27938         if (get_nulls_value(node) != slot)
27939 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
27940                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27941                                 return -1;
27942                         score++;
27943 +               } else {
27944 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27945 +                               return -1;
27946                 }
27947                 if (sk->sk_bound_dev_if) {
27948                         if (sk->sk_bound_dev_if != dif)
27949 diff -NurpP --minimal linux-2.6.34/net/ipv6/ip6_output.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/ip6_output.c
27950 --- linux-2.6.34/net/ipv6/ip6_output.c  2010-05-18 15:07:53.000000000 +0200
27951 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/ip6_output.c     2010-05-18 18:11:22.000000000 +0200
27952 @@ -937,7 +937,7 @@ static int ip6_dst_lookup_tail(struct so
27953                 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
27954                                          &fl->fl6_dst,
27955                                          sk ? inet6_sk(sk)->srcprefs : 0,
27956 -                                        &fl->fl6_src);
27957 +                                        &fl->fl6_src, sk->sk_nx_info);
27958                 if (err)
27959                         goto out_err_release;
27960         }
27961 diff -NurpP --minimal linux-2.6.34/net/ipv6/Kconfig linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/Kconfig
27962 --- linux-2.6.34/net/ipv6/Kconfig       2010-02-25 11:52:10.000000000 +0100
27963 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/Kconfig  2010-05-18 18:11:22.000000000 +0200
27964 @@ -4,8 +4,8 @@
27965  
27966  #   IPv6 as module will cause a CRASH if you try to unload it
27967  menuconfig IPV6
27968 -       tristate "The IPv6 protocol"
27969 -       default m
27970 +       bool "The IPv6 protocol"
27971 +       default n
27972         ---help---
27973           This is complemental support for the IP version 6.
27974           You will still be able to do traditional IPv4 networking as well.
27975 diff -NurpP --minimal linux-2.6.34/net/ipv6/ndisc.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/ndisc.c
27976 --- linux-2.6.34/net/ipv6/ndisc.c       2010-05-18 15:07:53.000000000 +0200
27977 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/ndisc.c  2010-05-18 18:11:22.000000000 +0200
27978 @@ -590,7 +590,7 @@ static void ndisc_send_na(struct net_dev
27979         } else {
27980                 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27981                                        inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27982 -                                      &tmpaddr))
27983 +                                      &tmpaddr, NULL /* FIXME: ? */ ))
27984                         return;
27985                 src_addr = &tmpaddr;
27986         }
27987 diff -NurpP --minimal linux-2.6.34/net/ipv6/raw.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/raw.c
27988 --- linux-2.6.34/net/ipv6/raw.c 2010-05-18 15:07:53.000000000 +0200
27989 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/raw.c    2010-05-18 18:11:22.000000000 +0200
27990 @@ -30,6 +30,7 @@
27991  #include <linux/icmpv6.h>
27992  #include <linux/netfilter.h>
27993  #include <linux/netfilter_ipv6.h>
27994 +#include <linux/vs_inet6.h>
27995  #include <linux/skbuff.h>
27996  #include <asm/uaccess.h>
27997  #include <asm/ioctls.h>
27998 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
27999                                 goto out_unlock;
28000                 }
28001  
28002 +               if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28003 +                       err = -EADDRNOTAVAIL;
28004 +                       if (dev)
28005 +                               dev_put(dev);
28006 +                       goto out;
28007 +               }
28008 +
28009                 /* ipv4 addr of the socket is invalid.  Only the
28010                  * unspecified and mapped address have a v4 equivalent.
28011                  */
28012 diff -NurpP --minimal linux-2.6.34/net/ipv6/route.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/route.c
28013 --- linux-2.6.34/net/ipv6/route.c       2010-05-18 15:07:53.000000000 +0200
28014 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/route.c  2010-05-18 18:11:22.000000000 +0200
28015 @@ -2257,7 +2257,8 @@ static int rt6_fill_node(struct net *net
28016                 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
28017                 struct in6_addr saddr_buf;
28018                 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
28019 -                                      dst, 0, &saddr_buf) == 0)
28020 +                       dst, 0, &saddr_buf,
28021 +                       (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
28022                         NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
28023         }
28024  
28025 diff -NurpP --minimal linux-2.6.34/net/ipv6/tcp_ipv6.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/tcp_ipv6.c
28026 --- linux-2.6.34/net/ipv6/tcp_ipv6.c    2010-05-18 15:07:53.000000000 +0200
28027 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/tcp_ipv6.c       2010-05-18 18:11:22.000000000 +0200
28028 @@ -69,6 +69,7 @@
28029  
28030  #include <linux/crypto.h>
28031  #include <linux/scatterlist.h>
28032 +#include <linux/vs_inet6.h>
28033  
28034  static void    tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
28035  static void    tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
28036 @@ -157,8 +158,15 @@ static int tcp_v6_connect(struct sock *s
28037          *      connect() to INADDR_ANY means loopback (BSD'ism).
28038          */
28039  
28040 -       if(ipv6_addr_any(&usin->sin6_addr))
28041 -               usin->sin6_addr.s6_addr[15] = 0x1;
28042 +       if(ipv6_addr_any(&usin->sin6_addr)) {
28043 +               struct nx_info *nxi =  sk->sk_nx_info;
28044 +
28045 +               if (nxi && nx_info_has_v6(nxi))
28046 +                       /* FIXME: remap lback? */
28047 +                       usin->sin6_addr = nxi->v6.ip;
28048 +               else
28049 +                       usin->sin6_addr.s6_addr[15] = 0x1;
28050 +       }
28051  
28052         addr_type = ipv6_addr_type(&usin->sin6_addr);
28053  
28054 diff -NurpP --minimal linux-2.6.34/net/ipv6/udp.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/udp.c
28055 --- linux-2.6.34/net/ipv6/udp.c 2010-05-18 15:07:53.000000000 +0200
28056 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/udp.c    2010-05-18 18:11:22.000000000 +0200
28057 @@ -48,13 +48,14 @@
28058  
28059  #include <linux/proc_fs.h>
28060  #include <linux/seq_file.h>
28061 +#include <linux/vs_inet6.h>
28062  #include "udp_impl.h"
28063  
28064  int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
28065  {
28066         const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
28067         const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
28068 -       __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28069 +       __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28070         __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28071         int sk_ipv6only = ipv6_only_sock(sk);
28072         int sk2_ipv6only = inet_v6_ipv6only(sk2);
28073 @@ -62,24 +63,49 @@ int ipv6_rcv_saddr_equal(const struct so
28074         int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
28075  
28076         /* if both are mapped, treat as IPv4 */
28077 -       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
28078 -               return (!sk2_ipv6only &&
28079 -                       (!sk1_rcv_saddr || !sk2_rcv_saddr ||
28080 -                         sk1_rcv_saddr == sk2_rcv_saddr));
28081 +       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
28082 +               if (!sk2_ipv6only &&
28083 +                       (!sk_rcv_saddr || !sk2_rcv_saddr ||
28084 +                         sk_rcv_saddr == sk2_rcv_saddr))
28085 +                       goto vs_v4;
28086 +               else
28087 +                       return 0;
28088 +       }
28089  
28090         if (addr_type2 == IPV6_ADDR_ANY &&
28091             !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
28092 -               return 1;
28093 +               goto vs;
28094  
28095         if (addr_type == IPV6_ADDR_ANY &&
28096             !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
28097 -               return 1;
28098 +               goto vs;
28099  
28100         if (sk2_rcv_saddr6 &&
28101             ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
28102 -               return 1;
28103 +               goto vs;
28104  
28105         return 0;
28106 +
28107 +vs_v4:
28108 +       if (!sk_rcv_saddr && !sk2_rcv_saddr)
28109 +               return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28110 +       if (!sk2_rcv_saddr)
28111 +               return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
28112 +       if (!sk_rcv_saddr)
28113 +               return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
28114 +       return 1;
28115 +vs:
28116 +       if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
28117 +               return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28118 +       else if (addr_type2 == IPV6_ADDR_ANY)
28119 +               return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
28120 +       else if (addr_type == IPV6_ADDR_ANY) {
28121 +               if (addr_type2 == IPV6_ADDR_MAPPED)
28122 +                       return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28123 +               else
28124 +                       return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
28125 +       }
28126 +       return 1;
28127  }
28128  
28129  static unsigned int udp6_portaddr_hash(struct net *net,
28130 @@ -134,6 +160,10 @@ static inline int compute_score(struct s
28131                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28132                                 return -1;
28133                         score++;
28134 +               } else {
28135 +                       /* block non nx_info ips */
28136 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28137 +                               return -1;
28138                 }
28139                 if (!ipv6_addr_any(&np->daddr)) {
28140                         if (!ipv6_addr_equal(&np->daddr, saddr))
28141 diff -NurpP --minimal linux-2.6.34/net/ipv6/xfrm6_policy.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/xfrm6_policy.c
28142 --- linux-2.6.34/net/ipv6/xfrm6_policy.c        2010-05-18 15:07:53.000000000 +0200
28143 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/ipv6/xfrm6_policy.c   2010-05-18 18:11:22.000000000 +0200
28144 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
28145         dev = ip6_dst_idev(dst)->dev;
28146         ipv6_dev_get_saddr(dev_net(dev), dev,
28147                            (struct in6_addr *)&daddr->a6, 0,
28148 -                          (struct in6_addr *)&saddr->a6);
28149 +                          (struct in6_addr *)&saddr->a6, NULL);
28150         dst_release(dst);
28151         return 0;
28152  }
28153 diff -NurpP --minimal linux-2.6.34/net/netlink/af_netlink.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/netlink/af_netlink.c
28154 --- linux-2.6.34/net/netlink/af_netlink.c       2010-05-18 15:07:53.000000000 +0200
28155 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/netlink/af_netlink.c  2010-05-18 18:11:22.000000000 +0200
28156 @@ -55,6 +55,9 @@
28157  #include <linux/types.h>
28158  #include <linux/audit.h>
28159  #include <linux/mutex.h>
28160 +#include <linux/vs_context.h>
28161 +#include <linux/vs_network.h>
28162 +#include <linux/vs_limit.h>
28163  
28164  #include <net/net_namespace.h>
28165  #include <net/sock.h>
28166 @@ -1919,6 +1922,8 @@ static struct sock *netlink_seq_socket_i
28167                         sk_for_each(s, node, &hash->table[j]) {
28168                                 if (sock_net(s) != seq_file_net(seq))
28169                                         continue;
28170 +                               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28171 +                                       continue;
28172                                 if (off == pos) {
28173                                         iter->link = i;
28174                                         iter->hash_idx = j;
28175 @@ -1953,7 +1958,8 @@ static void *netlink_seq_next(struct seq
28176         s = v;
28177         do {
28178                 s = sk_next(s);
28179 -       } while (s && sock_net(s) != seq_file_net(seq));
28180 +       } while (s && (sock_net(s) != seq_file_net(seq) ||
28181 +               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28182         if (s)
28183                 return s;
28184  
28185 @@ -1965,7 +1971,8 @@ static void *netlink_seq_next(struct seq
28186  
28187                 for (; j <= hash->mask; j++) {
28188                         s = sk_head(&hash->table[j]);
28189 -                       while (s && sock_net(s) != seq_file_net(seq))
28190 +                       while (s && (sock_net(s) != seq_file_net(seq) ||
28191 +                               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28192                                 s = sk_next(s);
28193                         if (s) {
28194                                 iter->link = i;
28195 diff -NurpP --minimal linux-2.6.34/net/sctp/ipv6.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/sctp/ipv6.c
28196 --- linux-2.6.34/net/sctp/ipv6.c        2010-05-18 15:07:53.000000000 +0200
28197 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/sctp/ipv6.c   2010-05-18 18:11:22.000000000 +0200
28198 @@ -317,7 +317,8 @@ static void sctp_v6_get_saddr(struct sct
28199                                    dst ? ip6_dst_idev(dst)->dev : NULL,
28200                                    &daddr->v6.sin6_addr,
28201                                    inet6_sk(&sk->inet.sk)->srcprefs,
28202 -                                  &saddr->v6.sin6_addr);
28203 +                                  &saddr->v6.sin6_addr,
28204 +                                  asoc->base.sk->sk_nx_info);
28205                 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
28206                                   &saddr->v6.sin6_addr);
28207                 return;
28208 diff -NurpP --minimal linux-2.6.34/net/socket.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/socket.c
28209 --- linux-2.6.34/net/socket.c   2010-05-18 15:07:53.000000000 +0200
28210 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/socket.c      2010-05-18 18:11:22.000000000 +0200
28211 @@ -97,6 +97,10 @@
28212  
28213  #include <net/sock.h>
28214  #include <linux/netfilter.h>
28215 +#include <linux/vs_base.h>
28216 +#include <linux/vs_socket.h>
28217 +#include <linux/vs_inet.h>
28218 +#include <linux/vs_inet6.h>
28219  
28220  #include <linux/if_tun.h>
28221  #include <linux/ipv6_route.h>
28222 @@ -540,7 +544,7 @@ static inline int __sock_sendmsg(struct 
28223                                  struct msghdr *msg, size_t size)
28224  {
28225         struct sock_iocb *si = kiocb_to_siocb(iocb);
28226 -       int err;
28227 +       int err, len;
28228  
28229         si->sock = sock;
28230         si->scm = NULL;
28231 @@ -551,7 +555,22 @@ static inline int __sock_sendmsg(struct 
28232         if (err)
28233                 return err;
28234  
28235 -       return sock->ops->sendmsg(iocb, sock, msg, size);
28236 +       len = sock->ops->sendmsg(iocb, sock, msg, size);
28237 +       if (sock->sk) {
28238 +               if (len == size)
28239 +                       vx_sock_send(sock->sk, size);
28240 +               else
28241 +                       vx_sock_fail(sock->sk, size);
28242 +       }
28243 +       vxdprintk(VXD_CBIT(net, 7),
28244 +               "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28245 +               sock, sock->sk,
28246 +               (sock->sk)?sock->sk->sk_nx_info:0,
28247 +               (sock->sk)?sock->sk->sk_vx_info:0,
28248 +               (sock->sk)?sock->sk->sk_xid:0,
28249 +               (sock->sk)?sock->sk->sk_nid:0,
28250 +               (unsigned int)size, len);
28251 +       return len;
28252  }
28253  
28254  int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
28255 @@ -668,6 +687,7 @@ static inline int __sock_recvmsg_nosec(s
28256                                        struct msghdr *msg, size_t size, int flags)
28257  {
28258         struct sock_iocb *si = kiocb_to_siocb(iocb);
28259 +       int len;
28260  
28261         si->sock = sock;
28262         si->scm = NULL;
28263 @@ -675,7 +695,18 @@ static inline int __sock_recvmsg_nosec(s
28264         si->size = size;
28265         si->flags = flags;
28266  
28267 -       return sock->ops->recvmsg(iocb, sock, msg, size, flags);
28268 +       len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
28269 +       if ((len >= 0) && sock->sk)
28270 +               vx_sock_recv(sock->sk, len);
28271 +       vxdprintk(VXD_CBIT(net, 7),
28272 +               "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28273 +               sock, sock->sk,
28274 +               (sock->sk)?sock->sk->sk_nx_info:0,
28275 +               (sock->sk)?sock->sk->sk_vx_info:0,
28276 +               (sock->sk)?sock->sk->sk_xid:0,
28277 +               (sock->sk)?sock->sk->sk_nid:0,
28278 +               (unsigned int)size, len);
28279 +       return len;
28280  }
28281  
28282  static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
28283 @@ -1183,6 +1214,13 @@ static int __sock_create(struct net *net
28284         if (type < 0 || type >= SOCK_MAX)
28285                 return -EINVAL;
28286  
28287 +       if (!nx_check(0, VS_ADMIN)) {
28288 +               if (family == PF_INET && !current_nx_info_has_v4())
28289 +                       return -EAFNOSUPPORT;
28290 +               if (family == PF_INET6 && !current_nx_info_has_v6())
28291 +                       return -EAFNOSUPPORT;
28292 +       }
28293 +
28294         /* Compatibility.
28295  
28296            This uglymoron is moved from INET layer to here to avoid
28297 @@ -1315,6 +1353,7 @@ SYSCALL_DEFINE3(socket, int, family, int
28298         if (retval < 0)
28299                 goto out;
28300  
28301 +       set_bit(SOCK_USER_SOCKET, &sock->flags);
28302         retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
28303         if (retval < 0)
28304                 goto out_release;
28305 @@ -1356,10 +1395,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
28306         err = sock_create(family, type, protocol, &sock1);
28307         if (err < 0)
28308                 goto out;
28309 +       set_bit(SOCK_USER_SOCKET, &sock1->flags);
28310  
28311         err = sock_create(family, type, protocol, &sock2);
28312         if (err < 0)
28313                 goto out_release_1;
28314 +       set_bit(SOCK_USER_SOCKET, &sock2->flags);
28315  
28316         err = sock1->ops->socketpair(sock1, sock2);
28317         if (err < 0)
28318 diff -NurpP --minimal linux-2.6.34/net/sunrpc/auth.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/sunrpc/auth.c
28319 --- linux-2.6.34/net/sunrpc/auth.c      2010-05-18 15:07:53.000000000 +0200
28320 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/sunrpc/auth.c 2010-05-18 18:11:22.000000000 +0200
28321 @@ -14,6 +14,7 @@
28322  #include <linux/hash.h>
28323  #include <linux/sunrpc/clnt.h>
28324  #include <linux/spinlock.h>
28325 +#include <linux/vs_tag.h>
28326  
28327  #ifdef RPC_DEBUG
28328  # define RPCDBG_FACILITY       RPCDBG_AUTH
28329 @@ -363,6 +364,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
28330         memset(&acred, 0, sizeof(acred));
28331         acred.uid = cred->fsuid;
28332         acred.gid = cred->fsgid;
28333 +       acred.tag = dx_current_tag();
28334         acred.group_info = get_group_info(((struct cred *)cred)->group_info);
28335  
28336         ret = auth->au_ops->lookup_cred(auth, &acred, flags);
28337 @@ -403,6 +405,7 @@ rpcauth_bind_root_cred(struct rpc_task *
28338         struct auth_cred acred = {
28339                 .uid = 0,
28340                 .gid = 0,
28341 +               .tag = dx_current_tag(),
28342         };
28343         struct rpc_cred *ret;
28344  
28345 diff -NurpP --minimal linux-2.6.34/net/sunrpc/auth_unix.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/sunrpc/auth_unix.c
28346 --- linux-2.6.34/net/sunrpc/auth_unix.c 2010-05-18 15:07:53.000000000 +0200
28347 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/sunrpc/auth_unix.c    2010-05-18 18:11:22.000000000 +0200
28348 @@ -12,12 +12,14 @@
28349  #include <linux/module.h>
28350  #include <linux/sunrpc/clnt.h>
28351  #include <linux/sunrpc/auth.h>
28352 +#include <linux/vs_tag.h>
28353  
28354  #define NFS_NGROUPS    16
28355  
28356  struct unx_cred {
28357         struct rpc_cred         uc_base;
28358         gid_t                   uc_gid;
28359 +       tag_t                   uc_tag;
28360         gid_t                   uc_gids[NFS_NGROUPS];
28361  };
28362  #define uc_uid                 uc_base.cr_uid
28363 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
28364                 groups = NFS_NGROUPS;
28365  
28366         cred->uc_gid = acred->gid;
28367 +       cred->uc_tag = acred->tag;
28368         for (i = 0; i < groups; i++)
28369                 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28370         if (i < NFS_NGROUPS)
28371 @@ -120,7 +123,9 @@ unx_match(struct auth_cred *acred, struc
28372         unsigned int i;
28373  
28374  
28375 -       if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28376 +       if (cred->uc_uid != acred->uid ||
28377 +               cred->uc_gid != acred->gid ||
28378 +               cred->uc_tag != acred->tag)
28379                 return 0;
28380  
28381         if (acred->group_info != NULL)
28382 @@ -143,7 +148,7 @@ unx_marshal(struct rpc_task *task, __be3
28383         struct rpc_clnt *clnt = task->tk_client;
28384         struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
28385         __be32          *base, *hold;
28386 -       int             i;
28387 +       int             i, tag;
28388  
28389         *p++ = htonl(RPC_AUTH_UNIX);
28390         base = p++;
28391 @@ -153,9 +158,12 @@ unx_marshal(struct rpc_task *task, __be3
28392          * Copy the UTS nodename captured when the client was created.
28393          */
28394         p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28395 +       tag = task->tk_client->cl_tag;
28396  
28397 -       *p++ = htonl((u32) cred->uc_uid);
28398 -       *p++ = htonl((u32) cred->uc_gid);
28399 +       *p++ = htonl((u32) TAGINO_UID(tag,
28400 +               cred->uc_uid, cred->uc_tag));
28401 +       *p++ = htonl((u32) TAGINO_GID(tag,
28402 +               cred->uc_gid, cred->uc_tag));
28403         hold = p++;
28404         for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28405                 *p++ = htonl((u32) cred->uc_gids[i]);
28406 diff -NurpP --minimal linux-2.6.34/net/sunrpc/clnt.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/sunrpc/clnt.c
28407 --- linux-2.6.34/net/sunrpc/clnt.c      2010-05-18 15:07:53.000000000 +0200
28408 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/sunrpc/clnt.c 2010-05-18 18:11:22.000000000 +0200
28409 @@ -33,6 +33,7 @@
28410  #include <linux/utsname.h>
28411  #include <linux/workqueue.h>
28412  #include <linux/in6.h>
28413 +#include <linux/vs_cvirt.h>
28414  
28415  #include <linux/sunrpc/clnt.h>
28416  #include <linux/sunrpc/rpc_pipe_fs.h>
28417 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28418         if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28419                 clnt->cl_chatty = 1;
28420  
28421 +       /* TODO: handle RPC_CLNT_CREATE_TAGGED
28422 +       if (args->flags & RPC_CLNT_CREATE_TAGGED)
28423 +               clnt->cl_tag = 1; */
28424         return clnt;
28425  }
28426  EXPORT_SYMBOL_GPL(rpc_create);
28427 diff -NurpP --minimal linux-2.6.34/net/unix/af_unix.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/unix/af_unix.c
28428 --- linux-2.6.34/net/unix/af_unix.c     2010-05-18 15:07:53.000000000 +0200
28429 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/unix/af_unix.c        2010-05-18 18:11:22.000000000 +0200
28430 @@ -114,6 +114,8 @@
28431  #include <linux/mount.h>
28432  #include <net/checksum.h>
28433  #include <linux/security.h>
28434 +#include <linux/vs_context.h>
28435 +#include <linux/vs_limit.h>
28436  
28437  static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28438  static DEFINE_SPINLOCK(unix_table_lock);
28439 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28440                 if (!net_eq(sock_net(s), net))
28441                         continue;
28442  
28443 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28444 +                       continue;
28445                 if (u->addr->len == len &&
28446                     !memcmp(u->addr->name, sunname, len))
28447                         goto found;
28448 @@ -2115,6 +2119,8 @@ static struct sock *unix_seq_idx(struct 
28449         for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28450                 if (sock_net(s) != seq_file_net(seq))
28451                         continue;
28452 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28453 +                       continue;
28454                 if (off == pos)
28455                         return s;
28456                 ++off;
28457 @@ -2139,7 +2145,8 @@ static void *unix_seq_next(struct seq_fi
28458                 sk = first_unix_socket(&iter->i);
28459         else
28460                 sk = next_unix_socket(&iter->i, sk);
28461 -       while (sk && (sock_net(sk) != seq_file_net(seq)))
28462 +       while (sk && (sock_net(sk) != seq_file_net(seq) ||
28463 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28464                 sk = next_unix_socket(&iter->i, sk);
28465         return sk;
28466  }
28467 diff -NurpP --minimal linux-2.6.34/net/x25/af_x25.c linux-2.6.34-vs2.3.0.36.30.4.pre6/net/x25/af_x25.c
28468 --- linux-2.6.34/net/x25/af_x25.c       2010-05-18 15:07:53.000000000 +0200
28469 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/net/x25/af_x25.c  2010-05-18 18:11:22.000000000 +0200
28470 @@ -569,7 +569,10 @@ static int x25_create(struct net *net, s
28471  
28472         x25 = x25_sk(sk);
28473  
28474 -       sock_init_data(sock, sk);
28475 +       sk->sk_socket = sock;
28476 +       sk->sk_type = sock->type;
28477 +       sk->sk_sleep = &sock->wait;
28478 +       sock->sk = sk;
28479  
28480         x25_init_timers(sk);
28481  
28482 diff -NurpP --minimal linux-2.6.34/scripts/checksyscalls.sh linux-2.6.34-vs2.3.0.36.30.4.pre6/scripts/checksyscalls.sh
28483 --- linux-2.6.34/scripts/checksyscalls.sh       2009-09-10 15:26:31.000000000 +0200
28484 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/scripts/checksyscalls.sh  2010-05-18 18:11:22.000000000 +0200
28485 @@ -194,7 +194,6 @@ cat << EOF
28486  #define __IGNORE_afs_syscall
28487  #define __IGNORE_getpmsg
28488  #define __IGNORE_putpmsg
28489 -#define __IGNORE_vserver
28490  EOF
28491  }
28492  
28493 diff -NurpP --minimal linux-2.6.34/security/commoncap.c linux-2.6.34-vs2.3.0.36.30.4.pre6/security/commoncap.c
28494 --- linux-2.6.34/security/commoncap.c   2010-05-18 15:07:53.000000000 +0200
28495 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/security/commoncap.c      2010-05-18 18:11:22.000000000 +0200
28496 @@ -28,6 +28,7 @@
28497  #include <linux/prctl.h>
28498  #include <linux/securebits.h>
28499  #include <linux/syslog.h>
28500 +#include <linux/vs_context.h>
28501  
28502  /*
28503   * If a non-root user executes a setuid-root binary in
28504 @@ -53,7 +54,7 @@ static void warn_setuid_and_fcaps_mixed(
28505  
28506  int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
28507  {
28508 -       NETLINK_CB(skb).eff_cap = current_cap();
28509 +       NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
28510         return 0;
28511  }
28512  
28513 @@ -63,6 +64,7 @@ int cap_netlink_recv(struct sk_buff *skb
28514                 return -EPERM;
28515         return 0;
28516  }
28517 +
28518  EXPORT_SYMBOL(cap_netlink_recv);
28519  
28520  /**
28521 @@ -83,7 +85,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
28522  int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
28523                 int audit)
28524  {
28525 -       return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
28526 +       struct vx_info *vxi = tsk->vx_info;
28527 +
28528 +#if 0
28529 +       printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
28530 +               vx_info_flags(vxi, VXF_STATE_SETUP, 0),
28531 +               cap_raised(tsk->cap_effective, cap),
28532 +               tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
28533 +#endif
28534 +
28535 +       /* special case SETUP */
28536 +       if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28537 +               /* FIXME: maybe use cred instead? */
28538 +               cap_raised(tsk->cred->cap_effective, cap))
28539 +               return 0;
28540 +
28541 +       return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
28542  }
28543  
28544  /**
28545 @@ -571,7 +588,7 @@ int cap_inode_setxattr(struct dentry *de
28546  
28547         if (!strncmp(name, XATTR_SECURITY_PREFIX,
28548                      sizeof(XATTR_SECURITY_PREFIX) - 1)  &&
28549 -           !capable(CAP_SYS_ADMIN))
28550 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28551                 return -EPERM;
28552         return 0;
28553  }
28554 @@ -597,7 +614,7 @@ int cap_inode_removexattr(struct dentry 
28555  
28556         if (!strncmp(name, XATTR_SECURITY_PREFIX,
28557                      sizeof(XATTR_SECURITY_PREFIX) - 1)  &&
28558 -           !capable(CAP_SYS_ADMIN))
28559 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28560                 return -EPERM;
28561         return 0;
28562  }
28563 @@ -899,7 +916,8 @@ int cap_syslog(int type, bool from_file)
28564         if (type != SYSLOG_ACTION_OPEN && from_file)
28565                 return 0;
28566         if ((type != SYSLOG_ACTION_READ_ALL &&
28567 -            type != SYSLOG_ACTION_SIZE_BUFFER) && !capable(CAP_SYS_ADMIN))
28568 +            type != SYSLOG_ACTION_SIZE_BUFFER) &&
28569 +               !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
28570                 return -EPERM;
28571         return 0;
28572  }
28573 @@ -951,3 +969,4 @@ int cap_file_mmap(struct file *file, uns
28574         }
28575         return ret;
28576  }
28577 +
28578 diff -NurpP --minimal linux-2.6.34/security/selinux/av_permissions.h linux-2.6.34-vs2.3.0.36.30.4.pre6/security/selinux/av_permissions.h
28579 --- linux-2.6.34/security/selinux/av_permissions.h      1970-01-01 01:00:00.000000000 +0100
28580 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/security/selinux/av_permissions.h 2010-05-18 18:11:22.000000000 +0200
28581 @@ -0,0 +1,827 @@
28582 +/* This file is automatically generated.  Do not edit. */
28583 +#ifndef _SELINUX_AV_PERMISSIONS_H_
28584 +#define _SELINUX_AV_PERMISSIONS_H_
28585 +
28586 +#define SECURITY__COMPUTE_AV                      0x00000001UL
28587 +#define SECURITY__COMPUTE_CREATE                  0x00000002UL
28588 +#define SECURITY__COMPUTE_MEMBER                  0x00000004UL
28589 +#define SECURITY__CHECK_CONTEXT                   0x00000008UL
28590 +#define SECURITY__LOAD_POLICY                     0x00000010UL
28591 +#define SECURITY__COMPUTE_RELABEL                 0x00000020UL
28592 +#define SECURITY__COMPUTE_USER                    0x00000040UL
28593 +#define SECURITY__SETENFORCE                      0x00000080UL
28594 +#define SECURITY__SETBOOL                         0x00000100UL
28595 +#define SECURITY__SETSECPARAM                     0x00000200UL
28596 +#define SECURITY__SETCHECKREQPROT                 0x00000400UL
28597 +#define PROCESS__FORK                             0x00000001UL
28598 +#define PROCESS__TRANSITION                       0x00000002UL
28599 +#define PROCESS__SIGCHLD                          0x00000004UL
28600 +#define PROCESS__SIGKILL                          0x00000008UL
28601 +#define PROCESS__SIGSTOP                          0x00000010UL
28602 +#define PROCESS__SIGNULL                          0x00000020UL
28603 +#define PROCESS__SIGNAL                           0x00000040UL
28604 +#define PROCESS__PTRACE                           0x00000080UL
28605 +#define PROCESS__GETSCHED                         0x00000100UL
28606 +#define PROCESS__SETSCHED                         0x00000200UL
28607 +#define PROCESS__GETSESSION                       0x00000400UL
28608 +#define PROCESS__GETPGID                          0x00000800UL
28609 +#define PROCESS__SETPGID                          0x00001000UL
28610 +#define PROCESS__GETCAP                           0x00002000UL
28611 +#define PROCESS__SETCAP                           0x00004000UL
28612 +#define PROCESS__SHARE                            0x00008000UL
28613 +#define PROCESS__GETATTR                          0x00010000UL
28614 +#define PROCESS__SETEXEC                          0x00020000UL
28615 +#define PROCESS__SETFSCREATE                      0x00040000UL
28616 +#define PROCESS__NOATSECURE                       0x00080000UL
28617 +#define PROCESS__SIGINH                           0x00100000UL
28618 +#define PROCESS__SETRLIMIT                        0x00200000UL
28619 +#define PROCESS__RLIMITINH                        0x00400000UL
28620 +#define PROCESS__DYNTRANSITION                    0x00800000UL
28621 +#define PROCESS__SETCURRENT                       0x01000000UL
28622 +#define PROCESS__EXECMEM                          0x02000000UL
28623 +#define PROCESS__EXECSTACK                        0x04000000UL
28624 +#define PROCESS__EXECHEAP                         0x08000000UL
28625 +#define PROCESS__SETKEYCREATE                     0x10000000UL
28626 +#define PROCESS__SETSOCKCREATE                    0x20000000UL
28627 +#define SYSTEM__IPC_INFO                          0x00000001UL
28628 +#define SYSTEM__SYSLOG_READ                       0x00000002UL
28629 +#define SYSTEM__SYSLOG_MOD                        0x00000004UL
28630 +#define SYSTEM__SYSLOG_CONSOLE                    0x00000008UL
28631 +#define SYSTEM__MODULE_REQUEST                    0x00000010UL
28632 +#define CAPABILITY__CHOWN                         0x00000001UL
28633 +#define CAPABILITY__DAC_OVERRIDE                  0x00000002UL
28634 +#define CAPABILITY__DAC_READ_SEARCH               0x00000004UL
28635 +#define CAPABILITY__FOWNER                        0x00000008UL
28636 +#define CAPABILITY__FSETID                        0x00000010UL
28637 +#define CAPABILITY__KILL                          0x00000020UL
28638 +#define CAPABILITY__SETGID                        0x00000040UL
28639 +#define CAPABILITY__SETUID                        0x00000080UL
28640 +#define CAPABILITY__SETPCAP                       0x00000100UL
28641 +#define CAPABILITY__LINUX_IMMUTABLE               0x00000200UL
28642 +#define CAPABILITY__NET_BIND_SERVICE              0x00000400UL
28643 +#define CAPABILITY__NET_BROADCAST                 0x00000800UL
28644 +#define CAPABILITY__NET_ADMIN                     0x00001000UL
28645 +#define CAPABILITY__NET_RAW                       0x00002000UL
28646 +#define CAPABILITY__IPC_LOCK                      0x00004000UL
28647 +#define CAPABILITY__IPC_OWNER                     0x00008000UL
28648 +#define CAPABILITY__SYS_MODULE                    0x00010000UL
28649 +#define CAPABILITY__SYS_RAWIO                     0x00020000UL
28650 +#define CAPABILITY__SYS_CHROOT                    0x00040000UL
28651 +#define CAPABILITY__SYS_PTRACE                    0x00080000UL
28652 +#define CAPABILITY__SYS_PACCT                     0x00100000UL
28653 +#define CAPABILITY__SYS_ADMIN                     0x00200000UL
28654 +#define CAPABILITY__SYS_BOOT                      0x00400000UL
28655 +#define CAPABILITY__SYS_NICE                      0x00800000UL
28656 +#define CAPABILITY__SYS_RESOURCE                  0x01000000UL
28657 +#define CAPABILITY__SYS_TIME                      0x02000000UL
28658 +#define CAPABILITY__SYS_TTY_CONFIG                0x04000000UL
28659 +#define CAPABILITY__MKNOD                         0x08000000UL
28660 +#define CAPABILITY__LEASE                         0x10000000UL
28661 +#define CAPABILITY__AUDIT_WRITE                   0x20000000UL
28662 +#define CAPABILITY__AUDIT_CONTROL                 0x40000000UL
28663 +#define CAPABILITY__SETFCAP                       0x80000000UL
28664 +#define FILESYSTEM__MOUNT                         0x00000001UL
28665 +#define FILESYSTEM__REMOUNT                       0x00000002UL
28666 +#define FILESYSTEM__UNMOUNT                       0x00000004UL
28667 +#define FILESYSTEM__GETATTR                       0x00000008UL
28668 +#define FILESYSTEM__RELABELFROM                   0x00000010UL
28669 +#define FILESYSTEM__RELABELTO                     0x00000020UL
28670 +#define FILESYSTEM__TRANSITION                    0x00000040UL
28671 +#define FILESYSTEM__ASSOCIATE                     0x00000080UL
28672 +#define FILESYSTEM__QUOTAMOD                      0x00000100UL
28673 +#define FILESYSTEM__QUOTAGET                      0x00000200UL
28674 +#define FILE__IOCTL                               0x00000001UL
28675 +#define FILE__READ                                0x00000002UL
28676 +#define FILE__WRITE                               0x00000004UL
28677 +#define FILE__CREATE                              0x00000008UL
28678 +#define FILE__GETATTR                             0x00000010UL
28679 +#define FILE__SETATTR                             0x00000020UL
28680 +#define FILE__LOCK                                0x00000040UL
28681 +#define FILE__RELABELFROM                         0x00000080UL
28682 +#define FILE__RELABELTO                           0x00000100UL
28683 +#define FILE__APPEND                              0x00000200UL
28684 +#define FILE__UNLINK                              0x00000400UL
28685 +#define FILE__LINK                                0x00000800UL
28686 +#define FILE__RENAME                              0x00001000UL
28687 +#define FILE__EXECUTE                             0x00002000UL
28688 +#define FILE__SWAPON                              0x00004000UL
28689 +#define FILE__QUOTAON                             0x00008000UL
28690 +#define FILE__MOUNTON                             0x00010000UL
28691 +#define FILE__EXECUTE_NO_TRANS                    0x00020000UL
28692 +#define FILE__ENTRYPOINT                          0x00040000UL
28693 +#define FILE__EXECMOD                             0x00080000UL
28694 +#define FILE__OPEN                                0x00100000UL
28695 +#define DIR__IOCTL                                0x00000001UL
28696 +#define DIR__READ                                 0x00000002UL
28697 +#define DIR__WRITE                                0x00000004UL
28698 +#define DIR__CREATE                               0x00000008UL
28699 +#define DIR__GETATTR                              0x00000010UL
28700 +#define DIR__SETATTR                              0x00000020UL
28701 +#define DIR__LOCK                                 0x00000040UL
28702 +#define DIR__RELABELFROM                          0x00000080UL
28703 +#define DIR__RELABELTO                            0x00000100UL
28704 +#define DIR__APPEND                               0x00000200UL
28705 +#define DIR__UNLINK                               0x00000400UL
28706 +#define DIR__LINK                                 0x00000800UL
28707 +#define DIR__RENAME                               0x00001000UL
28708 +#define DIR__EXECUTE                              0x00002000UL
28709 +#define DIR__SWAPON                               0x00004000UL
28710 +#define DIR__QUOTAON                              0x00008000UL
28711 +#define DIR__MOUNTON                              0x00010000UL
28712 +#define DIR__ADD_NAME                             0x00020000UL
28713 +#define DIR__REMOVE_NAME                          0x00040000UL
28714 +#define DIR__REPARENT                             0x00080000UL
28715 +#define DIR__SEARCH                               0x00100000UL
28716 +#define DIR__RMDIR                                0x00200000UL
28717 +#define DIR__OPEN                                 0x00400000UL
28718 +#define FD__USE                                   0x00000001UL
28719 +#define LNK_FILE__IOCTL                           0x00000001UL
28720 +#define LNK_FILE__READ                            0x00000002UL
28721 +#define LNK_FILE__WRITE                           0x00000004UL
28722 +#define LNK_FILE__CREATE                          0x00000008UL
28723 +#define LNK_FILE__GETATTR                         0x00000010UL
28724 +#define LNK_FILE__SETATTR                         0x00000020UL
28725 +#define LNK_FILE__LOCK                            0x00000040UL
28726 +#define LNK_FILE__RELABELFROM                     0x00000080UL
28727 +#define LNK_FILE__RELABELTO                       0x00000100UL
28728 +#define LNK_FILE__APPEND                          0x00000200UL
28729 +#define LNK_FILE__UNLINK                          0x00000400UL
28730 +#define LNK_FILE__LINK                            0x00000800UL
28731 +#define LNK_FILE__RENAME                          0x00001000UL
28732 +#define LNK_FILE__EXECUTE                         0x00002000UL
28733 +#define LNK_FILE__SWAPON                          0x00004000UL
28734 +#define LNK_FILE__QUOTAON                         0x00008000UL
28735 +#define LNK_FILE__MOUNTON                         0x00010000UL
28736 +#define CHR_FILE__IOCTL                           0x00000001UL
28737 +#define CHR_FILE__READ                            0x00000002UL
28738 +#define CHR_FILE__WRITE                           0x00000004UL
28739 +#define CHR_FILE__CREATE                          0x00000008UL
28740 +#define CHR_FILE__GETATTR                         0x00000010UL
28741 +#define CHR_FILE__SETATTR                         0x00000020UL
28742 +#define CHR_FILE__LOCK                            0x00000040UL
28743 +#define CHR_FILE__RELABELFROM                     0x00000080UL
28744 +#define CHR_FILE__RELABELTO                       0x00000100UL
28745 +#define CHR_FILE__APPEND                          0x00000200UL
28746 +#define CHR_FILE__UNLINK                          0x00000400UL
28747 +#define CHR_FILE__LINK                            0x00000800UL
28748 +#define CHR_FILE__RENAME                          0x00001000UL
28749 +#define CHR_FILE__EXECUTE                         0x00002000UL
28750 +#define CHR_FILE__SWAPON                          0x00004000UL
28751 +#define CHR_FILE__QUOTAON                         0x00008000UL
28752 +#define CHR_FILE__MOUNTON                         0x00010000UL
28753 +#define CHR_FILE__EXECUTE_NO_TRANS                0x00020000UL
28754 +#define CHR_FILE__ENTRYPOINT                      0x00040000UL
28755 +#define CHR_FILE__EXECMOD                         0x00080000UL
28756 +#define CHR_FILE__OPEN                            0x00100000UL
28757 +#define BLK_FILE__IOCTL                           0x00000001UL
28758 +#define BLK_FILE__READ                            0x00000002UL
28759 +#define BLK_FILE__WRITE                           0x00000004UL
28760 +#define BLK_FILE__CREATE                          0x00000008UL
28761 +#define BLK_FILE__GETATTR                         0x00000010UL
28762 +#define BLK_FILE__SETATTR                         0x00000020UL
28763 +#define BLK_FILE__LOCK                            0x00000040UL
28764 +#define BLK_FILE__RELABELFROM                     0x00000080UL
28765 +#define BLK_FILE__RELABELTO                       0x00000100UL
28766 +#define BLK_FILE__APPEND                          0x00000200UL
28767 +#define BLK_FILE__UNLINK                          0x00000400UL
28768 +#define BLK_FILE__LINK                            0x00000800UL
28769 +#define BLK_FILE__RENAME                          0x00001000UL
28770 +#define BLK_FILE__EXECUTE                         0x00002000UL
28771 +#define BLK_FILE__SWAPON                          0x00004000UL
28772 +#define BLK_FILE__QUOTAON                         0x00008000UL
28773 +#define BLK_FILE__MOUNTON                         0x00010000UL
28774 +#define BLK_FILE__OPEN                            0x00020000UL
28775 +#define SOCK_FILE__IOCTL                          0x00000001UL
28776 +#define SOCK_FILE__READ                           0x00000002UL
28777 +#define SOCK_FILE__WRITE                          0x00000004UL
28778 +#define SOCK_FILE__CREATE                         0x00000008UL
28779 +#define SOCK_FILE__GETATTR                        0x00000010UL
28780 +#define SOCK_FILE__SETATTR                        0x00000020UL
28781 +#define SOCK_FILE__LOCK                           0x00000040UL
28782 +#define SOCK_FILE__RELABELFROM                    0x00000080UL
28783 +#define SOCK_FILE__RELABELTO                      0x00000100UL
28784 +#define SOCK_FILE__APPEND                         0x00000200UL
28785 +#define SOCK_FILE__UNLINK                         0x00000400UL
28786 +#define SOCK_FILE__LINK                           0x00000800UL
28787 +#define SOCK_FILE__RENAME                         0x00001000UL
28788 +#define SOCK_FILE__EXECUTE                        0x00002000UL
28789 +#define SOCK_FILE__SWAPON                         0x00004000UL
28790 +#define SOCK_FILE__QUOTAON                        0x00008000UL
28791 +#define SOCK_FILE__MOUNTON                        0x00010000UL
28792 +#define SOCK_FILE__OPEN                           0x00020000UL
28793 +#define FIFO_FILE__IOCTL                          0x00000001UL
28794 +#define FIFO_FILE__READ                           0x00000002UL
28795 +#define FIFO_FILE__WRITE                          0x00000004UL
28796 +#define FIFO_FILE__CREATE                         0x00000008UL
28797 +#define FIFO_FILE__GETATTR                        0x00000010UL
28798 +#define FIFO_FILE__SETATTR                        0x00000020UL
28799 +#define FIFO_FILE__LOCK                           0x00000040UL
28800 +#define FIFO_FILE__RELABELFROM                    0x00000080UL
28801 +#define FIFO_FILE__RELABELTO                      0x00000100UL
28802 +#define FIFO_FILE__APPEND                         0x00000200UL
28803 +#define FIFO_FILE__UNLINK                         0x00000400UL
28804 +#define FIFO_FILE__LINK                           0x00000800UL
28805 +#define FIFO_FILE__RENAME                         0x00001000UL
28806 +#define FIFO_FILE__EXECUTE                        0x00002000UL
28807 +#define FIFO_FILE__SWAPON                         0x00004000UL
28808 +#define FIFO_FILE__QUOTAON                        0x00008000UL
28809 +#define FIFO_FILE__MOUNTON                        0x00010000UL
28810 +#define FIFO_FILE__OPEN                           0x00020000UL
28811 +#define SOCKET__IOCTL                             0x00000001UL
28812 +#define SOCKET__READ                              0x00000002UL
28813 +#define SOCKET__WRITE                             0x00000004UL
28814 +#define SOCKET__CREATE                            0x00000008UL
28815 +#define SOCKET__GETATTR                           0x00000010UL
28816 +#define SOCKET__SETATTR                           0x00000020UL
28817 +#define SOCKET__LOCK                              0x00000040UL
28818 +#define SOCKET__RELABELFROM                       0x00000080UL
28819 +#define SOCKET__RELABELTO                         0x00000100UL
28820 +#define SOCKET__APPEND                            0x00000200UL
28821 +#define SOCKET__BIND                              0x00000400UL
28822 +#define SOCKET__CONNECT                           0x00000800UL
28823 +#define SOCKET__LISTEN                            0x00001000UL
28824 +#define SOCKET__ACCEPT                            0x00002000UL
28825 +#define SOCKET__GETOPT                            0x00004000UL
28826 +#define SOCKET__SETOPT                            0x00008000UL
28827 +#define SOCKET__SHUTDOWN                          0x00010000UL
28828 +#define SOCKET__RECVFROM                          0x00020000UL
28829 +#define SOCKET__SENDTO                            0x00040000UL
28830 +#define SOCKET__RECV_MSG                          0x00080000UL
28831 +#define SOCKET__SEND_MSG                          0x00100000UL
28832 +#define SOCKET__NAME_BIND                         0x00200000UL
28833 +#define TCP_SOCKET__IOCTL                         0x00000001UL
28834 +#define TCP_SOCKET__READ                          0x00000002UL
28835 +#define TCP_SOCKET__WRITE                         0x00000004UL
28836 +#define TCP_SOCKET__CREATE                        0x00000008UL
28837 +#define TCP_SOCKET__GETATTR                       0x00000010UL
28838 +#define TCP_SOCKET__SETATTR                       0x00000020UL
28839 +#define TCP_SOCKET__LOCK                          0x00000040UL
28840 +#define TCP_SOCKET__RELABELFROM                   0x00000080UL
28841 +#define TCP_SOCKET__RELABELTO                     0x00000100UL
28842 +#define TCP_SOCKET__APPEND                        0x00000200UL
28843 +#define TCP_SOCKET__BIND                          0x00000400UL
28844 +#define TCP_SOCKET__CONNECT                       0x00000800UL
28845 +#define TCP_SOCKET__LISTEN                        0x00001000UL
28846 +#define TCP_SOCKET__ACCEPT                        0x00002000UL
28847 +#define TCP_SOCKET__GETOPT                        0x00004000UL
28848 +#define TCP_SOCKET__SETOPT                        0x00008000UL
28849 +#define TCP_SOCKET__SHUTDOWN                      0x00010000UL
28850 +#define TCP_SOCKET__RECVFROM                      0x00020000UL
28851 +#define TCP_SOCKET__SENDTO                        0x00040000UL
28852 +#define TCP_SOCKET__RECV_MSG                      0x00080000UL
28853 +#define TCP_SOCKET__SEND_MSG                      0x00100000UL
28854 +#define TCP_SOCKET__NAME_BIND                     0x00200000UL
28855 +#define TCP_SOCKET__CONNECTTO                     0x00400000UL
28856 +#define TCP_SOCKET__NEWCONN                       0x00800000UL
28857 +#define TCP_SOCKET__ACCEPTFROM                    0x01000000UL
28858 +#define TCP_SOCKET__NODE_BIND                     0x02000000UL
28859 +#define TCP_SOCKET__NAME_CONNECT                  0x04000000UL
28860 +#define UDP_SOCKET__IOCTL                         0x00000001UL
28861 +#define UDP_SOCKET__READ                          0x00000002UL
28862 +#define UDP_SOCKET__WRITE                         0x00000004UL
28863 +#define UDP_SOCKET__CREATE                        0x00000008UL
28864 +#define UDP_SOCKET__GETATTR                       0x00000010UL
28865 +#define UDP_SOCKET__SETATTR                       0x00000020UL
28866 +#define UDP_SOCKET__LOCK                          0x00000040UL
28867 +#define UDP_SOCKET__RELABELFROM                   0x00000080UL
28868 +#define UDP_SOCKET__RELABELTO                     0x00000100UL
28869 +#define UDP_SOCKET__APPEND                        0x00000200UL
28870 +#define UDP_SOCKET__BIND                          0x00000400UL
28871 +#define UDP_SOCKET__CONNECT                       0x00000800UL
28872 +#define UDP_SOCKET__LISTEN                        0x00001000UL
28873 +#define UDP_SOCKET__ACCEPT                        0x00002000UL
28874 +#define UDP_SOCKET__GETOPT                        0x00004000UL
28875 +#define UDP_SOCKET__SETOPT                        0x00008000UL
28876 +#define UDP_SOCKET__SHUTDOWN                      0x00010000UL
28877 +#define UDP_SOCKET__RECVFROM                      0x00020000UL
28878 +#define UDP_SOCKET__SENDTO                        0x00040000UL
28879 +#define UDP_SOCKET__RECV_MSG                      0x00080000UL
28880 +#define UDP_SOCKET__SEND_MSG                      0x00100000UL
28881 +#define UDP_SOCKET__NAME_BIND                     0x00200000UL
28882 +#define UDP_SOCKET__NODE_BIND                     0x00400000UL
28883 +#define RAWIP_SOCKET__IOCTL                       0x00000001UL
28884 +#define RAWIP_SOCKET__READ                        0x00000002UL
28885 +#define RAWIP_SOCKET__WRITE                       0x00000004UL
28886 +#define RAWIP_SOCKET__CREATE                      0x00000008UL
28887 +#define RAWIP_SOCKET__GETATTR                     0x00000010UL
28888 +#define RAWIP_SOCKET__SETATTR                     0x00000020UL
28889 +#define RAWIP_SOCKET__LOCK                        0x00000040UL
28890 +#define RAWIP_SOCKET__RELABELFROM                 0x00000080UL
28891 +#define RAWIP_SOCKET__RELABELTO                   0x00000100UL
28892 +#define RAWIP_SOCKET__APPEND                      0x00000200UL
28893 +#define RAWIP_SOCKET__BIND                        0x00000400UL
28894 +#define RAWIP_SOCKET__CONNECT                     0x00000800UL
28895 +#define RAWIP_SOCKET__LISTEN                      0x00001000UL
28896 +#define RAWIP_SOCKET__ACCEPT                      0x00002000UL
28897 +#define RAWIP_SOCKET__GETOPT                      0x00004000UL
28898 +#define RAWIP_SOCKET__SETOPT                      0x00008000UL
28899 +#define RAWIP_SOCKET__SHUTDOWN                    0x00010000UL
28900 +#define RAWIP_SOCKET__RECVFROM                    0x00020000UL
28901 +#define RAWIP_SOCKET__SENDTO                      0x00040000UL
28902 +#define RAWIP_SOCKET__RECV_MSG                    0x00080000UL
28903 +#define RAWIP_SOCKET__SEND_MSG                    0x00100000UL
28904 +#define RAWIP_SOCKET__NAME_BIND                   0x00200000UL
28905 +#define RAWIP_SOCKET__NODE_BIND                   0x00400000UL
28906 +#define NODE__TCP_RECV                            0x00000001UL
28907 +#define NODE__TCP_SEND                            0x00000002UL
28908 +#define NODE__UDP_RECV                            0x00000004UL
28909 +#define NODE__UDP_SEND                            0x00000008UL
28910 +#define NODE__RAWIP_RECV                          0x00000010UL
28911 +#define NODE__RAWIP_SEND                          0x00000020UL
28912 +#define NODE__ENFORCE_DEST                        0x00000040UL
28913 +#define NODE__DCCP_RECV                           0x00000080UL
28914 +#define NODE__DCCP_SEND                           0x00000100UL
28915 +#define NODE__RECVFROM                            0x00000200UL
28916 +#define NODE__SENDTO                              0x00000400UL
28917 +#define NETIF__TCP_RECV                           0x00000001UL
28918 +#define NETIF__TCP_SEND                           0x00000002UL
28919 +#define NETIF__UDP_RECV                           0x00000004UL
28920 +#define NETIF__UDP_SEND                           0x00000008UL
28921 +#define NETIF__RAWIP_RECV                         0x00000010UL
28922 +#define NETIF__RAWIP_SEND                         0x00000020UL
28923 +#define NETIF__DCCP_RECV                          0x00000040UL
28924 +#define NETIF__DCCP_SEND                          0x00000080UL
28925 +#define NETIF__INGRESS                            0x00000100UL
28926 +#define NETIF__EGRESS                             0x00000200UL
28927 +#define NETLINK_SOCKET__IOCTL                     0x00000001UL
28928 +#define NETLINK_SOCKET__READ                      0x00000002UL
28929 +#define NETLINK_SOCKET__WRITE                     0x00000004UL
28930 +#define NETLINK_SOCKET__CREATE                    0x00000008UL
28931 +#define NETLINK_SOCKET__GETATTR                   0x00000010UL
28932 +#define NETLINK_SOCKET__SETATTR                   0x00000020UL
28933 +#define NETLINK_SOCKET__LOCK                      0x00000040UL
28934 +#define NETLINK_SOCKET__RELABELFROM               0x00000080UL
28935 +#define NETLINK_SOCKET__RELABELTO                 0x00000100UL
28936 +#define NETLINK_SOCKET__APPEND                    0x00000200UL
28937 +#define NETLINK_SOCKET__BIND                      0x00000400UL
28938 +#define NETLINK_SOCKET__CONNECT                   0x00000800UL
28939 +#define NETLINK_SOCKET__LISTEN                    0x00001000UL
28940 +#define NETLINK_SOCKET__ACCEPT                    0x00002000UL
28941 +#define NETLINK_SOCKET__GETOPT                    0x00004000UL
28942 +#define NETLINK_SOCKET__SETOPT                    0x00008000UL
28943 +#define NETLINK_SOCKET__SHUTDOWN                  0x00010000UL
28944 +#define NETLINK_SOCKET__RECVFROM                  0x00020000UL
28945 +#define NETLINK_SOCKET__SENDTO                    0x00040000UL
28946 +#define NETLINK_SOCKET__RECV_MSG                  0x00080000UL
28947 +#define NETLINK_SOCKET__SEND_MSG                  0x00100000UL
28948 +#define NETLINK_SOCKET__NAME_BIND                 0x00200000UL
28949 +#define PACKET_SOCKET__IOCTL                      0x00000001UL
28950 +#define PACKET_SOCKET__READ                       0x00000002UL
28951 +#define PACKET_SOCKET__WRITE                      0x00000004UL
28952 +#define PACKET_SOCKET__CREATE                     0x00000008UL
28953 +#define PACKET_SOCKET__GETATTR                    0x00000010UL
28954 +#define PACKET_SOCKET__SETATTR                    0x00000020UL
28955 +#define PACKET_SOCKET__LOCK                       0x00000040UL
28956 +#define PACKET_SOCKET__RELABELFROM                0x00000080UL
28957 +#define PACKET_SOCKET__RELABELTO                  0x00000100UL
28958 +#define PACKET_SOCKET__APPEND                     0x00000200UL
28959 +#define PACKET_SOCKET__BIND                       0x00000400UL
28960 +#define PACKET_SOCKET__CONNECT                    0x00000800UL
28961 +#define PACKET_SOCKET__LISTEN                     0x00001000UL
28962 +#define PACKET_SOCKET__ACCEPT                     0x00002000UL
28963 +#define PACKET_SOCKET__GETOPT                     0x00004000UL
28964 +#define PACKET_SOCKET__SETOPT                     0x00008000UL
28965 +#define PACKET_SOCKET__SHUTDOWN                   0x00010000UL
28966 +#define PACKET_SOCKET__RECVFROM                   0x00020000UL
28967 +#define PACKET_SOCKET__SENDTO                     0x00040000UL
28968 +#define PACKET_SOCKET__RECV_MSG                   0x00080000UL
28969 +#define PACKET_SOCKET__SEND_MSG                   0x00100000UL
28970 +#define PACKET_SOCKET__NAME_BIND                  0x00200000UL
28971 +#define KEY_SOCKET__IOCTL                         0x00000001UL
28972 +#define KEY_SOCKET__READ                          0x00000002UL
28973 +#define KEY_SOCKET__WRITE                         0x00000004UL
28974 +#define KEY_SOCKET__CREATE                        0x00000008UL
28975 +#define KEY_SOCKET__GETATTR                       0x00000010UL
28976 +#define KEY_SOCKET__SETATTR                       0x00000020UL
28977 +#define KEY_SOCKET__LOCK                          0x00000040UL
28978 +#define KEY_SOCKET__RELABELFROM                   0x00000080UL
28979 +#define KEY_SOCKET__RELABELTO                     0x00000100UL
28980 +#define KEY_SOCKET__APPEND                        0x00000200UL
28981 +#define KEY_SOCKET__BIND                          0x00000400UL
28982 +#define KEY_SOCKET__CONNECT                       0x00000800UL
28983 +#define KEY_SOCKET__LISTEN                        0x00001000UL
28984 +#define KEY_SOCKET__ACCEPT                        0x00002000UL
28985 +#define KEY_SOCKET__GETOPT                        0x00004000UL
28986 +#define KEY_SOCKET__SETOPT                        0x00008000UL
28987 +#define KEY_SOCKET__SHUTDOWN                      0x00010000UL
28988 +#define KEY_SOCKET__RECVFROM                      0x00020000UL
28989 +#define KEY_SOCKET__SENDTO                        0x00040000UL
28990 +#define KEY_SOCKET__RECV_MSG                      0x00080000UL
28991 +#define KEY_SOCKET__SEND_MSG                      0x00100000UL
28992 +#define KEY_SOCKET__NAME_BIND                     0x00200000UL
28993 +#define UNIX_STREAM_SOCKET__IOCTL                 0x00000001UL
28994 +#define UNIX_STREAM_SOCKET__READ                  0x00000002UL
28995 +#define UNIX_STREAM_SOCKET__WRITE                 0x00000004UL
28996 +#define UNIX_STREAM_SOCKET__CREATE                0x00000008UL
28997 +#define UNIX_STREAM_SOCKET__GETATTR               0x00000010UL
28998 +#define UNIX_STREAM_SOCKET__SETATTR               0x00000020UL
28999 +#define UNIX_STREAM_SOCKET__LOCK                  0x00000040UL
29000 +#define UNIX_STREAM_SOCKET__RELABELFROM           0x00000080UL
29001 +#define UNIX_STREAM_SOCKET__RELABELTO             0x00000100UL
29002 +#define UNIX_STREAM_SOCKET__APPEND                0x00000200UL
29003 +#define UNIX_STREAM_SOCKET__BIND                  0x00000400UL
29004 +#define UNIX_STREAM_SOCKET__CONNECT               0x00000800UL
29005 +#define UNIX_STREAM_SOCKET__LISTEN                0x00001000UL
29006 +#define UNIX_STREAM_SOCKET__ACCEPT                0x00002000UL
29007 +#define UNIX_STREAM_SOCKET__GETOPT                0x00004000UL
29008 +#define UNIX_STREAM_SOCKET__SETOPT                0x00008000UL
29009 +#define UNIX_STREAM_SOCKET__SHUTDOWN              0x00010000UL
29010 +#define UNIX_STREAM_SOCKET__RECVFROM              0x00020000UL
29011 +#define UNIX_STREAM_SOCKET__SENDTO                0x00040000UL
29012 +#define UNIX_STREAM_SOCKET__RECV_MSG              0x00080000UL
29013 +#define UNIX_STREAM_SOCKET__SEND_MSG              0x00100000UL
29014 +#define UNIX_STREAM_SOCKET__NAME_BIND             0x00200000UL
29015 +#define UNIX_STREAM_SOCKET__CONNECTTO             0x00400000UL
29016 +#define UNIX_STREAM_SOCKET__NEWCONN               0x00800000UL
29017 +#define UNIX_STREAM_SOCKET__ACCEPTFROM            0x01000000UL
29018 +#define UNIX_DGRAM_SOCKET__IOCTL                  0x00000001UL
29019 +#define UNIX_DGRAM_SOCKET__READ                   0x00000002UL
29020 +#define UNIX_DGRAM_SOCKET__WRITE                  0x00000004UL
29021 +#define UNIX_DGRAM_SOCKET__CREATE                 0x00000008UL
29022 +#define UNIX_DGRAM_SOCKET__GETATTR                0x00000010UL
29023 +#define UNIX_DGRAM_SOCKET__SETATTR                0x00000020UL
29024 +#define UNIX_DGRAM_SOCKET__LOCK                   0x00000040UL
29025 +#define UNIX_DGRAM_SOCKET__RELABELFROM            0x00000080UL
29026 +#define UNIX_DGRAM_SOCKET__RELABELTO              0x00000100UL
29027 +#define UNIX_DGRAM_SOCKET__APPEND                 0x00000200UL
29028 +#define UNIX_DGRAM_SOCKET__BIND                   0x00000400UL
29029 +#define UNIX_DGRAM_SOCKET__CONNECT                0x00000800UL
29030 +#define UNIX_DGRAM_SOCKET__LISTEN                 0x00001000UL
29031 +#define UNIX_DGRAM_SOCKET__ACCEPT                 0x00002000UL
29032 +#define UNIX_DGRAM_SOCKET__GETOPT                 0x00004000UL
29033 +#define UNIX_DGRAM_SOCKET__SETOPT                 0x00008000UL
29034 +#define UNIX_DGRAM_SOCKET__SHUTDOWN               0x00010000UL
29035 +#define UNIX_DGRAM_SOCKET__RECVFROM               0x00020000UL
29036 +#define UNIX_DGRAM_SOCKET__SENDTO                 0x00040000UL
29037 +#define UNIX_DGRAM_SOCKET__RECV_MSG               0x00080000UL
29038 +#define UNIX_DGRAM_SOCKET__SEND_MSG               0x00100000UL
29039 +#define UNIX_DGRAM_SOCKET__NAME_BIND              0x00200000UL
29040 +#define SEM__CREATE                               0x00000001UL
29041 +#define SEM__DESTROY                              0x00000002UL
29042 +#define SEM__GETATTR                              0x00000004UL
29043 +#define SEM__SETATTR                              0x00000008UL
29044 +#define SEM__READ                                 0x00000010UL
29045 +#define SEM__WRITE                                0x00000020UL
29046 +#define SEM__ASSOCIATE                            0x00000040UL
29047 +#define SEM__UNIX_READ                            0x00000080UL
29048 +#define SEM__UNIX_WRITE                           0x00000100UL
29049 +#define MSG__SEND                                 0x00000001UL
29050 +#define MSG__RECEIVE                              0x00000002UL
29051 +#define MSGQ__CREATE                              0x00000001UL
29052 +#define MSGQ__DESTROY                             0x00000002UL
29053 +#define MSGQ__GETATTR                             0x00000004UL
29054 +#define MSGQ__SETATTR                             0x00000008UL
29055 +#define MSGQ__READ                                0x00000010UL
29056 +#define MSGQ__WRITE                               0x00000020UL
29057 +#define MSGQ__ASSOCIATE                           0x00000040UL
29058 +#define MSGQ__UNIX_READ                           0x00000080UL
29059 +#define MSGQ__UNIX_WRITE                          0x00000100UL
29060 +#define MSGQ__ENQUEUE                             0x00000200UL
29061 +#define SHM__CREATE                               0x00000001UL
29062 +#define SHM__DESTROY                              0x00000002UL
29063 +#define SHM__GETATTR                              0x00000004UL
29064 +#define SHM__SETATTR                              0x00000008UL
29065 +#define SHM__READ                                 0x00000010UL
29066 +#define SHM__WRITE                                0x00000020UL
29067 +#define SHM__ASSOCIATE                            0x00000040UL
29068 +#define SHM__UNIX_READ                            0x00000080UL
29069 +#define SHM__UNIX_WRITE                           0x00000100UL
29070 +#define SHM__LOCK                                 0x00000200UL
29071 +#define IPC__CREATE                               0x00000001UL
29072 +#define IPC__DESTROY                              0x00000002UL
29073 +#define IPC__GETATTR                              0x00000004UL
29074 +#define IPC__SETATTR                              0x00000008UL
29075 +#define IPC__READ                                 0x00000010UL
29076 +#define IPC__WRITE                                0x00000020UL
29077 +#define IPC__ASSOCIATE                            0x00000040UL
29078 +#define IPC__UNIX_READ                            0x00000080UL
29079 +#define IPC__UNIX_WRITE                           0x00000100UL
29080 +#define NETLINK_ROUTE_SOCKET__IOCTL               0x00000001UL
29081 +#define NETLINK_ROUTE_SOCKET__READ                0x00000002UL
29082 +#define NETLINK_ROUTE_SOCKET__WRITE               0x00000004UL
29083 +#define NETLINK_ROUTE_SOCKET__CREATE              0x00000008UL
29084 +#define NETLINK_ROUTE_SOCKET__GETATTR             0x00000010UL
29085 +#define NETLINK_ROUTE_SOCKET__SETATTR             0x00000020UL
29086 +#define NETLINK_ROUTE_SOCKET__LOCK                0x00000040UL
29087 +#define NETLINK_ROUTE_SOCKET__RELABELFROM         0x00000080UL
29088 +#define NETLINK_ROUTE_SOCKET__RELABELTO           0x00000100UL
29089 +#define NETLINK_ROUTE_SOCKET__APPEND              0x00000200UL
29090 +#define NETLINK_ROUTE_SOCKET__BIND                0x00000400UL
29091 +#define NETLINK_ROUTE_SOCKET__CONNECT             0x00000800UL
29092 +#define NETLINK_ROUTE_SOCKET__LISTEN              0x00001000UL
29093 +#define NETLINK_ROUTE_SOCKET__ACCEPT              0x00002000UL
29094 +#define NETLINK_ROUTE_SOCKET__GETOPT              0x00004000UL
29095 +#define NETLINK_ROUTE_SOCKET__SETOPT              0x00008000UL
29096 +#define NETLINK_ROUTE_SOCKET__SHUTDOWN            0x00010000UL
29097 +#define NETLINK_ROUTE_SOCKET__RECVFROM            0x00020000UL
29098 +#define NETLINK_ROUTE_SOCKET__SENDTO              0x00040000UL
29099 +#define NETLINK_ROUTE_SOCKET__RECV_MSG            0x00080000UL
29100 +#define NETLINK_ROUTE_SOCKET__SEND_MSG            0x00100000UL
29101 +#define NETLINK_ROUTE_SOCKET__NAME_BIND           0x00200000UL
29102 +#define NETLINK_ROUTE_SOCKET__NLMSG_READ          0x00400000UL
29103 +#define NETLINK_ROUTE_SOCKET__NLMSG_WRITE         0x00800000UL
29104 +#define NETLINK_FIREWALL_SOCKET__IOCTL            0x00000001UL
29105 +#define NETLINK_FIREWALL_SOCKET__READ             0x00000002UL
29106 +#define NETLINK_FIREWALL_SOCKET__WRITE            0x00000004UL
29107 +#define NETLINK_FIREWALL_SOCKET__CREATE           0x00000008UL
29108 +#define NETLINK_FIREWALL_SOCKET__GETATTR          0x00000010UL
29109 +#define NETLINK_FIREWALL_SOCKET__SETATTR          0x00000020UL
29110 +#define NETLINK_FIREWALL_SOCKET__LOCK             0x00000040UL
29111 +#define NETLINK_FIREWALL_SOCKET__RELABELFROM      0x00000080UL
29112 +#define NETLINK_FIREWALL_SOCKET__RELABELTO        0x00000100UL
29113 +#define NETLINK_FIREWALL_SOCKET__APPEND           0x00000200UL
29114 +#define NETLINK_FIREWALL_SOCKET__BIND             0x00000400UL
29115 +#define NETLINK_FIREWALL_SOCKET__CONNECT          0x00000800UL
29116 +#define NETLINK_FIREWALL_SOCKET__LISTEN           0x00001000UL
29117 +#define NETLINK_FIREWALL_SOCKET__ACCEPT           0x00002000UL
29118 +#define NETLINK_FIREWALL_SOCKET__GETOPT           0x00004000UL
29119 +#define NETLINK_FIREWALL_SOCKET__SETOPT           0x00008000UL
29120 +#define NETLINK_FIREWALL_SOCKET__SHUTDOWN         0x00010000UL
29121 +#define NETLINK_FIREWALL_SOCKET__RECVFROM         0x00020000UL
29122 +#define NETLINK_FIREWALL_SOCKET__SENDTO           0x00040000UL
29123 +#define NETLINK_FIREWALL_SOCKET__RECV_MSG         0x00080000UL
29124 +#define NETLINK_FIREWALL_SOCKET__SEND_MSG         0x00100000UL
29125 +#define NETLINK_FIREWALL_SOCKET__NAME_BIND        0x00200000UL
29126 +#define NETLINK_FIREWALL_SOCKET__NLMSG_READ       0x00400000UL
29127 +#define NETLINK_FIREWALL_SOCKET__NLMSG_WRITE      0x00800000UL
29128 +#define NETLINK_TCPDIAG_SOCKET__IOCTL             0x00000001UL
29129 +#define NETLINK_TCPDIAG_SOCKET__READ              0x00000002UL
29130 +#define NETLINK_TCPDIAG_SOCKET__WRITE             0x00000004UL
29131 +#define NETLINK_TCPDIAG_SOCKET__CREATE            0x00000008UL
29132 +#define NETLINK_TCPDIAG_SOCKET__GETATTR           0x00000010UL
29133 +#define NETLINK_TCPDIAG_SOCKET__SETATTR           0x00000020UL
29134 +#define NETLINK_TCPDIAG_SOCKET__LOCK              0x00000040UL
29135 +#define NETLINK_TCPDIAG_SOCKET__RELABELFROM       0x00000080UL
29136 +#define NETLINK_TCPDIAG_SOCKET__RELABELTO         0x00000100UL
29137 +#define NETLINK_TCPDIAG_SOCKET__APPEND            0x00000200UL
29138 +#define NETLINK_TCPDIAG_SOCKET__BIND              0x00000400UL
29139 +#define NETLINK_TCPDIAG_SOCKET__CONNECT           0x00000800UL
29140 +#define NETLINK_TCPDIAG_SOCKET__LISTEN            0x00001000UL
29141 +#define NETLINK_TCPDIAG_SOCKET__ACCEPT            0x00002000UL
29142 +#define NETLINK_TCPDIAG_SOCKET__GETOPT            0x00004000UL
29143 +#define NETLINK_TCPDIAG_SOCKET__SETOPT            0x00008000UL
29144 +#define NETLINK_TCPDIAG_SOCKET__SHUTDOWN          0x00010000UL
29145 +#define NETLINK_TCPDIAG_SOCKET__RECVFROM          0x00020000UL
29146 +#define NETLINK_TCPDIAG_SOCKET__SENDTO            0x00040000UL
29147 +#define NETLINK_TCPDIAG_SOCKET__RECV_MSG          0x00080000UL
29148 +#define NETLINK_TCPDIAG_SOCKET__SEND_MSG          0x00100000UL
29149 +#define NETLINK_TCPDIAG_SOCKET__NAME_BIND         0x00200000UL
29150 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_READ        0x00400000UL
29151 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_WRITE       0x00800000UL
29152 +#define NETLINK_NFLOG_SOCKET__IOCTL               0x00000001UL
29153 +#define NETLINK_NFLOG_SOCKET__READ                0x00000002UL
29154 +#define NETLINK_NFLOG_SOCKET__WRITE               0x00000004UL
29155 +#define NETLINK_NFLOG_SOCKET__CREATE              0x00000008UL
29156 +#define NETLINK_NFLOG_SOCKET__GETATTR             0x00000010UL
29157 +#define NETLINK_NFLOG_SOCKET__SETATTR             0x00000020UL
29158 +#define NETLINK_NFLOG_SOCKET__LOCK                0x00000040UL
29159 +#define NETLINK_NFLOG_SOCKET__RELABELFROM         0x00000080UL
29160 +#define NETLINK_NFLOG_SOCKET__RELABELTO           0x00000100UL
29161 +#define NETLINK_NFLOG_SOCKET__APPEND              0x00000200UL
29162 +#define NETLINK_NFLOG_SOCKET__BIND                0x00000400UL
29163 +#define NETLINK_NFLOG_SOCKET__CONNECT             0x00000800UL
29164 +#define NETLINK_NFLOG_SOCKET__LISTEN              0x00001000UL
29165 +#define NETLINK_NFLOG_SOCKET__ACCEPT              0x00002000UL
29166 +#define NETLINK_NFLOG_SOCKET__GETOPT              0x00004000UL
29167 +#define NETLINK_NFLOG_SOCKET__SETOPT              0x00008000UL
29168 +#define NETLINK_NFLOG_SOCKET__SHUTDOWN            0x00010000UL
29169 +#define NETLINK_NFLOG_SOCKET__RECVFROM            0x00020000UL
29170 +#define NETLINK_NFLOG_SOCKET__SENDTO              0x00040000UL
29171 +#define NETLINK_NFLOG_SOCKET__RECV_MSG            0x00080000UL
29172 +#define NETLINK_NFLOG_SOCKET__SEND_MSG            0x00100000UL
29173 +#define NETLINK_NFLOG_SOCKET__NAME_BIND           0x00200000UL
29174 +#define NETLINK_XFRM_SOCKET__IOCTL                0x00000001UL
29175 +#define NETLINK_XFRM_SOCKET__READ                 0x00000002UL
29176 +#define NETLINK_XFRM_SOCKET__WRITE                0x00000004UL
29177 +#define NETLINK_XFRM_SOCKET__CREATE               0x00000008UL
29178 +#define NETLINK_XFRM_SOCKET__GETATTR              0x00000010UL
29179 +#define NETLINK_XFRM_SOCKET__SETATTR              0x00000020UL
29180 +#define NETLINK_XFRM_SOCKET__LOCK                 0x00000040UL
29181 +#define NETLINK_XFRM_SOCKET__RELABELFROM          0x00000080UL
29182 +#define NETLINK_XFRM_SOCKET__RELABELTO            0x00000100UL
29183 +#define NETLINK_XFRM_SOCKET__APPEND               0x00000200UL
29184 +#define NETLINK_XFRM_SOCKET__BIND                 0x00000400UL
29185 +#define NETLINK_XFRM_SOCKET__CONNECT              0x00000800UL
29186 +#define NETLINK_XFRM_SOCKET__LISTEN               0x00001000UL
29187 +#define NETLINK_XFRM_SOCKET__ACCEPT               0x00002000UL
29188 +#define NETLINK_XFRM_SOCKET__GETOPT               0x00004000UL
29189 +#define NETLINK_XFRM_SOCKET__SETOPT               0x00008000UL
29190 +#define NETLINK_XFRM_SOCKET__SHUTDOWN             0x00010000UL
29191 +#define NETLINK_XFRM_SOCKET__RECVFROM             0x00020000UL
29192 +#define NETLINK_XFRM_SOCKET__SENDTO               0x00040000UL
29193 +#define NETLINK_XFRM_SOCKET__RECV_MSG             0x00080000UL
29194 +#define NETLINK_XFRM_SOCKET__SEND_MSG             0x00100000UL
29195 +#define NETLINK_XFRM_SOCKET__NAME_BIND            0x00200000UL
29196 +#define NETLINK_XFRM_SOCKET__NLMSG_READ           0x00400000UL
29197 +#define NETLINK_XFRM_SOCKET__NLMSG_WRITE          0x00800000UL
29198 +#define NETLINK_SELINUX_SOCKET__IOCTL             0x00000001UL
29199 +#define NETLINK_SELINUX_SOCKET__READ              0x00000002UL
29200 +#define NETLINK_SELINUX_SOCKET__WRITE             0x00000004UL
29201 +#define NETLINK_SELINUX_SOCKET__CREATE            0x00000008UL
29202 +#define NETLINK_SELINUX_SOCKET__GETATTR           0x00000010UL
29203 +#define NETLINK_SELINUX_SOCKET__SETATTR           0x00000020UL
29204 +#define NETLINK_SELINUX_SOCKET__LOCK              0x00000040UL
29205 +#define NETLINK_SELINUX_SOCKET__RELABELFROM       0x00000080UL
29206 +#define NETLINK_SELINUX_SOCKET__RELABELTO         0x00000100UL
29207 +#define NETLINK_SELINUX_SOCKET__APPEND            0x00000200UL
29208 +#define NETLINK_SELINUX_SOCKET__BIND              0x00000400UL
29209 +#define NETLINK_SELINUX_SOCKET__CONNECT           0x00000800UL
29210 +#define NETLINK_SELINUX_SOCKET__LISTEN            0x00001000UL
29211 +#define NETLINK_SELINUX_SOCKET__ACCEPT            0x00002000UL
29212 +#define NETLINK_SELINUX_SOCKET__GETOPT            0x00004000UL
29213 +#define NETLINK_SELINUX_SOCKET__SETOPT            0x00008000UL
29214 +#define NETLINK_SELINUX_SOCKET__SHUTDOWN          0x00010000UL
29215 +#define NETLINK_SELINUX_SOCKET__RECVFROM          0x00020000UL
29216 +#define NETLINK_SELINUX_SOCKET__SENDTO            0x00040000UL
29217 +#define NETLINK_SELINUX_SOCKET__RECV_MSG          0x00080000UL
29218 +#define NETLINK_SELINUX_SOCKET__SEND_MSG          0x00100000UL
29219 +#define NETLINK_SELINUX_SOCKET__NAME_BIND         0x00200000UL
29220 +#define NETLINK_AUDIT_SOCKET__IOCTL               0x00000001UL
29221 +#define NETLINK_AUDIT_SOCKET__READ                0x00000002UL
29222 +#define NETLINK_AUDIT_SOCKET__WRITE               0x00000004UL
29223 +#define NETLINK_AUDIT_SOCKET__CREATE              0x00000008UL
29224 +#define NETLINK_AUDIT_SOCKET__GETATTR             0x00000010UL
29225 +#define NETLINK_AUDIT_SOCKET__SETATTR             0x00000020UL
29226 +#define NETLINK_AUDIT_SOCKET__LOCK                0x00000040UL
29227 +#define NETLINK_AUDIT_SOCKET__RELABELFROM         0x00000080UL
29228 +#define NETLINK_AUDIT_SOCKET__RELABELTO           0x00000100UL
29229 +#define NETLINK_AUDIT_SOCKET__APPEND              0x00000200UL
29230 +#define NETLINK_AUDIT_SOCKET__BIND                0x00000400UL
29231 +#define NETLINK_AUDIT_SOCKET__CONNECT             0x00000800UL
29232 +#define NETLINK_AUDIT_SOCKET__LISTEN              0x00001000UL
29233 +#define NETLINK_AUDIT_SOCKET__ACCEPT              0x00002000UL
29234 +#define NETLINK_AUDIT_SOCKET__GETOPT              0x00004000UL
29235 +#define NETLINK_AUDIT_SOCKET__SETOPT              0x00008000UL
29236 +#define NETLINK_AUDIT_SOCKET__SHUTDOWN            0x00010000UL
29237 +#define NETLINK_AUDIT_SOCKET__RECVFROM            0x00020000UL
29238 +#define NETLINK_AUDIT_SOCKET__SENDTO              0x00040000UL
29239 +#define NETLINK_AUDIT_SOCKET__RECV_MSG            0x00080000UL
29240 +#define NETLINK_AUDIT_SOCKET__SEND_MSG            0x00100000UL
29241 +#define NETLINK_AUDIT_SOCKET__NAME_BIND           0x00200000UL
29242 +#define NETLINK_AUDIT_SOCKET__NLMSG_READ          0x00400000UL
29243 +#define NETLINK_AUDIT_SOCKET__NLMSG_WRITE         0x00800000UL
29244 +#define NETLINK_AUDIT_SOCKET__NLMSG_RELAY         0x01000000UL
29245 +#define NETLINK_AUDIT_SOCKET__NLMSG_READPRIV      0x02000000UL
29246 +#define NETLINK_AUDIT_SOCKET__NLMSG_TTY_AUDIT     0x04000000UL
29247 +#define NETLINK_IP6FW_SOCKET__IOCTL               0x00000001UL
29248 +#define NETLINK_IP6FW_SOCKET__READ                0x00000002UL
29249 +#define NETLINK_IP6FW_SOCKET__WRITE               0x00000004UL
29250 +#define NETLINK_IP6FW_SOCKET__CREATE              0x00000008UL
29251 +#define NETLINK_IP6FW_SOCKET__GETATTR             0x00000010UL
29252 +#define NETLINK_IP6FW_SOCKET__SETATTR             0x00000020UL
29253 +#define NETLINK_IP6FW_SOCKET__LOCK                0x00000040UL
29254 +#define NETLINK_IP6FW_SOCKET__RELABELFROM         0x00000080UL
29255 +#define NETLINK_IP6FW_SOCKET__RELABELTO           0x00000100UL
29256 +#define NETLINK_IP6FW_SOCKET__APPEND              0x00000200UL
29257 +#define NETLINK_IP6FW_SOCKET__BIND                0x00000400UL
29258 +#define NETLINK_IP6FW_SOCKET__CONNECT             0x00000800UL
29259 +#define NETLINK_IP6FW_SOCKET__LISTEN              0x00001000UL
29260 +#define NETLINK_IP6FW_SOCKET__ACCEPT              0x00002000UL
29261 +#define NETLINK_IP6FW_SOCKET__GETOPT              0x00004000UL
29262 +#define NETLINK_IP6FW_SOCKET__SETOPT              0x00008000UL
29263 +#define NETLINK_IP6FW_SOCKET__SHUTDOWN            0x00010000UL
29264 +#define NETLINK_IP6FW_SOCKET__RECVFROM            0x00020000UL
29265 +#define NETLINK_IP6FW_SOCKET__SENDTO              0x00040000UL
29266 +#define NETLINK_IP6FW_SOCKET__RECV_MSG            0x00080000UL
29267 +#define NETLINK_IP6FW_SOCKET__SEND_MSG            0x00100000UL
29268 +#define NETLINK_IP6FW_SOCKET__NAME_BIND           0x00200000UL
29269 +#define NETLINK_IP6FW_SOCKET__NLMSG_READ          0x00400000UL
29270 +#define NETLINK_IP6FW_SOCKET__NLMSG_WRITE         0x00800000UL
29271 +#define NETLINK_DNRT_SOCKET__IOCTL                0x00000001UL
29272 +#define NETLINK_DNRT_SOCKET__READ                 0x00000002UL
29273 +#define NETLINK_DNRT_SOCKET__WRITE                0x00000004UL
29274 +#define NETLINK_DNRT_SOCKET__CREATE               0x00000008UL
29275 +#define NETLINK_DNRT_SOCKET__GETATTR              0x00000010UL
29276 +#define NETLINK_DNRT_SOCKET__SETATTR              0x00000020UL
29277 +#define NETLINK_DNRT_SOCKET__LOCK                 0x00000040UL
29278 +#define NETLINK_DNRT_SOCKET__RELABELFROM          0x00000080UL
29279 +#define NETLINK_DNRT_SOCKET__RELABELTO            0x00000100UL
29280 +#define NETLINK_DNRT_SOCKET__APPEND               0x00000200UL
29281 +#define NETLINK_DNRT_SOCKET__BIND                 0x00000400UL
29282 +#define NETLINK_DNRT_SOCKET__CONNECT              0x00000800UL
29283 +#define NETLINK_DNRT_SOCKET__LISTEN               0x00001000UL
29284 +#define NETLINK_DNRT_SOCKET__ACCEPT               0x00002000UL
29285 +#define NETLINK_DNRT_SOCKET__GETOPT               0x00004000UL
29286 +#define NETLINK_DNRT_SOCKET__SETOPT               0x00008000UL
29287 +#define NETLINK_DNRT_SOCKET__SHUTDOWN             0x00010000UL
29288 +#define NETLINK_DNRT_SOCKET__RECVFROM             0x00020000UL
29289 +#define NETLINK_DNRT_SOCKET__SENDTO               0x00040000UL
29290 +#define NETLINK_DNRT_SOCKET__RECV_MSG             0x00080000UL
29291 +#define NETLINK_DNRT_SOCKET__SEND_MSG             0x00100000UL
29292 +#define NETLINK_DNRT_SOCKET__NAME_BIND            0x00200000UL
29293 +#define ASSOCIATION__SENDTO                       0x00000001UL
29294 +#define ASSOCIATION__RECVFROM                     0x00000002UL
29295 +#define ASSOCIATION__SETCONTEXT                   0x00000004UL
29296 +#define ASSOCIATION__POLMATCH                     0x00000008UL
29297 +#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL      0x00000001UL
29298 +#define NETLINK_KOBJECT_UEVENT_SOCKET__READ       0x00000002UL
29299 +#define NETLINK_KOBJECT_UEVENT_SOCKET__WRITE      0x00000004UL
29300 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CREATE     0x00000008UL
29301 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETATTR    0x00000010UL
29302 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETATTR    0x00000020UL
29303 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LOCK       0x00000040UL
29304 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELFROM 0x00000080UL
29305 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELTO  0x00000100UL
29306 +#define NETLINK_KOBJECT_UEVENT_SOCKET__APPEND     0x00000200UL
29307 +#define NETLINK_KOBJECT_UEVENT_SOCKET__BIND       0x00000400UL
29308 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CONNECT    0x00000800UL
29309 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LISTEN     0x00001000UL
29310 +#define NETLINK_KOBJECT_UEVENT_SOCKET__ACCEPT     0x00002000UL
29311 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETOPT     0x00004000UL
29312 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETOPT     0x00008000UL
29313 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SHUTDOWN   0x00010000UL
29314 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECVFROM   0x00020000UL
29315 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SENDTO     0x00040000UL
29316 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECV_MSG   0x00080000UL
29317 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SEND_MSG   0x00100000UL
29318 +#define NETLINK_KOBJECT_UEVENT_SOCKET__NAME_BIND  0x00200000UL
29319 +#define APPLETALK_SOCKET__IOCTL                   0x00000001UL
29320 +#define APPLETALK_SOCKET__READ                    0x00000002UL
29321 +#define APPLETALK_SOCKET__WRITE                   0x00000004UL
29322 +#define APPLETALK_SOCKET__CREATE                  0x00000008UL
29323 +#define APPLETALK_SOCKET__GETATTR                 0x00000010UL
29324 +#define APPLETALK_SOCKET__SETATTR                 0x00000020UL
29325 +#define APPLETALK_SOCKET__LOCK                    0x00000040UL
29326 +#define APPLETALK_SOCKET__RELABELFROM             0x00000080UL
29327 +#define APPLETALK_SOCKET__RELABELTO               0x00000100UL
29328 +#define APPLETALK_SOCKET__APPEND                  0x00000200UL
29329 +#define APPLETALK_SOCKET__BIND                    0x00000400UL
29330 +#define APPLETALK_SOCKET__CONNECT                 0x00000800UL
29331 +#define APPLETALK_SOCKET__LISTEN                  0x00001000UL
29332 +#define APPLETALK_SOCKET__ACCEPT                  0x00002000UL
29333 +#define APPLETALK_SOCKET__GETOPT                  0x00004000UL
29334 +#define APPLETALK_SOCKET__SETOPT                  0x00008000UL
29335 +#define APPLETALK_SOCKET__SHUTDOWN                0x00010000UL
29336 +#define APPLETALK_SOCKET__RECVFROM                0x00020000UL
29337 +#define APPLETALK_SOCKET__SENDTO                  0x00040000UL
29338 +#define APPLETALK_SOCKET__RECV_MSG                0x00080000UL
29339 +#define APPLETALK_SOCKET__SEND_MSG                0x00100000UL
29340 +#define APPLETALK_SOCKET__NAME_BIND               0x00200000UL
29341 +#define PACKET__SEND                              0x00000001UL
29342 +#define PACKET__RECV                              0x00000002UL
29343 +#define PACKET__RELABELTO                         0x00000004UL
29344 +#define PACKET__FLOW_IN                           0x00000008UL
29345 +#define PACKET__FLOW_OUT                          0x00000010UL
29346 +#define PACKET__FORWARD_IN                        0x00000020UL
29347 +#define PACKET__FORWARD_OUT                       0x00000040UL
29348 +#define KEY__VIEW                                 0x00000001UL
29349 +#define KEY__READ                                 0x00000002UL
29350 +#define KEY__WRITE                                0x00000004UL
29351 +#define KEY__SEARCH                               0x00000008UL
29352 +#define KEY__LINK                                 0x00000010UL
29353 +#define KEY__SETATTR                              0x00000020UL
29354 +#define KEY__CREATE                               0x00000040UL
29355 +#define DCCP_SOCKET__IOCTL                        0x00000001UL
29356 +#define DCCP_SOCKET__READ                         0x00000002UL
29357 +#define DCCP_SOCKET__WRITE                        0x00000004UL
29358 +#define DCCP_SOCKET__CREATE                       0x00000008UL
29359 +#define DCCP_SOCKET__GETATTR                      0x00000010UL
29360 +#define DCCP_SOCKET__SETATTR                      0x00000020UL
29361 +#define DCCP_SOCKET__LOCK                         0x00000040UL
29362 +#define DCCP_SOCKET__RELABELFROM                  0x00000080UL
29363 +#define DCCP_SOCKET__RELABELTO                    0x00000100UL
29364 +#define DCCP_SOCKET__APPEND                       0x00000200UL
29365 +#define DCCP_SOCKET__BIND                         0x00000400UL
29366 +#define DCCP_SOCKET__CONNECT                      0x00000800UL
29367 +#define DCCP_SOCKET__LISTEN                       0x00001000UL
29368 +#define DCCP_SOCKET__ACCEPT                       0x00002000UL
29369 +#define DCCP_SOCKET__GETOPT                       0x00004000UL
29370 +#define DCCP_SOCKET__SETOPT                       0x00008000UL
29371 +#define DCCP_SOCKET__SHUTDOWN                     0x00010000UL
29372 +#define DCCP_SOCKET__RECVFROM                     0x00020000UL
29373 +#define DCCP_SOCKET__SENDTO                       0x00040000UL
29374 +#define DCCP_SOCKET__RECV_MSG                     0x00080000UL
29375 +#define DCCP_SOCKET__SEND_MSG                     0x00100000UL
29376 +#define DCCP_SOCKET__NAME_BIND                    0x00200000UL
29377 +#define DCCP_SOCKET__NODE_BIND                    0x00400000UL
29378 +#define DCCP_SOCKET__NAME_CONNECT                 0x00800000UL
29379 +#define MEMPROTECT__MMAP_ZERO                     0x00000001UL
29380 +#define PEER__RECV                                0x00000001UL
29381 +#define CAPABILITY2__MAC_OVERRIDE                 0x00000001UL
29382 +#define CAPABILITY2__MAC_ADMIN                    0x00000002UL
29383 +#define KERNEL_SERVICE__USE_AS_OVERRIDE           0x00000001UL
29384 +#define KERNEL_SERVICE__CREATE_FILES_AS           0x00000002UL
29385 +#define TUN_SOCKET__IOCTL                         0x00000001UL
29386 +#define TUN_SOCKET__READ                          0x00000002UL
29387 +#define TUN_SOCKET__WRITE                         0x00000004UL
29388 +#define TUN_SOCKET__CREATE                        0x00000008UL
29389 +#define TUN_SOCKET__GETATTR                       0x00000010UL
29390 +#define TUN_SOCKET__SETATTR                       0x00000020UL
29391 +#define TUN_SOCKET__LOCK                          0x00000040UL
29392 +#define TUN_SOCKET__RELABELFROM                   0x00000080UL
29393 +#define TUN_SOCKET__RELABELTO                     0x00000100UL
29394 +#define TUN_SOCKET__APPEND                        0x00000200UL
29395 +#define TUN_SOCKET__BIND                          0x00000400UL
29396 +#define TUN_SOCKET__CONNECT                       0x00000800UL
29397 +#define TUN_SOCKET__LISTEN                        0x00001000UL
29398 +#define TUN_SOCKET__ACCEPT                        0x00002000UL
29399 +#define TUN_SOCKET__GETOPT                        0x00004000UL
29400 +#define TUN_SOCKET__SETOPT                        0x00008000UL
29401 +#define TUN_SOCKET__SHUTDOWN                      0x00010000UL
29402 +#define TUN_SOCKET__RECVFROM                      0x00020000UL
29403 +#define TUN_SOCKET__SENDTO                        0x00040000UL
29404 +#define TUN_SOCKET__RECV_MSG                      0x00080000UL
29405 +#define TUN_SOCKET__SEND_MSG                      0x00100000UL
29406 +#define TUN_SOCKET__NAME_BIND                     0x00200000UL
29407 +
29408 +#endif
29409 diff -NurpP --minimal linux-2.6.34/security/selinux/hooks.c linux-2.6.34-vs2.3.0.36.30.4.pre6/security/selinux/hooks.c
29410 --- linux-2.6.34/security/selinux/hooks.c       2010-05-18 15:07:53.000000000 +0200
29411 +++ linux-2.6.34-vs2.3.0.36.30.4.pre6/security/selinux/hooks.c  2010-05-18 18:11:22.000000000 +0200
29412 @@ -64,7 +64,6 @@
29413  #include <linux/dccp.h>
29414  #include <linux/quota.h>
29415  #include <linux/un.h>          /* for Unix socket types */
29416 -#include <net/af_unix.h>       /* for Unix socket types */
29417  #include <linux/parser.h>
29418  #include <linux/nfs_mount.h>
29419  #include <net/ipv6.h>
This page took 2.589305 seconds and 4 git commands to generate.