]> git.pld-linux.org Git - packages/kernel.git/blob - kernel-vserver-2.3.patch
delta-signal-fix01.diff
[packages/kernel.git] / kernel-vserver-2.3.patch
1 diff -NurpP --minimal linux-2.6.33.2/arch/alpha/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/Kconfig
2 --- linux-2.6.33.2/arch/alpha/Kconfig   2010-02-25 11:51:18.000000000 +0100
3 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/Kconfig   2010-02-25 12:02:16.000000000 +0100
4 @@ -675,6 +675,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.33.2/arch/alpha/kernel/entry.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/kernel/entry.S
14 --- linux-2.6.33.2/arch/alpha/kernel/entry.S    2009-06-11 17:11:46.000000000 +0200
15 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/kernel/entry.S    2010-02-25 12:02:16.000000000 +0100
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.33.2/arch/alpha/kernel/osf_sys.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.33.2/arch/alpha/kernel/osf_sys.c  2010-02-25 11:51:19.000000000 +0100
50 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/kernel/osf_sys.c  2010-02-25 12:02:16.000000000 +0100
51 @@ -865,7 +865,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.33.2/arch/alpha/kernel/ptrace.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.33.2/arch/alpha/kernel/ptrace.c   2009-09-10 15:25:14.000000000 +0200
62 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/kernel/ptrace.c   2010-02-25 12:02:16.000000000 +0100
63 @@ -14,6 +14,7 @@
64  #include <linux/slab.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.33.2/arch/alpha/kernel/systbls.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/kernel/systbls.S
72 --- linux-2.6.33.2/arch/alpha/kernel/systbls.S  2010-02-25 11:51:19.000000000 +0100
73 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/kernel/systbls.S  2010-02-25 12:02:16.000000000 +0100
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.33.2/arch/alpha/kernel/traps.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/kernel/traps.c
84 --- linux-2.6.33.2/arch/alpha/kernel/traps.c    2009-06-11 17:11:46.000000000 +0200
85 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/kernel/traps.c    2010-02-25 12:02:16.000000000 +0100
86 @@ -183,7 +183,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.33.2/arch/alpha/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/mm/fault.c
97 --- linux-2.6.33.2/arch/alpha/mm/fault.c        2009-09-10 15:25:14.000000000 +0200
98 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/alpha/mm/fault.c        2010-02-25 12:02:16.000000000 +0100
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.33.2/arch/arm/include/asm/tlb.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/arm/include/asm/tlb.h
111 --- linux-2.6.33.2/arch/arm/include/asm/tlb.h   2009-09-10 15:25:15.000000000 +0200
112 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/arm/include/asm/tlb.h   2010-02-25 12:02:16.000000000 +0100
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.33.2/arch/arm/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/arm/Kconfig
122 --- linux-2.6.33.2/arch/arm/Kconfig     2010-02-25 11:51:19.000000000 +0100
123 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/arm/Kconfig     2010-02-25 12:02:16.000000000 +0100
124 @@ -1542,6 +1542,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.33.2/arch/arm/kernel/calls.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/arm/kernel/calls.S
134 --- linux-2.6.33.2/arch/arm/kernel/calls.S      2010-02-25 11:51:20.000000000 +0100
135 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/arm/kernel/calls.S      2010-02-25 12:02:16.000000000 +0100
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.33.2/arch/arm/kernel/process.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/arm/kernel/process.c
146 --- linux-2.6.33.2/arch/arm/kernel/process.c    2010-02-25 11:51:20.000000000 +0100
147 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/arm/kernel/process.c    2010-02-25 12:02:16.000000000 +0100
148 @@ -270,7 +270,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.33.2/arch/arm/kernel/traps.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/arm/kernel/traps.c
159 --- linux-2.6.33.2/arch/arm/kernel/traps.c      2009-12-03 20:01:50.000000000 +0100
160 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/arm/kernel/traps.c      2010-02-25 12:02:16.000000000 +0100
161 @@ -234,8 +234,8 @@ static void __die(const char *str, int e
162         sysfs_printk_last_file();
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.33.2/arch/avr32/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/avr32/mm/fault.c
173 --- linux-2.6.33.2/arch/avr32/mm/fault.c        2009-09-10 15:25:20.000000000 +0200
174 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/avr32/mm/fault.c        2010-02-25 12:02:16.000000000 +0100
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.33.2/arch/cris/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/cris/Kconfig
186 --- linux-2.6.33.2/arch/cris/Kconfig    2009-06-11 17:11:56.000000000 +0200
187 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/cris/Kconfig    2010-02-25 12:02:16.000000000 +0100
188 @@ -685,6 +685,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.33.2/arch/cris/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/cris/mm/fault.c
198 --- linux-2.6.33.2/arch/cris/mm/fault.c 2010-02-25 11:51:26.000000000 +0100
199 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/cris/mm/fault.c 2010-02-25 12:02:16.000000000 +0100
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.33.2/arch/frv/kernel/kernel_thread.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/frv/kernel/kernel_thread.S
211 --- linux-2.6.33.2/arch/frv/kernel/kernel_thread.S      2008-12-25 00:26:37.000000000 +0100
212 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/frv/kernel/kernel_thread.S      2010-02-25 12:02:16.000000000 +0100
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.33.2/arch/frv/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/frv/mm/fault.c
223 --- linux-2.6.33.2/arch/frv/mm/fault.c  2009-09-10 15:25:22.000000000 +0200
224 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/frv/mm/fault.c  2010-02-25 12:02:16.000000000 +0100
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.33.2/arch/h8300/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/h8300/Kconfig
236 --- linux-2.6.33.2/arch/h8300/Kconfig   2010-02-25 11:51:26.000000000 +0100
237 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/h8300/Kconfig   2010-02-25 12:02:16.000000000 +0100
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.33.2/arch/ia64/ia32/ia32_entry.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/ia32/ia32_entry.S
248 --- linux-2.6.33.2/arch/ia64/ia32/ia32_entry.S  2010-02-25 11:51:26.000000000 +0100
249 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/ia32/ia32_entry.S  2010-02-25 12:02:16.000000000 +0100
250 @@ -451,7 +451,7 @@ ia32_syscall_table:
251         data8 sys_tgkill        /* 270 */
252         data8 compat_sys_utimes
253         data8 sys32_fadvise64_64
254 -       data8 sys_ni_syscall
255 +       data8 sys32_vserver
256         data8 sys_ni_syscall
257         data8 sys_ni_syscall    /* 275 */
258         data8 sys_ni_syscall
259 diff -NurpP --minimal linux-2.6.33.2/arch/ia64/include/asm/tlb.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/include/asm/tlb.h
260 --- linux-2.6.33.2/arch/ia64/include/asm/tlb.h  2010-02-25 11:51:26.000000000 +0100
261 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/include/asm/tlb.h  2010-02-25 12:02:16.000000000 +0100
262 @@ -40,6 +40,7 @@
263  #include <linux/mm.h>
264  #include <linux/pagemap.h>
265  #include <linux/swap.h>
266 +#include <linux/vs_memory.h>
267  
268  #include <asm/pgalloc.h>
269  #include <asm/processor.h>
270 diff -NurpP --minimal linux-2.6.33.2/arch/ia64/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/Kconfig
271 --- linux-2.6.33.2/arch/ia64/Kconfig    2010-02-25 11:51:26.000000000 +0100
272 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/Kconfig    2010-02-25 12:02:16.000000000 +0100
273 @@ -682,6 +682,8 @@ source "fs/Kconfig"
274  
275  source "arch/ia64/Kconfig.debug"
276  
277 +source "kernel/vserver/Kconfig"
278 +
279  source "security/Kconfig"
280  
281  source "crypto/Kconfig"
282 diff -NurpP --minimal linux-2.6.33.2/arch/ia64/kernel/entry.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/kernel/entry.S
283 --- linux-2.6.33.2/arch/ia64/kernel/entry.S     2010-02-25 11:51:26.000000000 +0100
284 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/kernel/entry.S     2010-02-25 12:02:16.000000000 +0100
285 @@ -1753,7 +1753,7 @@ sys_call_table:
286         data8 sys_mq_notify
287         data8 sys_mq_getsetattr
288         data8 sys_kexec_load
289 -       data8 sys_ni_syscall                    // reserved for vserver
290 +       data8 sys_vserver
291         data8 sys_waitid                        // 1270
292         data8 sys_add_key
293         data8 sys_request_key
294 diff -NurpP --minimal linux-2.6.33.2/arch/ia64/kernel/perfmon.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/kernel/perfmon.c
295 --- linux-2.6.33.2/arch/ia64/kernel/perfmon.c   2010-02-25 11:51:26.000000000 +0100
296 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/kernel/perfmon.c   2010-02-25 12:02:16.000000000 +0100
297 @@ -41,6 +41,7 @@
298  #include <linux/rcupdate.h>
299  #include <linux/completion.h>
300  #include <linux/tracehook.h>
301 +#include <linux/vs_memory.h>
302  
303  #include <asm/errno.h>
304  #include <asm/intrinsics.h>
305 @@ -2367,7 +2368,7 @@ pfm_smpl_buffer_alloc(struct task_struct
306          */
307         insert_vm_struct(mm, vma);
308  
309 -       mm->total_vm  += size >> PAGE_SHIFT;
310 +       vx_vmpages_add(mm, size >> PAGE_SHIFT);
311         vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
312                                                         vma_pages(vma));
313         up_write(&task->mm->mmap_sem);
314 diff -NurpP --minimal linux-2.6.33.2/arch/ia64/kernel/process.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/kernel/process.c
315 --- linux-2.6.33.2/arch/ia64/kernel/process.c   2009-12-03 20:01:56.000000000 +0100
316 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/kernel/process.c   2010-02-25 12:02:16.000000000 +0100
317 @@ -110,8 +110,8 @@ show_regs (struct pt_regs *regs)
318         unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
319  
320         print_modules();
321 -       printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
322 -                       smp_processor_id(), current->comm);
323 +       printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
324 +                       current->xid, smp_processor_id(), current->comm);
325         printk("psr : %016lx ifs : %016lx ip  : [<%016lx>]    %s (%s)\n",
326                regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
327                init_utsname()->release);
328 diff -NurpP --minimal linux-2.6.33.2/arch/ia64/kernel/ptrace.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/kernel/ptrace.c
329 --- linux-2.6.33.2/arch/ia64/kernel/ptrace.c    2009-09-10 15:25:22.000000000 +0200
330 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/kernel/ptrace.c    2010-02-25 12:02:16.000000000 +0100
331 @@ -22,6 +22,7 @@
332  #include <linux/regset.h>
333  #include <linux/elf.h>
334  #include <linux/tracehook.h>
335 +#include <linux/vs_base.h>
336  
337  #include <asm/pgtable.h>
338  #include <asm/processor.h>
339 diff -NurpP --minimal linux-2.6.33.2/arch/ia64/kernel/traps.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/kernel/traps.c
340 --- linux-2.6.33.2/arch/ia64/kernel/traps.c     2008-12-25 00:26:37.000000000 +0100
341 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/kernel/traps.c     2010-02-25 12:02:16.000000000 +0100
342 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
343         put_cpu();
344  
345         if (++die.lock_owner_depth < 3) {
346 -               printk("%s[%d]: %s %ld [%d]\n",
347 -               current->comm, task_pid_nr(current), str, err, ++die_counter);
348 +               printk("%s[%d[#%u]]: %s %ld [%d]\n",
349 +                       current->comm, task_pid_nr(current), current->xid,
350 +                       str, err, ++die_counter);
351                 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
352                     != NOTIFY_STOP)
353                         show_regs(regs);
354 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
355                         if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
356                                 last.time = current_jiffies + 5 * HZ;
357                                 printk(KERN_WARNING
358 -                                       "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
359 -                                       current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
360 +                                       "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
361 +                                       current->comm, task_pid_nr(current), current->xid,
362 +                                       regs->cr_iip + ia64_psr(regs)->ri, isr);
363                         }
364                 }
365         }
366 diff -NurpP --minimal linux-2.6.33.2/arch/ia64/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/mm/fault.c
367 --- linux-2.6.33.2/arch/ia64/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
368 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/ia64/mm/fault.c 2010-02-25 12:02:16.000000000 +0100
369 @@ -10,6 +10,7 @@
370  #include <linux/interrupt.h>
371  #include <linux/kprobes.h>
372  #include <linux/kdebug.h>
373 +#include <linux/vs_memory.h>
374  
375  #include <asm/pgtable.h>
376  #include <asm/processor.h>
377 @@ -281,7 +282,8 @@ ia64_do_page_fault (unsigned long addres
378                 down_read(&mm->mmap_sem);
379                 goto survive;
380         }
381 -       printk(KERN_CRIT "VM: killing process %s\n", current->comm);
382 +       printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
383 +               current->comm, task_pid_nr(current), current->xid);
384         if (user_mode(regs))
385                 do_group_exit(SIGKILL);
386         goto no_context;
387 diff -NurpP --minimal linux-2.6.33.2/arch/m32r/kernel/traps.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/m32r/kernel/traps.c
388 --- linux-2.6.33.2/arch/m32r/kernel/traps.c     2009-12-03 20:01:57.000000000 +0100
389 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/m32r/kernel/traps.c     2010-02-25 12:02:16.000000000 +0100
390 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
391         } else {
392                 printk("SPI: %08lx\n", sp);
393         }
394 -       printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
395 -               current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
396 +       printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
397 +               current->comm, task_pid_nr(current), current->xid,
398 +               0xffff & i, 4096+(unsigned long)current);
399  
400         /*
401          * When in-kernel, we also print out the stack and code at the
402 diff -NurpP --minimal linux-2.6.33.2/arch/m32r/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/m32r/mm/fault.c
403 --- linux-2.6.33.2/arch/m32r/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
404 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/m32r/mm/fault.c 2010-02-25 12:02:16.000000000 +0100
405 @@ -276,7 +276,8 @@ out_of_memory:
406                 down_read(&mm->mmap_sem);
407                 goto survive;
408         }
409 -       printk("VM: killing process %s\n", tsk->comm);
410 +       printk("VM: killing process %s(%d:#%u)\n",
411 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
412         if (error_code & ACE_USERMODE)
413                 do_group_exit(SIGKILL);
414         goto no_context;
415 diff -NurpP --minimal linux-2.6.33.2/arch/m68k/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68k/Kconfig
416 --- linux-2.6.33.2/arch/m68k/Kconfig    2009-12-03 20:01:57.000000000 +0100
417 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68k/Kconfig    2010-02-25 12:02:16.000000000 +0100
418 @@ -622,6 +622,8 @@ source "fs/Kconfig"
419  
420  source "arch/m68k/Kconfig.debug"
421  
422 +source "kernel/vserver/Kconfig"
423 +
424  source "security/Kconfig"
425  
426  source "crypto/Kconfig"
427 diff -NurpP --minimal linux-2.6.33.2/arch/m68k/kernel/ptrace.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68k/kernel/ptrace.c
428 --- linux-2.6.33.2/arch/m68k/kernel/ptrace.c    2010-02-25 11:51:27.000000000 +0100
429 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68k/kernel/ptrace.c    2010-02-25 12:02:16.000000000 +0100
430 @@ -18,6 +18,7 @@
431  #include <linux/ptrace.h>
432  #include <linux/user.h>
433  #include <linux/signal.h>
434 +#include <linux/vs_base.h>
435  
436  #include <asm/uaccess.h>
437  #include <asm/page.h>
438 @@ -249,6 +250,8 @@ long arch_ptrace(struct task_struct *chi
439                 ret = ptrace_request(child, request, addr, data);
440                 break;
441         }
442 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
443 +               goto out_tsk;
444  
445         return ret;
446  out_eio:
447 diff -NurpP --minimal linux-2.6.33.2/arch/m68k/kernel/traps.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68k/kernel/traps.c
448 --- linux-2.6.33.2/arch/m68k/kernel/traps.c     2009-09-10 15:25:23.000000000 +0200
449 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68k/kernel/traps.c     2010-02-25 12:02:16.000000000 +0100
450 @@ -906,8 +906,8 @@ void show_registers(struct pt_regs *regs
451         printk("d4: %08lx    d5: %08lx    a0: %08lx    a1: %08lx\n",
452                regs->d4, regs->d5, regs->a0, regs->a1);
453  
454 -       printk("Process %s (pid: %d, task=%p)\n",
455 -               current->comm, task_pid_nr(current), current);
456 +       printk("Process %s (pid: %d[#%u], task=%p)\n",
457 +               current->comm, task_pid_nr(current), current->xid, current);
458         addr = (unsigned long)&fp->un;
459         printk("Frame format=%X ", regs->format);
460         switch (regs->format) {
461 diff -NurpP --minimal linux-2.6.33.2/arch/m68k/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68k/mm/fault.c
462 --- linux-2.6.33.2/arch/m68k/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
463 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68k/mm/fault.c 2010-02-25 12:02:16.000000000 +0100
464 @@ -186,7 +186,8 @@ out_of_memory:
465                 goto survive;
466         }
467  
468 -       printk("VM: killing process %s\n", current->comm);
469 +       printk("VM: killing process %s(%d:#%u)\n",
470 +               current->comm, task_pid_nr(current), current->xid);
471         if (user_mode(regs))
472                 do_group_exit(SIGKILL);
473  
474 diff -NurpP --minimal linux-2.6.33.2/arch/m68knommu/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68knommu/Kconfig
475 --- linux-2.6.33.2/arch/m68knommu/Kconfig       2010-02-25 11:51:27.000000000 +0100
476 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68knommu/Kconfig       2010-02-25 12:02:16.000000000 +0100
477 @@ -734,6 +734,8 @@ source "fs/Kconfig"
478  
479  source "arch/m68knommu/Kconfig.debug"
480  
481 +source "kernel/vserver/Kconfig"
482 +
483  source "security/Kconfig"
484  
485  source "crypto/Kconfig"
486 diff -NurpP --minimal linux-2.6.33.2/arch/m68knommu/kernel/traps.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68knommu/kernel/traps.c
487 --- linux-2.6.33.2/arch/m68knommu/kernel/traps.c        2009-09-10 15:25:23.000000000 +0200
488 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/m68knommu/kernel/traps.c        2010-02-25 12:02:16.000000000 +0100
489 @@ -78,8 +78,9 @@ void die_if_kernel(char *str, struct pt_
490         printk(KERN_EMERG "d4: %08lx    d5: %08lx    a0: %08lx    a1: %08lx\n",
491                fp->d4, fp->d5, fp->a0, fp->a1);
492  
493 -       printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
494 -               current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
495 +       printk(KERN_EMERG "Process %s (pid: %d[#%u], stackpage=%08lx)\n",
496 +               current->comm, task_pid_nr(current), current->xid,
497 +               PAGE_SIZE+(unsigned long)current);
498         show_stack(NULL, (unsigned long *)(fp + 1));
499         add_taint(TAINT_DIE);
500         do_exit(SIGSEGV);
501 diff -NurpP --minimal linux-2.6.33.2/arch/microblaze/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/microblaze/mm/fault.c
502 --- linux-2.6.33.2/arch/microblaze/mm/fault.c   2009-09-10 15:25:24.000000000 +0200
503 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/microblaze/mm/fault.c   2010-02-25 12:02:16.000000000 +0100
504 @@ -279,7 +279,8 @@ out_of_memory:
505                 goto survive;
506         }
507         up_read(&mm->mmap_sem);
508 -       printk(KERN_WARNING "VM: killing process %s\n", current->comm);
509 +       printk(KERN_WARNING "VM: killing process %s(%d:#%u)\n",
510 +               current->comm, task_pid_nr(current), current->xid);
511         if (user_mode(regs))
512                 do_exit(SIGKILL);
513         bad_page_fault(regs, address, SIGKILL);
514 diff -NurpP --minimal linux-2.6.33.2/arch/mips/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/Kconfig
515 --- linux-2.6.33.2/arch/mips/Kconfig    2010-02-25 11:51:27.000000000 +0100
516 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/Kconfig    2010-02-25 12:02:16.000000000 +0100
517 @@ -2220,6 +2220,8 @@ source "fs/Kconfig"
518  
519  source "arch/mips/Kconfig.debug"
520  
521 +source "kernel/vserver/Kconfig"
522 +
523  source "security/Kconfig"
524  
525  source "crypto/Kconfig"
526 diff -NurpP --minimal linux-2.6.33.2/arch/mips/kernel/ptrace.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/ptrace.c
527 --- linux-2.6.33.2/arch/mips/kernel/ptrace.c    2008-12-25 00:26:37.000000000 +0100
528 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/ptrace.c    2010-02-25 12:02:16.000000000 +0100
529 @@ -25,6 +25,7 @@
530  #include <linux/security.h>
531  #include <linux/audit.h>
532  #include <linux/seccomp.h>
533 +#include <linux/vs_base.h>
534  
535  #include <asm/byteorder.h>
536  #include <asm/cpu.h>
537 @@ -259,6 +260,9 @@ long arch_ptrace(struct task_struct *chi
538  {
539         int ret;
540  
541 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
542 +               goto out;
543 +
544         switch (request) {
545         /* when I and D space are separate, these will need to be fixed. */
546         case PTRACE_PEEKTEXT: /* read word at location addr. */
547 diff -NurpP --minimal linux-2.6.33.2/arch/mips/kernel/scall32-o32.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/scall32-o32.S
548 --- linux-2.6.33.2/arch/mips/kernel/scall32-o32.S       2010-02-25 11:51:28.000000000 +0100
549 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/scall32-o32.S       2010-02-25 12:02:16.000000000 +0100
550 @@ -525,7 +525,7 @@ einval:     li      v0, -ENOSYS
551         sys     sys_mq_timedreceive     5
552         sys     sys_mq_notify           2       /* 4275 */
553         sys     sys_mq_getsetattr       3
554 -       sys     sys_ni_syscall          0       /* sys_vserver */
555 +       sys     sys_vserver             3
556         sys     sys_waitid              5
557         sys     sys_ni_syscall          0       /* available, was setaltroot */
558         sys     sys_add_key             5       /* 4280 */
559 diff -NurpP --minimal linux-2.6.33.2/arch/mips/kernel/scall64-64.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/scall64-64.S
560 --- linux-2.6.33.2/arch/mips/kernel/scall64-64.S        2010-02-25 11:51:28.000000000 +0100
561 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/scall64-64.S        2010-02-25 12:02:16.000000000 +0100
562 @@ -362,7 +362,7 @@ sys_call_table:
563         PTR     sys_mq_timedreceive
564         PTR     sys_mq_notify
565         PTR     sys_mq_getsetattr               /* 5235 */
566 -       PTR     sys_ni_syscall                  /* sys_vserver */
567 +       PTR     sys_vserver
568         PTR     sys_waitid
569         PTR     sys_ni_syscall                  /* available, was setaltroot */
570         PTR     sys_add_key
571 diff -NurpP --minimal linux-2.6.33.2/arch/mips/kernel/scall64-n32.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/scall64-n32.S
572 --- linux-2.6.33.2/arch/mips/kernel/scall64-n32.S       2010-02-25 11:51:28.000000000 +0100
573 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/scall64-n32.S       2010-02-25 12:02:16.000000000 +0100
574 @@ -360,7 +360,7 @@ EXPORT(sysn32_call_table)
575         PTR     compat_sys_mq_timedreceive
576         PTR     compat_sys_mq_notify
577         PTR     compat_sys_mq_getsetattr
578 -       PTR     sys_ni_syscall                  /* 6240, sys_vserver */
579 +       PTR     sys32_vserver                   /* 6240 */
580         PTR     compat_sys_waitid
581         PTR     sys_ni_syscall                  /* available, was setaltroot */
582         PTR     sys_add_key
583 diff -NurpP --minimal linux-2.6.33.2/arch/mips/kernel/scall64-o32.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/scall64-o32.S
584 --- linux-2.6.33.2/arch/mips/kernel/scall64-o32.S       2010-02-25 11:51:28.000000000 +0100
585 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/scall64-o32.S       2010-02-25 12:02:16.000000000 +0100
586 @@ -480,7 +480,7 @@ sys_call_table:
587         PTR     compat_sys_mq_timedreceive
588         PTR     compat_sys_mq_notify            /* 4275 */
589         PTR     compat_sys_mq_getsetattr
590 -       PTR     sys_ni_syscall                  /* sys_vserver */
591 +       PTR     sys32_vserver
592         PTR     sys_32_waitid
593         PTR     sys_ni_syscall                  /* available, was setaltroot */
594         PTR     sys_add_key                     /* 4280 */
595 diff -NurpP --minimal linux-2.6.33.2/arch/mips/kernel/traps.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/traps.c
596 --- linux-2.6.33.2/arch/mips/kernel/traps.c     2010-02-25 11:51:28.000000000 +0100
597 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/mips/kernel/traps.c     2010-02-25 12:02:16.000000000 +0100
598 @@ -333,9 +333,10 @@ void show_registers(const struct pt_regs
599  
600         __show_regs(regs);
601         print_modules();
602 -       printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
603 -              current->comm, current->pid, current_thread_info(), current,
604 -             field, current_thread_info()->tp_value);
605 +       printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
606 +               current->comm, task_pid_nr(current), current->xid,
607 +               current_thread_info(), current,
608 +               field, current_thread_info()->tp_value);
609         if (cpu_has_userlocal) {
610                 unsigned long tls;
611  
612 diff -NurpP --minimal linux-2.6.33.2/arch/mn10300/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/mn10300/mm/fault.c
613 --- linux-2.6.33.2/arch/mn10300/mm/fault.c      2009-09-10 15:25:39.000000000 +0200
614 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/mn10300/mm/fault.c      2010-02-25 12:02:16.000000000 +0100
615 @@ -339,7 +339,8 @@ no_context:
616  out_of_memory:
617         up_read(&mm->mmap_sem);
618         monitor_signal(regs);
619 -       printk(KERN_ALERT "VM: killing process %s\n", tsk->comm);
620 +       printk(KERN_ALERT "VM: killing process %s(%d:#%u)\n",
621 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
622         if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR)
623                 do_exit(SIGKILL);
624         goto no_context;
625 diff -NurpP --minimal linux-2.6.33.2/arch/parisc/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/parisc/Kconfig
626 --- linux-2.6.33.2/arch/parisc/Kconfig  2010-02-25 11:51:29.000000000 +0100
627 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/parisc/Kconfig  2010-02-25 12:02:16.000000000 +0100
628 @@ -293,6 +293,8 @@ source "fs/Kconfig"
629  
630  source "arch/parisc/Kconfig.debug"
631  
632 +source "kernel/vserver/Kconfig"
633 +
634  source "security/Kconfig"
635  
636  source "crypto/Kconfig"
637 diff -NurpP --minimal linux-2.6.33.2/arch/parisc/kernel/syscall_table.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/parisc/kernel/syscall_table.S
638 --- linux-2.6.33.2/arch/parisc/kernel/syscall_table.S   2010-02-25 11:51:29.000000000 +0100
639 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/parisc/kernel/syscall_table.S   2010-02-25 12:02:16.000000000 +0100
640 @@ -361,7 +361,7 @@
641         ENTRY_COMP(mbind)               /* 260 */
642         ENTRY_COMP(get_mempolicy)
643         ENTRY_COMP(set_mempolicy)
644 -       ENTRY_SAME(ni_syscall)  /* 263: reserved for vserver */
645 +       ENTRY_DIFF(vserver)
646         ENTRY_SAME(add_key)
647         ENTRY_SAME(request_key)         /* 265 */
648         ENTRY_SAME(keyctl)
649 diff -NurpP --minimal linux-2.6.33.2/arch/parisc/kernel/traps.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/parisc/kernel/traps.c
650 --- linux-2.6.33.2/arch/parisc/kernel/traps.c   2009-09-10 15:25:40.000000000 +0200
651 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/parisc/kernel/traps.c   2010-02-25 12:02:16.000000000 +0100
652 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
653                 if (err == 0)
654                         return; /* STFU */
655  
656 -               printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
657 -                       current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
658 +               printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
659 +                       current->comm, task_pid_nr(current), current->xid,
660 +                       str, err, regs->iaoq[0]);
661  #ifdef PRINT_USER_FAULTS
662                 /* XXX for debugging only */
663                 show_regs(regs);
664 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
665                 pdc_console_restart();
666         
667         if (err)
668 -               printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
669 -                       current->comm, task_pid_nr(current), str, err);
670 +               printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
671 +                       current->comm, task_pid_nr(current), current->xid, str, err);
672  
673         /* Wot's wrong wif bein' racy? */
674         if (current->thread.flags & PARISC_KERNEL_DEATH) {
675 diff -NurpP --minimal linux-2.6.33.2/arch/parisc/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/parisc/mm/fault.c
676 --- linux-2.6.33.2/arch/parisc/mm/fault.c       2009-09-10 15:25:40.000000000 +0200
677 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/parisc/mm/fault.c       2010-02-25 12:02:16.000000000 +0100
678 @@ -237,8 +237,9 @@ bad_area:
679  
680  #ifdef PRINT_USER_FAULTS
681                 printk(KERN_DEBUG "\n");
682 -               printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
683 -                   task_pid_nr(tsk), tsk->comm, code, address);
684 +               printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
685 +                   "command='%s' type=%lu address=0x%08lx\n",
686 +                   task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
687                 if (vma) {
688                         printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
689                                         vma->vm_start, vma->vm_end);
690 @@ -264,7 +265,8 @@ no_context:
691  
692    out_of_memory:
693         up_read(&mm->mmap_sem);
694 -       printk(KERN_CRIT "VM: killing process %s\n", current->comm);
695 +       printk(KERN_CRIT "VM: killing process %s(%d:#%u)\n",
696 +               current->comm, current->pid, current->xid);
697         if (user_mode(regs))
698                 do_group_exit(SIGKILL);
699         goto no_context;
700 diff -NurpP --minimal linux-2.6.33.2/arch/powerpc/include/asm/unistd.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/include/asm/unistd.h
701 --- linux-2.6.33.2/arch/powerpc/include/asm/unistd.h    2009-12-03 20:02:01.000000000 +0100
702 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/include/asm/unistd.h    2010-02-25 12:02:16.000000000 +0100
703 @@ -275,7 +275,7 @@
704  #endif
705  #define __NR_rtas              255
706  #define __NR_sys_debug_setcontext 256
707 -/* Number 257 is reserved for vserver */
708 +#define __NR_vserver           257
709  #define __NR_migrate_pages     258
710  #define __NR_mbind             259
711  #define __NR_get_mempolicy     260
712 diff -NurpP --minimal linux-2.6.33.2/arch/powerpc/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/Kconfig
713 --- linux-2.6.33.2/arch/powerpc/Kconfig 2010-02-25 11:51:29.000000000 +0100
714 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/Kconfig 2010-02-25 12:02:16.000000000 +0100
715 @@ -968,6 +968,8 @@ source "lib/Kconfig"
716  
717  source "arch/powerpc/Kconfig.debug"
718  
719 +source "kernel/vserver/Kconfig"
720 +
721  source "security/Kconfig"
722  
723  config KEYS_COMPAT
724 diff -NurpP --minimal linux-2.6.33.2/arch/powerpc/kernel/irq.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/kernel/irq.c
725 --- linux-2.6.33.2/arch/powerpc/kernel/irq.c    2010-02-25 11:51:31.000000000 +0100
726 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/kernel/irq.c    2010-02-25 12:02:16.000000000 +0100
727 @@ -54,6 +54,7 @@
728  #include <linux/pci.h>
729  #include <linux/debugfs.h>
730  #include <linux/perf_event.h>
731 +// #include <linux/vs_context.h>
732  
733  #include <asm/uaccess.h>
734  #include <asm/system.h>
735 diff -NurpP --minimal linux-2.6.33.2/arch/powerpc/kernel/process.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/kernel/process.c
736 --- linux-2.6.33.2/arch/powerpc/kernel/process.c        2010-02-25 11:51:31.000000000 +0100
737 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/kernel/process.c        2010-02-25 12:02:16.000000000 +0100
738 @@ -519,8 +519,9 @@ void show_regs(struct pt_regs * regs)
739  #else
740                 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
741  #endif
742 -       printk("TASK = %p[%d] '%s' THREAD: %p",
743 -              current, task_pid_nr(current), current->comm, task_thread_info(current));
744 +       printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
745 +              current, task_pid_nr(current), current->xid,
746 +              current->comm, task_thread_info(current));
747  
748  #ifdef CONFIG_SMP
749         printk(" CPU: %d", raw_smp_processor_id());
750 diff -NurpP --minimal linux-2.6.33.2/arch/powerpc/kernel/traps.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/kernel/traps.c
751 --- linux-2.6.33.2/arch/powerpc/kernel/traps.c  2010-02-25 11:51:31.000000000 +0100
752 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/kernel/traps.c  2010-02-25 12:02:16.000000000 +0100
753 @@ -918,8 +918,9 @@ void nonrecoverable_exception(struct pt_
754  
755  void trace_syscall(struct pt_regs *regs)
756  {
757 -       printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld    %s\n",
758 -              current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
759 +       printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld    %s\n",
760 +              current, task_pid_nr(current), current->xid,
761 +              regs->nip, regs->link, regs->gpr[0],
762                regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
763  }
764  
765 diff -NurpP --minimal linux-2.6.33.2/arch/powerpc/kernel/vdso.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/kernel/vdso.c
766 --- linux-2.6.33.2/arch/powerpc/kernel/vdso.c   2010-02-25 11:51:31.000000000 +0100
767 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/kernel/vdso.c   2010-02-25 12:02:16.000000000 +0100
768 @@ -23,6 +23,7 @@
769  #include <linux/security.h>
770  #include <linux/bootmem.h>
771  #include <linux/lmb.h>
772 +#include <linux/vs_memory.h>
773  
774  #include <asm/pgtable.h>
775  #include <asm/system.h>
776 diff -NurpP --minimal linux-2.6.33.2/arch/powerpc/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/mm/fault.c
777 --- linux-2.6.33.2/arch/powerpc/mm/fault.c      2010-02-25 11:51:31.000000000 +0100
778 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/powerpc/mm/fault.c      2010-02-25 12:02:16.000000000 +0100
779 @@ -364,7 +364,8 @@ out_of_memory:
780                 down_read(&mm->mmap_sem);
781                 goto survive;
782         }
783 -       printk("VM: killing process %s\n", current->comm);
784 +       printk("VM: killing process %s(%d:#%u)\n",
785 +               current->comm, current->pid, current->xid);
786         if (user_mode(regs))
787                 do_group_exit(SIGKILL);
788         return SIGKILL;
789 diff -NurpP --minimal linux-2.6.33.2/arch/s390/include/asm/tlb.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/s390/include/asm/tlb.h
790 --- linux-2.6.33.2/arch/s390/include/asm/tlb.h  2009-09-10 15:25:43.000000000 +0200
791 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/s390/include/asm/tlb.h  2010-02-25 12:02:16.000000000 +0100
792 @@ -23,6 +23,8 @@
793  
794  #include <linux/mm.h>
795  #include <linux/swap.h>
796 +#include <linux/vs_memory.h>
797 +
798  #include <asm/processor.h>
799  #include <asm/pgalloc.h>
800  #include <asm/smp.h>
801 diff -NurpP --minimal linux-2.6.33.2/arch/s390/include/asm/unistd.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/s390/include/asm/unistd.h
802 --- linux-2.6.33.2/arch/s390/include/asm/unistd.h       2010-02-25 11:51:32.000000000 +0100
803 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/s390/include/asm/unistd.h       2010-02-25 12:02:16.000000000 +0100
804 @@ -202,7 +202,7 @@
805  #define __NR_clock_gettime     (__NR_timer_create+6)
806  #define __NR_clock_getres      (__NR_timer_create+7)
807  #define __NR_clock_nanosleep   (__NR_timer_create+8)
808 -/* Number 263 is reserved for vserver */
809 +#define __NR_vserver           263
810  #define __NR_statfs64          265
811  #define __NR_fstatfs64         266
812  #define __NR_remap_file_pages  267
813 diff -NurpP --minimal linux-2.6.33.2/arch/s390/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/s390/Kconfig
814 --- linux-2.6.33.2/arch/s390/Kconfig    2010-02-25 11:51:32.000000000 +0100
815 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/s390/Kconfig    2010-02-25 12:02:16.000000000 +0100
816 @@ -629,6 +629,8 @@ source "fs/Kconfig"
817  
818  source "arch/s390/Kconfig.debug"
819  
820 +source "kernel/vserver/Kconfig"
821 +
822  source "security/Kconfig"
823  
824  source "crypto/Kconfig"
825 diff -NurpP --minimal linux-2.6.33.2/arch/s390/kernel/ptrace.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/s390/kernel/ptrace.c
826 --- linux-2.6.33.2/arch/s390/kernel/ptrace.c    2010-02-25 11:51:32.000000000 +0100
827 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/s390/kernel/ptrace.c    2010-02-25 12:02:16.000000000 +0100
828 @@ -36,6 +36,7 @@
829  #include <linux/regset.h>
830  #include <linux/tracehook.h>
831  #include <linux/seccomp.h>
832 +#include <linux/vs_base.h>
833  #include <trace/syscall.h>
834  #include <asm/compat.h>
835  #include <asm/segment.h>
836 diff -NurpP --minimal linux-2.6.33.2/arch/s390/kernel/syscalls.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/s390/kernel/syscalls.S
837 --- linux-2.6.33.2/arch/s390/kernel/syscalls.S  2009-12-03 20:02:03.000000000 +0100
838 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/s390/kernel/syscalls.S  2010-02-25 12:02:16.000000000 +0100
839 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
840  SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper)       /* 260 */
841  SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
842  SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
843 -NI_SYSCALL                                                     /* reserved for vserver */
844 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
845  SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
846  SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
847  SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
848 diff -NurpP --minimal linux-2.6.33.2/arch/sh/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/sh/Kconfig
849 --- linux-2.6.33.2/arch/sh/Kconfig      2010-02-25 11:51:32.000000000 +0100
850 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/sh/Kconfig      2010-02-25 12:02:16.000000000 +0100
851 @@ -860,6 +860,8 @@ source "fs/Kconfig"
852  
853  source "arch/sh/Kconfig.debug"
854  
855 +source "kernel/vserver/Kconfig"
856 +
857  source "security/Kconfig"
858  
859  source "crypto/Kconfig"
860 diff -NurpP --minimal linux-2.6.33.2/arch/sh/kernel/irq.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/sh/kernel/irq.c
861 --- linux-2.6.33.2/arch/sh/kernel/irq.c 2010-02-25 11:51:33.000000000 +0100
862 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/sh/kernel/irq.c 2010-02-25 12:02:16.000000000 +0100
863 @@ -12,6 +12,7 @@
864  #include <linux/kernel_stat.h>
865  #include <linux/seq_file.h>
866  #include <linux/ftrace.h>
867 +// #include <linux/vs_context.h>
868  #include <asm/processor.h>
869  #include <asm/machvec.h>
870  #include <asm/uaccess.h>
871 diff -NurpP --minimal linux-2.6.33.2/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/sh/kernel/vsyscall/vsyscall.c
872 --- linux-2.6.33.2/arch/sh/kernel/vsyscall/vsyscall.c   2009-03-24 14:18:42.000000000 +0100
873 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/sh/kernel/vsyscall/vsyscall.c   2010-02-25 12:02:16.000000000 +0100
874 @@ -19,6 +19,7 @@
875  #include <linux/elf.h>
876  #include <linux/sched.h>
877  #include <linux/err.h>
878 +#include <linux/vs_memory.h>
879  
880  /*
881   * Should the kernel map a VDSO page into processes and pass its
882 diff -NurpP --minimal linux-2.6.33.2/arch/sh/mm/fault_32.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/sh/mm/fault_32.c
883 --- linux-2.6.33.2/arch/sh/mm/fault_32.c        2009-12-03 20:02:14.000000000 +0100
884 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/sh/mm/fault_32.c        2010-02-25 12:02:16.000000000 +0100
885 @@ -292,7 +292,8 @@ out_of_memory:
886                 down_read(&mm->mmap_sem);
887                 goto survive;
888         }
889 -       printk("VM: killing process %s\n", tsk->comm);
890 +       printk("VM: killing process %s(%d:#%u)\n",
891 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
892         if (user_mode(regs))
893                 do_group_exit(SIGKILL);
894         goto no_context;
895 diff -NurpP --minimal linux-2.6.33.2/arch/sh/mm/tlbflush_64.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/sh/mm/tlbflush_64.c
896 --- linux-2.6.33.2/arch/sh/mm/tlbflush_64.c     2009-12-03 20:02:14.000000000 +0100
897 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/sh/mm/tlbflush_64.c     2010-02-25 12:02:16.000000000 +0100
898 @@ -306,7 +306,8 @@ out_of_memory:
899                 down_read(&mm->mmap_sem);
900                 goto survive;
901         }
902 -       printk("VM: killing process %s\n", tsk->comm);
903 +       printk("VM: killing process %s(%d:#%u)\n",
904 +               tsk->comm, task_pid_nr(tsk), tsk->xid);
905         if (user_mode(regs))
906                 do_group_exit(SIGKILL);
907         goto no_context;
908 diff -NurpP --minimal linux-2.6.33.2/arch/sparc/include/asm/tlb_64.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/sparc/include/asm/tlb_64.h
909 --- linux-2.6.33.2/arch/sparc/include/asm/tlb_64.h      2009-09-10 15:25:45.000000000 +0200
910 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/sparc/include/asm/tlb_64.h      2010-02-25 12:02:16.000000000 +0100
911 @@ -3,6 +3,7 @@
912  
913  #include <linux/swap.h>
914  #include <linux/pagemap.h>
915 +#include <linux/vs_memory.h>
916  #include <asm/pgalloc.h>
917  #include <asm/tlbflush.h>
918  #include <asm/mmu_context.h>
919 diff -NurpP --minimal linux-2.6.33.2/arch/sparc/include/asm/unistd.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/sparc/include/asm/unistd.h
920 --- linux-2.6.33.2/arch/sparc/include/asm/unistd.h      2010-02-25 11:51:34.000000000 +0100
921 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/sparc/include/asm/unistd.h      2010-02-25 12:02:16.000000000 +0100
922 @@ -335,7 +335,7 @@
923  #define __NR_timer_getoverrun  264
924  #define __NR_timer_delete      265
925  #define __NR_timer_create      266
926 -/* #define __NR_vserver                267 Reserved for VSERVER */
927 +#define __NR_vserver           267
928  #define __NR_io_setup          268
929  #define __NR_io_destroy                269
930  #define __NR_io_submit         270
931 diff -NurpP --minimal linux-2.6.33.2/arch/sparc/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/sparc/Kconfig
932 --- linux-2.6.33.2/arch/sparc/Kconfig   2010-02-25 11:51:33.000000000 +0100
933 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/sparc/Kconfig   2010-02-25 12:02:16.000000000 +0100
934 @@ -561,6 +561,8 @@ source "fs/Kconfig"
935  
936  source "arch/sparc/Kconfig.debug"
937  
938 +source "kernel/vserver/Kconfig"
939 +
940  source "security/Kconfig"
941  
942  source "crypto/Kconfig"
943 diff -NurpP --minimal linux-2.6.33.2/arch/sparc/kernel/systbls_32.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/sparc/kernel/systbls_32.S
944 --- linux-2.6.33.2/arch/sparc/kernel/systbls_32.S       2010-02-25 11:51:34.000000000 +0100
945 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/sparc/kernel/systbls_32.S       2010-02-25 12:02:16.000000000 +0100
946 @@ -70,7 +70,7 @@ sys_call_table:
947  /*250*/        .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
948  /*255*/        .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
949  /*260*/        .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
950 -/*265*/        .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
951 +/*265*/        .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
952  /*270*/        .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
953  /*275*/        .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
954  /*280*/        .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
955 diff -NurpP --minimal linux-2.6.33.2/arch/sparc/kernel/systbls_64.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/sparc/kernel/systbls_64.S
956 --- linux-2.6.33.2/arch/sparc/kernel/systbls_64.S       2010-02-25 11:51:34.000000000 +0100
957 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/sparc/kernel/systbls_64.S       2010-02-25 12:02:16.000000000 +0100
958 @@ -71,7 +71,7 @@ sys_call_table32:
959  /*250*/        .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
960         .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
961  /*260*/        .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
962 -       .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
963 +       .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
964  /*270*/        .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
965         .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
966  /*280*/        .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
967 @@ -146,7 +146,7 @@ sys_call_table:
968  /*250*/        .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
969         .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
970  /*260*/        .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
971 -       .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
972 +       .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
973  /*270*/        .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
974         .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
975  /*280*/        .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
976 diff -NurpP --minimal linux-2.6.33.2/arch/um/include/asm/tlb.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/include/asm/tlb.h
977 --- linux-2.6.33.2/arch/um/include/asm/tlb.h    2009-09-10 15:25:46.000000000 +0200
978 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/include/asm/tlb.h    2010-03-10 20:29:12.000000000 +0100
979 @@ -3,6 +3,7 @@
980  
981  #include <linux/pagemap.h>
982  #include <linux/swap.h>
983 +#include <linux/vs_memory.h>
984  #include <asm/percpu.h>
985  #include <asm/pgalloc.h>
986  #include <asm/tlbflush.h>
987 diff -NurpP --minimal linux-2.6.33.2/arch/um/include/shared/kern_constants.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/include/shared/kern_constants.h
988 --- linux-2.6.33.2/arch/um/include/shared/kern_constants.h      1970-01-01 01:00:00.000000000 +0100
989 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/include/shared/kern_constants.h      2010-03-10 20:12:12.000000000 +0100
990 @@ -0,0 +1 @@
991 +#include "../../../../include/generated/asm-offsets.h"
992 diff -NurpP --minimal linux-2.6.33.2/arch/um/include/shared/user_constants.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/include/shared/user_constants.h
993 --- linux-2.6.33.2/arch/um/include/shared/user_constants.h      1970-01-01 01:00:00.000000000 +0100
994 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/include/shared/user_constants.h      2010-03-10 20:12:12.000000000 +0100
995 @@ -0,0 +1,40 @@
996 +/*
997 + * DO NOT MODIFY.
998 + *
999 + * This file was generated by arch/um/Makefile
1000 + *
1001 + */
1002 +
1003 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2)    # */
1004 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err)    # */
1005 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno)      # */
1006 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long)     # */
1007 +#define HOST_RBX 5 /* RBX      # */
1008 +#define HOST_RCX 11 /* RCX     # */
1009 +#define HOST_RDI 14 /* RDI     # */
1010 +#define HOST_RSI 13 /* RSI     # */
1011 +#define HOST_RDX 12 /* RDX     # */
1012 +#define HOST_RBP 4 /* RBP      # */
1013 +#define HOST_RAX 10 /* RAX     # */
1014 +#define HOST_R8 9 /* R8        # */
1015 +#define HOST_R9 8 /* R9        # */
1016 +#define HOST_R10 7 /* R10      # */
1017 +#define HOST_R11 6 /* R11      # */
1018 +#define HOST_R12 3 /* R12      # */
1019 +#define HOST_R13 2 /* R13      # */
1020 +#define HOST_R14 1 /* R14      # */
1021 +#define HOST_R15 0 /* R15      # */
1022 +#define HOST_ORIG_RAX 15 /* ORIG_RAX   # */
1023 +#define HOST_CS 17 /* CS       # */
1024 +#define HOST_SS 20 /* SS       # */
1025 +#define HOST_EFLAGS 18 /* EFLAGS       # */
1026 +#define HOST_IP 16 /* RIP      # */
1027 +#define HOST_SP 19 /* RSP      # */
1028 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct)   # */
1029 +#define UM_POLLIN 1 /* POLLIN  # */
1030 +#define UM_POLLPRI 2 /* POLLPRI        # */
1031 +#define UM_POLLOUT 4 /* POLLOUT        # */
1032 +#define UM_PROT_READ 1 /* PROT_READ    # */
1033 +#define UM_PROT_WRITE 2 /* PROT_WRITE  # */
1034 +#define UM_PROT_EXEC 4 /* PROT_EXEC    # */
1035 +
1036 diff -NurpP --minimal linux-2.6.33.2/arch/um/Kconfig.rest linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/Kconfig.rest
1037 --- linux-2.6.33.2/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
1038 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/Kconfig.rest 2010-03-10 20:23:16.000000000 +0100
1039 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
1040  
1041  source "fs/Kconfig"
1042  
1043 +source "kernel/vserver/Kconfig"
1044 +
1045  source "security/Kconfig"
1046  
1047  source "crypto/Kconfig"
1048 diff -NurpP --minimal linux-2.6.33.2/arch/um/kernel/config.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/kernel/config.c
1049 --- linux-2.6.33.2/arch/um/kernel/config.c      1970-01-01 01:00:00.000000000 +0100
1050 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/kernel/config.c      2010-03-10 20:29:55.000000000 +0100
1051 @@ -0,0 +1,417 @@
1052 +/*
1053 + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
1054 + * Licensed under the GPL
1055 + */
1056 +
1057 +#include <stdio.h>
1058 +#include <stdlib.h>
1059 +#include "init.h"
1060 +
1061 +static __initdata const char *config[] = {
1062 +
1063 +"#\n",
1064 +"# Automatically generated make config: don't edit\n",
1065 +"# Linux kernel version: 2.6.33-vs2.3.0.36.29.1\n",
1066 +"# Wed Mar 10 20:29:46 2010\n",
1067 +"#\n",
1068 +"CONFIG_DEFCONFIG_LIST=\"arch/$ARCH/defconfig\"\n",
1069 +"CONFIG_GENERIC_HARDIRQS=y\n",
1070 +"CONFIG_UML=y\n",
1071 +"CONFIG_MMU=y\n",
1072 +"CONFIG_NO_IOMEM=y\n",
1073 +"# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set\n",
1074 +"CONFIG_LOCKDEP_SUPPORT=y\n",
1075 +"# CONFIG_STACKTRACE_SUPPORT is not set\n",
1076 +"CONFIG_GENERIC_CALIBRATE_DELAY=y\n",
1077 +"CONFIG_GENERIC_BUG=y\n",
1078 +"CONFIG_GENERIC_TIME=y\n",
1079 +"CONFIG_GENERIC_CLOCKEVENTS=y\n",
1080 +"CONFIG_IRQ_RELEASE_METHOD=y\n",
1081 +"CONFIG_HZ=100\n",
1082 +"\n",
1083 +"#\n",
1084 +"# UML-specific options\n",
1085 +"#\n",
1086 +"\n",
1087 +"#\n",
1088 +"# Host processor type and features\n",
1089 +"#\n",
1090 +"# CONFIG_M386 is not set\n",
1091 +"# CONFIG_M486 is not set\n",
1092 +"# CONFIG_M586 is not set\n",
1093 +"# CONFIG_M586TSC is not set\n",
1094 +"# CONFIG_M586MMX is not set\n",
1095 +"# CONFIG_M686 is not set\n",
1096 +"# CONFIG_MPENTIUMII is not set\n",
1097 +"# CONFIG_MPENTIUMIII is not set\n",
1098 +"# CONFIG_MPENTIUMM is not set\n",
1099 +"# CONFIG_MPENTIUM4 is not set\n",
1100 +"# CONFIG_MK6 is not set\n",
1101 +"# CONFIG_MK7 is not set\n",
1102 +"CONFIG_MK8=y\n",
1103 +"# CONFIG_MCRUSOE is not set\n",
1104 +"# CONFIG_MEFFICEON is not set\n",
1105 +"# CONFIG_MWINCHIPC6 is not set\n",
1106 +"# CONFIG_MWINCHIP3D is not set\n",
1107 +"# CONFIG_MGEODEGX1 is not set\n",
1108 +"# CONFIG_MGEODE_LX is not set\n",
1109 +"# CONFIG_MCYRIXIII is not set\n",
1110 +"# CONFIG_MVIAC3_2 is not set\n",
1111 +"# CONFIG_MVIAC7 is not set\n",
1112 +"# CONFIG_MPSC is not set\n",
1113 +"# CONFIG_MCORE2 is not set\n",
1114 +"# CONFIG_MATOM is not set\n",
1115 +"# CONFIG_GENERIC_CPU is not set\n",
1116 +"CONFIG_X86_CPU=y\n",
1117 +"CONFIG_X86_INTERNODE_CACHE_SHIFT=6\n",
1118 +"# CONFIG_X86_CMPXCHG is not set\n",
1119 +"CONFIG_X86_L1_CACHE_SHIFT=6\n",
1120 +"CONFIG_X86_WP_WORKS_OK=y\n",
1121 +"CONFIG_X86_INTEL_USERCOPY=y\n",
1122 +"CONFIG_X86_USE_PPRO_CHECKSUM=y\n",
1123 +"CONFIG_X86_TSC=y\n",
1124 +"CONFIG_X86_CMOV=y\n",
1125 +"CONFIG_X86_MINIMUM_CPU_FAMILY=3\n",
1126 +"CONFIG_CPU_SUP_INTEL=y\n",
1127 +"CONFIG_CPU_SUP_AMD=y\n",
1128 +"CONFIG_CPU_SUP_CENTAUR=y\n",
1129 +"CONFIG_UML_X86=y\n",
1130 +"CONFIG_64BIT=y\n",
1131 +"# CONFIG_X86_32 is not set\n",
1132 +"# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set\n",
1133 +"CONFIG_RWSEM_GENERIC_SPINLOCK=y\n",
1134 +"# CONFIG_ARCH_HAS_SC_SIGNALS is not set\n",
1135 +"# CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA is not set\n",
1136 +"CONFIG_SMP_BROKEN=y\n",
1137 +"CONFIG_GENERIC_HWEIGHT=y\n",
1138 +"# CONFIG_STATIC_LINK is not set\n",
1139 +"CONFIG_FLATMEM=y\n",
1140 +"CONFIG_FLAT_NODE_MEM_MAP=y\n",
1141 +"CONFIG_PAGEFLAGS_EXTENDED=y\n",
1142 +"CONFIG_SPLIT_PTLOCK_CPUS=4\n",
1143 +"CONFIG_PHYS_ADDR_T_64BIT=y\n",
1144 +"CONFIG_ZONE_DMA_FLAG=0\n",
1145 +"CONFIG_VIRT_TO_BUS=y\n",
1146 +"# CONFIG_KSM is not set\n",
1147 +"CONFIG_DEFAULT_MMAP_MIN_ADDR=4096\n",
1148 +"# CONFIG_NO_HZ is not set\n",
1149 +"# CONFIG_HIGH_RES_TIMERS is not set\n",
1150 +"CONFIG_GENERIC_CLOCKEVENTS_BUILD=y\n",
1151 +"CONFIG_LD_SCRIPT_DYN=y\n",
1152 +"# CONFIG_BINFMT_ELF is not set\n",
1153 +"# CONFIG_HAVE_AOUT is not set\n",
1154 +"# CONFIG_BINFMT_MISC is not set\n",
1155 +"# CONFIG_HOSTFS is not set\n",
1156 +"# CONFIG_MCONSOLE is not set\n",
1157 +"CONFIG_KERNEL_STACK_ORDER=1\n",
1158 +"\n",
1159 +"#\n",
1160 +"# General setup\n",
1161 +"#\n",
1162 +"# CONFIG_EXPERIMENTAL is not set\n",
1163 +"CONFIG_BROKEN_ON_SMP=y\n",
1164 +"CONFIG_INIT_ENV_ARG_LIMIT=128\n",
1165 +"CONFIG_LOCALVERSION=\"\"\n",
1166 +"# CONFIG_LOCALVERSION_AUTO is not set\n",
1167 +"# CONFIG_SWAP is not set\n",
1168 +"CONFIG_SYSVIPC=y\n",
1169 +"CONFIG_SYSVIPC_SYSCTL=y\n",
1170 +"# CONFIG_BSD_PROCESS_ACCT is not set\n",
1171 +"\n",
1172 +"#\n",
1173 +"# RCU Subsystem\n",
1174 +"#\n",
1175 +"CONFIG_TREE_RCU=y\n",
1176 +"# CONFIG_TREE_PREEMPT_RCU is not set\n",
1177 +"# CONFIG_TINY_RCU is not set\n",
1178 +"# CONFIG_RCU_TRACE is not set\n",
1179 +"CONFIG_RCU_FANOUT=64\n",
1180 +"# CONFIG_RCU_FANOUT_EXACT is not set\n",
1181 +"# CONFIG_TREE_RCU_TRACE is not set\n",
1182 +"# CONFIG_IKCONFIG is not set\n",
1183 +"CONFIG_LOG_BUF_SHIFT=17\n",
1184 +"# CONFIG_CGROUPS is not set\n",
1185 +"# CONFIG_SYSFS_DEPRECATED_V2 is not set\n",
1186 +"# CONFIG_RELAY is not set\n",
1187 +"CONFIG_NAMESPACES=y\n",
1188 +"CONFIG_UTS_NS=y\n",
1189 +"CONFIG_IPC_NS=y\n",
1190 +"CONFIG_USER_NS=y\n",
1191 +"# CONFIG_BLK_DEV_INITRD is not set\n",
1192 +"# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set\n",
1193 +"CONFIG_SYSCTL=y\n",
1194 +"CONFIG_ANON_INODES=y\n",
1195 +"# CONFIG_EMBEDDED is not set\n",
1196 +"CONFIG_UID16=y\n",
1197 +"CONFIG_SYSCTL_SYSCALL=y\n",
1198 +"CONFIG_KALLSYMS=y\n",
1199 +"# CONFIG_KALLSYMS_EXTRA_PASS is not set\n",
1200 +"CONFIG_HOTPLUG=y\n",
1201 +"CONFIG_PRINTK=y\n",
1202 +"CONFIG_BUG=y\n",
1203 +"CONFIG_ELF_CORE=y\n",
1204 +"CONFIG_BASE_FULL=y\n",
1205 +"CONFIG_FUTEX=y\n",
1206 +"CONFIG_EPOLL=y\n",
1207 +"CONFIG_SIGNALFD=y\n",
1208 +"CONFIG_TIMERFD=y\n",
1209 +"CONFIG_EVENTFD=y\n",
1210 +"CONFIG_SHMEM=y\n",
1211 +"CONFIG_AIO=y\n",
1212 +"\n",
1213 +"#\n",
1214 +"# Kernel Performance Events And Counters\n",
1215 +"#\n",
1216 +"CONFIG_VM_EVENT_COUNTERS=y\n",
1217 +"CONFIG_SLUB_DEBUG=y\n",
1218 +"# CONFIG_COMPAT_BRK is not set\n",
1219 +"# CONFIG_SLAB is not set\n",
1220 +"CONFIG_SLUB=y\n",
1221 +"# CONFIG_SLOB is not set\n",
1222 +"# CONFIG_PROFILING is not set\n",
1223 +"\n",
1224 +"#\n",
1225 +"# GCOV-based kernel profiling\n",
1226 +"#\n",
1227 +"# CONFIG_SLOW_WORK is not set\n",
1228 +"# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set\n",
1229 +"CONFIG_SLABINFO=y\n",
1230 +"CONFIG_RT_MUTEXES=y\n",
1231 +"CONFIG_BASE_SMALL=0\n",
1232 +"# CONFIG_MODULES is not set\n",
1233 +"CONFIG_BLOCK=y\n",
1234 +"# CONFIG_BLK_DEV_BSG is not set\n",
1235 +"# CONFIG_BLK_DEV_INTEGRITY is not set\n",
1236 +"\n",
1237 +"#\n",
1238 +"# IO Schedulers\n",
1239 +"#\n",
1240 +"CONFIG_IOSCHED_NOOP=y\n",
1241 +"# CONFIG_IOSCHED_DEADLINE is not set\n",
1242 +"# CONFIG_IOSCHED_CFQ is not set\n",
1243 +"# CONFIG_DEFAULT_DEADLINE is not set\n",
1244 +"# CONFIG_DEFAULT_CFQ is not set\n",
1245 +"CONFIG_DEFAULT_NOOP=y\n",
1246 +"CONFIG_DEFAULT_IOSCHED=\"noop\"\n",
1247 +"# CONFIG_INLINE_SPIN_TRYLOCK is not set\n",
1248 +"# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set\n",
1249 +"# CONFIG_INLINE_SPIN_LOCK is not set\n",
1250 +"# CONFIG_INLINE_SPIN_LOCK_BH is not set\n",
1251 +"# CONFIG_INLINE_SPIN_LOCK_IRQ is not set\n",
1252 +"# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set\n",
1253 +"CONFIG_INLINE_SPIN_UNLOCK=y\n",
1254 +"# CONFIG_INLINE_SPIN_UNLOCK_BH is not set\n",
1255 +"CONFIG_INLINE_SPIN_UNLOCK_IRQ=y\n",
1256 +"# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set\n",
1257 +"# CONFIG_INLINE_READ_TRYLOCK is not set\n",
1258 +"# CONFIG_INLINE_READ_LOCK is not set\n",
1259 +"# CONFIG_INLINE_READ_LOCK_BH is not set\n",
1260 +"# CONFIG_INLINE_READ_LOCK_IRQ is not set\n",
1261 +"# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set\n",
1262 +"CONFIG_INLINE_READ_UNLOCK=y\n",
1263 +"# CONFIG_INLINE_READ_UNLOCK_BH is not set\n",
1264 +"CONFIG_INLINE_READ_UNLOCK_IRQ=y\n",
1265 +"# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set\n",
1266 +"# CONFIG_INLINE_WRITE_TRYLOCK is not set\n",
1267 +"# CONFIG_INLINE_WRITE_LOCK is not set\n",
1268 +"# CONFIG_INLINE_WRITE_LOCK_BH is not set\n",
1269 +"# CONFIG_INLINE_WRITE_LOCK_IRQ is not set\n",
1270 +"# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set\n",
1271 +"CONFIG_INLINE_WRITE_UNLOCK=y\n",
1272 +"# CONFIG_INLINE_WRITE_UNLOCK_BH is not set\n",
1273 +"CONFIG_INLINE_WRITE_UNLOCK_IRQ=y\n",
1274 +"# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set\n",
1275 +"# CONFIG_MUTEX_SPIN_ON_OWNER is not set\n",
1276 +"# CONFIG_FREEZER is not set\n",
1277 +"# CONFIG_BLK_DEV is not set\n",
1278 +"\n",
1279 +"#\n",
1280 +"# Character Devices\n",
1281 +"#\n",
1282 +"# CONFIG_STDERR_CONSOLE is not set\n",
1283 +"CONFIG_STDIO_CONSOLE=y\n",
1284 +"# CONFIG_SSL is not set\n",
1285 +"# CONFIG_NULL_CHAN is not set\n",
1286 +"# CONFIG_PORT_CHAN is not set\n",
1287 +"# CONFIG_PTY_CHAN is not set\n",
1288 +"# CONFIG_TTY_CHAN is not set\n",
1289 +"# CONFIG_XTERM_CHAN is not set\n",
1290 +"CONFIG_NOCONFIG_CHAN=y\n",
1291 +"CONFIG_CON_ZERO_CHAN=\"fd:0,fd:1\"\n",
1292 +"CONFIG_CON_CHAN=\"xterm\"\n",
1293 +"CONFIG_SSL_CHAN=\"pty\"\n",
1294 +"# CONFIG_UNIX98_PTYS is not set\n",
1295 +"# CONFIG_LEGACY_PTYS is not set\n",
1296 +"# CONFIG_RAW_DRIVER is not set\n",
1297 +"# CONFIG_WATCHDOG is not set\n",
1298 +"# CONFIG_UML_SOUND is not set\n",
1299 +"# CONFIG_SOUND is not set\n",
1300 +"# CONFIG_SOUND_OSS_CORE is not set\n",
1301 +"# CONFIG_HOSTAUDIO is not set\n",
1302 +"# CONFIG_HW_RANDOM is not set\n",
1303 +"# CONFIG_UML_RANDOM is not set\n",
1304 +"# CONFIG_MMAPPER is not set\n",
1305 +"\n",
1306 +"#\n",
1307 +"# Generic Driver Options\n",
1308 +"#\n",
1309 +"CONFIG_UEVENT_HELPER_PATH=\"/sbin/hotplug\"\n",
1310 +"CONFIG_STANDALONE=y\n",
1311 +"# CONFIG_PREVENT_FIRMWARE_BUILD is not set\n",
1312 +"CONFIG_FW_LOADER=y\n",
1313 +"# CONFIG_FIRMWARE_IN_KERNEL is not set\n",
1314 +"CONFIG_EXTRA_FIRMWARE=\"\"\n",
1315 +"# CONFIG_SYS_HYPERVISOR is not set\n",
1316 +"# CONFIG_NET is not set\n",
1317 +"\n",
1318 +"#\n",
1319 +"# File systems\n",
1320 +"#\n",
1321 +"# CONFIG_EXT2_FS is not set\n",
1322 +"# CONFIG_EXT3_FS is not set\n",
1323 +"# CONFIG_EXT4_FS is not set\n",
1324 +"# CONFIG_REISERFS_FS is not set\n",
1325 +"# CONFIG_JFS_FS is not set\n",
1326 +"# CONFIG_FS_POSIX_ACL is not set\n",
1327 +"# CONFIG_XFS_FS is not set\n",
1328 +"CONFIG_FILE_LOCKING=y\n",
1329 +"# CONFIG_FSNOTIFY is not set\n",
1330 +"# CONFIG_DNOTIFY is not set\n",
1331 +"# CONFIG_INOTIFY is not set\n",
1332 +"# CONFIG_INOTIFY_USER is not set\n",
1333 +"# CONFIG_QUOTA is not set\n",
1334 +"# CONFIG_AUTOFS_FS is not set\n",
1335 +"# CONFIG_AUTOFS4_FS is not set\n",
1336 +"# CONFIG_FUSE_FS is not set\n",
1337 +"\n",
1338 +"#\n",
1339 +"# Caches\n",
1340 +"#\n",
1341 +"\n",
1342 +"#\n",
1343 +"# CD-ROM/DVD Filesystems\n",
1344 +"#\n",
1345 +"# CONFIG_ISO9660_FS is not set\n",
1346 +"# CONFIG_UDF_FS is not set\n",
1347 +"\n",
1348 +"#\n",
1349 +"# DOS/FAT/NT Filesystems\n",
1350 +"#\n",
1351 +"# CONFIG_MSDOS_FS is not set\n",
1352 +"# CONFIG_VFAT_FS is not set\n",
1353 +"# CONFIG_NTFS_FS is not set\n",
1354 +"\n",
1355 +"#\n",
1356 +"# Pseudo filesystems\n",
1357 +"#\n",
1358 +"CONFIG_PROC_FS=y\n",
1359 +"# CONFIG_PROC_KCORE is not set\n",
1360 +"CONFIG_PROC_SYSCTL=y\n",
1361 +"CONFIG_PROC_PAGE_MONITOR=y\n",
1362 +"CONFIG_SYSFS=y\n",
1363 +"# CONFIG_TMPFS is not set\n",
1364 +"# CONFIG_HUGETLB_PAGE is not set\n",
1365 +"# CONFIG_CONFIGFS_FS is not set\n",
1366 +"# CONFIG_MISC_FILESYSTEMS is not set\n",
1367 +"\n",
1368 +"#\n",
1369 +"# Partition Types\n",
1370 +"#\n",
1371 +"# CONFIG_PARTITION_ADVANCED is not set\n",
1372 +"CONFIG_MSDOS_PARTITION=y\n",
1373 +"# CONFIG_NLS is not set\n",
1374 +"\n",
1375 +"#\n",
1376 +"# Linux VServer\n",
1377 +"#\n",
1378 +"# CONFIG_VSERVER_AUTO_LBACK is not set\n",
1379 +"# CONFIG_VSERVER_COWBL is not set\n",
1380 +"# CONFIG_VSERVER_PROC_SECURE is not set\n",
1381 +"# CONFIG_VSERVER_HARDCPU is not set\n",
1382 +"# CONFIG_TAGGING_NONE is not set\n",
1383 +"# CONFIG_TAGGING_UID16 is not set\n",
1384 +"# CONFIG_TAGGING_GID16 is not set\n",
1385 +"CONFIG_TAGGING_ID24=y\n",
1386 +"# CONFIG_TAGGING_INTERN is not set\n",
1387 +"# CONFIG_TAG_NFSD is not set\n",
1388 +"# CONFIG_VSERVER_PRIVACY is not set\n",
1389 +"CONFIG_VSERVER_CONTEXTS=768\n",
1390 +"# CONFIG_VSERVER_WARN is not set\n",
1391 +"# CONFIG_VSERVER_DEBUG is not set\n",
1392 +"CONFIG_VSERVER=y\n",
1393 +"\n",
1394 +"#\n",
1395 +"# Security options\n",
1396 +"#\n",
1397 +"# CONFIG_KEYS is not set\n",
1398 +"# CONFIG_SECURITY is not set\n",
1399 +"# CONFIG_SECURITYFS is not set\n",
1400 +"# CONFIG_DEFAULT_SECURITY_SELINUX is not set\n",
1401 +"# CONFIG_DEFAULT_SECURITY_SMACK is not set\n",
1402 +"# CONFIG_DEFAULT_SECURITY_TOMOYO is not set\n",
1403 +"CONFIG_DEFAULT_SECURITY_DAC=y\n",
1404 +"CONFIG_DEFAULT_SECURITY=\"\"\n",
1405 +"# CONFIG_CRYPTO is not set\n",
1406 +"# CONFIG_BINARY_PRINTF is not set\n",
1407 +"\n",
1408 +"#\n",
1409 +"# Library routines\n",
1410 +"#\n",
1411 +"CONFIG_GENERIC_FIND_FIRST_BIT=y\n",
1412 +"CONFIG_GENERIC_FIND_NEXT_BIT=y\n",
1413 +"CONFIG_GENERIC_FIND_LAST_BIT=y\n",
1414 +"# CONFIG_CRC_CCITT is not set\n",
1415 +"# CONFIG_CRC16 is not set\n",
1416 +"# CONFIG_CRC_T10DIF is not set\n",
1417 +"# CONFIG_CRC_ITU_T is not set\n",
1418 +"# CONFIG_CRC32 is not set\n",
1419 +"# CONFIG_CRC7 is not set\n",
1420 +"# CONFIG_LIBCRC32C is not set\n",
1421 +"CONFIG_HAS_DMA=y\n",
1422 +"\n",
1423 +"#\n",
1424 +"# SCSI device support\n",
1425 +"#\n",
1426 +"# CONFIG_RAID_ATTRS is not set\n",
1427 +"# CONFIG_SCSI is not set\n",
1428 +"# CONFIG_SCSI_DMA is not set\n",
1429 +"# CONFIG_SCSI_NETLINK is not set\n",
1430 +"# CONFIG_MD is not set\n",
1431 +"# CONFIG_NEW_LEDS is not set\n",
1432 +"# CONFIG_INPUT is not set\n",
1433 +"\n",
1434 +"#\n",
1435 +"# Kernel hacking\n",
1436 +"#\n",
1437 +"# CONFIG_PRINTK_TIME is not set\n",
1438 +"# CONFIG_ENABLE_WARN_DEPRECATED is not set\n",
1439 +"# CONFIG_ENABLE_MUST_CHECK is not set\n",
1440 +"CONFIG_FRAME_WARN=2048\n",
1441 +"# CONFIG_STRIP_ASM_SYMS is not set\n",
1442 +"# CONFIG_UNUSED_SYMBOLS is not set\n",
1443 +"# CONFIG_DEBUG_FS is not set\n",
1444 +"# CONFIG_DEBUG_KERNEL is not set\n",
1445 +"# CONFIG_SLUB_DEBUG_ON is not set\n",
1446 +"# CONFIG_SLUB_STATS is not set\n",
1447 +"CONFIG_DEBUG_BUGVERBOSE=y\n",
1448 +"CONFIG_DEBUG_MEMORY_INIT=y\n",
1449 +"# CONFIG_RCU_CPU_STALL_DETECTOR is not set\n",
1450 +"# CONFIG_SYSCTL_SYSCALL_CHECK is not set\n",
1451 +"# CONFIG_SAMPLES is not set\n",
1452 +"# CONFIG_DEBUG_STACK_USAGE is not set\n",
1453 +""
1454 +};
1455 +
1456 +static int __init print_config(char *line, int *add)
1457 +{
1458 +       int i;
1459 +       for (i = 0; i < sizeof(config)/sizeof(config[0]); i++)
1460 +               printf("%s", config[i]);
1461 +       exit(0);
1462 +}
1463 +
1464 +__uml_setup("--showconfig", print_config,
1465 +"--showconfig\n"
1466 +"    Prints the config file that this UML binary was generated from.\n\n"
1467 +);
1468 +
1469 diff -NurpP --minimal linux-2.6.33.2/arch/um/kernel/config.tmp linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/kernel/config.tmp
1470 --- linux-2.6.33.2/arch/um/kernel/config.tmp    1970-01-01 01:00:00.000000000 +0100
1471 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/kernel/config.tmp    2010-03-10 20:29:55.000000000 +0100
1472 @@ -0,0 +1,390 @@
1473 +"#\n",
1474 +"# Automatically generated make config: don't edit\n",
1475 +"# Linux kernel version: 2.6.33-vs2.3.0.36.29.1\n",
1476 +"# Wed Mar 10 20:29:46 2010\n",
1477 +"#\n",
1478 +"CONFIG_DEFCONFIG_LIST=\"arch/$ARCH/defconfig\"\n",
1479 +"CONFIG_GENERIC_HARDIRQS=y\n",
1480 +"CONFIG_UML=y\n",
1481 +"CONFIG_MMU=y\n",
1482 +"CONFIG_NO_IOMEM=y\n",
1483 +"# CONFIG_TRACE_IRQFLAGS_SUPPORT is not set\n",
1484 +"CONFIG_LOCKDEP_SUPPORT=y\n",
1485 +"# CONFIG_STACKTRACE_SUPPORT is not set\n",
1486 +"CONFIG_GENERIC_CALIBRATE_DELAY=y\n",
1487 +"CONFIG_GENERIC_BUG=y\n",
1488 +"CONFIG_GENERIC_TIME=y\n",
1489 +"CONFIG_GENERIC_CLOCKEVENTS=y\n",
1490 +"CONFIG_IRQ_RELEASE_METHOD=y\n",
1491 +"CONFIG_HZ=100\n",
1492 +"\n",
1493 +"#\n",
1494 +"# UML-specific options\n",
1495 +"#\n",
1496 +"\n",
1497 +"#\n",
1498 +"# Host processor type and features\n",
1499 +"#\n",
1500 +"# CONFIG_M386 is not set\n",
1501 +"# CONFIG_M486 is not set\n",
1502 +"# CONFIG_M586 is not set\n",
1503 +"# CONFIG_M586TSC is not set\n",
1504 +"# CONFIG_M586MMX is not set\n",
1505 +"# CONFIG_M686 is not set\n",
1506 +"# CONFIG_MPENTIUMII is not set\n",
1507 +"# CONFIG_MPENTIUMIII is not set\n",
1508 +"# CONFIG_MPENTIUMM is not set\n",
1509 +"# CONFIG_MPENTIUM4 is not set\n",
1510 +"# CONFIG_MK6 is not set\n",
1511 +"# CONFIG_MK7 is not set\n",
1512 +"CONFIG_MK8=y\n",
1513 +"# CONFIG_MCRUSOE is not set\n",
1514 +"# CONFIG_MEFFICEON is not set\n",
1515 +"# CONFIG_MWINCHIPC6 is not set\n",
1516 +"# CONFIG_MWINCHIP3D is not set\n",
1517 +"# CONFIG_MGEODEGX1 is not set\n",
1518 +"# CONFIG_MGEODE_LX is not set\n",
1519 +"# CONFIG_MCYRIXIII is not set\n",
1520 +"# CONFIG_MVIAC3_2 is not set\n",
1521 +"# CONFIG_MVIAC7 is not set\n",
1522 +"# CONFIG_MPSC is not set\n",
1523 +"# CONFIG_MCORE2 is not set\n",
1524 +"# CONFIG_MATOM is not set\n",
1525 +"# CONFIG_GENERIC_CPU is not set\n",
1526 +"CONFIG_X86_CPU=y\n",
1527 +"CONFIG_X86_INTERNODE_CACHE_SHIFT=6\n",
1528 +"# CONFIG_X86_CMPXCHG is not set\n",
1529 +"CONFIG_X86_L1_CACHE_SHIFT=6\n",
1530 +"CONFIG_X86_WP_WORKS_OK=y\n",
1531 +"CONFIG_X86_INTEL_USERCOPY=y\n",
1532 +"CONFIG_X86_USE_PPRO_CHECKSUM=y\n",
1533 +"CONFIG_X86_TSC=y\n",
1534 +"CONFIG_X86_CMOV=y\n",
1535 +"CONFIG_X86_MINIMUM_CPU_FAMILY=3\n",
1536 +"CONFIG_CPU_SUP_INTEL=y\n",
1537 +"CONFIG_CPU_SUP_AMD=y\n",
1538 +"CONFIG_CPU_SUP_CENTAUR=y\n",
1539 +"CONFIG_UML_X86=y\n",
1540 +"CONFIG_64BIT=y\n",
1541 +"# CONFIG_X86_32 is not set\n",
1542 +"# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set\n",
1543 +"CONFIG_RWSEM_GENERIC_SPINLOCK=y\n",
1544 +"# CONFIG_ARCH_HAS_SC_SIGNALS is not set\n",
1545 +"# CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA is not set\n",
1546 +"CONFIG_SMP_BROKEN=y\n",
1547 +"CONFIG_GENERIC_HWEIGHT=y\n",
1548 +"# CONFIG_STATIC_LINK is not set\n",
1549 +"CONFIG_FLATMEM=y\n",
1550 +"CONFIG_FLAT_NODE_MEM_MAP=y\n",
1551 +"CONFIG_PAGEFLAGS_EXTENDED=y\n",
1552 +"CONFIG_SPLIT_PTLOCK_CPUS=4\n",
1553 +"CONFIG_PHYS_ADDR_T_64BIT=y\n",
1554 +"CONFIG_ZONE_DMA_FLAG=0\n",
1555 +"CONFIG_VIRT_TO_BUS=y\n",
1556 +"# CONFIG_KSM is not set\n",
1557 +"CONFIG_DEFAULT_MMAP_MIN_ADDR=4096\n",
1558 +"# CONFIG_NO_HZ is not set\n",
1559 +"# CONFIG_HIGH_RES_TIMERS is not set\n",
1560 +"CONFIG_GENERIC_CLOCKEVENTS_BUILD=y\n",
1561 +"CONFIG_LD_SCRIPT_DYN=y\n",
1562 +"# CONFIG_BINFMT_ELF is not set\n",
1563 +"# CONFIG_HAVE_AOUT is not set\n",
1564 +"# CONFIG_BINFMT_MISC is not set\n",
1565 +"# CONFIG_HOSTFS is not set\n",
1566 +"# CONFIG_MCONSOLE is not set\n",
1567 +"CONFIG_KERNEL_STACK_ORDER=1\n",
1568 +"\n",
1569 +"#\n",
1570 +"# General setup\n",
1571 +"#\n",
1572 +"# CONFIG_EXPERIMENTAL is not set\n",
1573 +"CONFIG_BROKEN_ON_SMP=y\n",
1574 +"CONFIG_INIT_ENV_ARG_LIMIT=128\n",
1575 +"CONFIG_LOCALVERSION=\"\"\n",
1576 +"# CONFIG_LOCALVERSION_AUTO is not set\n",
1577 +"# CONFIG_SWAP is not set\n",
1578 +"CONFIG_SYSVIPC=y\n",
1579 +"CONFIG_SYSVIPC_SYSCTL=y\n",
1580 +"# CONFIG_BSD_PROCESS_ACCT is not set\n",
1581 +"\n",
1582 +"#\n",
1583 +"# RCU Subsystem\n",
1584 +"#\n",
1585 +"CONFIG_TREE_RCU=y\n",
1586 +"# CONFIG_TREE_PREEMPT_RCU is not set\n",
1587 +"# CONFIG_TINY_RCU is not set\n",
1588 +"# CONFIG_RCU_TRACE is not set\n",
1589 +"CONFIG_RCU_FANOUT=64\n",
1590 +"# CONFIG_RCU_FANOUT_EXACT is not set\n",
1591 +"# CONFIG_TREE_RCU_TRACE is not set\n",
1592 +"# CONFIG_IKCONFIG is not set\n",
1593 +"CONFIG_LOG_BUF_SHIFT=17\n",
1594 +"# CONFIG_CGROUPS is not set\n",
1595 +"# CONFIG_SYSFS_DEPRECATED_V2 is not set\n",
1596 +"# CONFIG_RELAY is not set\n",
1597 +"CONFIG_NAMESPACES=y\n",
1598 +"CONFIG_UTS_NS=y\n",
1599 +"CONFIG_IPC_NS=y\n",
1600 +"CONFIG_USER_NS=y\n",
1601 +"# CONFIG_BLK_DEV_INITRD is not set\n",
1602 +"# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set\n",
1603 +"CONFIG_SYSCTL=y\n",
1604 +"CONFIG_ANON_INODES=y\n",
1605 +"# CONFIG_EMBEDDED is not set\n",
1606 +"CONFIG_UID16=y\n",
1607 +"CONFIG_SYSCTL_SYSCALL=y\n",
1608 +"CONFIG_KALLSYMS=y\n",
1609 +"# CONFIG_KALLSYMS_EXTRA_PASS is not set\n",
1610 +"CONFIG_HOTPLUG=y\n",
1611 +"CONFIG_PRINTK=y\n",
1612 +"CONFIG_BUG=y\n",
1613 +"CONFIG_ELF_CORE=y\n",
1614 +"CONFIG_BASE_FULL=y\n",
1615 +"CONFIG_FUTEX=y\n",
1616 +"CONFIG_EPOLL=y\n",
1617 +"CONFIG_SIGNALFD=y\n",
1618 +"CONFIG_TIMERFD=y\n",
1619 +"CONFIG_EVENTFD=y\n",
1620 +"CONFIG_SHMEM=y\n",
1621 +"CONFIG_AIO=y\n",
1622 +"\n",
1623 +"#\n",
1624 +"# Kernel Performance Events And Counters\n",
1625 +"#\n",
1626 +"CONFIG_VM_EVENT_COUNTERS=y\n",
1627 +"CONFIG_SLUB_DEBUG=y\n",
1628 +"# CONFIG_COMPAT_BRK is not set\n",
1629 +"# CONFIG_SLAB is not set\n",
1630 +"CONFIG_SLUB=y\n",
1631 +"# CONFIG_SLOB is not set\n",
1632 +"# CONFIG_PROFILING is not set\n",
1633 +"\n",
1634 +"#\n",
1635 +"# GCOV-based kernel profiling\n",
1636 +"#\n",
1637 +"# CONFIG_SLOW_WORK is not set\n",
1638 +"# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set\n",
1639 +"CONFIG_SLABINFO=y\n",
1640 +"CONFIG_RT_MUTEXES=y\n",
1641 +"CONFIG_BASE_SMALL=0\n",
1642 +"# CONFIG_MODULES is not set\n",
1643 +"CONFIG_BLOCK=y\n",
1644 +"# CONFIG_BLK_DEV_BSG is not set\n",
1645 +"# CONFIG_BLK_DEV_INTEGRITY is not set\n",
1646 +"\n",
1647 +"#\n",
1648 +"# IO Schedulers\n",
1649 +"#\n",
1650 +"CONFIG_IOSCHED_NOOP=y\n",
1651 +"# CONFIG_IOSCHED_DEADLINE is not set\n",
1652 +"# CONFIG_IOSCHED_CFQ is not set\n",
1653 +"# CONFIG_DEFAULT_DEADLINE is not set\n",
1654 +"# CONFIG_DEFAULT_CFQ is not set\n",
1655 +"CONFIG_DEFAULT_NOOP=y\n",
1656 +"CONFIG_DEFAULT_IOSCHED=\"noop\"\n",
1657 +"# CONFIG_INLINE_SPIN_TRYLOCK is not set\n",
1658 +"# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set\n",
1659 +"# CONFIG_INLINE_SPIN_LOCK is not set\n",
1660 +"# CONFIG_INLINE_SPIN_LOCK_BH is not set\n",
1661 +"# CONFIG_INLINE_SPIN_LOCK_IRQ is not set\n",
1662 +"# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set\n",
1663 +"CONFIG_INLINE_SPIN_UNLOCK=y\n",
1664 +"# CONFIG_INLINE_SPIN_UNLOCK_BH is not set\n",
1665 +"CONFIG_INLINE_SPIN_UNLOCK_IRQ=y\n",
1666 +"# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set\n",
1667 +"# CONFIG_INLINE_READ_TRYLOCK is not set\n",
1668 +"# CONFIG_INLINE_READ_LOCK is not set\n",
1669 +"# CONFIG_INLINE_READ_LOCK_BH is not set\n",
1670 +"# CONFIG_INLINE_READ_LOCK_IRQ is not set\n",
1671 +"# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set\n",
1672 +"CONFIG_INLINE_READ_UNLOCK=y\n",
1673 +"# CONFIG_INLINE_READ_UNLOCK_BH is not set\n",
1674 +"CONFIG_INLINE_READ_UNLOCK_IRQ=y\n",
1675 +"# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set\n",
1676 +"# CONFIG_INLINE_WRITE_TRYLOCK is not set\n",
1677 +"# CONFIG_INLINE_WRITE_LOCK is not set\n",
1678 +"# CONFIG_INLINE_WRITE_LOCK_BH is not set\n",
1679 +"# CONFIG_INLINE_WRITE_LOCK_IRQ is not set\n",
1680 +"# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set\n",
1681 +"CONFIG_INLINE_WRITE_UNLOCK=y\n",
1682 +"# CONFIG_INLINE_WRITE_UNLOCK_BH is not set\n",
1683 +"CONFIG_INLINE_WRITE_UNLOCK_IRQ=y\n",
1684 +"# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set\n",
1685 +"# CONFIG_MUTEX_SPIN_ON_OWNER is not set\n",
1686 +"# CONFIG_FREEZER is not set\n",
1687 +"# CONFIG_BLK_DEV is not set\n",
1688 +"\n",
1689 +"#\n",
1690 +"# Character Devices\n",
1691 +"#\n",
1692 +"# CONFIG_STDERR_CONSOLE is not set\n",
1693 +"CONFIG_STDIO_CONSOLE=y\n",
1694 +"# CONFIG_SSL is not set\n",
1695 +"# CONFIG_NULL_CHAN is not set\n",
1696 +"# CONFIG_PORT_CHAN is not set\n",
1697 +"# CONFIG_PTY_CHAN is not set\n",
1698 +"# CONFIG_TTY_CHAN is not set\n",
1699 +"# CONFIG_XTERM_CHAN is not set\n",
1700 +"CONFIG_NOCONFIG_CHAN=y\n",
1701 +"CONFIG_CON_ZERO_CHAN=\"fd:0,fd:1\"\n",
1702 +"CONFIG_CON_CHAN=\"xterm\"\n",
1703 +"CONFIG_SSL_CHAN=\"pty\"\n",
1704 +"# CONFIG_UNIX98_PTYS is not set\n",
1705 +"# CONFIG_LEGACY_PTYS is not set\n",
1706 +"# CONFIG_RAW_DRIVER is not set\n",
1707 +"# CONFIG_WATCHDOG is not set\n",
1708 +"# CONFIG_UML_SOUND is not set\n",
1709 +"# CONFIG_SOUND is not set\n",
1710 +"# CONFIG_SOUND_OSS_CORE is not set\n",
1711 +"# CONFIG_HOSTAUDIO is not set\n",
1712 +"# CONFIG_HW_RANDOM is not set\n",
1713 +"# CONFIG_UML_RANDOM is not set\n",
1714 +"# CONFIG_MMAPPER is not set\n",
1715 +"\n",
1716 +"#\n",
1717 +"# Generic Driver Options\n",
1718 +"#\n",
1719 +"CONFIG_UEVENT_HELPER_PATH=\"/sbin/hotplug\"\n",
1720 +"CONFIG_STANDALONE=y\n",
1721 +"# CONFIG_PREVENT_FIRMWARE_BUILD is not set\n",
1722 +"CONFIG_FW_LOADER=y\n",
1723 +"# CONFIG_FIRMWARE_IN_KERNEL is not set\n",
1724 +"CONFIG_EXTRA_FIRMWARE=\"\"\n",
1725 +"# CONFIG_SYS_HYPERVISOR is not set\n",
1726 +"# CONFIG_NET is not set\n",
1727 +"\n",
1728 +"#\n",
1729 +"# File systems\n",
1730 +"#\n",
1731 +"# CONFIG_EXT2_FS is not set\n",
1732 +"# CONFIG_EXT3_FS is not set\n",
1733 +"# CONFIG_EXT4_FS is not set\n",
1734 +"# CONFIG_REISERFS_FS is not set\n",
1735 +"# CONFIG_JFS_FS is not set\n",
1736 +"# CONFIG_FS_POSIX_ACL is not set\n",
1737 +"# CONFIG_XFS_FS is not set\n",
1738 +"CONFIG_FILE_LOCKING=y\n",
1739 +"# CONFIG_FSNOTIFY is not set\n",
1740 +"# CONFIG_DNOTIFY is not set\n",
1741 +"# CONFIG_INOTIFY is not set\n",
1742 +"# CONFIG_INOTIFY_USER is not set\n",
1743 +"# CONFIG_QUOTA is not set\n",
1744 +"# CONFIG_AUTOFS_FS is not set\n",
1745 +"# CONFIG_AUTOFS4_FS is not set\n",
1746 +"# CONFIG_FUSE_FS is not set\n",
1747 +"\n",
1748 +"#\n",
1749 +"# Caches\n",
1750 +"#\n",
1751 +"\n",
1752 +"#\n",
1753 +"# CD-ROM/DVD Filesystems\n",
1754 +"#\n",
1755 +"# CONFIG_ISO9660_FS is not set\n",
1756 +"# CONFIG_UDF_FS is not set\n",
1757 +"\n",
1758 +"#\n",
1759 +"# DOS/FAT/NT Filesystems\n",
1760 +"#\n",
1761 +"# CONFIG_MSDOS_FS is not set\n",
1762 +"# CONFIG_VFAT_FS is not set\n",
1763 +"# CONFIG_NTFS_FS is not set\n",
1764 +"\n",
1765 +"#\n",
1766 +"# Pseudo filesystems\n",
1767 +"#\n",
1768 +"CONFIG_PROC_FS=y\n",
1769 +"# CONFIG_PROC_KCORE is not set\n",
1770 +"CONFIG_PROC_SYSCTL=y\n",
1771 +"CONFIG_PROC_PAGE_MONITOR=y\n",
1772 +"CONFIG_SYSFS=y\n",
1773 +"# CONFIG_TMPFS is not set\n",
1774 +"# CONFIG_HUGETLB_PAGE is not set\n",
1775 +"# CONFIG_CONFIGFS_FS is not set\n",
1776 +"# CONFIG_MISC_FILESYSTEMS is not set\n",
1777 +"\n",
1778 +"#\n",
1779 +"# Partition Types\n",
1780 +"#\n",
1781 +"# CONFIG_PARTITION_ADVANCED is not set\n",
1782 +"CONFIG_MSDOS_PARTITION=y\n",
1783 +"# CONFIG_NLS is not set\n",
1784 +"\n",
1785 +"#\n",
1786 +"# Linux VServer\n",
1787 +"#\n",
1788 +"# CONFIG_VSERVER_AUTO_LBACK is not set\n",
1789 +"# CONFIG_VSERVER_COWBL is not set\n",
1790 +"# CONFIG_VSERVER_PROC_SECURE is not set\n",
1791 +"# CONFIG_VSERVER_HARDCPU is not set\n",
1792 +"# CONFIG_TAGGING_NONE is not set\n",
1793 +"# CONFIG_TAGGING_UID16 is not set\n",
1794 +"# CONFIG_TAGGING_GID16 is not set\n",
1795 +"CONFIG_TAGGING_ID24=y\n",
1796 +"# CONFIG_TAGGING_INTERN is not set\n",
1797 +"# CONFIG_TAG_NFSD is not set\n",
1798 +"# CONFIG_VSERVER_PRIVACY is not set\n",
1799 +"CONFIG_VSERVER_CONTEXTS=768\n",
1800 +"# CONFIG_VSERVER_WARN is not set\n",
1801 +"# CONFIG_VSERVER_DEBUG is not set\n",
1802 +"CONFIG_VSERVER=y\n",
1803 +"\n",
1804 +"#\n",
1805 +"# Security options\n",
1806 +"#\n",
1807 +"# CONFIG_KEYS is not set\n",
1808 +"# CONFIG_SECURITY is not set\n",
1809 +"# CONFIG_SECURITYFS is not set\n",
1810 +"# CONFIG_DEFAULT_SECURITY_SELINUX is not set\n",
1811 +"# CONFIG_DEFAULT_SECURITY_SMACK is not set\n",
1812 +"# CONFIG_DEFAULT_SECURITY_TOMOYO is not set\n",
1813 +"CONFIG_DEFAULT_SECURITY_DAC=y\n",
1814 +"CONFIG_DEFAULT_SECURITY=\"\"\n",
1815 +"# CONFIG_CRYPTO is not set\n",
1816 +"# CONFIG_BINARY_PRINTF is not set\n",
1817 +"\n",
1818 +"#\n",
1819 +"# Library routines\n",
1820 +"#\n",
1821 +"CONFIG_GENERIC_FIND_FIRST_BIT=y\n",
1822 +"CONFIG_GENERIC_FIND_NEXT_BIT=y\n",
1823 +"CONFIG_GENERIC_FIND_LAST_BIT=y\n",
1824 +"# CONFIG_CRC_CCITT is not set\n",
1825 +"# CONFIG_CRC16 is not set\n",
1826 +"# CONFIG_CRC_T10DIF is not set\n",
1827 +"# CONFIG_CRC_ITU_T is not set\n",
1828 +"# CONFIG_CRC32 is not set\n",
1829 +"# CONFIG_CRC7 is not set\n",
1830 +"# CONFIG_LIBCRC32C is not set\n",
1831 +"CONFIG_HAS_DMA=y\n",
1832 +"\n",
1833 +"#\n",
1834 +"# SCSI device support\n",
1835 +"#\n",
1836 +"# CONFIG_RAID_ATTRS is not set\n",
1837 +"# CONFIG_SCSI is not set\n",
1838 +"# CONFIG_SCSI_DMA is not set\n",
1839 +"# CONFIG_SCSI_NETLINK is not set\n",
1840 +"# CONFIG_MD is not set\n",
1841 +"# CONFIG_NEW_LEDS is not set\n",
1842 +"# CONFIG_INPUT is not set\n",
1843 +"\n",
1844 +"#\n",
1845 +"# Kernel hacking\n",
1846 +"#\n",
1847 +"# CONFIG_PRINTK_TIME is not set\n",
1848 +"# CONFIG_ENABLE_WARN_DEPRECATED is not set\n",
1849 +"# CONFIG_ENABLE_MUST_CHECK is not set\n",
1850 +"CONFIG_FRAME_WARN=2048\n",
1851 +"# CONFIG_STRIP_ASM_SYMS is not set\n",
1852 +"# CONFIG_UNUSED_SYMBOLS is not set\n",
1853 +"# CONFIG_DEBUG_FS is not set\n",
1854 +"# CONFIG_DEBUG_KERNEL is not set\n",
1855 +"# CONFIG_SLUB_DEBUG_ON is not set\n",
1856 +"# CONFIG_SLUB_STATS is not set\n",
1857 +"CONFIG_DEBUG_BUGVERBOSE=y\n",
1858 +"CONFIG_DEBUG_MEMORY_INIT=y\n",
1859 +"# CONFIG_RCU_CPU_STALL_DETECTOR is not set\n",
1860 +"# CONFIG_SYSCTL_SYSCALL_CHECK is not set\n",
1861 +"# CONFIG_SAMPLES is not set\n",
1862 +"# CONFIG_DEBUG_STACK_USAGE is not set\n",
1863 diff -NurpP --minimal linux-2.6.33.2/arch/um/kernel/vmlinux.lds linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/kernel/vmlinux.lds
1864 --- linux-2.6.33.2/arch/um/kernel/vmlinux.lds   1970-01-01 01:00:00.000000000 +0100
1865 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/um/kernel/vmlinux.lds   2010-03-10 20:12:32.000000000 +0100
1866 @@ -0,0 +1,547 @@
1867 +
1868 +
1869 +/*
1870 + * Automatically generated C config: don't edit
1871 + * Linux kernel version: 2.6.33-vs2.3.0.36.29.1
1872 + * Wed Mar 10 20:12:10 2010
1873 + */
1874 +KERNEL_STACK_SIZE = 4096 * (1 << 1);
1875 +/*
1876 + * Helper macros to support writing architecture specific
1877 + * linker scripts.
1878 + *
1879 + * A minimal linker scripts has following content:
1880 + * [This is a sample, architectures may have special requiriements]
1881 + *
1882 + * OUTPUT_FORMAT(...)
1883 + * OUTPUT_ARCH(...)
1884 + * ENTRY(...)
1885 + * SECTIONS
1886 + * {
1887 + *     . = START;
1888 + *     __init_begin = .;
1889 + *     HEAD_TEXT_SECTION
1890 + *     INIT_TEXT_SECTION(PAGE_SIZE)
1891 + *     INIT_DATA_SECTION(...)
1892 + *     PERCPU(PAGE_SIZE)
1893 + *     __init_end = .;
1894 + *
1895 + *     _stext = .;
1896 + *     TEXT_SECTION = 0
1897 + *     _etext = .;
1898 + *
1899 + *      _sdata = .;
1900 + *     RO_DATA_SECTION(PAGE_SIZE)
1901 + *     RW_DATA_SECTION(...)
1902 + *     _edata = .;
1903 + *
1904 + *     EXCEPTION_TABLE(...)
1905 + *     NOTES
1906 + *
1907 + *     BSS_SECTION(0, 0, 0)
1908 + *     _end = .;
1909 + *
1910 + *     STABS_DEBUG
1911 + *     DWARF_DEBUG
1912 + *
1913 + *     DISCARDS                // must be the last
1914 + * }
1915 + *
1916 + * [__init_begin, __init_end] is the init section that may be freed after init
1917 + * [_stext, _etext] is the text section
1918 + * [_sdata, _edata] is the data section
1919 + *
1920 + * Some of the included output section have their own set of constants.
1921 + * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
1922 + *               [__nosave_begin, __nosave_end] for the nosave data
1923 + */
1924 +
1925 +
1926 +
1927 +
1928 +
1929 +
1930 +
1931 +/* Align . to a 8 byte boundary equals to maximum function alignment. */
1932 +
1933 +
1934 +/* The actual configuration determine if the init/exit sections
1935 + * are handled as text/data or they can be discarded (which
1936 + * often happens at runtime)
1937 + */
1938 +/* .data section */
1939 +/*
1940 + * Data section helpers
1941 + */
1942 +/*
1943 + * Read only Data
1944 + */
1945 +/* RODATA & RO_DATA provided for backward compatibility.
1946 + * All archs are supposed to use RO_DATA() */
1947 +/* .text section. Map to function alignment to avoid address changes
1948 + * during second ld run in second ld pass when generating System.map */
1949 +/* sched.text is aling to function alignment to secure we have same
1950 + * address even at second ld pass when generating System.map */
1951 +/* spinlock.text is aling to function alignment to secure we have same
1952 + * address even at second ld pass when generating System.map */
1953 +/* Section used for early init (in .S files) */
1954 +/*
1955 + * Exception table
1956 + */
1957 +/*
1958 + * Init task
1959 + */
1960 +/* init and exit section handling */
1961 +/*
1962 + * bss (Block Started by Symbol) - uninitialized data
1963 + * zeroed during startup
1964 + */
1965 +/*
1966 + * DWARF debug sections.
1967 + * Symbols in the DWARF debugging sections are relative to
1968 + * the beginning of the section so we begin them at 0.
1969 + */
1970 +  /* Stabs debugging sections.  */
1971 +/*
1972 + * Default discarded sections.
1973 + *
1974 + * Some archs want to discard exit text/data at runtime rather than
1975 + * link time due to cross-section references such as alt instructions,
1976 + * bug table, eh_frame, etc.  DISCARDS must be the last of output
1977 + * section definitions so that such archs put those in earlier section
1978 + * definitions.
1979 + */
1980 +/**
1981 + * PERCPU_VADDR - define output section for percpu area
1982 + * @vaddr: explicit base address (optional)
1983 + * @phdr: destination PHDR (optional)
1984 + *
1985 + * Macro which expands to output section for percpu area.  If @vaddr
1986 + * is not blank, it specifies explicit base address and all percpu
1987 + * symbols will be offset from the given address.  If blank, @vaddr
1988 + * always equals @laddr + LOAD_OFFSET.
1989 + *
1990 + * @phdr defines the output PHDR to use if not blank.  Be warned that
1991 + * output PHDR is sticky.  If @phdr is specified, the next output
1992 + * section in the linker script will go there too.  @phdr should have
1993 + * a leading colon.
1994 + *
1995 + * Note that this macros defines __per_cpu_load as an absolute symbol.
1996 + * If there is no need to put the percpu section at a predetermined
1997 + * address, use PERCPU().
1998 + */
1999 +/**
2000 + * PERCPU - define output section for percpu area, simple version
2001 + * @align: required alignment
2002 + *
2003 + * Align to @align and outputs output section for percpu area.  This
2004 + * macro doesn't maniuplate @vaddr or @phdr and __per_cpu_load and
2005 + * __per_cpu_start will be identical.
2006 + *
2007 + * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except
2008 + * that __per_cpu_load is defined as a relative symbol against
2009 + * .data.percpu which is required for relocatable x86_32
2010 + * configuration.
2011 + */
2012 +/*
2013 + * Definition of the high level *_SECTION macros
2014 + * They will fit only a subset of the architectures
2015 + */
2016 +/*
2017 + * Writeable data.
2018 + * All sections are combined in a single .data section.
2019 + * The sections following CONSTRUCTORS are arranged so their
2020 + * typical alignment matches.
2021 + * A cacheline is typical/always less than a PAGE_SIZE so
2022 + * the sections that has this restriction (or similar)
2023 + * is located before the ones requiring PAGE_SIZE alignment.
2024 + * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
2025 + * matches the requirment of PAGE_ALIGNED_DATA.
2026 + *
2027 + * use 0 as page_align if page_aligned data is not used */
2028 +/*
2029 + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
2030 + * Copyright 2003 PathScale, Inc.
2031 + * Licensed under the GPL
2032 + */
2033 +/* const.h: Macros for dealing with constants.  */
2034 +/* Some constant macros are used in both assembler and
2035 + * C code.  Therefore we cannot annotate them always with
2036 + * 'UL' and other type specifiers unilaterally.  We
2037 + * use the following macros to deal with this.
2038 + *
2039 + * Similarly, _AT() will cast an expression with a type in C, but
2040 + * leave it unchanged in asm.
2041 + */
2042 +/* PAGE_SHIFT determines the page size */
2043 +OUTPUT_FORMAT(elf64-x86-64)
2044 +OUTPUT_ARCH(i386:x86-64)
2045 +ENTRY(_start)
2046 +jiffies = jiffies_64;
2047 +SECTIONS
2048 +{
2049 +  PROVIDE (__executable_start = 0x60000000);
2050 +  . = 0x60000000 + SIZEOF_HEADERS;
2051 +  .interp : { *(.interp) }
2052 +  __binary_start = .;
2053 +  . = ALIGN(4096); /* Init code and data */
2054 +  _text = .;
2055 +  _stext = .;
2056 +  __init_begin = .;
2057 +  . = ALIGN((1 << 12)); .init.text : AT(ADDR(.init.text) - 0) { _sinittext = .; *(.init.text) *(.cpuinit.text) *(.meminit.text) _einittext = .; }
2058 +  . = ALIGN((1 << 12));
2059 +  /* Read-only sections, merged into text segment: */
2060 +  .hash : { *(.hash) }
2061 +  .gnu.hash : { *(.gnu.hash) }
2062 +  .dynsym : { *(.dynsym) }
2063 +  .dynstr : { *(.dynstr) }
2064 +  .gnu.version : { *(.gnu.version) }
2065 +  .gnu.version_d : { *(.gnu.version_d) }
2066 +  .gnu.version_r : { *(.gnu.version_r) }
2067 +  .rel.init : { *(.rel.init) }
2068 +  .rela.init : { *(.rela.init) }
2069 +  .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
2070 +  .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
2071 +  .rel.fini : { *(.rel.fini) }
2072 +  .rela.fini : { *(.rela.fini) }
2073 +  .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
2074 +  .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
2075 +  .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
2076 +  .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
2077 +  .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
2078 +  .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
2079 +  .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
2080 +  .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
2081 +  .rel.ctors : { *(.rel.ctors) }
2082 +  .rela.ctors : { *(.rela.ctors) }
2083 +  .rel.dtors : { *(.rel.dtors) }
2084 +  .rela.dtors : { *(.rela.dtors) }
2085 +  .rel.got : { *(.rel.got) }
2086 +  .rela.got : { *(.rela.got) }
2087 +  .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
2088 +  .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
2089 +  .rel.plt : { *(.rel.plt) }
2090 +  .rela.plt : { *(.rela.plt) }
2091 +  .init : {
2092 +    KEEP (*(.init))
2093 +  } =0x90909090
2094 +  .plt : { *(.plt) }
2095 +  .text : {
2096 +    . = ALIGN(8); *(.text.hot) *(.text) *(.ref.text) *(.devinit.text) *(.devexit.text) *(.text.unlikely)
2097 +    . = ALIGN(8); __sched_text_start = .; *(.sched.text) __sched_text_end = .;
2098 +    . = ALIGN(8); __lock_text_start = .; *(.spinlock.text) __lock_text_end = .;
2099 +    *(.fixup)
2100 +    *(.stub .text.* .gnu.linkonce.t.*)
2101 +    /* .gnu.warning sections are handled specially by elf32.em.  */
2102 +    *(.gnu.warning)
2103 +    . = ALIGN((1 << 12));
2104 +  } =0x90909090
2105 +  . = ALIGN((1 << 12));
2106 +  .syscall_stub : {
2107 + __syscall_stub_start = .;
2108 + *(.__syscall_stub*)
2109 + __syscall_stub_end = .;
2110 +  }
2111 +  .fini : {
2112 +    KEEP (*(.fini))
2113 +  } =0x90909090
2114 +  .kstrtab : { *(.kstrtab) }
2115 +/*
2116 + * Helper macros to support writing architecture specific
2117 + * linker scripts.
2118 + *
2119 + * A minimal linker scripts has following content:
2120 + * [This is a sample, architectures may have special requiriements]
2121 + *
2122 + * OUTPUT_FORMAT(...)
2123 + * OUTPUT_ARCH(...)
2124 + * ENTRY(...)
2125 + * SECTIONS
2126 + * {
2127 + *     . = START;
2128 + *     __init_begin = .;
2129 + *     HEAD_TEXT_SECTION
2130 + *     INIT_TEXT_SECTION(PAGE_SIZE)
2131 + *     INIT_DATA_SECTION(...)
2132 + *     PERCPU(PAGE_SIZE)
2133 + *     __init_end = .;
2134 + *
2135 + *     _stext = .;
2136 + *     TEXT_SECTION = 0
2137 + *     _etext = .;
2138 + *
2139 + *      _sdata = .;
2140 + *     RO_DATA_SECTION(PAGE_SIZE)
2141 + *     RW_DATA_SECTION(...)
2142 + *     _edata = .;
2143 + *
2144 + *     EXCEPTION_TABLE(...)
2145 + *     NOTES
2146 + *
2147 + *     BSS_SECTION(0, 0, 0)
2148 + *     _end = .;
2149 + *
2150 + *     STABS_DEBUG
2151 + *     DWARF_DEBUG
2152 + *
2153 + *     DISCARDS                // must be the last
2154 + * }
2155 + *
2156 + * [__init_begin, __init_end] is the init section that may be freed after init
2157 + * [_stext, _etext] is the text section
2158 + * [_sdata, _edata] is the data section
2159 + *
2160 + * Some of the included output section have their own set of constants.
2161 + * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
2162 + *               [__nosave_begin, __nosave_end] for the nosave data
2163 + */
2164 +/* Align . to a 8 byte boundary equals to maximum function alignment. */
2165 +/* The actual configuration determine if the init/exit sections
2166 + * are handled as text/data or they can be discarded (which
2167 + * often happens at runtime)
2168 + */
2169 +/* .data section */
2170 +/*
2171 + * Data section helpers
2172 + */
2173 +/*
2174 + * Read only Data
2175 + */
2176 +/* RODATA & RO_DATA provided for backward compatibility.
2177 + * All archs are supposed to use RO_DATA() */
2178 +/* .text section. Map to function alignment to avoid address changes
2179 + * during second ld run in second ld pass when generating System.map */
2180 +/* sched.text is aling to function alignment to secure we have same
2181 + * address even at second ld pass when generating System.map */
2182 +/* spinlock.text is aling to function alignment to secure we have same
2183 + * address even at second ld pass when generating System.map */
2184 +/* Section used for early init (in .S files) */
2185 +/*
2186 + * Exception table
2187 + */
2188 +/*
2189 + * Init task
2190 + */
2191 +/* init and exit section handling */
2192 +/*
2193 + * bss (Block Started by Symbol) - uninitialized data
2194 + * zeroed during startup
2195 + */
2196 +/*
2197 + * DWARF debug sections.
2198 + * Symbols in the DWARF debugging sections are relative to
2199 + * the beginning of the section so we begin them at 0.
2200 + */
2201 +  /* Stabs debugging sections.  */
2202 +/*
2203 + * Default discarded sections.
2204 + *
2205 + * Some archs want to discard exit text/data at runtime rather than
2206 + * link time due to cross-section references such as alt instructions,
2207 + * bug table, eh_frame, etc.  DISCARDS must be the last of output
2208 + * section definitions so that such archs put those in earlier section
2209 + * definitions.
2210 + */
2211 +/**
2212 + * PERCPU_VADDR - define output section for percpu area
2213 + * @vaddr: explicit base address (optional)
2214 + * @phdr: destination PHDR (optional)
2215 + *
2216 + * Macro which expands to output section for percpu area.  If @vaddr
2217 + * is not blank, it specifies explicit base address and all percpu
2218 + * symbols will be offset from the given address.  If blank, @vaddr
2219 + * always equals @laddr + LOAD_OFFSET.
2220 + *
2221 + * @phdr defines the output PHDR to use if not blank.  Be warned that
2222 + * output PHDR is sticky.  If @phdr is specified, the next output
2223 + * section in the linker script will go there too.  @phdr should have
2224 + * a leading colon.
2225 + *
2226 + * Note that this macros defines __per_cpu_load as an absolute symbol.
2227 + * If there is no need to put the percpu section at a predetermined
2228 + * address, use PERCPU().
2229 + */
2230 +/**
2231 + * PERCPU - define output section for percpu area, simple version
2232 + * @align: required alignment
2233 + *
2234 + * Align to @align and outputs output section for percpu area.  This
2235 + * macro doesn't maniuplate @vaddr or @phdr and __per_cpu_load and
2236 + * __per_cpu_start will be identical.
2237 + *
2238 + * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except
2239 + * that __per_cpu_load is defined as a relative symbol against
2240 + * .data.percpu which is required for relocatable x86_32
2241 + * configuration.
2242 + */
2243 +/*
2244 + * Definition of the high level *_SECTION macros
2245 + * They will fit only a subset of the architectures
2246 + */
2247 +/*
2248 + * Writeable data.
2249 + * All sections are combined in a single .data section.
2250 + * The sections following CONSTRUCTORS are arranged so their
2251 + * typical alignment matches.
2252 + * A cacheline is typical/always less than a PAGE_SIZE so
2253 + * the sections that has this restriction (or similar)
2254 + * is located before the ones requiring PAGE_SIZE alignment.
2255 + * NOSAVE_DATA starts and ends with a PAGE_SIZE alignment which
2256 + * matches the requirment of PAGE_ALIGNED_DATA.
2257 + *
2258 + * use 0 as page_align if page_aligned data is not used */
2259 +  .fini : { *(.fini) } =0x9090
2260 +  _etext = .;
2261 +  PROVIDE (etext = .);
2262 +  . = ALIGN(4096);
2263 +  _sdata = .;
2264 +  PROVIDE (sdata = .);
2265 +  . = 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));
2266 +  .unprotected : { *(.unprotected) }
2267 +  . = ALIGN(4096);
2268 +  PROVIDE (_unprotected_end = .);
2269 +  . = ALIGN(4096);
2270 +  .note : { *(.note.*) }
2271 +  . = ALIGN(0); __ex_table : AT(ADDR(__ex_table) - 0) { __start___ex_table = .; *(__ex_table) __stop___ex_table = .; }
2272 +  . = ALIGN(8); __bug_table : AT(ADDR(__bug_table) - 0) { __start___bug_table = .; *(__bug_table) __stop___bug_table = .; }
2273 +  .uml.setup.init : {
2274 + __uml_setup_start = .;
2275 + *(.uml.setup.init)
2276 + __uml_setup_end = .;
2277 +  }
2278 +  .uml.help.init : {
2279 + __uml_help_start = .;
2280 + *(.uml.help.init)
2281 + __uml_help_end = .;
2282 +  }
2283 +  .uml.postsetup.init : {
2284 + __uml_postsetup_start = .;
2285 + *(.uml.postsetup.init)
2286 + __uml_postsetup_end = .;
2287 +  }
2288 +  .init.setup : {
2289 + . = ALIGN(0); __setup_start = .; *(.init.setup) __setup_end = .;
2290 +  }
2291 +  . = 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 = .; }
2292 +  .initcall.init : {
2293 + __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 = .;
2294 +  }
2295 +  .con_initcall.init : {
2296 + __con_initcall_start = .; *(.con_initcall.init) __con_initcall_end = .;
2297 +  }
2298 +  .uml.initcall.init : {
2299 + __uml_initcall_start = .;
2300 + *(.uml.initcall.init)
2301 + __uml_initcall_end = .;
2302 +  }
2303 +  __init_end = .;
2304 +  .security_initcall.init : AT(ADDR(.security_initcall.init) - 0) { __security_initcall_start = .; *(.security_initcall.init) __security_initcall_end = .; }
2305 +  .exitcall : {
2306 + __exitcall_begin = .;
2307 + *(.exitcall.exit)
2308 + __exitcall_end = .;
2309 +  }
2310 +  .uml.exitcall : {
2311 + __uml_exitcall_begin = .;
2312 + *(.uml.exitcall.exit)
2313 + __uml_exitcall_end = .;
2314 +  }
2315 +  . = ALIGN(4);
2316 +  .altinstructions : {
2317 + __alt_instructions = .;
2318 + *(.altinstructions)
2319 + __alt_instructions_end = .;
2320 +  }
2321 +  .altinstr_replacement : { *(.altinstr_replacement) }
2322 +  /* .exit.text is discard at runtime, not link time, to deal with references
2323 +     from .altinstructions and .eh_frame */
2324 +  .exit.text : { *(.exit.text) }
2325 +  .exit.data : { *(.exit.data) }
2326 +  .preinit_array : {
2327 + __preinit_array_start = .;
2328 + *(.preinit_array)
2329 + __preinit_array_end = .;
2330 +  }
2331 +  .init_array : {
2332 + __init_array_start = .;
2333 + *(.init_array)
2334 + __init_array_end = .;
2335 +  }
2336 +  .fini_array : {
2337 + __fini_array_start = .;
2338 + *(.fini_array)
2339 + __fini_array_end = .;
2340 +  }
2341 +   . = ALIGN(4096);
2342 +  .init.ramfs : {
2343 +
2344 +  }
2345 +  init.data : { *(.init.data) *(.cpuinit.data) *(.meminit.data) *(.init.rodata) *(.cpuinit.rodata) *(.meminit.rodata) }
2346 +  /* Ensure the __preinit_array_start label is properly aligned.  We
2347 +     could instead move the label definition inside the section, but
2348 +     the linker would then create the section even if it turns out to
2349 +     be empty, which isn't pretty.  */
2350 +  . = ALIGN(32 / 8);
2351 +  .preinit_array : { *(.preinit_array) }
2352 +  .init_array : { *(.init_array) }
2353 +  .fini_array : { *(.fini_array) }
2354 +  .data : {
2355 +    . = ALIGN(KERNEL_STACK_SIZE); *(.data.init_task)
2356 +    . = ALIGN(KERNEL_STACK_SIZE);
2357 +    *(.data.init_irqstack)
2358 +    *(.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 = .;
2359 +    *(.data.* .gnu.linkonce.d.*)
2360 +    SORT(CONSTRUCTORS)
2361 +  }
2362 +  .data1 : { *(.data1) }
2363 +  .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
2364 +  .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
2365 +  .eh_frame : { KEEP (*(.eh_frame)) }
2366 +  .gcc_except_table : { *(.gcc_except_table) }
2367 +  .dynamic : { *(.dynamic) }
2368 +  .ctors : {
2369 +    /* gcc uses crtbegin.o to find the start of
2370 +       the constructors, so we make sure it is
2371 +       first.  Because this is a wildcard, it
2372 +       doesn't matter if the user does not
2373 +       actually link against crtbegin.o; the
2374 +       linker won't look for a file to match a
2375 +       wildcard.  The wildcard also means that it
2376 +       doesn't matter which directory crtbegin.o
2377 +       is in.  */
2378 +    KEEP (*crtbegin.o(.ctors))
2379 +    /* We don't want to include the .ctor section from
2380 +       from the crtend.o file until after the sorted ctors.
2381 +       The .ctor section from the crtend file contains the
2382 +       end of ctors marker and it must be last */
2383 +    KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
2384 +    KEEP (*(SORT(.ctors.*)))
2385 +    KEEP (*(.ctors))
2386 +  }
2387 +  .dtors : {
2388 +    KEEP (*crtbegin.o(.dtors))
2389 +    KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
2390 +    KEEP (*(SORT(.dtors.*)))
2391 +    KEEP (*(.dtors))
2392 +  }
2393 +  .jcr : { KEEP (*(.jcr)) }
2394 +  .got : { *(.got.plt) *(.got) }
2395 +  _edata = .;
2396 +  PROVIDE (edata = .);
2397 +  .bss : {
2398 +   __bss_start = .;
2399 +   *(.dynbss)
2400 +   *(.bss .bss.* .gnu.linkonce.b.*)
2401 +   *(COMMON)
2402 +   /* Align here to ensure that the .bss section occupies space up to
2403 +      _end.  Align after .bss to ensure correct alignment even if the
2404 +      .bss section disappears because there are no input sections.  */
2405 +   . = ALIGN(32 / 8);
2406 +  . = ALIGN(32 / 8);
2407 +  }
2408 +  _end = .;
2409 +  PROVIDE (end = .);
2410 +  .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) }
2411 +  .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) }
2412 +  /DISCARD/ : { *(.exit.text) *(.cpuexit.text) *(.memexit.text) *(.exit.data) *(.cpuexit.data) *(.cpuexit.rodata) *(.memexit.data) *(.memexit.rodata) *(.exitcall.exit) *(.discard) }
2413 +}
2414 diff -NurpP --minimal linux-2.6.33.2/arch/x86/ia32/ia32entry.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/x86/ia32/ia32entry.S
2415 --- linux-2.6.33.2/arch/x86/ia32/ia32entry.S    2010-02-25 11:51:34.000000000 +0100
2416 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/x86/ia32/ia32entry.S    2010-02-25 12:02:16.000000000 +0100
2417 @@ -777,7 +777,7 @@ ia32_sys_call_table:
2418         .quad sys_tgkill                /* 270 */
2419         .quad compat_sys_utimes
2420         .quad sys32_fadvise64_64
2421 -       .quad quiet_ni_syscall  /* sys_vserver */
2422 +       .quad sys32_vserver
2423         .quad sys_mbind
2424         .quad compat_sys_get_mempolicy  /* 275 */
2425         .quad sys_set_mempolicy
2426 diff -NurpP --minimal linux-2.6.33.2/arch/x86/include/asm/unistd_64.h linux-2.6.33.2-vs2.3.0.36.30.4/arch/x86/include/asm/unistd_64.h
2427 --- linux-2.6.33.2/arch/x86/include/asm/unistd_64.h     2010-02-25 11:51:34.000000000 +0100
2428 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/x86/include/asm/unistd_64.h     2010-02-25 12:02:16.000000000 +0100
2429 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
2430  #define __NR_utimes                            235
2431  __SYSCALL(__NR_utimes, sys_utimes)
2432  #define __NR_vserver                           236
2433 -__SYSCALL(__NR_vserver, sys_ni_syscall)
2434 +__SYSCALL(__NR_vserver, sys_vserver)
2435  #define __NR_mbind                             237
2436  __SYSCALL(__NR_mbind, sys_mbind)
2437  #define __NR_set_mempolicy                     238
2438 diff -NurpP --minimal linux-2.6.33.2/arch/x86/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/arch/x86/Kconfig
2439 --- linux-2.6.33.2/arch/x86/Kconfig     2010-02-25 11:51:34.000000000 +0100
2440 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/x86/Kconfig     2010-02-25 12:02:16.000000000 +0100
2441 @@ -2083,6 +2083,8 @@ source "fs/Kconfig"
2442  
2443  source "arch/x86/Kconfig.debug"
2444  
2445 +source "kernel/vserver/Kconfig"
2446 +
2447  source "security/Kconfig"
2448  
2449  source "crypto/Kconfig"
2450 diff -NurpP --minimal linux-2.6.33.2/arch/x86/kernel/syscall_table_32.S linux-2.6.33.2-vs2.3.0.36.30.4/arch/x86/kernel/syscall_table_32.S
2451 --- linux-2.6.33.2/arch/x86/kernel/syscall_table_32.S   2010-02-25 11:51:35.000000000 +0100
2452 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/x86/kernel/syscall_table_32.S   2010-02-25 12:02:16.000000000 +0100
2453 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
2454         .long sys_tgkill        /* 270 */
2455         .long sys_utimes
2456         .long sys_fadvise64_64
2457 -       .long sys_ni_syscall    /* sys_vserver */
2458 +       .long sys_vserver
2459         .long sys_mbind
2460         .long sys_get_mempolicy
2461         .long sys_set_mempolicy
2462 diff -NurpP --minimal linux-2.6.33.2/arch/xtensa/mm/fault.c linux-2.6.33.2-vs2.3.0.36.30.4/arch/xtensa/mm/fault.c
2463 --- linux-2.6.33.2/arch/xtensa/mm/fault.c       2009-09-10 15:25:48.000000000 +0200
2464 +++ linux-2.6.33.2-vs2.3.0.36.30.4/arch/xtensa/mm/fault.c       2010-02-25 12:02:16.000000000 +0100
2465 @@ -151,7 +151,8 @@ out_of_memory:
2466                 down_read(&mm->mmap_sem);
2467                 goto survive;
2468         }
2469 -       printk("VM: killing process %s\n", current->comm);
2470 +       printk("VM: killing process %s(%d:#%u)\n",
2471 +               current->comm, task_pid_nr(current), current->xid);
2472         if (user_mode(regs))
2473                 do_group_exit(SIGKILL);
2474         bad_page_fault(regs, address, SIGKILL);
2475 diff -NurpP --minimal linux-2.6.33.2/Documentation/vserver/debug.txt linux-2.6.33.2-vs2.3.0.36.30.4/Documentation/vserver/debug.txt
2476 --- linux-2.6.33.2/Documentation/vserver/debug.txt      1970-01-01 01:00:00.000000000 +0100
2477 +++ linux-2.6.33.2-vs2.3.0.36.30.4/Documentation/vserver/debug.txt      2010-02-25 12:02:16.000000000 +0100
2478 @@ -0,0 +1,154 @@
2479 +
2480 +debug_cvirt:
2481 +
2482 + 2   4 "vx_map_tgid: %p/%llx: %d -> %d"
2483 +       "vx_rmap_tgid: %p/%llx: %d -> %d"
2484 +
2485 +debug_dlim:
2486 +
2487 + 0   1 "ALLOC (%p,#%d)%c inode (%d)"
2488 +       "FREE  (%p,#%d)%c inode"
2489 + 1   2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
2490 +       "FREE  (%p,#%d)%c %lld bytes"
2491 + 2   4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
2492 + 3   8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
2493 +       "ext3_has_free_blocks(%p): free=%lu, root=%lu"
2494 +       "rcu_free_dl_info(%p)"
2495 + 4  10 "alloc_dl_info(%p,%d) = %p"
2496 +       "dealloc_dl_info(%p)"
2497 +       "get_dl_info(%p[#%d.%d])"
2498 +       "put_dl_info(%p[#%d.%d])"
2499 + 5  20 "alloc_dl_info(%p,%d)*"
2500 + 6  40 "__hash_dl_info: %p[#%d]"
2501 +       "__unhash_dl_info: %p[#%d]"
2502 + 7  80 "locate_dl_info(%p,#%d) = %p"
2503 +
2504 +debug_misc:
2505 +
2506 + 0   1 "destroy_dqhash: %p [#0x%08x] c=%d"
2507 +       "new_dqhash: %p [#0x%08x]"
2508 +       "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
2509 +       "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
2510 +       "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
2511 +       "vroot_get_real_bdev not set"
2512 + 1   2 "cow_break_link(»%s«)"
2513 +       "temp copy Â»%s«"
2514 + 2   4 "dentry_open(new): %p"
2515 +       "dentry_open(old): %p"
2516 +       "lookup_create(new): %p"
2517 +       "old path Â»%s«"
2518 +       "path_lookup(old): %d"
2519 +       "vfs_create(new): %d"
2520 +       "vfs_rename: %d"
2521 +       "vfs_sendfile: %d"
2522 + 3   8 "fput(new_file=%p[#%d])"
2523 +       "fput(old_file=%p[#%d])"
2524 + 4  10 "vx_info_kill(%p[#%d],%d,%d) = %d"
2525 +       "vx_info_kill(%p[#%d],%d,%d)*"
2526 + 5  20 "vs_reboot(%p[#%d],%d)"
2527 + 6  40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
2528 +
2529 +debug_net:
2530 +
2531 + 2   4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
2532 + 3   8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
2533 +       "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
2534 + 4  10 "ip_route_connect(%p) %p,%p;%lx"
2535 + 5  20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
2536 + 6  40 "sk,egf: %p [#%d] (from %d)"
2537 +       "sk,egn: %p [#%d] (from %d)"
2538 +       "sk,req: %p [#%d] (from %d)"
2539 +       "sk: %p [#%d] (from %d)"
2540 +       "tw: %p [#%d] (from %d)"
2541 + 7  80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
2542 +       "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
2543 +
2544 +debug_nid:
2545 +
2546 + 0   1 "__lookup_nx_info(#%u): %p[#%u]"
2547 +       "alloc_nx_info(%d) = %p"
2548 +       "create_nx_info(%d) (dynamic rejected)"
2549 +       "create_nx_info(%d) = %p (already there)"
2550 +       "create_nx_info(%d) = %p (new)"
2551 +       "dealloc_nx_info(%p)"
2552 + 1   2 "alloc_nx_info(%d)*"
2553 +       "create_nx_info(%d)*"
2554 + 2   4 "get_nx_info(%p[#%d.%d])"
2555 +       "put_nx_info(%p[#%d.%d])"
2556 + 3   8 "claim_nx_info(%p[#%d.%d.%d]) %p"
2557 +       "clr_nx_info(%p[#%d.%d])"
2558 +       "init_nx_info(%p[#%d.%d])"
2559 +       "release_nx_info(%p[#%d.%d.%d]) %p"
2560 +       "set_nx_info(%p[#%d.%d])"
2561 + 4  10 "__hash_nx_info: %p[#%d]"
2562 +       "__nx_dynamic_id: [#%d]"
2563 +       "__unhash_nx_info: %p[#%d.%d.%d]"
2564 + 5  20 "moved task %p into nxi:%p[#%d]"
2565 +       "nx_migrate_task(%p,%p[#%d.%d.%d])"
2566 +       "task_get_nx_info(%p)"
2567 + 6  40 "nx_clear_persistent(%p[#%d])"
2568 +
2569 +debug_quota:
2570 +
2571 + 0   1 "quota_sync_dqh(%p,%d) discard inode %p"
2572 + 1   2 "quota_sync_dqh(%p,%d)"
2573 +       "sync_dquots(%p,%d)"
2574 +       "sync_dquots_dqh(%p,%d)"
2575 + 3   8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
2576 +
2577 +debug_switch:
2578 +
2579 + 0   1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
2580 + 1   2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
2581 + 4  10 "%s: (%s %s) returned %s with %d"
2582 +
2583 +debug_tag:
2584 +
2585 + 7  80 "dx_parse_tag(»%s«): %d:#%d"
2586 +       "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
2587 +
2588 +debug_xid:
2589 +
2590 + 0   1 "__lookup_vx_info(#%u): %p[#%u]"
2591 +       "alloc_vx_info(%d) = %p"
2592 +       "alloc_vx_info(%d)*"
2593 +       "create_vx_info(%d) (dynamic rejected)"
2594 +       "create_vx_info(%d) = %p (already there)"
2595 +       "create_vx_info(%d) = %p (new)"
2596 +       "dealloc_vx_info(%p)"
2597 +       "loc_vx_info(%d) = %p (found)"
2598 +       "loc_vx_info(%d) = %p (new)"
2599 +       "loc_vx_info(%d) = %p (not available)"
2600 + 1   2 "create_vx_info(%d)*"
2601 +       "loc_vx_info(%d)*"
2602 + 2   4 "get_vx_info(%p[#%d.%d])"
2603 +       "put_vx_info(%p[#%d.%d])"
2604 + 3   8 "claim_vx_info(%p[#%d.%d.%d]) %p"
2605 +       "clr_vx_info(%p[#%d.%d])"
2606 +       "init_vx_info(%p[#%d.%d])"
2607 +       "release_vx_info(%p[#%d.%d.%d]) %p"
2608 +       "set_vx_info(%p[#%d.%d])"
2609 + 4  10 "__hash_vx_info: %p[#%d]"
2610 +       "__unhash_vx_info: %p[#%d.%d.%d]"
2611 +       "__vx_dynamic_id: [#%d]"
2612 + 5  20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
2613 +       "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
2614 +       "moved task %p into vxi:%p[#%d]"
2615 +       "task_get_vx_info(%p)"
2616 +       "vx_migrate_task(%p,%p[#%d.%d])"
2617 + 6  40 "vx_clear_persistent(%p[#%d])"
2618 +       "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
2619 +       "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
2620 +       "vx_set_persistent(%p[#%d])"
2621 +       "vx_set_reaper(%p[#%d],%p[#%d,%d])"
2622 + 7  80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
2623 +
2624 +
2625 +debug_limit:
2626 +
2627 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
2628 +       "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
2629 +
2630 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
2631 +       "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
2632 +       "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
2633 diff -NurpP --minimal linux-2.6.33.2/drivers/block/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/drivers/block/Kconfig
2634 --- linux-2.6.33.2/drivers/block/Kconfig        2010-02-25 11:51:36.000000000 +0100
2635 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/block/Kconfig        2010-02-25 12:02:16.000000000 +0100
2636 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
2637  
2638  source "drivers/block/drbd/Kconfig"
2639  
2640 +config BLK_DEV_VROOT
2641 +       tristate "Virtual Root device support"
2642 +       depends on QUOTACTL
2643 +       ---help---
2644 +         Saying Y here will allow you to use quota/fs ioctls on a shared
2645 +         partition within a virtual server without compromising security.
2646 +
2647  config BLK_DEV_NBD
2648         tristate "Network block device support"
2649         depends on NET
2650 diff -NurpP --minimal linux-2.6.33.2/drivers/block/loop.c linux-2.6.33.2-vs2.3.0.36.30.4/drivers/block/loop.c
2651 --- linux-2.6.33.2/drivers/block/loop.c 2009-12-03 20:02:19.000000000 +0100
2652 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/block/loop.c 2010-02-25 12:02:16.000000000 +0100
2653 @@ -74,6 +74,7 @@
2654  #include <linux/gfp.h>
2655  #include <linux/kthread.h>
2656  #include <linux/splice.h>
2657 +#include <linux/vs_context.h>
2658  
2659  #include <asm/uaccess.h>
2660  
2661 @@ -812,6 +813,7 @@ static int loop_set_fd(struct loop_devic
2662         lo->lo_blocksize = lo_blocksize;
2663         lo->lo_device = bdev;
2664         lo->lo_flags = lo_flags;
2665 +       lo->lo_xid = vx_current_xid();
2666         lo->lo_backing_file = file;
2667         lo->transfer = transfer_none;
2668         lo->ioctl = NULL;
2669 @@ -937,6 +939,7 @@ static int loop_clr_fd(struct loop_devic
2670         lo->lo_encrypt_key_size = 0;
2671         lo->lo_flags = 0;
2672         lo->lo_thread = NULL;
2673 +       lo->lo_xid = 0;
2674         memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2675         memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2676         memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2677 @@ -971,7 +974,7 @@ loop_set_status(struct loop_device *lo, 
2678  
2679         if (lo->lo_encrypt_key_size &&
2680             lo->lo_key_owner != uid &&
2681 -           !capable(CAP_SYS_ADMIN))
2682 +           !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2683                 return -EPERM;
2684         if (lo->lo_state != Lo_bound)
2685                 return -ENXIO;
2686 @@ -1055,7 +1058,8 @@ loop_get_status(struct loop_device *lo, 
2687         memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2688         info->lo_encrypt_type =
2689                 lo->lo_encryption ? lo->lo_encryption->number : 0;
2690 -       if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2691 +       if (lo->lo_encrypt_key_size &&
2692 +               vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2693                 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2694                 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2695                        lo->lo_encrypt_key_size);
2696 @@ -1399,6 +1403,9 @@ static int lo_open(struct block_device *
2697  {
2698         struct loop_device *lo = bdev->bd_disk->private_data;
2699  
2700 +       if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
2701 +               return -EACCES;
2702 +
2703         mutex_lock(&lo->lo_ctl_mutex);
2704         lo->lo_refcnt++;
2705         mutex_unlock(&lo->lo_ctl_mutex);
2706 diff -NurpP --minimal linux-2.6.33.2/drivers/block/Makefile linux-2.6.33.2-vs2.3.0.36.30.4/drivers/block/Makefile
2707 --- linux-2.6.33.2/drivers/block/Makefile       2010-02-25 11:51:36.000000000 +0100
2708 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/block/Makefile       2010-02-25 12:02:16.000000000 +0100
2709 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD)         += viodasd.o
2710  obj-$(CONFIG_BLK_DEV_SX8)      += sx8.o
2711  obj-$(CONFIG_BLK_DEV_UB)       += ub.o
2712  obj-$(CONFIG_BLK_DEV_HD)       += hd.o
2713 +obj-$(CONFIG_BLK_DEV_VROOT)    += vroot.o
2714  
2715  obj-$(CONFIG_XEN_BLKDEV_FRONTEND)      += xen-blkfront.o
2716  obj-$(CONFIG_BLK_DEV_DRBD)     += drbd/
2717 diff -NurpP --minimal linux-2.6.33.2/drivers/block/vroot.c linux-2.6.33.2-vs2.3.0.36.30.4/drivers/block/vroot.c
2718 --- linux-2.6.33.2/drivers/block/vroot.c        1970-01-01 01:00:00.000000000 +0100
2719 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/block/vroot.c        2010-02-25 12:02:16.000000000 +0100
2720 @@ -0,0 +1,281 @@
2721 +/*
2722 + *  linux/drivers/block/vroot.c
2723 + *
2724 + *  written by Herbert Pötzl, 9/11/2002
2725 + *  ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2726 + *
2727 + *  based on the loop.c code by Theodore Ts'o.
2728 + *
2729 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2730 + * Redistribution of this file is permitted under the
2731 + * GNU General Public License.
2732 + *
2733 + */
2734 +
2735 +#include <linux/module.h>
2736 +#include <linux/moduleparam.h>
2737 +#include <linux/file.h>
2738 +#include <linux/major.h>
2739 +#include <linux/blkdev.h>
2740 +
2741 +#include <linux/vroot.h>
2742 +#include <linux/vs_context.h>
2743 +
2744 +
2745 +static int max_vroot = 8;
2746 +
2747 +static struct vroot_device *vroot_dev;
2748 +static struct gendisk **disks;
2749 +
2750 +
2751 +static int vroot_set_dev(
2752 +       struct vroot_device *vr,
2753 +       struct block_device *bdev,
2754 +       unsigned int arg)
2755 +{
2756 +       struct block_device *real_bdev;
2757 +       struct file *file;
2758 +       struct inode *inode;
2759 +       int error;
2760 +
2761 +       error = -EBUSY;
2762 +       if (vr->vr_state != Vr_unbound)
2763 +               goto out;
2764 +
2765 +       error = -EBADF;
2766 +       file = fget(arg);
2767 +       if (!file)
2768 +               goto out;
2769 +
2770 +       error = -EINVAL;
2771 +       inode = file->f_dentry->d_inode;
2772 +
2773 +
2774 +       if (S_ISBLK(inode->i_mode)) {
2775 +               real_bdev = inode->i_bdev;
2776 +               vr->vr_device = real_bdev;
2777 +               __iget(real_bdev->bd_inode);
2778 +       } else
2779 +               goto out_fput;
2780 +
2781 +       vxdprintk(VXD_CBIT(misc, 0),
2782 +               "vroot[%d]_set_dev: dev=" VXF_DEV,
2783 +               vr->vr_number, VXD_DEV(real_bdev));
2784 +
2785 +       vr->vr_state = Vr_bound;
2786 +       error = 0;
2787 +
2788 + out_fput:
2789 +       fput(file);
2790 + out:
2791 +       return error;
2792 +}
2793 +
2794 +static int vroot_clr_dev(
2795 +       struct vroot_device *vr,
2796 +       struct block_device *bdev)
2797 +{
2798 +       struct block_device *real_bdev;
2799 +
2800 +       if (vr->vr_state != Vr_bound)
2801 +               return -ENXIO;
2802 +       if (vr->vr_refcnt > 1)  /* we needed one fd for the ioctl */
2803 +               return -EBUSY;
2804 +
2805 +       real_bdev = vr->vr_device;
2806 +
2807 +       vxdprintk(VXD_CBIT(misc, 0),
2808 +               "vroot[%d]_clr_dev: dev=" VXF_DEV,
2809 +               vr->vr_number, VXD_DEV(real_bdev));
2810 +
2811 +       bdput(real_bdev);
2812 +       vr->vr_state = Vr_unbound;
2813 +       vr->vr_device = NULL;
2814 +       return 0;
2815 +}
2816 +
2817 +
2818 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
2819 +       unsigned int cmd, unsigned long arg)
2820 +{
2821 +       struct vroot_device *vr = bdev->bd_disk->private_data;
2822 +       int err;
2823 +
2824 +       down(&vr->vr_ctl_mutex);
2825 +       switch (cmd) {
2826 +       case VROOT_SET_DEV:
2827 +               err = vroot_set_dev(vr, bdev, arg);
2828 +               break;
2829 +       case VROOT_CLR_DEV:
2830 +               err = vroot_clr_dev(vr, bdev);
2831 +               break;
2832 +       default:
2833 +               err = -EINVAL;
2834 +               break;
2835 +       }
2836 +       up(&vr->vr_ctl_mutex);
2837 +       return err;
2838 +}
2839 +
2840 +static int vr_open(struct block_device *bdev, fmode_t mode)
2841 +{
2842 +       struct vroot_device *vr = bdev->bd_disk->private_data;
2843 +
2844 +       down(&vr->vr_ctl_mutex);
2845 +       vr->vr_refcnt++;
2846 +       up(&vr->vr_ctl_mutex);
2847 +       return 0;
2848 +}
2849 +
2850 +static int vr_release(struct gendisk *disk, fmode_t mode)
2851 +{
2852 +       struct vroot_device *vr = disk->private_data;
2853 +
2854 +       down(&vr->vr_ctl_mutex);
2855 +       --vr->vr_refcnt;
2856 +       up(&vr->vr_ctl_mutex);
2857 +       return 0;
2858 +}
2859 +
2860 +static struct block_device_operations vr_fops = {
2861 +       .owner =        THIS_MODULE,
2862 +       .open =         vr_open,
2863 +       .release =      vr_release,
2864 +       .ioctl =        vr_ioctl,
2865 +};
2866 +
2867 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2868 +{
2869 +       struct inode *inode = bdev->bd_inode;
2870 +       struct vroot_device *vr;
2871 +       struct block_device *real_bdev;
2872 +       int minor = iminor(inode);
2873 +
2874 +       vr = &vroot_dev[minor];
2875 +       real_bdev = vr->vr_device;
2876 +
2877 +       vxdprintk(VXD_CBIT(misc, 0),
2878 +               "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2879 +               vr->vr_number, VXD_DEV(real_bdev));
2880 +
2881 +       if (vr->vr_state != Vr_bound)
2882 +               return ERR_PTR(-ENXIO);
2883 +
2884 +       __iget(real_bdev->bd_inode);
2885 +       return real_bdev;
2886 +}
2887 +
2888 +/*
2889 + * And now the modules code and kernel interface.
2890 + */
2891 +
2892 +module_param(max_vroot, int, 0);
2893 +
2894 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
2895 +MODULE_LICENSE("GPL");
2896 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
2897 +
2898 +MODULE_AUTHOR ("Herbert Pötzl");
2899 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
2900 +
2901 +
2902 +int __init vroot_init(void)
2903 +{
2904 +       int err, i;
2905 +
2906 +       if (max_vroot < 1 || max_vroot > 256) {
2907 +               max_vroot = MAX_VROOT_DEFAULT;
2908 +               printk(KERN_WARNING "vroot: invalid max_vroot "
2909 +                       "(must be between 1 and 256), "
2910 +                       "using default (%d)\n", max_vroot);
2911 +       }
2912 +
2913 +       if (register_blkdev(VROOT_MAJOR, "vroot"))
2914 +               return -EIO;
2915 +
2916 +       err = -ENOMEM;
2917 +       vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2918 +       if (!vroot_dev)
2919 +               goto out_mem1;
2920 +       memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2921 +
2922 +       disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2923 +       if (!disks)
2924 +               goto out_mem2;
2925 +
2926 +       for (i = 0; i < max_vroot; i++) {
2927 +               disks[i] = alloc_disk(1);
2928 +               if (!disks[i])
2929 +                       goto out_mem3;
2930 +               disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
2931 +               if (!disks[i]->queue)
2932 +                       goto out_mem3;
2933 +       }
2934 +
2935 +       for (i = 0; i < max_vroot; i++) {
2936 +               struct vroot_device *vr = &vroot_dev[i];
2937 +               struct gendisk *disk = disks[i];
2938 +
2939 +               memset(vr, 0, sizeof(*vr));
2940 +               init_MUTEX(&vr->vr_ctl_mutex);
2941 +               vr->vr_number = i;
2942 +               disk->major = VROOT_MAJOR;
2943 +               disk->first_minor = i;
2944 +               disk->fops = &vr_fops;
2945 +               sprintf(disk->disk_name, "vroot%d", i);
2946 +               disk->private_data = vr;
2947 +       }
2948 +
2949 +       err = register_vroot_grb(&__vroot_get_real_bdev);
2950 +       if (err)
2951 +               goto out_mem3;
2952 +
2953 +       for (i = 0; i < max_vroot; i++)
2954 +               add_disk(disks[i]);
2955 +       printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2956 +       return 0;
2957 +
2958 +out_mem3:
2959 +       while (i--)
2960 +               put_disk(disks[i]);
2961 +       kfree(disks);
2962 +out_mem2:
2963 +       kfree(vroot_dev);
2964 +out_mem1:
2965 +       unregister_blkdev(VROOT_MAJOR, "vroot");
2966 +       printk(KERN_ERR "vroot: ran out of memory\n");
2967 +       return err;
2968 +}
2969 +
2970 +void vroot_exit(void)
2971 +{
2972 +       int i;
2973 +
2974 +       if (unregister_vroot_grb(&__vroot_get_real_bdev))
2975 +               printk(KERN_WARNING "vroot: cannot unregister grb\n");
2976 +
2977 +       for (i = 0; i < max_vroot; i++) {
2978 +               del_gendisk(disks[i]);
2979 +               put_disk(disks[i]);
2980 +       }
2981 +       unregister_blkdev(VROOT_MAJOR, "vroot");
2982 +
2983 +       kfree(disks);
2984 +       kfree(vroot_dev);
2985 +}
2986 +
2987 +module_init(vroot_init);
2988 +module_exit(vroot_exit);
2989 +
2990 +#ifndef MODULE
2991 +
2992 +static int __init max_vroot_setup(char *str)
2993 +{
2994 +       max_vroot = simple_strtol(str, NULL, 0);
2995 +       return 1;
2996 +}
2997 +
2998 +__setup("max_vroot=", max_vroot_setup);
2999 +
3000 +#endif
3001 +
3002 diff -NurpP --minimal linux-2.6.33.2/drivers/char/sysrq.c linux-2.6.33.2-vs2.3.0.36.30.4/drivers/char/sysrq.c
3003 --- linux-2.6.33.2/drivers/char/sysrq.c 2010-02-25 11:51:37.000000000 +0100
3004 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/char/sysrq.c 2010-02-25 12:02:16.000000000 +0100
3005 @@ -38,6 +38,7 @@
3006  #include <linux/workqueue.h>
3007  #include <linux/hrtimer.h>
3008  #include <linux/oom.h>
3009 +#include <linux/vserver/debug.h>
3010  
3011  #include <asm/ptrace.h>
3012  #include <asm/irq_regs.h>
3013 @@ -391,6 +392,21 @@ static struct sysrq_key_op sysrq_unrt_op
3014         .enable_mask    = SYSRQ_ENABLE_RTNICE,
3015  };
3016  
3017 +
3018 +#ifdef CONFIG_VSERVER_DEBUG
3019 +static void sysrq_handle_vxinfo(int key, struct tty_struct *tty)
3020 +{
3021 +       dump_vx_info_inactive((key == 'x')?0:1);
3022 +}
3023 +
3024 +static struct sysrq_key_op sysrq_showvxinfo_op = {
3025 +       .handler        = sysrq_handle_vxinfo,
3026 +       .help_msg       = "conteXt",
3027 +       .action_msg     = "Show Context Info",
3028 +       .enable_mask    = SYSRQ_ENABLE_DUMP,
3029 +};
3030 +#endif
3031 +
3032  /* Key Operations table and lock */
3033  static DEFINE_SPINLOCK(sysrq_key_table_lock);
3034  
3035 @@ -445,7 +461,11 @@ static struct sysrq_key_op *sysrq_key_ta
3036         NULL,                           /* v */
3037         &sysrq_showstate_blocked_op,    /* w */
3038         /* x: May be registered on ppc/powerpc for xmon */
3039 +#ifdef CONFIG_VSERVER_DEBUG
3040 +       &sysrq_showvxinfo_op,           /* x */
3041 +#else
3042         NULL,                           /* x */
3043 +#endif
3044         /* y: May be registered on sparc64 for global register dump */
3045         NULL,                           /* y */
3046         &sysrq_ftrace_dump_op,          /* z */
3047 @@ -460,6 +480,8 @@ static int sysrq_key_table_key2index(int
3048                 retval = key - '0';
3049         else if ((key >= 'a') && (key <= 'z'))
3050                 retval = key + 10 - 'a';
3051 +       else if ((key >= 'A') && (key <= 'Z'))
3052 +               retval = key + 10 - 'A';
3053         else
3054                 retval = -1;
3055         return retval;
3056 diff -NurpP --minimal linux-2.6.33.2/drivers/char/tty_io.c linux-2.6.33.2-vs2.3.0.36.30.4/drivers/char/tty_io.c
3057 --- linux-2.6.33.2/drivers/char/tty_io.c        2010-02-25 11:51:37.000000000 +0100
3058 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/char/tty_io.c        2010-02-25 12:02:16.000000000 +0100
3059 @@ -106,6 +106,7 @@
3060  
3061  #include <linux/kmod.h>
3062  #include <linux/nsproxy.h>
3063 +#include <linux/vs_pid.h>
3064  
3065  #undef TTY_DEBUG_HANGUP
3066  
3067 @@ -1989,7 +1990,8 @@ static int tiocsti(struct tty_struct *tt
3068         char ch, mbz = 0;
3069         struct tty_ldisc *ld;
3070  
3071 -       if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
3072 +       if (((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN)) ||
3073 +               !vx_ccaps(VXC_TIOCSTI))
3074                 return -EPERM;
3075         if (get_user(ch, p))
3076                 return -EFAULT;
3077 @@ -2277,6 +2279,7 @@ static int tiocspgrp(struct tty_struct *
3078                 return -ENOTTY;
3079         if (get_user(pgrp_nr, p))
3080                 return -EFAULT;
3081 +       pgrp_nr = vx_rmap_pid(pgrp_nr);
3082         if (pgrp_nr < 0)
3083                 return -EINVAL;
3084         rcu_read_lock();
3085 diff -NurpP --minimal linux-2.6.33.2/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r100_reg_safe.h
3086 --- linux-2.6.33.2/drivers/gpu/drm/radeon/r100_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3087 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r100_reg_safe.h       2010-02-27 15:52:40.000000000 +0100
3088 @@ -0,0 +1,28 @@
3089 +static const unsigned r100_reg_safe_bm[102] = {
3090 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3091 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3092 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3093 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3094 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3095 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3096 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3097 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3098 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3099 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3100 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3101 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3102 +       0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3103 +       0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3104 +       0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
3105 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3106 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
3107 +       0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
3108 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3109 +       0xFFFFFFFF, 0xFFFCFFFF, 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, 0xFFFFFFEF,
3116 +};
3117 diff -NurpP --minimal linux-2.6.33.2/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r200_reg_safe.h
3118 --- linux-2.6.33.2/drivers/gpu/drm/radeon/r200_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3119 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r200_reg_safe.h       2010-02-27 15:52:44.000000000 +0100
3120 @@ -0,0 +1,28 @@
3121 +static const unsigned r200_reg_safe_bm[102] = {
3122 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3123 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3124 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3125 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3126 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3127 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3128 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3129 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3130 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3131 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3132 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3133 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3134 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3135 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3136 +       0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
3137 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3138 +       0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
3139 +       0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
3140 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3141 +       0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3142 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3143 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3144 +       0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
3145 +       0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
3146 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3147 +       0xFFFFFE3F, 0xFFFFFFEF,
3148 +};
3149 diff -NurpP --minimal linux-2.6.33.2/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r300_reg_safe.h
3150 --- linux-2.6.33.2/drivers/gpu/drm/radeon/r300_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3151 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r300_reg_safe.h       2010-02-27 15:52:41.000000000 +0100
3152 @@ -0,0 +1,42 @@
3153 +static const unsigned r300_reg_safe_bm[159] = {
3154 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
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 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3165 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3166 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3167 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3168 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3169 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3170 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3171 +       0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3172 +       0xFFFFFFFF, 0xFFFFFFFF, 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 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3181 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3182 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3183 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3184 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3185 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3186 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3187 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3188 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3189 +       0x00000000, 0x0000C100, 0x00000000, 0x00000000,
3190 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3191 +       0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
3192 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3193 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3194 +};
3195 diff -NurpP --minimal linux-2.6.33.2/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r420_reg_safe.h
3196 --- linux-2.6.33.2/drivers/gpu/drm/radeon/r420_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3197 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r420_reg_safe.h       2010-02-27 15:52:41.000000000 +0100
3198 @@ -0,0 +1,42 @@
3199 +static const unsigned r420_reg_safe_bm[159] = {
3200 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3201 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3202 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3203 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3204 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3205 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3206 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3207 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3208 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3209 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3210 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3211 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3212 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3213 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3214 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3215 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3216 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3217 +       0xF0000078, 0xFF000009, 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 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3227 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3228 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3229 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3230 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3231 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3232 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3233 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3234 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3235 +       0x00000000, 0x00000100, 0x00000000, 0x00000000,
3236 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3237 +       0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3238 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3239 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3240 +};
3241 diff -NurpP --minimal linux-2.6.33.2/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/rn50_reg_safe.h
3242 --- linux-2.6.33.2/drivers/gpu/drm/radeon/rn50_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3243 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/rn50_reg_safe.h       2010-02-27 15:52:40.000000000 +0100
3244 @@ -0,0 +1,28 @@
3245 +static const unsigned rn50_reg_safe_bm[102] = {
3246 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3247 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3248 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3249 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3250 +       0xFFFFFFFF, 0xFFFFFFFF, 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 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3257 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3258 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3259 +       0xFFFFFFFF, 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 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3266 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3267 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3268 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3269 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3270 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3271 +       0xFFFFFFFF, 0xFFFFFFFF,
3272 +};
3273 diff -NurpP --minimal linux-2.6.33.2/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/rs600_reg_safe.h
3274 --- linux-2.6.33.2/drivers/gpu/drm/radeon/rs600_reg_safe.h      1970-01-01 01:00:00.000000000 +0100
3275 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/rs600_reg_safe.h      2010-02-27 15:52:42.000000000 +0100
3276 @@ -0,0 +1,57 @@
3277 +static const unsigned rs600_reg_safe_bm[219] = {
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, 0xFFFFFFFF,
3288 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3289 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3290 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3291 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3292 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3293 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3294 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3295 +       0xF0000078, 0xFF000009, 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 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3305 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3306 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3307 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3308 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3309 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3310 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3311 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3312 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3313 +       0x00000000, 0x00000100, 0x00000000, 0x00000000,
3314 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3315 +       0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3316 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3317 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
3318 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3319 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3320 +       0xFFFFFFFF, 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 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3327 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3328 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3329 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3330 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3331 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3332 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3333 +};
3334 diff -NurpP --minimal linux-2.6.33.2/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/rv515_reg_safe.h
3335 --- linux-2.6.33.2/drivers/gpu/drm/radeon/rv515_reg_safe.h      1970-01-01 01:00:00.000000000 +0100
3336 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/rv515_reg_safe.h      2010-02-27 15:52:42.000000000 +0100
3337 @@ -0,0 +1,57 @@
3338 +static const unsigned rv515_reg_safe_bm[219] = {
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, 0xFFFFFFFF,
3349 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3350 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3351 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3352 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3353 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3354 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3355 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3356 +       0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3357 +       0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
3358 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3359 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3360 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3361 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3362 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3363 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3364 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3365 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3366 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3367 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3368 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3369 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3370 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3371 +       0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
3372 +       0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
3373 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3374 +       0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
3375 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3376 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
3377 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3378 +       0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
3379 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3380 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3381 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3382 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3383 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3384 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3385 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3386 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3387 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3388 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3389 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3390 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3391 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3392 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3393 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3394 +};
3395 diff -NurpP --minimal linux-2.6.33.2/drivers/infiniband/core/addr.c linux-2.6.33.2-vs2.3.0.36.30.4/drivers/infiniband/core/addr.c
3396 --- linux-2.6.33.2/drivers/infiniband/core/addr.c       2010-02-25 11:51:39.000000000 +0100
3397 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/infiniband/core/addr.c       2010-02-26 10:39:59.000000000 +0100
3398 @@ -251,7 +251,7 @@ static int addr6_resolve(struct sockaddr
3399  
3400         if (ipv6_addr_any(&fl.fl6_src)) {
3401                 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
3402 -                                        &fl.fl6_dst, 0, &fl.fl6_src);
3403 +                                        &fl.fl6_dst, 0, &fl.fl6_src, NULL);
3404                 if (ret)
3405                         goto put;
3406  
3407 diff -NurpP --minimal linux-2.6.33.2/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.33.2-vs2.3.0.36.30.4/drivers/infiniband/hw/ipath/ipath_user_pages.c
3408 --- linux-2.6.33.2/drivers/infiniband/hw/ipath/ipath_user_pages.c       2009-12-03 20:02:23.000000000 +0100
3409 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/infiniband/hw/ipath/ipath_user_pages.c       2010-02-25 12:02:16.000000000 +0100
3410 @@ -34,6 +34,7 @@
3411  #include <linux/mm.h>
3412  #include <linux/device.h>
3413  #include <linux/sched.h>
3414 +#include <linux/vs_memory.h>
3415  
3416  #include "ipath_kernel.h"
3417  
3418 @@ -62,7 +63,8 @@ static int __get_user_pages(unsigned lon
3419         lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
3420                 PAGE_SHIFT;
3421  
3422 -       if (num_pages > lock_limit) {
3423 +       if (num_pages > lock_limit ||
3424 +               !vx_vmlocked_avail(current->mm, num_pages)) {
3425                 ret = -ENOMEM;
3426                 goto bail;
3427         }
3428 @@ -79,7 +81,7 @@ static int __get_user_pages(unsigned lon
3429                         goto bail_release;
3430         }
3431  
3432 -       current->mm->locked_vm += num_pages;
3433 +       vx_vmlocked_add(current->mm, num_pages);
3434  
3435         ret = 0;
3436         goto bail;
3437 @@ -178,7 +180,7 @@ void ipath_release_user_pages(struct pag
3438  
3439         __ipath_release_user_pages(p, num_pages, 1);
3440  
3441 -       current->mm->locked_vm -= num_pages;
3442 +       vx_vmlocked_sub(current->mm, num_pages);
3443  
3444         up_write(&current->mm->mmap_sem);
3445  }
3446 @@ -195,7 +197,7 @@ static void user_pages_account(struct wo
3447                 container_of(_work, struct ipath_user_pages_work, work);
3448  
3449         down_write(&work->mm->mmap_sem);
3450 -       work->mm->locked_vm -= work->num_pages;
3451 +       vx_vmlocked_sub(work->mm, work->num_pages);
3452         up_write(&work->mm->mmap_sem);
3453         mmput(work->mm);
3454         kfree(work);
3455 diff -NurpP --minimal linux-2.6.33.2/drivers/md/dm.c linux-2.6.33.2-vs2.3.0.36.30.4/drivers/md/dm.c
3456 --- linux-2.6.33.2/drivers/md/dm.c      2010-04-06 01:47:45.000000000 +0200
3457 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/md/dm.c      2010-04-06 01:59:25.000000000 +0200
3458 @@ -19,6 +19,7 @@
3459  #include <linux/slab.h>
3460  #include <linux/idr.h>
3461  #include <linux/hdreg.h>
3462 +#include <linux/vs_base.h>
3463  
3464  #include <trace/events/block.h>
3465  
3466 @@ -119,6 +120,7 @@ struct mapped_device {
3467         rwlock_t map_lock;
3468         atomic_t holders;
3469         atomic_t open_count;
3470 +       xid_t xid;
3471  
3472         unsigned long flags;
3473  
3474 @@ -337,6 +339,7 @@ int dm_deleting_md(struct mapped_device 
3475  static int dm_blk_open(struct block_device *bdev, fmode_t mode)
3476  {
3477         struct mapped_device *md;
3478 +       int ret = -ENXIO;
3479  
3480         spin_lock(&_minor_lock);
3481  
3482 @@ -345,18 +348,19 @@ static int dm_blk_open(struct block_devi
3483                 goto out;
3484  
3485         if (test_bit(DMF_FREEING, &md->flags) ||
3486 -           dm_deleting_md(md)) {
3487 -               md = NULL;
3488 +           dm_deleting_md(md))
3489 +               goto out;
3490 +
3491 +       ret = -EACCES;
3492 +       if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
3493                 goto out;
3494 -       }
3495  
3496         dm_get(md);
3497         atomic_inc(&md->open_count);
3498 -
3499 +       ret = 0;
3500  out:
3501         spin_unlock(&_minor_lock);
3502 -
3503 -       return md ? 0 : -ENXIO;
3504 +       return ret;
3505  }
3506  
3507  static int dm_blk_close(struct gendisk *disk, fmode_t mode)
3508 @@ -574,6 +578,14 @@ int dm_set_geometry(struct mapped_device
3509         return 0;
3510  }
3511  
3512 +/*
3513 + * Get the xid associated with a dm device
3514 + */
3515 +xid_t dm_get_xid(struct mapped_device *md)
3516 +{
3517 +       return md->xid;
3518 +}
3519 +
3520  /*-----------------------------------------------------------------
3521   * CRUD START:
3522   *   A more elegant soln is in the works that uses the queue
3523 @@ -1886,6 +1898,7 @@ static struct mapped_device *alloc_dev(i
3524         INIT_LIST_HEAD(&md->uevent_list);
3525         spin_lock_init(&md->uevent_lock);
3526  
3527 +       md->xid = vx_current_xid();
3528         md->queue = blk_init_queue(dm_request_fn, NULL);
3529         if (!md->queue)
3530                 goto bad_queue;
3531 diff -NurpP --minimal linux-2.6.33.2/drivers/md/dm.h linux-2.6.33.2-vs2.3.0.36.30.4/drivers/md/dm.h
3532 --- linux-2.6.33.2/drivers/md/dm.h      2010-02-25 11:51:41.000000000 +0100
3533 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/md/dm.h      2010-02-25 12:02:16.000000000 +0100
3534 @@ -41,6 +41,8 @@ struct dm_dev_internal {
3535  struct dm_table;
3536  struct dm_md_mempools;
3537  
3538 +xid_t dm_get_xid(struct mapped_device *md);
3539 +
3540  /*-----------------------------------------------------------------
3541   * Internal table functions.
3542   *---------------------------------------------------------------*/
3543 diff -NurpP --minimal linux-2.6.33.2/drivers/md/dm-ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/drivers/md/dm-ioctl.c
3544 --- linux-2.6.33.2/drivers/md/dm-ioctl.c        2010-04-06 01:47:45.000000000 +0200
3545 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/md/dm-ioctl.c        2010-04-06 01:59:25.000000000 +0200
3546 @@ -16,6 +16,7 @@
3547  #include <linux/dm-ioctl.h>
3548  #include <linux/hdreg.h>
3549  #include <linux/compat.h>
3550 +#include <linux/vs_context.h>
3551  
3552  #include <asm/uaccess.h>
3553  
3554 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
3555         unsigned int h = hash_str(str);
3556  
3557         list_for_each_entry (hc, _name_buckets + h, name_list)
3558 -               if (!strcmp(hc->name, str)) {
3559 +               if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3560 +                       !strcmp(hc->name, str)) {
3561                         dm_get(hc->md);
3562                         return hc;
3563                 }
3564 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
3565         unsigned int h = hash_str(str);
3566  
3567         list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
3568 -               if (!strcmp(hc->uuid, str)) {
3569 +               if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3570 +                       !strcmp(hc->uuid, str)) {
3571                         dm_get(hc->md);
3572                         return hc;
3573                 }
3574 @@ -363,6 +366,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl 
3575  
3576  static int remove_all(struct dm_ioctl *param, size_t param_size)
3577  {
3578 +       if (!vx_check(0, VS_ADMIN))
3579 +               return -EPERM;
3580 +
3581         dm_hash_remove_all(1);
3582         param->data_size = 0;
3583         return 0;
3584 @@ -410,6 +416,8 @@ static int list_devices(struct dm_ioctl 
3585          */
3586         for (i = 0; i < NUM_BUCKETS; i++) {
3587                 list_for_each_entry (hc, _name_buckets + i, name_list) {
3588 +                       if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3589 +                               continue;
3590                         needed += sizeof(struct dm_name_list);
3591                         needed += strlen(hc->name) + 1;
3592                         needed += ALIGN_MASK;
3593 @@ -433,6 +441,8 @@ static int list_devices(struct dm_ioctl 
3594          */
3595         for (i = 0; i < NUM_BUCKETS; i++) {
3596                 list_for_each_entry (hc, _name_buckets + i, name_list) {
3597 +                       if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3598 +                               continue;
3599                         if (old_nl)
3600                                 old_nl->next = (uint32_t) ((void *) nl -
3601                                                            (void *) old_nl);
3602 @@ -667,10 +677,11 @@ static struct hash_cell *__find_device_h
3603         if (!md)
3604                 goto out;
3605  
3606 -       mdptr = dm_get_mdptr(md);
3607 +       if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
3608 +               mdptr = dm_get_mdptr(md);
3609 +
3610         if (!mdptr)
3611                 dm_put(md);
3612 -
3613  out:
3614         return mdptr;
3615  }
3616 @@ -1509,8 +1520,8 @@ static int ctl_ioctl(uint command, struc
3617         ioctl_fn fn = NULL;
3618         size_t param_size;
3619  
3620 -       /* only root can play with this */
3621 -       if (!capable(CAP_SYS_ADMIN))
3622 +       /* only root and certain contexts can play with this */
3623 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
3624                 return -EACCES;
3625  
3626         if (_IOC_TYPE(command) != DM_IOCTL)
3627 diff -NurpP --minimal linux-2.6.33.2/drivers/net/tun.c linux-2.6.33.2-vs2.3.0.36.30.4/drivers/net/tun.c
3628 --- linux-2.6.33.2/drivers/net/tun.c    2010-02-25 11:51:53.000000000 +0100
3629 +++ linux-2.6.33.2-vs2.3.0.36.30.4/drivers/net/tun.c    2010-02-25 12:02:16.000000000 +0100
3630 @@ -61,6 +61,7 @@
3631  #include <linux/crc32.h>
3632  #include <linux/nsproxy.h>
3633  #include <linux/virtio_net.h>
3634 +#include <linux/vs_network.h>
3635  #include <net/net_namespace.h>
3636  #include <net/netns/generic.h>
3637  #include <net/rtnetlink.h>
3638 @@ -102,6 +103,7 @@ struct tun_struct {
3639         unsigned int            flags;
3640         uid_t                   owner;
3641         gid_t                   group;
3642 +       nid_t                   nid;
3643  
3644         struct net_device       *dev;
3645         struct fasync_struct    *fasync;
3646 @@ -816,6 +818,7 @@ static void tun_setup(struct net_device 
3647  
3648         tun->owner = -1;
3649         tun->group = -1;
3650 +       tun->nid = current->nid;
3651  
3652         dev->ethtool_ops = &tun_ethtool_ops;
3653         dev->destructor = tun_free_netdev;
3654 @@ -932,7 +935,7 @@ static int tun_set_iff(struct net *net, 
3655  
3656                 if (((tun->owner != -1 && cred->euid != tun->owner) ||
3657                      (tun->group != -1 && !in_egroup_p(tun->group))) &&
3658 -                   !capable(CAP_NET_ADMIN))
3659 +               !cap_raised(current_cap(), CAP_NET_ADMIN))
3660                         return -EPERM;
3661                 err = security_tun_dev_attach(tun->socket.sk);
3662                 if (err < 0)
3663 @@ -946,7 +949,7 @@ static int tun_set_iff(struct net *net, 
3664                 char *name;
3665                 unsigned long flags = 0;
3666  
3667 -               if (!capable(CAP_NET_ADMIN))
3668 +               if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
3669                         return -EPERM;
3670                 err = security_tun_dev_create();
3671                 if (err < 0)
3672 @@ -1013,6 +1016,9 @@ static int tun_set_iff(struct net *net, 
3673  
3674                 sk->sk_destruct = tun_sock_destruct;
3675  
3676 +               if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
3677 +                       return -EPERM;
3678 +
3679                 err = tun_attach(tun, file);
3680                 if (err < 0)
3681                         goto failed;
3682 @@ -1202,6 +1208,16 @@ static long __tun_chr_ioctl(struct file 
3683                 DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
3684                 break;
3685  
3686 +       case TUNSETNID:
3687 +               if (!capable(CAP_CONTEXT))
3688 +                       return -EPERM;
3689 +
3690 +               /* Set nid owner of the device */
3691 +               tun->nid = (nid_t) arg;
3692 +
3693 +               DBG(KERN_INFO "%s: nid owner set to %u\n", tun->dev->name, tun->nid);
3694 +               break;
3695 +
3696         case TUNSETLINK:
3697                 /* Only allow setting the type when the interface is down */
3698                 if (tun->dev->flags & IFF_UP) {
3699 diff -NurpP --minimal linux-2.6.33.2/fs/attr.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/attr.c
3700 --- linux-2.6.33.2/fs/attr.c    2009-12-03 20:02:51.000000000 +0100
3701 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/attr.c    2010-02-25 12:02:16.000000000 +0100
3702 @@ -14,6 +14,9 @@
3703  #include <linux/fcntl.h>
3704  #include <linux/quotaops.h>
3705  #include <linux/security.h>
3706 +#include <linux/proc_fs.h>
3707 +#include <linux/devpts_fs.h>
3708 +#include <linux/vs_tag.h>
3709  
3710  /* Taken over from the old code... */
3711  
3712 @@ -55,6 +58,10 @@ int inode_change_ok(const struct inode *
3713                 if (!is_owner_or_cap(inode))
3714                         goto error;
3715         }
3716 +
3717 +       if (dx_permission(inode, MAY_WRITE))
3718 +               goto error;
3719 +
3720  fine:
3721         retval = 0;
3722  error:
3723 @@ -120,6 +127,8 @@ int inode_setattr(struct inode * inode, 
3724                 inode->i_uid = attr->ia_uid;
3725         if (ia_valid & ATTR_GID)
3726                 inode->i_gid = attr->ia_gid;
3727 +       if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3728 +               inode->i_tag = attr->ia_tag;
3729         if (ia_valid & ATTR_ATIME)
3730                 inode->i_atime = timespec_trunc(attr->ia_atime,
3731                                                 inode->i_sb->s_time_gran);
3732 @@ -214,7 +223,8 @@ int notify_change(struct dentry * dentry
3733                 error = inode_change_ok(inode, attr);
3734                 if (!error) {
3735                         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3736 -                           (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid))
3737 +                           (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3738 +                           (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag))
3739                                 error = vfs_dq_transfer(inode, attr) ?
3740                                         -EDQUOT : 0;
3741                         if (!error)
3742 diff -NurpP --minimal linux-2.6.33.2/fs/binfmt_aout.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/binfmt_aout.c
3743 --- linux-2.6.33.2/fs/binfmt_aout.c     2010-02-25 11:52:04.000000000 +0100
3744 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/binfmt_aout.c     2010-02-25 12:02:16.000000000 +0100
3745 @@ -24,6 +24,7 @@
3746  #include <linux/binfmts.h>
3747  #include <linux/personality.h>
3748  #include <linux/init.h>
3749 +#include <linux/vs_memory.h>
3750  
3751  #include <asm/system.h>
3752  #include <asm/uaccess.h>
3753 diff -NurpP --minimal linux-2.6.33.2/fs/binfmt_elf.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/binfmt_elf.c
3754 --- linux-2.6.33.2/fs/binfmt_elf.c      2010-02-25 11:52:04.000000000 +0100
3755 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/binfmt_elf.c      2010-02-25 12:02:16.000000000 +0100
3756 @@ -31,6 +31,7 @@
3757  #include <linux/random.h>
3758  #include <linux/elf.h>
3759  #include <linux/utsname.h>
3760 +#include <linux/vs_memory.h>
3761  #include <asm/uaccess.h>
3762  #include <asm/param.h>
3763  #include <asm/page.h>
3764 diff -NurpP --minimal linux-2.6.33.2/fs/binfmt_flat.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/binfmt_flat.c
3765 --- linux-2.6.33.2/fs/binfmt_flat.c     2010-02-25 11:52:04.000000000 +0100
3766 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/binfmt_flat.c     2010-02-25 12:02:16.000000000 +0100
3767 @@ -35,6 +35,7 @@
3768  #include <linux/init.h>
3769  #include <linux/flat.h>
3770  #include <linux/syscalls.h>
3771 +#include <linux/vs_memory.h>
3772  
3773  #include <asm/byteorder.h>
3774  #include <asm/system.h>
3775 diff -NurpP --minimal linux-2.6.33.2/fs/binfmt_som.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/binfmt_som.c
3776 --- linux-2.6.33.2/fs/binfmt_som.c      2010-02-25 11:52:04.000000000 +0100
3777 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/binfmt_som.c      2010-02-25 12:02:16.000000000 +0100
3778 @@ -28,6 +28,7 @@
3779  #include <linux/shm.h>
3780  #include <linux/personality.h>
3781  #include <linux/init.h>
3782 +#include <linux/vs_memory.h>
3783  
3784  #include <asm/uaccess.h>
3785  #include <asm/pgtable.h>
3786 diff -NurpP --minimal linux-2.6.33.2/fs/block_dev.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/block_dev.c
3787 --- linux-2.6.33.2/fs/block_dev.c       2010-02-25 11:52:04.000000000 +0100
3788 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/block_dev.c       2010-02-25 12:02:16.000000000 +0100
3789 @@ -26,6 +26,7 @@
3790  #include <linux/namei.h>
3791  #include <linux/log2.h>
3792  #include <linux/kmemleak.h>
3793 +#include <linux/vs_device.h>
3794  #include <asm/uaccess.h>
3795  #include "internal.h"
3796  
3797 @@ -566,6 +567,7 @@ struct block_device *bdget(dev_t dev)
3798                 bdev->bd_invalidated = 0;
3799                 inode->i_mode = S_IFBLK;
3800                 inode->i_rdev = dev;
3801 +               inode->i_mdev = dev;
3802                 inode->i_bdev = bdev;
3803                 inode->i_data.a_ops = &def_blk_aops;
3804                 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
3805 @@ -612,6 +614,11 @@ EXPORT_SYMBOL(bdput);
3806  static struct block_device *bd_acquire(struct inode *inode)
3807  {
3808         struct block_device *bdev;
3809 +       dev_t mdev;
3810 +
3811 +       if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
3812 +               return NULL;
3813 +       inode->i_mdev = mdev;
3814  
3815         spin_lock(&bdev_lock);
3816         bdev = inode->i_bdev;
3817 @@ -622,7 +629,7 @@ static struct block_device *bd_acquire(s
3818         }
3819         spin_unlock(&bdev_lock);
3820  
3821 -       bdev = bdget(inode->i_rdev);
3822 +       bdev = bdget(mdev);
3823         if (bdev) {
3824                 spin_lock(&bdev_lock);
3825                 if (!inode->i_bdev) {
3826 diff -NurpP --minimal linux-2.6.33.2/fs/btrfs/ctree.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/btrfs/ctree.h
3827 --- linux-2.6.33.2/fs/btrfs/ctree.h     2010-02-25 11:52:04.000000000 +0100
3828 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/btrfs/ctree.h     2010-02-25 12:02:16.000000000 +0100
3829 @@ -547,11 +547,14 @@ struct btrfs_inode_item {
3830         /* modification sequence number for NFS */
3831         __le64 sequence;
3832  
3833 +       __le16 tag;
3834         /*
3835          * a little future expansion, for more than this we can
3836          * just grow the inode item and version it
3837          */
3838 -       __le64 reserved[4];
3839 +       __le16 reserved16;
3840 +       __le32 reserved32;
3841 +       __le64 reserved[3];
3842         struct btrfs_timespec atime;
3843         struct btrfs_timespec ctime;
3844         struct btrfs_timespec mtime;
3845 @@ -1163,6 +1166,8 @@ struct btrfs_root {
3846  #define BTRFS_MOUNT_DISCARD            (1 << 10)
3847  #define BTRFS_MOUNT_FORCE_COMPRESS      (1 << 11)
3848  
3849 +#define BTRFS_MOUNT_TAGGED             (1 << 24)
3850 +
3851  #define btrfs_clear_opt(o, opt)                ((o) &= ~BTRFS_MOUNT_##opt)
3852  #define btrfs_set_opt(o, opt)          ((o) |= BTRFS_MOUNT_##opt)
3853  #define btrfs_test_opt(root, opt)      ((root)->fs_info->mount_opt & \
3854 @@ -1182,6 +1187,10 @@ struct btrfs_root {
3855  #define BTRFS_INODE_NOATIME            (1 << 9)
3856  #define BTRFS_INODE_DIRSYNC            (1 << 10)
3857  
3858 +#define BTRFS_INODE_IXUNLINK           (1 << 24)
3859 +#define BTRFS_INODE_BARRIER            (1 << 25)
3860 +#define BTRFS_INODE_COW                        (1 << 26)
3861 +
3862  
3863  /* some macros to generate set/get funcs for the struct fields.  This
3864   * assumes there is a lefoo_to_cpu for every type, so lets make a simple
3865 @@ -1384,6 +1393,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
3866  BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
3867  BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
3868  BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
3869 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
3870  BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
3871  BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
3872  BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
3873 @@ -2357,6 +2367,7 @@ extern const struct dentry_operations bt
3874  long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3875  void btrfs_update_iflags(struct inode *inode);
3876  void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
3877 +int btrfs_sync_flags(struct inode *inode, int, int);
3878  
3879  /* file.c */
3880  int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync);
3881 diff -NurpP --minimal linux-2.6.33.2/fs/btrfs/disk-io.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/btrfs/disk-io.c
3882 --- linux-2.6.33.2/fs/btrfs/disk-io.c   2010-02-25 11:52:04.000000000 +0100
3883 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/btrfs/disk-io.c   2010-02-25 12:02:16.000000000 +0100
3884 @@ -1726,6 +1726,9 @@ struct btrfs_root *open_ctree(struct sup
3885                 goto fail_iput;
3886         }
3887  
3888 +       if (btrfs_test_opt(tree_root, TAGGED))
3889 +               sb->s_flags |= MS_TAGGED;
3890 +
3891         features = btrfs_super_incompat_flags(disk_super) &
3892                 ~BTRFS_FEATURE_INCOMPAT_SUPP;
3893         if (features) {
3894 diff -NurpP --minimal linux-2.6.33.2/fs/btrfs/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/btrfs/inode.c
3895 --- linux-2.6.33.2/fs/btrfs/inode.c     2010-02-25 11:52:04.000000000 +0100
3896 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/btrfs/inode.c     2010-02-25 12:02:16.000000000 +0100
3897 @@ -36,6 +36,8 @@
3898  #include <linux/xattr.h>
3899  #include <linux/posix_acl.h>
3900  #include <linux/falloc.h>
3901 +#include <linux/vs_tag.h>
3902 +
3903  #include "compat.h"
3904  #include "ctree.h"
3905  #include "disk-io.h"
3906 @@ -2264,6 +2266,8 @@ static void btrfs_read_locked_inode(stru
3907         int maybe_acls;
3908         u64 alloc_group_block;
3909         u32 rdev;
3910 +       uid_t uid;
3911 +       gid_t gid;
3912         int ret;
3913  
3914         path = btrfs_alloc_path();
3915 @@ -2280,8 +2284,13 @@ static void btrfs_read_locked_inode(stru
3916  
3917         inode->i_mode = btrfs_inode_mode(leaf, inode_item);
3918         inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
3919 -       inode->i_uid = btrfs_inode_uid(leaf, inode_item);
3920 -       inode->i_gid = btrfs_inode_gid(leaf, inode_item);
3921 +
3922 +       uid = btrfs_inode_uid(leaf, inode_item);
3923 +       gid = btrfs_inode_gid(leaf, inode_item);
3924 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3925 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3926 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3927 +               btrfs_inode_tag(leaf, inode_item));
3928         btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
3929  
3930         tspec = btrfs_inode_atime(inode_item);
3931 @@ -2363,8 +2372,15 @@ static void fill_inode_item(struct btrfs
3932                             struct btrfs_inode_item *item,
3933                             struct inode *inode)
3934  {
3935 -       btrfs_set_inode_uid(leaf, item, inode->i_uid);
3936 -       btrfs_set_inode_gid(leaf, item, inode->i_gid);
3937 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3938 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3939 +
3940 +       btrfs_set_inode_uid(leaf, item, uid);
3941 +       btrfs_set_inode_gid(leaf, item, gid);
3942 +#ifdef CONFIG_TAGGING_INTERN
3943 +       btrfs_set_inode_tag(leaf, item, inode->i_tag);
3944 +#endif
3945 +
3946         btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
3947         btrfs_set_inode_mode(leaf, item, inode->i_mode);
3948         btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
3949 @@ -4154,6 +4170,7 @@ static struct inode *btrfs_new_inode(str
3950         } else
3951                 inode->i_gid = current_fsgid();
3952  
3953 +       inode->i_tag = dx_current_fstag(root->fs_info->sb);
3954         inode->i_mode = mode;
3955         inode->i_ino = objectid;
3956         inode_set_bytes(inode, 0);
3957 @@ -5955,6 +5972,7 @@ static const struct inode_operations btr
3958         .listxattr      = btrfs_listxattr,
3959         .removexattr    = btrfs_removexattr,
3960         .permission     = btrfs_permission,
3961 +       .sync_flags     = btrfs_sync_flags,
3962  };
3963  static const struct inode_operations btrfs_dir_ro_inode_operations = {
3964         .lookup         = btrfs_lookup,
3965 @@ -6030,6 +6048,7 @@ static const struct inode_operations btr
3966         .permission     = btrfs_permission,
3967         .fallocate      = btrfs_fallocate,
3968         .fiemap         = btrfs_fiemap,
3969 +       .sync_flags     = btrfs_sync_flags,
3970  };
3971  static const struct inode_operations btrfs_special_inode_operations = {
3972         .getattr        = btrfs_getattr,
3973 diff -NurpP --minimal linux-2.6.33.2/fs/btrfs/ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/btrfs/ioctl.c
3974 --- linux-2.6.33.2/fs/btrfs/ioctl.c     2010-02-25 11:52:04.000000000 +0100
3975 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/btrfs/ioctl.c     2010-02-25 12:02:16.000000000 +0100
3976 @@ -67,10 +67,13 @@ static unsigned int btrfs_flags_to_ioctl
3977  {
3978         unsigned int iflags = 0;
3979  
3980 -       if (flags & BTRFS_INODE_SYNC)
3981 -               iflags |= FS_SYNC_FL;
3982         if (flags & BTRFS_INODE_IMMUTABLE)
3983                 iflags |= FS_IMMUTABLE_FL;
3984 +       if (flags & BTRFS_INODE_IXUNLINK)
3985 +               iflags |= FS_IXUNLINK_FL;
3986 +
3987 +       if (flags & BTRFS_INODE_SYNC)
3988 +               iflags |= FS_SYNC_FL;
3989         if (flags & BTRFS_INODE_APPEND)
3990                 iflags |= FS_APPEND_FL;
3991         if (flags & BTRFS_INODE_NODUMP)
3992 @@ -80,28 +83,78 @@ static unsigned int btrfs_flags_to_ioctl
3993         if (flags & BTRFS_INODE_DIRSYNC)
3994                 iflags |= FS_DIRSYNC_FL;
3995  
3996 +       if (flags & BTRFS_INODE_BARRIER)
3997 +               iflags |= FS_BARRIER_FL;
3998 +       if (flags & BTRFS_INODE_COW)
3999 +               iflags |= FS_COW_FL;
4000         return iflags;
4001  }
4002  
4003  /*
4004 - * Update inode->i_flags based on the btrfs internal flags.
4005 + * Update inode->i_(v)flags based on the btrfs internal flags.
4006   */
4007  void btrfs_update_iflags(struct inode *inode)
4008  {
4009         struct btrfs_inode *ip = BTRFS_I(inode);
4010  
4011 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4012 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4013 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4014  
4015 -       if (ip->flags & BTRFS_INODE_SYNC)
4016 -               inode->i_flags |= S_SYNC;
4017         if (ip->flags & BTRFS_INODE_IMMUTABLE)
4018                 inode->i_flags |= S_IMMUTABLE;
4019 +       if (ip->flags & BTRFS_INODE_IXUNLINK)
4020 +               inode->i_flags |= S_IXUNLINK;
4021 +
4022 +       if (ip->flags & BTRFS_INODE_SYNC)
4023 +               inode->i_flags |= S_SYNC;
4024         if (ip->flags & BTRFS_INODE_APPEND)
4025                 inode->i_flags |= S_APPEND;
4026         if (ip->flags & BTRFS_INODE_NOATIME)
4027                 inode->i_flags |= S_NOATIME;
4028         if (ip->flags & BTRFS_INODE_DIRSYNC)
4029                 inode->i_flags |= S_DIRSYNC;
4030 +
4031 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
4032 +
4033 +       if (ip->flags & BTRFS_INODE_BARRIER)
4034 +               inode->i_vflags |= V_BARRIER;
4035 +       if (ip->flags & BTRFS_INODE_COW)
4036 +               inode->i_vflags |= V_COW;
4037 +}
4038 +
4039 +/*
4040 + * Update btrfs internal flags from inode->i_(v)flags.
4041 + */
4042 +void btrfs_update_flags(struct inode *inode)
4043 +{
4044 +       struct btrfs_inode *ip = BTRFS_I(inode);
4045 +
4046 +       unsigned int flags = inode->i_flags;
4047 +       unsigned int vflags = inode->i_vflags;
4048 +
4049 +       ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
4050 +                       BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
4051 +                       BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
4052 +                       BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
4053 +
4054 +       if (flags & S_IMMUTABLE)
4055 +               ip->flags |= BTRFS_INODE_IMMUTABLE;
4056 +       if (flags & S_IXUNLINK)
4057 +               ip->flags |= BTRFS_INODE_IXUNLINK;
4058 +
4059 +       if (flags & S_SYNC)
4060 +               ip->flags |= BTRFS_INODE_SYNC;
4061 +       if (flags & S_APPEND)
4062 +               ip->flags |= BTRFS_INODE_APPEND;
4063 +       if (flags & S_NOATIME)
4064 +               ip->flags |= BTRFS_INODE_NOATIME;
4065 +       if (flags & S_DIRSYNC)
4066 +               ip->flags |= BTRFS_INODE_DIRSYNC;
4067 +
4068 +       if (vflags & V_BARRIER)
4069 +               ip->flags |= BTRFS_INODE_BARRIER;
4070 +       if (vflags & V_COW)
4071 +               ip->flags |= BTRFS_INODE_COW;
4072  }
4073  
4074  /*
4075 @@ -119,7 +172,7 @@ void btrfs_inherit_iflags(struct inode *
4076         flags = BTRFS_I(dir)->flags;
4077  
4078         if (S_ISREG(inode->i_mode))
4079 -               flags &= ~BTRFS_INODE_DIRSYNC;
4080 +               flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
4081         else if (!S_ISDIR(inode->i_mode))
4082                 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
4083  
4084 @@ -127,6 +180,30 @@ void btrfs_inherit_iflags(struct inode *
4085         btrfs_update_iflags(inode);
4086  }
4087  
4088 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
4089 +{
4090 +       struct btrfs_inode *ip = BTRFS_I(inode);
4091 +       struct btrfs_root *root = ip->root;
4092 +       struct btrfs_trans_handle *trans;
4093 +       int ret;
4094 +
4095 +       trans = btrfs_join_transaction(root, 1);
4096 +       BUG_ON(!trans);
4097 +
4098 +       inode->i_flags = flags;
4099 +       inode->i_vflags = vflags;
4100 +       btrfs_update_flags(inode);
4101 +
4102 +       ret = btrfs_update_inode(trans, root, inode);
4103 +       BUG_ON(ret);
4104 +
4105 +       btrfs_update_iflags(inode);
4106 +       inode->i_ctime = CURRENT_TIME;
4107 +       btrfs_end_transaction(trans, root);
4108 +
4109 +       return 0;
4110 +}
4111 +
4112  static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
4113  {
4114         struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
4115 @@ -149,6 +226,7 @@ static int btrfs_ioctl_setflags(struct f
4116         if (copy_from_user(&flags, arg, sizeof(flags)))
4117                 return -EFAULT;
4118  
4119 +       /* maybe add FS_IXUNLINK_FL ? */
4120         if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
4121                       FS_NOATIME_FL | FS_NODUMP_FL | \
4122                       FS_SYNC_FL | FS_DIRSYNC_FL))
4123 @@ -161,7 +239,8 @@ static int btrfs_ioctl_setflags(struct f
4124  
4125         flags = btrfs_mask_flags(inode->i_mode, flags);
4126         oldflags = btrfs_flags_to_ioctl(ip->flags);
4127 -       if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
4128 +       if ((flags ^ oldflags) & (FS_APPEND_FL |
4129 +               FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
4130                 if (!capable(CAP_LINUX_IMMUTABLE)) {
4131                         ret = -EPERM;
4132                         goto out_unlock;
4133 @@ -172,14 +251,19 @@ static int btrfs_ioctl_setflags(struct f
4134         if (ret)
4135                 goto out_unlock;
4136  
4137 -       if (flags & FS_SYNC_FL)
4138 -               ip->flags |= BTRFS_INODE_SYNC;
4139 -       else
4140 -               ip->flags &= ~BTRFS_INODE_SYNC;
4141         if (flags & FS_IMMUTABLE_FL)
4142                 ip->flags |= BTRFS_INODE_IMMUTABLE;
4143         else
4144                 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
4145 +       if (flags & FS_IXUNLINK_FL)
4146 +               ip->flags |= BTRFS_INODE_IXUNLINK;
4147 +       else
4148 +               ip->flags &= ~BTRFS_INODE_IXUNLINK;
4149 +
4150 +       if (flags & FS_SYNC_FL)
4151 +               ip->flags |= BTRFS_INODE_SYNC;
4152 +       else
4153 +               ip->flags &= ~BTRFS_INODE_SYNC;
4154         if (flags & FS_APPEND_FL)
4155                 ip->flags |= BTRFS_INODE_APPEND;
4156         else
4157 diff -NurpP --minimal linux-2.6.33.2/fs/btrfs/super.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/btrfs/super.c
4158 --- linux-2.6.33.2/fs/btrfs/super.c     2010-02-25 11:52:04.000000000 +0100
4159 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/btrfs/super.c     2010-02-25 15:33:43.000000000 +0100
4160 @@ -68,7 +68,7 @@ enum {
4161         Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl,
4162         Opt_compress, Opt_compress_force, Opt_notreelog, Opt_ratio,
4163         Opt_flushoncommit,
4164 -       Opt_discard, Opt_err,
4165 +       Opt_tag, Opt_notag, Opt_tagid, Opt_discard, Opt_err,
4166  };
4167  
4168  static match_table_t tokens = {
4169 @@ -92,6 +92,9 @@ static match_table_t tokens = {
4170         {Opt_flushoncommit, "flushoncommit"},
4171         {Opt_ratio, "metadata_ratio=%d"},
4172         {Opt_discard, "discard"},
4173 +       {Opt_tag, "tag"},
4174 +       {Opt_notag, "notag"},
4175 +       {Opt_tagid, "tagid=%u"},
4176         {Opt_err, NULL},
4177  };
4178  
4179 @@ -270,6 +273,22 @@ int btrfs_parse_options(struct btrfs_roo
4180                 case Opt_discard:
4181                         btrfs_set_opt(info->mount_opt, DISCARD);
4182                         break;
4183 +#ifndef CONFIG_TAGGING_NONE
4184 +               case Opt_tag:
4185 +                       printk(KERN_INFO "btrfs: use tagging\n");
4186 +                       btrfs_set_opt(info->mount_opt, TAGGED);
4187 +                       break;
4188 +               case Opt_notag:
4189 +                       printk(KERN_INFO "btrfs: disabled tagging\n");
4190 +                       btrfs_clear_opt(info->mount_opt, TAGGED);
4191 +                       break;
4192 +#endif
4193 +#ifdef CONFIG_PROPAGATE
4194 +               case Opt_tagid:
4195 +                       /* use args[0] */
4196 +                       btrfs_set_opt(info->mount_opt, TAGGED);
4197 +                       break;
4198 +#endif
4199                 case Opt_err:
4200                         printk(KERN_INFO "btrfs: unrecognized mount option "
4201                                "'%s'\n", p);
4202 @@ -591,6 +610,12 @@ static int btrfs_remount(struct super_bl
4203         if (ret)
4204                 return -EINVAL;
4205  
4206 +       if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4207 +               printk("btrfs: %s: tagging not permitted on remount.\n",
4208 +                       sb->s_id);
4209 +               return -EINVAL;
4210 +       }
4211 +
4212         if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
4213                 return 0;
4214  
4215 diff -NurpP --minimal linux-2.6.33.2/fs/char_dev.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/char_dev.c
4216 --- linux-2.6.33.2/fs/char_dev.c        2009-12-03 20:02:51.000000000 +0100
4217 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/char_dev.c        2010-02-25 12:02:16.000000000 +0100
4218 @@ -20,6 +20,8 @@
4219  #include <linux/cdev.h>
4220  #include <linux/mutex.h>
4221  #include <linux/backing-dev.h>
4222 +#include <linux/vs_context.h>
4223 +#include <linux/vs_device.h>
4224  
4225  #include "internal.h"
4226  
4227 @@ -368,14 +370,21 @@ static int chrdev_open(struct inode *ino
4228         struct cdev *p;
4229         struct cdev *new = NULL;
4230         int ret = 0;
4231 +       dev_t mdev;
4232 +
4233 +       if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
4234 +               return -EPERM;
4235 +       inode->i_mdev = mdev;
4236  
4237         spin_lock(&cdev_lock);
4238         p = inode->i_cdev;
4239         if (!p) {
4240                 struct kobject *kobj;
4241                 int idx;
4242 +
4243                 spin_unlock(&cdev_lock);
4244 -               kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
4245 +
4246 +               kobj = kobj_lookup(cdev_map, mdev, &idx);
4247                 if (!kobj)
4248                         return -ENXIO;
4249                 new = container_of(kobj, struct cdev, kobj);
4250 diff -NurpP --minimal linux-2.6.33.2/fs/dcache.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/dcache.c
4251 --- linux-2.6.33.2/fs/dcache.c  2010-02-25 11:52:05.000000000 +0100
4252 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/dcache.c  2010-02-25 12:02:16.000000000 +0100
4253 @@ -33,6 +33,7 @@
4254  #include <linux/bootmem.h>
4255  #include <linux/fs_struct.h>
4256  #include <linux/hardirq.h>
4257 +#include <linux/vs_limit.h>
4258  #include "internal.h"
4259  
4260  int sysctl_vfs_cache_pressure __read_mostly = 100;
4261 @@ -230,6 +231,8 @@ repeat:
4262                 return;
4263         }
4264  
4265 +       vx_dentry_dec(dentry);
4266 +
4267         /*
4268          * AV: ->d_delete() is _NOT_ allowed to block now.
4269          */
4270 @@ -321,6 +324,7 @@ static inline struct dentry * __dget_loc
4271  {
4272         atomic_inc(&dentry->d_count);
4273         dentry_lru_del_init(dentry);
4274 +       vx_dentry_inc(dentry);
4275         return dentry;
4276  }
4277  
4278 @@ -919,6 +923,9 @@ struct dentry *d_alloc(struct dentry * p
4279         struct dentry *dentry;
4280         char *dname;
4281  
4282 +       if (!vx_dentry_avail(1))
4283 +               return NULL;
4284 +
4285         dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
4286         if (!dentry)
4287                 return NULL;
4288 @@ -964,6 +971,7 @@ struct dentry *d_alloc(struct dentry * p
4289         if (parent)
4290                 list_add(&dentry->d_u.d_child, &parent->d_subdirs);
4291         dentry_stat.nr_dentry++;
4292 +       vx_dentry_inc(dentry);
4293         spin_unlock(&dcache_lock);
4294  
4295         return dentry;
4296 @@ -1408,6 +1416,7 @@ struct dentry * __d_lookup(struct dentry
4297                 }
4298  
4299                 atomic_inc(&dentry->d_count);
4300 +               vx_dentry_inc(dentry);
4301                 found = dentry;
4302                 spin_unlock(&dentry->d_lock);
4303                 break;
4304 diff -NurpP --minimal linux-2.6.33.2/fs/devpts/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/devpts/inode.c
4305 --- linux-2.6.33.2/fs/devpts/inode.c    2010-02-25 11:52:05.000000000 +0100
4306 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/devpts/inode.c    2010-02-25 12:02:16.000000000 +0100
4307 @@ -24,6 +24,7 @@
4308  #include <linux/parser.h>
4309  #include <linux/fsnotify.h>
4310  #include <linux/seq_file.h>
4311 +#include <linux/vs_base.h>
4312  
4313  #define DEVPTS_DEFAULT_MODE 0600
4314  /*
4315 @@ -35,6 +36,20 @@
4316  #define DEVPTS_DEFAULT_PTMX_MODE 0000
4317  #define PTMX_MINOR     2
4318  
4319 +static int devpts_permission(struct inode *inode, int mask)
4320 +{
4321 +       int ret = -EACCES;
4322 +
4323 +       /* devpts is xid tagged */
4324 +       if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
4325 +               ret = generic_permission(inode, mask, NULL);
4326 +       return ret;
4327 +}
4328 +
4329 +static struct inode_operations devpts_file_inode_operations = {
4330 +       .permission     = devpts_permission,
4331 +};
4332 +
4333  extern int pty_limit;                  /* Config limit on Unix98 ptys */
4334  static DEFINE_MUTEX(allocated_ptys_lock);
4335  
4336 @@ -262,6 +277,25 @@ static int devpts_show_options(struct se
4337         return 0;
4338  }
4339  
4340 +static int devpts_filter(struct dentry *de)
4341 +{
4342 +       /* devpts is xid tagged */
4343 +       return vx_check((xid_t)de->d_inode->i_tag, VS_WATCH_P | VS_IDENT);
4344 +}
4345 +
4346 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
4347 +{
4348 +       return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
4349 +}
4350 +
4351 +static struct file_operations devpts_dir_operations = {
4352 +       .open           = dcache_dir_open,
4353 +       .release        = dcache_dir_close,
4354 +       .llseek         = dcache_dir_lseek,
4355 +       .read           = generic_read_dir,
4356 +       .readdir        = devpts_readdir,
4357 +};
4358 +
4359  static const struct super_operations devpts_sops = {
4360         .statfs         = simple_statfs,
4361         .remount_fs     = devpts_remount,
4362 @@ -301,12 +335,15 @@ devpts_fill_super(struct super_block *s,
4363         inode = new_inode(s);
4364         if (!inode)
4365                 goto free_fsi;
4366 +
4367         inode->i_ino = 1;
4368         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4369         inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
4370         inode->i_op = &simple_dir_inode_operations;
4371 -       inode->i_fop = &simple_dir_operations;
4372 +       inode->i_fop = &devpts_dir_operations;
4373         inode->i_nlink = 2;
4374 +       /* devpts is xid tagged */
4375 +       inode->i_tag = (tag_t)vx_current_xid();
4376  
4377         s->s_root = d_alloc_root(inode);
4378         if (s->s_root)
4379 @@ -497,6 +534,9 @@ int devpts_pty_new(struct inode *ptmx_in
4380         inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
4381         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4382         init_special_inode(inode, S_IFCHR|opts->mode, device);
4383 +       /* devpts is xid tagged */
4384 +       inode->i_tag = (tag_t)vx_current_xid();
4385 +       inode->i_op = &devpts_file_inode_operations;
4386         inode->i_private = tty;
4387         tty->driver_data = inode;
4388  
4389 diff -NurpP --minimal linux-2.6.33.2/fs/exec.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/exec.c
4390 --- linux-2.6.33.2/fs/exec.c    2010-04-06 01:47:46.000000000 +0200
4391 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/exec.c    2010-04-06 01:59:25.000000000 +0200
4392 @@ -250,7 +250,9 @@ static int __bprm_mm_init(struct linux_b
4393         if (err)
4394                 goto err;
4395  
4396 -       mm->stack_vm = mm->total_vm = 1;
4397 +       mm->total_vm = 0;
4398 +       vx_vmpages_inc(mm);
4399 +       mm->stack_vm = 1;
4400         up_write(&mm->mmap_sem);
4401         bprm->p = vma->vm_end - sizeof(void *);
4402         return 0;
4403 @@ -1503,7 +1505,7 @@ static int format_corename(char *corenam
4404                         /* UNIX time of coredump */
4405                         case 't': {
4406                                 struct timeval tv;
4407 -                               do_gettimeofday(&tv);
4408 +                               vx_gettimeofday(&tv);
4409                                 rc = snprintf(out_ptr, out_end - out_ptr,
4410                                               "%lu", tv.tv_sec);
4411                                 if (rc > out_end - out_ptr)
4412 diff -NurpP --minimal linux-2.6.33.2/fs/ext2/balloc.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/balloc.c
4413 --- linux-2.6.33.2/fs/ext2/balloc.c     2009-06-11 17:13:03.000000000 +0200
4414 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/balloc.c     2010-02-25 12:02:16.000000000 +0100
4415 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block 
4416                         start = 0;
4417                 end = EXT2_BLOCKS_PER_GROUP(sb);
4418         }
4419 -
4420         BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
4421  
4422  repeat:
4423 diff -NurpP --minimal linux-2.6.33.2/fs/ext2/ext2.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/ext2.h
4424 --- linux-2.6.33.2/fs/ext2/ext2.h       2010-02-25 11:52:05.000000000 +0100
4425 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/ext2.h       2010-02-25 12:02:16.000000000 +0100
4426 @@ -131,6 +131,7 @@ extern int ext2_fiemap(struct inode *ino
4427  int __ext2_write_begin(struct file *file, struct address_space *mapping,
4428                 loff_t pos, unsigned len, unsigned flags,
4429                 struct page **pagep, void **fsdata);
4430 +extern int ext2_sync_flags(struct inode *, int, int);
4431  
4432  /* ioctl.c */
4433  extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
4434 diff -NurpP --minimal linux-2.6.33.2/fs/ext2/file.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/file.c
4435 --- linux-2.6.33.2/fs/ext2/file.c       2010-02-25 11:52:05.000000000 +0100
4436 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/file.c       2010-02-25 12:02:16.000000000 +0100
4437 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
4438         .setattr        = ext2_setattr,
4439         .check_acl      = ext2_check_acl,
4440         .fiemap         = ext2_fiemap,
4441 +       .sync_flags     = ext2_sync_flags,
4442  };
4443 diff -NurpP --minimal linux-2.6.33.2/fs/ext2/ialloc.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/ialloc.c
4444 --- linux-2.6.33.2/fs/ext2/ialloc.c     2009-06-11 17:13:03.000000000 +0200
4445 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/ialloc.c     2010-02-25 12:02:16.000000000 +0100
4446 @@ -17,6 +17,7 @@
4447  #include <linux/backing-dev.h>
4448  #include <linux/buffer_head.h>
4449  #include <linux/random.h>
4450 +#include <linux/vs_tag.h>
4451  #include "ext2.h"
4452  #include "xattr.h"
4453  #include "acl.h"
4454 @@ -560,6 +561,7 @@ got:
4455         } else
4456                 inode->i_gid = current_fsgid();
4457         inode->i_mode = mode;
4458 +       inode->i_tag = dx_current_fstag(sb);
4459  
4460         inode->i_ino = ino;
4461         inode->i_blocks = 0;
4462 diff -NurpP --minimal linux-2.6.33.2/fs/ext2/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/inode.c
4463 --- linux-2.6.33.2/fs/ext2/inode.c      2010-02-25 11:52:05.000000000 +0100
4464 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/inode.c      2010-02-25 12:02:16.000000000 +0100
4465 @@ -33,6 +33,7 @@
4466  #include <linux/mpage.h>
4467  #include <linux/fiemap.h>
4468  #include <linux/namei.h>
4469 +#include <linux/vs_tag.h>
4470  #include "ext2.h"
4471  #include "acl.h"
4472  #include "xip.h"
4473 @@ -1042,7 +1043,7 @@ void ext2_truncate(struct inode *inode)
4474                 return;
4475         if (ext2_inode_is_fast_symlink(inode))
4476                 return;
4477 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4478 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4479                 return;
4480  
4481         blocksize = inode->i_sb->s_blocksize;
4482 @@ -1180,36 +1181,61 @@ void ext2_set_inode_flags(struct inode *
4483  {
4484         unsigned int flags = EXT2_I(inode)->i_flags;
4485  
4486 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4487 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4488 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4489 +
4490 +
4491 +       if (flags & EXT2_IMMUTABLE_FL)
4492 +               inode->i_flags |= S_IMMUTABLE;
4493 +       if (flags & EXT2_IXUNLINK_FL)
4494 +               inode->i_flags |= S_IXUNLINK;
4495 +
4496         if (flags & EXT2_SYNC_FL)
4497                 inode->i_flags |= S_SYNC;
4498         if (flags & EXT2_APPEND_FL)
4499                 inode->i_flags |= S_APPEND;
4500 -       if (flags & EXT2_IMMUTABLE_FL)
4501 -               inode->i_flags |= S_IMMUTABLE;
4502         if (flags & EXT2_NOATIME_FL)
4503                 inode->i_flags |= S_NOATIME;
4504         if (flags & EXT2_DIRSYNC_FL)
4505                 inode->i_flags |= S_DIRSYNC;
4506 +
4507 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
4508 +
4509 +       if (flags & EXT2_BARRIER_FL)
4510 +               inode->i_vflags |= V_BARRIER;
4511 +       if (flags & EXT2_COW_FL)
4512 +               inode->i_vflags |= V_COW;
4513  }
4514  
4515  /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
4516  void ext2_get_inode_flags(struct ext2_inode_info *ei)
4517  {
4518         unsigned int flags = ei->vfs_inode.i_flags;
4519 +       unsigned int vflags = ei->vfs_inode.i_vflags;
4520 +
4521 +       ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
4522 +                       EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
4523 +                       EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
4524 +                       EXT2_BARRIER_FL | EXT2_COW_FL);
4525 +
4526 +       if (flags & S_IMMUTABLE)
4527 +               ei->i_flags |= EXT2_IMMUTABLE_FL;
4528 +       if (flags & S_IXUNLINK)
4529 +               ei->i_flags |= EXT2_IXUNLINK_FL;
4530  
4531 -       ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
4532 -                       EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
4533         if (flags & S_SYNC)
4534                 ei->i_flags |= EXT2_SYNC_FL;
4535         if (flags & S_APPEND)
4536                 ei->i_flags |= EXT2_APPEND_FL;
4537 -       if (flags & S_IMMUTABLE)
4538 -               ei->i_flags |= EXT2_IMMUTABLE_FL;
4539         if (flags & S_NOATIME)
4540                 ei->i_flags |= EXT2_NOATIME_FL;
4541         if (flags & S_DIRSYNC)
4542                 ei->i_flags |= EXT2_DIRSYNC_FL;
4543 +
4544 +       if (vflags & V_BARRIER)
4545 +               ei->i_flags |= EXT2_BARRIER_FL;
4546 +       if (vflags & V_COW)
4547 +               ei->i_flags |= EXT2_COW_FL;
4548  }
4549  
4550  struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
4551 @@ -1219,6 +1245,8 @@ struct inode *ext2_iget (struct super_bl
4552         struct ext2_inode *raw_inode;
4553         struct inode *inode;
4554         long ret = -EIO;
4555 +       uid_t uid;
4556 +       gid_t gid;
4557         int n;
4558  
4559         inode = iget_locked(sb, ino);
4560 @@ -1237,12 +1265,17 @@ struct inode *ext2_iget (struct super_bl
4561         }
4562  
4563         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4564 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4565 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4566 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4567 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4568         if (!(test_opt (inode->i_sb, NO_UID32))) {
4569 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4570 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4571 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4572 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4573         }
4574 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4575 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4576 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4577 +               le16_to_cpu(raw_inode->i_raw_tag));
4578 +
4579         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4580         inode->i_size = le32_to_cpu(raw_inode->i_size);
4581         inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4582 @@ -1340,8 +1373,8 @@ int ext2_write_inode(struct inode *inode
4583         struct ext2_inode_info *ei = EXT2_I(inode);
4584         struct super_block *sb = inode->i_sb;
4585         ino_t ino = inode->i_ino;
4586 -       uid_t uid = inode->i_uid;
4587 -       gid_t gid = inode->i_gid;
4588 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4589 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4590         struct buffer_head * bh;
4591         struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
4592         int n;
4593 @@ -1377,6 +1410,9 @@ int ext2_write_inode(struct inode *inode
4594                 raw_inode->i_uid_high = 0;
4595                 raw_inode->i_gid_high = 0;
4596         }
4597 +#ifdef CONFIG_TAGGING_INTERN
4598 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4599 +#endif
4600         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4601         raw_inode->i_size = cpu_to_le32(inode->i_size);
4602         raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4603 @@ -1458,7 +1494,8 @@ int ext2_setattr(struct dentry *dentry, 
4604         if (error)
4605                 return error;
4606         if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4607 -           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4608 +           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4609 +           (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4610                 error = vfs_dq_transfer(inode, iattr) ? -EDQUOT : 0;
4611                 if (error)
4612                         return error;
4613 diff -NurpP --minimal linux-2.6.33.2/fs/ext2/ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/ioctl.c
4614 --- linux-2.6.33.2/fs/ext2/ioctl.c      2009-09-10 15:26:21.000000000 +0200
4615 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/ioctl.c      2010-02-25 12:02:16.000000000 +0100
4616 @@ -17,6 +17,16 @@
4617  #include <asm/uaccess.h>
4618  
4619  
4620 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
4621 +{
4622 +       inode->i_flags = flags;
4623 +       inode->i_vflags = vflags;
4624 +       ext2_get_inode_flags(EXT2_I(inode));
4625 +       inode->i_ctime = CURRENT_TIME_SEC;
4626 +       mark_inode_dirty(inode);
4627 +       return 0;
4628 +}
4629 +
4630  long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4631  {
4632         struct inode *inode = filp->f_dentry->d_inode;
4633 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
4634  
4635                 flags = ext2_mask_flags(inode->i_mode, flags);
4636  
4637 +               if (IS_BARRIER(inode)) {
4638 +                       vxwprintk_task(1, "messing with the barrier.");
4639 +                       return -EACCES;
4640 +               }
4641 +
4642                 mutex_lock(&inode->i_mutex);
4643                 /* Is it quota file? Do not allow user to mess with it */
4644                 if (IS_NOQUOTA(inode)) {
4645 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
4646                  *
4647                  * This test looks nicer. Thanks to Pauline Middelink
4648                  */
4649 -               if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
4650 +               if ((oldflags & EXT2_IMMUTABLE_FL) ||
4651 +                       ((flags ^ oldflags) & (EXT2_APPEND_FL |
4652 +                       EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
4653                         if (!capable(CAP_LINUX_IMMUTABLE)) {
4654                                 mutex_unlock(&inode->i_mutex);
4655                                 ret = -EPERM;
4656 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
4657                         }
4658                 }
4659  
4660 -               flags = flags & EXT2_FL_USER_MODIFIABLE;
4661 +               flags &= EXT2_FL_USER_MODIFIABLE;
4662                 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
4663                 ei->i_flags = flags;
4664                 mutex_unlock(&inode->i_mutex);
4665 diff -NurpP --minimal linux-2.6.33.2/fs/ext2/namei.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/namei.c
4666 --- linux-2.6.33.2/fs/ext2/namei.c      2009-12-03 20:02:51.000000000 +0100
4667 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/namei.c      2010-02-25 12:02:16.000000000 +0100
4668 @@ -31,6 +31,7 @@
4669   */
4670  
4671  #include <linux/pagemap.h>
4672 +#include <linux/vs_tag.h>
4673  #include "ext2.h"
4674  #include "xattr.h"
4675  #include "acl.h"
4676 @@ -74,6 +75,7 @@ static struct dentry *ext2_lookup(struct
4677                                 return ERR_PTR(-EIO);
4678                         } else {
4679                                 return ERR_CAST(inode);
4680 +               dx_propagate_tag(nd, inode);
4681                         }
4682                 }
4683         }
4684 @@ -401,6 +403,7 @@ const struct inode_operations ext2_dir_i
4685  #endif
4686         .setattr        = ext2_setattr,
4687         .check_acl      = ext2_check_acl,
4688 +       .sync_flags     = ext2_sync_flags,
4689  };
4690  
4691  const struct inode_operations ext2_special_inode_operations = {
4692 diff -NurpP --minimal linux-2.6.33.2/fs/ext2/super.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/super.c
4693 --- linux-2.6.33.2/fs/ext2/super.c      2010-02-25 11:52:05.000000000 +0100
4694 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext2/super.c      2010-02-25 12:02:16.000000000 +0100
4695 @@ -382,7 +382,8 @@ enum {
4696         Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
4697         Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
4698         Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
4699 -       Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
4700 +       Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
4701 +       Opt_tag, Opt_notag, Opt_tagid
4702  };
4703  
4704  static const match_table_t tokens = {
4705 @@ -410,6 +411,9 @@ static const match_table_t tokens = {
4706         {Opt_acl, "acl"},
4707         {Opt_noacl, "noacl"},
4708         {Opt_xip, "xip"},
4709 +       {Opt_tag, "tag"},
4710 +       {Opt_notag, "notag"},
4711 +       {Opt_tagid, "tagid=%u"},
4712         {Opt_grpquota, "grpquota"},
4713         {Opt_ignore, "noquota"},
4714         {Opt_quota, "quota"},
4715 @@ -480,6 +484,20 @@ static int parse_options(char *options, 
4716                 case Opt_nouid32:
4717                         set_opt (sbi->s_mount_opt, NO_UID32);
4718                         break;
4719 +#ifndef CONFIG_TAGGING_NONE
4720 +               case Opt_tag:
4721 +                       set_opt (sbi->s_mount_opt, TAGGED);
4722 +                       break;
4723 +               case Opt_notag:
4724 +                       clear_opt (sbi->s_mount_opt, TAGGED);
4725 +                       break;
4726 +#endif
4727 +#ifdef CONFIG_PROPAGATE
4728 +               case Opt_tagid:
4729 +                       /* use args[0] */
4730 +                       set_opt (sbi->s_mount_opt, TAGGED);
4731 +                       break;
4732 +#endif
4733                 case Opt_nocheck:
4734                         clear_opt (sbi->s_mount_opt, CHECK);
4735                         break;
4736 @@ -836,6 +854,8 @@ static int ext2_fill_super(struct super_
4737         if (!parse_options((char *) data, sb))
4738                 goto failed_mount;
4739  
4740 +       if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
4741 +               sb->s_flags |= MS_TAGGED;
4742         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4743                 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
4744                  MS_POSIXACL : 0);
4745 @@ -1229,6 +1249,14 @@ static int ext2_remount (struct super_bl
4746                 goto restore_opts;
4747         }
4748  
4749 +       if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
4750 +               !(sb->s_flags & MS_TAGGED)) {
4751 +               printk("EXT2-fs: %s: tagging not permitted on remount.\n",
4752 +                      sb->s_id);
4753 +               err = -EINVAL;
4754 +               goto restore_opts;
4755 +       }
4756 +
4757         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4758                 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4759  
4760 diff -NurpP --minimal linux-2.6.33.2/fs/ext3/file.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/file.c
4761 --- linux-2.6.33.2/fs/ext3/file.c       2009-12-03 20:02:51.000000000 +0100
4762 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/file.c       2010-02-25 12:02:16.000000000 +0100
4763 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
4764  #endif
4765         .check_acl      = ext3_check_acl,
4766         .fiemap         = ext3_fiemap,
4767 +       .sync_flags     = ext3_sync_flags,
4768  };
4769  
4770 diff -NurpP --minimal linux-2.6.33.2/fs/ext3/ialloc.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/ialloc.c
4771 --- linux-2.6.33.2/fs/ext3/ialloc.c     2009-09-10 15:26:21.000000000 +0200
4772 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/ialloc.c     2010-02-25 12:02:16.000000000 +0100
4773 @@ -23,6 +23,7 @@
4774  #include <linux/buffer_head.h>
4775  #include <linux/random.h>
4776  #include <linux/bitops.h>
4777 +#include <linux/vs_tag.h>
4778  
4779  #include <asm/byteorder.h>
4780  
4781 @@ -548,6 +549,7 @@ got:
4782         } else
4783                 inode->i_gid = current_fsgid();
4784         inode->i_mode = mode;
4785 +       inode->i_tag = dx_current_fstag(sb);
4786  
4787         inode->i_ino = ino;
4788         /* This is the optimal IO size (for stat), not the fs block size */
4789 diff -NurpP --minimal linux-2.6.33.2/fs/ext3/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/inode.c
4790 --- linux-2.6.33.2/fs/ext3/inode.c      2010-02-25 11:52:05.000000000 +0100
4791 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/inode.c      2010-02-25 12:02:16.000000000 +0100
4792 @@ -38,6 +38,7 @@
4793  #include <linux/bio.h>
4794  #include <linux/fiemap.h>
4795  #include <linux/namei.h>
4796 +#include <linux/vs_tag.h>
4797  #include "xattr.h"
4798  #include "acl.h"
4799  
4800 @@ -2343,7 +2344,7 @@ static void ext3_free_branches(handle_t 
4801  
4802  int ext3_can_truncate(struct inode *inode)
4803  {
4804 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4805 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4806                 return 0;
4807         if (S_ISREG(inode->i_mode))
4808                 return 1;
4809 @@ -2728,36 +2729,60 @@ void ext3_set_inode_flags(struct inode *
4810  {
4811         unsigned int flags = EXT3_I(inode)->i_flags;
4812  
4813 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4814 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4815 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4816 +
4817 +       if (flags & EXT3_IMMUTABLE_FL)
4818 +               inode->i_flags |= S_IMMUTABLE;
4819 +       if (flags & EXT3_IXUNLINK_FL)
4820 +               inode->i_flags |= S_IXUNLINK;
4821 +
4822         if (flags & EXT3_SYNC_FL)
4823                 inode->i_flags |= S_SYNC;
4824         if (flags & EXT3_APPEND_FL)
4825                 inode->i_flags |= S_APPEND;
4826 -       if (flags & EXT3_IMMUTABLE_FL)
4827 -               inode->i_flags |= S_IMMUTABLE;
4828         if (flags & EXT3_NOATIME_FL)
4829                 inode->i_flags |= S_NOATIME;
4830         if (flags & EXT3_DIRSYNC_FL)
4831                 inode->i_flags |= S_DIRSYNC;
4832 +
4833 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
4834 +
4835 +       if (flags & EXT3_BARRIER_FL)
4836 +               inode->i_vflags |= V_BARRIER;
4837 +       if (flags & EXT3_COW_FL)
4838 +               inode->i_vflags |= V_COW;
4839  }
4840  
4841  /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
4842  void ext3_get_inode_flags(struct ext3_inode_info *ei)
4843  {
4844         unsigned int flags = ei->vfs_inode.i_flags;
4845 +       unsigned int vflags = ei->vfs_inode.i_vflags;
4846 +
4847 +       ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
4848 +                       EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
4849 +                       EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
4850 +                       EXT3_BARRIER_FL | EXT3_COW_FL);
4851 +
4852 +       if (flags & S_IMMUTABLE)
4853 +               ei->i_flags |= EXT3_IMMUTABLE_FL;
4854 +       if (flags & S_IXUNLINK)
4855 +               ei->i_flags |= EXT3_IXUNLINK_FL;
4856  
4857 -       ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
4858 -                       EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
4859         if (flags & S_SYNC)
4860                 ei->i_flags |= EXT3_SYNC_FL;
4861         if (flags & S_APPEND)
4862                 ei->i_flags |= EXT3_APPEND_FL;
4863 -       if (flags & S_IMMUTABLE)
4864 -               ei->i_flags |= EXT3_IMMUTABLE_FL;
4865         if (flags & S_NOATIME)
4866                 ei->i_flags |= EXT3_NOATIME_FL;
4867         if (flags & S_DIRSYNC)
4868                 ei->i_flags |= EXT3_DIRSYNC_FL;
4869 +
4870 +       if (vflags & V_BARRIER)
4871 +               ei->i_flags |= EXT3_BARRIER_FL;
4872 +       if (vflags & V_COW)
4873 +               ei->i_flags |= EXT3_COW_FL;
4874  }
4875  
4876  struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
4877 @@ -2771,6 +2796,8 @@ struct inode *ext3_iget(struct super_blo
4878         transaction_t *transaction;
4879         long ret;
4880         int block;
4881 +       uid_t uid;
4882 +       gid_t gid;
4883  
4884         inode = iget_locked(sb, ino);
4885         if (!inode)
4886 @@ -2787,12 +2814,17 @@ struct inode *ext3_iget(struct super_blo
4887         bh = iloc.bh;
4888         raw_inode = ext3_raw_inode(&iloc);
4889         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4890 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4891 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4892 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4893 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4894         if(!(test_opt (inode->i_sb, NO_UID32))) {
4895 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4896 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4897 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4898 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4899         }
4900 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4901 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4902 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4903 +               le16_to_cpu(raw_inode->i_raw_tag));
4904 +
4905         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4906         inode->i_size = le32_to_cpu(raw_inode->i_size);
4907         inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4908 @@ -2947,6 +2979,8 @@ static int ext3_do_update_inode(handle_t
4909         struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
4910         struct ext3_inode_info *ei = EXT3_I(inode);
4911         struct buffer_head *bh = iloc->bh;
4912 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4913 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4914         int err = 0, rc, block;
4915  
4916  again:
4917 @@ -2961,29 +2995,32 @@ again:
4918         ext3_get_inode_flags(ei);
4919         raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4920         if(!(test_opt(inode->i_sb, NO_UID32))) {
4921 -               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4922 -               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4923 +               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4924 +               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4925  /*
4926   * Fix up interoperability with old kernels. Otherwise, old inodes get
4927   * re-used with the upper 16 bits of the uid/gid intact
4928   */
4929                 if(!ei->i_dtime) {
4930                         raw_inode->i_uid_high =
4931 -                               cpu_to_le16(high_16_bits(inode->i_uid));
4932 +                               cpu_to_le16(high_16_bits(uid));
4933                         raw_inode->i_gid_high =
4934 -                               cpu_to_le16(high_16_bits(inode->i_gid));
4935 +                               cpu_to_le16(high_16_bits(gid));
4936                 } else {
4937                         raw_inode->i_uid_high = 0;
4938                         raw_inode->i_gid_high = 0;
4939                 }
4940         } else {
4941                 raw_inode->i_uid_low =
4942 -                       cpu_to_le16(fs_high2lowuid(inode->i_uid));
4943 +                       cpu_to_le16(fs_high2lowuid(uid));
4944                 raw_inode->i_gid_low =
4945 -                       cpu_to_le16(fs_high2lowgid(inode->i_gid));
4946 +                       cpu_to_le16(fs_high2lowgid(gid));
4947                 raw_inode->i_uid_high = 0;
4948                 raw_inode->i_gid_high = 0;
4949         }
4950 +#ifdef CONFIG_TAGGING_INTERN
4951 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4952 +#endif
4953         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4954         raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4955         raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4956 @@ -3141,7 +3178,8 @@ int ext3_setattr(struct dentry *dentry, 
4957                 return error;
4958  
4959         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4960 -               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4961 +               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4962 +               (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4963                 handle_t *handle;
4964  
4965                 /* (user+group)*(old+new) structure, inode write (sb,
4966 @@ -3163,6 +3201,8 @@ int ext3_setattr(struct dentry *dentry, 
4967                         inode->i_uid = attr->ia_uid;
4968                 if (attr->ia_valid & ATTR_GID)
4969                         inode->i_gid = attr->ia_gid;
4970 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4971 +                       inode->i_tag = attr->ia_tag;
4972                 error = ext3_mark_inode_dirty(handle, inode);
4973                 ext3_journal_stop(handle);
4974         }
4975 diff -NurpP --minimal linux-2.6.33.2/fs/ext3/ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/ioctl.c
4976 --- linux-2.6.33.2/fs/ext3/ioctl.c      2009-06-11 17:13:03.000000000 +0200
4977 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/ioctl.c      2010-02-25 12:02:16.000000000 +0100
4978 @@ -8,6 +8,7 @@
4979   */
4980  
4981  #include <linux/fs.h>
4982 +#include <linux/mount.h>
4983  #include <linux/jbd.h>
4984  #include <linux/capability.h>
4985  #include <linux/ext3_fs.h>
4986 @@ -17,6 +18,34 @@
4987  #include <linux/compat.h>
4988  #include <asm/uaccess.h>
4989  
4990 +
4991 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
4992 +{
4993 +       handle_t *handle = NULL;
4994 +       struct ext3_iloc iloc;
4995 +       int err;
4996 +
4997 +       handle = ext3_journal_start(inode, 1);
4998 +       if (IS_ERR(handle))
4999 +               return PTR_ERR(handle);
5000 +
5001 +       if (IS_SYNC(inode))
5002 +               handle->h_sync = 1;
5003 +       err = ext3_reserve_inode_write(handle, inode, &iloc);
5004 +       if (err)
5005 +               goto flags_err;
5006 +
5007 +       inode->i_flags = flags;
5008 +       inode->i_vflags = vflags;
5009 +       ext3_get_inode_flags(EXT3_I(inode));
5010 +       inode->i_ctime = CURRENT_TIME_SEC;
5011 +
5012 +       err = ext3_mark_iloc_dirty(handle, inode, &iloc);
5013 +flags_err:
5014 +       ext3_journal_stop(handle);
5015 +       return err;
5016 +}
5017 +
5018  long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5019  {
5020         struct inode *inode = filp->f_dentry->d_inode;
5021 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
5022  
5023                 flags = ext3_mask_flags(inode->i_mode, flags);
5024  
5025 +               if (IS_BARRIER(inode)) {
5026 +                       vxwprintk_task(1, "messing with the barrier.");
5027 +                       return -EACCES;
5028 +               }
5029 +
5030                 mutex_lock(&inode->i_mutex);
5031  
5032                 /* Is it quota file? Do not allow user to mess with it */
5033 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
5034                  *
5035                  * This test looks nicer. Thanks to Pauline Middelink
5036                  */
5037 -               if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
5038 +               if ((oldflags & EXT3_IMMUTABLE_FL) ||
5039 +                       ((flags ^ oldflags) & (EXT3_APPEND_FL |
5040 +                       EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
5041                         if (!capable(CAP_LINUX_IMMUTABLE))
5042                                 goto flags_out;
5043                 }
5044 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
5045                 if (err)
5046                         goto flags_err;
5047  
5048 -               flags = flags & EXT3_FL_USER_MODIFIABLE;
5049 +               flags &= EXT3_FL_USER_MODIFIABLE;
5050                 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
5051                 ei->i_flags = flags;
5052  
5053 diff -NurpP --minimal linux-2.6.33.2/fs/ext3/namei.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/namei.c
5054 --- linux-2.6.33.2/fs/ext3/namei.c      2010-02-25 11:52:05.000000000 +0100
5055 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/namei.c      2010-02-25 12:02:16.000000000 +0100
5056 @@ -36,6 +36,7 @@
5057  #include <linux/quotaops.h>
5058  #include <linux/buffer_head.h>
5059  #include <linux/bio.h>
5060 +#include <linux/vs_tag.h>
5061  
5062  #include "namei.h"
5063  #include "xattr.h"
5064 @@ -912,6 +913,7 @@ restart:
5065                                 if (bh)
5066                                         ll_rw_block(READ_META, 1, &bh);
5067                         }
5068 +               dx_propagate_tag(nd, inode);
5069                 }
5070                 if ((bh = bh_use[ra_ptr++]) == NULL)
5071                         goto next;
5072 @@ -2448,6 +2450,7 @@ const struct inode_operations ext3_dir_i
5073         .removexattr    = generic_removexattr,
5074  #endif
5075         .check_acl      = ext3_check_acl,
5076 +       .sync_flags     = ext3_sync_flags,
5077  };
5078  
5079  const struct inode_operations ext3_special_inode_operations = {
5080 diff -NurpP --minimal linux-2.6.33.2/fs/ext3/super.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/super.c
5081 --- linux-2.6.33.2/fs/ext3/super.c      2010-02-25 11:52:05.000000000 +0100
5082 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext3/super.c      2010-02-25 13:29:21.000000000 +0100
5083 @@ -817,7 +817,7 @@ enum {
5084         Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
5085         Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
5086         Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
5087 -       Opt_usrquota, Opt_grpquota
5088 +       Opt_usrquota, Opt_grpquota, Opt_tag, Opt_notag, Opt_tagid
5089  };
5090  
5091  static const match_table_t tokens = {
5092 @@ -872,6 +872,9 @@ static const match_table_t tokens = {
5093         {Opt_usrquota, "usrquota"},
5094         {Opt_barrier, "barrier=%u"},
5095         {Opt_resize, "resize"},
5096 +       {Opt_tag, "tag"},
5097 +       {Opt_notag, "notag"},
5098 +       {Opt_tagid, "tagid=%u"},
5099         {Opt_err, NULL},
5100  };
5101  
5102 @@ -964,6 +967,20 @@ static int parse_options (char *options,
5103                 case Opt_nouid32:
5104                         set_opt (sbi->s_mount_opt, NO_UID32);
5105                         break;
5106 +#ifndef CONFIG_TAGGING_NONE
5107 +               case Opt_tag:
5108 +                       set_opt (sbi->s_mount_opt, TAGGED);
5109 +                       break;
5110 +               case Opt_notag:
5111 +                       clear_opt (sbi->s_mount_opt, TAGGED);
5112 +                       break;
5113 +#endif
5114 +#ifdef CONFIG_PROPAGATE
5115 +               case Opt_tagid:
5116 +                       /* use args[0] */
5117 +                       set_opt (sbi->s_mount_opt, TAGGED);
5118 +                       break;
5119 +#endif
5120                 case Opt_nocheck:
5121                         clear_opt (sbi->s_mount_opt, CHECK);
5122                         break;
5123 @@ -1693,6 +1710,9 @@ static int ext3_fill_super (struct super
5124                             NULL, 0))
5125                 goto failed_mount;
5126  
5127 +       if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
5128 +               sb->s_flags |= MS_TAGGED;
5129 +
5130         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5131                 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
5132  
5133 @@ -2564,6 +2584,14 @@ static int ext3_remount (struct super_bl
5134         if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
5135                 ext3_abort(sb, __func__, "Abort forced by user");
5136  
5137 +       if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
5138 +               !(sb->s_flags & MS_TAGGED)) {
5139 +               printk("EXT3-fs: %s: tagging not permitted on remount.\n",
5140 +                       sb->s_id);
5141 +               err = -EINVAL;
5142 +               goto restore_opts;
5143 +       }
5144 +
5145         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5146                 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
5147  
5148 diff -NurpP --minimal linux-2.6.33.2/fs/ext4/ext4.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/ext4.h
5149 --- linux-2.6.33.2/fs/ext4/ext4.h       2010-02-25 11:52:05.000000000 +0100
5150 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/ext4.h       2010-02-25 12:02:16.000000000 +0100
5151 @@ -284,8 +284,12 @@ struct flex_groups {
5152  #define EXT4_TOPDIR_FL                 0x00020000 /* Top of directory hierarchies*/
5153  #define EXT4_HUGE_FILE_FL               0x00040000 /* Set to each huge file */
5154  #define EXT4_EXTENTS_FL                        0x00080000 /* Inode uses extents */
5155 +#define EXT4_IXUNLINK_FL               0x08000000 /* Immutable invert on unlink */
5156  #define EXT4_RESERVED_FL               0x80000000 /* reserved for ext4 lib */
5157  
5158 +#define EXT4_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
5159 +#define EXT4_COW_FL                    0x20000000 /* Copy on Write marker */
5160 +
5161  #define EXT4_FL_USER_VISIBLE           0x000BDFFF /* User visible flags */
5162  #define EXT4_FL_USER_MODIFIABLE                0x000B80FF /* User modifiable flags */
5163  
5164 @@ -472,7 +476,8 @@ struct ext4_inode {
5165                         __le16  l_i_file_acl_high;
5166                         __le16  l_i_uid_high;   /* these 2 fields */
5167                         __le16  l_i_gid_high;   /* were reserved2[0] */
5168 -                       __u32   l_i_reserved2;
5169 +                       __le16  l_i_tag;        /* Context Tag */
5170 +                       __u16   l_i_reserved2;
5171                 } linux2;
5172                 struct {
5173                         __le16  h_i_reserved1;  /* Obsoleted fragment number/size which are removed in ext4 */
5174 @@ -586,6 +591,7 @@ do {                                                                               \
5175  #define i_gid_low      i_gid
5176  #define i_uid_high     osd2.linux2.l_i_uid_high
5177  #define i_gid_high     osd2.linux2.l_i_gid_high
5178 +#define i_raw_tag      osd2.linux2.l_i_tag
5179  #define i_reserved2    osd2.linux2.l_i_reserved2
5180  
5181  #elif defined(__GNU__)
5182 @@ -760,6 +766,7 @@ struct ext4_inode_info {
5183  #define EXT4_MOUNT_QUOTA               0x80000 /* Some quota option set */
5184  #define EXT4_MOUNT_USRQUOTA            0x100000 /* "old" user quota */
5185  #define EXT4_MOUNT_GRPQUOTA            0x200000 /* "old" group quota */
5186 +#define EXT4_MOUNT_TAGGED              0x400000 /* Enable Context Tags */
5187  #define EXT4_MOUNT_JOURNAL_CHECKSUM    0x800000 /* Journal checksums */
5188  #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT        0x1000000 /* Journal Async Commit */
5189  #define EXT4_MOUNT_I_VERSION            0x2000000 /* i_version support */
5190 @@ -1750,6 +1757,7 @@ extern int ext4_get_blocks(handle_t *han
5191                            struct buffer_head *bh, int flags);
5192  extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
5193                         __u64 start, __u64 len);
5194 +extern int ext4_sync_flags(struct inode *, int, int);
5195  /* move_extent.c */
5196  extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
5197                              __u64 start_orig, __u64 start_donor,
5198 diff -NurpP --minimal linux-2.6.33.2/fs/ext4/file.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/file.c
5199 --- linux-2.6.33.2/fs/ext4/file.c       2009-12-03 20:02:51.000000000 +0100
5200 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/file.c       2010-02-25 12:02:16.000000000 +0100
5201 @@ -161,5 +161,6 @@ const struct inode_operations ext4_file_
5202         .check_acl      = ext4_check_acl,
5203         .fallocate      = ext4_fallocate,
5204         .fiemap         = ext4_fiemap,
5205 +       .sync_flags     = ext4_sync_flags,
5206  };
5207  
5208 diff -NurpP --minimal linux-2.6.33.2/fs/ext4/ialloc.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/ialloc.c
5209 --- linux-2.6.33.2/fs/ext4/ialloc.c     2009-12-03 20:02:51.000000000 +0100
5210 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/ialloc.c     2010-02-25 12:02:16.000000000 +0100
5211 @@ -22,6 +22,7 @@
5212  #include <linux/random.h>
5213  #include <linux/bitops.h>
5214  #include <linux/blkdev.h>
5215 +#include <linux/vs_tag.h>
5216  #include <asm/byteorder.h>
5217  
5218  #include "ext4.h"
5219 @@ -995,6 +996,7 @@ got:
5220         } else
5221                 inode->i_gid = current_fsgid();
5222         inode->i_mode = mode;
5223 +       inode->i_tag = dx_current_fstag(sb);
5224  
5225         inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb);
5226         /* This is the optimal IO size (for stat), not the fs block size */
5227 diff -NurpP --minimal linux-2.6.33.2/fs/ext4/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/inode.c
5228 --- linux-2.6.33.2/fs/ext4/inode.c      2010-02-25 11:52:05.000000000 +0100
5229 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/inode.c      2010-02-25 12:02:16.000000000 +0100
5230 @@ -38,6 +38,7 @@
5231  #include <linux/uio.h>
5232  #include <linux/bio.h>
5233  #include <linux/workqueue.h>
5234 +#include <linux/vs_tag.h>
5235  
5236  #include "ext4_jbd2.h"
5237  #include "xattr.h"
5238 @@ -4376,7 +4377,7 @@ static void ext4_free_branches(handle_t 
5239  
5240  int ext4_can_truncate(struct inode *inode)
5241  {
5242 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
5243 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
5244                 return 0;
5245         if (S_ISREG(inode->i_mode))
5246                 return 1;
5247 @@ -4727,36 +4728,60 @@ void ext4_set_inode_flags(struct inode *
5248  {
5249         unsigned int flags = EXT4_I(inode)->i_flags;
5250  
5251 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5252 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5253 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5254 +
5255 +       if (flags & EXT4_IMMUTABLE_FL)
5256 +               inode->i_flags |= S_IMMUTABLE;
5257 +       if (flags & EXT4_IXUNLINK_FL)
5258 +               inode->i_flags |= S_IXUNLINK;
5259 +
5260         if (flags & EXT4_SYNC_FL)
5261                 inode->i_flags |= S_SYNC;
5262         if (flags & EXT4_APPEND_FL)
5263                 inode->i_flags |= S_APPEND;
5264 -       if (flags & EXT4_IMMUTABLE_FL)
5265 -               inode->i_flags |= S_IMMUTABLE;
5266         if (flags & EXT4_NOATIME_FL)
5267                 inode->i_flags |= S_NOATIME;
5268         if (flags & EXT4_DIRSYNC_FL)
5269                 inode->i_flags |= S_DIRSYNC;
5270 +
5271 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
5272 +
5273 +       if (flags & EXT4_BARRIER_FL)
5274 +               inode->i_vflags |= V_BARRIER;
5275 +       if (flags & EXT4_COW_FL)
5276 +               inode->i_vflags |= V_COW;
5277  }
5278  
5279  /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
5280  void ext4_get_inode_flags(struct ext4_inode_info *ei)
5281  {
5282         unsigned int flags = ei->vfs_inode.i_flags;
5283 +       unsigned int vflags = ei->vfs_inode.i_vflags;
5284 +
5285 +       ei->i_flags &= ~(EXT4_SYNC_FL | EXT4_APPEND_FL |
5286 +                       EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL |
5287 +                       EXT4_NOATIME_FL | EXT4_DIRSYNC_FL |
5288 +                       EXT4_BARRIER_FL | EXT4_COW_FL);
5289 +
5290 +       if (flags & S_IMMUTABLE)
5291 +               ei->i_flags |= EXT4_IMMUTABLE_FL;
5292 +       if (flags & S_IXUNLINK)
5293 +               ei->i_flags |= EXT4_IXUNLINK_FL;
5294  
5295 -       ei->i_flags &= ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
5296 -                       EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|EXT4_DIRSYNC_FL);
5297         if (flags & S_SYNC)
5298                 ei->i_flags |= EXT4_SYNC_FL;
5299         if (flags & S_APPEND)
5300                 ei->i_flags |= EXT4_APPEND_FL;
5301 -       if (flags & S_IMMUTABLE)
5302 -               ei->i_flags |= EXT4_IMMUTABLE_FL;
5303         if (flags & S_NOATIME)
5304                 ei->i_flags |= EXT4_NOATIME_FL;
5305         if (flags & S_DIRSYNC)
5306                 ei->i_flags |= EXT4_DIRSYNC_FL;
5307 +
5308 +       if (vflags & V_BARRIER)
5309 +               ei->i_flags |= EXT4_BARRIER_FL;
5310 +       if (vflags & V_COW)
5311 +               ei->i_flags |= EXT4_COW_FL;
5312  }
5313  
5314  static blkcnt_t ext4_inode_blocks(struct ext4_inode *raw_inode,
5315 @@ -4791,6 +4816,8 @@ struct inode *ext4_iget(struct super_blo
5316         journal_t *journal = EXT4_SB(sb)->s_journal;
5317         long ret;
5318         int block;
5319 +       uid_t uid;
5320 +       gid_t gid;
5321  
5322         inode = iget_locked(sb, ino);
5323         if (!inode)
5324 @@ -4806,12 +4833,16 @@ struct inode *ext4_iget(struct super_blo
5325                 goto bad_inode;
5326         raw_inode = ext4_raw_inode(&iloc);
5327         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
5328 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5329 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5330 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5331 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5332         if (!(test_opt(inode->i_sb, NO_UID32))) {
5333 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5334 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5335 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5336 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5337         }
5338 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5339 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5340 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5341 +               le16_to_cpu(raw_inode->i_raw_tag));
5342         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
5343  
5344         ei->i_state = 0;
5345 @@ -5033,6 +5064,8 @@ static int ext4_do_update_inode(handle_t
5346         struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
5347         struct ext4_inode_info *ei = EXT4_I(inode);
5348         struct buffer_head *bh = iloc->bh;
5349 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5350 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5351         int err = 0, rc, block;
5352  
5353         /* For fields not not tracking in the in-memory inode,
5354 @@ -5043,29 +5076,32 @@ static int ext4_do_update_inode(handle_t
5355         ext4_get_inode_flags(ei);
5356         raw_inode->i_mode = cpu_to_le16(inode->i_mode);
5357         if (!(test_opt(inode->i_sb, NO_UID32))) {
5358 -               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
5359 -               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
5360 +               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
5361 +               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
5362  /*
5363   * Fix up interoperability with old kernels. Otherwise, old inodes get
5364   * re-used with the upper 16 bits of the uid/gid intact
5365   */
5366                 if (!ei->i_dtime) {
5367                         raw_inode->i_uid_high =
5368 -                               cpu_to_le16(high_16_bits(inode->i_uid));
5369 +                               cpu_to_le16(high_16_bits(uid));
5370                         raw_inode->i_gid_high =
5371 -                               cpu_to_le16(high_16_bits(inode->i_gid));
5372 +                               cpu_to_le16(high_16_bits(gid));
5373                 } else {
5374                         raw_inode->i_uid_high = 0;
5375                         raw_inode->i_gid_high = 0;
5376                 }
5377         } else {
5378                 raw_inode->i_uid_low =
5379 -                       cpu_to_le16(fs_high2lowuid(inode->i_uid));
5380 +                       cpu_to_le16(fs_high2lowuid(uid));
5381                 raw_inode->i_gid_low =
5382 -                       cpu_to_le16(fs_high2lowgid(inode->i_gid));
5383 +                       cpu_to_le16(fs_high2lowgid(gid));
5384                 raw_inode->i_uid_high = 0;
5385                 raw_inode->i_gid_high = 0;
5386         }
5387 +#ifdef CONFIG_TAGGING_INTERN
5388 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
5389 +#endif
5390         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
5391  
5392         EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
5393 @@ -5250,7 +5286,8 @@ int ext4_setattr(struct dentry *dentry, 
5394                 return error;
5395  
5396         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
5397 -               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
5398 +               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
5399 +               (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
5400                 handle_t *handle;
5401  
5402                 /* (user+group)*(old+new) structure, inode write (sb,
5403 @@ -5272,6 +5309,8 @@ int ext4_setattr(struct dentry *dentry, 
5404                         inode->i_uid = attr->ia_uid;
5405                 if (attr->ia_valid & ATTR_GID)
5406                         inode->i_gid = attr->ia_gid;
5407 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5408 +                       inode->i_tag = attr->ia_tag;
5409                 error = ext4_mark_inode_dirty(handle, inode);
5410                 ext4_journal_stop(handle);
5411         }
5412 diff -NurpP --minimal linux-2.6.33.2/fs/ext4/ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/ioctl.c
5413 --- linux-2.6.33.2/fs/ext4/ioctl.c      2010-02-25 11:52:05.000000000 +0100
5414 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/ioctl.c      2010-02-25 12:02:16.000000000 +0100
5415 @@ -14,10 +14,39 @@
5416  #include <linux/compat.h>
5417  #include <linux/mount.h>
5418  #include <linux/file.h>
5419 +#include <linux/vs_tag.h>
5420  #include <asm/uaccess.h>
5421  #include "ext4_jbd2.h"
5422  #include "ext4.h"
5423  
5424 +
5425 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
5426 +{
5427 +       handle_t *handle = NULL;
5428 +       struct ext4_iloc iloc;
5429 +       int err;
5430 +
5431 +       handle = ext4_journal_start(inode, 1);
5432 +       if (IS_ERR(handle))
5433 +               return PTR_ERR(handle);
5434 +
5435 +       if (IS_SYNC(inode))
5436 +               ext4_handle_sync(handle);
5437 +       err = ext4_reserve_inode_write(handle, inode, &iloc);
5438 +       if (err)
5439 +               goto flags_err;
5440 +
5441 +       inode->i_flags = flags;
5442 +       inode->i_vflags = vflags;
5443 +       ext4_get_inode_flags(EXT4_I(inode));
5444 +       inode->i_ctime = ext4_current_time(inode);
5445 +
5446 +       err = ext4_mark_iloc_dirty(handle, inode, &iloc);
5447 +flags_err:
5448 +       ext4_journal_stop(handle);
5449 +       return err;
5450 +}
5451 +
5452  long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5453  {
5454         struct inode *inode = filp->f_dentry->d_inode;
5455 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
5456  
5457                 flags = ext4_mask_flags(inode->i_mode, flags);
5458  
5459 +               if (IS_BARRIER(inode)) {
5460 +                       vxwprintk_task(1, "messing with the barrier.");
5461 +                       return -EACCES;
5462 +               }
5463 +
5464                 err = -EPERM;
5465                 mutex_lock(&inode->i_mutex);
5466                 /* Is it quota file? Do not allow user to mess with it */
5467 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
5468                  *
5469                  * This test looks nicer. Thanks to Pauline Middelink
5470                  */
5471 -               if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
5472 +               if ((oldflags & EXT4_IMMUTABLE_FL) ||
5473 +                       ((flags ^ oldflags) & (EXT4_APPEND_FL |
5474 +                       EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
5475                         if (!capable(CAP_LINUX_IMMUTABLE))
5476                                 goto flags_out;
5477                 }
5478 diff -NurpP --minimal linux-2.6.33.2/fs/ext4/namei.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/namei.c
5479 --- linux-2.6.33.2/fs/ext4/namei.c      2010-02-25 11:52:05.000000000 +0100
5480 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/namei.c      2010-02-25 12:02:16.000000000 +0100
5481 @@ -34,6 +34,7 @@
5482  #include <linux/quotaops.h>
5483  #include <linux/buffer_head.h>
5484  #include <linux/bio.h>
5485 +#include <linux/vs_tag.h>
5486  #include "ext4.h"
5487  #include "ext4_jbd2.h"
5488  
5489 @@ -941,6 +942,7 @@ restart:
5490                                 if (bh)
5491                                         ll_rw_block(READ_META, 1, &bh);
5492                         }
5493 +               dx_propagate_tag(nd, inode);
5494                 }
5495                 if ((bh = bh_use[ra_ptr++]) == NULL)
5496                         goto next;
5497 @@ -2533,6 +2535,7 @@ const struct inode_operations ext4_dir_i
5498  #endif
5499         .check_acl      = ext4_check_acl,
5500         .fiemap         = ext4_fiemap,
5501 +       .sync_flags     = ext4_sync_flags,
5502  };
5503  
5504  const struct inode_operations ext4_special_inode_operations = {
5505 diff -NurpP --minimal linux-2.6.33.2/fs/ext4/super.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/super.c
5506 --- linux-2.6.33.2/fs/ext4/super.c      2010-02-25 11:52:05.000000000 +0100
5507 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ext4/super.c      2010-02-25 12:02:16.000000000 +0100
5508 @@ -1110,6 +1110,7 @@ enum {
5509         Opt_block_validity, Opt_noblock_validity,
5510         Opt_inode_readahead_blks, Opt_journal_ioprio,
5511         Opt_discard, Opt_nodiscard,
5512 +       Opt_tag, Opt_notag, Opt_tagid
5513  };
5514  
5515  static const match_table_t tokens = {
5516 @@ -1178,6 +1179,9 @@ static const match_table_t tokens = {
5517         {Opt_noauto_da_alloc, "noauto_da_alloc"},
5518         {Opt_discard, "discard"},
5519         {Opt_nodiscard, "nodiscard"},
5520 +       {Opt_tag, "tag"},
5521 +       {Opt_notag, "notag"},
5522 +       {Opt_tagid, "tagid=%u"},
5523         {Opt_err, NULL},
5524  };
5525  
5526 @@ -1275,6 +1279,20 @@ static int parse_options(char *options, 
5527                 case Opt_nouid32:
5528                         set_opt(sbi->s_mount_opt, NO_UID32);
5529                         break;
5530 +#ifndef CONFIG_TAGGING_NONE
5531 +               case Opt_tag:
5532 +                       set_opt (sbi->s_mount_opt, TAGGED);
5533 +                       break;
5534 +               case Opt_notag:
5535 +                       clear_opt (sbi->s_mount_opt, TAGGED);
5536 +                       break;
5537 +#endif
5538 +#ifdef CONFIG_PROPAGATE
5539 +               case Opt_tagid:
5540 +                       /* use args[0] */
5541 +                       set_opt (sbi->s_mount_opt, TAGGED);
5542 +                       break;
5543 +#endif
5544                 case Opt_debug:
5545                         set_opt(sbi->s_mount_opt, DEBUG);
5546                         break;
5547 @@ -2476,6 +2494,9 @@ static int ext4_fill_super(struct super_
5548                            &journal_ioprio, NULL, 0))
5549                 goto failed_mount;
5550  
5551 +       if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
5552 +               sb->s_flags |= MS_TAGGED;
5553 +
5554         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5555                 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
5556  
5557 @@ -3513,6 +3534,14 @@ static int ext4_remount(struct super_blo
5558         if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
5559                 ext4_abort(sb, __func__, "Abort forced by user");
5560  
5561 +       if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
5562 +               !(sb->s_flags & MS_TAGGED)) {
5563 +               printk("EXT4-fs: %s: tagging not permitted on remount.\n",
5564 +                       sb->s_id);
5565 +               err = -EINVAL;
5566 +               goto restore_opts;
5567 +       }
5568 +
5569         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5570                 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
5571  
5572 diff -NurpP --minimal linux-2.6.33.2/fs/fcntl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/fcntl.c
5573 --- linux-2.6.33.2/fs/fcntl.c   2010-02-25 11:52:05.000000000 +0100
5574 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/fcntl.c   2010-02-25 12:02:16.000000000 +0100
5575 @@ -19,6 +19,7 @@
5576  #include <linux/signal.h>
5577  #include <linux/rcupdate.h>
5578  #include <linux/pid_namespace.h>
5579 +#include <linux/vs_limit.h>
5580  
5581  #include <asm/poll.h>
5582  #include <asm/siginfo.h>
5583 @@ -102,6 +103,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
5584  
5585         if (tofree)
5586                 filp_close(tofree, files);
5587 +       else
5588 +               vx_openfd_inc(newfd);   /* fd was unused */
5589  
5590         return newfd;
5591  
5592 @@ -426,6 +429,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
5593         filp = fget(fd);
5594         if (!filp)
5595                 goto out;
5596 +       if (!vx_files_avail(1))
5597 +               goto out;
5598  
5599         err = security_file_fcntl(filp, cmd, arg);
5600         if (err) {
5601 diff -NurpP --minimal linux-2.6.33.2/fs/file.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/file.c
5602 --- linux-2.6.33.2/fs/file.c    2009-12-03 20:02:51.000000000 +0100
5603 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/file.c    2010-02-25 12:02:16.000000000 +0100
5604 @@ -20,6 +20,7 @@
5605  #include <linux/spinlock.h>
5606  #include <linux/rcupdate.h>
5607  #include <linux/workqueue.h>
5608 +#include <linux/vs_limit.h>
5609  
5610  struct fdtable_defer {
5611         spinlock_t lock;
5612 @@ -368,6 +369,8 @@ struct files_struct *dup_fd(struct files
5613                 struct file *f = *old_fds++;
5614                 if (f) {
5615                         get_file(f);
5616 +                       /* TODO: sum it first for check and performance */
5617 +                       vx_openfd_inc(open_files - i);
5618                 } else {
5619                         /*
5620                          * The fd may be claimed in the fd bitmap but not yet
5621 @@ -476,6 +479,7 @@ repeat:
5622         else
5623                 FD_CLR(fd, fdt->close_on_exec);
5624         error = fd;
5625 +       vx_openfd_inc(fd);
5626  #if 1
5627         /* Sanity check */
5628         if (rcu_dereference(fdt->fd[fd]) != NULL) {
5629 diff -NurpP --minimal linux-2.6.33.2/fs/file_table.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/file_table.c
5630 --- linux-2.6.33.2/fs/file_table.c      2010-04-06 01:47:46.000000000 +0200
5631 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/file_table.c      2010-04-06 01:59:25.000000000 +0200
5632 @@ -22,6 +22,8 @@
5633  #include <linux/sysctl.h>
5634  #include <linux/percpu_counter.h>
5635  #include <linux/ima.h>
5636 +#include <linux/vs_limit.h>
5637 +#include <linux/vs_context.h>
5638  
5639  #include <asm/atomic.h>
5640  
5641 @@ -133,6 +135,8 @@ struct file *get_empty_filp(void)
5642         spin_lock_init(&f->f_lock);
5643         eventpoll_init_file(f);
5644         /* f->f_version: 0 */
5645 +       f->f_xid = vx_current_xid();
5646 +       vx_files_inc(f);
5647         return f;
5648  
5649  over:
5650 @@ -258,6 +262,8 @@ void __fput(struct file *file)
5651                 cdev_put(inode->i_cdev);
5652         fops_put(file->f_op);
5653         put_pid(file->f_owner.pid);
5654 +       vx_files_dec(file);
5655 +       file->f_xid = 0;
5656         file_kill(file);
5657         if (file->f_mode & FMODE_WRITE)
5658                 drop_file_write_access(file);
5659 @@ -325,6 +331,8 @@ void put_filp(struct file *file)
5660  {
5661         if (atomic_long_dec_and_test(&file->f_count)) {
5662                 security_file_free(file);
5663 +               vx_files_dec(file);
5664 +               file->f_xid = 0;
5665                 file_kill(file);
5666                 file_free(file);
5667         }
5668 diff -NurpP --minimal linux-2.6.33.2/fs/fs_struct.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/fs_struct.c
5669 --- linux-2.6.33.2/fs/fs_struct.c       2009-06-11 17:13:04.000000000 +0200
5670 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/fs_struct.c       2010-02-25 12:02:16.000000000 +0100
5671 @@ -4,6 +4,7 @@
5672  #include <linux/path.h>
5673  #include <linux/slab.h>
5674  #include <linux/fs_struct.h>
5675 +#include <linux/vserver/global.h>
5676  
5677  /*
5678   * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
5679 @@ -77,6 +78,7 @@ void free_fs_struct(struct fs_struct *fs
5680  {
5681         path_put(&fs->root);
5682         path_put(&fs->pwd);
5683 +       atomic_dec(&vs_global_fs);
5684         kmem_cache_free(fs_cachep, fs);
5685  }
5686  
5687 @@ -112,6 +114,7 @@ struct fs_struct *copy_fs_struct(struct 
5688                 fs->pwd = old->pwd;
5689                 path_get(&old->pwd);
5690                 read_unlock(&old->lock);
5691 +               atomic_inc(&vs_global_fs);
5692         }
5693         return fs;
5694  }
5695 diff -NurpP --minimal linux-2.6.33.2/fs/gfs2/file.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/gfs2/file.c
5696 --- linux-2.6.33.2/fs/gfs2/file.c       2010-04-06 01:47:46.000000000 +0200
5697 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/gfs2/file.c       2010-04-06 01:59:25.000000000 +0200
5698 @@ -132,6 +132,9 @@ static const u32 fsflags_to_gfs2[32] = {
5699         [7] = GFS2_DIF_NOATIME,
5700         [12] = GFS2_DIF_EXHASH,
5701         [14] = GFS2_DIF_INHERIT_JDATA,
5702 +       [27] = GFS2_DIF_IXUNLINK,
5703 +       [26] = GFS2_DIF_BARRIER,
5704 +       [29] = GFS2_DIF_COW,
5705  };
5706  
5707  static const u32 gfs2_to_fsflags[32] = {
5708 @@ -141,6 +144,9 @@ static const u32 gfs2_to_fsflags[32] = {
5709         [gfs2fl_NoAtime] = FS_NOATIME_FL,
5710         [gfs2fl_ExHash] = FS_INDEX_FL,
5711         [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
5712 +       [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
5713 +       [gfs2fl_Barrier] = FS_BARRIER_FL,
5714 +       [gfs2fl_Cow] = FS_COW_FL,
5715  };
5716  
5717  static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
5718 @@ -171,10 +177,16 @@ void gfs2_set_inode_flags(struct inode *
5719  {
5720         struct gfs2_inode *ip = GFS2_I(inode);
5721         unsigned int flags = inode->i_flags;
5722 +       unsigned int vflags = inode->i_vflags;
5723 +
5724 +       flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5725 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5726  
5727 -       flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5728         if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
5729                 flags |= S_IMMUTABLE;
5730 +       if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
5731 +               flags |= S_IXUNLINK;
5732 +
5733         if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
5734                 flags |= S_APPEND;
5735         if (ip->i_diskflags & GFS2_DIF_NOATIME)
5736 @@ -182,6 +194,43 @@ void gfs2_set_inode_flags(struct inode *
5737         if (ip->i_diskflags & GFS2_DIF_SYNC)
5738                 flags |= S_SYNC;
5739         inode->i_flags = flags;
5740 +
5741 +       vflags &= ~(V_BARRIER | V_COW);
5742 +
5743 +       if (ip->i_diskflags & GFS2_DIF_BARRIER)
5744 +               vflags |= V_BARRIER;
5745 +       if (ip->i_diskflags & GFS2_DIF_COW)
5746 +               vflags |= V_COW;
5747 +       inode->i_vflags = vflags;
5748 +}
5749 +
5750 +void gfs2_get_inode_flags(struct inode *inode)
5751 +{
5752 +       struct gfs2_inode *ip = GFS2_I(inode);
5753 +       unsigned int flags = inode->i_flags;
5754 +       unsigned int vflags = inode->i_vflags;
5755 +
5756 +       ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
5757 +                       GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
5758 +                       GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
5759 +                       GFS2_DIF_BARRIER | GFS2_DIF_COW);
5760 +
5761 +       if (flags & S_IMMUTABLE)
5762 +               ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
5763 +       if (flags & S_IXUNLINK)
5764 +               ip->i_diskflags |= GFS2_DIF_IXUNLINK;
5765 +
5766 +       if (flags & S_APPEND)
5767 +               ip->i_diskflags |= GFS2_DIF_APPENDONLY;
5768 +       if (flags & S_NOATIME)
5769 +               ip->i_diskflags |= GFS2_DIF_NOATIME;
5770 +       if (flags & S_SYNC)
5771 +               ip->i_diskflags |= GFS2_DIF_SYNC;
5772 +
5773 +       if (vflags & V_BARRIER)
5774 +               ip->i_diskflags |= GFS2_DIF_BARRIER;
5775 +       if (vflags & V_COW)
5776 +               ip->i_diskflags |= GFS2_DIF_COW;
5777  }
5778  
5779  /* Flags that can be set by user space */
5780 @@ -286,6 +335,37 @@ static int gfs2_set_flags(struct file *f
5781         return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
5782  }
5783  
5784 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
5785 +{
5786 +       struct gfs2_inode *ip = GFS2_I(inode);
5787 +       struct gfs2_sbd *sdp = GFS2_SB(inode);
5788 +       struct buffer_head *bh;
5789 +       struct gfs2_holder gh;
5790 +       int error;
5791 +
5792 +       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
5793 +       if (error)
5794 +               return error;
5795 +       error = gfs2_trans_begin(sdp, RES_DINODE, 0);
5796 +       if (error)
5797 +               goto out;
5798 +       error = gfs2_meta_inode_buffer(ip, &bh);
5799 +       if (error)
5800 +               goto out_trans_end;
5801 +       gfs2_trans_add_bh(ip->i_gl, bh, 1);
5802 +       inode->i_flags = flags;
5803 +       inode->i_vflags = vflags;
5804 +       gfs2_get_inode_flags(inode);
5805 +       gfs2_dinode_out(ip, bh->b_data);
5806 +       brelse(bh);
5807 +       gfs2_set_aops(inode);
5808 +out_trans_end:
5809 +       gfs2_trans_end(sdp);
5810 +out:
5811 +       gfs2_glock_dq_uninit(&gh);
5812 +       return error;
5813 +}
5814 +
5815  static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5816  {
5817         switch(cmd) {
5818 diff -NurpP --minimal linux-2.6.33.2/fs/gfs2/inode.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/gfs2/inode.h
5819 --- linux-2.6.33.2/fs/gfs2/inode.h      2009-09-10 15:26:22.000000000 +0200
5820 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/gfs2/inode.h      2010-02-25 12:02:16.000000000 +0100
5821 @@ -109,6 +109,7 @@ extern const struct file_operations gfs2
5822  extern const struct file_operations gfs2_dir_fops_nolock;
5823  
5824  extern void gfs2_set_inode_flags(struct inode *inode);
5825 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
5826   
5827  #ifdef CONFIG_GFS2_FS_LOCKING_DLM
5828  extern const struct file_operations gfs2_file_fops;
5829 diff -NurpP --minimal linux-2.6.33.2/fs/gfs2/ops_inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/gfs2/ops_inode.c
5830 --- linux-2.6.33.2/fs/gfs2/ops_inode.c  2010-02-25 11:52:05.000000000 +0100
5831 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/gfs2/ops_inode.c  2010-02-25 12:02:16.000000000 +0100
5832 @@ -1403,6 +1403,7 @@ const struct inode_operations gfs2_file_
5833         .listxattr = gfs2_listxattr,
5834         .removexattr = gfs2_removexattr,
5835         .fiemap = gfs2_fiemap,
5836 +       .sync_flags = gfs2_sync_flags,
5837  };
5838  
5839  const struct inode_operations gfs2_dir_iops = {
5840 @@ -1423,6 +1424,7 @@ const struct inode_operations gfs2_dir_i
5841         .listxattr = gfs2_listxattr,
5842         .removexattr = gfs2_removexattr,
5843         .fiemap = gfs2_fiemap,
5844 +       .sync_flags = gfs2_sync_flags,
5845  };
5846  
5847  const struct inode_operations gfs2_symlink_iops = {
5848 diff -NurpP --minimal linux-2.6.33.2/fs/hfsplus/ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/hfsplus/ioctl.c
5849 --- linux-2.6.33.2/fs/hfsplus/ioctl.c   2008-12-25 00:26:37.000000000 +0100
5850 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/hfsplus/ioctl.c   2010-02-25 12:02:16.000000000 +0100
5851 @@ -17,6 +17,7 @@
5852  #include <linux/mount.h>
5853  #include <linux/sched.h>
5854  #include <linux/xattr.h>
5855 +#include <linux/mount.h>
5856  #include <asm/uaccess.h>
5857  #include "hfsplus_fs.h"
5858  
5859 diff -NurpP --minimal linux-2.6.33.2/fs/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/inode.c
5860 --- linux-2.6.33.2/fs/inode.c   2010-02-25 11:52:05.000000000 +0100
5861 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/inode.c   2010-02-25 12:02:16.000000000 +0100
5862 @@ -132,6 +132,9 @@ int inode_init_always(struct super_block
5863         struct address_space *const mapping = &inode->i_data;
5864  
5865         inode->i_sb = sb;
5866 +
5867 +       /* essential because of inode slab reuse */
5868 +       inode->i_tag = 0;
5869         inode->i_blkbits = sb->s_blocksize_bits;
5870         inode->i_flags = 0;
5871         atomic_set(&inode->i_count, 1);
5872 @@ -152,6 +155,7 @@ int inode_init_always(struct super_block
5873         inode->i_bdev = NULL;
5874         inode->i_cdev = NULL;
5875         inode->i_rdev = 0;
5876 +       inode->i_mdev = 0;
5877         inode->dirtied_when = 0;
5878  
5879         if (security_inode_alloc(inode))
5880 @@ -297,6 +301,8 @@ void __iget(struct inode *inode)
5881         inodes_stat.nr_unused--;
5882  }
5883  
5884 +EXPORT_SYMBOL_GPL(__iget);
5885 +
5886  /**
5887   * clear_inode - clear an inode
5888   * @inode: inode to clear
5889 @@ -1601,9 +1607,11 @@ void init_special_inode(struct inode *in
5890         if (S_ISCHR(mode)) {
5891                 inode->i_fop = &def_chr_fops;
5892                 inode->i_rdev = rdev;
5893 +               inode->i_mdev = rdev;
5894         } else if (S_ISBLK(mode)) {
5895                 inode->i_fop = &def_blk_fops;
5896                 inode->i_rdev = rdev;
5897 +               inode->i_mdev = rdev;
5898         } else if (S_ISFIFO(mode))
5899                 inode->i_fop = &def_fifo_fops;
5900         else if (S_ISSOCK(mode))
5901 diff -NurpP --minimal linux-2.6.33.2/fs/ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ioctl.c
5902 --- linux-2.6.33.2/fs/ioctl.c   2009-12-03 20:02:52.000000000 +0100
5903 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ioctl.c   2010-02-25 12:02:16.000000000 +0100
5904 @@ -16,6 +16,9 @@
5905  #include <linux/writeback.h>
5906  #include <linux/buffer_head.h>
5907  #include <linux/falloc.h>
5908 +#include <linux/proc_fs.h>
5909 +#include <linux/vserver/inode.h>
5910 +#include <linux/vs_tag.h>
5911  
5912  #include <asm/ioctls.h>
5913  
5914 diff -NurpP --minimal linux-2.6.33.2/fs/ioprio.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ioprio.c
5915 --- linux-2.6.33.2/fs/ioprio.c  2009-03-24 14:22:26.000000000 +0100
5916 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ioprio.c  2010-02-25 12:02:16.000000000 +0100
5917 @@ -26,6 +26,7 @@
5918  #include <linux/syscalls.h>
5919  #include <linux/security.h>
5920  #include <linux/pid_namespace.h>
5921 +#include <linux/vs_base.h>
5922  
5923  int set_task_ioprio(struct task_struct *task, int ioprio)
5924  {
5925 @@ -123,6 +124,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which, 
5926                         else
5927                                 pgrp = find_vpid(who);
5928                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5929 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5930 +                                       continue;
5931                                 ret = set_task_ioprio(p, ioprio);
5932                                 if (ret)
5933                                         break;
5934 @@ -212,6 +215,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which, 
5935                         else
5936                                 pgrp = find_vpid(who);
5937                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5938 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5939 +                                       continue;
5940                                 tmpio = get_task_ioprio(p);
5941                                 if (tmpio < 0)
5942                                         continue;
5943 diff -NurpP --minimal linux-2.6.33.2/fs/jfs/acl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/acl.c
5944 --- linux-2.6.33.2/fs/jfs/acl.c 2009-12-03 20:02:52.000000000 +0100
5945 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/acl.c 2010-02-25 12:02:16.000000000 +0100
5946 @@ -216,7 +216,8 @@ int jfs_setattr(struct dentry *dentry, s
5947                 return rc;
5948  
5949         if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5950 -           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5951 +           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5952 +           (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5953                 if (vfs_dq_transfer(inode, iattr))
5954                         return -EDQUOT;
5955         }
5956 diff -NurpP --minimal linux-2.6.33.2/fs/jfs/file.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/file.c
5957 --- linux-2.6.33.2/fs/jfs/file.c        2009-12-03 20:02:52.000000000 +0100
5958 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/file.c        2010-02-25 12:02:16.000000000 +0100
5959 @@ -98,6 +98,7 @@ const struct inode_operations jfs_file_i
5960         .setattr        = jfs_setattr,
5961         .check_acl      = jfs_check_acl,
5962  #endif
5963 +       .sync_flags     = jfs_sync_flags,
5964  };
5965  
5966  const struct file_operations jfs_file_operations = {
5967 diff -NurpP --minimal linux-2.6.33.2/fs/jfs/ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/ioctl.c
5968 --- linux-2.6.33.2/fs/jfs/ioctl.c       2008-12-25 00:26:37.000000000 +0100
5969 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/ioctl.c       2010-02-25 12:02:16.000000000 +0100
5970 @@ -11,6 +11,7 @@
5971  #include <linux/mount.h>
5972  #include <linux/time.h>
5973  #include <linux/sched.h>
5974 +#include <linux/mount.h>
5975  #include <asm/current.h>
5976  #include <asm/uaccess.h>
5977  
5978 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
5979  }
5980  
5981  
5982 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
5983 +{
5984 +       inode->i_flags = flags;
5985 +       inode->i_vflags = vflags;
5986 +       jfs_get_inode_flags(JFS_IP(inode));
5987 +       inode->i_ctime = CURRENT_TIME_SEC;
5988 +       mark_inode_dirty(inode);
5989 +       return 0;
5990 +}
5991 +
5992  long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5993  {
5994         struct inode *inode = filp->f_dentry->d_inode;
5995 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
5996                 if (!S_ISDIR(inode->i_mode))
5997                         flags &= ~JFS_DIRSYNC_FL;
5998  
5999 +               if (IS_BARRIER(inode)) {
6000 +                       vxwprintk_task(1, "messing with the barrier.");
6001 +                       return -EACCES;
6002 +               }
6003 +
6004                 /* Is it quota file? Do not allow user to mess with it */
6005                 if (IS_NOQUOTA(inode)) {
6006                         err = -EPERM;
6007 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
6008                  * the relevant capability.
6009                  */
6010                 if ((oldflags & JFS_IMMUTABLE_FL) ||
6011 -                       ((flags ^ oldflags) &
6012 -                       (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
6013 +                       ((flags ^ oldflags) & (JFS_APPEND_FL |
6014 +                       JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
6015                         if (!capable(CAP_LINUX_IMMUTABLE)) {
6016                                 mutex_unlock(&inode->i_mutex);
6017                                 err = -EPERM;
6018 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
6019                         }
6020                 }
6021  
6022 -               flags = flags & JFS_FL_USER_MODIFIABLE;
6023 +               flags &= JFS_FL_USER_MODIFIABLE;
6024                 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
6025                 jfs_inode->mode2 = flags;
6026  
6027 diff -NurpP --minimal linux-2.6.33.2/fs/jfs/jfs_dinode.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/jfs_dinode.h
6028 --- linux-2.6.33.2/fs/jfs/jfs_dinode.h  2008-12-25 00:26:37.000000000 +0100
6029 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/jfs_dinode.h  2010-02-25 12:02:16.000000000 +0100
6030 @@ -161,9 +161,13 @@ struct dinode {
6031  
6032  #define JFS_APPEND_FL          0x01000000 /* writes to file may only append */
6033  #define JFS_IMMUTABLE_FL       0x02000000 /* Immutable file */
6034 +#define JFS_IXUNLINK_FL                0x08000000 /* Immutable invert on unlink */
6035  
6036 -#define JFS_FL_USER_VISIBLE    0x03F80000
6037 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
6038 +#define JFS_BARRIER_FL         0x04000000 /* Barrier for chroot() */
6039 +#define JFS_COW_FL             0x20000000 /* Copy on Write marker */
6040 +
6041 +#define JFS_FL_USER_VISIBLE    0x07F80000
6042 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
6043  #define JFS_FL_INHERIT         0x03C80000
6044  
6045  /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
6046 diff -NurpP --minimal linux-2.6.33.2/fs/jfs/jfs_filsys.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/jfs_filsys.h
6047 --- linux-2.6.33.2/fs/jfs/jfs_filsys.h  2008-12-25 00:26:37.000000000 +0100
6048 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/jfs_filsys.h  2010-02-25 12:02:16.000000000 +0100
6049 @@ -263,6 +263,7 @@
6050  #define JFS_NAME_MAX   255
6051  #define JFS_PATH_MAX   BPSIZE
6052  
6053 +#define JFS_TAGGED             0x00800000      /* Context Tagging */
6054  
6055  /*
6056   *     file system state (superblock state)
6057 diff -NurpP --minimal linux-2.6.33.2/fs/jfs/jfs_imap.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/jfs_imap.c
6058 --- linux-2.6.33.2/fs/jfs/jfs_imap.c    2009-09-10 15:26:22.000000000 +0200
6059 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/jfs_imap.c    2010-02-25 12:02:16.000000000 +0100
6060 @@ -45,6 +45,7 @@
6061  #include <linux/buffer_head.h>
6062  #include <linux/pagemap.h>
6063  #include <linux/quotaops.h>
6064 +#include <linux/vs_tag.h>
6065  
6066  #include "jfs_incore.h"
6067  #include "jfs_inode.h"
6068 @@ -3059,6 +3060,8 @@ static int copy_from_dinode(struct dinod
6069  {
6070         struct jfs_inode_info *jfs_ip = JFS_IP(ip);
6071         struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
6072 +       uid_t uid;
6073 +       gid_t gid;
6074  
6075         jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
6076         jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
6077 @@ -3079,14 +3082,18 @@ static int copy_from_dinode(struct dinod
6078         }
6079         ip->i_nlink = le32_to_cpu(dip->di_nlink);
6080  
6081 -       jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
6082 +       uid = le32_to_cpu(dip->di_uid);
6083 +       gid = le32_to_cpu(dip->di_gid);
6084 +       ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
6085 +
6086 +       jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
6087         if (sbi->uid == -1)
6088                 ip->i_uid = jfs_ip->saved_uid;
6089         else {
6090                 ip->i_uid = sbi->uid;
6091         }
6092  
6093 -       jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
6094 +       jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
6095         if (sbi->gid == -1)
6096                 ip->i_gid = jfs_ip->saved_gid;
6097         else {
6098 @@ -3151,14 +3158,12 @@ static void copy_to_dinode(struct dinode
6099         dip->di_size = cpu_to_le64(ip->i_size);
6100         dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
6101         dip->di_nlink = cpu_to_le32(ip->i_nlink);
6102 -       if (sbi->uid == -1)
6103 -               dip->di_uid = cpu_to_le32(ip->i_uid);
6104 -       else
6105 -               dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
6106 -       if (sbi->gid == -1)
6107 -               dip->di_gid = cpu_to_le32(ip->i_gid);
6108 -       else
6109 -               dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
6110 +
6111 +       dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
6112 +               (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
6113 +       dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
6114 +               (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
6115 +
6116         jfs_get_inode_flags(jfs_ip);
6117         /*
6118          * mode2 is only needed for storing the higher order bits.
6119 diff -NurpP --minimal linux-2.6.33.2/fs/jfs/jfs_inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/jfs_inode.c
6120 --- linux-2.6.33.2/fs/jfs/jfs_inode.c   2009-06-11 17:13:05.000000000 +0200
6121 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/jfs_inode.c   2010-02-25 12:02:16.000000000 +0100
6122 @@ -18,6 +18,7 @@
6123  
6124  #include <linux/fs.h>
6125  #include <linux/quotaops.h>
6126 +#include <linux/vs_tag.h>
6127  #include "jfs_incore.h"
6128  #include "jfs_inode.h"
6129  #include "jfs_filsys.h"
6130 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
6131  {
6132         unsigned int flags = JFS_IP(inode)->mode2;
6133  
6134 -       inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
6135 -               S_NOATIME | S_DIRSYNC | S_SYNC);
6136 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6137 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6138  
6139         if (flags & JFS_IMMUTABLE_FL)
6140                 inode->i_flags |= S_IMMUTABLE;
6141 +       if (flags & JFS_IXUNLINK_FL)
6142 +               inode->i_flags |= S_IXUNLINK;
6143 +
6144 +       if (flags & JFS_SYNC_FL)
6145 +               inode->i_flags |= S_SYNC;
6146         if (flags & JFS_APPEND_FL)
6147                 inode->i_flags |= S_APPEND;
6148         if (flags & JFS_NOATIME_FL)
6149                 inode->i_flags |= S_NOATIME;
6150         if (flags & JFS_DIRSYNC_FL)
6151                 inode->i_flags |= S_DIRSYNC;
6152 -       if (flags & JFS_SYNC_FL)
6153 -               inode->i_flags |= S_SYNC;
6154 +
6155 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
6156 +
6157 +       if (flags & JFS_BARRIER_FL)
6158 +               inode->i_vflags |= V_BARRIER;
6159 +       if (flags & JFS_COW_FL)
6160 +               inode->i_vflags |= V_COW;
6161  }
6162  
6163  void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
6164  {
6165         unsigned int flags = jfs_ip->vfs_inode.i_flags;
6166 +       unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
6167 +
6168 +       jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
6169 +                          JFS_APPEND_FL | JFS_NOATIME_FL |
6170 +                          JFS_DIRSYNC_FL | JFS_SYNC_FL |
6171 +                          JFS_BARRIER_FL | JFS_COW_FL);
6172  
6173 -       jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
6174 -                          JFS_DIRSYNC_FL | JFS_SYNC_FL);
6175         if (flags & S_IMMUTABLE)
6176                 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
6177 +       if (flags & S_IXUNLINK)
6178 +               jfs_ip->mode2 |= JFS_IXUNLINK_FL;
6179 +
6180         if (flags & S_APPEND)
6181                 jfs_ip->mode2 |= JFS_APPEND_FL;
6182         if (flags & S_NOATIME)
6183 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
6184                 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
6185         if (flags & S_SYNC)
6186                 jfs_ip->mode2 |= JFS_SYNC_FL;
6187 +
6188 +       if (vflags & V_BARRIER)
6189 +               jfs_ip->mode2 |= JFS_BARRIER_FL;
6190 +       if (vflags & V_COW)
6191 +               jfs_ip->mode2 |= JFS_COW_FL;
6192  }
6193  
6194  /*
6195 @@ -105,6 +128,7 @@ struct inode *ialloc(struct inode *paren
6196                         mode |= S_ISGID;
6197         } else
6198                 inode->i_gid = current_fsgid();
6199 +       inode->i_tag = dx_current_fstag(sb);
6200  
6201         /*
6202          * New inodes need to save sane values on disk when
6203 diff -NurpP --minimal linux-2.6.33.2/fs/jfs/jfs_inode.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/jfs_inode.h
6204 --- linux-2.6.33.2/fs/jfs/jfs_inode.h   2009-06-11 17:13:05.000000000 +0200
6205 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/jfs_inode.h   2010-02-25 12:02:16.000000000 +0100
6206 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
6207  extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
6208         int fh_len, int fh_type);
6209  extern void jfs_set_inode_flags(struct inode *);
6210 +extern int jfs_sync_flags(struct inode *, int, int);
6211  extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
6212  
6213  extern const struct address_space_operations jfs_aops;
6214 diff -NurpP --minimal linux-2.6.33.2/fs/jfs/namei.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/namei.c
6215 --- linux-2.6.33.2/fs/jfs/namei.c       2009-12-03 20:02:52.000000000 +0100
6216 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/namei.c       2010-02-25 12:02:16.000000000 +0100
6217 @@ -21,6 +21,7 @@
6218  #include <linux/ctype.h>
6219  #include <linux/quotaops.h>
6220  #include <linux/exportfs.h>
6221 +#include <linux/vs_tag.h>
6222  #include "jfs_incore.h"
6223  #include "jfs_superblock.h"
6224  #include "jfs_inode.h"
6225 @@ -1476,6 +1477,7 @@ static struct dentry *jfs_lookup(struct 
6226                 return ERR_CAST(ip);
6227         }
6228  
6229 +       dx_propagate_tag(nd, ip);
6230         dentry = d_splice_alias(ip, dentry);
6231  
6232         if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
6233 @@ -1545,6 +1547,7 @@ const struct inode_operations jfs_dir_in
6234         .setattr        = jfs_setattr,
6235         .check_acl      = jfs_check_acl,
6236  #endif
6237 +       .sync_flags     = jfs_sync_flags,
6238  };
6239  
6240  const struct file_operations jfs_dir_operations = {
6241 diff -NurpP --minimal linux-2.6.33.2/fs/jfs/super.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/super.c
6242 --- linux-2.6.33.2/fs/jfs/super.c       2010-02-25 11:52:05.000000000 +0100
6243 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/jfs/super.c       2010-02-25 12:02:16.000000000 +0100
6244 @@ -192,7 +192,8 @@ static void jfs_put_super(struct super_b
6245  enum {
6246         Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
6247         Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
6248 -       Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
6249 +       Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
6250 +       Opt_tag, Opt_notag, Opt_tagid
6251  };
6252  
6253  static const match_table_t tokens = {
6254 @@ -202,6 +203,10 @@ static const match_table_t tokens = {
6255         {Opt_resize, "resize=%u"},
6256         {Opt_resize_nosize, "resize"},
6257         {Opt_errors, "errors=%s"},
6258 +       {Opt_tag, "tag"},
6259 +       {Opt_notag, "notag"},
6260 +       {Opt_tagid, "tagid=%u"},
6261 +       {Opt_tag, "tagxid"},
6262         {Opt_ignore, "noquota"},
6263         {Opt_ignore, "quota"},
6264         {Opt_usrquota, "usrquota"},
6265 @@ -336,6 +341,20 @@ static int parse_options(char *options, 
6266                         }
6267                         break;
6268                 }
6269 +#ifndef CONFIG_TAGGING_NONE
6270 +               case Opt_tag:
6271 +                       *flag |= JFS_TAGGED;
6272 +                       break;
6273 +               case Opt_notag:
6274 +                       *flag &= JFS_TAGGED;
6275 +                       break;
6276 +#endif
6277 +#ifdef CONFIG_PROPAGATE
6278 +               case Opt_tagid:
6279 +                       /* use args[0] */
6280 +                       *flag |= JFS_TAGGED;
6281 +                       break;
6282 +#endif
6283                 default:
6284                         printk("jfs: Unrecognized mount option \"%s\" "
6285                                         " or missing value\n", p);
6286 @@ -366,6 +385,12 @@ static int jfs_remount(struct super_bloc
6287         if (!parse_options(data, sb, &newLVSize, &flag)) {
6288                 return -EINVAL;
6289         }
6290 +       if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
6291 +               printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
6292 +                       sb->s_id);
6293 +               return -EINVAL;
6294 +       }
6295 +
6296         lock_kernel();
6297         if (newLVSize) {
6298                 if (sb->s_flags & MS_RDONLY) {
6299 @@ -449,6 +474,9 @@ static int jfs_fill_super(struct super_b
6300  #ifdef CONFIG_JFS_POSIX_ACL
6301         sb->s_flags |= MS_POSIXACL;
6302  #endif
6303 +       /* map mount option tagxid */
6304 +       if (sbi->flag & JFS_TAGGED)
6305 +               sb->s_flags |= MS_TAGGED;
6306  
6307         if (newLVSize) {
6308                 printk(KERN_ERR "resize option for remount only\n");
6309 diff -NurpP --minimal linux-2.6.33.2/fs/libfs.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/libfs.c
6310 --- linux-2.6.33.2/fs/libfs.c   2010-02-25 11:52:05.000000000 +0100
6311 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/libfs.c   2010-02-25 12:02:16.000000000 +0100
6312 @@ -127,7 +127,8 @@ static inline unsigned char dt_type(stru
6313   * both impossible due to the lock on directory.
6314   */
6315  
6316 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6317 +static inline int do_dcache_readdir_filter(struct file *filp,
6318 +       void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6319  {
6320         struct dentry *dentry = filp->f_path.dentry;
6321         struct dentry *cursor = filp->private_data;
6322 @@ -160,6 +161,8 @@ int dcache_readdir(struct file * filp, v
6323                                 next = list_entry(p, struct dentry, d_u.d_child);
6324                                 if (d_unhashed(next) || !next->d_inode)
6325                                         continue;
6326 +                               if (filter && !filter(next))
6327 +                                       continue;
6328  
6329                                 spin_unlock(&dcache_lock);
6330                                 if (filldir(dirent, next->d_name.name, 
6331 @@ -178,6 +181,18 @@ int dcache_readdir(struct file * filp, v
6332         return 0;
6333  }
6334  
6335 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6336 +{
6337 +       return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6338 +}
6339 +
6340 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6341 +       int (*filter)(struct dentry *))
6342 +{
6343 +       return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6344 +}
6345 +
6346 +
6347  ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6348  {
6349         return -EISDIR;
6350 @@ -841,6 +856,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6351  EXPORT_SYMBOL(dcache_dir_lseek);
6352  EXPORT_SYMBOL(dcache_dir_open);
6353  EXPORT_SYMBOL(dcache_readdir);
6354 +EXPORT_SYMBOL(dcache_readdir_filter);
6355  EXPORT_SYMBOL(generic_read_dir);
6356  EXPORT_SYMBOL(get_sb_pseudo);
6357  EXPORT_SYMBOL(simple_write_begin);
6358 diff -NurpP --minimal linux-2.6.33.2/fs/locks.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/locks.c
6359 --- linux-2.6.33.2/fs/locks.c   2009-12-03 20:02:52.000000000 +0100
6360 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/locks.c   2010-02-25 12:02:16.000000000 +0100
6361 @@ -127,6 +127,8 @@
6362  #include <linux/time.h>
6363  #include <linux/rcupdate.h>
6364  #include <linux/pid_namespace.h>
6365 +#include <linux/vs_base.h>
6366 +#include <linux/vs_limit.h>
6367  
6368  #include <asm/uaccess.h>
6369  
6370 @@ -148,6 +150,8 @@ static struct kmem_cache *filelock_cache
6371  /* Allocate an empty lock structure. */
6372  static struct file_lock *locks_alloc_lock(void)
6373  {
6374 +       if (!vx_locks_avail(1))
6375 +               return NULL;
6376         return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6377  }
6378  
6379 @@ -174,6 +178,7 @@ static void locks_free_lock(struct file_
6380         BUG_ON(!list_empty(&fl->fl_block));
6381         BUG_ON(!list_empty(&fl->fl_link));
6382  
6383 +       vx_locks_dec(fl);
6384         locks_release_private(fl);
6385         kmem_cache_free(filelock_cache, fl);
6386  }
6387 @@ -194,6 +199,7 @@ void locks_init_lock(struct file_lock *f
6388         fl->fl_start = fl->fl_end = 0;
6389         fl->fl_ops = NULL;
6390         fl->fl_lmops = NULL;
6391 +       fl->fl_xid = -1;
6392  }
6393  
6394  EXPORT_SYMBOL(locks_init_lock);
6395 @@ -248,6 +254,7 @@ void locks_copy_lock(struct file_lock *n
6396         new->fl_file = fl->fl_file;
6397         new->fl_ops = fl->fl_ops;
6398         new->fl_lmops = fl->fl_lmops;
6399 +       new->fl_xid = fl->fl_xid;
6400  
6401         locks_copy_private(new, fl);
6402  }
6403 @@ -286,6 +293,11 @@ static int flock_make_lock(struct file *
6404         fl->fl_flags = FL_FLOCK;
6405         fl->fl_type = type;
6406         fl->fl_end = OFFSET_MAX;
6407 +
6408 +       vxd_assert(filp->f_xid == vx_current_xid(),
6409 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6410 +       fl->fl_xid = filp->f_xid;
6411 +       vx_locks_inc(fl);
6412         
6413         *lock = fl;
6414         return 0;
6415 @@ -451,6 +463,7 @@ static int lease_init(struct file *filp,
6416  
6417         fl->fl_owner = current->files;
6418         fl->fl_pid = current->tgid;
6419 +       fl->fl_xid = vx_current_xid();
6420  
6421         fl->fl_file = filp;
6422         fl->fl_flags = FL_LEASE;
6423 @@ -470,6 +483,11 @@ static struct file_lock *lease_alloc(str
6424         if (fl == NULL)
6425                 return ERR_PTR(error);
6426  
6427 +       fl->fl_xid = vx_current_xid();
6428 +       if (filp)
6429 +               vxd_assert(filp->f_xid == fl->fl_xid,
6430 +                       "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6431 +       vx_locks_inc(fl);
6432         error = lease_init(filp, type, fl);
6433         if (error) {
6434                 locks_free_lock(fl);
6435 @@ -770,6 +788,7 @@ static int flock_lock_file(struct file *
6436         if (found)
6437                 cond_resched();
6438  
6439 +       new_fl->fl_xid = -1;
6440  find_conflict:
6441         for_each_lock(inode, before) {
6442                 struct file_lock *fl = *before;
6443 @@ -790,6 +809,7 @@ find_conflict:
6444                 goto out;
6445         locks_copy_lock(new_fl, request);
6446         locks_insert_lock(before, new_fl);
6447 +       vx_locks_inc(new_fl);
6448         new_fl = NULL;
6449         error = 0;
6450  
6451 @@ -800,7 +820,8 @@ out:
6452         return error;
6453  }
6454  
6455 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6456 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6457 +       struct file_lock *conflock, xid_t xid)
6458  {
6459         struct file_lock *fl;
6460         struct file_lock *new_fl = NULL;
6461 @@ -810,6 +831,8 @@ static int __posix_lock_file(struct inod
6462         struct file_lock **before;
6463         int error, added = 0;
6464  
6465 +       vxd_assert(xid == vx_current_xid(),
6466 +               "xid(%d) == current(%d)", xid, vx_current_xid());
6467         /*
6468          * We may need two file_lock structures for this operation,
6469          * so we get them in advance to avoid races.
6470 @@ -820,7 +843,11 @@ static int __posix_lock_file(struct inod
6471             (request->fl_type != F_UNLCK ||
6472              request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6473                 new_fl = locks_alloc_lock();
6474 +               new_fl->fl_xid = xid;
6475 +               vx_locks_inc(new_fl);
6476                 new_fl2 = locks_alloc_lock();
6477 +               new_fl2->fl_xid = xid;
6478 +               vx_locks_inc(new_fl2);
6479         }
6480  
6481         lock_kernel();
6482 @@ -1019,7 +1046,8 @@ static int __posix_lock_file(struct inod
6483  int posix_lock_file(struct file *filp, struct file_lock *fl,
6484                         struct file_lock *conflock)
6485  {
6486 -       return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6487 +       return __posix_lock_file(filp->f_path.dentry->d_inode,
6488 +               fl, conflock, filp->f_xid);
6489  }
6490  EXPORT_SYMBOL(posix_lock_file);
6491  
6492 @@ -1109,7 +1137,7 @@ int locks_mandatory_area(int read_write,
6493         fl.fl_end = offset + count - 1;
6494  
6495         for (;;) {
6496 -               error = __posix_lock_file(inode, &fl, NULL);
6497 +               error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6498                 if (error != FILE_LOCK_DEFERRED)
6499                         break;
6500                 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
6501 @@ -1424,6 +1452,7 @@ int generic_setlease(struct file *filp, 
6502  
6503         locks_copy_lock(new_fl, lease);
6504         locks_insert_lock(before, new_fl);
6505 +       vx_locks_inc(new_fl);
6506  
6507         *flp = new_fl;
6508         return 0;
6509 @@ -1779,6 +1808,11 @@ int fcntl_setlk(unsigned int fd, struct 
6510         if (file_lock == NULL)
6511                 return -ENOLCK;
6512  
6513 +       vxd_assert(filp->f_xid == vx_current_xid(),
6514 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6515 +       file_lock->fl_xid = filp->f_xid;
6516 +       vx_locks_inc(file_lock);
6517 +
6518         /*
6519          * This might block, so we do it before checking the inode.
6520          */
6521 @@ -1897,6 +1931,11 @@ int fcntl_setlk64(unsigned int fd, struc
6522         if (file_lock == NULL)
6523                 return -ENOLCK;
6524  
6525 +       vxd_assert(filp->f_xid == vx_current_xid(),
6526 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6527 +       file_lock->fl_xid = filp->f_xid;
6528 +       vx_locks_inc(file_lock);
6529 +
6530         /*
6531          * This might block, so we do it before checking the inode.
6532          */
6533 @@ -2162,8 +2201,11 @@ static int locks_show(struct seq_file *f
6534  
6535         lock_get_status(f, fl, (long)f->private, "");
6536  
6537 -       list_for_each_entry(bfl, &fl->fl_block, fl_block)
6538 +       list_for_each_entry(bfl, &fl->fl_block, fl_block) {
6539 +               if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6540 +                       continue;
6541                 lock_get_status(f, bfl, (long)f->private, " ->");
6542 +       }
6543  
6544         f->private++;
6545         return 0;
6546 diff -NurpP --minimal linux-2.6.33.2/fs/namei.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/namei.c
6547 --- linux-2.6.33.2/fs/namei.c   2010-02-25 11:52:05.000000000 +0100
6548 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/namei.c   2010-02-25 15:31:15.000000000 +0100
6549 @@ -33,6 +33,14 @@
6550  #include <linux/fcntl.h>
6551  #include <linux/device_cgroup.h>
6552  #include <linux/fs_struct.h>
6553 +#include <linux/proc_fs.h>
6554 +#include <linux/vserver/inode.h>
6555 +#include <linux/vs_base.h>
6556 +#include <linux/vs_tag.h>
6557 +#include <linux/vs_cowbl.h>
6558 +#include <linux/vs_device.h>
6559 +#include <linux/vs_context.h>
6560 +#include <linux/pid_namespace.h>
6561  #include <asm/uaccess.h>
6562  
6563  #include "internal.h"
6564 @@ -167,6 +175,77 @@ void putname(const char *name)
6565  EXPORT_SYMBOL(putname);
6566  #endif
6567  
6568 +static inline int dx_barrier(const struct inode *inode)
6569 +{
6570 +       if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
6571 +               vxwprintk_task(1, "did hit the barrier.");
6572 +               return 1;
6573 +       }
6574 +       return 0;
6575 +}
6576 +
6577 +static int __dx_permission(const struct inode *inode, int mask)
6578 +{
6579 +       if (dx_barrier(inode))
6580 +               return -EACCES;
6581 +
6582 +       if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6583 +               /* devpts is xid tagged */
6584 +               if (S_ISDIR(inode->i_mode) ||
6585 +                   vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
6586 +                       return 0;
6587 +       }
6588 +       else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6589 +               struct proc_dir_entry *de = PDE(inode);
6590 +
6591 +               if (de && !vx_hide_check(0, de->vx_flags))
6592 +                       goto out;
6593 +
6594 +               if ((mask & (MAY_WRITE | MAY_APPEND))) {
6595 +                       struct pid *pid;
6596 +                       struct task_struct *tsk;
6597 +
6598 +                       if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
6599 +                           vx_flags(VXF_STATE_SETUP, 0))
6600 +                               return 0;
6601 +
6602 +                       pid = PROC_I(inode)->pid;
6603 +                       if (!pid)
6604 +                               goto out;
6605 +
6606 +                       tsk = pid_task(pid, PIDTYPE_PID);
6607 +                       vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
6608 +                                 tsk, (tsk ? vx_task_xid(tsk) : 0));
6609 +                       if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
6610 +                               return 0;
6611 +               }
6612 +               else {
6613 +                       /* FIXME: Should we block some entries here? */
6614 +                       return 0;
6615 +               }
6616 +       }
6617 +       else {
6618 +               if (dx_notagcheck(inode->i_sb) ||
6619 +                   dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
6620 +                            DX_IDENT))
6621 +                       return 0;
6622 +       }
6623 +
6624 +out:
6625 +       return -EACCES;
6626 +}
6627 +
6628 +int dx_permission(const struct inode *inode, int mask)
6629 +{
6630 +       int ret = __dx_permission(inode, mask);
6631 +       if (unlikely(ret)) {
6632 +               vxwprintk_task(1, "denied %x access to %s:%p[#%d,%lu]",
6633 +                       mask, inode->i_sb->s_id, inode, inode->i_tag,
6634 +                       inode->i_ino);
6635 +       }
6636 +       return ret;
6637 +}
6638 +
6639  /*
6640   * This does basic POSIX ACL permission checking
6641   */
6642 @@ -267,10 +346,14 @@ int inode_permission(struct inode *inode
6643                 /*
6644                  * Nobody gets write access to an immutable file.
6645                  */
6646 -               if (IS_IMMUTABLE(inode))
6647 +               if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6648                         return -EACCES;
6649         }
6650  
6651 +       retval = dx_permission(inode, mask);
6652 +       if (retval)
6653 +               return retval;
6654 +
6655         if (inode->i_op->permission)
6656                 retval = inode->i_op->permission(inode, mask);
6657         else
6658 @@ -465,6 +548,9 @@ static int exec_permission(struct inode 
6659  {
6660         int ret;
6661  
6662 +       if (dx_barrier(inode))
6663 +               return -EACCES;
6664 +
6665         if (inode->i_op->permission) {
6666                 ret = inode->i_op->permission(inode, MAY_EXEC);
6667                 if (!ret)
6668 @@ -694,7 +780,8 @@ static __always_inline void follow_dotdo
6669  
6670                 if (nd->path.dentry == nd->root.dentry &&
6671                     nd->path.mnt == nd->root.mnt) {
6672 -                       break;
6673 +                       /* for sane '/' avoid follow_mount() */
6674 +                       return;
6675                 }
6676                 spin_lock(&dcache_lock);
6677                 if (nd->path.dentry != nd->path.mnt->mnt_root) {
6678 @@ -730,7 +817,7 @@ static int do_lookup(struct nameidata *n
6679  {
6680         struct vfsmount *mnt = nd->path.mnt;
6681         struct dentry *dentry, *parent;
6682 -       struct inode *dir;
6683 +       struct inode *dir, *inode;
6684         /*
6685          * See if the low-level filesystem might want
6686          * to use its own hash..
6687 @@ -746,12 +833,26 @@ static int do_lookup(struct nameidata *n
6688                 goto need_lookup;
6689         if (dentry->d_op && dentry->d_op->d_revalidate)
6690                 goto need_revalidate;
6691 +
6692 +       inode = dentry->d_inode;
6693 +       if (!inode)
6694 +               goto done;
6695 +
6696 +       if (__dx_permission(inode, MAY_ACCESS))
6697 +               goto hidden;
6698  done:
6699         path->mnt = mnt;
6700         path->dentry = dentry;
6701         __follow_mount(path);
6702         return 0;
6703  
6704 +hidden:
6705 +       vxwprintk_task(1, "did lookup hidden %s:%p[#%d,%lu] Â»%s/%.*s«.",
6706 +               inode->i_sb->s_id, inode, inode->i_tag, inode->i_ino,
6707 +               vxd_path(&nd->path), name->len, name->name);
6708 +       dput(dentry);
6709 +       return -ENOENT;
6710 +
6711  need_lookup:
6712         parent = nd->path.dentry;
6713         dir = parent->d_inode;
6714 @@ -1355,7 +1456,7 @@ static int may_delete(struct inode *dir,
6715         if (IS_APPEND(dir))
6716                 return -EPERM;
6717         if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6718 -           IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6719 +               IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6720                 return -EPERM;
6721         if (isdir) {
6722                 if (!S_ISDIR(victim->d_inode->i_mode))
6723 @@ -1495,6 +1596,14 @@ int may_open(struct path *path, int acc_
6724                 break;
6725         }
6726  
6727 +#ifdef CONFIG_VSERVER_COWBL
6728 +       if (IS_COW(inode) && (flag & FMODE_WRITE)) {
6729 +               if (IS_COW_LINK(inode))
6730 +                       return -EMLINK;
6731 +               inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
6732 +               mark_inode_dirty(inode);
6733 +       }
6734 +#endif
6735         error = inode_permission(inode, acc_mode);
6736         if (error)
6737                 return error;
6738 @@ -1621,6 +1730,11 @@ struct file *do_filp_open(int dfd, const
6739         int flag = open_to_namei_flags(open_flag);
6740         int force_reval = 0;
6741  
6742 +#ifdef CONFIG_VSERVER_COWBL
6743 +       int rflag = flag;
6744 +       int rmode = mode;
6745 +restart:
6746 +#endif
6747         /*
6748          * O_SYNC is implemented as __O_SYNC|O_DSYNC.  As many places only
6749          * check for O_DSYNC if the need any syncing at all we enforce it's
6750 @@ -1799,6 +1913,25 @@ ok:
6751                         goto exit;
6752         }
6753         error = may_open(&nd.path, acc_mode, flag);
6754 +#ifdef CONFIG_VSERVER_COWBL
6755 +       if (error == -EMLINK) {
6756 +               struct dentry *dentry;
6757 +               dentry = cow_break_link(pathname);
6758 +               if (IS_ERR(dentry)) {
6759 +                       error = PTR_ERR(dentry);
6760 +                       goto exit_cow;
6761 +               }
6762 +               dput(dentry);
6763 +               if (will_truncate)
6764 +                       mnt_drop_write(nd.path.mnt);
6765 +               release_open_intent(&nd);
6766 +               path_put(&nd.path);
6767 +               flag = rflag;
6768 +               mode = rmode;
6769 +               goto restart;
6770 +       }
6771 +exit_cow:
6772 +#endif
6773         if (error) {
6774                 if (will_truncate)
6775                         mnt_drop_write(nd.path.mnt);
6776 @@ -1982,9 +2115,17 @@ int vfs_mknod(struct inode *dir, struct 
6777         if (error)
6778                 return error;
6779  
6780 -       if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
6781 +       if (!(S_ISCHR(mode) || S_ISBLK(mode)))
6782 +               goto okay;
6783 +
6784 +       if (!capable(CAP_MKNOD))
6785                 return -EPERM;
6786  
6787 +       if (S_ISCHR(mode) && !vs_chrdev_perm(dev, DATTR_CREATE))
6788 +               return -EPERM;
6789 +       if (S_ISBLK(mode) && !vs_blkdev_perm(dev, DATTR_CREATE))
6790 +               return -EPERM;
6791 +okay:
6792         if (!dir->i_op->mknod)
6793                 return -EPERM;
6794  
6795 @@ -2451,7 +2592,7 @@ int vfs_link(struct dentry *old_dentry, 
6796         /*
6797          * A link to an append-only or immutable file cannot be created.
6798          */
6799 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6800 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6801                 return -EPERM;
6802         if (!dir->i_op->link)
6803                 return -EPERM;
6804 @@ -2824,6 +2965,219 @@ int vfs_follow_link(struct nameidata *nd
6805         return __vfs_follow_link(nd, link);
6806  }
6807  
6808 +
6809 +#ifdef CONFIG_VSERVER_COWBL
6810 +
6811 +#include <linux/file.h>
6812 +
6813 +static inline
6814 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6815 +{
6816 +       loff_t ppos = 0;
6817 +
6818 +       return do_splice_direct(in, &ppos, out, len, 0);
6819 +}
6820 +
6821 +struct dentry *cow_break_link(const char *pathname)
6822 +{
6823 +       int ret, mode, pathlen, redo = 0;
6824 +       struct nameidata old_nd, dir_nd;
6825 +       struct path old_path, new_path;
6826 +       struct dentry *dir, *res = NULL;
6827 +       struct file *old_file;
6828 +       struct file *new_file;
6829 +       char *to, *path, pad='\251';
6830 +       loff_t size;
6831 +
6832 +       vxdprintk(VXD_CBIT(misc, 1), "cow_break_link(»%s«)", pathname);
6833 +       path = kmalloc(PATH_MAX, GFP_KERNEL);
6834 +       ret = -ENOMEM;
6835 +       if (!path)
6836 +               goto out;
6837 +
6838 +       /* old_nd will have refs to dentry and mnt */
6839 +       ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6840 +       vxdprintk(VXD_CBIT(misc, 2), "path_lookup(old): %d", ret);
6841 +       if (ret < 0)
6842 +               goto out_free_path;
6843 +
6844 +       old_path = old_nd.path;
6845 +       mode = old_path.dentry->d_inode->i_mode;
6846 +
6847 +       to = d_path(&old_path, path, PATH_MAX-2);
6848 +       pathlen = strlen(to);
6849 +       vxdprintk(VXD_CBIT(misc, 2), "old path Â»%s« [»%.*s«:%d]", to,
6850 +               old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6851 +               old_path.dentry->d_name.len);
6852 +
6853 +       to[pathlen + 1] = 0;
6854 +retry:
6855 +       to[pathlen] = pad--;
6856 +       ret = -EMLINK;
6857 +       if (pad <= '\240')
6858 +               goto out_rel_old;
6859 +
6860 +       vxdprintk(VXD_CBIT(misc, 1), "temp copy Â»%s«", to);
6861 +       /* dir_nd will have refs to dentry and mnt */
6862 +       ret = path_lookup(to,
6863 +               LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6864 +       vxdprintk(VXD_CBIT(misc, 2),
6865 +               "path_lookup(new): %d", ret);
6866 +       if (ret < 0)
6867 +               goto retry;
6868 +
6869 +       /* this puppy downs the inode mutex */
6870 +       new_path.dentry = lookup_create(&dir_nd, 0);
6871 +       if (!new_path.dentry || IS_ERR(new_path.dentry)) {
6872 +               vxdprintk(VXD_CBIT(misc, 2),
6873 +                       "lookup_create(new): %p", new_path.dentry);
6874 +               mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
6875 +               path_put(&dir_nd.path);
6876 +               goto retry;
6877 +       }
6878 +       vxdprintk(VXD_CBIT(misc, 2),
6879 +               "lookup_create(new): %p [»%.*s«:%d]", new_path.dentry,
6880 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6881 +               new_path.dentry->d_name.len);
6882 +       dir = dir_nd.path.dentry;
6883 +
6884 +       ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
6885 +       vxdprintk(VXD_CBIT(misc, 2),
6886 +               "vfs_create(new): %d", ret);
6887 +       if (ret == -EEXIST) {
6888 +               mutex_unlock(&dir->d_inode->i_mutex);
6889 +               dput(new_path.dentry);
6890 +               path_put(&dir_nd.path);
6891 +               goto retry;
6892 +       }
6893 +       else if (ret < 0)
6894 +               goto out_unlock_new;
6895 +
6896 +       /* drop out early, ret passes ENOENT */
6897 +       ret = -ENOENT;
6898 +       if ((redo = d_unhashed(old_path.dentry)))
6899 +               goto out_unlock_new;
6900 +
6901 +       new_path.mnt = dir_nd.path.mnt;
6902 +       dget(old_path.dentry);
6903 +       mntget(old_path.mnt);
6904 +       /* this one cleans up the dentry/mnt in case of failure */
6905 +       old_file = dentry_open(old_path.dentry, old_path.mnt,
6906 +               O_RDONLY, current_cred());
6907 +       vxdprintk(VXD_CBIT(misc, 2),
6908 +               "dentry_open(old): %p", old_file);
6909 +       if (!old_file || IS_ERR(old_file)) {
6910 +               res = IS_ERR(old_file) ? (void *) old_file : res;
6911 +               goto out_unlock_new;
6912 +       }
6913 +
6914 +       dget(new_path.dentry);
6915 +       mntget(new_path.mnt);
6916 +       /* this one cleans up the dentry/mnt in case of failure */
6917 +       new_file = dentry_open(new_path.dentry, new_path.mnt,
6918 +               O_WRONLY, current_cred());
6919 +       vxdprintk(VXD_CBIT(misc, 2),
6920 +               "dentry_open(new): %p", new_file);
6921 +
6922 +       ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
6923 +       if (!new_file || IS_ERR(new_file))
6924 +               goto out_fput_old;
6925 +
6926 +       size = i_size_read(old_file->f_dentry->d_inode);
6927 +       ret = do_cow_splice(old_file, new_file, size);
6928 +       vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
6929 +       if (ret < 0) {
6930 +               goto out_fput_both;
6931 +       } else if (ret < size) {
6932 +               ret = -ENOSPC;
6933 +               goto out_fput_both;
6934 +       } else {
6935 +               struct inode *old_inode = old_path.dentry->d_inode;
6936 +               struct inode *new_inode = new_path.dentry->d_inode;
6937 +               struct iattr attr = {
6938 +                       .ia_uid = old_inode->i_uid,
6939 +                       .ia_gid = old_inode->i_gid,
6940 +                       .ia_valid = ATTR_UID | ATTR_GID
6941 +                       };
6942 +
6943 +               ret = inode_setattr(new_inode, &attr);
6944 +               if (ret)
6945 +                       goto out_fput_both;
6946 +       }
6947 +
6948 +       mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6949 +
6950 +       /* drop out late */
6951 +       ret = -ENOENT;
6952 +       if ((redo = d_unhashed(old_path.dentry)))
6953 +               goto out_unlock;
6954 +
6955 +       vxdprintk(VXD_CBIT(misc, 2),
6956 +               "vfs_rename: [»%*s«:%d] -> [»%*s«:%d]",
6957 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6958 +               new_path.dentry->d_name.len,
6959 +               old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6960 +               old_path.dentry->d_name.len);
6961 +       ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
6962 +               old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
6963 +       vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
6964 +       res = new_path.dentry;
6965 +
6966 +out_unlock:
6967 +       mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6968 +
6969 +out_fput_both:
6970 +       vxdprintk(VXD_CBIT(misc, 3),
6971 +               "fput(new_file=%p[#%ld])", new_file,
6972 +               atomic_long_read(&new_file->f_count));
6973 +       fput(new_file);
6974 +
6975 +out_fput_old:
6976 +       vxdprintk(VXD_CBIT(misc, 3),
6977 +               "fput(old_file=%p[#%ld])", old_file,
6978 +               atomic_long_read(&old_file->f_count));
6979 +       fput(old_file);
6980 +
6981 +out_unlock_new:
6982 +       mutex_unlock(&dir->d_inode->i_mutex);
6983 +       if (!ret)
6984 +               goto out_redo;
6985 +
6986 +       /* error path cleanup */
6987 +       vfs_unlink(dir->d_inode, new_path.dentry);
6988 +       dput(new_path.dentry);
6989 +
6990 +out_redo:
6991 +       if (!redo)
6992 +               goto out_rel_both;
6993 +       /* lookup dentry once again */
6994 +       path_put(&old_nd.path);
6995 +       ret = path_lookup(pathname, LOOKUP_FOLLOW, &old_nd);
6996 +       if (ret)
6997 +               goto out_rel_both;
6998 +
6999 +       new_path.dentry = old_nd.path.dentry;
7000 +       vxdprintk(VXD_CBIT(misc, 2),
7001 +               "path_lookup(redo): %p [»%.*s«:%d]", new_path.dentry,
7002 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
7003 +               new_path.dentry->d_name.len);
7004 +       dget(new_path.dentry);
7005 +       res = new_path.dentry;
7006 +
7007 +out_rel_both:
7008 +       path_put(&dir_nd.path);
7009 +out_rel_old:
7010 +       path_put(&old_nd.path);
7011 +out_free_path:
7012 +       kfree(path);
7013 +out:
7014 +       if (ret)
7015 +               res = ERR_PTR(ret);
7016 +       return res;
7017 +}
7018 +
7019 +#endif
7020 +
7021  /* get the link contents into pagecache */
7022  static char *page_getlink(struct dentry * dentry, struct page **ppage)
7023  {
7024 diff -NurpP --minimal linux-2.6.33.2/fs/namespace.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/namespace.c
7025 --- linux-2.6.33.2/fs/namespace.c       2010-02-25 11:52:05.000000000 +0100
7026 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/namespace.c       2010-02-25 12:02:16.000000000 +0100
7027 @@ -29,6 +29,11 @@
7028  #include <linux/log2.h>
7029  #include <linux/idr.h>
7030  #include <linux/fs_struct.h>
7031 +#include <linux/vs_base.h>
7032 +#include <linux/vs_context.h>
7033 +#include <linux/vs_tag.h>
7034 +#include <linux/vserver/space.h>
7035 +#include <linux/vserver/global.h>
7036  #include <asm/uaccess.h>
7037  #include <asm/unistd.h>
7038  #include "pnode.h"
7039 @@ -567,6 +572,7 @@ static struct vfsmount *clone_mnt(struct
7040                 mnt->mnt_root = dget(root);
7041                 mnt->mnt_mountpoint = mnt->mnt_root;
7042                 mnt->mnt_parent = mnt;
7043 +               mnt->mnt_tag = old->mnt_tag;
7044  
7045                 if (flag & CL_SLAVE) {
7046                         list_add(&mnt->mnt_slave, &old->mnt_slave_list);
7047 @@ -661,6 +667,31 @@ static inline void mangle(struct seq_fil
7048         seq_escape(m, s, " \t\n\\");
7049  }
7050  
7051 +static int mnt_is_reachable(struct vfsmount *mnt)
7052 +{
7053 +       struct path root;
7054 +       struct dentry *point;
7055 +       int ret;
7056 +
7057 +       if (mnt == mnt->mnt_ns->root)
7058 +               return 1;
7059 +
7060 +       spin_lock(&vfsmount_lock);
7061 +       root = current->fs->root;
7062 +       point = root.dentry;
7063 +
7064 +       while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
7065 +               point = mnt->mnt_mountpoint;
7066 +               mnt = mnt->mnt_parent;
7067 +       }
7068 +
7069 +       ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
7070 +
7071 +       spin_unlock(&vfsmount_lock);
7072 +
7073 +       return ret;
7074 +}
7075 +
7076  /*
7077   * Simple .show_options callback for filesystems which don't want to
7078   * implement more complex mount option showing.
7079 @@ -748,6 +779,8 @@ static int show_sb_opts(struct seq_file 
7080                 { MS_SYNCHRONOUS, ",sync" },
7081                 { MS_DIRSYNC, ",dirsync" },
7082                 { MS_MANDLOCK, ",mand" },
7083 +               { MS_TAGGED, ",tag" },
7084 +               { MS_NOTAGCHECK, ",notagcheck" },
7085                 { 0, NULL }
7086         };
7087         const struct proc_fs_info *fs_infop;
7088 @@ -795,10 +828,20 @@ static int show_vfsmnt(struct seq_file *
7089         int err = 0;
7090         struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
7091  
7092 -       mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7093 -       seq_putc(m, ' ');
7094 -       seq_path(m, &mnt_path, " \t\n\\");
7095 -       seq_putc(m, ' ');
7096 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
7097 +               return SEQ_SKIP;
7098 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7099 +               return SEQ_SKIP;
7100 +
7101 +       if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7102 +               mnt == current->fs->root.mnt) {
7103 +               seq_puts(m, "/dev/root / ");
7104 +       } else {
7105 +               mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7106 +               seq_putc(m, ' ');
7107 +               seq_path(m, &mnt_path, " \t\n\\");
7108 +               seq_putc(m, ' ');
7109 +       }
7110         show_type(m, mnt->mnt_sb);
7111         seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
7112         err = show_sb_opts(m, mnt->mnt_sb);
7113 @@ -828,6 +871,11 @@ static int show_mountinfo(struct seq_fil
7114         struct path root = p->root;
7115         int err = 0;
7116  
7117 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
7118 +               return SEQ_SKIP;
7119 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7120 +               return SEQ_SKIP;
7121 +
7122         seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
7123                    MAJOR(sb->s_dev), MINOR(sb->s_dev));
7124         seq_dentry(m, mnt->mnt_root, " \t\n\\");
7125 @@ -886,17 +934,27 @@ static int show_vfsstat(struct seq_file 
7126         struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
7127         int err = 0;
7128  
7129 -       /* device */
7130 -       if (mnt->mnt_devname) {
7131 -               seq_puts(m, "device ");
7132 -               mangle(m, mnt->mnt_devname);
7133 -       } else
7134 -               seq_puts(m, "no device");
7135 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
7136 +               return SEQ_SKIP;
7137 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7138 +               return SEQ_SKIP;
7139  
7140 -       /* mount point */
7141 -       seq_puts(m, " mounted on ");
7142 -       seq_path(m, &mnt_path, " \t\n\\");
7143 -       seq_putc(m, ' ');
7144 +       if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7145 +               mnt == current->fs->root.mnt) {
7146 +               seq_puts(m, "device /dev/root mounted on / ");
7147 +       } else {
7148 +               /* device */
7149 +               if (mnt->mnt_devname) {
7150 +                       seq_puts(m, "device ");
7151 +                       mangle(m, mnt->mnt_devname);
7152 +               } else
7153 +                       seq_puts(m, "no device");
7154 +
7155 +               /* mount point */
7156 +               seq_puts(m, " mounted on ");
7157 +               seq_path(m, &mnt_path, " \t\n\\");
7158 +               seq_putc(m, ' ');
7159 +       }
7160  
7161         /* file system type */
7162         seq_puts(m, "with fstype ");
7163 @@ -1132,7 +1190,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
7164                 goto dput_and_out;
7165  
7166         retval = -EPERM;
7167 -       if (!capable(CAP_SYS_ADMIN))
7168 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7169                 goto dput_and_out;
7170  
7171         retval = do_umount(path.mnt, flags);
7172 @@ -1158,7 +1216,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
7173  
7174  static int mount_is_safe(struct path *path)
7175  {
7176 -       if (capable(CAP_SYS_ADMIN))
7177 +       if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7178                 return 0;
7179         return -EPERM;
7180  #ifdef notyet
7181 @@ -1422,7 +1480,7 @@ static int do_change_type(struct path *p
7182         int type = flag & ~MS_REC;
7183         int err = 0;
7184  
7185 -       if (!capable(CAP_SYS_ADMIN))
7186 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
7187                 return -EPERM;
7188  
7189         if (path->dentry != path->mnt->mnt_root)
7190 @@ -1449,11 +1507,13 @@ static int do_change_type(struct path *p
7191   * do loopback mount.
7192   */
7193  static int do_loopback(struct path *path, char *old_name,
7194 -                               int recurse)
7195 +       tag_t tag, unsigned long flags, int mnt_flags)
7196  {
7197         struct path old_path;
7198         struct vfsmount *mnt = NULL;
7199         int err = mount_is_safe(path);
7200 +       int recurse = flags & MS_REC;
7201 +
7202         if (err)
7203                 return err;
7204         if (!old_name || !*old_name)
7205 @@ -1487,6 +1547,7 @@ static int do_loopback(struct path *path
7206                 spin_unlock(&vfsmount_lock);
7207                 release_mounts(&umount_list);
7208         }
7209 +       mnt->mnt_flags = mnt_flags;
7210  
7211  out:
7212         up_write(&namespace_sem);
7213 @@ -1517,12 +1578,12 @@ static int change_mount_flags(struct vfs
7214   * on it - tough luck.
7215   */
7216  static int do_remount(struct path *path, int flags, int mnt_flags,
7217 -                     void *data)
7218 +       void *data, xid_t xid)
7219  {
7220         int err;
7221         struct super_block *sb = path->mnt->mnt_sb;
7222  
7223 -       if (!capable(CAP_SYS_ADMIN))
7224 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7225                 return -EPERM;
7226  
7227         if (!check_mnt(path->mnt))
7228 @@ -1568,7 +1629,7 @@ static int do_move_mount(struct path *pa
7229         struct path old_path, parent_path;
7230         struct vfsmount *p;
7231         int err = 0;
7232 -       if (!capable(CAP_SYS_ADMIN))
7233 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7234                 return -EPERM;
7235         if (!old_name || !*old_name)
7236                 return -EINVAL;
7237 @@ -1650,7 +1711,7 @@ static int do_new_mount(struct path *pat
7238                 return -EINVAL;
7239  
7240         /* we need capabilities... */
7241 -       if (!capable(CAP_SYS_ADMIN))
7242 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7243                 return -EPERM;
7244  
7245         lock_kernel();
7246 @@ -1916,6 +1977,7 @@ long do_mount(char *dev_name, char *dir_
7247         struct path path;
7248         int retval = 0;
7249         int mnt_flags = 0;
7250 +       tag_t tag = 0;
7251  
7252         /* Discard magic */
7253         if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7254 @@ -1943,6 +2005,12 @@ long do_mount(char *dev_name, char *dir_
7255         if (!(flags & MS_NOATIME))
7256                 mnt_flags |= MNT_RELATIME;
7257  
7258 +       if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
7259 +               /* FIXME: bind and re-mounts get the tag flag? */
7260 +               if (flags & (MS_BIND|MS_REMOUNT))
7261 +                       flags |= MS_TAGID;
7262 +       }
7263 +
7264         /* Separate the per-mountpoint flags */
7265         if (flags & MS_NOSUID)
7266                 mnt_flags |= MNT_NOSUID;
7267 @@ -1959,15 +2027,17 @@ long do_mount(char *dev_name, char *dir_
7268         if (flags & MS_RDONLY)
7269                 mnt_flags |= MNT_READONLY;
7270  
7271 +       if (!capable(CAP_SYS_ADMIN))
7272 +               mnt_flags |= MNT_NODEV;
7273         flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
7274                    MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
7275                    MS_STRICTATIME);
7276  
7277         if (flags & MS_REMOUNT)
7278                 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
7279 -                                   data_page);
7280 +                                   data_page, tag);
7281         else if (flags & MS_BIND)
7282 -               retval = do_loopback(&path, dev_name, flags & MS_REC);
7283 +               retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
7284         else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7285                 retval = do_change_type(&path, flags);
7286         else if (flags & MS_MOVE)
7287 @@ -2046,6 +2116,7 @@ static struct mnt_namespace *dup_mnt_ns(
7288                 q = next_mnt(q, new_ns->root);
7289         }
7290         up_write(&namespace_sem);
7291 +       atomic_inc(&vs_global_mnt_ns);
7292  
7293         if (rootmnt)
7294                 mntput(rootmnt);
7295 @@ -2190,9 +2261,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
7296         down_write(&namespace_sem);
7297         mutex_lock(&old.dentry->d_inode->i_mutex);
7298         error = -EINVAL;
7299 -       if (IS_MNT_SHARED(old.mnt) ||
7300 +       if ((IS_MNT_SHARED(old.mnt) ||
7301                 IS_MNT_SHARED(new.mnt->mnt_parent) ||
7302 -               IS_MNT_SHARED(root.mnt->mnt_parent))
7303 +               IS_MNT_SHARED(root.mnt->mnt_parent)) &&
7304 +               !vx_flags(VXF_STATE_SETUP, 0))
7305                 goto out2;
7306         if (!check_mnt(root.mnt))
7307                 goto out2;
7308 @@ -2328,6 +2400,7 @@ void put_mnt_ns(struct mnt_namespace *ns
7309         spin_unlock(&vfsmount_lock);
7310         up_write(&namespace_sem);
7311         release_mounts(&umount_list);
7312 +       atomic_dec(&vs_global_mnt_ns);
7313         kfree(ns);
7314  }
7315  EXPORT_SYMBOL(put_mnt_ns);
7316 diff -NurpP --minimal linux-2.6.33.2/fs/nfs/client.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/client.c
7317 --- linux-2.6.33.2/fs/nfs/client.c      2010-02-25 11:52:05.000000000 +0100
7318 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/client.c      2010-02-25 12:02:16.000000000 +0100
7319 @@ -738,6 +738,9 @@ static int nfs_init_server_rpcclient(str
7320         if (server->flags & NFS_MOUNT_SOFT)
7321                 server->client->cl_softrtry = 1;
7322  
7323 +       server->client->cl_tag = 0;
7324 +       if (server->flags & NFS_MOUNT_TAGGED)
7325 +               server->client->cl_tag = 1;
7326         return 0;
7327  }
7328  
7329 @@ -909,6 +912,10 @@ static void nfs_server_set_fsinfo(struct
7330                 server->acdirmin = server->acdirmax = 0;
7331         }
7332  
7333 +       /* FIXME: needs fsinfo
7334 +       if (server->flags & NFS_MOUNT_TAGGED)
7335 +               sb->s_flags |= MS_TAGGED;       */
7336 +
7337         server->maxfilesize = fsinfo->maxfilesize;
7338  
7339         /* We're airborne Set socket buffersize */
7340 diff -NurpP --minimal linux-2.6.33.2/fs/nfs/dir.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/dir.c
7341 --- linux-2.6.33.2/fs/nfs/dir.c 2010-04-06 01:47:46.000000000 +0200
7342 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/dir.c 2010-04-06 01:59:25.000000000 +0200
7343 @@ -33,6 +33,7 @@
7344  #include <linux/namei.h>
7345  #include <linux/mount.h>
7346  #include <linux/sched.h>
7347 +#include <linux/vs_tag.h>
7348  
7349  #include "nfs4_fs.h"
7350  #include "delegation.h"
7351 @@ -949,6 +950,7 @@ static struct dentry *nfs_lookup(struct 
7352         if (IS_ERR(res))
7353                 goto out_unblock_sillyrename;
7354  
7355 +       dx_propagate_tag(nd, inode);
7356  no_entry:
7357         res = d_materialise_unique(dentry, inode);
7358         if (res != NULL) {
7359 diff -NurpP --minimal linux-2.6.33.2/fs/nfs/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/inode.c
7360 --- linux-2.6.33.2/fs/nfs/inode.c       2010-04-06 01:47:46.000000000 +0200
7361 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/inode.c       2010-04-06 01:59:25.000000000 +0200
7362 @@ -36,6 +36,7 @@
7363  #include <linux/vfs.h>
7364  #include <linux/inet.h>
7365  #include <linux/nfs_xdr.h>
7366 +#include <linux/vs_tag.h>
7367  
7368  #include <asm/system.h>
7369  #include <asm/uaccess.h>
7370 @@ -279,6 +280,8 @@ nfs_fhget(struct super_block *sb, struct
7371         if (inode->i_state & I_NEW) {
7372                 struct nfs_inode *nfsi = NFS_I(inode);
7373                 unsigned long now = jiffies;
7374 +               uid_t uid;
7375 +               gid_t gid;
7376  
7377                 /* We set i_ino for the few things that still rely on it,
7378                  * such as stat(2) */
7379 @@ -327,8 +330,8 @@ nfs_fhget(struct super_block *sb, struct
7380                 nfsi->change_attr = 0;
7381                 inode->i_size = 0;
7382                 inode->i_nlink = 0;
7383 -               inode->i_uid = -2;
7384 -               inode->i_gid = -2;
7385 +               uid = -2;
7386 +               gid = -2;
7387                 inode->i_blocks = 0;
7388                 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
7389  
7390 @@ -365,13 +368,13 @@ nfs_fhget(struct super_block *sb, struct
7391                 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
7392                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
7393                 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
7394 -                       inode->i_uid = fattr->uid;
7395 +                       uid = fattr->uid;
7396                 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
7397                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7398                                 | NFS_INO_INVALID_ACCESS
7399                                 | NFS_INO_INVALID_ACL;
7400                 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
7401 -                       inode->i_gid = fattr->gid;
7402 +                       gid = fattr->gid;
7403                 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
7404                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7405                                 | NFS_INO_INVALID_ACCESS
7406 @@ -384,6 +387,11 @@ nfs_fhget(struct super_block *sb, struct
7407                          */
7408                         inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
7409                 }
7410 +               inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7411 +               inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7412 +               inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7413 +                               /* maybe fattr->xid someday */
7414 +
7415                 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
7416                 nfsi->attrtimeo_timestamp = now;
7417                 nfsi->access_cache = RB_ROOT;
7418 @@ -496,6 +504,8 @@ void nfs_setattr_update_inode(struct ino
7419                         inode->i_uid = attr->ia_uid;
7420                 if ((attr->ia_valid & ATTR_GID) != 0)
7421                         inode->i_gid = attr->ia_gid;
7422 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7423 +                       inode->i_tag = attr->ia_tag;
7424                 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7425                 spin_unlock(&inode->i_lock);
7426         }
7427 @@ -906,6 +916,9 @@ static int nfs_check_inode_attributes(st
7428         struct nfs_inode *nfsi = NFS_I(inode);
7429         loff_t cur_size, new_isize;
7430         unsigned long invalid = 0;
7431 +       uid_t uid;
7432 +       gid_t gid;
7433 +       tag_t tag;
7434  
7435  
7436         /* Has the inode gone and changed behind our back? */
7437 @@ -929,13 +942,18 @@ static int nfs_check_inode_attributes(st
7438                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7439         }
7440  
7441 +       uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7442 +       gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7443 +       tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7444 +
7445         /* Have any file permissions changed? */
7446         if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
7447                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7448 -       if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
7449 +       if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
7450                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7451 -       if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
7452 +       if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
7453                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7454 +               /* maybe check for tag too? */
7455  
7456         /* Has the link count changed? */
7457         if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
7458 @@ -1150,6 +1168,9 @@ static int nfs_update_inode(struct inode
7459         unsigned long invalid = 0;
7460         unsigned long now = jiffies;
7461         unsigned long save_cache_validity;
7462 +       uid_t uid;
7463 +       gid_t gid;
7464 +       tag_t tag;
7465  
7466         dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7467                         __func__, inode->i_sb->s_id, inode->i_ino,
7468 @@ -1252,6 +1273,9 @@ static int nfs_update_inode(struct inode
7469                                 | NFS_INO_REVAL_PAGECACHE
7470                                 | NFS_INO_REVAL_FORCED);
7471  
7472 +       uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7473 +       gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7474 +       tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7475  
7476         if (fattr->valid & NFS_ATTR_FATTR_ATIME)
7477                 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7478 @@ -1273,9 +1297,9 @@ static int nfs_update_inode(struct inode
7479                                 | NFS_INO_REVAL_FORCED);
7480  
7481         if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
7482 -               if (inode->i_uid != fattr->uid) {
7483 +               if (uid != fattr->uid) {
7484                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7485 -                       inode->i_uid = fattr->uid;
7486 +                       uid = fattr->uid;
7487                 }
7488         } else if (server->caps & NFS_CAP_OWNER)
7489                 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7490 @@ -1284,9 +1308,9 @@ static int nfs_update_inode(struct inode
7491                                 | NFS_INO_REVAL_FORCED);
7492  
7493         if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
7494 -               if (inode->i_gid != fattr->gid) {
7495 +               if (gid != fattr->gid) {
7496                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7497 -                       inode->i_gid = fattr->gid;
7498 +                       gid = fattr->gid;
7499                 }
7500         } else if (server->caps & NFS_CAP_OWNER_GROUP)
7501                 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7502 @@ -1294,6 +1318,10 @@ static int nfs_update_inode(struct inode
7503                                 | NFS_INO_INVALID_ACL
7504                                 | NFS_INO_REVAL_FORCED);
7505  
7506 +       inode->i_uid = uid;
7507 +       inode->i_gid = gid;
7508 +       inode->i_tag = tag;
7509 +
7510         if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
7511                 if (inode->i_nlink != fattr->nlink) {
7512                         invalid |= NFS_INO_INVALID_ATTR;
7513 diff -NurpP --minimal linux-2.6.33.2/fs/nfs/nfs3xdr.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/nfs3xdr.c
7514 --- linux-2.6.33.2/fs/nfs/nfs3xdr.c     2009-12-03 20:02:52.000000000 +0100
7515 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/nfs3xdr.c     2010-02-25 12:02:16.000000000 +0100
7516 @@ -21,6 +21,7 @@
7517  #include <linux/nfs3.h>
7518  #include <linux/nfs_fs.h>
7519  #include <linux/nfsacl.h>
7520 +#include <linux/vs_tag.h>
7521  #include "internal.h"
7522  
7523  #define NFSDBG_FACILITY                NFSDBG_XDR
7524 @@ -176,7 +177,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_f
7525  }
7526  
7527  static inline __be32 *
7528 -xdr_encode_sattr(__be32 *p, struct iattr *attr)
7529 +xdr_encode_sattr(__be32 *p, struct iattr *attr, int tag)
7530  {
7531         if (attr->ia_valid & ATTR_MODE) {
7532                 *p++ = xdr_one;
7533 @@ -184,15 +185,17 @@ xdr_encode_sattr(__be32 *p, struct iattr
7534         } else {
7535                 *p++ = xdr_zero;
7536         }
7537 -       if (attr->ia_valid & ATTR_UID) {
7538 +       if (attr->ia_valid & ATTR_UID ||
7539 +               (tag && (attr->ia_valid & ATTR_TAG))) {
7540                 *p++ = xdr_one;
7541 -               *p++ = htonl(attr->ia_uid);
7542 +               *p++ = htonl(TAGINO_UID(tag, attr->ia_uid, attr->ia_tag));
7543         } else {
7544                 *p++ = xdr_zero;
7545         }
7546 -       if (attr->ia_valid & ATTR_GID) {
7547 +       if (attr->ia_valid & ATTR_GID ||
7548 +               (tag && (attr->ia_valid & ATTR_TAG))) {
7549                 *p++ = xdr_one;
7550 -               *p++ = htonl(attr->ia_gid);
7551 +               *p++ = htonl(TAGINO_GID(tag, attr->ia_gid, attr->ia_tag));
7552         } else {
7553                 *p++ = xdr_zero;
7554         }
7555 @@ -279,7 +282,8 @@ static int
7556  nfs3_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs3_sattrargs *args)
7557  {
7558         p = xdr_encode_fhandle(p, args->fh);
7559 -       p = xdr_encode_sattr(p, args->sattr);
7560 +       p = xdr_encode_sattr(p, args->sattr,
7561 +               req->rq_task->tk_client->cl_tag);
7562         *p++ = htonl(args->guard);
7563         if (args->guard)
7564                 p = xdr_encode_time3(p, &args->guardtime);
7565 @@ -384,7 +388,8 @@ nfs3_xdr_createargs(struct rpc_rqst *req
7566                 *p++ = args->verifier[0];
7567                 *p++ = args->verifier[1];
7568         } else
7569 -               p = xdr_encode_sattr(p, args->sattr);
7570 +               p = xdr_encode_sattr(p, args->sattr,
7571 +                       req->rq_task->tk_client->cl_tag);
7572  
7573         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7574         return 0;
7575 @@ -398,7 +403,8 @@ nfs3_xdr_mkdirargs(struct rpc_rqst *req,
7576  {
7577         p = xdr_encode_fhandle(p, args->fh);
7578         p = xdr_encode_array(p, args->name, args->len);
7579 -       p = xdr_encode_sattr(p, args->sattr);
7580 +       p = xdr_encode_sattr(p, args->sattr,
7581 +               req->rq_task->tk_client->cl_tag);
7582         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7583         return 0;
7584  }
7585 @@ -411,7 +417,8 @@ nfs3_xdr_symlinkargs(struct rpc_rqst *re
7586  {
7587         p = xdr_encode_fhandle(p, args->fromfh);
7588         p = xdr_encode_array(p, args->fromname, args->fromlen);
7589 -       p = xdr_encode_sattr(p, args->sattr);
7590 +       p = xdr_encode_sattr(p, args->sattr,
7591 +               req->rq_task->tk_client->cl_tag);
7592         *p++ = htonl(args->pathlen);
7593         req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
7594  
7595 @@ -429,7 +436,8 @@ nfs3_xdr_mknodargs(struct rpc_rqst *req,
7596         p = xdr_encode_fhandle(p, args->fh);
7597         p = xdr_encode_array(p, args->name, args->len);
7598         *p++ = htonl(args->type);
7599 -       p = xdr_encode_sattr(p, args->sattr);
7600 +       p = xdr_encode_sattr(p, args->sattr,
7601 +               req->rq_task->tk_client->cl_tag);
7602         if (args->type == NF3CHR || args->type == NF3BLK) {
7603                 *p++ = htonl(MAJOR(args->rdev));
7604                 *p++ = htonl(MINOR(args->rdev));
7605 diff -NurpP --minimal linux-2.6.33.2/fs/nfs/nfsroot.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/nfsroot.c
7606 --- linux-2.6.33.2/fs/nfs/nfsroot.c     2009-09-10 15:26:23.000000000 +0200
7607 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/nfsroot.c     2010-02-25 12:02:16.000000000 +0100
7608 @@ -122,12 +122,12 @@ static int mount_port __initdata = 0;             /
7609  enum {
7610         /* Options that take integer arguments */
7611         Opt_port, Opt_rsize, Opt_wsize, Opt_timeo, Opt_retrans, Opt_acregmin,
7612 -       Opt_acregmax, Opt_acdirmin, Opt_acdirmax,
7613 +       Opt_acregmax, Opt_acdirmin, Opt_acdirmax, Opt_tagid,
7614         /* Options that take no arguments */
7615         Opt_soft, Opt_hard, Opt_intr,
7616         Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac, 
7617         Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
7618 -       Opt_acl, Opt_noacl,
7619 +       Opt_acl, Opt_noacl, Opt_tag, Opt_notag,
7620         /* Error token */
7621         Opt_err
7622  };
7623 @@ -164,6 +164,9 @@ static const match_table_t tokens __init
7624         {Opt_tcp, "tcp"},
7625         {Opt_acl, "acl"},
7626         {Opt_noacl, "noacl"},
7627 +       {Opt_tag, "tag"},
7628 +       {Opt_notag, "notag"},
7629 +       {Opt_tagid, "tagid=%u"},
7630         {Opt_err, NULL}
7631         
7632  };
7633 @@ -275,6 +278,20 @@ static int __init root_nfs_parse(char *n
7634                         case Opt_noacl:
7635                                 nfs_data.flags |= NFS_MOUNT_NOACL;
7636                                 break;
7637 +#ifndef CONFIG_TAGGING_NONE
7638 +                       case Opt_tag:
7639 +                               nfs_data.flags |= NFS_MOUNT_TAGGED;
7640 +                               break;
7641 +                       case Opt_notag:
7642 +                               nfs_data.flags &= ~NFS_MOUNT_TAGGED;
7643 +                               break;
7644 +#endif
7645 +#ifdef CONFIG_PROPAGATE
7646 +                       case Opt_tagid:
7647 +                               /* use args[0] */
7648 +                               nfs_data.flags |= NFS_MOUNT_TAGGED;
7649 +                               break;
7650 +#endif
7651                         default:
7652                                 printk(KERN_WARNING "Root-NFS: unknown "
7653                                         "option: %s\n", p);
7654 diff -NurpP --minimal linux-2.6.33.2/fs/nfs/super.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/super.c
7655 --- linux-2.6.33.2/fs/nfs/super.c       2010-02-25 11:52:05.000000000 +0100
7656 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfs/super.c       2010-02-25 12:02:16.000000000 +0100
7657 @@ -53,6 +53,7 @@
7658  #include <linux/nfs_xdr.h>
7659  #include <linux/magic.h>
7660  #include <linux/parser.h>
7661 +#include <linux/vs_tag.h>
7662  
7663  #include <asm/system.h>
7664  #include <asm/uaccess.h>
7665 @@ -585,6 +586,7 @@ static void nfs_show_mount_options(struc
7666                 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7667                 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
7668                 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
7669 +               { NFS_MOUNT_TAGGED, ",tag", "" },
7670                 { 0, NULL, NULL }
7671         };
7672         const struct proc_nfs_info *nfs_infop;
7673 diff -NurpP --minimal linux-2.6.33.2/fs/nfsd/auth.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfsd/auth.c
7674 --- linux-2.6.33.2/fs/nfsd/auth.c       2010-02-25 11:52:05.000000000 +0100
7675 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfsd/auth.c       2010-02-25 13:17:41.000000000 +0100
7676 @@ -1,6 +1,7 @@
7677  /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
7678  
7679  #include <linux/sched.h>
7680 +#include <linux/vs_tag.h>
7681  #include "nfsd.h"
7682  #include "auth.h"
7683  
7684 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7685  
7686         new->fsuid = rqstp->rq_cred.cr_uid;
7687         new->fsgid = rqstp->rq_cred.cr_gid;
7688 +       /* FIXME: this desperately needs a tag :)
7689 +       new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7690 +                       */
7691  
7692         rqgi = rqstp->rq_cred.cr_group_info;
7693  
7694 diff -NurpP --minimal linux-2.6.33.2/fs/nfsd/nfs3xdr.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfsd/nfs3xdr.c
7695 --- linux-2.6.33.2/fs/nfsd/nfs3xdr.c    2010-02-25 11:52:05.000000000 +0100
7696 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfsd/nfs3xdr.c    2010-02-25 13:18:45.000000000 +0100
7697 @@ -7,6 +7,7 @@
7698   */
7699  
7700  #include <linux/namei.h>
7701 +#include <linux/vs_tag.h>
7702  #include "xdr3.h"
7703  #include "auth.h"
7704  
7705 @@ -95,6 +96,8 @@ static __be32 *
7706  decode_sattr3(__be32 *p, struct iattr *iap)
7707  {
7708         u32     tmp;
7709 +       uid_t   uid = 0;
7710 +       gid_t   gid = 0;
7711  
7712         iap->ia_valid = 0;
7713  
7714 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7715         }
7716         if (*p++) {
7717                 iap->ia_valid |= ATTR_UID;
7718 -               iap->ia_uid = ntohl(*p++);
7719 +               uid = ntohl(*p++);
7720         }
7721         if (*p++) {
7722                 iap->ia_valid |= ATTR_GID;
7723 -               iap->ia_gid = ntohl(*p++);
7724 +               gid = ntohl(*p++);
7725         }
7726 +       iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7727 +       iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7728 +       iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7729         if (*p++) {
7730                 u64     newsize;
7731  
7732 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
7733         *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7734         *p++ = htonl((u32) stat->mode);
7735         *p++ = htonl((u32) stat->nlink);
7736 -       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7737 -       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7738 +       *p++ = htonl((u32) nfsd_ruid(rqstp,
7739 +               TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7740 +               stat->uid, stat->tag)));
7741 +       *p++ = htonl((u32) nfsd_rgid(rqstp,
7742 +               TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7743 +               stat->gid, stat->tag)));
7744         if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7745                 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7746         } else {
7747 diff -NurpP --minimal linux-2.6.33.2/fs/nfsd/nfs4xdr.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfsd/nfs4xdr.c
7748 --- linux-2.6.33.2/fs/nfsd/nfs4xdr.c    2010-02-25 11:52:05.000000000 +0100
7749 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfsd/nfs4xdr.c    2010-02-25 12:02:16.000000000 +0100
7750 @@ -46,6 +46,7 @@
7751  #include <linux/nfsd_idmap.h>
7752  #include <linux/nfs4_acl.h>
7753  #include <linux/sunrpc/svcauth_gss.h>
7754 +#include <linux/vs_tag.h>
7755  
7756  #include "xdr4.h"
7757  #include "vfs.h"
7758 @@ -2042,14 +2043,18 @@ out_acl:
7759                 WRITE32(stat.nlink);
7760         }
7761         if (bmval1 & FATTR4_WORD1_OWNER) {
7762 -               status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7763 +               status = nfsd4_encode_user(rqstp,
7764 +                       TAGINO_UID(DX_TAG(dentry->d_inode),
7765 +                       stat.uid, stat.tag), &p, &buflen);
7766                 if (status == nfserr_resource)
7767                         goto out_resource;
7768                 if (status)
7769                         goto out;
7770         }
7771         if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7772 -               status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7773 +               status = nfsd4_encode_group(rqstp,
7774 +                       TAGINO_GID(DX_TAG(dentry->d_inode),
7775 +                       stat.gid, stat.tag), &p, &buflen);
7776                 if (status == nfserr_resource)
7777                         goto out_resource;
7778                 if (status)
7779 diff -NurpP --minimal linux-2.6.33.2/fs/nfsd/nfsxdr.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfsd/nfsxdr.c
7780 --- linux-2.6.33.2/fs/nfsd/nfsxdr.c     2010-02-25 11:52:05.000000000 +0100
7781 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/nfsd/nfsxdr.c     2010-02-25 13:18:10.000000000 +0100
7782 @@ -6,6 +6,7 @@
7783  
7784  #include "xdr.h"
7785  #include "auth.h"
7786 +#include <linux/vs_tag.h>
7787  
7788  #define NFSDDBG_FACILITY               NFSDDBG_XDR
7789  
7790 @@ -88,6 +89,8 @@ static __be32 *
7791  decode_sattr(__be32 *p, struct iattr *iap)
7792  {
7793         u32     tmp, tmp1;
7794 +       uid_t   uid = 0;
7795 +       gid_t   gid = 0;
7796  
7797         iap->ia_valid = 0;
7798  
7799 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7800         }
7801         if ((tmp = ntohl(*p++)) != (u32)-1) {
7802                 iap->ia_valid |= ATTR_UID;
7803 -               iap->ia_uid = tmp;
7804 +               uid = tmp;
7805         }
7806         if ((tmp = ntohl(*p++)) != (u32)-1) {
7807                 iap->ia_valid |= ATTR_GID;
7808 -               iap->ia_gid = tmp;
7809 +               gid = tmp;
7810         }
7811 +       iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7812 +       iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7813 +       iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7814         if ((tmp = ntohl(*p++)) != (u32)-1) {
7815                 iap->ia_valid |= ATTR_SIZE;
7816                 iap->ia_size = tmp;
7817 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7818         *p++ = htonl(nfs_ftypes[type >> 12]);
7819         *p++ = htonl((u32) stat->mode);
7820         *p++ = htonl((u32) stat->nlink);
7821 -       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7822 -       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7823 +       *p++ = htonl((u32) nfsd_ruid(rqstp,
7824 +               TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7825 +       *p++ = htonl((u32) nfsd_rgid(rqstp,
7826 +               TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7827  
7828         if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7829                 *p++ = htonl(NFS_MAXPATHLEN);
7830 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/dlm/dlmfs.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/dlm/dlmfs.c
7831 --- linux-2.6.33.2/fs/ocfs2/dlm/dlmfs.c 2009-12-03 20:02:53.000000000 +0100
7832 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/dlm/dlmfs.c 2010-02-25 12:02:16.000000000 +0100
7833 @@ -43,6 +43,7 @@
7834  #include <linux/init.h>
7835  #include <linux/string.h>
7836  #include <linux/backing-dev.h>
7837 +#include <linux/vs_tag.h>
7838  
7839  #include <asm/uaccess.h>
7840  
7841 @@ -342,6 +343,7 @@ static struct inode *dlmfs_get_root_inod
7842                 inode->i_mode = mode;
7843                 inode->i_uid = current_fsuid();
7844                 inode->i_gid = current_fsgid();
7845 +               inode->i_tag = dx_current_fstag(sb);
7846                 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
7847                 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
7848                 inc_nlink(inode);
7849 @@ -367,6 +369,7 @@ static struct inode *dlmfs_get_inode(str
7850         inode->i_mode = mode;
7851         inode->i_uid = current_fsuid();
7852         inode->i_gid = current_fsgid();
7853 +       inode->i_tag = dx_current_fstag(sb);
7854         inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
7855         inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
7856  
7857 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/dlmglue.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/dlmglue.c
7858 --- linux-2.6.33.2/fs/ocfs2/dlmglue.c   2010-02-25 11:52:06.000000000 +0100
7859 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/dlmglue.c   2010-02-25 12:02:16.000000000 +0100
7860 @@ -2023,6 +2023,7 @@ static void __ocfs2_stuff_meta_lvb(struc
7861         lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
7862         lvb->lvb_iuid      = cpu_to_be32(inode->i_uid);
7863         lvb->lvb_igid      = cpu_to_be32(inode->i_gid);
7864 +       lvb->lvb_itag      = cpu_to_be16(inode->i_tag);
7865         lvb->lvb_imode     = cpu_to_be16(inode->i_mode);
7866         lvb->lvb_inlink    = cpu_to_be16(inode->i_nlink);
7867         lvb->lvb_iatime_packed  =
7868 @@ -2077,6 +2078,7 @@ static void ocfs2_refresh_inode_from_lvb
7869  
7870         inode->i_uid     = be32_to_cpu(lvb->lvb_iuid);
7871         inode->i_gid     = be32_to_cpu(lvb->lvb_igid);
7872 +       inode->i_tag     = be16_to_cpu(lvb->lvb_itag);
7873         inode->i_mode    = be16_to_cpu(lvb->lvb_imode);
7874         inode->i_nlink   = be16_to_cpu(lvb->lvb_inlink);
7875         ocfs2_unpack_timespec(&inode->i_atime,
7876 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/dlmglue.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/dlmglue.h
7877 --- linux-2.6.33.2/fs/ocfs2/dlmglue.h   2009-12-03 20:02:53.000000000 +0100
7878 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/dlmglue.h   2010-02-25 12:02:16.000000000 +0100
7879 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
7880         __be16       lvb_inlink;
7881         __be32       lvb_iattr;
7882         __be32       lvb_igeneration;
7883 -       __be32       lvb_reserved2;
7884 +       __be16       lvb_itag;
7885 +       __be16       lvb_reserved2;
7886  };
7887  
7888  #define OCFS2_QINFO_LVB_VERSION 1
7889 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/file.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/file.c
7890 --- linux-2.6.33.2/fs/ocfs2/file.c      2010-02-25 11:52:06.000000000 +0100
7891 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/file.c      2010-02-25 12:02:16.000000000 +0100
7892 @@ -960,13 +960,15 @@ int ocfs2_setattr(struct dentry *dentry,
7893                 mlog(0, "uid change: %d\n", attr->ia_uid);
7894         if (attr->ia_valid & ATTR_GID)
7895                 mlog(0, "gid change: %d\n", attr->ia_gid);
7896 +       if (attr->ia_valid & ATTR_TAG)
7897 +               mlog(0, "tag change: %d\n", attr->ia_tag);
7898         if (attr->ia_valid & ATTR_SIZE)
7899                 mlog(0, "size change...\n");
7900         if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME))
7901                 mlog(0, "time change...\n");
7902  
7903  #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
7904 -                          | ATTR_GID | ATTR_UID | ATTR_MODE)
7905 +                          | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
7906         if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) {
7907                 mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid);
7908                 return 0;
7909 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/inode.c
7910 --- linux-2.6.33.2/fs/ocfs2/inode.c     2010-02-25 11:52:06.000000000 +0100
7911 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/inode.c     2010-02-25 12:02:16.000000000 +0100
7912 @@ -29,6 +29,7 @@
7913  #include <linux/highmem.h>
7914  #include <linux/pagemap.h>
7915  #include <linux/quotaops.h>
7916 +#include <linux/vs_tag.h>
7917  
7918  #include <asm/byteorder.h>
7919  
7920 @@ -79,11 +80,13 @@ void ocfs2_set_inode_flags(struct inode 
7921  {
7922         unsigned int flags = OCFS2_I(inode)->ip_attr;
7923  
7924 -       inode->i_flags &= ~(S_IMMUTABLE |
7925 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
7926                 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
7927  
7928         if (flags & OCFS2_IMMUTABLE_FL)
7929                 inode->i_flags |= S_IMMUTABLE;
7930 +       if (flags & OCFS2_IXUNLINK_FL)
7931 +               inode->i_flags |= S_IXUNLINK;
7932  
7933         if (flags & OCFS2_SYNC_FL)
7934                 inode->i_flags |= S_SYNC;
7935 @@ -93,25 +96,44 @@ void ocfs2_set_inode_flags(struct inode 
7936                 inode->i_flags |= S_NOATIME;
7937         if (flags & OCFS2_DIRSYNC_FL)
7938                 inode->i_flags |= S_DIRSYNC;
7939 +
7940 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
7941 +
7942 +       if (flags & OCFS2_BARRIER_FL)
7943 +               inode->i_vflags |= V_BARRIER;
7944 +       if (flags & OCFS2_COW_FL)
7945 +               inode->i_vflags |= V_COW;
7946  }
7947  
7948  /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
7949  void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
7950  {
7951         unsigned int flags = oi->vfs_inode.i_flags;
7952 +       unsigned int vflags = oi->vfs_inode.i_vflags;
7953 +
7954 +       oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
7955 +                       OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
7956 +                       OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
7957 +                       OCFS2_BARRIER_FL | OCFS2_COW_FL);
7958 +
7959 +       if (flags & S_IMMUTABLE)
7960 +               oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7961 +       if (flags & S_IXUNLINK)
7962 +               oi->ip_attr |= OCFS2_IXUNLINK_FL;
7963  
7964 -       oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
7965 -                       OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
7966         if (flags & S_SYNC)
7967                 oi->ip_attr |= OCFS2_SYNC_FL;
7968         if (flags & S_APPEND)
7969                 oi->ip_attr |= OCFS2_APPEND_FL;
7970 -       if (flags & S_IMMUTABLE)
7971 -               oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7972         if (flags & S_NOATIME)
7973                 oi->ip_attr |= OCFS2_NOATIME_FL;
7974         if (flags & S_DIRSYNC)
7975                 oi->ip_attr |= OCFS2_DIRSYNC_FL;
7976 +
7977 +       if (vflags & V_BARRIER)
7978 +               oi->ip_attr |= OCFS2_BARRIER_FL;
7979 +       if (vflags & V_COW)
7980 +               oi->ip_attr |= OCFS2_COW_FL;
7981  }
7982  
7983  struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
7984 @@ -246,6 +268,8 @@ void ocfs2_populate_inode(struct inode *
7985         struct super_block *sb;
7986         struct ocfs2_super *osb;
7987         int use_plocks = 1;
7988 +       uid_t uid;
7989 +       gid_t gid;
7990  
7991         mlog_entry("(0x%p, size:%llu)\n", inode,
7992                    (unsigned long long)le64_to_cpu(fe->i_size));
7993 @@ -277,8 +301,12 @@ void ocfs2_populate_inode(struct inode *
7994         inode->i_generation = le32_to_cpu(fe->i_generation);
7995         inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
7996         inode->i_mode = le16_to_cpu(fe->i_mode);
7997 -       inode->i_uid = le32_to_cpu(fe->i_uid);
7998 -       inode->i_gid = le32_to_cpu(fe->i_gid);
7999 +       uid = le32_to_cpu(fe->i_uid);
8000 +       gid = le32_to_cpu(fe->i_gid);
8001 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8002 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8003 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
8004 +               /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
8005  
8006         /* Fast symlinks will have i_size but no allocated clusters. */
8007         if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
8008 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/inode.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/inode.h
8009 --- linux-2.6.33.2/fs/ocfs2/inode.h     2009-12-03 20:02:53.000000000 +0100
8010 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/inode.h     2010-02-25 12:02:16.000000000 +0100
8011 @@ -150,6 +150,7 @@ struct buffer_head *ocfs2_bread(struct i
8012  
8013  void ocfs2_set_inode_flags(struct inode *inode);
8014  void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
8015 +int ocfs2_sync_flags(struct inode *inode, int, int);
8016  
8017  static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
8018  {
8019 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/ioctl.c
8020 --- linux-2.6.33.2/fs/ocfs2/ioctl.c     2010-02-25 11:52:06.000000000 +0100
8021 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/ioctl.c     2010-02-25 12:02:16.000000000 +0100
8022 @@ -43,7 +43,41 @@ static int ocfs2_get_inode_attr(struct i
8023         return status;
8024  }
8025  
8026 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8027 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
8028 +{
8029 +       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
8030 +       struct buffer_head *bh = NULL;
8031 +       handle_t *handle = NULL;
8032 +       int status;
8033 +
8034 +       status = ocfs2_inode_lock(inode, &bh, 1);
8035 +       if (status < 0) {
8036 +               mlog_errno(status);
8037 +               return status;
8038 +       }
8039 +       handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
8040 +       if (IS_ERR(handle)) {
8041 +               status = PTR_ERR(handle);
8042 +               mlog_errno(status);
8043 +               goto bail_unlock;
8044 +       }
8045 +
8046 +       inode->i_flags = flags;
8047 +       inode->i_vflags = vflags;
8048 +       ocfs2_get_inode_flags(OCFS2_I(inode));
8049 +
8050 +       status = ocfs2_mark_inode_dirty(handle, inode, bh);
8051 +       if (status < 0)
8052 +               mlog_errno(status);
8053 +
8054 +       ocfs2_commit_trans(osb, handle);
8055 +bail_unlock:
8056 +       ocfs2_inode_unlock(inode, 1);
8057 +       brelse(bh);
8058 +       return status;
8059 +}
8060 +
8061 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8062                                 unsigned mask)
8063  {
8064         struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
8065 @@ -68,6 +102,11 @@ static int ocfs2_set_inode_attr(struct i
8066         if (!S_ISDIR(inode->i_mode))
8067                 flags &= ~OCFS2_DIRSYNC_FL;
8068  
8069 +       if (IS_BARRIER(inode)) {
8070 +               vxwprintk_task(1, "messing with the barrier.");
8071 +               goto bail_unlock;
8072 +       }
8073 +
8074         handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
8075         if (IS_ERR(handle)) {
8076                 status = PTR_ERR(handle);
8077 @@ -109,6 +148,7 @@ bail:
8078         return status;
8079  }
8080  
8081 +
8082  long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
8083  {
8084         struct inode *inode = filp->f_path.dentry->d_inode;
8085 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/namei.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/namei.c
8086 --- linux-2.6.33.2/fs/ocfs2/namei.c     2010-02-25 11:52:06.000000000 +0100
8087 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/namei.c     2010-02-25 12:02:16.000000000 +0100
8088 @@ -41,6 +41,7 @@
8089  #include <linux/slab.h>
8090  #include <linux/highmem.h>
8091  #include <linux/quotaops.h>
8092 +#include <linux/vs_tag.h>
8093  
8094  #define MLOG_MASK_PREFIX ML_NAMEI
8095  #include <cluster/masklog.h>
8096 @@ -481,6 +482,7 @@ static int ocfs2_mknod_locked(struct ocf
8097         u64 fe_blkno = 0;
8098         u16 suballoc_bit;
8099         u16 feat;
8100 +       tag_t tag;
8101  
8102         *new_fe_bh = NULL;
8103  
8104 @@ -524,8 +526,11 @@ static int ocfs2_mknod_locked(struct ocf
8105         fe->i_blkno = cpu_to_le64(fe_blkno);
8106         fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
8107         fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
8108 -       fe->i_uid = cpu_to_le32(inode->i_uid);
8109 -       fe->i_gid = cpu_to_le32(inode->i_gid);
8110 +
8111 +       tag = dx_current_fstag(osb->sb);
8112 +       fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
8113 +       fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
8114 +       inode->i_tag = tag;
8115         fe->i_mode = cpu_to_le16(inode->i_mode);
8116         if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
8117                 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
8118 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/ocfs2_fs.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/ocfs2_fs.h
8119 --- linux-2.6.33.2/fs/ocfs2/ocfs2_fs.h  2010-02-25 11:52:06.000000000 +0100
8120 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/ocfs2_fs.h  2010-02-25 12:02:16.000000000 +0100
8121 @@ -231,18 +231,23 @@
8122  #define OCFS2_HAS_REFCOUNT_FL   (0x0010)
8123  
8124  /* Inode attributes, keep in sync with EXT2 */
8125 -#define OCFS2_SECRM_FL         (0x00000001)    /* Secure deletion */
8126 -#define OCFS2_UNRM_FL          (0x00000002)    /* Undelete */
8127 -#define OCFS2_COMPR_FL         (0x00000004)    /* Compress file */
8128 -#define OCFS2_SYNC_FL          (0x00000008)    /* Synchronous updates */
8129 -#define OCFS2_IMMUTABLE_FL     (0x00000010)    /* Immutable file */
8130 -#define OCFS2_APPEND_FL                (0x00000020)    /* writes to file may only append */
8131 -#define OCFS2_NODUMP_FL                (0x00000040)    /* do not dump file */
8132 -#define OCFS2_NOATIME_FL       (0x00000080)    /* do not update atime */
8133 -#define OCFS2_DIRSYNC_FL       (0x00010000)    /* dirsync behaviour (directories only) */
8134 +#define OCFS2_SECRM_FL         FS_SECRM_FL     /* Secure deletion */
8135 +#define OCFS2_UNRM_FL          FS_UNRM_FL      /* Undelete */
8136 +#define OCFS2_COMPR_FL         FS_COMPR_FL     /* Compress file */
8137 +#define OCFS2_SYNC_FL          FS_SYNC_FL      /* Synchronous updates */
8138 +#define OCFS2_IMMUTABLE_FL     FS_IMMUTABLE_FL /* Immutable file */
8139 +#define OCFS2_APPEND_FL                FS_APPEND_FL    /* writes to file may only append */
8140 +#define OCFS2_NODUMP_FL                FS_NODUMP_FL    /* do not dump file */
8141 +#define OCFS2_NOATIME_FL       FS_NOATIME_FL   /* do not update atime */
8142  
8143 -#define OCFS2_FL_VISIBLE       (0x000100FF)    /* User visible flags */
8144 -#define OCFS2_FL_MODIFIABLE    (0x000100FF)    /* User modifiable flags */
8145 +#define OCFS2_DIRSYNC_FL       FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
8146 +#define OCFS2_IXUNLINK_FL      FS_IXUNLINK_FL  /* Immutable invert on unlink */
8147 +
8148 +#define OCFS2_BARRIER_FL       FS_BARRIER_FL   /* Barrier for chroot() */
8149 +#define OCFS2_COW_FL           FS_COW_FL       /* Copy on Write marker */
8150 +
8151 +#define OCFS2_FL_VISIBLE       (0x010300FF)    /* User visible flags */
8152 +#define OCFS2_FL_MODIFIABLE    (0x010300FF)    /* User modifiable flags */
8153  
8154  /*
8155   * Extent record flags (e_node.leaf.flags)
8156 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/ocfs2.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/ocfs2.h
8157 --- linux-2.6.33.2/fs/ocfs2/ocfs2.h     2010-02-25 11:52:06.000000000 +0100
8158 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/ocfs2.h     2010-02-25 13:22:33.000000000 +0100
8159 @@ -254,6 +254,7 @@ enum ocfs2_mount_options
8160                                                    control lists */
8161         OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
8162         OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
8163 +       OCFS2_MOUNT_TAGGED = 1 << 12, /* use tagging */
8164  };
8165  
8166  #define OCFS2_OSB_SOFT_RO                      0x0001
8167 diff -NurpP --minimal linux-2.6.33.2/fs/ocfs2/super.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/super.c
8168 --- linux-2.6.33.2/fs/ocfs2/super.c     2010-02-25 11:52:06.000000000 +0100
8169 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/ocfs2/super.c     2010-02-25 13:23:24.000000000 +0100
8170 @@ -175,6 +175,7 @@ enum {
8171         Opt_noacl,
8172         Opt_usrquota,
8173         Opt_grpquota,
8174 +       Opt_tag, Opt_notag, Opt_tagid,
8175         Opt_err,
8176  };
8177  
8178 @@ -201,6 +202,9 @@ static const match_table_t tokens = {
8179         {Opt_noacl, "noacl"},
8180         {Opt_usrquota, "usrquota"},
8181         {Opt_grpquota, "grpquota"},
8182 +       {Opt_tag, "tag"},
8183 +       {Opt_notag, "notag"},
8184 +       {Opt_tagid, "tagid=%u"},
8185         {Opt_err, NULL}
8186  };
8187  
8188 @@ -608,6 +612,13 @@ static int ocfs2_remount(struct super_bl
8189                 goto out;
8190         }
8191  
8192 +       if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
8193 +           (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
8194 +               ret = -EINVAL;
8195 +               mlog(ML_ERROR, "Cannot change tagging on remount\n");
8196 +               goto out;
8197 +       }
8198 +
8199         if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) !=
8200             (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL)) {
8201                 ret = -EINVAL;
8202 @@ -1138,6 +1149,9 @@ static int ocfs2_fill_super(struct super
8203  
8204         ocfs2_complete_mount_recovery(osb);
8205  
8206 +       if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
8207 +               sb->s_flags |= MS_TAGGED;
8208 +
8209         if (ocfs2_mount_local(osb))
8210                 snprintf(nodestr, sizeof(nodestr), "local");
8211         else
8212 @@ -1429,6 +1443,20 @@ static int ocfs2_parse_options(struct su
8213                         mopt->mount_opt |= OCFS2_MOUNT_NO_POSIX_ACL;
8214                         mopt->mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
8215                         break;
8216 +#ifndef CONFIG_TAGGING_NONE
8217 +               case Opt_tag:
8218 +                       mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8219 +                       break;
8220 +               case Opt_notag:
8221 +                       mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
8222 +                       break;
8223 +#endif
8224 +#ifdef CONFIG_PROPAGATE
8225 +               case Opt_tagid:
8226 +                       /* use args[0] */
8227 +                       mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8228 +                       break;
8229 +#endif
8230                 default:
8231                         mlog(ML_ERROR,
8232                              "Unrecognized mount option \"%s\" "
8233 diff -NurpP --minimal linux-2.6.33.2/fs/open.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/open.c
8234 --- linux-2.6.33.2/fs/open.c    2010-02-25 11:52:06.000000000 +0100
8235 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/open.c    2010-02-25 13:17:13.000000000 +0100
8236 @@ -31,6 +31,10 @@
8237  #include <linux/falloc.h>
8238  #include <linux/fs_struct.h>
8239  #include <linux/ima.h>
8240 +#include <linux/vs_base.h>
8241 +#include <linux/vs_limit.h>
8242 +#include <linux/vs_tag.h>
8243 +#include <linux/vs_cowbl.h>
8244  
8245  #include "internal.h"
8246  
8247 @@ -39,16 +43,20 @@ int vfs_statfs(struct dentry *dentry, st
8248         int retval = -ENODEV;
8249  
8250         if (dentry) {
8251 +               struct super_block *sb = dentry->d_sb;
8252 +
8253                 retval = -ENOSYS;
8254 -               if (dentry->d_sb->s_op->statfs) {
8255 +               if (sb->s_op->statfs) {
8256                         memset(buf, 0, sizeof(*buf));
8257                         retval = security_sb_statfs(dentry);
8258                         if (retval)
8259                                 return retval;
8260 -                       retval = dentry->d_sb->s_op->statfs(dentry, buf);
8261 +                       retval = sb->s_op->statfs(dentry, buf);
8262                         if (retval == 0 && buf->f_frsize == 0)
8263                                 buf->f_frsize = buf->f_bsize;
8264                 }
8265 +               if (!vx_check(0, VS_ADMIN|VS_WATCH))
8266 +                       vx_vsi_statfs(sb, buf);
8267         }
8268         return retval;
8269  }
8270 @@ -650,6 +658,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
8271         error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
8272         if (error)
8273                 goto out;
8274 +
8275 +       error = cow_check_and_break(&path);
8276 +       if (error)
8277 +               goto dput_and_out;
8278         inode = path.dentry->d_inode;
8279  
8280         error = mnt_want_write(path.mnt);
8281 @@ -687,11 +699,11 @@ static int chown_common(struct path *pat
8282         newattrs.ia_valid =  ATTR_CTIME;
8283         if (user != (uid_t) -1) {
8284                 newattrs.ia_valid |= ATTR_UID;
8285 -               newattrs.ia_uid = user;
8286 +               newattrs.ia_uid = dx_map_uid(user);
8287         }
8288         if (group != (gid_t) -1) {
8289                 newattrs.ia_valid |= ATTR_GID;
8290 -               newattrs.ia_gid = group;
8291 +               newattrs.ia_gid = dx_map_gid(group);
8292         }
8293         if (!S_ISDIR(inode->i_mode))
8294                 newattrs.ia_valid |=
8295 @@ -716,6 +728,10 @@ SYSCALL_DEFINE3(chown, const char __user
8296         error = mnt_want_write(path.mnt);
8297         if (error)
8298                 goto out_release;
8299 +#ifdef CONFIG_VSERVER_COWBL
8300 +       error = cow_check_and_break(&path);
8301 +       if (!error)
8302 +#endif
8303         error = chown_common(&path, user, group);
8304         mnt_drop_write(path.mnt);
8305  out_release:
8306 @@ -741,6 +757,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
8307         error = mnt_want_write(path.mnt);
8308         if (error)
8309                 goto out_release;
8310 +#ifdef CONFIG_VSERVER_COWBL
8311 +       error = cow_check_and_break(&path);
8312 +       if (!error)
8313 +#endif
8314         error = chown_common(&path, user, group);
8315         mnt_drop_write(path.mnt);
8316  out_release:
8317 @@ -760,6 +780,10 @@ SYSCALL_DEFINE3(lchown, const char __use
8318         error = mnt_want_write(path.mnt);
8319         if (error)
8320                 goto out_release;
8321 +#ifdef CONFIG_VSERVER_COWBL
8322 +       error = cow_check_and_break(&path);
8323 +       if (!error)
8324 +#endif
8325         error = chown_common(&path, user, group);
8326         mnt_drop_write(path.mnt);
8327  out_release:
8328 @@ -1006,6 +1030,7 @@ static void __put_unused_fd(struct files
8329         __FD_CLR(fd, fdt->open_fds);
8330         if (fd < files->next_fd)
8331                 files->next_fd = fd;
8332 +       vx_openfd_dec(fd);
8333  }
8334  
8335  void put_unused_fd(unsigned int fd)
8336 diff -NurpP --minimal linux-2.6.33.2/fs/proc/array.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/array.c
8337 --- linux-2.6.33.2/fs/proc/array.c      2010-02-25 11:52:06.000000000 +0100
8338 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/array.c      2010-02-25 12:02:16.000000000 +0100
8339 @@ -83,6 +83,8 @@
8340  #include <linux/ptrace.h>
8341  #include <linux/tracehook.h>
8342  #include <linux/swapops.h>
8343 +#include <linux/vs_context.h>
8344 +#include <linux/vs_network.h>
8345  
8346  #include <asm/pgtable.h>
8347  #include <asm/processor.h>
8348 @@ -172,6 +174,9 @@ static inline void task_state(struct seq
8349         rcu_read_lock();
8350         ppid = pid_alive(p) ?
8351                 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
8352 +       if (unlikely(vx_current_initpid(p->pid)))
8353 +               ppid = 0;
8354 +
8355         tpid = 0;
8356         if (pid_alive(p)) {
8357                 struct task_struct *tracer = tracehook_tracer_task(p);
8358 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
8359  }
8360  
8361  static void render_cap_t(struct seq_file *m, const char *header,
8362 -                       kernel_cap_t *a)
8363 +                       struct vx_info *vxi, kernel_cap_t *a)
8364  {
8365         unsigned __capi;
8366  
8367 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
8368         cap_bset        = cred->cap_bset;
8369         rcu_read_unlock();
8370  
8371 -       render_cap_t(m, "CapInh:\t", &cap_inheritable);
8372 -       render_cap_t(m, "CapPrm:\t", &cap_permitted);
8373 -       render_cap_t(m, "CapEff:\t", &cap_effective);
8374 -       render_cap_t(m, "CapBnd:\t", &cap_bset);
8375 +       /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
8376 +       render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
8377 +       render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
8378 +       render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
8379 +       render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
8380  }
8381  
8382  static inline void task_context_switch_counts(struct seq_file *m,
8383 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
8384         seq_printf(m, "\n");
8385  }
8386  
8387 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8388 +                       struct pid *pid, struct task_struct *task)
8389 +{
8390 +       seq_printf(m,   "Proxy:\t%p(%c)\n"
8391 +                       "Count:\t%u\n"
8392 +                       "uts:\t%p(%c)\n"
8393 +                       "ipc:\t%p(%c)\n"
8394 +                       "mnt:\t%p(%c)\n"
8395 +                       "pid:\t%p(%c)\n"
8396 +                       "net:\t%p(%c)\n",
8397 +                       task->nsproxy,
8398 +                       (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
8399 +                       atomic_read(&task->nsproxy->count),
8400 +                       task->nsproxy->uts_ns,
8401 +                       (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
8402 +                       task->nsproxy->ipc_ns,
8403 +                       (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
8404 +                       task->nsproxy->mnt_ns,
8405 +                       (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
8406 +                       task->nsproxy->pid_ns,
8407 +                       (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
8408 +                       task->nsproxy->net_ns,
8409 +                       (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
8410 +       return 0;
8411 +}
8412 +
8413 +void task_vs_id(struct seq_file *m, struct task_struct *task)
8414 +{
8415 +       if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8416 +               return;
8417 +
8418 +       seq_printf(m, "VxID: %d\n", vx_task_xid(task));
8419 +       seq_printf(m, "NxID: %d\n", nx_task_nid(task));
8420 +}
8421 +
8422 +
8423  int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
8424                         struct pid *pid, struct task_struct *task)
8425  {
8426 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m, 
8427         task_cap(m, task);
8428         task_cpus_allowed(m, task);
8429         cpuset_task_status_allowed(m, task);
8430 +       task_vs_id(m, task);
8431  #if defined(CONFIG_S390)
8432         task_show_regs(m, task);
8433  #endif
8434 @@ -465,6 +508,17 @@ static int do_task_stat(struct seq_file 
8435         /* convert nsec -> ticks */
8436         start_time = nsec_to_clock_t(start_time);
8437  
8438 +       /* fixup start time for virt uptime */
8439 +       if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8440 +               unsigned long long bias =
8441 +                       current->vx_info->cvirt.bias_clock;
8442 +
8443 +               if (start_time > bias)
8444 +                       start_time -= bias;
8445 +               else
8446 +                       start_time = 0;
8447 +       }
8448 +
8449         seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
8450  %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8451  %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
8452 diff -NurpP --minimal linux-2.6.33.2/fs/proc/base.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/base.c
8453 --- linux-2.6.33.2/fs/proc/base.c       2010-02-25 11:52:06.000000000 +0100
8454 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/base.c       2010-02-25 12:02:16.000000000 +0100
8455 @@ -81,6 +81,8 @@
8456  #include <linux/elf.h>
8457  #include <linux/pid_namespace.h>
8458  #include <linux/fs_struct.h>
8459 +#include <linux/vs_context.h>
8460 +#include <linux/vs_network.h>
8461  #include "internal.h"
8462  
8463  /* NOTE:
8464 @@ -1047,12 +1049,17 @@ static ssize_t oom_adjust_write(struct f
8465                 return -ESRCH;
8466         }
8467  
8468 -       if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
8469 +       if (oom_adjust < task->signal->oom_adj &&
8470 +               !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
8471                 unlock_task_sighand(task, &flags);
8472                 put_task_struct(task);
8473                 return -EACCES;
8474         }
8475  
8476 +       /* prevent guest processes from circumventing the oom killer */
8477 +       if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
8478 +               oom_adjust = OOM_ADJUST_MIN;
8479 +
8480         task->signal->oom_adj = oom_adjust;
8481  
8482         unlock_task_sighand(task, &flags);
8483 @@ -1092,7 +1099,7 @@ static ssize_t proc_loginuid_write(struc
8484         ssize_t length;
8485         uid_t loginuid;
8486  
8487 -       if (!capable(CAP_AUDIT_CONTROL))
8488 +       if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
8489                 return -EPERM;
8490  
8491         if (current != pid_task(proc_pid(inode), PIDTYPE_PID))
8492 @@ -1523,6 +1530,8 @@ static struct inode *proc_pid_make_inode
8493                 inode->i_gid = cred->egid;
8494                 rcu_read_unlock();
8495         }
8496 +       /* procfs is xid tagged */
8497 +       inode->i_tag = (tag_t)vx_task_xid(task);
8498         security_task_to_inode(task, inode);
8499  
8500  out:
8501 @@ -2073,6 +2082,13 @@ static struct dentry *proc_pident_lookup
8502         if (!task)
8503                 goto out_no_task;
8504  
8505 +       /* TODO: maybe we can come up with a generic approach? */
8506 +       if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8507 +               (dentry->d_name.len == 5) &&
8508 +               (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8509 +               !memcmp(dentry->d_name.name, "ninfo", 5)))
8510 +               goto out;
8511 +
8512         /*
8513          * Yes, it does not scale. And it should not. Don't add
8514          * new entries into /proc/<tgid>/ without very good reasons.
8515 @@ -2478,7 +2494,7 @@ out_iput:
8516  static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8517  {
8518         struct dentry *error;
8519 -       struct task_struct *task = get_proc_task(dir);
8520 +       struct task_struct *task = get_proc_task_real(dir);
8521         const struct pid_entry *p, *last;
8522  
8523         error = ERR_PTR(-ENOENT);
8524 @@ -2568,6 +2584,9 @@ static int proc_pid_personality(struct s
8525  static const struct file_operations proc_task_operations;
8526  static const struct inode_operations proc_task_inode_operations;
8527  
8528 +extern int proc_pid_vx_info(struct task_struct *, char *);
8529 +extern int proc_pid_nx_info(struct task_struct *, char *);
8530 +
8531  static const struct pid_entry tgid_base_stuff[] = {
8532         DIR("task",       S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
8533         DIR("fd",         S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
8534 @@ -2627,6 +2646,8 @@ static const struct pid_entry tgid_base_
8535  #ifdef CONFIG_CGROUPS
8536         REG("cgroup",  S_IRUGO, proc_cgroup_operations),
8537  #endif
8538 +       INF("vinfo",      S_IRUGO, proc_pid_vx_info),
8539 +       INF("ninfo",      S_IRUGO, proc_pid_nx_info),
8540         INF("oom_score",  S_IRUGO, proc_oom_score),
8541         REG("oom_adj",    S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
8542  #ifdef CONFIG_AUDITSYSCALL
8543 @@ -2642,6 +2663,7 @@ static const struct pid_entry tgid_base_
8544  #ifdef CONFIG_TASK_IO_ACCOUNTING
8545         INF("io",       S_IRUGO, proc_tgid_io_accounting),
8546  #endif
8547 +       ONE("nsproxy",  S_IRUGO, proc_pid_nsproxy),
8548  };
8549  
8550  static int proc_tgid_base_readdir(struct file * filp,
8551 @@ -2833,7 +2855,7 @@ retry:
8552         iter.task = NULL;
8553         pid = find_ge_pid(iter.tgid, ns);
8554         if (pid) {
8555 -               iter.tgid = pid_nr_ns(pid, ns);
8556 +               iter.tgid = pid_unmapped_nr_ns(pid, ns);
8557                 iter.task = pid_task(pid, PIDTYPE_PID);
8558                 /* What we to know is if the pid we have find is the
8559                  * pid of a thread_group_leader.  Testing for task
8560 @@ -2863,7 +2885,7 @@ static int proc_pid_fill_cache(struct fi
8561         struct tgid_iter iter)
8562  {
8563         char name[PROC_NUMBUF];
8564 -       int len = snprintf(name, sizeof(name), "%d", iter.tgid);
8565 +       int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
8566         return proc_fill_cache(filp, dirent, filldir, name, len,
8567                                 proc_pid_instantiate, iter.task, NULL);
8568  }
8569 @@ -2872,7 +2894,7 @@ static int proc_pid_fill_cache(struct fi
8570  int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir)
8571  {
8572         unsigned int nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8573 -       struct task_struct *reaper = get_proc_task(filp->f_path.dentry->d_inode);
8574 +       struct task_struct *reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8575         struct tgid_iter iter;
8576         struct pid_namespace *ns;
8577  
8578 @@ -2892,6 +2914,8 @@ int proc_pid_readdir(struct file * filp,
8579              iter.task;
8580              iter.tgid += 1, iter = next_tgid(ns, iter)) {
8581                 filp->f_pos = iter.tgid + TGID_OFFSET;
8582 +               if (!vx_proc_task_visible(iter.task))
8583 +                       continue;
8584                 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
8585                         put_task_struct(iter.task);
8586                         goto out;
8587 @@ -3039,6 +3063,8 @@ static struct dentry *proc_task_lookup(s
8588         tid = name_to_int(dentry);
8589         if (tid == ~0U)
8590                 goto out;
8591 +       if (vx_current_initpid(tid))
8592 +               goto out;
8593  
8594         ns = dentry->d_sb->s_fs_info;
8595         rcu_read_lock();
8596 diff -NurpP --minimal linux-2.6.33.2/fs/proc/generic.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/generic.c
8597 --- linux-2.6.33.2/fs/proc/generic.c    2010-02-25 11:52:06.000000000 +0100
8598 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/generic.c    2010-02-25 13:20:40.000000000 +0100
8599 @@ -20,6 +20,7 @@
8600  #include <linux/bitops.h>
8601  #include <linux/spinlock.h>
8602  #include <linux/completion.h>
8603 +#include <linux/vserver/inode.h>
8604  #include <asm/uaccess.h>
8605  
8606  #include "internal.h"
8607 @@ -425,6 +426,8 @@ struct dentry *proc_lookup_de(struct pro
8608         for (de = de->subdir; de ; de = de->next) {
8609                 if (de->namelen != dentry->d_name.len)
8610                         continue;
8611 +                       if (!vx_hide_check(0, de->vx_flags))
8612 +                               continue;
8613                 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8614                         unsigned int ino;
8615  
8616 @@ -433,6 +436,8 @@ struct dentry *proc_lookup_de(struct pro
8617                         spin_unlock(&proc_subdir_lock);
8618                         error = -EINVAL;
8619                         inode = proc_get_inode(dir->i_sb, ino, de);
8620 +                               /* generic proc entries belong to the host */
8621 +                               inode->i_tag = 0;
8622                         goto out_unlock;
8623                 }
8624         }
8625 @@ -510,6 +515,8 @@ int proc_readdir_de(struct proc_dir_entr
8626  
8627                                 /* filldir passes info to user space */
8628                                 pde_get(de);
8629 +                               if (!vx_hide_check(0, de->vx_flags))
8630 +                                       goto skip;
8631                                 spin_unlock(&proc_subdir_lock);
8632                                 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8633                                             de->low_ino, de->mode >> 12) < 0) {
8634 @@ -517,6 +524,7 @@ int proc_readdir_de(struct proc_dir_entr
8635                                         goto out;
8636                                 }
8637                                 spin_lock(&proc_subdir_lock);
8638 +                       skip:
8639                                 filp->f_pos++;
8640                                 next = de->next;
8641                                 pde_put(de);
8642 @@ -631,6 +639,7 @@ static struct proc_dir_entry *__proc_cre
8643         ent->nlink = nlink;
8644         atomic_set(&ent->count, 1);
8645         ent->pde_users = 0;
8646 +       ent->vx_flags = IATTR_PROC_DEFAULT;
8647         spin_lock_init(&ent->pde_unload_lock);
8648         ent->pde_unload_completion = NULL;
8649         INIT_LIST_HEAD(&ent->pde_openers);
8650 @@ -654,7 +663,8 @@ struct proc_dir_entry *proc_symlink(cons
8651                                 kfree(ent->data);
8652                                 kfree(ent);
8653                                 ent = NULL;
8654 -                       }
8655 +                       } else
8656 +                               ent->vx_flags = IATTR_PROC_SYMLINK;
8657                 } else {
8658                         kfree(ent);
8659                         ent = NULL;
8660 diff -NurpP --minimal linux-2.6.33.2/fs/proc/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/inode.c
8661 --- linux-2.6.33.2/fs/proc/inode.c      2010-02-25 11:52:06.000000000 +0100
8662 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/inode.c      2010-02-25 12:02:16.000000000 +0100
8663 @@ -436,6 +436,8 @@ struct inode *proc_get_inode(struct supe
8664                         inode->i_uid = de->uid;
8665                         inode->i_gid = de->gid;
8666                 }
8667 +               if (de->vx_flags)
8668 +                       PROC_I(inode)->vx_flags = de->vx_flags;
8669                 if (de->size)
8670                         inode->i_size = de->size;
8671                 if (de->nlink)
8672 diff -NurpP --minimal linux-2.6.33.2/fs/proc/internal.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/internal.h
8673 --- linux-2.6.33.2/fs/proc/internal.h   2010-02-25 11:52:06.000000000 +0100
8674 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/internal.h   2010-02-25 12:02:16.000000000 +0100
8675 @@ -10,6 +10,7 @@
8676   */
8677  
8678  #include <linux/proc_fs.h>
8679 +#include <linux/vs_pid.h>
8680  
8681  extern struct proc_dir_entry proc_root;
8682  #ifdef CONFIG_PROC_SYSCTL
8683 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
8684                                 struct pid *pid, struct task_struct *task);
8685  extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
8686                                 struct pid *pid, struct task_struct *task);
8687 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8688 +                               struct pid *pid, struct task_struct *task);
8689 +
8690  extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
8691  
8692  extern const struct file_operations proc_maps_operations;
8693 @@ -68,11 +72,16 @@ static inline struct pid *proc_pid(struc
8694         return PROC_I(inode)->pid;
8695  }
8696  
8697 -static inline struct task_struct *get_proc_task(struct inode *inode)
8698 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
8699  {
8700         return get_pid_task(proc_pid(inode), PIDTYPE_PID);
8701  }
8702  
8703 +static inline struct task_struct *get_proc_task(struct inode *inode)
8704 +{
8705 +       return vx_get_proc_task(inode, proc_pid(inode));
8706 +}
8707 +
8708  static inline int proc_fd(struct inode *inode)
8709  {
8710         return PROC_I(inode)->fd;
8711 diff -NurpP --minimal linux-2.6.33.2/fs/proc/loadavg.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/loadavg.c
8712 --- linux-2.6.33.2/fs/proc/loadavg.c    2009-09-10 15:26:23.000000000 +0200
8713 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/loadavg.c    2010-02-25 12:02:16.000000000 +0100
8714 @@ -12,15 +12,27 @@
8715  
8716  static int loadavg_proc_show(struct seq_file *m, void *v)
8717  {
8718 +       unsigned long running;
8719 +       unsigned int threads;
8720         unsigned long avnrun[3];
8721  
8722         get_avenrun(avnrun, FIXED_1/200, 0);
8723  
8724 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
8725 +               struct vx_info *vxi = current_vx_info();
8726 +
8727 +               running = atomic_read(&vxi->cvirt.nr_running);
8728 +               threads = atomic_read(&vxi->cvirt.nr_threads);
8729 +       } else {
8730 +               running = nr_running();
8731 +               threads = nr_threads;
8732 +       }
8733 +
8734         seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
8735                 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
8736                 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
8737                 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
8738 -               nr_running(), nr_threads,
8739 +               running, threads,
8740                 task_active_pid_ns(current)->last_pid);
8741         return 0;
8742  }
8743 diff -NurpP --minimal linux-2.6.33.2/fs/proc/meminfo.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/meminfo.c
8744 --- linux-2.6.33.2/fs/proc/meminfo.c    2009-12-03 20:02:53.000000000 +0100
8745 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/meminfo.c    2010-02-25 12:02:16.000000000 +0100
8746 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
8747         allowed = ((totalram_pages - hugetlb_total_pages())
8748                 * sysctl_overcommit_ratio / 100) + total_swap_pages;
8749  
8750 -       cached = global_page_state(NR_FILE_PAGES) -
8751 +       cached = vx_flags(VXF_VIRT_MEM, 0) ?
8752 +               vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
8753                         total_swapcache_pages - i.bufferram;
8754         if (cached < 0)
8755                 cached = 0;
8756 diff -NurpP --minimal linux-2.6.33.2/fs/proc/root.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/root.c
8757 --- linux-2.6.33.2/fs/proc/root.c       2009-06-11 17:13:07.000000000 +0200
8758 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/root.c       2010-02-25 12:02:16.000000000 +0100
8759 @@ -18,9 +18,14 @@
8760  #include <linux/bitops.h>
8761  #include <linux/mount.h>
8762  #include <linux/pid_namespace.h>
8763 +#include <linux/vserver/inode.h>
8764  
8765  #include "internal.h"
8766  
8767 +struct proc_dir_entry *proc_virtual;
8768 +
8769 +extern void proc_vx_init(void);
8770 +
8771  static int proc_test_super(struct super_block *sb, void *data)
8772  {
8773         return sb->s_fs_info == data;
8774 @@ -136,6 +141,7 @@ void __init proc_root_init(void)
8775  #endif
8776         proc_mkdir("bus", NULL);
8777         proc_sys_init();
8778 +       proc_vx_init();
8779  }
8780  
8781  static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
8782 @@ -203,6 +209,7 @@ struct proc_dir_entry proc_root = {
8783         .proc_iops      = &proc_root_inode_operations, 
8784         .proc_fops      = &proc_root_operations,
8785         .parent         = &proc_root,
8786 +       .vx_flags       = IATTR_ADMIN | IATTR_WATCH,
8787  };
8788  
8789  int pid_ns_prepare_proc(struct pid_namespace *ns)
8790 diff -NurpP --minimal linux-2.6.33.2/fs/proc/uptime.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/uptime.c
8791 --- linux-2.6.33.2/fs/proc/uptime.c     2009-12-03 20:02:53.000000000 +0100
8792 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/proc/uptime.c     2010-02-25 12:02:16.000000000 +0100
8793 @@ -4,22 +4,22 @@
8794  #include <linux/sched.h>
8795  #include <linux/seq_file.h>
8796  #include <linux/time.h>
8797 -#include <linux/kernel_stat.h>
8798 +#include <linux/vserver/cvirt.h>
8799  #include <asm/cputime.h>
8800  
8801  static int uptime_proc_show(struct seq_file *m, void *v)
8802  {
8803         struct timespec uptime;
8804         struct timespec idle;
8805 -       int i;
8806 -       cputime_t idletime = cputime_zero;
8807 -
8808 -       for_each_possible_cpu(i)
8809 -               idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
8810 +       cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
8811  
8812         do_posix_clock_monotonic_gettime(&uptime);
8813         monotonic_to_bootbased(&uptime);
8814         cputime_to_timespec(idletime, &idle);
8815 +
8816 +       if (vx_flags(VXF_VIRT_UPTIME, 0))
8817 +               vx_vsi_uptime(&uptime, &idle);
8818 +
8819         seq_printf(m, "%lu.%02lu %lu.%02lu\n",
8820                         (unsigned long) uptime.tv_sec,
8821                         (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
8822 diff -NurpP --minimal linux-2.6.33.2/fs/quota/quota.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/quota/quota.c
8823 --- linux-2.6.33.2/fs/quota/quota.c     2010-02-25 11:52:06.000000000 +0100
8824 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/quota/quota.c     2010-02-25 13:25:13.000000000 +0100
8825 @@ -18,6 +18,7 @@
8826  #include <linux/capability.h>
8827  #include <linux/quotaops.h>
8828  #include <linux/types.h>
8829 +#include <linux/vs_context.h>
8830  #include <net/netlink.h>
8831  #include <net/genetlink.h>
8832  
8833 @@ -85,11 +86,11 @@ static int generic_quotactl_valid(struct
8834         if (cmd == Q_GETQUOTA) {
8835                 if (((type == USRQUOTA && current_euid() != id) ||
8836                      (type == GRPQUOTA && !in_egroup_p(id))) &&
8837 -                   !capable(CAP_SYS_ADMIN))
8838 +                   !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8839                         return -EPERM;
8840         }
8841         else if (cmd != Q_GETFMT && cmd != Q_SYNC && cmd != Q_GETINFO)
8842 -               if (!capable(CAP_SYS_ADMIN))
8843 +               if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8844                         return -EPERM;
8845  
8846         return 0;
8847 @@ -137,10 +138,10 @@ static int xqm_quotactl_valid(struct sup
8848         if (cmd == Q_XGETQUOTA) {
8849                 if (((type == XQM_USRQUOTA && current_euid() != id) ||
8850                      (type == XQM_GRPQUOTA && !in_egroup_p(id))) &&
8851 -                    !capable(CAP_SYS_ADMIN))
8852 +                    !vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8853                         return -EPERM;
8854         } else if (cmd != Q_XGETQSTAT && cmd != Q_XQUOTASYNC) {
8855 -               if (!capable(CAP_SYS_ADMIN))
8856 +               if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8857                         return -EPERM;
8858         }
8859  
8860 @@ -353,6 +354,46 @@ static int do_quotactl(struct super_bloc
8861         return 0;
8862  }
8863  
8864 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8865 +
8866 +#include <linux/vroot.h>
8867 +#include <linux/major.h>
8868 +#include <linux/module.h>
8869 +#include <linux/kallsyms.h>
8870 +#include <linux/vserver/debug.h>
8871 +
8872 +static vroot_grb_func *vroot_get_real_bdev = NULL;
8873 +
8874 +static spinlock_t vroot_grb_lock = SPIN_LOCK_UNLOCKED;
8875 +
8876 +int register_vroot_grb(vroot_grb_func *func) {
8877 +       int ret = -EBUSY;
8878 +
8879 +       spin_lock(&vroot_grb_lock);
8880 +       if (!vroot_get_real_bdev) {
8881 +               vroot_get_real_bdev = func;
8882 +               ret = 0;
8883 +       }
8884 +       spin_unlock(&vroot_grb_lock);
8885 +       return ret;
8886 +}
8887 +EXPORT_SYMBOL(register_vroot_grb);
8888 +
8889 +int unregister_vroot_grb(vroot_grb_func *func) {
8890 +       int ret = -EINVAL;
8891 +
8892 +       spin_lock(&vroot_grb_lock);
8893 +       if (vroot_get_real_bdev) {
8894 +               vroot_get_real_bdev = NULL;
8895 +               ret = 0;
8896 +       }
8897 +       spin_unlock(&vroot_grb_lock);
8898 +       return ret;
8899 +}
8900 +EXPORT_SYMBOL(unregister_vroot_grb);
8901 +
8902 +#endif
8903 +
8904  /*
8905   * look up a superblock on which quota ops will be performed
8906   * - use the name of a block device to find the superblock thereon
8907 @@ -370,6 +411,22 @@ static struct super_block *quotactl_bloc
8908         putname(tmp);
8909         if (IS_ERR(bdev))
8910                 return ERR_CAST(bdev);
8911 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8912 +       if (bdev && bdev->bd_inode &&
8913 +                       imajor(bdev->bd_inode) == VROOT_MAJOR) {
8914 +               struct block_device *bdnew = (void *)-EINVAL;
8915 +
8916 +               if (vroot_get_real_bdev)
8917 +                       bdnew = vroot_get_real_bdev(bdev);
8918 +               else
8919 +                       vxdprintk(VXD_CBIT(misc, 0),
8920 +                                       "vroot_get_real_bdev not set");
8921 +               bdput(bdev);
8922 +               if (IS_ERR(bdnew))
8923 +                       return ERR_PTR(PTR_ERR(bdnew));
8924 +               bdev = bdnew;
8925 +       }
8926 +#endif
8927         sb = get_super(bdev);
8928         bdput(bdev);
8929         if (!sb)
8930 diff -NurpP --minimal linux-2.6.33.2/fs/reiserfs/file.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/file.c
8931 --- linux-2.6.33.2/fs/reiserfs/file.c   2010-02-25 11:52:06.000000000 +0100
8932 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/file.c   2010-02-25 12:02:16.000000000 +0100
8933 @@ -307,4 +307,5 @@ const struct inode_operations reiserfs_f
8934         .listxattr = reiserfs_listxattr,
8935         .removexattr = reiserfs_removexattr,
8936         .permission = reiserfs_permission,
8937 +       .sync_flags = reiserfs_sync_flags,
8938  };
8939 diff -NurpP --minimal linux-2.6.33.2/fs/reiserfs/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/inode.c
8940 --- linux-2.6.33.2/fs/reiserfs/inode.c  2010-02-25 11:52:06.000000000 +0100
8941 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/inode.c  2010-02-25 12:02:16.000000000 +0100
8942 @@ -18,6 +18,7 @@
8943  #include <linux/writeback.h>
8944  #include <linux/quotaops.h>
8945  #include <linux/swap.h>
8946 +#include <linux/vs_tag.h>
8947  
8948  int reiserfs_commit_write(struct file *f, struct page *page,
8949                           unsigned from, unsigned to);
8950 @@ -1121,6 +1122,8 @@ static void init_inode(struct inode *ino
8951         struct buffer_head *bh;
8952         struct item_head *ih;
8953         __u32 rdev;
8954 +       uid_t uid;
8955 +       gid_t gid;
8956         //int version = ITEM_VERSION_1;
8957  
8958         bh = PATH_PLAST_BUFFER(path);
8959 @@ -1142,12 +1145,13 @@ static void init_inode(struct inode *ino
8960                     (struct stat_data_v1 *)B_I_PITEM(bh, ih);
8961                 unsigned long blocks;
8962  
8963 +               uid = sd_v1_uid(sd);
8964 +               gid = sd_v1_gid(sd);
8965 +
8966                 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
8967                 set_inode_sd_version(inode, STAT_DATA_V1);
8968                 inode->i_mode = sd_v1_mode(sd);
8969                 inode->i_nlink = sd_v1_nlink(sd);
8970 -               inode->i_uid = sd_v1_uid(sd);
8971 -               inode->i_gid = sd_v1_gid(sd);
8972                 inode->i_size = sd_v1_size(sd);
8973                 inode->i_atime.tv_sec = sd_v1_atime(sd);
8974                 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
8975 @@ -1189,11 +1193,12 @@ static void init_inode(struct inode *ino
8976                 // (directories and symlinks)
8977                 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
8978  
8979 +               uid    = sd_v2_uid(sd);
8980 +               gid    = sd_v2_gid(sd);
8981 +
8982                 inode->i_mode = sd_v2_mode(sd);
8983                 inode->i_nlink = sd_v2_nlink(sd);
8984 -               inode->i_uid = sd_v2_uid(sd);
8985                 inode->i_size = sd_v2_size(sd);
8986 -               inode->i_gid = sd_v2_gid(sd);
8987                 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
8988                 inode->i_atime.tv_sec = sd_v2_atime(sd);
8989                 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
8990 @@ -1223,6 +1228,10 @@ static void init_inode(struct inode *ino
8991                 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
8992         }
8993  
8994 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8995 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8996 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
8997 +
8998         pathrelse(path);
8999         if (S_ISREG(inode->i_mode)) {
9000                 inode->i_op = &reiserfs_file_inode_operations;
9001 @@ -1245,13 +1254,15 @@ static void init_inode(struct inode *ino
9002  static void inode2sd(void *sd, struct inode *inode, loff_t size)
9003  {
9004         struct stat_data *sd_v2 = (struct stat_data *)sd;
9005 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
9006 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
9007         __u16 flags;
9008  
9009 +       set_sd_v2_uid(sd_v2, uid);
9010 +       set_sd_v2_gid(sd_v2, gid);
9011         set_sd_v2_mode(sd_v2, inode->i_mode);
9012         set_sd_v2_nlink(sd_v2, inode->i_nlink);
9013 -       set_sd_v2_uid(sd_v2, inode->i_uid);
9014         set_sd_v2_size(sd_v2, size);
9015 -       set_sd_v2_gid(sd_v2, inode->i_gid);
9016         set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
9017         set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
9018         set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
9019 @@ -2852,14 +2863,19 @@ int reiserfs_commit_write(struct file *f
9020  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
9021  {
9022         if (reiserfs_attrs(inode->i_sb)) {
9023 -               if (sd_attrs & REISERFS_SYNC_FL)
9024 -                       inode->i_flags |= S_SYNC;
9025 -               else
9026 -                       inode->i_flags &= ~S_SYNC;
9027                 if (sd_attrs & REISERFS_IMMUTABLE_FL)
9028                         inode->i_flags |= S_IMMUTABLE;
9029                 else
9030                         inode->i_flags &= ~S_IMMUTABLE;
9031 +               if (sd_attrs & REISERFS_IXUNLINK_FL)
9032 +                       inode->i_flags |= S_IXUNLINK;
9033 +               else
9034 +                       inode->i_flags &= ~S_IXUNLINK;
9035 +
9036 +               if (sd_attrs & REISERFS_SYNC_FL)
9037 +                       inode->i_flags |= S_SYNC;
9038 +               else
9039 +                       inode->i_flags &= ~S_SYNC;
9040                 if (sd_attrs & REISERFS_APPEND_FL)
9041                         inode->i_flags |= S_APPEND;
9042                 else
9043 @@ -2872,6 +2888,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
9044                         REISERFS_I(inode)->i_flags |= i_nopack_mask;
9045                 else
9046                         REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
9047 +
9048 +               if (sd_attrs & REISERFS_BARRIER_FL)
9049 +                       inode->i_vflags |= V_BARRIER;
9050 +               else
9051 +                       inode->i_vflags &= ~V_BARRIER;
9052 +               if (sd_attrs & REISERFS_COW_FL)
9053 +                       inode->i_vflags |= V_COW;
9054 +               else
9055 +                       inode->i_vflags &= ~V_COW;
9056         }
9057  }
9058  
9059 @@ -2882,6 +2907,11 @@ void i_attrs_to_sd_attrs(struct inode *i
9060                         *sd_attrs |= REISERFS_IMMUTABLE_FL;
9061                 else
9062                         *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
9063 +               if (inode->i_flags & S_IXUNLINK)
9064 +                       *sd_attrs |= REISERFS_IXUNLINK_FL;
9065 +               else
9066 +                       *sd_attrs &= ~REISERFS_IXUNLINK_FL;
9067 +
9068                 if (inode->i_flags & S_SYNC)
9069                         *sd_attrs |= REISERFS_SYNC_FL;
9070                 else
9071 @@ -2894,6 +2924,15 @@ void i_attrs_to_sd_attrs(struct inode *i
9072                         *sd_attrs |= REISERFS_NOTAIL_FL;
9073                 else
9074                         *sd_attrs &= ~REISERFS_NOTAIL_FL;
9075 +
9076 +               if (inode->i_vflags & V_BARRIER)
9077 +                       *sd_attrs |= REISERFS_BARRIER_FL;
9078 +               else
9079 +                       *sd_attrs &= ~REISERFS_BARRIER_FL;
9080 +               if (inode->i_vflags & V_COW)
9081 +                       *sd_attrs |= REISERFS_COW_FL;
9082 +               else
9083 +                       *sd_attrs &= ~REISERFS_COW_FL;
9084         }
9085  }
9086  
9087 @@ -3115,9 +3154,11 @@ int reiserfs_setattr(struct dentry *dent
9088         }
9089  
9090         error = inode_change_ok(inode, attr);
9091 +
9092         if (!error) {
9093                 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
9094 -                   (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
9095 +                   (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
9096 +                   (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
9097                         error = reiserfs_chown_xattrs(inode, attr);
9098  
9099                         if (!error) {
9100 @@ -3147,6 +3188,9 @@ int reiserfs_setattr(struct dentry *dent
9101                                         inode->i_uid = attr->ia_uid;
9102                                 if (attr->ia_valid & ATTR_GID)
9103                                         inode->i_gid = attr->ia_gid;
9104 +                               if ((attr->ia_valid & ATTR_TAG) &&
9105 +                                       IS_TAGGED(inode))
9106 +                                       inode->i_tag = attr->ia_tag;
9107                                 mark_inode_dirty(inode);
9108                                 error =
9109                                     journal_end(&th, inode->i_sb, jbegin_count);
9110 diff -NurpP --minimal linux-2.6.33.2/fs/reiserfs/ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/ioctl.c
9111 --- linux-2.6.33.2/fs/reiserfs/ioctl.c  2010-02-25 11:52:06.000000000 +0100
9112 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/ioctl.c  2010-02-25 13:21:56.000000000 +0100
9113 @@ -7,11 +7,27 @@
9114  #include <linux/mount.h>
9115  #include <linux/reiserfs_fs.h>
9116  #include <linux/time.h>
9117 +#include <linux/mount.h>
9118  #include <asm/uaccess.h>
9119  #include <linux/pagemap.h>
9120  #include <linux/smp_lock.h>
9121  #include <linux/compat.h>
9122  
9123 +
9124 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
9125 +{
9126 +       __u16 sd_attrs = 0;
9127 +
9128 +       inode->i_flags = flags;
9129 +       inode->i_vflags = vflags;
9130 +
9131 +       i_attrs_to_sd_attrs(inode, &sd_attrs);
9132 +       REISERFS_I(inode)->i_attrs = sd_attrs;
9133 +       inode->i_ctime = CURRENT_TIME_SEC;
9134 +       mark_inode_dirty(inode);
9135 +       return 0;
9136 +}
9137 +
9138  /*
9139   * reiserfs_ioctl - handler for ioctl for inode
9140   * supported commands:
9141 @@ -23,7 +39,7 @@
9142  long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
9143  {
9144         struct inode *inode = filp->f_path.dentry->d_inode;
9145 -       unsigned int flags;
9146 +       unsigned int flags, oldflags;
9147         int err = 0;
9148  
9149         reiserfs_write_lock(inode->i_sb);
9150 @@ -48,6 +64,7 @@ long reiserfs_ioctl(struct file *filp, u
9151  
9152                 flags = REISERFS_I(inode)->i_attrs;
9153                 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
9154 +               flags &= REISERFS_FL_USER_VISIBLE;
9155                 err = put_user(flags, (int __user *)arg);
9156                 break;
9157         case REISERFS_IOC_SETFLAGS:{
9158 @@ -68,6 +85,10 @@ long reiserfs_ioctl(struct file *filp, u
9159                                 err = -EFAULT;
9160                                 goto setflags_out;
9161                         }
9162 +                       if (IS_BARRIER(inode)) {
9163 +                               vxwprintk_task(1, "messing with the barrier.");
9164 +                               return -EACCES;
9165 +                       }
9166                         /*
9167                          * Is it quota file? Do not allow user to mess with it
9168                          */
9169 @@ -92,6 +113,10 @@ long reiserfs_ioctl(struct file *filp, u
9170                                         goto setflags_out;
9171                                 }
9172                         }
9173 +
9174 +                       oldflags = REISERFS_I(inode)->i_attrs;
9175 +                       flags &= REISERFS_FL_USER_MODIFIABLE;
9176 +                       flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
9177                         sd_attrs_to_i_attrs(flags, inode);
9178                         REISERFS_I(inode)->i_attrs = flags;
9179                         inode->i_ctime = CURRENT_TIME_SEC;
9180 diff -NurpP --minimal linux-2.6.33.2/fs/reiserfs/namei.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/namei.c
9181 --- linux-2.6.33.2/fs/reiserfs/namei.c  2010-02-25 11:52:06.000000000 +0100
9182 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/namei.c  2010-02-25 12:02:16.000000000 +0100
9183 @@ -17,6 +17,7 @@
9184  #include <linux/reiserfs_acl.h>
9185  #include <linux/reiserfs_xattr.h>
9186  #include <linux/quotaops.h>
9187 +#include <linux/vs_tag.h>
9188  
9189  #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; }
9190  #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
9191 @@ -361,6 +362,7 @@ static struct dentry *reiserfs_lookup(st
9192         if (retval == IO_ERROR) {
9193                 return ERR_PTR(-EIO);
9194         }
9195 +               dx_propagate_tag(nd, inode);
9196  
9197         return d_splice_alias(inode, dentry);
9198  }
9199 @@ -577,6 +579,7 @@ static int new_inode_init(struct inode *
9200         } else {
9201                 inode->i_gid = current_fsgid();
9202         }
9203 +       inode->i_tag = dx_current_fstag(inode->i_sb);
9204         vfs_dq_init(inode);
9205         return 0;
9206  }
9207 @@ -1524,6 +1527,7 @@ const struct inode_operations reiserfs_d
9208         .listxattr = reiserfs_listxattr,
9209         .removexattr = reiserfs_removexattr,
9210         .permission = reiserfs_permission,
9211 +       .sync_flags = reiserfs_sync_flags,
9212  };
9213  
9214  /*
9215 diff -NurpP --minimal linux-2.6.33.2/fs/reiserfs/super.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/super.c
9216 --- linux-2.6.33.2/fs/reiserfs/super.c  2010-02-25 11:52:06.000000000 +0100
9217 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/super.c  2010-02-25 12:02:16.000000000 +0100
9218 @@ -887,6 +887,14 @@ static int reiserfs_parse_options(struct
9219                 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9220                 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9221  #endif
9222 +#ifndef CONFIG_TAGGING_NONE
9223 +               {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9224 +               {"tag",.setmask = 1 << REISERFS_TAGGED},
9225 +               {"notag",.clrmask = 1 << REISERFS_TAGGED},
9226 +#endif
9227 +#ifdef CONFIG_PROPAGATE
9228 +               {"tag",.arg_required = 'T',.values = NULL},
9229 +#endif
9230  #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9231                 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9232                 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9233 @@ -1196,6 +1204,14 @@ static int reiserfs_remount(struct super
9234         handle_quota_files(s, qf_names, &qfmt);
9235  #endif
9236  
9237 +       if ((mount_options & (1 << REISERFS_TAGGED)) &&
9238 +               !(s->s_flags & MS_TAGGED)) {
9239 +               reiserfs_warning(s, "super-vs01",
9240 +                       "reiserfs: tagging not permitted on remount.");
9241 +               err = -EINVAL;
9242 +               goto out_err;
9243 +       }
9244 +
9245         handle_attrs(s);
9246  
9247         /* Add options that are safe here */
9248 @@ -1674,6 +1690,10 @@ static int reiserfs_fill_super(struct su
9249                 goto error;
9250         }
9251  
9252 +       /* map mount option tagxid */
9253 +       if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9254 +               s->s_flags |= MS_TAGGED;
9255 +
9256         rs = SB_DISK_SUPER_BLOCK(s);
9257         /* Let's do basic sanity check to verify that underlying device is not
9258            smaller than the filesystem. If the check fails then abort and scream,
9259 diff -NurpP --minimal linux-2.6.33.2/fs/reiserfs/xattr.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/xattr.c
9260 --- linux-2.6.33.2/fs/reiserfs/xattr.c  2010-02-25 11:52:06.000000000 +0100
9261 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/reiserfs/xattr.c  2010-02-25 12:02:16.000000000 +0100
9262 @@ -39,6 +39,7 @@
9263  #include <linux/namei.h>
9264  #include <linux/errno.h>
9265  #include <linux/fs.h>
9266 +#include <linux/mount.h>
9267  #include <linux/file.h>
9268  #include <linux/pagemap.h>
9269  #include <linux/xattr.h>
9270 diff -NurpP --minimal linux-2.6.33.2/fs/stat.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/stat.c
9271 --- linux-2.6.33.2/fs/stat.c    2010-02-25 11:52:06.000000000 +0100
9272 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/stat.c    2010-02-25 12:02:16.000000000 +0100
9273 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9274         stat->nlink = inode->i_nlink;
9275         stat->uid = inode->i_uid;
9276         stat->gid = inode->i_gid;
9277 +       stat->tag = inode->i_tag;
9278         stat->rdev = inode->i_rdev;
9279         stat->atime = inode->i_atime;
9280         stat->mtime = inode->i_mtime;
9281 diff -NurpP --minimal linux-2.6.33.2/fs/super.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/super.c
9282 --- linux-2.6.33.2/fs/super.c   2010-02-25 11:52:06.000000000 +0100
9283 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/super.c   2010-02-25 12:02:16.000000000 +0100
9284 @@ -37,6 +37,9 @@
9285  #include <linux/kobject.h>
9286  #include <linux/mutex.h>
9287  #include <linux/file.h>
9288 +#include <linux/devpts_fs.h>
9289 +#include <linux/proc_fs.h>
9290 +#include <linux/vs_context.h>
9291  #include <asm/uaccess.h>
9292  #include "internal.h"
9293  
9294 @@ -914,12 +917,18 @@ struct vfsmount *
9295  vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
9296  {
9297         struct vfsmount *mnt;
9298 +       struct super_block *sb;
9299         char *secdata = NULL;
9300         int error;
9301  
9302         if (!type)
9303                 return ERR_PTR(-ENODEV);
9304  
9305 +       error = -EPERM;
9306 +       if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
9307 +               !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
9308 +               goto out;
9309 +
9310         error = -ENOMEM;
9311         mnt = alloc_vfsmnt(name);
9312         if (!mnt)
9313 @@ -938,9 +947,17 @@ vfs_kern_mount(struct file_system_type *
9314         error = type->get_sb(type, flags, name, data, mnt);
9315         if (error < 0)
9316                 goto out_free_secdata;
9317 -       BUG_ON(!mnt->mnt_sb);
9318  
9319 -       error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata);
9320 +       sb = mnt->mnt_sb;
9321 +       BUG_ON(!sb);
9322 +
9323 +       error = -EPERM;
9324 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) && !sb->s_bdev &&
9325 +               (sb->s_magic != PROC_SUPER_MAGIC) &&
9326 +               (sb->s_magic != DEVPTS_SUPER_MAGIC))
9327 +               goto out_sb;
9328 +
9329 +       error = security_sb_kern_mount(sb, flags, secdata);
9330         if (error)
9331                 goto out_sb;
9332  
9333 diff -NurpP --minimal linux-2.6.33.2/fs/sysfs/mount.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/sysfs/mount.c
9334 --- linux-2.6.33.2/fs/sysfs/mount.c     2009-06-11 17:13:08.000000000 +0200
9335 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/sysfs/mount.c     2010-02-25 12:02:16.000000000 +0100
9336 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
9337  
9338         sb->s_blocksize = PAGE_CACHE_SIZE;
9339         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9340 -       sb->s_magic = SYSFS_MAGIC;
9341 +       sb->s_magic = SYSFS_SUPER_MAGIC;
9342         sb->s_op = &sysfs_ops;
9343         sb->s_time_gran = 1;
9344         sysfs_sb = sb;
9345 diff -NurpP --minimal linux-2.6.33.2/fs/utimes.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/utimes.c
9346 --- linux-2.6.33.2/fs/utimes.c  2009-03-24 14:22:37.000000000 +0100
9347 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/utimes.c  2010-02-25 12:02:16.000000000 +0100
9348 @@ -8,6 +8,8 @@
9349  #include <linux/stat.h>
9350  #include <linux/utime.h>
9351  #include <linux/syscalls.h>
9352 +#include <linux/mount.h>
9353 +#include <linux/vs_cowbl.h>
9354  #include <asm/uaccess.h>
9355  #include <asm/unistd.h>
9356  
9357 diff -NurpP --minimal linux-2.6.33.2/fs/xattr.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/xattr.c
9358 --- linux-2.6.33.2/fs/xattr.c   2010-02-25 11:52:06.000000000 +0100
9359 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xattr.c   2010-03-05 19:55:41.000000000 +0100
9360 @@ -18,6 +18,7 @@
9361  #include <linux/module.h>
9362  #include <linux/fsnotify.h>
9363  #include <linux/audit.h>
9364 +#include <linux/mount.h>
9365  #include <asm/uaccess.h>
9366  
9367  
9368 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
9369          * The trusted.* namespace can only be accessed by a privileged user.
9370          */
9371         if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
9372 -               return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
9373 +               return (vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED) ? 0 : -EPERM);
9374  
9375         /* In user.* namespace, only regular files and directories can have
9376          * extended attributes. For sticky directories, only the owner and
9377 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_ioctl.c
9378 --- linux-2.6.33.2/fs/xfs/linux-2.6/xfs_ioctl.c 2010-02-25 11:52:06.000000000 +0100
9379 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_ioctl.c 2010-02-25 12:02:16.000000000 +0100
9380 @@ -34,7 +34,6 @@
9381  #include "xfs_dir2_sf.h"
9382  #include "xfs_dinode.h"
9383  #include "xfs_inode.h"
9384 -#include "xfs_ioctl.h"
9385  #include "xfs_btree.h"
9386  #include "xfs_ialloc.h"
9387  #include "xfs_rtalloc.h"
9388 @@ -743,6 +742,10 @@ xfs_merge_ioc_xflags(
9389                 xflags |= XFS_XFLAG_IMMUTABLE;
9390         else
9391                 xflags &= ~XFS_XFLAG_IMMUTABLE;
9392 +       if (flags & FS_IXUNLINK_FL)
9393 +               xflags |= XFS_XFLAG_IXUNLINK;
9394 +       else
9395 +               xflags &= ~XFS_XFLAG_IXUNLINK;
9396         if (flags & FS_APPEND_FL)
9397                 xflags |= XFS_XFLAG_APPEND;
9398         else
9399 @@ -771,6 +774,8 @@ xfs_di2lxflags(
9400  
9401         if (di_flags & XFS_DIFLAG_IMMUTABLE)
9402                 flags |= FS_IMMUTABLE_FL;
9403 +       if (di_flags & XFS_DIFLAG_IXUNLINK)
9404 +               flags |= FS_IXUNLINK_FL;
9405         if (di_flags & XFS_DIFLAG_APPEND)
9406                 flags |= FS_APPEND_FL;
9407         if (di_flags & XFS_DIFLAG_SYNC)
9408 @@ -829,6 +834,8 @@ xfs_set_diflags(
9409         di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
9410         if (xflags & XFS_XFLAG_IMMUTABLE)
9411                 di_flags |= XFS_DIFLAG_IMMUTABLE;
9412 +       if (xflags & XFS_XFLAG_IXUNLINK)
9413 +               di_flags |= XFS_DIFLAG_IXUNLINK;
9414         if (xflags & XFS_XFLAG_APPEND)
9415                 di_flags |= XFS_DIFLAG_APPEND;
9416         if (xflags & XFS_XFLAG_SYNC)
9417 @@ -871,6 +878,10 @@ xfs_diflags_to_linux(
9418                 inode->i_flags |= S_IMMUTABLE;
9419         else
9420                 inode->i_flags &= ~S_IMMUTABLE;
9421 +       if (xflags & XFS_XFLAG_IXUNLINK)
9422 +               inode->i_flags |= S_IXUNLINK;
9423 +       else
9424 +               inode->i_flags &= ~S_IXUNLINK;
9425         if (xflags & XFS_XFLAG_APPEND)
9426                 inode->i_flags |= S_APPEND;
9427         else
9428 @@ -1347,10 +1358,18 @@ xfs_file_ioctl(
9429         case XFS_IOC_FSGETXATTRA:
9430                 return xfs_ioc_fsgetxattr(ip, 1, arg);
9431         case XFS_IOC_FSSETXATTR:
9432 +               if (IS_BARRIER(inode)) {
9433 +                       vxwprintk_task(1, "messing with the barrier.");
9434 +                       return -XFS_ERROR(EACCES);
9435 +               }
9436                 return xfs_ioc_fssetxattr(ip, filp, arg);
9437         case XFS_IOC_GETXFLAGS:
9438                 return xfs_ioc_getxflags(ip, arg);
9439         case XFS_IOC_SETXFLAGS:
9440 +               if (IS_BARRIER(inode)) {
9441 +                       vxwprintk_task(1, "messing with the barrier.");
9442 +                       return -XFS_ERROR(EACCES);
9443 +               }
9444                 return xfs_ioc_setxflags(ip, filp, arg);
9445  
9446         case XFS_IOC_FSSETDM: {
9447 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_ioctl.h
9448 --- linux-2.6.33.2/fs/xfs/linux-2.6/xfs_ioctl.h 2009-03-24 14:22:37.000000000 +0100
9449 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_ioctl.h 2010-02-25 12:02:16.000000000 +0100
9450 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
9451         void __user             *uhandle,
9452         u32                     hlen);
9453  
9454 +extern int
9455 +xfs_sync_flags(
9456 +       struct inode            *inode,
9457 +       int                     flags,
9458 +       int                     vflags);
9459 +
9460  extern long
9461  xfs_file_ioctl(
9462         struct file             *filp,
9463 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_iops.c
9464 --- linux-2.6.33.2/fs/xfs/linux-2.6/xfs_iops.c  2010-02-25 11:52:06.000000000 +0100
9465 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_iops.c  2010-02-25 12:02:16.000000000 +0100
9466 @@ -36,6 +36,7 @@
9467  #include "xfs_attr_sf.h"
9468  #include "xfs_dinode.h"
9469  #include "xfs_inode.h"
9470 +#include "xfs_ioctl.h"
9471  #include "xfs_bmap.h"
9472  #include "xfs_btree.h"
9473  #include "xfs_ialloc.h"
9474 @@ -56,6 +57,7 @@
9475  #include <linux/security.h>
9476  #include <linux/falloc.h>
9477  #include <linux/fiemap.h>
9478 +#include <linux/vs_tag.h>
9479  
9480  /*
9481   * Bring the timestamps in the XFS inode uptodate.
9482 @@ -496,6 +498,7 @@ xfs_vn_getattr(
9483         stat->nlink = ip->i_d.di_nlink;
9484         stat->uid = ip->i_d.di_uid;
9485         stat->gid = ip->i_d.di_gid;
9486 +       stat->tag = ip->i_d.di_tag;
9487         stat->ino = ip->i_ino;
9488         stat->atime = inode->i_atime;
9489         stat->mtime = inode->i_mtime;
9490 @@ -687,6 +690,7 @@ static const struct inode_operations xfs
9491         .listxattr              = xfs_vn_listxattr,
9492         .fallocate              = xfs_vn_fallocate,
9493         .fiemap                 = xfs_vn_fiemap,
9494 +       .sync_flags             = xfs_sync_flags,
9495  };
9496  
9497  static const struct inode_operations xfs_dir_inode_operations = {
9498 @@ -712,6 +716,7 @@ static const struct inode_operations xfs
9499         .getxattr               = generic_getxattr,
9500         .removexattr            = generic_removexattr,
9501         .listxattr              = xfs_vn_listxattr,
9502 +       .sync_flags             = xfs_sync_flags,
9503  };
9504  
9505  static const struct inode_operations xfs_dir_ci_inode_operations = {
9506 @@ -761,6 +766,10 @@ xfs_diflags_to_iflags(
9507                 inode->i_flags |= S_IMMUTABLE;
9508         else
9509                 inode->i_flags &= ~S_IMMUTABLE;
9510 +       if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
9511 +               inode->i_flags |= S_IXUNLINK;
9512 +       else
9513 +               inode->i_flags &= ~S_IXUNLINK;
9514         if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
9515                 inode->i_flags |= S_APPEND;
9516         else
9517 @@ -773,6 +782,15 @@ xfs_diflags_to_iflags(
9518                 inode->i_flags |= S_NOATIME;
9519         else
9520                 inode->i_flags &= ~S_NOATIME;
9521 +
9522 +       if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
9523 +               inode->i_vflags |= V_BARRIER;
9524 +       else
9525 +               inode->i_vflags &= ~V_BARRIER;
9526 +       if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
9527 +               inode->i_vflags |= V_COW;
9528 +       else
9529 +               inode->i_vflags &= ~V_COW;
9530  }
9531  
9532  /*
9533 @@ -801,6 +819,7 @@ xfs_setup_inode(
9534         inode->i_nlink  = ip->i_d.di_nlink;
9535         inode->i_uid    = ip->i_d.di_uid;
9536         inode->i_gid    = ip->i_d.di_gid;
9537 +       inode->i_tag    = ip->i_d.di_tag;
9538  
9539         switch (inode->i_mode & S_IFMT) {
9540         case S_IFBLK:
9541 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_linux.h
9542 --- linux-2.6.33.2/fs/xfs/linux-2.6/xfs_linux.h 2010-02-25 11:52:06.000000000 +0100
9543 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_linux.h 2010-02-25 12:02:16.000000000 +0100
9544 @@ -118,6 +118,7 @@
9545  
9546  #define current_cpu()          (raw_smp_processor_id())
9547  #define current_pid()          (current->pid)
9548 +#define current_fstag(cred,vp) (dx_current_fstag((vp)->i_sb))
9549  #define current_test_flags(f)  (current->flags & (f))
9550  #define current_set_flags_nested(sp, f)                \
9551                 (*(sp) = current->flags, current->flags |= (f))
9552 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/linux-2.6/xfs_super.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_super.c
9553 --- linux-2.6.33.2/fs/xfs/linux-2.6/xfs_super.c 2010-02-25 11:52:06.000000000 +0100
9554 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_super.c 2010-02-25 12:02:16.000000000 +0100
9555 @@ -118,6 +118,9 @@ mempool_t *xfs_ioend_pool;
9556  #define MNTOPT_DMAPI   "dmapi"         /* DMI enabled (DMAPI / XDSM) */
9557  #define MNTOPT_XDSM    "xdsm"          /* DMI enabled (DMAPI / XDSM) */
9558  #define MNTOPT_DMI     "dmi"           /* DMI enabled (DMAPI / XDSM) */
9559 +#define MNTOPT_TAGXID  "tagxid"        /* context tagging for inodes */
9560 +#define MNTOPT_TAGGED  "tag"           /* context tagging for inodes */
9561 +#define MNTOPT_NOTAGTAG        "notag"         /* do not use context tagging */
9562  
9563  /*
9564   * Table driven mount option parser.
9565 @@ -126,10 +129,14 @@ mempool_t *xfs_ioend_pool;
9566   * in the future, too.
9567   */
9568  enum {
9569 +       Opt_tag, Opt_notag,
9570         Opt_barrier, Opt_nobarrier, Opt_err
9571  };
9572  
9573  static const match_table_t tokens = {
9574 +       {Opt_tag, "tagxid"},
9575 +       {Opt_tag, "tag"},
9576 +       {Opt_notag, "notag"},
9577         {Opt_barrier, "barrier"},
9578         {Opt_nobarrier, "nobarrier"},
9579         {Opt_err, NULL}
9580 @@ -383,6 +390,19 @@ xfs_parseargs(
9581                 } else if (!strcmp(this_char, "irixsgid")) {
9582                         cmn_err(CE_WARN,
9583         "XFS: irixsgid is now a sysctl(2) variable, option is deprecated.");
9584 +#ifndef CONFIG_TAGGING_NONE
9585 +               } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9586 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9587 +               } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
9588 +                       mp->m_flags &= ~XFS_MOUNT_TAGGED;
9589 +               } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
9590 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9591 +#endif
9592 +#ifdef CONFIG_PROPAGATE
9593 +               } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9594 +                       /* use value */
9595 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9596 +#endif
9597                 } else {
9598                         cmn_err(CE_WARN,
9599                                 "XFS: unknown mount option [%s].", this_char);
9600 @@ -1290,6 +1310,16 @@ xfs_fs_remount(
9601                 case Opt_nobarrier:
9602                         mp->m_flags &= ~XFS_MOUNT_BARRIER;
9603                         break;
9604 +               case Opt_tag:
9605 +                       if (!(sb->s_flags & MS_TAGGED)) {
9606 +                               printk(KERN_INFO
9607 +                                       "XFS: %s: tagging not permitted on remount.\n",
9608 +                                       sb->s_id);
9609 +                               return -EINVAL;
9610 +                       }
9611 +                       break;
9612 +               case Opt_notag:
9613 +                       break;
9614                 default:
9615                         /*
9616                          * Logically we would return an error here to prevent
9617 @@ -1497,6 +1527,9 @@ xfs_fs_fill_super(
9618  
9619         XFS_SEND_MOUNT(mp, DM_RIGHT_NULL, mtpt, mp->m_fsname);
9620  
9621 +       if (mp->m_flags & XFS_MOUNT_TAGGED)
9622 +               sb->s_flags |= MS_TAGGED;
9623 +
9624         sb->s_magic = XFS_SB_MAGIC;
9625         sb->s_blocksize = mp->m_sb.sb_blocksize;
9626         sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
9627 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/xfs_dinode.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_dinode.h
9628 --- linux-2.6.33.2/fs/xfs/xfs_dinode.h  2009-06-11 17:13:09.000000000 +0200
9629 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_dinode.h  2010-02-25 12:02:16.000000000 +0100
9630 @@ -50,7 +50,9 @@ typedef struct xfs_dinode {
9631         __be32          di_gid;         /* owner's group id */
9632         __be32          di_nlink;       /* number of links to file */
9633         __be16          di_projid;      /* owner's project id */
9634 -       __u8            di_pad[8];      /* unused, zeroed space */
9635 +       __be16          di_tag;         /* context tagging */
9636 +       __be16          di_vflags;      /* vserver specific flags */
9637 +       __u8            di_pad[4];      /* unused, zeroed space */
9638         __be16          di_flushiter;   /* incremented on flush */
9639         xfs_timestamp_t di_atime;       /* time last accessed */
9640         xfs_timestamp_t di_mtime;       /* time last modified */
9641 @@ -183,6 +185,8 @@ static inline void xfs_dinode_put_rdev(s
9642  #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
9643  #define XFS_DIFLAG_NODEFRAG_BIT     13 /* do not reorganize/defragment */
9644  #define XFS_DIFLAG_FILESTREAM_BIT   14  /* use filestream allocator */
9645 +#define XFS_DIFLAG_IXUNLINK_BIT     15 /* Immutable inver on unlink */
9646 +
9647  #define XFS_DIFLAG_REALTIME      (1 << XFS_DIFLAG_REALTIME_BIT)
9648  #define XFS_DIFLAG_PREALLOC      (1 << XFS_DIFLAG_PREALLOC_BIT)
9649  #define XFS_DIFLAG_NEWRTBM       (1 << XFS_DIFLAG_NEWRTBM_BIT)
9650 @@ -198,6 +202,7 @@ static inline void xfs_dinode_put_rdev(s
9651  #define XFS_DIFLAG_EXTSZINHERIT  (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
9652  #define XFS_DIFLAG_NODEFRAG      (1 << XFS_DIFLAG_NODEFRAG_BIT)
9653  #define XFS_DIFLAG_FILESTREAM    (1 << XFS_DIFLAG_FILESTREAM_BIT)
9654 +#define XFS_DIFLAG_IXUNLINK      (1 << XFS_DIFLAG_IXUNLINK_BIT)
9655  
9656  #ifdef CONFIG_XFS_RT
9657  #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
9658 @@ -210,6 +215,10 @@ static inline void xfs_dinode_put_rdev(s
9659          XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
9660          XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
9661          XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
9662 -        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
9663 +        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
9664 +        XFS_DIFLAG_IXUNLINK)
9665 +
9666 +#define XFS_DIVFLAG_BARRIER    0x01
9667 +#define XFS_DIVFLAG_COW                0x02
9668  
9669  #endif /* __XFS_DINODE_H__ */
9670 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/xfs_fs.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_fs.h
9671 --- linux-2.6.33.2/fs/xfs/xfs_fs.h      2009-12-03 20:02:53.000000000 +0100
9672 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_fs.h      2010-02-25 12:02:16.000000000 +0100
9673 @@ -67,6 +67,9 @@ struct fsxattr {
9674  #define XFS_XFLAG_EXTSZINHERIT 0x00001000      /* inherit inode extent size */
9675  #define XFS_XFLAG_NODEFRAG     0x00002000      /* do not defragment */
9676  #define XFS_XFLAG_FILESTREAM   0x00004000      /* use filestream allocator */
9677 +#define XFS_XFLAG_IXUNLINK     0x00008000      /* immutable invert on unlink */
9678 +#define XFS_XFLAG_BARRIER      0x10000000      /* chroot() barrier */
9679 +#define XFS_XFLAG_COW          0x20000000      /* copy on write mark */
9680  #define XFS_XFLAG_HASATTR      0x80000000      /* no DIFLAG for this   */
9681  
9682  /*
9683 @@ -292,7 +295,8 @@ typedef struct xfs_bstat {
9684         __s32           bs_extents;     /* number of extents            */
9685         __u32           bs_gen;         /* generation count             */
9686         __u16           bs_projid;      /* project id                   */
9687 -       unsigned char   bs_pad[14];     /* pad space, unused            */
9688 +       __u16           bs_tag;         /* context tagging              */
9689 +       unsigned char   bs_pad[12];     /* pad space, unused            */
9690         __u32           bs_dmevmask;    /* DMIG event mask              */
9691         __u16           bs_dmstate;     /* DMIG state info              */
9692         __u16           bs_aextents;    /* attribute number of extents  */
9693 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/xfs_ialloc.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_ialloc.c
9694 --- linux-2.6.33.2/fs/xfs/xfs_ialloc.c  2010-02-25 11:52:06.000000000 +0100
9695 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_ialloc.c  2010-02-25 12:02:16.000000000 +0100
9696 @@ -41,7 +41,6 @@
9697  #include "xfs_error.h"
9698  #include "xfs_bmap.h"
9699  
9700 -
9701  /*
9702   * Allocation group level functions.
9703   */
9704 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/xfs_inode.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_inode.c
9705 --- linux-2.6.33.2/fs/xfs/xfs_inode.c   2010-02-25 11:52:06.000000000 +0100
9706 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_inode.c   2010-02-25 12:02:16.000000000 +0100
9707 @@ -249,6 +249,7 @@ xfs_inotobp(
9708         return 0;
9709  }
9710  
9711 +#include <linux/vs_tag.h>
9712  
9713  /*
9714   * This routine is called to map an inode to the buffer containing
9715 @@ -654,15 +655,25 @@ xfs_iformat_btree(
9716  STATIC void
9717  xfs_dinode_from_disk(
9718         xfs_icdinode_t          *to,
9719 -       xfs_dinode_t            *from)
9720 +       xfs_dinode_t            *from,
9721 +       int tagged)
9722  {
9723 +       uint32_t uid, gid, tag;
9724 +
9725         to->di_magic = be16_to_cpu(from->di_magic);
9726         to->di_mode = be16_to_cpu(from->di_mode);
9727         to->di_version = from ->di_version;
9728         to->di_format = from->di_format;
9729         to->di_onlink = be16_to_cpu(from->di_onlink);
9730 -       to->di_uid = be32_to_cpu(from->di_uid);
9731 -       to->di_gid = be32_to_cpu(from->di_gid);
9732 +
9733 +       uid = be32_to_cpu(from->di_uid);
9734 +       gid = be32_to_cpu(from->di_gid);
9735 +       tag = be16_to_cpu(from->di_tag);
9736 +
9737 +       to->di_uid = INOTAG_UID(tagged, uid, gid);
9738 +       to->di_gid = INOTAG_GID(tagged, uid, gid);
9739 +       to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
9740 +
9741         to->di_nlink = be32_to_cpu(from->di_nlink);
9742         to->di_projid = be16_to_cpu(from->di_projid);
9743         memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
9744 @@ -683,21 +694,26 @@ xfs_dinode_from_disk(
9745         to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
9746         to->di_dmstate  = be16_to_cpu(from->di_dmstate);
9747         to->di_flags    = be16_to_cpu(from->di_flags);
9748 +       to->di_vflags   = be16_to_cpu(from->di_vflags);
9749         to->di_gen      = be32_to_cpu(from->di_gen);
9750  }
9751  
9752  void
9753  xfs_dinode_to_disk(
9754         xfs_dinode_t            *to,
9755 -       xfs_icdinode_t          *from)
9756 +       xfs_icdinode_t          *from,
9757 +       int tagged)
9758  {
9759         to->di_magic = cpu_to_be16(from->di_magic);
9760         to->di_mode = cpu_to_be16(from->di_mode);
9761         to->di_version = from ->di_version;
9762         to->di_format = from->di_format;
9763         to->di_onlink = cpu_to_be16(from->di_onlink);
9764 -       to->di_uid = cpu_to_be32(from->di_uid);
9765 -       to->di_gid = cpu_to_be32(from->di_gid);
9766 +
9767 +       to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
9768 +       to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
9769 +       to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
9770 +
9771         to->di_nlink = cpu_to_be32(from->di_nlink);
9772         to->di_projid = cpu_to_be16(from->di_projid);
9773         memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
9774 @@ -718,12 +734,14 @@ xfs_dinode_to_disk(
9775         to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
9776         to->di_dmstate = cpu_to_be16(from->di_dmstate);
9777         to->di_flags = cpu_to_be16(from->di_flags);
9778 +       to->di_vflags = cpu_to_be16(from->di_vflags);
9779         to->di_gen = cpu_to_be32(from->di_gen);
9780  }
9781  
9782  STATIC uint
9783  _xfs_dic2xflags(
9784 -       __uint16_t              di_flags)
9785 +       __uint16_t              di_flags,
9786 +       __uint16_t              di_vflags)
9787  {
9788         uint                    flags = 0;
9789  
9790 @@ -734,6 +752,8 @@ _xfs_dic2xflags(
9791                         flags |= XFS_XFLAG_PREALLOC;
9792                 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9793                         flags |= XFS_XFLAG_IMMUTABLE;
9794 +               if (di_flags & XFS_DIFLAG_IXUNLINK)
9795 +                       flags |= XFS_XFLAG_IXUNLINK;
9796                 if (di_flags & XFS_DIFLAG_APPEND)
9797                         flags |= XFS_XFLAG_APPEND;
9798                 if (di_flags & XFS_DIFLAG_SYNC)
9799 @@ -758,6 +778,10 @@ _xfs_dic2xflags(
9800                         flags |= XFS_XFLAG_FILESTREAM;
9801         }
9802  
9803 +       if (di_vflags & XFS_DIVFLAG_BARRIER)
9804 +               flags |= FS_BARRIER_FL;
9805 +       if (di_vflags & XFS_DIVFLAG_COW)
9806 +               flags |= FS_COW_FL;
9807         return flags;
9808  }
9809  
9810 @@ -767,7 +791,7 @@ xfs_ip2xflags(
9811  {
9812         xfs_icdinode_t          *dic = &ip->i_d;
9813  
9814 -       return _xfs_dic2xflags(dic->di_flags) |
9815 +       return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
9816                                 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
9817  }
9818  
9819 @@ -775,7 +799,8 @@ uint
9820  xfs_dic2xflags(
9821         xfs_dinode_t            *dip)
9822  {
9823 -       return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
9824 +       return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
9825 +                               be16_to_cpu(dip->di_vflags)) |
9826                                 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
9827  }
9828  
9829 @@ -811,7 +836,6 @@ xfs_iread(
9830         if (error)
9831                 return error;
9832         dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
9833 -
9834         /*
9835          * If we got something that isn't an inode it means someone
9836          * (nfs or dmi) has a stale handle.
9837 @@ -836,7 +860,8 @@ xfs_iread(
9838          * Otherwise, just get the truly permanent information.
9839          */
9840         if (dip->di_mode) {
9841 -               xfs_dinode_from_disk(&ip->i_d, dip);
9842 +               xfs_dinode_from_disk(&ip->i_d, dip,
9843 +                       mp->m_flags & XFS_MOUNT_TAGGED);
9844                 error = xfs_iformat(ip, dip);
9845                 if (error)  {
9846  #ifdef DEBUG
9847 @@ -1036,6 +1061,7 @@ xfs_ialloc(
9848         ASSERT(ip->i_d.di_nlink == nlink);
9849         ip->i_d.di_uid = current_fsuid();
9850         ip->i_d.di_gid = current_fsgid();
9851 +       ip->i_d.di_tag = current_fstag(cr, &ip->i_vnode);
9852         ip->i_d.di_projid = prid;
9853         memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
9854  
9855 @@ -1096,6 +1122,7 @@ xfs_ialloc(
9856         ip->i_d.di_dmevmask = 0;
9857         ip->i_d.di_dmstate = 0;
9858         ip->i_d.di_flags = 0;
9859 +       ip->i_d.di_vflags = 0;
9860         flags = XFS_ILOG_CORE;
9861         switch (mode & S_IFMT) {
9862         case S_IFIFO:
9863 @@ -2136,6 +2163,7 @@ xfs_ifree(
9864         }
9865         ip->i_d.di_mode = 0;            /* mark incore inode as free */
9866         ip->i_d.di_flags = 0;
9867 +       ip->i_d.di_vflags = 0;
9868         ip->i_d.di_dmevmask = 0;
9869         ip->i_d.di_forkoff = 0;         /* mark the attr fork not in use */
9870         ip->i_df.if_ext_max =
9871 @@ -3116,7 +3144,8 @@ xfs_iflush_int(
9872          * because if the inode is dirty at all the core must
9873          * be.
9874          */
9875 -       xfs_dinode_to_disk(dip, &ip->i_d);
9876 +       xfs_dinode_to_disk(dip, &ip->i_d,
9877 +               mp->m_flags & XFS_MOUNT_TAGGED);
9878  
9879         /* Wrap, we never let the log put out DI_MAX_FLUSH */
9880         if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
9881 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/xfs_inode.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_inode.h
9882 --- linux-2.6.33.2/fs/xfs/xfs_inode.h   2010-02-25 11:52:06.000000000 +0100
9883 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_inode.h   2010-02-25 12:02:16.000000000 +0100
9884 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
9885         __uint32_t      di_gid;         /* owner's group id */
9886         __uint32_t      di_nlink;       /* number of links to file */
9887         __uint16_t      di_projid;      /* owner's project id */
9888 -       __uint8_t       di_pad[8];      /* unused, zeroed space */
9889 +       __uint16_t      di_tag;         /* context tagging */
9890 +       __uint16_t      di_vflags;      /* vserver specific flags */
9891 +       __uint8_t       di_pad[4];      /* unused, zeroed space */
9892         __uint16_t      di_flushiter;   /* incremented on flush */
9893         xfs_ictimestamp_t di_atime;     /* time last accessed */
9894         xfs_ictimestamp_t di_mtime;     /* time last modified */
9895 @@ -521,7 +523,7 @@ int         xfs_itobp(struct xfs_mount *, struc
9896  int            xfs_iread(struct xfs_mount *, struct xfs_trans *,
9897                           struct xfs_inode *, xfs_daddr_t, uint);
9898  void           xfs_dinode_to_disk(struct xfs_dinode *,
9899 -                                  struct xfs_icdinode *);
9900 +                                  struct xfs_icdinode *, int);
9901  void           xfs_idestroy_fork(struct xfs_inode *, int);
9902  void           xfs_idata_realloc(struct xfs_inode *, int, int);
9903  void           xfs_iroot_realloc(struct xfs_inode *, int, int);
9904 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/xfs_itable.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_itable.c
9905 --- linux-2.6.33.2/fs/xfs/xfs_itable.c  2009-12-03 20:02:54.000000000 +0100
9906 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_itable.c  2010-02-25 12:02:16.000000000 +0100
9907 @@ -84,6 +84,7 @@ xfs_bulkstat_one_iget(
9908         buf->bs_mode = dic->di_mode;
9909         buf->bs_uid = dic->di_uid;
9910         buf->bs_gid = dic->di_gid;
9911 +       buf->bs_tag = dic->di_tag;
9912         buf->bs_size = dic->di_size;
9913  
9914         /*
9915 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/xfs_log_recover.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_log_recover.c
9916 --- linux-2.6.33.2/fs/xfs/xfs_log_recover.c     2010-02-25 11:52:06.000000000 +0100
9917 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_log_recover.c     2010-02-25 12:02:16.000000000 +0100
9918 @@ -2462,7 +2462,8 @@ xlog_recover_do_inode_trans(
9919         }
9920  
9921         /* The core is in in-core format */
9922 -       xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
9923 +       xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr,
9924 +               mp->m_flags & XFS_MOUNT_TAGGED);
9925  
9926         /* the rest is in on-disk format */
9927         if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
9928 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/xfs_mount.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_mount.h
9929 --- linux-2.6.33.2/fs/xfs/xfs_mount.h   2010-02-25 11:52:06.000000000 +0100
9930 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_mount.h   2010-02-25 12:02:16.000000000 +0100
9931 @@ -298,6 +298,7 @@ typedef struct xfs_mount {
9932                                                    allocator */
9933  #define XFS_MOUNT_NOATTR2      (1ULL << 25)    /* disable use of attr2 format */
9934  
9935 +#define XFS_MOUNT_TAGGED       (1ULL << 31)    /* context tagging */
9936  
9937  /*
9938   * Default minimum read and write sizes.
9939 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/xfs_vnodeops.c linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_vnodeops.c
9940 --- linux-2.6.33.2/fs/xfs/xfs_vnodeops.c        2010-02-25 11:52:06.000000000 +0100
9941 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_vnodeops.c        2010-02-25 13:24:14.000000000 +0100
9942 @@ -55,6 +55,80 @@
9943  #include "xfs_vnodeops.h"
9944  #include "xfs_trace.h"
9945  
9946 +
9947 +STATIC void
9948 +xfs_get_inode_flags(
9949 +       xfs_inode_t     *ip)
9950 +{
9951 +       struct inode    *inode = VFS_I(ip);
9952 +       unsigned int    flags = inode->i_flags;
9953 +       unsigned int    vflags = inode->i_vflags;
9954 +
9955 +       if (flags & S_IMMUTABLE)
9956 +               ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
9957 +       else
9958 +               ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
9959 +       if (flags & S_IXUNLINK)
9960 +               ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
9961 +       else
9962 +               ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
9963 +
9964 +       if (vflags & V_BARRIER)
9965 +               ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
9966 +       else
9967 +               ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
9968 +       if (vflags & V_COW)
9969 +               ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
9970 +       else
9971 +               ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
9972 +}
9973 +
9974 +int
9975 +xfs_sync_flags(
9976 +       struct inode            *inode,
9977 +       int                     flags,
9978 +       int                     vflags)
9979 +{
9980 +       struct xfs_inode        *ip = XFS_I(inode);
9981 +       struct xfs_mount        *mp = ip->i_mount;
9982 +       struct xfs_trans        *tp;
9983 +       unsigned int            lock_flags = 0;
9984 +       int                     code;
9985 +
9986 +       tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
9987 +       code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
9988 +       if (code)
9989 +               goto error_out;
9990 +
9991 +       lock_flags = XFS_ILOCK_EXCL;
9992 +       xfs_ilock(ip, lock_flags);
9993 +
9994 +       xfs_trans_ijoin(tp, ip, lock_flags);
9995 +       xfs_trans_ihold(tp, ip);
9996 +
9997 +       inode->i_flags = flags;
9998 +       inode->i_vflags = vflags;
9999 +       xfs_get_inode_flags(ip);
10000 +
10001 +       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
10002 +       xfs_ichgtime(ip, XFS_ICHGTIME_CHG);
10003 +
10004 +       XFS_STATS_INC(xs_ig_attrchg);
10005 +
10006 +       if (mp->m_flags & XFS_MOUNT_WSYNC)
10007 +               xfs_trans_set_sync(tp);
10008 +       code = xfs_trans_commit(tp, 0);
10009 +       xfs_iunlock(ip, lock_flags);
10010 +       return code;
10011 +
10012 +error_out:
10013 +       xfs_trans_cancel(tp, 0);
10014 +       if (lock_flags)
10015 +               xfs_iunlock(ip, lock_flags);
10016 +       return code;
10017 +}
10018 +
10019 +
10020  int
10021  xfs_setattr(
10022         struct xfs_inode        *ip,
10023 @@ -70,6 +144,7 @@ xfs_setattr(
10024         uint                    commit_flags=0;
10025         uid_t                   uid=0, iuid=0;
10026         gid_t                   gid=0, igid=0;
10027 +       tag_t                   tag=0, itag=0;
10028         struct xfs_dquot        *udqp, *gdqp, *olddquot1, *olddquot2;
10029         int                     need_iolock = 1;
10030  
10031 @@ -162,7 +237,7 @@ xfs_setattr(
10032         /*
10033          * Change file ownership.  Must be the owner or privileged.
10034          */
10035 -       if (mask & (ATTR_UID|ATTR_GID)) {
10036 +       if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
10037                 /*
10038                  * These IDs could have changed since we last looked at them.
10039                  * But, we're assured that if the ownership did change
10040 @@ -171,8 +246,10 @@ xfs_setattr(
10041                  */
10042                 iuid = ip->i_d.di_uid;
10043                 igid = ip->i_d.di_gid;
10044 +               itag = ip->i_d.di_tag;
10045                 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
10046                 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
10047 +               tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
10048  
10049                 /*
10050                  * Do a quota reservation only if uid/gid is actually
10051 @@ -180,7 +257,8 @@ xfs_setattr(
10052                  */
10053                 if (XFS_IS_QUOTA_RUNNING(mp) &&
10054                     ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
10055 -                    (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
10056 +                    (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
10057 +                    (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
10058                         ASSERT(tp);
10059                         code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
10060                                                 capable(CAP_FOWNER) ?
10061 @@ -341,7 +419,7 @@ xfs_setattr(
10062         /*
10063          * Change file ownership.  Must be the owner or privileged.
10064          */
10065 -       if (mask & (ATTR_UID|ATTR_GID)) {
10066 +       if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
10067                 /*
10068                  * CAP_FSETID overrides the following restrictions:
10069                  *
10070 @@ -357,6 +435,10 @@ xfs_setattr(
10071                  * Change the ownerships and register quota modifications
10072                  * in the transaction.
10073                  */
10074 +               if (itag != tag) {
10075 +                       ip->i_d.di_tag = tag;
10076 +                       inode->i_tag = tag;
10077 +               }
10078                 if (iuid != uid) {
10079                         if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
10080                                 ASSERT(mask & ATTR_UID);
10081 diff -NurpP --minimal linux-2.6.33.2/fs/xfs/xfs_vnodeops.h linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_vnodeops.h
10082 --- linux-2.6.33.2/fs/xfs/xfs_vnodeops.h        2010-02-25 11:52:06.000000000 +0100
10083 +++ linux-2.6.33.2-vs2.3.0.36.30.4/fs/xfs/xfs_vnodeops.h        2010-02-25 12:02:16.000000000 +0100
10084 @@ -14,6 +14,7 @@ struct xfs_inode;
10085  struct xfs_iomap;
10086  
10087  
10088 +int xfs_sync_xflags(struct xfs_inode *ip);
10089  int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
10090  #define        XFS_ATTR_DMI            0x01    /* invocation from a DMI function */
10091  #define        XFS_ATTR_NONBLOCK       0x02    /* return EAGAIN if operation would block */
10092 diff -NurpP --minimal linux-2.6.33.2/include/asm-generic/tlb.h linux-2.6.33.2-vs2.3.0.36.30.4/include/asm-generic/tlb.h
10093 --- linux-2.6.33.2/include/asm-generic/tlb.h    2009-09-10 15:26:24.000000000 +0200
10094 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/asm-generic/tlb.h    2010-02-25 12:02:16.000000000 +0100
10095 @@ -14,6 +14,7 @@
10096  #define _ASM_GENERIC__TLB_H
10097  
10098  #include <linux/swap.h>
10099 +#include <linux/vs_memory.h>
10100  #include <asm/pgalloc.h>
10101  #include <asm/tlbflush.h>
10102  
10103 diff -NurpP --minimal linux-2.6.33.2/include/linux/capability.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/capability.h
10104 --- linux-2.6.33.2/include/linux/capability.h   2010-02-25 11:52:07.000000000 +0100
10105 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/capability.h   2010-02-25 12:02:16.000000000 +0100
10106 @@ -283,6 +283,7 @@ struct cpu_vfs_cap_data {
10107     arbitrary SCSI commands */
10108  /* Allow setting encryption key on loopback filesystem */
10109  /* Allow setting zone reclaim policy */
10110 +/* Allow the selection of a security context */
10111  
10112  #define CAP_SYS_ADMIN        21
10113  
10114 @@ -355,7 +356,13 @@ struct cpu_vfs_cap_data {
10115  
10116  #define CAP_MAC_ADMIN        33
10117  
10118 -#define CAP_LAST_CAP         CAP_MAC_ADMIN
10119 +/* Allow context manipulations */
10120 +/* Allow changing context info on files */
10121 +
10122 +#define CAP_CONTEXT         34
10123 +
10124 +
10125 +#define CAP_LAST_CAP         CAP_CONTEXT
10126  
10127  #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
10128  
10129 diff -NurpP --minimal linux-2.6.33.2/include/linux/devpts_fs.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/devpts_fs.h
10130 --- linux-2.6.33.2/include/linux/devpts_fs.h    2008-12-25 00:26:37.000000000 +0100
10131 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/devpts_fs.h    2010-02-25 12:02:16.000000000 +0100
10132 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
10133  
10134  #endif
10135  
10136 -
10137  #endif /* _LINUX_DEVPTS_FS_H */
10138 diff -NurpP --minimal linux-2.6.33.2/include/linux/ext2_fs.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/ext2_fs.h
10139 --- linux-2.6.33.2/include/linux/ext2_fs.h      2010-02-25 11:52:07.000000000 +0100
10140 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/ext2_fs.h      2010-02-25 12:02:16.000000000 +0100
10141 @@ -189,8 +189,12 @@ struct ext2_group_desc
10142  #define EXT2_NOTAIL_FL                 FS_NOTAIL_FL    /* file tail should not be merged */
10143  #define EXT2_DIRSYNC_FL                        FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
10144  #define EXT2_TOPDIR_FL                 FS_TOPDIR_FL    /* Top of directory hierarchies*/
10145 +#define EXT2_IXUNLINK_FL               FS_IXUNLINK_FL  /* Immutable invert on unlink */
10146  #define EXT2_RESERVED_FL               FS_RESERVED_FL  /* reserved for ext2 lib */
10147  
10148 +#define EXT2_BARRIER_FL                        FS_BARRIER_FL   /* Barrier for chroot() */
10149 +#define EXT2_COW_FL                    FS_COW_FL       /* Copy on Write marker */
10150 +
10151  #define EXT2_FL_USER_VISIBLE           FS_FL_USER_VISIBLE      /* User visible flags */
10152  #define EXT2_FL_USER_MODIFIABLE                FS_FL_USER_MODIFIABLE   /* User modifiable flags */
10153  
10154 @@ -274,7 +278,8 @@ struct ext2_inode {
10155                         __u16   i_pad1;
10156                         __le16  l_i_uid_high;   /* these 2 fields    */
10157                         __le16  l_i_gid_high;   /* were reserved2[0] */
10158 -                       __u32   l_i_reserved2;
10159 +                       __le16  l_i_tag;        /* Context Tag */
10160 +                       __u16   l_i_reserved2;
10161                 } linux2;
10162                 struct {
10163                         __u8    h_i_frag;       /* Fragment number */
10164 @@ -303,6 +308,7 @@ struct ext2_inode {
10165  #define i_gid_low      i_gid
10166  #define i_uid_high     osd2.linux2.l_i_uid_high
10167  #define i_gid_high     osd2.linux2.l_i_gid_high
10168 +#define i_raw_tag      osd2.linux2.l_i_tag
10169  #define i_reserved2    osd2.linux2.l_i_reserved2
10170  #endif
10171  
10172 @@ -347,6 +353,7 @@ struct ext2_inode {
10173  #define EXT2_MOUNT_USRQUOTA            0x020000  /* user quota */
10174  #define EXT2_MOUNT_GRPQUOTA            0x040000  /* group quota */
10175  #define EXT2_MOUNT_RESERVATION         0x080000  /* Preallocation */
10176 +#define EXT2_MOUNT_TAGGED              (1<<24)   /* Enable Context Tags */
10177  
10178  
10179  #define clear_opt(o, opt)              o &= ~EXT2_MOUNT_##opt
10180 diff -NurpP --minimal linux-2.6.33.2/include/linux/ext3_fs.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/ext3_fs.h
10181 --- linux-2.6.33.2/include/linux/ext3_fs.h      2010-02-25 11:52:07.000000000 +0100
10182 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/ext3_fs.h      2010-02-25 12:02:16.000000000 +0100
10183 @@ -173,10 +173,14 @@ struct ext3_group_desc
10184  #define EXT3_NOTAIL_FL                 0x00008000 /* file tail should not be merged */
10185  #define EXT3_DIRSYNC_FL                        0x00010000 /* dirsync behaviour (directories only) */
10186  #define EXT3_TOPDIR_FL                 0x00020000 /* Top of directory hierarchies*/
10187 +#define EXT3_IXUNLINK_FL               0x08000000 /* Immutable invert on unlink */
10188  #define EXT3_RESERVED_FL               0x80000000 /* reserved for ext3 lib */
10189  
10190 -#define EXT3_FL_USER_VISIBLE           0x0003DFFF /* User visible flags */
10191 -#define EXT3_FL_USER_MODIFIABLE                0x000380FF /* User modifiable flags */
10192 +#define EXT3_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
10193 +#define EXT3_COW_FL                    0x20000000 /* Copy on Write marker */
10194 +
10195 +#define EXT3_FL_USER_VISIBLE           0x0103DFFF /* User visible flags */
10196 +#define EXT3_FL_USER_MODIFIABLE                0x010380FF /* User modifiable flags */
10197  
10198  /* Flags that should be inherited by new inodes from their parent. */
10199  #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
10200 @@ -320,7 +324,8 @@ struct ext3_inode {
10201                         __u16   i_pad1;
10202                         __le16  l_i_uid_high;   /* these 2 fields    */
10203                         __le16  l_i_gid_high;   /* were reserved2[0] */
10204 -                       __u32   l_i_reserved2;
10205 +                       __le16  l_i_tag;        /* Context Tag */
10206 +                       __u16   l_i_reserved2;
10207                 } linux2;
10208                 struct {
10209                         __u8    h_i_frag;       /* Fragment number */
10210 @@ -351,6 +356,7 @@ struct ext3_inode {
10211  #define i_gid_low      i_gid
10212  #define i_uid_high     osd2.linux2.l_i_uid_high
10213  #define i_gid_high     osd2.linux2.l_i_gid_high
10214 +#define i_raw_tag      osd2.linux2.l_i_tag
10215  #define i_reserved2    osd2.linux2.l_i_reserved2
10216  
10217  #elif defined(__GNU__)
10218 @@ -414,6 +420,7 @@ struct ext3_inode {
10219  #define EXT3_MOUNT_GRPQUOTA            0x200000 /* "old" group quota */
10220  #define EXT3_MOUNT_DATA_ERR_ABORT      0x400000 /* Abort on file data write
10221                                                   * error in ordered mode */
10222 +#define EXT3_MOUNT_TAGGED              (1<<24) /* Enable Context Tags */
10223  
10224  /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
10225  #ifndef _LINUX_EXT2_FS_H
10226 @@ -892,6 +899,7 @@ extern void ext3_get_inode_flags(struct 
10227  extern void ext3_set_aops(struct inode *inode);
10228  extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
10229                        u64 start, u64 len);
10230 +extern int ext3_sync_flags(struct inode *, int, int);
10231  
10232  /* ioctl.c */
10233  extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
10234 diff -NurpP --minimal linux-2.6.33.2/include/linux/fs.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/fs.h
10235 --- linux-2.6.33.2/include/linux/fs.h   2010-04-06 01:47:46.000000000 +0200
10236 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/fs.h   2010-04-06 01:59:25.000000000 +0200
10237 @@ -209,6 +209,9 @@ struct inodes_stat_t {
10238  #define MS_KERNMOUNT   (1<<22) /* this is a kern_mount call */
10239  #define MS_I_VERSION   (1<<23) /* Update inode I_version field */
10240  #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
10241 +#define MS_TAGGED      (1<<25) /* use generic inode tagging */
10242 +#define MS_TAGID       (1<<26) /* use specific tag for this mount */
10243 +#define MS_NOTAGCHECK  (1<<27) /* don't check tags */
10244  #define MS_ACTIVE      (1<<30)
10245  #define MS_NOUSER      (1<<31)
10246  
10247 @@ -235,6 +238,14 @@ struct inodes_stat_t {
10248  #define S_NOCMTIME     128     /* Do not update file c/mtime */
10249  #define S_SWAPFILE     256     /* Do not truncate: swapon got its bmaps */
10250  #define S_PRIVATE      512     /* Inode is fs-internal */
10251 +#define S_IXUNLINK     1024    /* Immutable Invert on unlink */
10252 +
10253 +/* Linux-VServer related Inode flags */
10254 +
10255 +#define V_VALID                1
10256 +#define V_XATTR                2
10257 +#define V_BARRIER      4       /* Barrier for chroot() */
10258 +#define V_COW          8       /* Copy on Write */
10259  
10260  /*
10261   * Note that nosuid etc flags are inode-specific: setting some file-system
10262 @@ -257,12 +268,15 @@ struct inodes_stat_t {
10263  #define IS_DIRSYNC(inode)      (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
10264                                         ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
10265  #define IS_MANDLOCK(inode)     __IS_FLG(inode, MS_MANDLOCK)
10266 -#define IS_NOATIME(inode)   __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10267 -#define IS_I_VERSION(inode)   __IS_FLG(inode, MS_I_VERSION)
10268 +#define IS_NOATIME(inode)      __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10269 +#define IS_I_VERSION(inode)    __IS_FLG(inode, MS_I_VERSION)
10270 +#define IS_TAGGED(inode)       __IS_FLG(inode, MS_TAGGED)
10271  
10272  #define IS_NOQUOTA(inode)      ((inode)->i_flags & S_NOQUOTA)
10273  #define IS_APPEND(inode)       ((inode)->i_flags & S_APPEND)
10274  #define IS_IMMUTABLE(inode)    ((inode)->i_flags & S_IMMUTABLE)
10275 +#define IS_IXUNLINK(inode)     ((inode)->i_flags & S_IXUNLINK)
10276 +#define IS_IXORUNLINK(inode)   ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
10277  #define IS_POSIXACL(inode)     __IS_FLG(inode, MS_POSIXACL)
10278  
10279  #define IS_DEADDIR(inode)      ((inode)->i_flags & S_DEAD)
10280 @@ -270,6 +284,16 @@ struct inodes_stat_t {
10281  #define IS_SWAPFILE(inode)     ((inode)->i_flags & S_SWAPFILE)
10282  #define IS_PRIVATE(inode)      ((inode)->i_flags & S_PRIVATE)
10283  
10284 +#define IS_BARRIER(inode)      (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
10285 +
10286 +#ifdef CONFIG_VSERVER_COWBL
10287 +#  define IS_COW(inode)                (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
10288 +#  define IS_COW_LINK(inode)   (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
10289 +#else
10290 +#  define IS_COW(inode)                (0)
10291 +#  define IS_COW_LINK(inode)   (0)
10292 +#endif
10293 +
10294  /* the read-only stuff doesn't really belong here, but any other place is
10295     probably as bad and I don't want to create yet another include file. */
10296  
10297 @@ -352,11 +376,14 @@ struct inodes_stat_t {
10298  #define FS_TOPDIR_FL                   0x00020000 /* Top of directory hierarchies*/
10299  #define FS_EXTENT_FL                   0x00080000 /* Extents */
10300  #define FS_DIRECTIO_FL                 0x00100000 /* Use direct i/o */
10301 +#define FS_IXUNLINK_FL                 0x08000000 /* Immutable invert on unlink */
10302  #define FS_RESERVED_FL                 0x80000000 /* reserved for ext2 lib */
10303  
10304 -#define FS_FL_USER_VISIBLE             0x0003DFFF /* User visible flags */
10305 -#define FS_FL_USER_MODIFIABLE          0x000380FF /* User modifiable flags */
10306 +#define FS_BARRIER_FL                  0x04000000 /* Barrier for chroot() */
10307 +#define FS_COW_FL                      0x20000000 /* Copy on Write marker */
10308  
10309 +#define FS_FL_USER_VISIBLE             0x0103DFFF /* User visible flags */
10310 +#define FS_FL_USER_MODIFIABLE          0x010380FF /* User modifiable flags */
10311  
10312  #define SYNC_FILE_RANGE_WAIT_BEFORE    1
10313  #define SYNC_FILE_RANGE_WRITE          2
10314 @@ -438,6 +465,7 @@ typedef void (dio_iodone_t)(struct kiocb
10315  #define ATTR_KILL_PRIV (1 << 14)
10316  #define ATTR_OPEN      (1 << 15) /* Truncating from open(O_TRUNC) */
10317  #define ATTR_TIMES_SET (1 << 16)
10318 +#define ATTR_TAG       (1 << 17)
10319  
10320  /*
10321   * This is the Inode Attributes structure, used for notify_change().  It
10322 @@ -453,6 +481,7 @@ struct iattr {
10323         umode_t         ia_mode;
10324         uid_t           ia_uid;
10325         gid_t           ia_gid;
10326 +       tag_t           ia_tag;
10327         loff_t          ia_size;
10328         struct timespec ia_atime;
10329         struct timespec ia_mtime;
10330 @@ -466,6 +495,9 @@ struct iattr {
10331         struct file     *ia_file;
10332  };
10333  
10334 +#define ATTR_FLAG_BARRIER      512     /* Barrier for chroot() */
10335 +#define ATTR_FLAG_IXUNLINK     1024    /* Immutable invert on unlink */
10336 +
10337  /*
10338   * Includes for diskquotas.
10339   */
10340 @@ -731,7 +763,9 @@ struct inode {
10341         unsigned int            i_nlink;
10342         uid_t                   i_uid;
10343         gid_t                   i_gid;
10344 +       tag_t                   i_tag;
10345         dev_t                   i_rdev;
10346 +       dev_t                   i_mdev;
10347         unsigned int            i_blkbits;
10348         u64                     i_version;
10349         loff_t                  i_size;
10350 @@ -778,7 +812,8 @@ struct inode {
10351         unsigned long           i_state;
10352         unsigned long           dirtied_when;   /* jiffies of first dirtying */
10353  
10354 -       unsigned int            i_flags;
10355 +       unsigned short          i_flags;
10356 +       unsigned short          i_vflags;
10357  
10358         atomic_t                i_writecount;
10359  #ifdef CONFIG_SECURITY
10360 @@ -866,12 +901,12 @@ static inline void i_size_write(struct i
10361  
10362  static inline unsigned iminor(const struct inode *inode)
10363  {
10364 -       return MINOR(inode->i_rdev);
10365 +       return MINOR(inode->i_mdev);
10366  }
10367  
10368  static inline unsigned imajor(const struct inode *inode)
10369  {
10370 -       return MAJOR(inode->i_rdev);
10371 +       return MAJOR(inode->i_mdev);
10372  }
10373  
10374  extern struct block_device *I_BDEV(struct inode *inode);
10375 @@ -930,6 +965,7 @@ struct file {
10376         loff_t                  f_pos;
10377         struct fown_struct      f_owner;
10378         const struct cred       *f_cred;
10379 +       xid_t                   f_xid;
10380         struct file_ra_state    f_ra;
10381  
10382         u64                     f_version;
10383 @@ -1071,6 +1107,7 @@ struct file_lock {
10384         struct file *fl_file;
10385         loff_t fl_start;
10386         loff_t fl_end;
10387 +       xid_t fl_xid;
10388  
10389         struct fasync_struct *  fl_fasync; /* for lease break notifications */
10390         unsigned long fl_break_time;    /* for nonblocking lease breaks */
10391 @@ -1532,6 +1569,7 @@ struct inode_operations {
10392         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
10393         ssize_t (*listxattr) (struct dentry *, char *, size_t);
10394         int (*removexattr) (struct dentry *, const char *);
10395 +       int (*sync_flags) (struct inode *, int, int);
10396         void (*truncate_range)(struct inode *, loff_t, loff_t);
10397         long (*fallocate)(struct inode *inode, int mode, loff_t offset,
10398                           loff_t len);
10399 @@ -1552,6 +1590,7 @@ extern ssize_t vfs_readv(struct file *, 
10400                 unsigned long, loff_t *);
10401  extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
10402                 unsigned long, loff_t *);
10403 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
10404  
10405  struct super_operations {
10406         struct inode *(*alloc_inode)(struct super_block *sb);
10407 @@ -2334,6 +2373,7 @@ extern int dcache_dir_open(struct inode 
10408  extern int dcache_dir_close(struct inode *, struct file *);
10409  extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
10410  extern int dcache_readdir(struct file *, void *, filldir_t);
10411 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
10412  extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
10413  extern int simple_statfs(struct dentry *, struct kstatfs *);
10414  extern int simple_link(struct dentry *, struct inode *, struct dentry *);
10415 diff -NurpP --minimal linux-2.6.33.2/include/linux/gfs2_ondisk.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/gfs2_ondisk.h
10416 --- linux-2.6.33.2/include/linux/gfs2_ondisk.h  2010-02-25 11:52:07.000000000 +0100
10417 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/gfs2_ondisk.h  2010-02-25 12:02:16.000000000 +0100
10418 @@ -239,6 +239,9 @@ enum {
10419         gfs2fl_NoAtime          = 7,
10420         gfs2fl_Sync             = 8,
10421         gfs2fl_System           = 9,
10422 +       gfs2fl_IXUnlink         = 16,
10423 +       gfs2fl_Barrier          = 17,
10424 +       gfs2fl_Cow              = 18,
10425         gfs2fl_TruncInProg      = 29,
10426         gfs2fl_InheritDirectio  = 30,
10427         gfs2fl_InheritJdata     = 31,
10428 @@ -255,6 +258,9 @@ enum {
10429  #define GFS2_DIF_NOATIME               0x00000080
10430  #define GFS2_DIF_SYNC                  0x00000100
10431  #define GFS2_DIF_SYSTEM                        0x00000200 /* New in gfs2 */
10432 +#define GFS2_DIF_IXUNLINK              0x00010000
10433 +#define GFS2_DIF_BARRIER               0x00020000
10434 +#define GFS2_DIF_COW                   0x00040000
10435  #define GFS2_DIF_TRUNC_IN_PROG         0x20000000 /* New in gfs2 */
10436  #define GFS2_DIF_INHERIT_DIRECTIO      0x40000000
10437  #define GFS2_DIF_INHERIT_JDATA         0x80000000
10438 diff -NurpP --minimal linux-2.6.33.2/include/linux/if_tun.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/if_tun.h
10439 --- linux-2.6.33.2/include/linux/if_tun.h       2009-12-03 20:02:55.000000000 +0100
10440 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/if_tun.h       2010-02-25 12:02:16.000000000 +0100
10441 @@ -48,6 +48,7 @@
10442  #define TUNGETIFF      _IOR('T', 210, unsigned int)
10443  #define TUNGETSNDBUF   _IOR('T', 211, int)
10444  #define TUNSETSNDBUF   _IOW('T', 212, int)
10445 +#define TUNSETNID     _IOW('T', 215, int)
10446  
10447  /* TUNSETIFF ifr flags */
10448  #define IFF_TUN                0x0001
10449 diff -NurpP --minimal linux-2.6.33.2/include/linux/init_task.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/init_task.h
10450 --- linux-2.6.33.2/include/linux/init_task.h    2010-02-25 11:52:07.000000000 +0100
10451 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/init_task.h    2010-02-25 12:02:16.000000000 +0100
10452 @@ -180,6 +180,10 @@ extern struct cred init_cred;
10453         INIT_FTRACE_GRAPH                                               \
10454         INIT_TRACE_RECURSION                                            \
10455         INIT_TASK_RCU_PREEMPT(tsk)                                      \
10456 +       .xid            = 0,                                            \
10457 +       .vx_info        = NULL,                                         \
10458 +       .nid            = 0,                                            \
10459 +       .nx_info        = NULL,                                         \
10460  }
10461  
10462  
10463 diff -NurpP --minimal linux-2.6.33.2/include/linux/ipc.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/ipc.h
10464 --- linux-2.6.33.2/include/linux/ipc.h  2009-12-03 20:02:55.000000000 +0100
10465 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/ipc.h  2010-02-25 12:02:16.000000000 +0100
10466 @@ -91,6 +91,7 @@ struct kern_ipc_perm
10467         key_t           key;
10468         uid_t           uid;
10469         gid_t           gid;
10470 +       xid_t           xid;
10471         uid_t           cuid;
10472         gid_t           cgid;
10473         mode_t          mode; 
10474 diff -NurpP --minimal linux-2.6.33.2/include/linux/Kbuild linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/Kbuild
10475 --- linux-2.6.33.2/include/linux/Kbuild 2010-02-25 11:52:07.000000000 +0100
10476 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/Kbuild 2010-02-25 12:02:16.000000000 +0100
10477 @@ -383,5 +383,8 @@ unifdef-y += xattr.h
10478  unifdef-y += xfrm.h
10479  
10480  objhdr-y += version.h
10481 +
10482 +header-y += vserver/
10483  header-y += wimax.h
10484  header-y += wimax/
10485 +
10486 diff -NurpP --minimal linux-2.6.33.2/include/linux/loop.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/loop.h
10487 --- linux-2.6.33.2/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
10488 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/loop.h 2010-02-25 12:02:16.000000000 +0100
10489 @@ -45,6 +45,7 @@ struct loop_device {
10490         struct loop_func_table *lo_encryption;
10491         __u32           lo_init[2];
10492         uid_t           lo_key_owner;   /* Who set the key */
10493 +       xid_t           lo_xid;
10494         int             (*ioctl)(struct loop_device *, int cmd, 
10495                                  unsigned long arg); 
10496  
10497 diff -NurpP --minimal linux-2.6.33.2/include/linux/magic.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/magic.h
10498 --- linux-2.6.33.2/include/linux/magic.h        2009-12-03 20:02:55.000000000 +0100
10499 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/magic.h        2010-02-25 12:02:16.000000000 +0100
10500 @@ -3,7 +3,7 @@
10501  
10502  #define ADFS_SUPER_MAGIC       0xadf5
10503  #define AFFS_SUPER_MAGIC       0xadff
10504 -#define AFS_SUPER_MAGIC                0x5346414F
10505 +#define AFS_SUPER_MAGIC                0x5346414F
10506  #define AUTOFS_SUPER_MAGIC     0x0187
10507  #define CODA_SUPER_MAGIC       0x73757245
10508  #define CRAMFS_MAGIC           0x28cd3d45      /* some random number */
10509 @@ -38,6 +38,7 @@
10510  #define NFS_SUPER_MAGIC                0x6969
10511  #define OPENPROM_SUPER_MAGIC   0x9fa1
10512  #define PROC_SUPER_MAGIC       0x9fa0
10513 +#define DEVPTS_SUPER_MAGIC     0x1cd1
10514  #define QNX4_SUPER_MAGIC       0x002f          /* qnx4 fs detection */
10515  
10516  #define REISERFS_SUPER_MAGIC   0x52654973      /* used by gcc */
10517 diff -NurpP --minimal linux-2.6.33.2/include/linux/major.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/major.h
10518 --- linux-2.6.33.2/include/linux/major.h        2009-09-10 15:26:25.000000000 +0200
10519 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/major.h        2010-02-25 12:02:16.000000000 +0100
10520 @@ -15,6 +15,7 @@
10521  #define HD_MAJOR               IDE0_MAJOR
10522  #define PTY_SLAVE_MAJOR                3
10523  #define TTY_MAJOR              4
10524 +#define VROOT_MAJOR            4
10525  #define TTYAUX_MAJOR           5
10526  #define LP_MAJOR               6
10527  #define VCS_MAJOR              7
10528 diff -NurpP --minimal linux-2.6.33.2/include/linux/memcontrol.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/memcontrol.h
10529 --- linux-2.6.33.2/include/linux/memcontrol.h   2010-02-25 11:52:07.000000000 +0100
10530 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/memcontrol.h   2010-02-25 12:02:16.000000000 +0100
10531 @@ -76,6 +76,13 @@ int task_in_mem_cgroup(struct task_struc
10532  extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
10533  extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
10534  
10535 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
10536 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
10537 +
10538 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
10539 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
10540 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
10541 +
10542  static inline
10543  int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
10544  {
10545 diff -NurpP --minimal linux-2.6.33.2/include/linux/mm_types.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/mm_types.h
10546 --- linux-2.6.33.2/include/linux/mm_types.h     2010-02-25 11:52:07.000000000 +0100
10547 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/mm_types.h     2010-02-25 12:02:16.000000000 +0100
10548 @@ -250,6 +250,7 @@ struct mm_struct {
10549  
10550         /* Architecture-specific MM context */
10551         mm_context_t context;
10552 +       struct vx_info *mm_vx_info;
10553  
10554         /* Swap token stuff */
10555         /*
10556 diff -NurpP --minimal linux-2.6.33.2/include/linux/mount.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/mount.h
10557 --- linux-2.6.33.2/include/linux/mount.h        2009-09-10 15:26:25.000000000 +0200
10558 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/mount.h        2010-02-25 12:02:16.000000000 +0100
10559 @@ -36,6 +36,9 @@ struct mnt_namespace;
10560  #define MNT_UNBINDABLE 0x2000  /* if the vfsmount is a unbindable mount */
10561  #define MNT_PNODE_MASK 0x3000  /* propagation flag mask */
10562  
10563 +#define MNT_TAGID      0x10000
10564 +#define MNT_NOTAG      0x20000
10565 +
10566  struct vfsmount {
10567         struct list_head mnt_hash;
10568         struct vfsmount *mnt_parent;    /* fs we are mounted on */
10569 @@ -70,6 +73,7 @@ struct vfsmount {
10570  #else
10571         int mnt_writers;
10572  #endif
10573 +       tag_t mnt_tag;                  /* tagging used for vfsmount */
10574  };
10575  
10576  static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
10577 diff -NurpP --minimal linux-2.6.33.2/include/linux/net.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/net.h
10578 --- linux-2.6.33.2/include/linux/net.h  2010-02-25 11:52:07.000000000 +0100
10579 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/net.h  2010-02-25 12:02:16.000000000 +0100
10580 @@ -70,6 +70,7 @@ struct net;
10581  #define SOCK_NOSPACE           2
10582  #define SOCK_PASSCRED          3
10583  #define SOCK_PASSSEC           4
10584 +#define SOCK_USER_SOCKET       5
10585  
10586  #ifndef ARCH_HAS_SOCKET_TYPES
10587  /**
10588 diff -NurpP --minimal linux-2.6.33.2/include/linux/nfs_mount.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/nfs_mount.h
10589 --- linux-2.6.33.2/include/linux/nfs_mount.h    2009-03-24 14:22:43.000000000 +0100
10590 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/nfs_mount.h    2010-02-25 12:02:16.000000000 +0100
10591 @@ -63,7 +63,8 @@ struct nfs_mount_data {
10592  #define NFS_MOUNT_SECFLAVOUR   0x2000  /* 5 */
10593  #define NFS_MOUNT_NORDIRPLUS   0x4000  /* 5 */
10594  #define NFS_MOUNT_UNSHARED     0x8000  /* 5 */
10595 -#define NFS_MOUNT_FLAGMASK     0xFFFF
10596 +#define NFS_MOUNT_TAGGED       0x10000 /* context tagging */
10597 +#define NFS_MOUNT_FLAGMASK     0x1FFFF
10598  
10599  /* The following are for internal use only */
10600  #define NFS_MOUNT_LOOKUP_CACHE_NONEG   0x10000
10601 diff -NurpP --minimal linux-2.6.33.2/include/linux/nsproxy.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/nsproxy.h
10602 --- linux-2.6.33.2/include/linux/nsproxy.h      2009-06-11 17:13:17.000000000 +0200
10603 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/nsproxy.h      2010-02-25 12:02:16.000000000 +0100
10604 @@ -3,6 +3,7 @@
10605  
10606  #include <linux/spinlock.h>
10607  #include <linux/sched.h>
10608 +#include <linux/vserver/debug.h>
10609  
10610  struct mnt_namespace;
10611  struct uts_namespace;
10612 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
10613  }
10614  
10615  int copy_namespaces(unsigned long flags, struct task_struct *tsk);
10616 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
10617  void exit_task_namespaces(struct task_struct *tsk);
10618  void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
10619  void free_nsproxy(struct nsproxy *ns);
10620  int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
10621         struct fs_struct *);
10622  
10623 -static inline void put_nsproxy(struct nsproxy *ns)
10624 +#define        get_nsproxy(n)  __get_nsproxy(n, __FILE__, __LINE__)
10625 +
10626 +static inline void __get_nsproxy(struct nsproxy *ns,
10627 +       const char *_file, int _line)
10628  {
10629 -       if (atomic_dec_and_test(&ns->count)) {
10630 -               free_nsproxy(ns);
10631 -       }
10632 +       vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
10633 +               ns, atomic_read(&ns->count), _file, _line);
10634 +       atomic_inc(&ns->count);
10635  }
10636  
10637 -static inline void get_nsproxy(struct nsproxy *ns)
10638 +#define        put_nsproxy(n)  __put_nsproxy(n, __FILE__, __LINE__)
10639 +
10640 +static inline void __put_nsproxy(struct nsproxy *ns,
10641 +       const char *_file, int _line)
10642  {
10643 -       atomic_inc(&ns->count);
10644 +       vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
10645 +               ns, atomic_read(&ns->count), _file, _line);
10646 +       if (atomic_dec_and_test(&ns->count)) {
10647 +               free_nsproxy(ns);
10648 +       }
10649  }
10650  
10651  #ifdef CONFIG_CGROUP_NS
10652 diff -NurpP --minimal linux-2.6.33.2/include/linux/pid.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/pid.h
10653 --- linux-2.6.33.2/include/linux/pid.h  2009-03-24 14:22:43.000000000 +0100
10654 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/pid.h  2010-02-25 12:02:16.000000000 +0100
10655 @@ -8,7 +8,8 @@ enum pid_type
10656         PIDTYPE_PID,
10657         PIDTYPE_PGID,
10658         PIDTYPE_SID,
10659 -       PIDTYPE_MAX
10660 +       PIDTYPE_MAX,
10661 +       PIDTYPE_REALPID
10662  };
10663  
10664  /*
10665 @@ -160,6 +161,7 @@ static inline pid_t pid_nr(struct pid *p
10666  }
10667  
10668  pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
10669 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
10670  pid_t pid_vnr(struct pid *pid);
10671  
10672  #define do_each_pid_task(pid, type, task)                              \
10673 diff -NurpP --minimal linux-2.6.33.2/include/linux/proc_fs.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/proc_fs.h
10674 --- linux-2.6.33.2/include/linux/proc_fs.h      2009-12-03 20:02:56.000000000 +0100
10675 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/proc_fs.h      2010-02-25 12:02:16.000000000 +0100
10676 @@ -56,6 +56,7 @@ struct proc_dir_entry {
10677         nlink_t nlink;
10678         uid_t uid;
10679         gid_t gid;
10680 +       int vx_flags;
10681         loff_t size;
10682         const struct inode_operations *proc_iops;
10683         /*
10684 @@ -250,12 +251,18 @@ kclist_add(struct kcore_list *new, void 
10685  extern void kclist_add(struct kcore_list *, void *, size_t, int type);
10686  #endif
10687  
10688 +struct vx_info;
10689 +struct nx_info;
10690 +
10691  union proc_op {
10692         int (*proc_get_link)(struct inode *, struct path *);
10693         int (*proc_read)(struct task_struct *task, char *page);
10694         int (*proc_show)(struct seq_file *m,
10695                 struct pid_namespace *ns, struct pid *pid,
10696                 struct task_struct *task);
10697 +       int (*proc_vs_read)(char *page);
10698 +       int (*proc_vxi_read)(struct vx_info *vxi, char *page);
10699 +       int (*proc_nxi_read)(struct nx_info *nxi, char *page);
10700  };
10701  
10702  struct ctl_table_header;
10703 @@ -263,6 +270,7 @@ struct ctl_table;
10704  
10705  struct proc_inode {
10706         struct pid *pid;
10707 +       int vx_flags;
10708         int fd;
10709         union proc_op op;
10710         struct proc_dir_entry *pde;
10711 diff -NurpP --minimal linux-2.6.33.2/include/linux/quotaops.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/quotaops.h
10712 --- linux-2.6.33.2/include/linux/quotaops.h     2010-04-06 01:47:46.000000000 +0200
10713 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/quotaops.h     2010-04-06 02:00:16.000000000 +0200
10714 @@ -8,6 +8,7 @@
10715  #define _LINUX_QUOTAOPS_
10716  
10717  #include <linux/fs.h>
10718 +#include <linux/vs_dlimit.h>
10719  
10720  static inline struct quota_info *sb_dqopt(struct super_block *sb)
10721  {
10722 @@ -157,10 +158,14 @@ static inline void vfs_dq_init(struct in
10723   * a transaction (deadlocks possible otherwise) */
10724  static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
10725  {
10726 +       if (dl_alloc_space(inode, nr))
10727 +               return 1;
10728         if (sb_any_quota_active(inode->i_sb)) {
10729                 /* Used space is updated in alloc_space() */
10730 -               if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
10731 +               if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) {
10732 +                       dl_free_space(inode, nr);
10733                         return 1;
10734 +               }
10735         }
10736         else
10737                 inode_add_bytes(inode, nr);
10738 @@ -177,10 +182,14 @@ static inline int vfs_dq_prealloc_space(
10739  
10740  static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
10741  {
10742 +       if (dl_alloc_space(inode, nr))
10743 +               return 1;
10744         if (sb_any_quota_active(inode->i_sb)) {
10745                 /* Used space is updated in alloc_space() */
10746 -               if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
10747 +               if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) {
10748 +                       dl_free_space(inode, nr);
10749                         return 1;
10750 +               }
10751         }
10752         else
10753                 inode_add_bytes(inode, nr);
10754 @@ -197,10 +206,14 @@ static inline int vfs_dq_alloc_space(str
10755  
10756  static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
10757  {
10758 +       if (dl_reserve_space(inode, nr))
10759 +               return 1;
10760         if (sb_any_quota_active(inode->i_sb)) {
10761                 /* Used space is updated in alloc_space() */
10762 -               if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA)
10763 +               if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA) {
10764 +                       dl_release_space(inode, nr);
10765                         return 1;
10766 +               }
10767         }
10768         else
10769                 inode_add_rsv_space(inode, nr);
10770 @@ -209,10 +222,14 @@ static inline int vfs_dq_reserve_space(s
10771  
10772  static inline int vfs_dq_alloc_inode(struct inode *inode)
10773  {
10774 +       if (dl_alloc_inode(inode))
10775 +               return 1;
10776         if (sb_any_quota_active(inode->i_sb)) {
10777                 vfs_dq_init(inode);
10778 -               if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
10779 +               if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
10780 +                       dl_free_inode(inode);
10781                         return 1;
10782 +               }
10783         }
10784         return 0;
10785  }
10786 @@ -222,9 +239,13 @@ static inline int vfs_dq_alloc_inode(str
10787   */
10788  static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
10789  {
10790 +       if (dl_claim_space(inode, nr))
10791 +               return 1;
10792         if (sb_any_quota_active(inode->i_sb)) {
10793 -               if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
10794 +               if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) {
10795 +                       dl_release_space(inode, nr);
10796                         return 1;
10797 +               }
10798         } else
10799                 inode_claim_rsv_space(inode, nr);
10800  
10801 @@ -242,6 +263,7 @@ void vfs_dq_release_reservation_space(st
10802                 inode->i_sb->dq_op->release_rsv(inode, nr);
10803         else
10804                 inode_sub_rsv_space(inode, nr);
10805 +       dl_release_space(inode, nr);
10806  }
10807  
10808  static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
10809 @@ -250,6 +272,7 @@ static inline void vfs_dq_free_space_nod
10810                 inode->i_sb->dq_op->free_space(inode, nr);
10811         else
10812                 inode_sub_bytes(inode, nr);
10813 +       dl_free_space(inode, nr);
10814  }
10815  
10816  static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
10817 @@ -262,6 +285,7 @@ static inline void vfs_dq_free_inode(str
10818  {
10819         if (sb_any_quota_active(inode->i_sb))
10820                 inode->i_sb->dq_op->free_inode(inode, 1);
10821 +       dl_free_inode(inode);
10822  }
10823  
10824  /* Cannot be called inside a transaction */
10825 @@ -365,6 +389,8 @@ static inline int vfs_dq_transfer(struct
10826  
10827  static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
10828  {
10829 +       if (dl_alloc_space(inode, nr))
10830 +               return 1;
10831         inode_add_bytes(inode, nr);
10832         return 0;
10833  }
10834 @@ -378,6 +404,8 @@ static inline int vfs_dq_prealloc_space(
10835  
10836  static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
10837  {
10838 +       if (dl_alloc_space(inode, nr))
10839 +               return 1;
10840         inode_add_bytes(inode, nr);
10841         return 0;
10842  }
10843 @@ -391,22 +419,28 @@ static inline int vfs_dq_alloc_space(str
10844  
10845  static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
10846  {
10847 +       if (dl_reserve_space(inode, nr))
10848 +               return 1;
10849         return 0;
10850  }
10851  
10852  static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
10853  {
10854 +       if (dl_claim_space(inode, nr))
10855 +               return 1;
10856         return vfs_dq_alloc_space(inode, nr);
10857  }
10858  
10859  static inline
10860  int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
10861  {
10862 +       dl_release_space(inode, nr);
10863         return 0;
10864  }
10865  
10866  static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
10867  {
10868 +       dl_free_space(inode, nr);
10869         inode_sub_bytes(inode, nr);
10870  }
10871  
10872 diff -NurpP --minimal linux-2.6.33.2/include/linux/reboot.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/reboot.h
10873 --- linux-2.6.33.2/include/linux/reboot.h       2008-12-25 00:26:37.000000000 +0100
10874 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/reboot.h       2010-02-25 12:02:16.000000000 +0100
10875 @@ -33,6 +33,7 @@
10876  #define        LINUX_REBOOT_CMD_RESTART2       0xA1B2C3D4
10877  #define        LINUX_REBOOT_CMD_SW_SUSPEND     0xD000FCE2
10878  #define        LINUX_REBOOT_CMD_KEXEC          0x45584543
10879 +#define        LINUX_REBOOT_CMD_OOM            0xDEADBEEF
10880  
10881  
10882  #ifdef __KERNEL__
10883 diff -NurpP --minimal linux-2.6.33.2/include/linux/reiserfs_fs.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/reiserfs_fs.h
10884 --- linux-2.6.33.2/include/linux/reiserfs_fs.h  2010-02-25 11:52:07.000000000 +0100
10885 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/reiserfs_fs.h  2010-02-25 12:02:16.000000000 +0100
10886 @@ -977,6 +977,11 @@ struct stat_data_v1 {
10887  #define REISERFS_COMPR_FL     FS_COMPR_FL
10888  #define REISERFS_NOTAIL_FL    FS_NOTAIL_FL
10889  
10890 +/* unfortunately reiserfs sdattr is only 16 bit */
10891 +#define REISERFS_IXUNLINK_FL  (FS_IXUNLINK_FL >> 16)
10892 +#define REISERFS_BARRIER_FL   (FS_BARRIER_FL >> 16)
10893 +#define REISERFS_COW_FL       (FS_COW_FL >> 16)
10894 +
10895  /* persistent flags that file inherits from the parent directory */
10896  #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL |        \
10897                                 REISERFS_SYNC_FL |      \
10898 @@ -986,6 +991,9 @@ struct stat_data_v1 {
10899                                 REISERFS_COMPR_FL |     \
10900                                 REISERFS_NOTAIL_FL )
10901  
10902 +#define REISERFS_FL_USER_VISIBLE       0x80FF
10903 +#define REISERFS_FL_USER_MODIFIABLE    0x80FF
10904 +
10905  /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10906     address blocks) */
10907  struct stat_data {
10908 @@ -2071,6 +2079,7 @@ static inline void reiserfs_update_sd(st
10909  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10910  void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10911  int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10912 +int reiserfs_sync_flags(struct inode *inode, int, int);
10913  
10914  /* namei.c */
10915  void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
10916 diff -NurpP --minimal linux-2.6.33.2/include/linux/reiserfs_fs_sb.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/reiserfs_fs_sb.h
10917 --- linux-2.6.33.2/include/linux/reiserfs_fs_sb.h       2010-02-25 11:52:07.000000000 +0100
10918 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/reiserfs_fs_sb.h       2010-02-25 12:02:16.000000000 +0100
10919 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
10920         REISERFS_EXPOSE_PRIVROOT,
10921         REISERFS_BARRIER_NONE,
10922         REISERFS_BARRIER_FLUSH,
10923 +       REISERFS_TAGGED,
10924  
10925         /* Actions on error */
10926         REISERFS_ERROR_PANIC,
10927 diff -NurpP --minimal linux-2.6.33.2/include/linux/sched.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/sched.h
10928 --- linux-2.6.33.2/include/linux/sched.h        2010-04-06 01:47:46.000000000 +0200
10929 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/sched.h        2010-04-06 01:59:25.000000000 +0200
10930 @@ -401,25 +401,28 @@ static inline void arch_pick_mmap_layout
10931   * The mm counters are not protected by its page_table_lock,
10932   * so must be incremented atomically.
10933   */
10934 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
10935 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
10936 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
10937 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
10938 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
10939 +#define __set_mm_counter(mm, member, value) \
10940 +       atomic_long_set(&(mm)->_##member, value)
10941 +#define get_mm_counter(mm, member) \
10942 +       ((unsigned long)atomic_long_read(&(mm)->_##member))
10943  
10944  #else  /* !USE_SPLIT_PTLOCKS */
10945  /*
10946   * The mm counters are protected by its page_table_lock,
10947   * so can be incremented directly.
10948   */
10949 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
10950 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
10951  #define get_mm_counter(mm, member) ((mm)->_##member)
10952 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
10953 -#define inc_mm_counter(mm, member) (mm)->_##member++
10954 -#define dec_mm_counter(mm, member) (mm)->_##member--
10955  
10956  #endif /* !USE_SPLIT_PTLOCKS */
10957  
10958 +#define set_mm_counter(mm, member, value) \
10959 +       vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
10960 +#define add_mm_counter(mm, member, value) \
10961 +       vx_ ## member ## pages_add((mm), (value))
10962 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
10963 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
10964 +
10965  #define get_mm_rss(mm)                                 \
10966         (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
10967  #define update_hiwater_rss(mm) do {                    \
10968 @@ -1415,6 +1418,14 @@ struct task_struct {
10969  #endif
10970         seccomp_t seccomp;
10971  
10972 +/* vserver context data */
10973 +       struct vx_info *vx_info;
10974 +       struct nx_info *nx_info;
10975 +
10976 +       xid_t xid;
10977 +       nid_t nid;
10978 +       tag_t tag;
10979 +
10980  /* Thread group tracking */
10981         u32 parent_exec_id;
10982         u32 self_exec_id;
10983 @@ -1648,6 +1659,11 @@ struct pid_namespace;
10984  pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
10985                         struct pid_namespace *ns);
10986  
10987 +#include <linux/vserver/base.h>
10988 +#include <linux/vserver/context.h>
10989 +#include <linux/vserver/debug.h>
10990 +#include <linux/vserver/pid.h>
10991 +
10992  static inline pid_t task_pid_nr(struct task_struct *tsk)
10993  {
10994         return tsk->pid;
10995 @@ -1661,7 +1677,8 @@ static inline pid_t task_pid_nr_ns(struc
10996  
10997  static inline pid_t task_pid_vnr(struct task_struct *tsk)
10998  {
10999 -       return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
11000 +       // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
11001 +       return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
11002  }
11003  
11004  
11005 @@ -1674,7 +1691,7 @@ pid_t task_tgid_nr_ns(struct task_struct
11006  
11007  static inline pid_t task_tgid_vnr(struct task_struct *tsk)
11008  {
11009 -       return pid_vnr(task_tgid(tsk));
11010 +       return vx_map_tgid(pid_vnr(task_tgid(tsk)));
11011  }
11012  
11013  
11014 diff -NurpP --minimal linux-2.6.33.2/include/linux/shmem_fs.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/shmem_fs.h
11015 --- linux-2.6.33.2/include/linux/shmem_fs.h     2010-02-25 11:52:08.000000000 +0100
11016 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/shmem_fs.h     2010-02-25 12:02:16.000000000 +0100
11017 @@ -8,6 +8,9 @@
11018  
11019  #define SHMEM_NR_DIRECT 16
11020  
11021 +#define TMPFS_SUPER_MAGIC      0x01021994
11022 +
11023 +
11024  struct shmem_inode_info {
11025         spinlock_t              lock;
11026         unsigned long           flags;
11027 diff -NurpP --minimal linux-2.6.33.2/include/linux/stat.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/stat.h
11028 --- linux-2.6.33.2/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
11029 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/stat.h 2010-02-25 12:02:16.000000000 +0100
11030 @@ -66,6 +66,7 @@ struct kstat {
11031         unsigned int    nlink;
11032         uid_t           uid;
11033         gid_t           gid;
11034 +       tag_t           tag;
11035         dev_t           rdev;
11036         loff_t          size;
11037         struct timespec  atime;
11038 diff -NurpP --minimal linux-2.6.33.2/include/linux/sunrpc/auth.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/sunrpc/auth.h
11039 --- linux-2.6.33.2/include/linux/sunrpc/auth.h  2009-12-03 20:02:56.000000000 +0100
11040 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/sunrpc/auth.h  2010-02-25 12:02:16.000000000 +0100
11041 @@ -25,6 +25,7 @@
11042  struct auth_cred {
11043         uid_t   uid;
11044         gid_t   gid;
11045 +       tag_t   tag;
11046         struct group_info *group_info;
11047         unsigned char machine_cred : 1;
11048  };
11049 diff -NurpP --minimal linux-2.6.33.2/include/linux/sunrpc/clnt.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/sunrpc/clnt.h
11050 --- linux-2.6.33.2/include/linux/sunrpc/clnt.h  2009-12-03 20:02:56.000000000 +0100
11051 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/sunrpc/clnt.h  2010-02-25 12:02:16.000000000 +0100
11052 @@ -49,7 +49,8 @@ struct rpc_clnt {
11053         unsigned int            cl_softrtry : 1,/* soft timeouts */
11054                                 cl_discrtry : 1,/* disconnect before retry */
11055                                 cl_autobind : 1,/* use getport() */
11056 -                               cl_chatty   : 1;/* be verbose */
11057 +                               cl_chatty   : 1,/* be verbose */
11058 +                               cl_tag      : 1;/* context tagging */
11059  
11060         struct rpc_rtt *        cl_rtt;         /* RTO estimator data */
11061         const struct rpc_timeout *cl_timeout;   /* Timeout strategy */
11062 diff -NurpP --minimal linux-2.6.33.2/include/linux/syscalls.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/syscalls.h
11063 --- linux-2.6.33.2/include/linux/syscalls.h     2010-04-06 01:47:46.000000000 +0200
11064 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/syscalls.h     2010-04-06 01:59:25.000000000 +0200
11065 @@ -498,6 +498,8 @@ asmlinkage long sys_symlink(const char _
11066  asmlinkage long sys_unlink(const char __user *pathname);
11067  asmlinkage long sys_rename(const char __user *oldname,
11068                                 const char __user *newname);
11069 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
11070 +                               umode_t mode);
11071  asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
11072  asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
11073  
11074 diff -NurpP --minimal linux-2.6.33.2/include/linux/sysctl.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/sysctl.h
11075 --- linux-2.6.33.2/include/linux/sysctl.h       2010-02-25 11:52:08.000000000 +0100
11076 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/sysctl.h       2010-02-25 12:02:16.000000000 +0100
11077 @@ -60,6 +60,7 @@ enum
11078         CTL_ABI=9,              /* Binary emulation */
11079         CTL_CPU=10,             /* CPU stuff (speed scaling, etc) */
11080         CTL_ARLAN=254,          /* arlan wireless driver */
11081 +       CTL_VSERVER=4242,       /* Linux-VServer debug */
11082         CTL_S390DBF=5677,       /* s390 debug */
11083         CTL_SUNRPC=7249,        /* sunrpc debug */
11084         CTL_PM=9899,            /* frv power management */
11085 @@ -94,6 +95,7 @@ enum
11086  
11087         KERN_PANIC=15,          /* int: panic timeout */
11088         KERN_REALROOTDEV=16,    /* real root device to mount after initrd */
11089 +       KERN_VSHELPER=17,       /* string: path to vshelper policy agent */
11090  
11091         KERN_SPARC_REBOOT=21,   /* reboot command on Sparc */
11092         KERN_CTLALTDEL=22,      /* int: allow ctl-alt-del to reboot */
11093 diff -NurpP --minimal linux-2.6.33.2/include/linux/sysfs.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/sysfs.h
11094 --- linux-2.6.33.2/include/linux/sysfs.h        2010-02-25 11:52:08.000000000 +0100
11095 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/sysfs.h        2010-02-25 12:02:16.000000000 +0100
11096 @@ -17,6 +17,8 @@
11097  #include <linux/list.h>
11098  #include <asm/atomic.h>
11099  
11100 +#define SYSFS_SUPER_MAGIC      0x62656572
11101 +
11102  struct kobject;
11103  struct module;
11104  
11105 diff -NurpP --minimal linux-2.6.33.2/include/linux/time.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/time.h
11106 --- linux-2.6.33.2/include/linux/time.h 2010-02-25 11:52:08.000000000 +0100
11107 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/time.h 2010-02-25 12:02:16.000000000 +0100
11108 @@ -238,6 +238,9 @@ static __always_inline void timespec_add
11109         a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
11110         a->tv_nsec = ns;
11111  }
11112 +
11113 +#include <linux/vs_time.h>
11114 +
11115  #endif /* __KERNEL__ */
11116  
11117  #define NFDBITS                        __NFDBITS
11118 diff -NurpP --minimal linux-2.6.33.2/include/linux/types.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/types.h
11119 --- linux-2.6.33.2/include/linux/types.h        2009-09-10 15:26:26.000000000 +0200
11120 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/types.h        2010-02-25 12:02:16.000000000 +0100
11121 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t      uid_t;
11122  typedef __kernel_gid32_t       gid_t;
11123  typedef __kernel_uid16_t        uid16_t;
11124  typedef __kernel_gid16_t        gid16_t;
11125 +typedef unsigned int           xid_t;
11126 +typedef unsigned int           nid_t;
11127 +typedef unsigned int           tag_t;
11128  
11129  typedef unsigned long          uintptr_t;
11130  
11131 diff -NurpP --minimal linux-2.6.33.2/include/linux/vroot.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vroot.h
11132 --- linux-2.6.33.2/include/linux/vroot.h        1970-01-01 01:00:00.000000000 +0100
11133 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vroot.h        2010-02-25 12:02:16.000000000 +0100
11134 @@ -0,0 +1,51 @@
11135 +
11136 +/*
11137 + * include/linux/vroot.h
11138 + *
11139 + * written by Herbert Pötzl, 9/11/2002
11140 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
11141 + *
11142 + * Copyright (C) 2002-2007 by Herbert Pötzl.
11143 + * Redistribution of this file is permitted under the
11144 + * GNU General Public License.
11145 + */
11146 +
11147 +#ifndef _LINUX_VROOT_H
11148 +#define _LINUX_VROOT_H
11149 +
11150 +
11151 +#ifdef __KERNEL__
11152 +
11153 +/* Possible states of device */
11154 +enum {
11155 +       Vr_unbound,
11156 +       Vr_bound,
11157 +};
11158 +
11159 +struct vroot_device {
11160 +       int             vr_number;
11161 +       int             vr_refcnt;
11162 +
11163 +       struct semaphore        vr_ctl_mutex;
11164 +       struct block_device    *vr_device;
11165 +       int                     vr_state;
11166 +};
11167 +
11168 +
11169 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
11170 +
11171 +extern int register_vroot_grb(vroot_grb_func *);
11172 +extern int unregister_vroot_grb(vroot_grb_func *);
11173 +
11174 +#endif /* __KERNEL__ */
11175 +
11176 +#define MAX_VROOT_DEFAULT      8
11177 +
11178 +/*
11179 + * IOCTL commands --- we will commandeer 0x56 ('V')
11180 + */
11181 +
11182 +#define VROOT_SET_DEV          0x5600
11183 +#define VROOT_CLR_DEV          0x5601
11184 +
11185 +#endif /* _LINUX_VROOT_H */
11186 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_base.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_base.h
11187 --- linux-2.6.33.2/include/linux/vs_base.h      1970-01-01 01:00:00.000000000 +0100
11188 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_base.h      2010-02-25 12:02:16.000000000 +0100
11189 @@ -0,0 +1,10 @@
11190 +#ifndef _VS_BASE_H
11191 +#define _VS_BASE_H
11192 +
11193 +#include "vserver/base.h"
11194 +#include "vserver/check.h"
11195 +#include "vserver/debug.h"
11196 +
11197 +#else
11198 +#warning duplicate inclusion
11199 +#endif
11200 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_context.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_context.h
11201 --- linux-2.6.33.2/include/linux/vs_context.h   1970-01-01 01:00:00.000000000 +0100
11202 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_context.h   2010-02-25 12:02:16.000000000 +0100
11203 @@ -0,0 +1,242 @@
11204 +#ifndef _VS_CONTEXT_H
11205 +#define _VS_CONTEXT_H
11206 +
11207 +#include "vserver/base.h"
11208 +#include "vserver/check.h"
11209 +#include "vserver/context.h"
11210 +#include "vserver/history.h"
11211 +#include "vserver/debug.h"
11212 +
11213 +#include <linux/sched.h>
11214 +
11215 +
11216 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
11217 +
11218 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
11219 +       const char *_file, int _line, void *_here)
11220 +{
11221 +       if (!vxi)
11222 +               return NULL;
11223 +
11224 +       vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
11225 +               vxi, vxi ? vxi->vx_id : 0,
11226 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11227 +               _file, _line);
11228 +       __vxh_get_vx_info(vxi, _here);
11229 +
11230 +       atomic_inc(&vxi->vx_usecnt);
11231 +       return vxi;
11232 +}
11233 +
11234 +
11235 +extern void free_vx_info(struct vx_info *);
11236 +
11237 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
11238 +
11239 +static inline void __put_vx_info(struct vx_info *vxi,
11240 +       const char *_file, int _line, void *_here)
11241 +{
11242 +       if (!vxi)
11243 +               return;
11244 +
11245 +       vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
11246 +               vxi, vxi ? vxi->vx_id : 0,
11247 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11248 +               _file, _line);
11249 +       __vxh_put_vx_info(vxi, _here);
11250 +
11251 +       if (atomic_dec_and_test(&vxi->vx_usecnt))
11252 +               free_vx_info(vxi);
11253 +}
11254 +
11255 +
11256 +#define init_vx_info(p, i) \
11257 +       __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11258 +
11259 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11260 +       const char *_file, int _line, void *_here)
11261 +{
11262 +       if (vxi) {
11263 +               vxlprintk(VXD_CBIT(xid, 3),
11264 +                       "init_vx_info(%p[#%d.%d])",
11265 +                       vxi, vxi ? vxi->vx_id : 0,
11266 +                       vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11267 +                       _file, _line);
11268 +               __vxh_init_vx_info(vxi, vxp, _here);
11269 +
11270 +               atomic_inc(&vxi->vx_usecnt);
11271 +       }
11272 +       *vxp = vxi;
11273 +}
11274 +
11275 +
11276 +#define set_vx_info(p, i) \
11277 +       __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11278 +
11279 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11280 +       const char *_file, int _line, void *_here)
11281 +{
11282 +       struct vx_info *vxo;
11283 +
11284 +       if (!vxi)
11285 +               return;
11286 +
11287 +       vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
11288 +               vxi, vxi ? vxi->vx_id : 0,
11289 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11290 +               _file, _line);
11291 +       __vxh_set_vx_info(vxi, vxp, _here);
11292 +
11293 +       atomic_inc(&vxi->vx_usecnt);
11294 +       vxo = xchg(vxp, vxi);
11295 +       BUG_ON(vxo);
11296 +}
11297 +
11298 +
11299 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
11300 +
11301 +static inline void __clr_vx_info(struct vx_info **vxp,
11302 +       const char *_file, int _line, void *_here)
11303 +{
11304 +       struct vx_info *vxo;
11305 +
11306 +       vxo = xchg(vxp, NULL);
11307 +       if (!vxo)
11308 +               return;
11309 +
11310 +       vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
11311 +               vxo, vxo ? vxo->vx_id : 0,
11312 +               vxo ? atomic_read(&vxo->vx_usecnt) : 0,
11313 +               _file, _line);
11314 +       __vxh_clr_vx_info(vxo, vxp, _here);
11315 +
11316 +       if (atomic_dec_and_test(&vxo->vx_usecnt))
11317 +               free_vx_info(vxo);
11318 +}
11319 +
11320 +
11321 +#define claim_vx_info(v, p) \
11322 +       __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11323 +
11324 +static inline void __claim_vx_info(struct vx_info *vxi,
11325 +       struct task_struct *task,
11326 +       const char *_file, int _line, void *_here)
11327 +{
11328 +       vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
11329 +               vxi, vxi ? vxi->vx_id : 0,
11330 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11331 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11332 +               task, _file, _line);
11333 +       __vxh_claim_vx_info(vxi, task, _here);
11334 +
11335 +       atomic_inc(&vxi->vx_tasks);
11336 +}
11337 +
11338 +
11339 +extern void unhash_vx_info(struct vx_info *);
11340 +
11341 +#define release_vx_info(v, p) \
11342 +       __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11343 +
11344 +static inline void __release_vx_info(struct vx_info *vxi,
11345 +       struct task_struct *task,
11346 +       const char *_file, int _line, void *_here)
11347 +{
11348 +       vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
11349 +               vxi, vxi ? vxi->vx_id : 0,
11350 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11351 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11352 +               task, _file, _line);
11353 +       __vxh_release_vx_info(vxi, task, _here);
11354 +
11355 +       might_sleep();
11356 +
11357 +       if (atomic_dec_and_test(&vxi->vx_tasks))
11358 +               unhash_vx_info(vxi);
11359 +}
11360 +
11361 +
11362 +#define task_get_vx_info(p) \
11363 +       __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
11364 +
11365 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
11366 +       const char *_file, int _line, void *_here)
11367 +{
11368 +       struct vx_info *vxi;
11369 +
11370 +       task_lock(p);
11371 +       vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
11372 +               p, _file, _line);
11373 +       vxi = __get_vx_info(p->vx_info, _file, _line, _here);
11374 +       task_unlock(p);
11375 +       return vxi;
11376 +}
11377 +
11378 +
11379 +static inline void __wakeup_vx_info(struct vx_info *vxi)
11380 +{
11381 +       if (waitqueue_active(&vxi->vx_wait))
11382 +               wake_up_interruptible(&vxi->vx_wait);
11383 +}
11384 +
11385 +
11386 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
11387 +
11388 +static inline void __enter_vx_info(struct vx_info *vxi,
11389 +       struct vx_info_save *vxis, const char *_file, int _line)
11390 +{
11391 +       vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
11392 +               vxi, vxi ? vxi->vx_id : 0, vxis, current,
11393 +               current->xid, current->vx_info, _file, _line);
11394 +       vxis->vxi = xchg(&current->vx_info, vxi);
11395 +       vxis->xid = current->xid;
11396 +       current->xid = vxi ? vxi->vx_id : 0;
11397 +}
11398 +
11399 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
11400 +
11401 +static inline void __leave_vx_info(struct vx_info_save *vxis,
11402 +       const char *_file, int _line)
11403 +{
11404 +       vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
11405 +               vxis, vxis->xid, vxis->vxi, current,
11406 +               current->xid, current->vx_info, _file, _line);
11407 +       (void)xchg(&current->vx_info, vxis->vxi);
11408 +       current->xid = vxis->xid;
11409 +}
11410 +
11411 +
11412 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
11413 +{
11414 +       vxis->vxi = xchg(&current->vx_info, NULL);
11415 +       vxis->xid = xchg(&current->xid, (xid_t)0);
11416 +}
11417 +
11418 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
11419 +{
11420 +       (void)xchg(&current->xid, vxis->xid);
11421 +       (void)xchg(&current->vx_info, vxis->vxi);
11422 +}
11423 +
11424 +#define task_is_init(p) \
11425 +       __task_is_init(p, __FILE__, __LINE__, __HERE__)
11426 +
11427 +static inline int __task_is_init(struct task_struct *p,
11428 +       const char *_file, int _line, void *_here)
11429 +{
11430 +       int is_init = is_global_init(p);
11431 +
11432 +       task_lock(p);
11433 +       if (p->vx_info)
11434 +               is_init = p->vx_info->vx_initpid == p->pid;
11435 +       task_unlock(p);
11436 +       return is_init;
11437 +}
11438 +
11439 +extern void exit_vx_info(struct task_struct *, int);
11440 +extern void exit_vx_info_early(struct task_struct *, int);
11441 +
11442 +
11443 +#else
11444 +#warning duplicate inclusion
11445 +#endif
11446 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_cowbl.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_cowbl.h
11447 --- linux-2.6.33.2/include/linux/vs_cowbl.h     1970-01-01 01:00:00.000000000 +0100
11448 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_cowbl.h     2010-02-25 12:02:16.000000000 +0100
11449 @@ -0,0 +1,47 @@
11450 +#ifndef _VS_COWBL_H
11451 +#define _VS_COWBL_H
11452 +
11453 +#include <linux/fs.h>
11454 +#include <linux/dcache.h>
11455 +#include <linux/namei.h>
11456 +
11457 +extern struct dentry *cow_break_link(const char *pathname);
11458 +
11459 +static inline int cow_check_and_break(struct path *path)
11460 +{
11461 +       struct inode *inode = path->dentry->d_inode;
11462 +       int error = 0;
11463 +
11464 +       /* do we need this check? */
11465 +       if (IS_RDONLY(inode))
11466 +               return -EROFS;
11467 +
11468 +       if (IS_COW(inode)) {
11469 +               if (IS_COW_LINK(inode)) {
11470 +                       struct dentry *new_dentry, *old_dentry = path->dentry;
11471 +                       char *pp, *buf;
11472 +
11473 +                       buf = kmalloc(PATH_MAX, GFP_KERNEL);
11474 +                       if (!buf) {
11475 +                               return -ENOMEM;
11476 +                       }
11477 +                       pp = d_path(path, buf, PATH_MAX);
11478 +                       new_dentry = cow_break_link(pp);
11479 +                       kfree(buf);
11480 +                       if (!IS_ERR(new_dentry)) {
11481 +                               path->dentry = new_dentry;
11482 +                               dput(old_dentry);
11483 +                       } else
11484 +                               error = PTR_ERR(new_dentry);
11485 +               } else {
11486 +                       inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
11487 +                       inode->i_ctime = CURRENT_TIME;
11488 +                       mark_inode_dirty(inode);
11489 +               }
11490 +       }
11491 +       return error;
11492 +}
11493 +
11494 +#else
11495 +#warning duplicate inclusion
11496 +#endif
11497 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_cvirt.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_cvirt.h
11498 --- linux-2.6.33.2/include/linux/vs_cvirt.h     1970-01-01 01:00:00.000000000 +0100
11499 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_cvirt.h     2010-02-25 12:02:16.000000000 +0100
11500 @@ -0,0 +1,50 @@
11501 +#ifndef _VS_CVIRT_H
11502 +#define _VS_CVIRT_H
11503 +
11504 +#include "vserver/cvirt.h"
11505 +#include "vserver/context.h"
11506 +#include "vserver/base.h"
11507 +#include "vserver/check.h"
11508 +#include "vserver/debug.h"
11509 +
11510 +
11511 +static inline void vx_activate_task(struct task_struct *p)
11512 +{
11513 +       struct vx_info *vxi;
11514 +
11515 +       if ((vxi = p->vx_info)) {
11516 +               vx_update_load(vxi);
11517 +               atomic_inc(&vxi->cvirt.nr_running);
11518 +       }
11519 +}
11520 +
11521 +static inline void vx_deactivate_task(struct task_struct *p)
11522 +{
11523 +       struct vx_info *vxi;
11524 +
11525 +       if ((vxi = p->vx_info)) {
11526 +               vx_update_load(vxi);
11527 +               atomic_dec(&vxi->cvirt.nr_running);
11528 +       }
11529 +}
11530 +
11531 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11532 +{
11533 +       struct vx_info *vxi;
11534 +
11535 +       if ((vxi = p->vx_info))
11536 +               atomic_inc(&vxi->cvirt.nr_uninterruptible);
11537 +}
11538 +
11539 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11540 +{
11541 +       struct vx_info *vxi;
11542 +
11543 +       if ((vxi = p->vx_info))
11544 +               atomic_dec(&vxi->cvirt.nr_uninterruptible);
11545 +}
11546 +
11547 +
11548 +#else
11549 +#warning duplicate inclusion
11550 +#endif
11551 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_device.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_device.h
11552 --- linux-2.6.33.2/include/linux/vs_device.h    1970-01-01 01:00:00.000000000 +0100
11553 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_device.h    2010-02-25 12:02:16.000000000 +0100
11554 @@ -0,0 +1,45 @@
11555 +#ifndef _VS_DEVICE_H
11556 +#define _VS_DEVICE_H
11557 +
11558 +#include "vserver/base.h"
11559 +#include "vserver/device.h"
11560 +#include "vserver/debug.h"
11561 +
11562 +
11563 +#ifdef CONFIG_VSERVER_DEVICE
11564 +
11565 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
11566 +
11567 +#define vs_device_perm(v, d, m, p) \
11568 +       ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
11569 +
11570 +#else
11571 +
11572 +static inline
11573 +int vs_map_device(struct vx_info *vxi,
11574 +       dev_t device, dev_t *target, umode_t mode)
11575 +{
11576 +       if (target)
11577 +               *target = device;
11578 +       return ~0;
11579 +}
11580 +
11581 +#define vs_device_perm(v, d, m, p) ((p) == (p))
11582 +
11583 +#endif
11584 +
11585 +
11586 +#define vs_map_chrdev(d, t, p) \
11587 +       ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
11588 +#define vs_map_blkdev(d, t, p) \
11589 +       ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
11590 +
11591 +#define vs_chrdev_perm(d, p) \
11592 +       vs_device_perm(current_vx_info(), d, S_IFCHR, p)
11593 +#define vs_blkdev_perm(d, p) \
11594 +       vs_device_perm(current_vx_info(), d, S_IFBLK, p)
11595 +
11596 +
11597 +#else
11598 +#warning duplicate inclusion
11599 +#endif
11600 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_dlimit.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_dlimit.h
11601 --- linux-2.6.33.2/include/linux/vs_dlimit.h    1970-01-01 01:00:00.000000000 +0100
11602 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_dlimit.h    2010-03-21 06:38:55.000000000 +0100
11603 @@ -0,0 +1,215 @@
11604 +#ifndef _VS_DLIMIT_H
11605 +#define _VS_DLIMIT_H
11606 +
11607 +#include <linux/fs.h>
11608 +
11609 +#include "vserver/dlimit.h"
11610 +#include "vserver/base.h"
11611 +#include "vserver/debug.h"
11612 +
11613 +
11614 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11615 +
11616 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11617 +       const char *_file, int _line)
11618 +{
11619 +       if (!dli)
11620 +               return NULL;
11621 +       vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11622 +               dli, dli ? dli->dl_tag : 0,
11623 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11624 +               _file, _line);
11625 +       atomic_inc(&dli->dl_usecnt);
11626 +       return dli;
11627 +}
11628 +
11629 +
11630 +#define free_dl_info(i) \
11631 +       call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11632 +
11633 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11634 +
11635 +static inline void __put_dl_info(struct dl_info *dli,
11636 +       const char *_file, int _line)
11637 +{
11638 +       if (!dli)
11639 +               return;
11640 +       vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11641 +               dli, dli ? dli->dl_tag : 0,
11642 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11643 +               _file, _line);
11644 +       if (atomic_dec_and_test(&dli->dl_usecnt))
11645 +               free_dl_info(dli);
11646 +}
11647 +
11648 +
11649 +#define __dlimit_char(d)       ((d) ? '*' : ' ')
11650 +
11651 +static inline int __dl_alloc_space(struct super_block *sb,
11652 +       tag_t tag, dlsize_t nr, const char *file, int line)
11653 +{
11654 +       struct dl_info *dli = NULL;
11655 +       int ret = 0;
11656 +
11657 +       if (nr == 0)
11658 +               goto out;
11659 +       dli = locate_dl_info(sb, tag);
11660 +       if (!dli)
11661 +               goto out;
11662 +
11663 +       spin_lock(&dli->dl_lock);
11664 +       ret = (dli->dl_space_used + nr > dli->dl_space_total);
11665 +       if (!ret)
11666 +               dli->dl_space_used += nr;
11667 +       spin_unlock(&dli->dl_lock);
11668 +       put_dl_info(dli);
11669 +out:
11670 +       vxlprintk(VXD_CBIT(dlim, 1),
11671 +               "ALLOC (%p,#%d)%c %lld bytes (%d)",
11672 +               sb, tag, __dlimit_char(dli), (long long)nr,
11673 +               ret, file, line);
11674 +       return ret;
11675 +}
11676 +
11677 +static inline void __dl_free_space(struct super_block *sb,
11678 +       tag_t tag, dlsize_t nr, const char *_file, int _line)
11679 +{
11680 +       struct dl_info *dli = NULL;
11681 +
11682 +       if (nr == 0)
11683 +               goto out;
11684 +       dli = locate_dl_info(sb, tag);
11685 +       if (!dli)
11686 +               goto out;
11687 +
11688 +       spin_lock(&dli->dl_lock);
11689 +       if (dli->dl_space_used > nr)
11690 +               dli->dl_space_used -= nr;
11691 +       else
11692 +               dli->dl_space_used = 0;
11693 +       spin_unlock(&dli->dl_lock);
11694 +       put_dl_info(dli);
11695 +out:
11696 +       vxlprintk(VXD_CBIT(dlim, 1),
11697 +               "FREE  (%p,#%d)%c %lld bytes",
11698 +               sb, tag, __dlimit_char(dli), (long long)nr,
11699 +               _file, _line);
11700 +}
11701 +
11702 +static inline int __dl_alloc_inode(struct super_block *sb,
11703 +       tag_t tag, const char *_file, int _line)
11704 +{
11705 +       struct dl_info *dli;
11706 +       int ret = 0;
11707 +
11708 +       dli = locate_dl_info(sb, tag);
11709 +       if (!dli)
11710 +               goto out;
11711 +
11712 +       spin_lock(&dli->dl_lock);
11713 +       dli->dl_inodes_used++;
11714 +       ret = (dli->dl_inodes_used > dli->dl_inodes_total);
11715 +       spin_unlock(&dli->dl_lock);
11716 +       put_dl_info(dli);
11717 +out:
11718 +       vxlprintk(VXD_CBIT(dlim, 0),
11719 +               "ALLOC (%p,#%d)%c inode (%d)",
11720 +               sb, tag, __dlimit_char(dli), ret, _file, _line);
11721 +       return ret;
11722 +}
11723 +
11724 +static inline void __dl_free_inode(struct super_block *sb,
11725 +       tag_t tag, const char *_file, int _line)
11726 +{
11727 +       struct dl_info *dli;
11728 +
11729 +       dli = locate_dl_info(sb, tag);
11730 +       if (!dli)
11731 +               goto out;
11732 +
11733 +       spin_lock(&dli->dl_lock);
11734 +       if (dli->dl_inodes_used > 1)
11735 +               dli->dl_inodes_used--;
11736 +       else
11737 +               dli->dl_inodes_used = 0;
11738 +       spin_unlock(&dli->dl_lock);
11739 +       put_dl_info(dli);
11740 +out:
11741 +       vxlprintk(VXD_CBIT(dlim, 0),
11742 +               "FREE  (%p,#%d)%c inode",
11743 +               sb, tag, __dlimit_char(dli), _file, _line);
11744 +}
11745 +
11746 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11747 +       unsigned long long *free_blocks, unsigned long long *root_blocks,
11748 +       const char *_file, int _line)
11749 +{
11750 +       struct dl_info *dli;
11751 +       uint64_t broot, bfree;
11752 +
11753 +       dli = locate_dl_info(sb, tag);
11754 +       if (!dli)
11755 +               return;
11756 +
11757 +       spin_lock(&dli->dl_lock);
11758 +       broot = (dli->dl_space_total -
11759 +               (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11760 +               >> sb->s_blocksize_bits;
11761 +       bfree = (dli->dl_space_total - dli->dl_space_used)
11762 +                       >> sb->s_blocksize_bits;
11763 +       spin_unlock(&dli->dl_lock);
11764 +
11765 +       vxlprintk(VXD_CBIT(dlim, 2),
11766 +               "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11767 +               (long long)bfree, (long long)broot,
11768 +               *free_blocks, *root_blocks, dli->dl_nrlmult,
11769 +               _file, _line);
11770 +       if (free_blocks) {
11771 +               if (*free_blocks > bfree)
11772 +                       *free_blocks = bfree;
11773 +       }
11774 +       if (root_blocks) {
11775 +               if (*root_blocks > broot)
11776 +                       *root_blocks = broot;
11777 +       }
11778 +       put_dl_info(dli);
11779 +}
11780 +
11781 +#define dl_prealloc_space(in, bytes) \
11782 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11783 +               __FILE__, __LINE__ )
11784 +
11785 +#define dl_alloc_space(in, bytes) \
11786 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11787 +               __FILE__, __LINE__ )
11788 +
11789 +#define dl_reserve_space(in, bytes) \
11790 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11791 +               __FILE__, __LINE__ )
11792 +
11793 +#define dl_claim_space(in, bytes) (0)
11794 +
11795 +#define dl_release_space(in, bytes) \
11796 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11797 +               __FILE__, __LINE__ )
11798 +
11799 +#define dl_free_space(in, bytes) \
11800 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11801 +               __FILE__, __LINE__ )
11802 +
11803 +
11804 +
11805 +#define dl_alloc_inode(in) \
11806 +       __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11807 +
11808 +#define dl_free_inode(in) \
11809 +       __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11810 +
11811 +
11812 +#define dl_adjust_block(sb, tag, fb, rb) \
11813 +       __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11814 +
11815 +
11816 +#else
11817 +#warning duplicate inclusion
11818 +#endif
11819 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/base.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/base.h
11820 --- linux-2.6.33.2/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11821 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/base.h 2010-02-25 12:02:16.000000000 +0100
11822 @@ -0,0 +1,170 @@
11823 +#ifndef _VX_BASE_H
11824 +#define _VX_BASE_H
11825 +
11826 +
11827 +/* context state changes */
11828 +
11829 +enum {
11830 +       VSC_STARTUP = 1,
11831 +       VSC_SHUTDOWN,
11832 +
11833 +       VSC_NETUP,
11834 +       VSC_NETDOWN,
11835 +};
11836 +
11837 +
11838 +
11839 +#define vx_task_xid(t) ((t)->xid)
11840 +
11841 +#define vx_current_xid() vx_task_xid(current)
11842 +
11843 +#define current_vx_info() (current->vx_info)
11844 +
11845 +
11846 +#define nx_task_nid(t) ((t)->nid)
11847 +
11848 +#define nx_current_nid() nx_task_nid(current)
11849 +
11850 +#define current_nx_info() (current->nx_info)
11851 +
11852 +
11853 +/* generic flag merging */
11854 +
11855 +#define vs_check_flags(v, m, f)        (((v) & (m)) ^ (f))
11856 +
11857 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11858 +
11859 +#define vs_mask_mask(v, f, m)  (((v) & ~(m)) | ((v) & (f) & (m)))
11860 +
11861 +#define vs_check_bit(v, n)     ((v) & (1LL << (n)))
11862 +
11863 +
11864 +/* context flags */
11865 +
11866 +#define __vx_flags(v)  ((v) ? (v)->vx_flags : 0)
11867 +
11868 +#define vx_current_flags()     __vx_flags(current_vx_info())
11869 +
11870 +#define vx_info_flags(v, m, f) \
11871 +       vs_check_flags(__vx_flags(v), m, f)
11872 +
11873 +#define task_vx_flags(t, m, f) \
11874 +       ((t) && vx_info_flags((t)->vx_info, m, f))
11875 +
11876 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11877 +
11878 +
11879 +/* context caps */
11880 +
11881 +#define __vx_ccaps(v)  ((v) ? (v)->vx_ccaps : 0)
11882 +
11883 +#define vx_current_ccaps()     __vx_ccaps(current_vx_info())
11884 +
11885 +#define vx_info_ccaps(v, c)    (__vx_ccaps(v) & (c))
11886 +
11887 +#define vx_ccaps(c)    vx_info_ccaps(current_vx_info(), (c))
11888 +
11889 +
11890 +
11891 +/* network flags */
11892 +
11893 +#define __nx_flags(n)  ((n) ? (n)->nx_flags : 0)
11894 +
11895 +#define nx_current_flags()     __nx_flags(current_nx_info())
11896 +
11897 +#define nx_info_flags(n, m, f) \
11898 +       vs_check_flags(__nx_flags(n), m, f)
11899 +
11900 +#define task_nx_flags(t, m, f) \
11901 +       ((t) && nx_info_flags((t)->nx_info, m, f))
11902 +
11903 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11904 +
11905 +
11906 +/* network caps */
11907 +
11908 +#define __nx_ncaps(n)  ((n) ? (n)->nx_ncaps : 0)
11909 +
11910 +#define nx_current_ncaps()     __nx_ncaps(current_nx_info())
11911 +
11912 +#define nx_info_ncaps(n, c)    (__nx_ncaps(n) & (c))
11913 +
11914 +#define nx_ncaps(c)    nx_info_ncaps(current_nx_info(), c)
11915 +
11916 +
11917 +/* context mask capabilities */
11918 +
11919 +#define __vx_mcaps(v)  ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11920 +
11921 +#define vx_info_mcaps(v, c)    (__vx_mcaps(v) & (c))
11922 +
11923 +#define vx_mcaps(c)    vx_info_mcaps(current_vx_info(), c)
11924 +
11925 +
11926 +/* context bcap mask */
11927 +
11928 +#define __vx_bcaps(v)          ((v)->vx_bcaps)
11929 +
11930 +#define vx_current_bcaps()     __vx_bcaps(current_vx_info())
11931 +
11932 +
11933 +/* mask given bcaps */
11934 +
11935 +#define vx_info_mbcaps(v, c)   ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11936 +
11937 +#define vx_mbcaps(c)           vx_info_mbcaps(current_vx_info(), c)
11938 +
11939 +
11940 +/* masked cap_bset */
11941 +
11942 +#define vx_info_cap_bset(v)    vx_info_mbcaps(v, current->cap_bset)
11943 +
11944 +#define vx_current_cap_bset()  vx_info_cap_bset(current_vx_info())
11945 +
11946 +#if 0
11947 +#define vx_info_mbcap(v, b) \
11948 +       (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11949 +       vx_info_bcaps(v, b) : (b))
11950 +
11951 +#define task_vx_mbcap(t, b) \
11952 +       vx_info_mbcap((t)->vx_info, (t)->b)
11953 +
11954 +#define vx_mbcap(b)    task_vx_mbcap(current, b)
11955 +#endif
11956 +
11957 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11958 +
11959 +#define vx_capable(b, c) (capable(b) || \
11960 +       (cap_raised(current_cap(), b) && vx_ccaps(c)))
11961 +
11962 +#define nx_capable(b, c) (capable(b) || \
11963 +       (cap_raised(current_cap(), b) && nx_ncaps(c)))
11964 +
11965 +#define vx_task_initpid(t, n) \
11966 +       ((t)->vx_info && \
11967 +       ((t)->vx_info->vx_initpid == (n)))
11968 +
11969 +#define vx_current_initpid(n)  vx_task_initpid(current, n)
11970 +
11971 +
11972 +/* context unshare mask */
11973 +
11974 +#define __vx_umask(v)          ((v)->vx_umask)
11975 +
11976 +#define vx_current_umask()     __vx_umask(current_vx_info())
11977 +
11978 +#define vx_can_unshare(b, f) (capable(b) || \
11979 +       (cap_raised(current_cap(), b) && \
11980 +       !((f) & ~vx_current_umask())))
11981 +
11982 +
11983 +#define __vx_state(v)  ((v) ? ((v)->vx_state) : 0)
11984 +
11985 +#define vx_info_state(v, m)    (__vx_state(v) & (m))
11986 +
11987 +
11988 +#define __nx_state(n)  ((n) ? ((n)->nx_state) : 0)
11989 +
11990 +#define nx_info_state(n, m)    (__nx_state(n) & (m))
11991 +
11992 +#endif
11993 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/cacct_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cacct_cmd.h
11994 --- linux-2.6.33.2/include/linux/vserver/cacct_cmd.h    1970-01-01 01:00:00.000000000 +0100
11995 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cacct_cmd.h    2010-02-25 12:02:16.000000000 +0100
11996 @@ -0,0 +1,23 @@
11997 +#ifndef _VX_CACCT_CMD_H
11998 +#define _VX_CACCT_CMD_H
11999 +
12000 +
12001 +/* virtual host info name commands */
12002 +
12003 +#define VCMD_sock_stat         VC_CMD(VSTAT, 5, 0)
12004 +
12005 +struct vcmd_sock_stat_v0 {
12006 +       uint32_t field;
12007 +       uint32_t count[3];
12008 +       uint64_t total[3];
12009 +};
12010 +
12011 +
12012 +#ifdef __KERNEL__
12013 +
12014 +#include <linux/compiler.h>
12015 +
12016 +extern int vc_sock_stat(struct vx_info *, void __user *);
12017 +
12018 +#endif /* __KERNEL__ */
12019 +#endif /* _VX_CACCT_CMD_H */
12020 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/cacct_def.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cacct_def.h
12021 --- linux-2.6.33.2/include/linux/vserver/cacct_def.h    1970-01-01 01:00:00.000000000 +0100
12022 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cacct_def.h    2010-02-25 12:02:16.000000000 +0100
12023 @@ -0,0 +1,43 @@
12024 +#ifndef _VX_CACCT_DEF_H
12025 +#define _VX_CACCT_DEF_H
12026 +
12027 +#include <asm/atomic.h>
12028 +#include <linux/vserver/cacct.h>
12029 +
12030 +
12031 +struct _vx_sock_acc {
12032 +       atomic_long_t count;
12033 +       atomic_long_t total;
12034 +};
12035 +
12036 +/* context sub struct */
12037 +
12038 +struct _vx_cacct {
12039 +       struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
12040 +       atomic_t slab[8];
12041 +       atomic_t page[6][8];
12042 +};
12043 +
12044 +#ifdef CONFIG_VSERVER_DEBUG
12045 +
12046 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
12047 +{
12048 +       int i, j;
12049 +
12050 +       printk("\t_vx_cacct:");
12051 +       for (i = 0; i < 6; i++) {
12052 +               struct _vx_sock_acc *ptr = cacct->sock[i];
12053 +
12054 +               printk("\t [%d] =", i);
12055 +               for (j = 0; j < 3; j++) {
12056 +                       printk(" [%d] = %8lu, %8lu", j,
12057 +                               atomic_long_read(&ptr[j].count),
12058 +                               atomic_long_read(&ptr[j].total));
12059 +               }
12060 +               printk("\n");
12061 +       }
12062 +}
12063 +
12064 +#endif
12065 +
12066 +#endif /* _VX_CACCT_DEF_H */
12067 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/cacct.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cacct.h
12068 --- linux-2.6.33.2/include/linux/vserver/cacct.h        1970-01-01 01:00:00.000000000 +0100
12069 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cacct.h        2010-02-25 12:02:16.000000000 +0100
12070 @@ -0,0 +1,15 @@
12071 +#ifndef _VX_CACCT_H
12072 +#define _VX_CACCT_H
12073 +
12074 +
12075 +enum sock_acc_field {
12076 +       VXA_SOCK_UNSPEC = 0,
12077 +       VXA_SOCK_UNIX,
12078 +       VXA_SOCK_INET,
12079 +       VXA_SOCK_INET6,
12080 +       VXA_SOCK_PACKET,
12081 +       VXA_SOCK_OTHER,
12082 +       VXA_SOCK_SIZE   /* array size */
12083 +};
12084 +
12085 +#endif /* _VX_CACCT_H */
12086 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/cacct_int.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cacct_int.h
12087 --- linux-2.6.33.2/include/linux/vserver/cacct_int.h    1970-01-01 01:00:00.000000000 +0100
12088 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cacct_int.h    2010-02-25 12:02:16.000000000 +0100
12089 @@ -0,0 +1,21 @@
12090 +#ifndef _VX_CACCT_INT_H
12091 +#define _VX_CACCT_INT_H
12092 +
12093 +
12094 +#ifdef __KERNEL__
12095 +
12096 +static inline
12097 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
12098 +{
12099 +       return atomic_long_read(&cacct->sock[type][pos].count);
12100 +}
12101 +
12102 +
12103 +static inline
12104 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
12105 +{
12106 +       return atomic_long_read(&cacct->sock[type][pos].total);
12107 +}
12108 +
12109 +#endif /* __KERNEL__ */
12110 +#endif /* _VX_CACCT_INT_H */
12111 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/check.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/check.h
12112 --- linux-2.6.33.2/include/linux/vserver/check.h        1970-01-01 01:00:00.000000000 +0100
12113 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/check.h        2010-02-25 12:02:16.000000000 +0100
12114 @@ -0,0 +1,89 @@
12115 +#ifndef _VS_CHECK_H
12116 +#define _VS_CHECK_H
12117 +
12118 +
12119 +#define MAX_S_CONTEXT  65535   /* Arbitrary limit */
12120 +
12121 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
12122 +#define MIN_D_CONTEXT  49152   /* dynamic contexts start here */
12123 +#else
12124 +#define MIN_D_CONTEXT  65536
12125 +#endif
12126 +
12127 +/* check conditions */
12128 +
12129 +#define VS_ADMIN       0x0001
12130 +#define VS_WATCH       0x0002
12131 +#define VS_HIDE                0x0004
12132 +#define VS_HOSTID      0x0008
12133 +
12134 +#define VS_IDENT       0x0010
12135 +#define VS_EQUIV       0x0020
12136 +#define VS_PARENT      0x0040
12137 +#define VS_CHILD       0x0080
12138 +
12139 +#define VS_ARG_MASK    0x00F0
12140 +
12141 +#define VS_DYNAMIC     0x0100
12142 +#define VS_STATIC      0x0200
12143 +
12144 +#define VS_ATR_MASK    0x0F00
12145 +
12146 +#ifdef CONFIG_VSERVER_PRIVACY
12147 +#define VS_ADMIN_P     (0)
12148 +#define VS_WATCH_P     (0)
12149 +#else
12150 +#define VS_ADMIN_P     VS_ADMIN
12151 +#define VS_WATCH_P     VS_WATCH
12152 +#endif
12153 +
12154 +#define VS_HARDIRQ     0x1000
12155 +#define VS_SOFTIRQ     0x2000
12156 +#define VS_IRQ         0x4000
12157 +
12158 +#define VS_IRQ_MASK    0xF000
12159 +
12160 +#include <linux/hardirq.h>
12161 +
12162 +/*
12163 + * check current context for ADMIN/WATCH and
12164 + * optionally against supplied argument
12165 + */
12166 +static inline int __vs_check(int cid, int id, unsigned int mode)
12167 +{
12168 +       if (mode & VS_ARG_MASK) {
12169 +               if ((mode & VS_IDENT) && (id == cid))
12170 +                       return 1;
12171 +       }
12172 +       if (mode & VS_ATR_MASK) {
12173 +               if ((mode & VS_DYNAMIC) &&
12174 +                       (id >= MIN_D_CONTEXT) &&
12175 +                       (id <= MAX_S_CONTEXT))
12176 +                       return 1;
12177 +               if ((mode & VS_STATIC) &&
12178 +                       (id > 1) && (id < MIN_D_CONTEXT))
12179 +                       return 1;
12180 +       }
12181 +       if (mode & VS_IRQ_MASK) {
12182 +               if ((mode & VS_IRQ) && unlikely(in_interrupt()))
12183 +                       return 1;
12184 +               if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
12185 +                       return 1;
12186 +               if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
12187 +                       return 1;
12188 +       }
12189 +       return (((mode & VS_ADMIN) && (cid == 0)) ||
12190 +               ((mode & VS_WATCH) && (cid == 1)) ||
12191 +               ((mode & VS_HOSTID) && (id == 0)));
12192 +}
12193 +
12194 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
12195 +
12196 +#define vx_weak_check(c, m)    ((m) ? vx_check(c, m) : 1)
12197 +
12198 +
12199 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
12200 +
12201 +#define nx_weak_check(c, m)    ((m) ? nx_check(c, m) : 1)
12202 +
12203 +#endif
12204 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/context_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/context_cmd.h
12205 --- linux-2.6.33.2/include/linux/vserver/context_cmd.h  1970-01-01 01:00:00.000000000 +0100
12206 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/context_cmd.h  2010-02-25 12:02:16.000000000 +0100
12207 @@ -0,0 +1,145 @@
12208 +#ifndef _VX_CONTEXT_CMD_H
12209 +#define _VX_CONTEXT_CMD_H
12210 +
12211 +
12212 +/* vinfo commands */
12213 +
12214 +#define VCMD_task_xid          VC_CMD(VINFO, 1, 0)
12215 +
12216 +#ifdef __KERNEL__
12217 +extern int vc_task_xid(uint32_t);
12218 +
12219 +#endif /* __KERNEL__ */
12220 +
12221 +#define VCMD_vx_info           VC_CMD(VINFO, 5, 0)
12222 +
12223 +struct vcmd_vx_info_v0 {
12224 +       uint32_t xid;
12225 +       uint32_t initpid;
12226 +       /* more to come */
12227 +};
12228 +
12229 +#ifdef __KERNEL__
12230 +extern int vc_vx_info(struct vx_info *, void __user *);
12231 +
12232 +#endif /* __KERNEL__ */
12233 +
12234 +#define VCMD_ctx_stat          VC_CMD(VSTAT, 0, 0)
12235 +
12236 +struct vcmd_ctx_stat_v0 {
12237 +       uint32_t usecnt;
12238 +       uint32_t tasks;
12239 +       /* more to come */
12240 +};
12241 +
12242 +#ifdef __KERNEL__
12243 +extern int vc_ctx_stat(struct vx_info *, void __user *);
12244 +
12245 +#endif /* __KERNEL__ */
12246 +
12247 +/* context commands */
12248 +
12249 +#define VCMD_ctx_create_v0     VC_CMD(VPROC, 1, 0)
12250 +#define VCMD_ctx_create                VC_CMD(VPROC, 1, 1)
12251 +
12252 +struct vcmd_ctx_create {
12253 +       uint64_t flagword;
12254 +};
12255 +
12256 +#define VCMD_ctx_migrate_v0    VC_CMD(PROCMIG, 1, 0)
12257 +#define VCMD_ctx_migrate       VC_CMD(PROCMIG, 1, 1)
12258 +
12259 +struct vcmd_ctx_migrate {
12260 +       uint64_t flagword;
12261 +};
12262 +
12263 +#ifdef __KERNEL__
12264 +extern int vc_ctx_create(uint32_t, void __user *);
12265 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
12266 +
12267 +#endif /* __KERNEL__ */
12268 +
12269 +
12270 +/* flag commands */
12271 +
12272 +#define VCMD_get_cflags                VC_CMD(FLAGS, 1, 0)
12273 +#define VCMD_set_cflags                VC_CMD(FLAGS, 2, 0)
12274 +
12275 +struct vcmd_ctx_flags_v0 {
12276 +       uint64_t flagword;
12277 +       uint64_t mask;
12278 +};
12279 +
12280 +#ifdef __KERNEL__
12281 +extern int vc_get_cflags(struct vx_info *, void __user *);
12282 +extern int vc_set_cflags(struct vx_info *, void __user *);
12283 +
12284 +#endif /* __KERNEL__ */
12285 +
12286 +
12287 +/* context caps commands */
12288 +
12289 +#define VCMD_get_ccaps         VC_CMD(FLAGS, 3, 1)
12290 +#define VCMD_set_ccaps         VC_CMD(FLAGS, 4, 1)
12291 +
12292 +struct vcmd_ctx_caps_v1 {
12293 +       uint64_t ccaps;
12294 +       uint64_t cmask;
12295 +};
12296 +
12297 +#ifdef __KERNEL__
12298 +extern int vc_get_ccaps(struct vx_info *, void __user *);
12299 +extern int vc_set_ccaps(struct vx_info *, void __user *);
12300 +
12301 +#endif /* __KERNEL__ */
12302 +
12303 +
12304 +/* bcaps commands */
12305 +
12306 +#define VCMD_get_bcaps         VC_CMD(FLAGS, 9, 0)
12307 +#define VCMD_set_bcaps         VC_CMD(FLAGS, 10, 0)
12308 +
12309 +struct vcmd_bcaps {
12310 +       uint64_t bcaps;
12311 +       uint64_t bmask;
12312 +};
12313 +
12314 +#ifdef __KERNEL__
12315 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12316 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12317 +
12318 +#endif /* __KERNEL__ */
12319 +
12320 +
12321 +/* umask commands */
12322 +
12323 +#define VCMD_get_umask         VC_CMD(FLAGS, 13, 0)
12324 +#define VCMD_set_umask         VC_CMD(FLAGS, 14, 0)
12325 +
12326 +struct vcmd_umask {
12327 +       uint64_t umask;
12328 +       uint64_t mask;
12329 +};
12330 +
12331 +#ifdef __KERNEL__
12332 +extern int vc_get_umask(struct vx_info *, void __user *);
12333 +extern int vc_set_umask(struct vx_info *, void __user *);
12334 +
12335 +#endif /* __KERNEL__ */
12336 +
12337 +
12338 +/* OOM badness */
12339 +
12340 +#define VCMD_get_badness       VC_CMD(MEMCTRL, 5, 0)
12341 +#define VCMD_set_badness       VC_CMD(MEMCTRL, 6, 0)
12342 +
12343 +struct vcmd_badness_v0 {
12344 +       int64_t bias;
12345 +};
12346 +
12347 +#ifdef __KERNEL__
12348 +extern int vc_get_badness(struct vx_info *, void __user *);
12349 +extern int vc_set_badness(struct vx_info *, void __user *);
12350 +
12351 +#endif /* __KERNEL__ */
12352 +#endif /* _VX_CONTEXT_CMD_H */
12353 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/context.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/context.h
12354 --- linux-2.6.33.2/include/linux/vserver/context.h      1970-01-01 01:00:00.000000000 +0100
12355 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/context.h      2010-03-05 19:53:00.000000000 +0100
12356 @@ -0,0 +1,184 @@
12357 +#ifndef _VX_CONTEXT_H
12358 +#define _VX_CONTEXT_H
12359 +
12360 +#include <linux/types.h>
12361 +#include <linux/capability.h>
12362 +
12363 +
12364 +/* context flags */
12365 +
12366 +#define VXF_INFO_SCHED         0x00000002
12367 +#define VXF_INFO_NPROC         0x00000004
12368 +#define VXF_INFO_PRIVATE       0x00000008
12369 +
12370 +#define VXF_INFO_INIT          0x00000010
12371 +#define VXF_INFO_HIDE          0x00000020
12372 +#define VXF_INFO_ULIMIT                0x00000040
12373 +#define VXF_INFO_NSPACE                0x00000080
12374 +
12375 +#define VXF_SCHED_HARD         0x00000100
12376 +#define VXF_SCHED_PRIO         0x00000200
12377 +#define VXF_SCHED_PAUSE                0x00000400
12378 +
12379 +#define VXF_VIRT_MEM           0x00010000
12380 +#define VXF_VIRT_UPTIME                0x00020000
12381 +#define VXF_VIRT_CPU           0x00040000
12382 +#define VXF_VIRT_LOAD          0x00080000
12383 +#define VXF_VIRT_TIME          0x00100000
12384 +
12385 +#define VXF_HIDE_MOUNT         0x01000000
12386 +/* was VXF_HIDE_NETIF          0x02000000 */
12387 +#define VXF_HIDE_VINFO         0x04000000
12388 +
12389 +#define VXF_STATE_SETUP                (1ULL << 32)
12390 +#define VXF_STATE_INIT         (1ULL << 33)
12391 +#define VXF_STATE_ADMIN                (1ULL << 34)
12392 +
12393 +#define VXF_SC_HELPER          (1ULL << 36)
12394 +#define VXF_REBOOT_KILL                (1ULL << 37)
12395 +#define VXF_PERSISTENT         (1ULL << 38)
12396 +
12397 +#define VXF_FORK_RSS           (1ULL << 48)
12398 +#define VXF_PROLIFIC           (1ULL << 49)
12399 +
12400 +#define VXF_IGNEG_NICE         (1ULL << 52)
12401 +
12402 +#define VXF_ONE_TIME           (0x0007ULL << 32)
12403 +
12404 +#define VXF_INIT_SET           (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12405 +
12406 +
12407 +/* context migration */
12408 +
12409 +#define VXM_SET_INIT           0x00000001
12410 +#define VXM_SET_REAPER         0x00000002
12411 +
12412 +/* context caps */
12413 +
12414 +#define VXC_CAP_MASK           0x00000000
12415 +
12416 +#define VXC_SET_UTSNAME                0x00000001
12417 +#define VXC_SET_RLIMIT         0x00000002
12418 +#define VXC_FS_SECURITY                0x00000004
12419 +#define VXC_FS_TRUSTED         0x00000008
12420 +#define VXC_TIOCSTI            0x00000010
12421 +
12422 +/* was VXC_RAW_ICMP            0x00000100 */
12423 +#define VXC_SYSLOG             0x00001000
12424 +#define VXC_OOM_ADJUST         0x00002000
12425 +#define VXC_AUDIT_CONTROL      0x00004000
12426 +
12427 +#define VXC_SECURE_MOUNT       0x00010000
12428 +#define VXC_SECURE_REMOUNT     0x00020000
12429 +#define VXC_BINARY_MOUNT       0x00040000
12430 +
12431 +#define VXC_QUOTA_CTL          0x00100000
12432 +#define VXC_ADMIN_MAPPER       0x00200000
12433 +#define VXC_ADMIN_CLOOP                0x00400000
12434 +
12435 +#define VXC_KTHREAD            0x01000000
12436 +#define VXC_NAMESPACE          0x02000000
12437 +
12438 +
12439 +#ifdef __KERNEL__
12440 +
12441 +#include <linux/list.h>
12442 +#include <linux/spinlock.h>
12443 +#include <linux/rcupdate.h>
12444 +
12445 +#include "limit_def.h"
12446 +#include "sched_def.h"
12447 +#include "cvirt_def.h"
12448 +#include "cacct_def.h"
12449 +#include "device_def.h"
12450 +
12451 +#define VX_SPACES      2
12452 +
12453 +struct _vx_info_pc {
12454 +       struct _vx_sched_pc sched_pc;
12455 +       struct _vx_cvirt_pc cvirt_pc;
12456 +};
12457 +
12458 +struct vx_info {
12459 +       struct hlist_node vx_hlist;             /* linked list of contexts */
12460 +       xid_t vx_id;                            /* context id */
12461 +       atomic_t vx_usecnt;                     /* usage count */
12462 +       atomic_t vx_tasks;                      /* tasks count */
12463 +       struct vx_info *vx_parent;              /* parent context */
12464 +       int vx_state;                           /* context state */
12465 +
12466 +       unsigned long vx_nsmask[VX_SPACES];     /* assignment mask */
12467 +       struct nsproxy *vx_nsproxy[VX_SPACES];  /* private namespaces */
12468 +       struct fs_struct *vx_fs[VX_SPACES];     /* private namespace fs */
12469 +
12470 +       uint64_t vx_flags;                      /* context flags */
12471 +       uint64_t vx_ccaps;                      /* context caps (vserver) */
12472 +       kernel_cap_t vx_bcaps;                  /* bounding caps (system) */
12473 +       unsigned long vx_umask;                 /* unshare mask (guest) */
12474 +
12475 +       struct task_struct *vx_reaper;          /* guest reaper process */
12476 +       pid_t vx_initpid;                       /* PID of guest init */
12477 +       int64_t vx_badness_bias;                /* OOM points bias */
12478 +
12479 +       struct _vx_limit limit;                 /* vserver limits */
12480 +       struct _vx_sched sched;                 /* vserver scheduler */
12481 +       struct _vx_cvirt cvirt;                 /* virtual/bias stuff */
12482 +       struct _vx_cacct cacct;                 /* context accounting */
12483 +
12484 +       struct _vx_device dmap;                 /* default device map targets */
12485 +
12486 +#ifndef CONFIG_SMP
12487 +       struct _vx_info_pc info_pc;             /* per cpu data */
12488 +#else
12489 +       struct _vx_info_pc *ptr_pc;             /* per cpu array */
12490 +#endif
12491 +
12492 +       wait_queue_head_t vx_wait;              /* context exit waitqueue */
12493 +       int reboot_cmd;                         /* last sys_reboot() cmd */
12494 +       int exit_code;                          /* last process exit code */
12495 +
12496 +       char vx_name[65];                       /* vserver name */
12497 +};
12498 +
12499 +#ifndef CONFIG_SMP
12500 +#define        vx_ptr_pc(vxi)          (&(vxi)->info_pc)
12501 +#define        vx_per_cpu(vxi, v, id)  vx_ptr_pc(vxi)->v
12502 +#else
12503 +#define        vx_ptr_pc(vxi)          ((vxi)->ptr_pc)
12504 +#define        vx_per_cpu(vxi, v, id)  per_cpu_ptr(vx_ptr_pc(vxi), id)->v
12505 +#endif
12506 +
12507 +#define        vx_cpu(vxi, v)          vx_per_cpu(vxi, v, smp_processor_id())
12508 +
12509 +
12510 +struct vx_info_save {
12511 +       struct vx_info *vxi;
12512 +       xid_t xid;
12513 +};
12514 +
12515 +
12516 +/* status flags */
12517 +
12518 +#define VXS_HASHED     0x0001
12519 +#define VXS_PAUSED     0x0010
12520 +#define VXS_SHUTDOWN   0x0100
12521 +#define VXS_HELPER     0x1000
12522 +#define VXS_RELEASED   0x8000
12523 +
12524 +
12525 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
12526 +extern void release_vx_info(struct vx_info *, struct task_struct *);
12527 +
12528 +extern struct vx_info *lookup_vx_info(int);
12529 +extern struct vx_info *lookup_or_create_vx_info(int);
12530 +
12531 +extern int get_xid_list(int, unsigned int *, int);
12532 +extern int xid_is_hashed(xid_t);
12533 +
12534 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
12535 +
12536 +extern long vs_state_change(struct vx_info *, unsigned int);
12537 +
12538 +
12539 +#endif /* __KERNEL__ */
12540 +#endif /* _VX_CONTEXT_H */
12541 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/cvirt_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cvirt_cmd.h
12542 --- linux-2.6.33.2/include/linux/vserver/cvirt_cmd.h    1970-01-01 01:00:00.000000000 +0100
12543 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cvirt_cmd.h    2010-02-25 12:02:16.000000000 +0100
12544 @@ -0,0 +1,53 @@
12545 +#ifndef _VX_CVIRT_CMD_H
12546 +#define _VX_CVIRT_CMD_H
12547 +
12548 +
12549 +/* virtual host info name commands */
12550 +
12551 +#define VCMD_set_vhi_name      VC_CMD(VHOST, 1, 0)
12552 +#define VCMD_get_vhi_name      VC_CMD(VHOST, 2, 0)
12553 +
12554 +struct vcmd_vhi_name_v0 {
12555 +       uint32_t field;
12556 +       char name[65];
12557 +};
12558 +
12559 +
12560 +enum vhi_name_field {
12561 +       VHIN_CONTEXT = 0,
12562 +       VHIN_SYSNAME,
12563 +       VHIN_NODENAME,
12564 +       VHIN_RELEASE,
12565 +       VHIN_VERSION,
12566 +       VHIN_MACHINE,
12567 +       VHIN_DOMAINNAME,
12568 +};
12569 +
12570 +
12571 +#ifdef __KERNEL__
12572 +
12573 +#include <linux/compiler.h>
12574 +
12575 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12576 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12577 +
12578 +#endif /* __KERNEL__ */
12579 +
12580 +#define VCMD_virt_stat         VC_CMD(VSTAT, 3, 0)
12581 +
12582 +struct vcmd_virt_stat_v0 {
12583 +       uint64_t offset;
12584 +       uint64_t uptime;
12585 +       uint32_t nr_threads;
12586 +       uint32_t nr_running;
12587 +       uint32_t nr_uninterruptible;
12588 +       uint32_t nr_onhold;
12589 +       uint32_t nr_forks;
12590 +       uint32_t load[3];
12591 +};
12592 +
12593 +#ifdef __KERNEL__
12594 +extern int vc_virt_stat(struct vx_info *, void __user *);
12595 +
12596 +#endif /* __KERNEL__ */
12597 +#endif /* _VX_CVIRT_CMD_H */
12598 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/cvirt_def.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cvirt_def.h
12599 --- linux-2.6.33.2/include/linux/vserver/cvirt_def.h    1970-01-01 01:00:00.000000000 +0100
12600 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cvirt_def.h    2010-02-25 12:02:16.000000000 +0100
12601 @@ -0,0 +1,80 @@
12602 +#ifndef _VX_CVIRT_DEF_H
12603 +#define _VX_CVIRT_DEF_H
12604 +
12605 +#include <linux/jiffies.h>
12606 +#include <linux/spinlock.h>
12607 +#include <linux/wait.h>
12608 +#include <linux/time.h>
12609 +#include <asm/atomic.h>
12610 +
12611 +
12612 +struct _vx_usage_stat {
12613 +       uint64_t user;
12614 +       uint64_t nice;
12615 +       uint64_t system;
12616 +       uint64_t softirq;
12617 +       uint64_t irq;
12618 +       uint64_t idle;
12619 +       uint64_t iowait;
12620 +};
12621 +
12622 +struct _vx_syslog {
12623 +       wait_queue_head_t log_wait;
12624 +       spinlock_t logbuf_lock;         /* lock for the log buffer */
12625 +
12626 +       unsigned long log_start;        /* next char to be read by syslog() */
12627 +       unsigned long con_start;        /* next char to be sent to consoles */
12628 +       unsigned long log_end;  /* most-recently-written-char + 1 */
12629 +       unsigned long logged_chars;     /* #chars since last read+clear operation */
12630 +
12631 +       char log_buf[1024];
12632 +};
12633 +
12634 +
12635 +/* context sub struct */
12636 +
12637 +struct _vx_cvirt {
12638 +       atomic_t nr_threads;            /* number of current threads */
12639 +       atomic_t nr_running;            /* number of running threads */
12640 +       atomic_t nr_uninterruptible;    /* number of uninterruptible threads */
12641 +
12642 +       atomic_t nr_onhold;             /* processes on hold */
12643 +       uint32_t onhold_last;           /* jiffies when put on hold */
12644 +
12645 +       struct timeval bias_tv;         /* time offset to the host */
12646 +       struct timespec bias_idle;
12647 +       struct timespec bias_uptime;    /* context creation point */
12648 +       uint64_t bias_clock;            /* offset in clock_t */
12649 +
12650 +       spinlock_t load_lock;           /* lock for the load averages */
12651 +       atomic_t load_updates;          /* nr of load updates done so far */
12652 +       uint32_t load_last;             /* last time load was calculated */
12653 +       uint32_t load[3];               /* load averages 1,5,15 */
12654 +
12655 +       atomic_t total_forks;           /* number of forks so far */
12656 +
12657 +       struct _vx_syslog syslog;
12658 +};
12659 +
12660 +struct _vx_cvirt_pc {
12661 +       struct _vx_usage_stat cpustat;
12662 +};
12663 +
12664 +
12665 +#ifdef CONFIG_VSERVER_DEBUG
12666 +
12667 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12668 +{
12669 +       printk("\t_vx_cvirt:\n");
12670 +       printk("\t threads: %4d, %4d, %4d, %4d\n",
12671 +               atomic_read(&cvirt->nr_threads),
12672 +               atomic_read(&cvirt->nr_running),
12673 +               atomic_read(&cvirt->nr_uninterruptible),
12674 +               atomic_read(&cvirt->nr_onhold));
12675 +       /* add rest here */
12676 +       printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12677 +}
12678 +
12679 +#endif
12680 +
12681 +#endif /* _VX_CVIRT_DEF_H */
12682 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/cvirt.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cvirt.h
12683 --- linux-2.6.33.2/include/linux/vserver/cvirt.h        1970-01-01 01:00:00.000000000 +0100
12684 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/cvirt.h        2010-02-25 12:02:16.000000000 +0100
12685 @@ -0,0 +1,20 @@
12686 +#ifndef _VX_CVIRT_H
12687 +#define _VX_CVIRT_H
12688 +
12689 +
12690 +#ifdef __KERNEL__
12691 +
12692 +struct timespec;
12693 +
12694 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12695 +
12696 +
12697 +struct vx_info;
12698 +
12699 +void vx_update_load(struct vx_info *);
12700 +
12701 +
12702 +int vx_do_syslog(int, char __user *, int);
12703 +
12704 +#endif /* __KERNEL__ */
12705 +#endif /* _VX_CVIRT_H */
12706 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/debug_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/debug_cmd.h
12707 --- linux-2.6.33.2/include/linux/vserver/debug_cmd.h    1970-01-01 01:00:00.000000000 +0100
12708 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/debug_cmd.h    2010-02-25 12:02:16.000000000 +0100
12709 @@ -0,0 +1,58 @@
12710 +#ifndef _VX_DEBUG_CMD_H
12711 +#define _VX_DEBUG_CMD_H
12712 +
12713 +
12714 +/* debug commands */
12715 +
12716 +#define VCMD_dump_history      VC_CMD(DEBUG, 1, 0)
12717 +
12718 +#define VCMD_read_history      VC_CMD(DEBUG, 5, 0)
12719 +#define VCMD_read_monitor      VC_CMD(DEBUG, 6, 0)
12720 +
12721 +struct  vcmd_read_history_v0 {
12722 +       uint32_t index;
12723 +       uint32_t count;
12724 +       char __user *data;
12725 +};
12726 +
12727 +struct  vcmd_read_monitor_v0 {
12728 +       uint32_t index;
12729 +       uint32_t count;
12730 +       char __user *data;
12731 +};
12732 +
12733 +
12734 +#ifdef __KERNEL__
12735 +
12736 +#ifdef CONFIG_COMPAT
12737 +
12738 +#include <asm/compat.h>
12739 +
12740 +struct vcmd_read_history_v0_x32 {
12741 +       uint32_t index;
12742 +       uint32_t count;
12743 +       compat_uptr_t data_ptr;
12744 +};
12745 +
12746 +struct vcmd_read_monitor_v0_x32 {
12747 +       uint32_t index;
12748 +       uint32_t count;
12749 +       compat_uptr_t data_ptr;
12750 +};
12751 +
12752 +#endif  /* CONFIG_COMPAT */
12753 +
12754 +extern int vc_dump_history(uint32_t);
12755 +
12756 +extern int vc_read_history(uint32_t, void __user *);
12757 +extern int vc_read_monitor(uint32_t, void __user *);
12758 +
12759 +#ifdef CONFIG_COMPAT
12760 +
12761 +extern int vc_read_history_x32(uint32_t, void __user *);
12762 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12763 +
12764 +#endif  /* CONFIG_COMPAT */
12765 +
12766 +#endif /* __KERNEL__ */
12767 +#endif /* _VX_DEBUG_CMD_H */
12768 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/debug.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/debug.h
12769 --- linux-2.6.33.2/include/linux/vserver/debug.h        1970-01-01 01:00:00.000000000 +0100
12770 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/debug.h        2010-02-25 12:02:16.000000000 +0100
12771 @@ -0,0 +1,127 @@
12772 +#ifndef _VX_DEBUG_H
12773 +#define _VX_DEBUG_H
12774 +
12775 +
12776 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12777 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12778 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12779 +
12780 +#define VXD_DEV(d)     (d), (d)->bd_inode->i_ino,              \
12781 +                       imajor((d)->bd_inode), iminor((d)->bd_inode)
12782 +#define VXF_DEV                "%p[%lu,%d:%d]"
12783 +
12784 +
12785 +#define vxd_path(p)                                            \
12786 +       ({ static char _buffer[PATH_MAX];                       \
12787 +          d_path(p, _buffer, sizeof(_buffer)); })
12788 +
12789 +#define vxd_cond_path(n)                                       \
12790 +       ((n) ? vxd_path(&(n)->path) : "<null>" )
12791 +
12792 +
12793 +#ifdef CONFIG_VSERVER_DEBUG
12794 +
12795 +extern unsigned int vx_debug_switch;
12796 +extern unsigned int vx_debug_xid;
12797 +extern unsigned int vx_debug_nid;
12798 +extern unsigned int vx_debug_tag;
12799 +extern unsigned int vx_debug_net;
12800 +extern unsigned int vx_debug_limit;
12801 +extern unsigned int vx_debug_cres;
12802 +extern unsigned int vx_debug_dlim;
12803 +extern unsigned int vx_debug_quota;
12804 +extern unsigned int vx_debug_cvirt;
12805 +extern unsigned int vx_debug_space;
12806 +extern unsigned int vx_debug_misc;
12807 +
12808 +
12809 +#define VX_LOGLEVEL    "vxD: "
12810 +#define VX_PROC_FMT    "%p: "
12811 +#define VX_PROCESS     current
12812 +
12813 +#define vxdprintk(c, f, x...)                                  \
12814 +       do {                                                    \
12815 +               if (c)                                          \
12816 +                       printk(VX_LOGLEVEL VX_PROC_FMT f "\n",  \
12817 +                               VX_PROCESS , ##x);              \
12818 +       } while (0)
12819 +
12820 +#define vxlprintk(c, f, x...)                                  \
12821 +       do {                                                    \
12822 +               if (c)                                          \
12823 +                       printk(VX_LOGLEVEL f " @%s:%d\n", x);   \
12824 +       } while (0)
12825 +
12826 +#define vxfprintk(c, f, x...)                                  \
12827 +       do {                                                    \
12828 +               if (c)                                          \
12829 +                       printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12830 +       } while (0)
12831 +
12832 +
12833 +struct vx_info;
12834 +
12835 +void dump_vx_info(struct vx_info *, int);
12836 +void dump_vx_info_inactive(int);
12837 +
12838 +#else  /* CONFIG_VSERVER_DEBUG */
12839 +
12840 +#define vx_debug_switch 0
12841 +#define vx_debug_xid   0
12842 +#define vx_debug_nid   0
12843 +#define vx_debug_tag   0
12844 +#define vx_debug_net   0
12845 +#define vx_debug_limit 0
12846 +#define vx_debug_cres  0
12847 +#define vx_debug_dlim  0
12848 +#define vx_debug_cvirt 0
12849 +
12850 +#define vxdprintk(x...) do { } while (0)
12851 +#define vxlprintk(x...) do { } while (0)
12852 +#define vxfprintk(x...) do { } while (0)
12853 +
12854 +#endif /* CONFIG_VSERVER_DEBUG */
12855 +
12856 +
12857 +#ifdef CONFIG_VSERVER_WARN
12858 +
12859 +#define VX_WARNLEVEL   KERN_WARNING "vxW: "
12860 +#define VX_WARN_TASK   "[»%s«,%u:#%u|%u|%u] "
12861 +#define VX_WARN_XID    "[xid #%u] "
12862 +#define VX_WARN_NID    "[nid #%u] "
12863 +#define VX_WARN_TAG    "[tag #%u] "
12864 +
12865 +#define vxwprintk(c, f, x...)                                  \
12866 +       do {                                                    \
12867 +               if (c)                                          \
12868 +                       printk(VX_WARNLEVEL f "\n", ##x);       \
12869 +       } while (0)
12870 +
12871 +#else  /* CONFIG_VSERVER_WARN */
12872 +
12873 +#define vxwprintk(x...) do { } while (0)
12874 +
12875 +#endif /* CONFIG_VSERVER_WARN */
12876 +
12877 +#define vxwprintk_task(c, f, x...)                             \
12878 +       vxwprintk(c, VX_WARN_TASK f,                            \
12879 +               current->comm, current->pid,                    \
12880 +               current->xid, current->nid, current->tag, ##x)
12881 +#define vxwprintk_xid(c, f, x...)                              \
12882 +       vxwprintk(c, VX_WARN_XID f, current->xid, x)
12883 +#define vxwprintk_nid(c, f, x...)                              \
12884 +       vxwprintk(c, VX_WARN_NID f, current->nid, x)
12885 +#define vxwprintk_tag(c, f, x...)                              \
12886 +       vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12887 +
12888 +#ifdef CONFIG_VSERVER_DEBUG
12889 +#define vxd_assert_lock(l)     assert_spin_locked(l)
12890 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12891 +       "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12892 +#else
12893 +#define vxd_assert_lock(l)     do { } while (0)
12894 +#define vxd_assert(c, f, x...) do { } while (0)
12895 +#endif
12896 +
12897 +
12898 +#endif /* _VX_DEBUG_H */
12899 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/device_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/device_cmd.h
12900 --- linux-2.6.33.2/include/linux/vserver/device_cmd.h   1970-01-01 01:00:00.000000000 +0100
12901 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/device_cmd.h   2010-02-25 12:02:16.000000000 +0100
12902 @@ -0,0 +1,44 @@
12903 +#ifndef _VX_DEVICE_CMD_H
12904 +#define _VX_DEVICE_CMD_H
12905 +
12906 +
12907 +/*  device vserver commands */
12908 +
12909 +#define VCMD_set_mapping       VC_CMD(DEVICE, 1, 0)
12910 +#define VCMD_unset_mapping     VC_CMD(DEVICE, 2, 0)
12911 +
12912 +struct vcmd_set_mapping_v0 {
12913 +       const char __user *device;
12914 +       const char __user *target;
12915 +       uint32_t flags;
12916 +};
12917 +
12918 +
12919 +#ifdef __KERNEL__
12920 +
12921 +#ifdef CONFIG_COMPAT
12922 +
12923 +#include <asm/compat.h>
12924 +
12925 +struct vcmd_set_mapping_v0_x32 {
12926 +       compat_uptr_t device_ptr;
12927 +       compat_uptr_t target_ptr;
12928 +       uint32_t flags;
12929 +};
12930 +
12931 +#endif /* CONFIG_COMPAT */
12932 +
12933 +#include <linux/compiler.h>
12934 +
12935 +extern int vc_set_mapping(struct vx_info *, void __user *);
12936 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12937 +
12938 +#ifdef CONFIG_COMPAT
12939 +
12940 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12941 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12942 +
12943 +#endif /* CONFIG_COMPAT */
12944 +
12945 +#endif /* __KERNEL__ */
12946 +#endif /* _VX_DEVICE_CMD_H */
12947 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/device_def.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/device_def.h
12948 --- linux-2.6.33.2/include/linux/vserver/device_def.h   1970-01-01 01:00:00.000000000 +0100
12949 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/device_def.h   2010-02-25 12:02:16.000000000 +0100
12950 @@ -0,0 +1,17 @@
12951 +#ifndef _VX_DEVICE_DEF_H
12952 +#define _VX_DEVICE_DEF_H
12953 +
12954 +#include <linux/types.h>
12955 +
12956 +struct vx_dmap_target {
12957 +       dev_t target;
12958 +       uint32_t flags;
12959 +};
12960 +
12961 +struct _vx_device {
12962 +#ifdef CONFIG_VSERVER_DEVICE
12963 +       struct vx_dmap_target targets[2];
12964 +#endif
12965 +};
12966 +
12967 +#endif /* _VX_DEVICE_DEF_H */
12968 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/device.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/device.h
12969 --- linux-2.6.33.2/include/linux/vserver/device.h       1970-01-01 01:00:00.000000000 +0100
12970 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/device.h       2010-02-25 12:02:16.000000000 +0100
12971 @@ -0,0 +1,15 @@
12972 +#ifndef _VX_DEVICE_H
12973 +#define _VX_DEVICE_H
12974 +
12975 +
12976 +#define DATTR_CREATE   0x00000001
12977 +#define DATTR_OPEN     0x00000002
12978 +
12979 +#define DATTR_REMAP    0x00000010
12980 +
12981 +#define DATTR_MASK     0x00000013
12982 +
12983 +
12984 +#else  /* _VX_DEVICE_H */
12985 +#warning duplicate inclusion
12986 +#endif /* _VX_DEVICE_H */
12987 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/dlimit_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/dlimit_cmd.h
12988 --- linux-2.6.33.2/include/linux/vserver/dlimit_cmd.h   1970-01-01 01:00:00.000000000 +0100
12989 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/dlimit_cmd.h   2010-02-25 12:02:16.000000000 +0100
12990 @@ -0,0 +1,109 @@
12991 +#ifndef _VX_DLIMIT_CMD_H
12992 +#define _VX_DLIMIT_CMD_H
12993 +
12994 +
12995 +/*  dlimit vserver commands */
12996 +
12997 +#define VCMD_add_dlimit                VC_CMD(DLIMIT, 1, 0)
12998 +#define VCMD_rem_dlimit                VC_CMD(DLIMIT, 2, 0)
12999 +
13000 +#define VCMD_set_dlimit                VC_CMD(DLIMIT, 5, 0)
13001 +#define VCMD_get_dlimit                VC_CMD(DLIMIT, 6, 0)
13002 +
13003 +struct vcmd_ctx_dlimit_base_v0 {
13004 +       const char __user *name;
13005 +       uint32_t flags;
13006 +};
13007 +
13008 +struct vcmd_ctx_dlimit_v0 {
13009 +       const char __user *name;
13010 +       uint32_t space_used;                    /* used space in kbytes */
13011 +       uint32_t space_total;                   /* maximum space in kbytes */
13012 +       uint32_t inodes_used;                   /* used inodes */
13013 +       uint32_t inodes_total;                  /* maximum inodes */
13014 +       uint32_t reserved;                      /* reserved for root in % */
13015 +       uint32_t flags;
13016 +};
13017 +
13018 +#define CDLIM_UNSET            ((uint32_t)0UL)
13019 +#define CDLIM_INFINITY         ((uint32_t)~0UL)
13020 +#define CDLIM_KEEP             ((uint32_t)~1UL)
13021 +
13022 +#define DLIME_UNIT     0
13023 +#define DLIME_KILO     1
13024 +#define DLIME_MEGA     2
13025 +#define DLIME_GIGA     3
13026 +
13027 +#define DLIMF_SHIFT    0x10
13028 +
13029 +#define DLIMS_USED     0
13030 +#define DLIMS_TOTAL    2
13031 +
13032 +static inline
13033 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
13034 +{
13035 +       int exp = (flags & DLIMF_SHIFT) ?
13036 +               (flags >> shift) & DLIME_GIGA : DLIME_KILO;
13037 +       return ((uint64_t)val) << (10 * exp);
13038 +}
13039 +
13040 +static inline
13041 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
13042 +{
13043 +       int exp = 0;
13044 +
13045 +       if (*flags & DLIMF_SHIFT) {
13046 +               while (val > (1LL << 32) && (exp < 3)) {
13047 +                       val >>= 10;
13048 +                       exp++;
13049 +               }
13050 +               *flags &= ~(DLIME_GIGA << shift);
13051 +               *flags |= exp << shift;
13052 +       } else
13053 +               val >>= 10;
13054 +       return val;
13055 +}
13056 +
13057 +#ifdef __KERNEL__
13058 +
13059 +#ifdef CONFIG_COMPAT
13060 +
13061 +#include <asm/compat.h>
13062 +
13063 +struct vcmd_ctx_dlimit_base_v0_x32 {
13064 +       compat_uptr_t name_ptr;
13065 +       uint32_t flags;
13066 +};
13067 +
13068 +struct vcmd_ctx_dlimit_v0_x32 {
13069 +       compat_uptr_t name_ptr;
13070 +       uint32_t space_used;                    /* used space in kbytes */
13071 +       uint32_t space_total;                   /* maximum space in kbytes */
13072 +       uint32_t inodes_used;                   /* used inodes */
13073 +       uint32_t inodes_total;                  /* maximum inodes */
13074 +       uint32_t reserved;                      /* reserved for root in % */
13075 +       uint32_t flags;
13076 +};
13077 +
13078 +#endif /* CONFIG_COMPAT */
13079 +
13080 +#include <linux/compiler.h>
13081 +
13082 +extern int vc_add_dlimit(uint32_t, void __user *);
13083 +extern int vc_rem_dlimit(uint32_t, void __user *);
13084 +
13085 +extern int vc_set_dlimit(uint32_t, void __user *);
13086 +extern int vc_get_dlimit(uint32_t, void __user *);
13087 +
13088 +#ifdef CONFIG_COMPAT
13089 +
13090 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
13091 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
13092 +
13093 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
13094 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
13095 +
13096 +#endif /* CONFIG_COMPAT */
13097 +
13098 +#endif /* __KERNEL__ */
13099 +#endif /* _VX_DLIMIT_CMD_H */
13100 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/dlimit.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/dlimit.h
13101 --- linux-2.6.33.2/include/linux/vserver/dlimit.h       1970-01-01 01:00:00.000000000 +0100
13102 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/dlimit.h       2010-02-25 12:02:16.000000000 +0100
13103 @@ -0,0 +1,54 @@
13104 +#ifndef _VX_DLIMIT_H
13105 +#define _VX_DLIMIT_H
13106 +
13107 +#include "switch.h"
13108 +
13109 +
13110 +#ifdef __KERNEL__
13111 +
13112 +/*      keep in sync with CDLIM_INFINITY       */
13113 +
13114 +#define DLIM_INFINITY          (~0ULL)
13115 +
13116 +#include <linux/spinlock.h>
13117 +#include <linux/rcupdate.h>
13118 +
13119 +struct super_block;
13120 +
13121 +struct dl_info {
13122 +       struct hlist_node dl_hlist;             /* linked list of contexts */
13123 +       struct rcu_head dl_rcu;                 /* the rcu head */
13124 +       tag_t dl_tag;                           /* context tag */
13125 +       atomic_t dl_usecnt;                     /* usage count */
13126 +       atomic_t dl_refcnt;                     /* reference count */
13127 +
13128 +       struct super_block *dl_sb;              /* associated superblock */
13129 +
13130 +       spinlock_t dl_lock;                     /* protect the values */
13131 +
13132 +       unsigned long long dl_space_used;       /* used space in bytes */
13133 +       unsigned long long dl_space_total;      /* maximum space in bytes */
13134 +       unsigned long dl_inodes_used;           /* used inodes */
13135 +       unsigned long dl_inodes_total;          /* maximum inodes */
13136 +
13137 +       unsigned int dl_nrlmult;                /* non root limit mult */
13138 +};
13139 +
13140 +struct rcu_head;
13141 +
13142 +extern void rcu_free_dl_info(struct rcu_head *);
13143 +extern void unhash_dl_info(struct dl_info *);
13144 +
13145 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
13146 +
13147 +
13148 +struct kstatfs;
13149 +
13150 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
13151 +
13152 +typedef uint64_t dlsize_t;
13153 +
13154 +#endif /* __KERNEL__ */
13155 +#else  /* _VX_DLIMIT_H */
13156 +#warning duplicate inclusion
13157 +#endif /* _VX_DLIMIT_H */
13158 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/global.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/global.h
13159 --- linux-2.6.33.2/include/linux/vserver/global.h       1970-01-01 01:00:00.000000000 +0100
13160 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/global.h       2010-02-25 12:02:16.000000000 +0100
13161 @@ -0,0 +1,19 @@
13162 +#ifndef _VX_GLOBAL_H
13163 +#define _VX_GLOBAL_H
13164 +
13165 +
13166 +extern atomic_t vx_global_ctotal;
13167 +extern atomic_t vx_global_cactive;
13168 +
13169 +extern atomic_t nx_global_ctotal;
13170 +extern atomic_t nx_global_cactive;
13171 +
13172 +extern atomic_t vs_global_nsproxy;
13173 +extern atomic_t vs_global_fs;
13174 +extern atomic_t vs_global_mnt_ns;
13175 +extern atomic_t vs_global_uts_ns;
13176 +extern atomic_t vs_global_user_ns;
13177 +extern atomic_t vs_global_pid_ns;
13178 +
13179 +
13180 +#endif /* _VX_GLOBAL_H */
13181 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/history.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/history.h
13182 --- linux-2.6.33.2/include/linux/vserver/history.h      1970-01-01 01:00:00.000000000 +0100
13183 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/history.h      2010-02-25 12:02:16.000000000 +0100
13184 @@ -0,0 +1,197 @@
13185 +#ifndef _VX_HISTORY_H
13186 +#define _VX_HISTORY_H
13187 +
13188 +
13189 +enum {
13190 +       VXH_UNUSED = 0,
13191 +       VXH_THROW_OOPS = 1,
13192 +
13193 +       VXH_GET_VX_INFO,
13194 +       VXH_PUT_VX_INFO,
13195 +       VXH_INIT_VX_INFO,
13196 +       VXH_SET_VX_INFO,
13197 +       VXH_CLR_VX_INFO,
13198 +       VXH_CLAIM_VX_INFO,
13199 +       VXH_RELEASE_VX_INFO,
13200 +       VXH_ALLOC_VX_INFO,
13201 +       VXH_DEALLOC_VX_INFO,
13202 +       VXH_HASH_VX_INFO,
13203 +       VXH_UNHASH_VX_INFO,
13204 +       VXH_LOC_VX_INFO,
13205 +       VXH_LOOKUP_VX_INFO,
13206 +       VXH_CREATE_VX_INFO,
13207 +};
13208 +
13209 +struct _vxhe_vxi {
13210 +       struct vx_info *ptr;
13211 +       unsigned xid;
13212 +       unsigned usecnt;
13213 +       unsigned tasks;
13214 +};
13215 +
13216 +struct _vxhe_set_clr {
13217 +       void *data;
13218 +};
13219 +
13220 +struct _vxhe_loc_lookup {
13221 +       unsigned arg;
13222 +};
13223 +
13224 +struct _vx_hist_entry {
13225 +       void *loc;
13226 +       unsigned short seq;
13227 +       unsigned short type;
13228 +       struct _vxhe_vxi vxi;
13229 +       union {
13230 +               struct _vxhe_set_clr sc;
13231 +               struct _vxhe_loc_lookup ll;
13232 +       };
13233 +};
13234 +
13235 +#ifdef CONFIG_VSERVER_HISTORY
13236 +
13237 +extern unsigned volatile int vxh_active;
13238 +
13239 +struct _vx_hist_entry *vxh_advance(void *loc);
13240 +
13241 +
13242 +static inline
13243 +void   __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
13244 +{
13245 +       entry->vxi.ptr = vxi;
13246 +       if (vxi) {
13247 +               entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
13248 +               entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
13249 +               entry->vxi.xid = vxi->vx_id;
13250 +       }
13251 +}
13252 +
13253 +
13254 +#define        __HERE__ current_text_addr()
13255 +
13256 +#define __VXH_BODY(__type, __data, __here)     \
13257 +       struct _vx_hist_entry *entry;           \
13258 +                                               \
13259 +       preempt_disable();                      \
13260 +       entry = vxh_advance(__here);            \
13261 +       __data;                                 \
13262 +       entry->type = __type;                   \
13263 +       preempt_enable();
13264 +
13265 +
13266 +       /* pass vxi only */
13267 +
13268 +#define __VXH_SMPL                             \
13269 +       __vxh_copy_vxi(entry, vxi)
13270 +
13271 +static inline
13272 +void   __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
13273 +{
13274 +       __VXH_BODY(__type, __VXH_SMPL, __here)
13275 +}
13276 +
13277 +       /* pass vxi and data (void *) */
13278 +
13279 +#define __VXH_DATA                             \
13280 +       __vxh_copy_vxi(entry, vxi);             \
13281 +       entry->sc.data = data
13282 +
13283 +static inline
13284 +void   __vxh_data(struct vx_info *vxi, void *data,
13285 +                       int __type, void *__here)
13286 +{
13287 +       __VXH_BODY(__type, __VXH_DATA, __here)
13288 +}
13289 +
13290 +       /* pass vxi and arg (long) */
13291 +
13292 +#define __VXH_LONG                             \
13293 +       __vxh_copy_vxi(entry, vxi);             \
13294 +       entry->ll.arg = arg
13295 +
13296 +static inline
13297 +void   __vxh_long(struct vx_info *vxi, long arg,
13298 +                       int __type, void *__here)
13299 +{
13300 +       __VXH_BODY(__type, __VXH_LONG, __here)
13301 +}
13302 +
13303 +
13304 +static inline
13305 +void   __vxh_throw_oops(void *__here)
13306 +{
13307 +       __VXH_BODY(VXH_THROW_OOPS, {}, __here);
13308 +       /* prevent further acquisition */
13309 +       vxh_active = 0;
13310 +}
13311 +
13312 +
13313 +#define vxh_throw_oops()       __vxh_throw_oops(__HERE__);
13314 +
13315 +#define __vxh_get_vx_info(v, h)        __vxh_smpl(v, VXH_GET_VX_INFO, h);
13316 +#define __vxh_put_vx_info(v, h)        __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13317 +
13318 +#define __vxh_init_vx_info(v, d, h) \
13319 +       __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13320 +#define __vxh_set_vx_info(v, d, h) \
13321 +       __vxh_data(v, d, VXH_SET_VX_INFO, h);
13322 +#define __vxh_clr_vx_info(v, d, h) \
13323 +       __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13324 +
13325 +#define __vxh_claim_vx_info(v, d, h) \
13326 +       __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13327 +#define __vxh_release_vx_info(v, d, h) \
13328 +       __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13329 +
13330 +#define vxh_alloc_vx_info(v) \
13331 +       __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13332 +#define vxh_dealloc_vx_info(v) \
13333 +       __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13334 +
13335 +#define vxh_hash_vx_info(v) \
13336 +       __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13337 +#define vxh_unhash_vx_info(v) \
13338 +       __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13339 +
13340 +#define vxh_loc_vx_info(v, l) \
13341 +       __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13342 +#define vxh_lookup_vx_info(v, l) \
13343 +       __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13344 +#define vxh_create_vx_info(v, l) \
13345 +       __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13346 +
13347 +extern void vxh_dump_history(void);
13348 +
13349 +
13350 +#else  /* CONFIG_VSERVER_HISTORY */
13351 +
13352 +#define        __HERE__        0
13353 +
13354 +#define vxh_throw_oops()               do { } while (0)
13355 +
13356 +#define __vxh_get_vx_info(v, h)                do { } while (0)
13357 +#define __vxh_put_vx_info(v, h)                do { } while (0)
13358 +
13359 +#define __vxh_init_vx_info(v, d, h)    do { } while (0)
13360 +#define __vxh_set_vx_info(v, d, h)     do { } while (0)
13361 +#define __vxh_clr_vx_info(v, d, h)     do { } while (0)
13362 +
13363 +#define __vxh_claim_vx_info(v, d, h)   do { } while (0)
13364 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13365 +
13366 +#define vxh_alloc_vx_info(v)           do { } while (0)
13367 +#define vxh_dealloc_vx_info(v)         do { } while (0)
13368 +
13369 +#define vxh_hash_vx_info(v)            do { } while (0)
13370 +#define vxh_unhash_vx_info(v)          do { } while (0)
13371 +
13372 +#define vxh_loc_vx_info(v, l)          do { } while (0)
13373 +#define vxh_lookup_vx_info(v, l)       do { } while (0)
13374 +#define vxh_create_vx_info(v, l)       do { } while (0)
13375 +
13376 +#define vxh_dump_history()             do { } while (0)
13377 +
13378 +
13379 +#endif /* CONFIG_VSERVER_HISTORY */
13380 +
13381 +#endif /* _VX_HISTORY_H */
13382 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/inode_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/inode_cmd.h
13383 --- linux-2.6.33.2/include/linux/vserver/inode_cmd.h    1970-01-01 01:00:00.000000000 +0100
13384 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/inode_cmd.h    2010-02-25 12:02:16.000000000 +0100
13385 @@ -0,0 +1,59 @@
13386 +#ifndef _VX_INODE_CMD_H
13387 +#define _VX_INODE_CMD_H
13388 +
13389 +
13390 +/*  inode vserver commands */
13391 +
13392 +#define VCMD_get_iattr         VC_CMD(INODE, 1, 1)
13393 +#define VCMD_set_iattr         VC_CMD(INODE, 2, 1)
13394 +
13395 +#define VCMD_fget_iattr                VC_CMD(INODE, 3, 0)
13396 +#define VCMD_fset_iattr                VC_CMD(INODE, 4, 0)
13397 +
13398 +struct vcmd_ctx_iattr_v1 {
13399 +       const char __user *name;
13400 +       uint32_t tag;
13401 +       uint32_t flags;
13402 +       uint32_t mask;
13403 +};
13404 +
13405 +struct vcmd_ctx_fiattr_v0 {
13406 +       uint32_t tag;
13407 +       uint32_t flags;
13408 +       uint32_t mask;
13409 +};
13410 +
13411 +
13412 +#ifdef __KERNEL__
13413 +
13414 +
13415 +#ifdef CONFIG_COMPAT
13416 +
13417 +#include <asm/compat.h>
13418 +
13419 +struct vcmd_ctx_iattr_v1_x32 {
13420 +       compat_uptr_t name_ptr;
13421 +       uint32_t tag;
13422 +       uint32_t flags;
13423 +       uint32_t mask;
13424 +};
13425 +
13426 +#endif /* CONFIG_COMPAT */
13427 +
13428 +#include <linux/compiler.h>
13429 +
13430 +extern int vc_get_iattr(void __user *);
13431 +extern int vc_set_iattr(void __user *);
13432 +
13433 +extern int vc_fget_iattr(uint32_t, void __user *);
13434 +extern int vc_fset_iattr(uint32_t, void __user *);
13435 +
13436 +#ifdef CONFIG_COMPAT
13437 +
13438 +extern int vc_get_iattr_x32(void __user *);
13439 +extern int vc_set_iattr_x32(void __user *);
13440 +
13441 +#endif /* CONFIG_COMPAT */
13442 +
13443 +#endif /* __KERNEL__ */
13444 +#endif /* _VX_INODE_CMD_H */
13445 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/inode.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/inode.h
13446 --- linux-2.6.33.2/include/linux/vserver/inode.h        1970-01-01 01:00:00.000000000 +0100
13447 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/inode.h        2010-02-25 12:02:16.000000000 +0100
13448 @@ -0,0 +1,39 @@
13449 +#ifndef _VX_INODE_H
13450 +#define _VX_INODE_H
13451 +
13452 +
13453 +#define IATTR_TAG      0x01000000
13454 +
13455 +#define IATTR_ADMIN    0x00000001
13456 +#define IATTR_WATCH    0x00000002
13457 +#define IATTR_HIDE     0x00000004
13458 +#define IATTR_FLAGS    0x00000007
13459 +
13460 +#define IATTR_BARRIER  0x00010000
13461 +#define IATTR_IXUNLINK 0x00020000
13462 +#define IATTR_IMMUTABLE 0x00040000
13463 +#define IATTR_COW      0x00080000
13464 +
13465 +#ifdef __KERNEL__
13466 +
13467 +
13468 +#ifdef CONFIG_VSERVER_PROC_SECURE
13469 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN | IATTR_HIDE )
13470 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
13471 +#else
13472 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN )
13473 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
13474 +#endif
13475 +
13476 +#define vx_hide_check(c, m)    (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
13477 +
13478 +#endif /* __KERNEL__ */
13479 +
13480 +/* inode ioctls */
13481 +
13482 +#define FIOC_GETXFLG   _IOR('x', 5, long)
13483 +#define FIOC_SETXFLG   _IOW('x', 6, long)
13484 +
13485 +#else  /* _VX_INODE_H */
13486 +#warning duplicate inclusion
13487 +#endif /* _VX_INODE_H */
13488 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/Kbuild linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/Kbuild
13489 --- linux-2.6.33.2/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
13490 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/Kbuild 2010-02-25 12:02:16.000000000 +0100
13491 @@ -0,0 +1,8 @@
13492 +
13493 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
13494 +       cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
13495 +       inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
13496 +       debug_cmd.h device_cmd.h
13497 +
13498 +unifdef-y += switch.h network.h monitor.h inode.h device.h
13499 +
13500 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/limit_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/limit_cmd.h
13501 --- linux-2.6.33.2/include/linux/vserver/limit_cmd.h    1970-01-01 01:00:00.000000000 +0100
13502 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/limit_cmd.h    2010-02-25 12:02:16.000000000 +0100
13503 @@ -0,0 +1,71 @@
13504 +#ifndef _VX_LIMIT_CMD_H
13505 +#define _VX_LIMIT_CMD_H
13506 +
13507 +
13508 +/*  rlimit vserver commands */
13509 +
13510 +#define VCMD_get_rlimit                VC_CMD(RLIMIT, 1, 0)
13511 +#define VCMD_set_rlimit                VC_CMD(RLIMIT, 2, 0)
13512 +#define VCMD_get_rlimit_mask   VC_CMD(RLIMIT, 3, 0)
13513 +#define VCMD_reset_hits                VC_CMD(RLIMIT, 7, 0)
13514 +#define VCMD_reset_minmax      VC_CMD(RLIMIT, 9, 0)
13515 +
13516 +struct vcmd_ctx_rlimit_v0 {
13517 +       uint32_t id;
13518 +       uint64_t minimum;
13519 +       uint64_t softlimit;
13520 +       uint64_t maximum;
13521 +};
13522 +
13523 +struct vcmd_ctx_rlimit_mask_v0 {
13524 +       uint32_t minimum;
13525 +       uint32_t softlimit;
13526 +       uint32_t maximum;
13527 +};
13528 +
13529 +#define VCMD_rlimit_stat       VC_CMD(VSTAT, 1, 0)
13530 +
13531 +struct vcmd_rlimit_stat_v0 {
13532 +       uint32_t id;
13533 +       uint32_t hits;
13534 +       uint64_t value;
13535 +       uint64_t minimum;
13536 +       uint64_t maximum;
13537 +};
13538 +
13539 +#define CRLIM_UNSET            (0ULL)
13540 +#define CRLIM_INFINITY         (~0ULL)
13541 +#define CRLIM_KEEP             (~1ULL)
13542 +
13543 +#ifdef __KERNEL__
13544 +
13545 +#ifdef CONFIG_IA32_EMULATION
13546 +
13547 +struct vcmd_ctx_rlimit_v0_x32 {
13548 +       uint32_t id;
13549 +       uint64_t minimum;
13550 +       uint64_t softlimit;
13551 +       uint64_t maximum;
13552 +} __attribute__ ((packed));
13553 +
13554 +#endif /* CONFIG_IA32_EMULATION */
13555 +
13556 +#include <linux/compiler.h>
13557 +
13558 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13559 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13560 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13561 +extern int vc_reset_hits(struct vx_info *, void __user *);
13562 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13563 +
13564 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13565 +
13566 +#ifdef CONFIG_IA32_EMULATION
13567 +
13568 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13569 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13570 +
13571 +#endif /* CONFIG_IA32_EMULATION */
13572 +
13573 +#endif /* __KERNEL__ */
13574 +#endif /* _VX_LIMIT_CMD_H */
13575 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/limit_def.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/limit_def.h
13576 --- linux-2.6.33.2/include/linux/vserver/limit_def.h    1970-01-01 01:00:00.000000000 +0100
13577 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/limit_def.h    2010-02-25 12:02:16.000000000 +0100
13578 @@ -0,0 +1,47 @@
13579 +#ifndef _VX_LIMIT_DEF_H
13580 +#define _VX_LIMIT_DEF_H
13581 +
13582 +#include <asm/atomic.h>
13583 +#include <asm/resource.h>
13584 +
13585 +#include "limit.h"
13586 +
13587 +
13588 +struct _vx_res_limit {
13589 +       rlim_t soft;            /* Context soft limit */
13590 +       rlim_t hard;            /* Context hard limit */
13591 +
13592 +       rlim_atomic_t rcur;     /* Current value */
13593 +       rlim_t rmin;            /* Context minimum */
13594 +       rlim_t rmax;            /* Context maximum */
13595 +
13596 +       atomic_t lhit;          /* Limit hits */
13597 +};
13598 +
13599 +/* context sub struct */
13600 +
13601 +struct _vx_limit {
13602 +       struct _vx_res_limit res[NUM_LIMITS];
13603 +};
13604 +
13605 +#ifdef CONFIG_VSERVER_DEBUG
13606 +
13607 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13608 +{
13609 +       int i;
13610 +
13611 +       printk("\t_vx_limit:");
13612 +       for (i = 0; i < NUM_LIMITS; i++) {
13613 +               printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13614 +                       i, (unsigned long)__rlim_get(limit, i),
13615 +                       (unsigned long)__rlim_rmin(limit, i),
13616 +                       (unsigned long)__rlim_rmax(limit, i),
13617 +                       (long)__rlim_soft(limit, i),
13618 +                       (long)__rlim_hard(limit, i),
13619 +                       atomic_read(&__rlim_lhit(limit, i)));
13620 +       }
13621 +}
13622 +
13623 +#endif
13624 +
13625 +#endif /* _VX_LIMIT_DEF_H */
13626 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/limit.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/limit.h
13627 --- linux-2.6.33.2/include/linux/vserver/limit.h        1970-01-01 01:00:00.000000000 +0100
13628 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/limit.h        2010-02-25 12:02:16.000000000 +0100
13629 @@ -0,0 +1,71 @@
13630 +#ifndef _VX_LIMIT_H
13631 +#define _VX_LIMIT_H
13632 +
13633 +#define VLIMIT_NSOCK   16
13634 +#define VLIMIT_OPENFD  17
13635 +#define VLIMIT_ANON    18
13636 +#define VLIMIT_SHMEM   19
13637 +#define VLIMIT_SEMARY  20
13638 +#define VLIMIT_NSEMS   21
13639 +#define VLIMIT_DENTRY  22
13640 +#define VLIMIT_MAPPED  23
13641 +
13642 +
13643 +#ifdef __KERNEL__
13644 +
13645 +#define        VLIM_NOCHECK    ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13646 +
13647 +/*     keep in sync with CRLIM_INFINITY */
13648 +
13649 +#define        VLIM_INFINITY   (~0ULL)
13650 +
13651 +#include <asm/atomic.h>
13652 +#include <asm/resource.h>
13653 +
13654 +#ifndef RLIM_INFINITY
13655 +#warning RLIM_INFINITY is undefined
13656 +#endif
13657 +
13658 +#define __rlim_val(l, r, v)    ((l)->res[r].v)
13659 +
13660 +#define __rlim_soft(l, r)      __rlim_val(l, r, soft)
13661 +#define __rlim_hard(l, r)      __rlim_val(l, r, hard)
13662 +
13663 +#define __rlim_rcur(l, r)      __rlim_val(l, r, rcur)
13664 +#define __rlim_rmin(l, r)      __rlim_val(l, r, rmin)
13665 +#define __rlim_rmax(l, r)      __rlim_val(l, r, rmax)
13666 +
13667 +#define __rlim_lhit(l, r)      __rlim_val(l, r, lhit)
13668 +#define __rlim_hit(l, r)       atomic_inc(&__rlim_lhit(l, r))
13669 +
13670 +typedef atomic_long_t rlim_atomic_t;
13671 +typedef unsigned long rlim_t;
13672 +
13673 +#define __rlim_get(l, r)       atomic_long_read(&__rlim_rcur(l, r))
13674 +#define __rlim_set(l, r, v)    atomic_long_set(&__rlim_rcur(l, r), v)
13675 +#define __rlim_inc(l, r)       atomic_long_inc(&__rlim_rcur(l, r))
13676 +#define __rlim_dec(l, r)       atomic_long_dec(&__rlim_rcur(l, r))
13677 +#define __rlim_add(l, r, v)    atomic_long_add(v, &__rlim_rcur(l, r))
13678 +#define __rlim_sub(l, r, v)    atomic_long_sub(v, &__rlim_rcur(l, r))
13679 +
13680 +
13681 +#if    (RLIM_INFINITY == VLIM_INFINITY)
13682 +#define        VX_VLIM(r) ((long long)(long)(r))
13683 +#define        VX_RLIM(v) ((rlim_t)(v))
13684 +#else
13685 +#define        VX_VLIM(r) (((r) == RLIM_INFINITY) \
13686 +               ? VLIM_INFINITY : (long long)(r))
13687 +#define        VX_RLIM(v) (((v) == VLIM_INFINITY) \
13688 +               ? RLIM_INFINITY : (rlim_t)(v))
13689 +#endif
13690 +
13691 +struct sysinfo;
13692 +
13693 +void vx_vsi_meminfo(struct sysinfo *);
13694 +void vx_vsi_swapinfo(struct sysinfo *);
13695 +long vx_vsi_cached(struct sysinfo *);
13696 +
13697 +#define NUM_LIMITS     24
13698 +
13699 +#endif /* __KERNEL__ */
13700 +#endif /* _VX_LIMIT_H */
13701 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/limit_int.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/limit_int.h
13702 --- linux-2.6.33.2/include/linux/vserver/limit_int.h    1970-01-01 01:00:00.000000000 +0100
13703 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/limit_int.h    2010-02-25 12:02:16.000000000 +0100
13704 @@ -0,0 +1,198 @@
13705 +#ifndef _VX_LIMIT_INT_H
13706 +#define _VX_LIMIT_INT_H
13707 +
13708 +#include "context.h"
13709 +
13710 +#ifdef __KERNEL__
13711 +
13712 +#define VXD_RCRES_COND(r)      VXD_CBIT(cres, r)
13713 +#define VXD_RLIMIT_COND(r)     VXD_CBIT(limit, r)
13714 +
13715 +extern const char *vlimit_name[NUM_LIMITS];
13716 +
13717 +static inline void __vx_acc_cres(struct vx_info *vxi,
13718 +       int res, int dir, void *_data, char *_file, int _line)
13719 +{
13720 +       if (VXD_RCRES_COND(res))
13721 +               vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13722 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13723 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13724 +                       (dir > 0) ? "++" : "--", _data, _file, _line);
13725 +       if (!vxi)
13726 +               return;
13727 +
13728 +       if (dir > 0)
13729 +               __rlim_inc(&vxi->limit, res);
13730 +       else
13731 +               __rlim_dec(&vxi->limit, res);
13732 +}
13733 +
13734 +static inline void __vx_add_cres(struct vx_info *vxi,
13735 +       int res, int amount, void *_data, char *_file, int _line)
13736 +{
13737 +       if (VXD_RCRES_COND(res))
13738 +               vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13739 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13740 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13741 +                       amount, _data, _file, _line);
13742 +       if (amount == 0)
13743 +               return;
13744 +       if (!vxi)
13745 +               return;
13746 +       __rlim_add(&vxi->limit, res, amount);
13747 +}
13748 +
13749 +static inline
13750 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13751 +{
13752 +       int cond = (value > __rlim_rmax(limit, res));
13753 +
13754 +       if (cond)
13755 +               __rlim_rmax(limit, res) = value;
13756 +       return cond;
13757 +}
13758 +
13759 +static inline
13760 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13761 +{
13762 +       int cond = (value < __rlim_rmin(limit, res));
13763 +
13764 +       if (cond)
13765 +               __rlim_rmin(limit, res) = value;
13766 +       return cond;
13767 +}
13768 +
13769 +static inline
13770 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13771 +{
13772 +       if (!__vx_cres_adjust_max(limit, res, value))
13773 +               __vx_cres_adjust_min(limit, res, value);
13774 +}
13775 +
13776 +
13777 +/*     return values:
13778 +        +1 ... no limit hit
13779 +        -1 ... over soft limit
13780 +         0 ... over hard limit         */
13781 +
13782 +static inline int __vx_cres_avail(struct vx_info *vxi,
13783 +       int res, int num, char *_file, int _line)
13784 +{
13785 +       struct _vx_limit *limit;
13786 +       rlim_t value;
13787 +
13788 +       if (VXD_RLIMIT_COND(res))
13789 +               vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13790 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13791 +                       (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13792 +                       (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13793 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13794 +                       num, _file, _line);
13795 +       if (!vxi)
13796 +               return 1;
13797 +
13798 +       limit = &vxi->limit;
13799 +       value = __rlim_get(limit, res);
13800 +
13801 +       if (!__vx_cres_adjust_max(limit, res, value))
13802 +               __vx_cres_adjust_min(limit, res, value);
13803 +
13804 +       if (num == 0)
13805 +               return 1;
13806 +
13807 +       if (__rlim_soft(limit, res) == RLIM_INFINITY)
13808 +               return -1;
13809 +       if (value + num <= __rlim_soft(limit, res))
13810 +               return -1;
13811 +
13812 +       if (__rlim_hard(limit, res) == RLIM_INFINITY)
13813 +               return 1;
13814 +       if (value + num <= __rlim_hard(limit, res))
13815 +               return 1;
13816 +
13817 +       __rlim_hit(limit, res);
13818 +       return 0;
13819 +}
13820 +
13821 +
13822 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13823 +
13824 +static inline
13825 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13826 +{
13827 +       rlim_t value, sum = 0;
13828 +       int res;
13829 +
13830 +       while ((res = *array++)) {
13831 +               value = __rlim_get(limit, res);
13832 +               __vx_cres_fixup(limit, res, value);
13833 +               sum += value;
13834 +       }
13835 +       return sum;
13836 +}
13837 +
13838 +static inline
13839 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13840 +{
13841 +       rlim_t value = __vx_cres_array_sum(limit, array + 1);
13842 +       int res = *array;
13843 +
13844 +       if (value == __rlim_get(limit, res))
13845 +               return value;
13846 +
13847 +       __rlim_set(limit, res, value);
13848 +       /* now adjust min/max */
13849 +       if (!__vx_cres_adjust_max(limit, res, value))
13850 +               __vx_cres_adjust_min(limit, res, value);
13851 +
13852 +       return value;
13853 +}
13854 +
13855 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13856 +       const int *array, int num, char *_file, int _line)
13857 +{
13858 +       struct _vx_limit *limit;
13859 +       rlim_t value = 0;
13860 +       int res;
13861 +
13862 +       if (num == 0)
13863 +               return 1;
13864 +       if (!vxi)
13865 +               return 1;
13866 +
13867 +       limit = &vxi->limit;
13868 +       res = *array;
13869 +       value = __vx_cres_array_sum(limit, array + 1);
13870 +
13871 +       __rlim_set(limit, res, value);
13872 +       __vx_cres_fixup(limit, res, value);
13873 +
13874 +       return __vx_cres_avail(vxi, res, num, _file, _line);
13875 +}
13876 +
13877 +
13878 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13879 +{
13880 +       rlim_t value;
13881 +       int res;
13882 +
13883 +       /* complex resources first */
13884 +       if ((id < 0) || (id == RLIMIT_RSS))
13885 +               __vx_cres_array_fixup(limit, VLA_RSS);
13886 +
13887 +       for (res = 0; res < NUM_LIMITS; res++) {
13888 +               if ((id > 0) && (res != id))
13889 +                       continue;
13890 +
13891 +               value = __rlim_get(limit, res);
13892 +               __vx_cres_fixup(limit, res, value);
13893 +
13894 +               /* not supposed to happen, maybe warn? */
13895 +               if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13896 +                       __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13897 +       }
13898 +}
13899 +
13900 +
13901 +#endif /* __KERNEL__ */
13902 +#endif /* _VX_LIMIT_INT_H */
13903 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/monitor.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/monitor.h
13904 --- linux-2.6.33.2/include/linux/vserver/monitor.h      1970-01-01 01:00:00.000000000 +0100
13905 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/monitor.h      2010-02-25 12:02:16.000000000 +0100
13906 @@ -0,0 +1,96 @@
13907 +#ifndef _VX_MONITOR_H
13908 +#define _VX_MONITOR_H
13909 +
13910 +#include <linux/types.h>
13911 +
13912 +enum {
13913 +       VXM_UNUSED = 0,
13914 +
13915 +       VXM_SYNC = 0x10,
13916 +
13917 +       VXM_UPDATE = 0x20,
13918 +       VXM_UPDATE_1,
13919 +       VXM_UPDATE_2,
13920 +
13921 +       VXM_RQINFO_1 = 0x24,
13922 +       VXM_RQINFO_2,
13923 +
13924 +       VXM_ACTIVATE = 0x40,
13925 +       VXM_DEACTIVATE,
13926 +       VXM_IDLE,
13927 +
13928 +       VXM_HOLD = 0x44,
13929 +       VXM_UNHOLD,
13930 +
13931 +       VXM_MIGRATE = 0x48,
13932 +       VXM_RESCHED,
13933 +
13934 +       /* all other bits are flags */
13935 +       VXM_SCHED = 0x80,
13936 +};
13937 +
13938 +struct _vxm_update_1 {
13939 +       uint32_t tokens_max;
13940 +       uint32_t fill_rate;
13941 +       uint32_t interval;
13942 +};
13943 +
13944 +struct _vxm_update_2 {
13945 +       uint32_t tokens_min;
13946 +       uint32_t fill_rate;
13947 +       uint32_t interval;
13948 +};
13949 +
13950 +struct _vxm_rqinfo_1 {
13951 +       uint16_t running;
13952 +       uint16_t onhold;
13953 +       uint16_t iowait;
13954 +       uint16_t uintr;
13955 +       uint32_t idle_tokens;
13956 +};
13957 +
13958 +struct _vxm_rqinfo_2 {
13959 +       uint32_t norm_time;
13960 +       uint32_t idle_time;
13961 +       uint32_t idle_skip;
13962 +};
13963 +
13964 +struct _vxm_sched {
13965 +       uint32_t tokens;
13966 +       uint32_t norm_time;
13967 +       uint32_t idle_time;
13968 +};
13969 +
13970 +struct _vxm_task {
13971 +       uint16_t pid;
13972 +       uint16_t state;
13973 +};
13974 +
13975 +struct _vxm_event {
13976 +       uint32_t jif;
13977 +       union {
13978 +               uint32_t seq;
13979 +               uint32_t sec;
13980 +       };
13981 +       union {
13982 +               uint32_t tokens;
13983 +               uint32_t nsec;
13984 +               struct _vxm_task tsk;
13985 +       };
13986 +};
13987 +
13988 +struct _vx_mon_entry {
13989 +       uint16_t type;
13990 +       uint16_t xid;
13991 +       union {
13992 +               struct _vxm_event ev;
13993 +               struct _vxm_sched sd;
13994 +               struct _vxm_update_1 u1;
13995 +               struct _vxm_update_2 u2;
13996 +               struct _vxm_rqinfo_1 q1;
13997 +               struct _vxm_rqinfo_2 q2;
13998 +       };
13999 +};
14000 +
14001 +
14002 +#endif /* _VX_MONITOR_H */
14003 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/network_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/network_cmd.h
14004 --- linux-2.6.33.2/include/linux/vserver/network_cmd.h  1970-01-01 01:00:00.000000000 +0100
14005 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/network_cmd.h  2010-02-25 12:02:16.000000000 +0100
14006 @@ -0,0 +1,150 @@
14007 +#ifndef _VX_NETWORK_CMD_H
14008 +#define _VX_NETWORK_CMD_H
14009 +
14010 +
14011 +/* vinfo commands */
14012 +
14013 +#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
14014 +
14015 +#ifdef __KERNEL__
14016 +extern int vc_task_nid(uint32_t);
14017 +
14018 +#endif /* __KERNEL__ */
14019 +
14020 +#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
14021 +
14022 +struct vcmd_nx_info_v0 {
14023 +       uint32_t nid;
14024 +       /* more to come */
14025 +};
14026 +
14027 +#ifdef __KERNEL__
14028 +extern int vc_nx_info(struct nx_info *, void __user *);
14029 +
14030 +#endif /* __KERNEL__ */
14031 +
14032 +#include <linux/in.h>
14033 +#include <linux/in6.h>
14034 +
14035 +#define VCMD_net_create_v0     VC_CMD(VNET, 1, 0)
14036 +#define VCMD_net_create                VC_CMD(VNET, 1, 1)
14037 +
14038 +struct  vcmd_net_create {
14039 +       uint64_t flagword;
14040 +};
14041 +
14042 +#define VCMD_net_migrate       VC_CMD(NETMIG, 1, 0)
14043 +
14044 +#define VCMD_net_add           VC_CMD(NETALT, 1, 0)
14045 +#define VCMD_net_remove                VC_CMD(NETALT, 2, 0)
14046 +
14047 +struct vcmd_net_addr_v0 {
14048 +       uint16_t type;
14049 +       uint16_t count;
14050 +       struct in_addr ip[4];
14051 +       struct in_addr mask[4];
14052 +};
14053 +
14054 +#define VCMD_net_add_ipv4      VC_CMD(NETALT, 1, 1)
14055 +#define VCMD_net_remove_ipv4   VC_CMD(NETALT, 2, 1)
14056 +
14057 +struct vcmd_net_addr_ipv4_v1 {
14058 +       uint16_t type;
14059 +       uint16_t flags;
14060 +       struct in_addr ip;
14061 +       struct in_addr mask;
14062 +};
14063 +
14064 +#define VCMD_net_add_ipv6      VC_CMD(NETALT, 3, 1)
14065 +#define VCMD_net_remove_ipv6   VC_CMD(NETALT, 4, 1)
14066 +
14067 +struct vcmd_net_addr_ipv6_v1 {
14068 +       uint16_t type;
14069 +       uint16_t flags;
14070 +       uint32_t prefix;
14071 +       struct in6_addr ip;
14072 +       struct in6_addr mask;
14073 +};
14074 +
14075 +#define VCMD_add_match_ipv4    VC_CMD(NETALT, 5, 0)
14076 +#define VCMD_get_match_ipv4    VC_CMD(NETALT, 6, 0)
14077 +
14078 +struct vcmd_match_ipv4_v0 {
14079 +       uint16_t type;
14080 +       uint16_t flags;
14081 +       uint16_t parent;
14082 +       uint16_t prefix;
14083 +       struct in_addr ip;
14084 +       struct in_addr ip2;
14085 +       struct in_addr mask;
14086 +};
14087 +
14088 +#define VCMD_add_match_ipv6    VC_CMD(NETALT, 7, 0)
14089 +#define VCMD_get_match_ipv6    VC_CMD(NETALT, 8, 0)
14090 +
14091 +struct vcmd_match_ipv6_v0 {
14092 +       uint16_t type;
14093 +       uint16_t flags;
14094 +       uint16_t parent;
14095 +       uint16_t prefix;
14096 +       struct in6_addr ip;
14097 +       struct in6_addr ip2;
14098 +       struct in6_addr mask;
14099 +};
14100 +
14101 +
14102 +#ifdef __KERNEL__
14103 +extern int vc_net_create(uint32_t, void __user *);
14104 +extern int vc_net_migrate(struct nx_info *, void __user *);
14105 +
14106 +extern int vc_net_add(struct nx_info *, void __user *);
14107 +extern int vc_net_remove(struct nx_info *, void __user *);
14108 +
14109 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
14110 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
14111 +
14112 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
14113 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
14114 +
14115 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
14116 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
14117 +
14118 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
14119 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
14120 +
14121 +#endif /* __KERNEL__ */
14122 +
14123 +
14124 +/* flag commands */
14125 +
14126 +#define VCMD_get_nflags                VC_CMD(FLAGS, 5, 0)
14127 +#define VCMD_set_nflags                VC_CMD(FLAGS, 6, 0)
14128 +
14129 +struct vcmd_net_flags_v0 {
14130 +       uint64_t flagword;
14131 +       uint64_t mask;
14132 +};
14133 +
14134 +#ifdef __KERNEL__
14135 +extern int vc_get_nflags(struct nx_info *, void __user *);
14136 +extern int vc_set_nflags(struct nx_info *, void __user *);
14137 +
14138 +#endif /* __KERNEL__ */
14139 +
14140 +
14141 +/* network caps commands */
14142 +
14143 +#define VCMD_get_ncaps         VC_CMD(FLAGS, 7, 0)
14144 +#define VCMD_set_ncaps         VC_CMD(FLAGS, 8, 0)
14145 +
14146 +struct vcmd_net_caps_v0 {
14147 +       uint64_t ncaps;
14148 +       uint64_t cmask;
14149 +};
14150 +
14151 +#ifdef __KERNEL__
14152 +extern int vc_get_ncaps(struct nx_info *, void __user *);
14153 +extern int vc_set_ncaps(struct nx_info *, void __user *);
14154 +
14155 +#endif /* __KERNEL__ */
14156 +#endif /* _VX_CONTEXT_CMD_H */
14157 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/network.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/network.h
14158 --- linux-2.6.33.2/include/linux/vserver/network.h      1970-01-01 01:00:00.000000000 +0100
14159 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/network.h      2010-02-25 12:02:16.000000000 +0100
14160 @@ -0,0 +1,146 @@
14161 +#ifndef _VX_NETWORK_H
14162 +#define _VX_NETWORK_H
14163 +
14164 +#include <linux/types.h>
14165 +
14166 +
14167 +#define MAX_N_CONTEXT  65535   /* Arbitrary limit */
14168 +
14169 +
14170 +/* network flags */
14171 +
14172 +#define NXF_INFO_PRIVATE       0x00000008
14173 +
14174 +#define NXF_SINGLE_IP          0x00000100
14175 +#define NXF_LBACK_REMAP                0x00000200
14176 +#define NXF_LBACK_ALLOW                0x00000400
14177 +
14178 +#define NXF_HIDE_NETIF         0x02000000
14179 +#define NXF_HIDE_LBACK         0x04000000
14180 +
14181 +#define NXF_STATE_SETUP                (1ULL << 32)
14182 +#define NXF_STATE_ADMIN                (1ULL << 34)
14183 +
14184 +#define NXF_SC_HELPER          (1ULL << 36)
14185 +#define NXF_PERSISTENT         (1ULL << 38)
14186 +
14187 +#define NXF_ONE_TIME           (0x0005ULL << 32)
14188 +
14189 +
14190 +#define        NXF_INIT_SET            (__nxf_init_set())
14191 +
14192 +static inline uint64_t __nxf_init_set(void) {
14193 +       return    NXF_STATE_ADMIN
14194 +#ifdef CONFIG_VSERVER_AUTO_LBACK
14195 +               | NXF_LBACK_REMAP
14196 +               | NXF_HIDE_LBACK
14197 +#endif
14198 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
14199 +               | NXF_SINGLE_IP
14200 +#endif
14201 +               | NXF_HIDE_NETIF;
14202 +}
14203 +
14204 +
14205 +/* network caps */
14206 +
14207 +#define NXC_TUN_CREATE         0x00000001
14208 +
14209 +#define NXC_RAW_ICMP           0x00000100
14210 +
14211 +
14212 +/* address types */
14213 +
14214 +#define NXA_TYPE_IPV4          0x0001
14215 +#define NXA_TYPE_IPV6          0x0002
14216 +
14217 +#define NXA_TYPE_NONE          0x0000
14218 +#define NXA_TYPE_ANY           0x00FF
14219 +
14220 +#define NXA_TYPE_ADDR          0x0010
14221 +#define NXA_TYPE_MASK          0x0020
14222 +#define NXA_TYPE_RANGE         0x0040
14223 +
14224 +#define NXA_MASK_ALL           (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
14225 +
14226 +#define NXA_MOD_BCAST          0x0100
14227 +#define NXA_MOD_LBACK          0x0200
14228 +
14229 +#define NXA_LOOPBACK           0x1000
14230 +
14231 +#define NXA_MASK_BIND          (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
14232 +#define NXA_MASK_SHOW          (NXA_MASK_ALL | NXA_LOOPBACK)
14233 +
14234 +#ifdef __KERNEL__
14235 +
14236 +#include <linux/list.h>
14237 +#include <linux/spinlock.h>
14238 +#include <linux/rcupdate.h>
14239 +#include <linux/in.h>
14240 +#include <linux/in6.h>
14241 +#include <asm/atomic.h>
14242 +
14243 +struct nx_addr_v4 {
14244 +       struct nx_addr_v4 *next;
14245 +       struct in_addr ip[2];
14246 +       struct in_addr mask;
14247 +       uint16_t type;
14248 +       uint16_t flags;
14249 +};
14250 +
14251 +struct nx_addr_v6 {
14252 +       struct nx_addr_v6 *next;
14253 +       struct in6_addr ip;
14254 +       struct in6_addr mask;
14255 +       uint32_t prefix;
14256 +       uint16_t type;
14257 +       uint16_t flags;
14258 +};
14259 +
14260 +struct nx_info {
14261 +       struct hlist_node nx_hlist;     /* linked list of nxinfos */
14262 +       nid_t nx_id;                    /* vnet id */
14263 +       atomic_t nx_usecnt;             /* usage count */
14264 +       atomic_t nx_tasks;              /* tasks count */
14265 +       int nx_state;                   /* context state */
14266 +
14267 +       uint64_t nx_flags;              /* network flag word */
14268 +       uint64_t nx_ncaps;              /* network capabilities */
14269 +
14270 +       struct in_addr v4_lback;        /* Loopback address */
14271 +       struct in_addr v4_bcast;        /* Broadcast address */
14272 +       struct nx_addr_v4 v4;           /* First/Single ipv4 address */
14273 +#ifdef CONFIG_IPV6
14274 +       struct nx_addr_v6 v6;           /* First/Single ipv6 address */
14275 +#endif
14276 +       char nx_name[65];               /* network context name */
14277 +};
14278 +
14279 +
14280 +/* status flags */
14281 +
14282 +#define NXS_HASHED      0x0001
14283 +#define NXS_SHUTDOWN    0x0100
14284 +#define NXS_RELEASED    0x8000
14285 +
14286 +extern struct nx_info *lookup_nx_info(int);
14287 +
14288 +extern int get_nid_list(int, unsigned int *, int);
14289 +extern int nid_is_hashed(nid_t);
14290 +
14291 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
14292 +
14293 +extern long vs_net_change(struct nx_info *, unsigned int);
14294 +
14295 +struct sock;
14296 +
14297 +
14298 +#define NX_IPV4(n)     ((n)->v4.type != NXA_TYPE_NONE)
14299 +#ifdef  CONFIG_IPV6
14300 +#define NX_IPV6(n)     ((n)->v6.type != NXA_TYPE_NONE)
14301 +#else
14302 +#define NX_IPV6(n)     (0)
14303 +#endif
14304 +
14305 +#endif /* __KERNEL__ */
14306 +#endif /* _VX_NETWORK_H */
14307 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/percpu.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/percpu.h
14308 --- linux-2.6.33.2/include/linux/vserver/percpu.h       1970-01-01 01:00:00.000000000 +0100
14309 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/percpu.h       2010-02-25 12:02:16.000000000 +0100
14310 @@ -0,0 +1,14 @@
14311 +#ifndef _VX_PERCPU_H
14312 +#define _VX_PERCPU_H
14313 +
14314 +#include "cvirt_def.h"
14315 +#include "sched_def.h"
14316 +
14317 +struct _vx_percpu {
14318 +       struct _vx_cvirt_pc cvirt;
14319 +       struct _vx_sched_pc sched;
14320 +};
14321 +
14322 +#define        PERCPU_PERCTX   (sizeof(struct _vx_percpu))
14323 +
14324 +#endif /* _VX_PERCPU_H */
14325 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/pid.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/pid.h
14326 --- linux-2.6.33.2/include/linux/vserver/pid.h  1970-01-01 01:00:00.000000000 +0100
14327 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/pid.h  2010-02-25 12:02:16.000000000 +0100
14328 @@ -0,0 +1,51 @@
14329 +#ifndef _VSERVER_PID_H
14330 +#define _VSERVER_PID_H
14331 +
14332 +/* pid faking stuff */
14333 +
14334 +#define vx_info_map_pid(v, p) \
14335 +       __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
14336 +#define vx_info_map_tgid(v,p)  vx_info_map_pid(v,p)
14337 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
14338 +#define vx_map_tgid(p) vx_map_pid(p)
14339 +
14340 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
14341 +       const char *func, const char *file, int line)
14342 +{
14343 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14344 +               vxfprintk(VXD_CBIT(cvirt, 2),
14345 +                       "vx_map_tgid: %p/%llx: %d -> %d",
14346 +                       vxi, (long long)vxi->vx_flags, pid,
14347 +                       (pid && pid == vxi->vx_initpid) ? 1 : pid,
14348 +                       func, file, line);
14349 +               if (pid == 0)
14350 +                       return 0;
14351 +               if (pid == vxi->vx_initpid)
14352 +                       return 1;
14353 +       }
14354 +       return pid;
14355 +}
14356 +
14357 +#define vx_info_rmap_pid(v, p) \
14358 +       __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
14359 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
14360 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
14361 +
14362 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
14363 +       const char *func, const char *file, int line)
14364 +{
14365 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14366 +               vxfprintk(VXD_CBIT(cvirt, 2),
14367 +                       "vx_rmap_tgid: %p/%llx: %d -> %d",
14368 +                       vxi, (long long)vxi->vx_flags, pid,
14369 +                       (pid == 1) ? vxi->vx_initpid : pid,
14370 +                       func, file, line);
14371 +               if ((pid == 1) && vxi->vx_initpid)
14372 +                       return vxi->vx_initpid;
14373 +               if (pid == vxi->vx_initpid)
14374 +                       return ~0U;
14375 +       }
14376 +       return pid;
14377 +}
14378 +
14379 +#endif
14380 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/sched_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/sched_cmd.h
14381 --- linux-2.6.33.2/include/linux/vserver/sched_cmd.h    1970-01-01 01:00:00.000000000 +0100
14382 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/sched_cmd.h    2010-02-25 12:02:16.000000000 +0100
14383 @@ -0,0 +1,108 @@
14384 +#ifndef _VX_SCHED_CMD_H
14385 +#define _VX_SCHED_CMD_H
14386 +
14387 +
14388 +/*  sched vserver commands */
14389 +
14390 +#define VCMD_set_sched_v2      VC_CMD(SCHED, 1, 2)
14391 +#define VCMD_set_sched_v3      VC_CMD(SCHED, 1, 3)
14392 +#define VCMD_set_sched_v4      VC_CMD(SCHED, 1, 4)
14393 +
14394 +struct vcmd_set_sched_v2 {
14395 +       int32_t fill_rate;
14396 +       int32_t interval;
14397 +       int32_t tokens;
14398 +       int32_t tokens_min;
14399 +       int32_t tokens_max;
14400 +       uint64_t cpu_mask;
14401 +};
14402 +
14403 +struct vcmd_set_sched_v3 {
14404 +       uint32_t set_mask;
14405 +       int32_t fill_rate;
14406 +       int32_t interval;
14407 +       int32_t tokens;
14408 +       int32_t tokens_min;
14409 +       int32_t tokens_max;
14410 +       int32_t priority_bias;
14411 +};
14412 +
14413 +struct vcmd_set_sched_v4 {
14414 +       uint32_t set_mask;
14415 +       int32_t fill_rate;
14416 +       int32_t interval;
14417 +       int32_t tokens;
14418 +       int32_t tokens_min;
14419 +       int32_t tokens_max;
14420 +       int32_t prio_bias;
14421 +       int32_t cpu_id;
14422 +       int32_t bucket_id;
14423 +};
14424 +
14425 +#define VCMD_set_sched         VC_CMD(SCHED, 1, 5)
14426 +#define VCMD_get_sched         VC_CMD(SCHED, 2, 5)
14427 +
14428 +struct vcmd_sched_v5 {
14429 +       uint32_t mask;
14430 +       int32_t cpu_id;
14431 +       int32_t bucket_id;
14432 +       int32_t fill_rate[2];
14433 +       int32_t interval[2];
14434 +       int32_t tokens;
14435 +       int32_t tokens_min;
14436 +       int32_t tokens_max;
14437 +       int32_t prio_bias;
14438 +};
14439 +
14440 +#define VXSM_FILL_RATE         0x0001
14441 +#define VXSM_INTERVAL          0x0002
14442 +#define VXSM_FILL_RATE2                0x0004
14443 +#define VXSM_INTERVAL2         0x0008
14444 +#define VXSM_TOKENS            0x0010
14445 +#define VXSM_TOKENS_MIN                0x0020
14446 +#define VXSM_TOKENS_MAX                0x0040
14447 +#define VXSM_PRIO_BIAS         0x0100
14448 +
14449 +#define VXSM_IDLE_TIME         0x0200
14450 +#define VXSM_FORCE             0x0400
14451 +
14452 +#define        VXSM_V3_MASK            0x0173
14453 +#define        VXSM_SET_MASK           0x01FF
14454 +
14455 +#define VXSM_CPU_ID            0x1000
14456 +#define VXSM_BUCKET_ID         0x2000
14457 +
14458 +#define VXSM_MSEC              0x4000
14459 +
14460 +#define SCHED_KEEP             (-2)    /* only for v2 */
14461 +
14462 +#ifdef __KERNEL__
14463 +
14464 +#include <linux/compiler.h>
14465 +
14466 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
14467 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
14468 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
14469 +extern int vc_set_sched(struct vx_info *, void __user *);
14470 +extern int vc_get_sched(struct vx_info *, void __user *);
14471 +
14472 +#endif /* __KERNEL__ */
14473 +
14474 +#define VCMD_sched_info                VC_CMD(SCHED, 3, 0)
14475 +
14476 +struct vcmd_sched_info {
14477 +       int32_t cpu_id;
14478 +       int32_t bucket_id;
14479 +       uint64_t user_msec;
14480 +       uint64_t sys_msec;
14481 +       uint64_t hold_msec;
14482 +       uint32_t token_usec;
14483 +       int32_t vavavoom;
14484 +};
14485 +
14486 +#ifdef __KERNEL__
14487 +
14488 +extern int vc_sched_info(struct vx_info *, void __user *);
14489 +
14490 +#endif /* __KERNEL__ */
14491 +#endif /* _VX_SCHED_CMD_H */
14492 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/sched_def.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/sched_def.h
14493 --- linux-2.6.33.2/include/linux/vserver/sched_def.h    1970-01-01 01:00:00.000000000 +0100
14494 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/sched_def.h    2010-02-25 12:02:16.000000000 +0100
14495 @@ -0,0 +1,68 @@
14496 +#ifndef _VX_SCHED_DEF_H
14497 +#define _VX_SCHED_DEF_H
14498 +
14499 +#include <linux/spinlock.h>
14500 +#include <linux/jiffies.h>
14501 +#include <linux/cpumask.h>
14502 +#include <asm/atomic.h>
14503 +#include <asm/param.h>
14504 +
14505 +
14506 +/* context sub struct */
14507 +
14508 +struct _vx_sched {
14509 +       spinlock_t tokens_lock;         /* lock for token bucket */
14510 +
14511 +       int tokens;                     /* number of CPU tokens */
14512 +       int fill_rate[2];               /* Fill rate: add X tokens... */
14513 +       int interval[2];                /* Divisor:   per Y jiffies   */
14514 +       int tokens_min;                 /* Limit:     minimum for unhold */
14515 +       int tokens_max;                 /* Limit:     no more than N tokens */
14516 +
14517 +       int prio_bias;                  /* bias offset for priority */
14518 +
14519 +       unsigned update_mask;           /* which features should be updated */
14520 +       cpumask_t update;               /* CPUs which should update */
14521 +};
14522 +
14523 +struct _vx_sched_pc {
14524 +       int tokens;                     /* number of CPU tokens */
14525 +       int flags;                      /* bucket flags */
14526 +
14527 +       int fill_rate[2];               /* Fill rate: add X tokens... */
14528 +       int interval[2];                /* Divisor:   per Y jiffies   */
14529 +       int tokens_min;                 /* Limit:     minimum for unhold */
14530 +       int tokens_max;                 /* Limit:     no more than N tokens */
14531 +
14532 +       int prio_bias;                  /* bias offset for priority */
14533 +       int vavavoom;                   /* last calculated vavavoom */
14534 +
14535 +       unsigned long norm_time;        /* last time accounted */
14536 +       unsigned long idle_time;        /* non linear time for fair sched */
14537 +       unsigned long token_time;       /* token time for accounting */
14538 +       unsigned long onhold;           /* jiffies when put on hold */
14539 +
14540 +       uint64_t user_ticks;            /* token tick events */
14541 +       uint64_t sys_ticks;             /* token tick events */
14542 +       uint64_t hold_ticks;            /* token ticks paused */
14543 +};
14544 +
14545 +
14546 +#define VXSF_ONHOLD    0x0001
14547 +#define VXSF_IDLE_TIME 0x0100
14548 +
14549 +#ifdef CONFIG_VSERVER_DEBUG
14550 +
14551 +static inline void __dump_vx_sched(struct _vx_sched *sched)
14552 +{
14553 +       printk("\t_vx_sched:\n");
14554 +       printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
14555 +               sched->fill_rate[0], sched->interval[0],
14556 +               sched->fill_rate[1], sched->interval[1],
14557 +               sched->tokens_min, sched->tokens_max);
14558 +       printk("\t priority = %4d\n", sched->prio_bias);
14559 +}
14560 +
14561 +#endif
14562 +
14563 +#endif /* _VX_SCHED_DEF_H */
14564 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/sched.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/sched.h
14565 --- linux-2.6.33.2/include/linux/vserver/sched.h        1970-01-01 01:00:00.000000000 +0100
14566 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/sched.h        2010-02-25 12:02:16.000000000 +0100
14567 @@ -0,0 +1,26 @@
14568 +#ifndef _VX_SCHED_H
14569 +#define _VX_SCHED_H
14570 +
14571 +
14572 +#ifdef __KERNEL__
14573 +
14574 +struct timespec;
14575 +
14576 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14577 +
14578 +
14579 +struct vx_info;
14580 +
14581 +void vx_update_load(struct vx_info *);
14582 +
14583 +
14584 +int vx_tokens_recalc(struct _vx_sched_pc *,
14585 +       unsigned long *, unsigned long *, int [2]);
14586 +
14587 +void vx_update_sched_param(struct _vx_sched *sched,
14588 +       struct _vx_sched_pc *sched_pc);
14589 +
14590 +#endif /* __KERNEL__ */
14591 +#else  /* _VX_SCHED_H */
14592 +#warning duplicate inclusion
14593 +#endif /* _VX_SCHED_H */
14594 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/signal_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/signal_cmd.h
14595 --- linux-2.6.33.2/include/linux/vserver/signal_cmd.h   1970-01-01 01:00:00.000000000 +0100
14596 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/signal_cmd.h   2010-02-25 12:02:16.000000000 +0100
14597 @@ -0,0 +1,43 @@
14598 +#ifndef _VX_SIGNAL_CMD_H
14599 +#define _VX_SIGNAL_CMD_H
14600 +
14601 +
14602 +/*  signalling vserver commands */
14603 +
14604 +#define VCMD_ctx_kill          VC_CMD(PROCTRL, 1, 0)
14605 +#define VCMD_wait_exit         VC_CMD(EVENT, 99, 0)
14606 +
14607 +struct vcmd_ctx_kill_v0 {
14608 +       int32_t pid;
14609 +       int32_t sig;
14610 +};
14611 +
14612 +struct vcmd_wait_exit_v0 {
14613 +       int32_t reboot_cmd;
14614 +       int32_t exit_code;
14615 +};
14616 +
14617 +#ifdef __KERNEL__
14618 +
14619 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14620 +extern int vc_wait_exit(struct vx_info *, void __user *);
14621 +
14622 +#endif /* __KERNEL__ */
14623 +
14624 +/*  process alteration commands */
14625 +
14626 +#define VCMD_get_pflags                VC_CMD(PROCALT, 5, 0)
14627 +#define VCMD_set_pflags                VC_CMD(PROCALT, 6, 0)
14628 +
14629 +struct vcmd_pflags_v0 {
14630 +       uint32_t flagword;
14631 +       uint32_t mask;
14632 +};
14633 +
14634 +#ifdef __KERNEL__
14635 +
14636 +extern int vc_get_pflags(uint32_t pid, void __user *);
14637 +extern int vc_set_pflags(uint32_t pid, void __user *);
14638 +
14639 +#endif /* __KERNEL__ */
14640 +#endif /* _VX_SIGNAL_CMD_H */
14641 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/signal.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/signal.h
14642 --- linux-2.6.33.2/include/linux/vserver/signal.h       1970-01-01 01:00:00.000000000 +0100
14643 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/signal.h       2010-02-25 12:02:16.000000000 +0100
14644 @@ -0,0 +1,14 @@
14645 +#ifndef _VX_SIGNAL_H
14646 +#define _VX_SIGNAL_H
14647 +
14648 +
14649 +#ifdef __KERNEL__
14650 +
14651 +struct vx_info;
14652 +
14653 +int vx_info_kill(struct vx_info *, int, int);
14654 +
14655 +#endif /* __KERNEL__ */
14656 +#else  /* _VX_SIGNAL_H */
14657 +#warning duplicate inclusion
14658 +#endif /* _VX_SIGNAL_H */
14659 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/space_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/space_cmd.h
14660 --- linux-2.6.33.2/include/linux/vserver/space_cmd.h    1970-01-01 01:00:00.000000000 +0100
14661 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/space_cmd.h    2010-02-25 12:02:16.000000000 +0100
14662 @@ -0,0 +1,38 @@
14663 +#ifndef _VX_SPACE_CMD_H
14664 +#define _VX_SPACE_CMD_H
14665 +
14666 +
14667 +#define VCMD_enter_space_v0    VC_CMD(PROCALT, 1, 0)
14668 +#define VCMD_enter_space_v1    VC_CMD(PROCALT, 1, 1)
14669 +#define VCMD_enter_space       VC_CMD(PROCALT, 1, 2)
14670 +
14671 +#define VCMD_set_space_v0      VC_CMD(PROCALT, 3, 0)
14672 +#define VCMD_set_space_v1      VC_CMD(PROCALT, 3, 1)
14673 +#define VCMD_set_space         VC_CMD(PROCALT, 3, 2)
14674 +
14675 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14676 +
14677 +#define VCMD_get_space_mask    VC_CMD(VSPACE, 0, 1)
14678 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14679 +
14680 +
14681 +struct vcmd_space_mask_v1 {
14682 +       uint64_t mask;
14683 +};
14684 +
14685 +struct vcmd_space_mask_v2 {
14686 +       uint64_t mask;
14687 +       uint32_t index;
14688 +};
14689 +
14690 +
14691 +#ifdef __KERNEL__
14692 +
14693 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14694 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14695 +extern int vc_enter_space(struct vx_info *, void __user *);
14696 +extern int vc_set_space(struct vx_info *, void __user *);
14697 +extern int vc_get_space_mask(void __user *, int);
14698 +
14699 +#endif /* __KERNEL__ */
14700 +#endif /* _VX_SPACE_CMD_H */
14701 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/space.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/space.h
14702 --- linux-2.6.33.2/include/linux/vserver/space.h        1970-01-01 01:00:00.000000000 +0100
14703 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/space.h        2010-02-25 12:02:16.000000000 +0100
14704 @@ -0,0 +1,12 @@
14705 +#ifndef _VX_SPACE_H
14706 +#define _VX_SPACE_H
14707 +
14708 +#include <linux/types.h>
14709 +
14710 +struct vx_info;
14711 +
14712 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14713 +
14714 +#else  /* _VX_SPACE_H */
14715 +#warning duplicate inclusion
14716 +#endif /* _VX_SPACE_H */
14717 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/switch.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/switch.h
14718 --- linux-2.6.33.2/include/linux/vserver/switch.h       1970-01-01 01:00:00.000000000 +0100
14719 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/switch.h       2010-02-25 12:02:16.000000000 +0100
14720 @@ -0,0 +1,98 @@
14721 +#ifndef _VX_SWITCH_H
14722 +#define _VX_SWITCH_H
14723 +
14724 +#include <linux/types.h>
14725 +
14726 +
14727 +#define VC_CATEGORY(c)         (((c) >> 24) & 0x3F)
14728 +#define VC_COMMAND(c)          (((c) >> 16) & 0xFF)
14729 +#define VC_VERSION(c)          ((c) & 0xFFF)
14730 +
14731 +#define VC_CMD(c, i, v)                ((((VC_CAT_ ## c) & 0x3F) << 24) \
14732 +                               | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14733 +
14734 +/*
14735 +
14736 +  Syscall Matrix V2.8
14737 +
14738 +        |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14739 +        |STATS  |DESTROY|ALTER  |CHANGE |LIMIT  |TEST   | |       |       |
14740 +        |INFO   |SETUP  |       |MOVE   |       |       | |       |       |
14741 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14742 +  SYSTEM |VERSION|VSETUP |VHOST  |       |       |       | |DEVICE |       |
14743 +  HOST   |     00|     01|     02|     03|     04|     05| |     06|     07|
14744 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14745 +  CPU    |       |VPROC  |PROCALT|PROCMIG|PROCTRL|       | |SCHED. |       |
14746 +  PROCESS|     08|     09|     10|     11|     12|     13| |     14|     15|
14747 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14748 +  MEMORY |       |       |       |       |MEMCTRL|       | |SWAP   |       |
14749 +        |     16|     17|     18|     19|     20|     21| |     22|     23|
14750 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14751 +  NETWORK|       |VNET   |NETALT |NETMIG |NETCTL |       | |SERIAL |       |
14752 +        |     24|     25|     26|     27|     28|     29| |     30|     31|
14753 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14754 +  DISK   |       |       |       |TAGMIG |DLIMIT |       | |INODE  |       |
14755 +  VFS    |     32|     33|     34|     35|     36|     37| |     38|     39|
14756 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14757 +  OTHER  |VSTAT  |       |       |       |       |       | |VINFO  |       |
14758 +        |     40|     41|     42|     43|     44|     45| |     46|     47|
14759 +  =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14760 +  SPECIAL|EVENT  |       |       |       |FLAGS  |       | |VSPACE |       |
14761 +        |     48|     49|     50|     51|     52|     53| |     54|     55|
14762 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14763 +  SPECIAL|DEBUG  |       |       |       |RLIMIT |SYSCALL| |       |COMPAT |
14764 +        |     56|     57|     58|     59|     60|TEST 61| |     62|     63|
14765 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14766 +
14767 +*/
14768 +
14769 +#define VC_CAT_VERSION         0
14770 +
14771 +#define VC_CAT_VSETUP          1
14772 +#define VC_CAT_VHOST           2
14773 +
14774 +#define VC_CAT_DEVICE          6
14775 +
14776 +#define VC_CAT_VPROC           9
14777 +#define VC_CAT_PROCALT         10
14778 +#define VC_CAT_PROCMIG         11
14779 +#define VC_CAT_PROCTRL         12
14780 +
14781 +#define VC_CAT_SCHED           14
14782 +#define VC_CAT_MEMCTRL         20
14783 +
14784 +#define VC_CAT_VNET            25
14785 +#define VC_CAT_NETALT          26
14786 +#define VC_CAT_NETMIG          27
14787 +#define VC_CAT_NETCTRL         28
14788 +
14789 +#define VC_CAT_TAGMIG          35
14790 +#define VC_CAT_DLIMIT          36
14791 +#define VC_CAT_INODE           38
14792 +
14793 +#define VC_CAT_VSTAT           40
14794 +#define VC_CAT_VINFO           46
14795 +#define VC_CAT_EVENT           48
14796 +
14797 +#define VC_CAT_FLAGS           52
14798 +#define VC_CAT_VSPACE          54
14799 +#define VC_CAT_DEBUG           56
14800 +#define VC_CAT_RLIMIT          60
14801 +
14802 +#define VC_CAT_SYSTEST         61
14803 +#define VC_CAT_COMPAT          63
14804 +
14805 +/*  query version */
14806 +
14807 +#define VCMD_get_version       VC_CMD(VERSION, 0, 0)
14808 +#define VCMD_get_vci           VC_CMD(VERSION, 1, 0)
14809 +
14810 +
14811 +#ifdef __KERNEL__
14812 +
14813 +#include <linux/errno.h>
14814 +
14815 +#endif /* __KERNEL__ */
14816 +
14817 +#endif /* _VX_SWITCH_H */
14818 +
14819 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/tag_cmd.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/tag_cmd.h
14820 --- linux-2.6.33.2/include/linux/vserver/tag_cmd.h      1970-01-01 01:00:00.000000000 +0100
14821 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/tag_cmd.h      2010-02-25 12:02:16.000000000 +0100
14822 @@ -0,0 +1,22 @@
14823 +#ifndef _VX_TAG_CMD_H
14824 +#define _VX_TAG_CMD_H
14825 +
14826 +
14827 +/* vinfo commands */
14828 +
14829 +#define VCMD_task_tag          VC_CMD(VINFO, 3, 0)
14830 +
14831 +#ifdef __KERNEL__
14832 +extern int vc_task_tag(uint32_t);
14833 +
14834 +#endif /* __KERNEL__ */
14835 +
14836 +/* context commands */
14837 +
14838 +#define VCMD_tag_migrate       VC_CMD(TAGMIG, 1, 0)
14839 +
14840 +#ifdef __KERNEL__
14841 +extern int vc_tag_migrate(uint32_t);
14842 +
14843 +#endif /* __KERNEL__ */
14844 +#endif /* _VX_TAG_CMD_H */
14845 diff -NurpP --minimal linux-2.6.33.2/include/linux/vserver/tag.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/tag.h
14846 --- linux-2.6.33.2/include/linux/vserver/tag.h  1970-01-01 01:00:00.000000000 +0100
14847 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vserver/tag.h  2010-02-25 12:02:16.000000000 +0100
14848 @@ -0,0 +1,143 @@
14849 +#ifndef _DX_TAG_H
14850 +#define _DX_TAG_H
14851 +
14852 +#include <linux/types.h>
14853 +
14854 +
14855 +#define DX_TAG(in)     (IS_TAGGED(in))
14856 +
14857 +
14858 +#ifdef CONFIG_TAG_NFSD
14859 +#define DX_TAG_NFSD    1
14860 +#else
14861 +#define DX_TAG_NFSD    0
14862 +#endif
14863 +
14864 +
14865 +#ifdef CONFIG_TAGGING_NONE
14866 +
14867 +#define MAX_UID                0xFFFFFFFF
14868 +#define MAX_GID                0xFFFFFFFF
14869 +
14870 +#define INOTAG_TAG(cond, uid, gid, tag)        (0)
14871 +
14872 +#define TAGINO_UID(cond, uid, tag)     (uid)
14873 +#define TAGINO_GID(cond, gid, tag)     (gid)
14874 +
14875 +#endif
14876 +
14877 +
14878 +#ifdef CONFIG_TAGGING_GID16
14879 +
14880 +#define MAX_UID                0xFFFFFFFF
14881 +#define MAX_GID                0x0000FFFF
14882 +
14883 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14884 +       ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14885 +
14886 +#define TAGINO_UID(cond, uid, tag)     (uid)
14887 +#define TAGINO_GID(cond, gid, tag)     \
14888 +       ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14889 +
14890 +#endif
14891 +
14892 +
14893 +#ifdef CONFIG_TAGGING_ID24
14894 +
14895 +#define MAX_UID                0x00FFFFFF
14896 +#define MAX_GID                0x00FFFFFF
14897 +
14898 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14899 +       ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14900 +
14901 +#define TAGINO_UID(cond, uid, tag)     \
14902 +       ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14903 +#define TAGINO_GID(cond, gid, tag)     \
14904 +       ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14905 +
14906 +#endif
14907 +
14908 +
14909 +#ifdef CONFIG_TAGGING_UID16
14910 +
14911 +#define MAX_UID                0x0000FFFF
14912 +#define MAX_GID                0xFFFFFFFF
14913 +
14914 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14915 +       ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14916 +
14917 +#define TAGINO_UID(cond, uid, tag)     \
14918 +       ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14919 +#define TAGINO_GID(cond, gid, tag)     (gid)
14920 +
14921 +#endif
14922 +
14923 +
14924 +#ifdef CONFIG_TAGGING_INTERN
14925 +
14926 +#define MAX_UID                0xFFFFFFFF
14927 +#define MAX_GID                0xFFFFFFFF
14928 +
14929 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14930 +       ((cond) ? (tag) : 0)
14931 +
14932 +#define TAGINO_UID(cond, uid, tag)     (uid)
14933 +#define TAGINO_GID(cond, gid, tag)     (gid)
14934 +
14935 +#endif
14936 +
14937 +
14938 +#ifndef CONFIG_TAGGING_NONE
14939 +#define dx_current_fstag(sb)   \
14940 +       ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14941 +#else
14942 +#define dx_current_fstag(sb)   (0)
14943 +#endif
14944 +
14945 +#ifndef CONFIG_TAGGING_INTERN
14946 +#define TAGINO_TAG(cond, tag)  (0)
14947 +#else
14948 +#define TAGINO_TAG(cond, tag)  ((cond) ? (tag) : 0)
14949 +#endif
14950 +
14951 +#define INOTAG_UID(cond, uid, gid)     \
14952 +       ((cond) ? ((uid) & MAX_UID) : (uid))
14953 +#define INOTAG_GID(cond, uid, gid)     \
14954 +       ((cond) ? ((gid) & MAX_GID) : (gid))
14955 +
14956 +
14957 +static inline uid_t dx_map_uid(uid_t uid)
14958 +{
14959 +       if ((uid > MAX_UID) && (uid != -1))
14960 +               uid = -2;
14961 +       return (uid & MAX_UID);
14962 +}
14963 +
14964 +static inline gid_t dx_map_gid(gid_t gid)
14965 +{
14966 +       if ((gid > MAX_GID) && (gid != -1))
14967 +               gid = -2;
14968 +       return (gid & MAX_GID);
14969 +}
14970 +
14971 +struct peer_tag {
14972 +       int32_t xid;
14973 +       int32_t nid;
14974 +};
14975 +
14976 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14977 +
14978 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14979 +                unsigned long *flags);
14980 +
14981 +#ifdef CONFIG_PROPAGATE
14982 +
14983 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14984 +
14985 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14986 +
14987 +#else
14988 +#define dx_propagate_tag(n, i) do { } while (0)
14989 +#endif
14990 +
14991 +#endif /* _DX_TAG_H */
14992 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_inet6.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_inet6.h
14993 --- linux-2.6.33.2/include/linux/vs_inet6.h     1970-01-01 01:00:00.000000000 +0100
14994 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_inet6.h     2010-02-25 14:47:08.000000000 +0100
14995 @@ -0,0 +1,246 @@
14996 +#ifndef _VS_INET6_H
14997 +#define _VS_INET6_H
14998 +
14999 +#include "vserver/base.h"
15000 +#include "vserver/network.h"
15001 +#include "vserver/debug.h"
15002 +
15003 +#include <net/ipv6.h>
15004 +
15005 +#define NXAV6(a)       &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
15006 +#define NXAV6_FMT      "[%pI6/%pI6/%d:%04x]"
15007 +
15008 +
15009 +#ifdef CONFIG_IPV6
15010 +
15011 +static inline
15012 +int v6_addr_match(struct nx_addr_v6 *nxa,
15013 +       const struct in6_addr *addr, uint16_t mask)
15014 +{
15015 +       int ret = 0;
15016 +
15017 +       switch (nxa->type & mask) {
15018 +       case NXA_TYPE_MASK:
15019 +               ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
15020 +               break;
15021 +       case NXA_TYPE_ADDR:
15022 +               ret = ipv6_addr_equal(&nxa->ip, addr);
15023 +               break;
15024 +       case NXA_TYPE_ANY:
15025 +               ret = 1;
15026 +               break;
15027 +       }
15028 +       vxdprintk(VXD_CBIT(net, 0),
15029 +               "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
15030 +               nxa, NXAV6(nxa), addr, mask, ret);
15031 +       return ret;
15032 +}
15033 +
15034 +static inline
15035 +int v6_addr_in_nx_info(struct nx_info *nxi,
15036 +       const struct in6_addr *addr, uint16_t mask)
15037 +{
15038 +       struct nx_addr_v6 *nxa;
15039 +       int ret = 1;
15040 +
15041 +       if (!nxi)
15042 +               goto out;
15043 +       for (nxa = &nxi->v6; nxa; nxa = nxa->next)
15044 +               if (v6_addr_match(nxa, addr, mask))
15045 +                       goto out;
15046 +       ret = 0;
15047 +out:
15048 +       vxdprintk(VXD_CBIT(net, 0),
15049 +               "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
15050 +               nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
15051 +       return ret;
15052 +}
15053 +
15054 +static inline
15055 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
15056 +{
15057 +       /* FIXME: needs full range checks */
15058 +       return v6_addr_match(nxa, &addr->ip, mask);
15059 +}
15060 +
15061 +static inline
15062 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
15063 +{
15064 +       struct nx_addr_v6 *ptr;
15065 +
15066 +       for (ptr = &nxi->v6; ptr; ptr = ptr->next)
15067 +               if (v6_nx_addr_match(ptr, nxa, mask))
15068 +                       return 1;
15069 +       return 0;
15070 +}
15071 +
15072 +
15073 +/*
15074 + *     Check if a given address matches for a socket
15075 + *
15076 + *     nxi:            the socket's nx_info if any
15077 + *     addr:           to be verified address
15078 + */
15079 +static inline
15080 +int v6_sock_addr_match (
15081 +       struct nx_info *nxi,
15082 +       struct inet_sock *inet,
15083 +       struct in6_addr *addr)
15084 +{
15085 +       struct sock *sk = &inet->sk;
15086 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
15087 +
15088 +       if (!ipv6_addr_any(addr) &&
15089 +               ipv6_addr_equal(saddr, addr))
15090 +               return 1;
15091 +       if (ipv6_addr_any(saddr))
15092 +               return v6_addr_in_nx_info(nxi, addr, -1);
15093 +       return 0;
15094 +}
15095 +
15096 +/*
15097 + *     check if address is covered by socket
15098 + *
15099 + *     sk:     the socket to check against
15100 + *     addr:   the address in question (must be != 0)
15101 + */
15102 +
15103 +static inline
15104 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
15105 +{
15106 +       struct nx_info *nxi = sk->sk_nx_info;
15107 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
15108 +
15109 +       vxdprintk(VXD_CBIT(net, 5),
15110 +               "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
15111 +               sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
15112 +               (sk->sk_socket?sk->sk_socket->flags:0));
15113 +
15114 +       if (!ipv6_addr_any(saddr)) {    /* direct address match */
15115 +               return v6_addr_match(nxa, saddr, -1);
15116 +       } else if (nxi) {               /* match against nx_info */
15117 +               return v6_nx_addr_in_nx_info(nxi, nxa, -1);
15118 +       } else {                        /* unrestricted any socket */
15119 +               return 1;
15120 +       }
15121 +}
15122 +
15123 +
15124 +/* inet related checks and helpers */
15125 +
15126 +
15127 +struct in_ifaddr;
15128 +struct net_device;
15129 +struct sock;
15130 +
15131 +
15132 +#include <linux/netdevice.h>
15133 +#include <linux/inetdevice.h>
15134 +#include <net/inet_timewait_sock.h>
15135 +
15136 +
15137 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15138 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
15139 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
15140 +
15141 +
15142 +
15143 +static inline
15144 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
15145 +{
15146 +       if (!nxi)
15147 +               return 1;
15148 +       if (!ifa)
15149 +               return 0;
15150 +       return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
15151 +}
15152 +
15153 +static inline
15154 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
15155 +{
15156 +       vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
15157 +               nxi, nxi ? nxi->nx_id : 0, ifa,
15158 +               nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
15159 +
15160 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15161 +               return 1;
15162 +       if (v6_ifa_in_nx_info(ifa, nxi))
15163 +               return 1;
15164 +       return 0;
15165 +}
15166 +
15167 +
15168 +struct nx_v6_sock_addr {
15169 +       struct in6_addr saddr;  /* Address used for validation */
15170 +       struct in6_addr baddr;  /* Address used for socket bind */
15171 +};
15172 +
15173 +static inline
15174 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
15175 +       struct nx_v6_sock_addr *nsa)
15176 +{
15177 +       // struct sock *sk = &inet->sk;
15178 +       // struct nx_info *nxi = sk->sk_nx_info;
15179 +       struct in6_addr saddr = addr->sin6_addr;
15180 +       struct in6_addr baddr = saddr;
15181 +
15182 +       nsa->saddr = saddr;
15183 +       nsa->baddr = baddr;
15184 +       return 0;
15185 +}
15186 +
15187 +static inline
15188 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
15189 +{
15190 +       // struct sock *sk = &inet->sk;
15191 +       // struct in6_addr *saddr = inet6_rcv_saddr(sk);
15192 +
15193 +       // *saddr = nsa->baddr;
15194 +       // inet->inet_saddr = nsa->baddr;
15195 +}
15196 +
15197 +static inline
15198 +int nx_info_has_v6(struct nx_info *nxi)
15199 +{
15200 +       if (!nxi)
15201 +               return 1;
15202 +       if (NX_IPV6(nxi))
15203 +               return 1;
15204 +       return 0;
15205 +}
15206 +
15207 +#else /* CONFIG_IPV6 */
15208 +
15209 +static inline
15210 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
15211 +{
15212 +       return 1;
15213 +}
15214 +
15215 +
15216 +static inline
15217 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
15218 +{
15219 +       return 1;
15220 +}
15221 +
15222 +static inline
15223 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
15224 +{
15225 +       return 1;
15226 +}
15227 +
15228 +static inline
15229 +int nx_info_has_v6(struct nx_info *nxi)
15230 +{
15231 +       return 0;
15232 +}
15233 +
15234 +#endif /* CONFIG_IPV6 */
15235 +
15236 +#define current_nx_info_has_v6() \
15237 +       nx_info_has_v6(current_nx_info())
15238 +
15239 +#else
15240 +#warning duplicate inclusion
15241 +#endif
15242 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_inet.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_inet.h
15243 --- linux-2.6.33.2/include/linux/vs_inet.h      1970-01-01 01:00:00.000000000 +0100
15244 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_inet.h      2010-02-25 14:45:44.000000000 +0100
15245 @@ -0,0 +1,342 @@
15246 +#ifndef _VS_INET_H
15247 +#define _VS_INET_H
15248 +
15249 +#include "vserver/base.h"
15250 +#include "vserver/network.h"
15251 +#include "vserver/debug.h"
15252 +
15253 +#define IPI_LOOPBACK   htonl(INADDR_LOOPBACK)
15254 +
15255 +#define NXAV4(a)       NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
15256 +                       NIPQUAD((a)->mask), (a)->type
15257 +#define NXAV4_FMT      "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
15258 +
15259 +
15260 +static inline
15261 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
15262 +{
15263 +       __be32 ip = nxa->ip[0].s_addr;
15264 +       __be32 mask = nxa->mask.s_addr;
15265 +       __be32 bcast = ip | ~mask;
15266 +       int ret = 0;
15267 +
15268 +       switch (nxa->type & tmask) {
15269 +       case NXA_TYPE_MASK:
15270 +               ret = (ip == (addr & mask));
15271 +               break;
15272 +       case NXA_TYPE_ADDR:
15273 +               ret = 3;
15274 +               if (addr == ip)
15275 +                       break;
15276 +               /* fall through to broadcast */
15277 +       case NXA_MOD_BCAST:
15278 +               ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
15279 +               break;
15280 +       case NXA_TYPE_RANGE:
15281 +               ret = ((nxa->ip[0].s_addr <= addr) &&
15282 +                       (nxa->ip[1].s_addr > addr));
15283 +               break;
15284 +       case NXA_TYPE_ANY:
15285 +               ret = 2;
15286 +               break;
15287 +       }
15288 +
15289 +       vxdprintk(VXD_CBIT(net, 0),
15290 +               "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
15291 +               nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
15292 +       return ret;
15293 +}
15294 +
15295 +static inline
15296 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
15297 +{
15298 +       struct nx_addr_v4 *nxa;
15299 +       int ret = 1;
15300 +
15301 +       if (!nxi)
15302 +               goto out;
15303 +
15304 +       ret = 2;
15305 +       /* allow 127.0.0.1 when remapping lback */
15306 +       if ((tmask & NXA_LOOPBACK) &&
15307 +               (addr == IPI_LOOPBACK) &&
15308 +               nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15309 +               goto out;
15310 +       ret = 3;
15311 +       /* check for lback address */
15312 +       if ((tmask & NXA_MOD_LBACK) &&
15313 +               (nxi->v4_lback.s_addr == addr))
15314 +               goto out;
15315 +       ret = 4;
15316 +       /* check for broadcast address */
15317 +       if ((tmask & NXA_MOD_BCAST) &&
15318 +               (nxi->v4_bcast.s_addr == addr))
15319 +               goto out;
15320 +       ret = 5;
15321 +       /* check for v4 addresses */
15322 +       for (nxa = &nxi->v4; nxa; nxa = nxa->next)
15323 +               if (v4_addr_match(nxa, addr, tmask))
15324 +                       goto out;
15325 +       ret = 0;
15326 +out:
15327 +       vxdprintk(VXD_CBIT(net, 0),
15328 +               "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
15329 +               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
15330 +       return ret;
15331 +}
15332 +
15333 +static inline
15334 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
15335 +{
15336 +       /* FIXME: needs full range checks */
15337 +       return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
15338 +}
15339 +
15340 +static inline
15341 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
15342 +{
15343 +       struct nx_addr_v4 *ptr;
15344 +
15345 +       for (ptr = &nxi->v4; ptr; ptr = ptr->next)
15346 +               if (v4_nx_addr_match(ptr, nxa, mask))
15347 +                       return 1;
15348 +       return 0;
15349 +}
15350 +
15351 +#include <net/inet_sock.h>
15352 +
15353 +/*
15354 + *     Check if a given address matches for a socket
15355 + *
15356 + *     nxi:            the socket's nx_info if any
15357 + *     addr:           to be verified address
15358 + */
15359 +static inline
15360 +int v4_sock_addr_match (
15361 +       struct nx_info *nxi,
15362 +       struct inet_sock *inet,
15363 +       __be32 addr)
15364 +{
15365 +       __be32 saddr = inet->inet_rcv_saddr;
15366 +       __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
15367 +
15368 +       if (addr && (saddr == addr || bcast == addr))
15369 +               return 1;
15370 +       if (!saddr)
15371 +               return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
15372 +       return 0;
15373 +}
15374 +
15375 +
15376 +/* inet related checks and helpers */
15377 +
15378 +
15379 +struct in_ifaddr;
15380 +struct net_device;
15381 +struct sock;
15382 +
15383 +#ifdef CONFIG_INET
15384 +
15385 +#include <linux/netdevice.h>
15386 +#include <linux/inetdevice.h>
15387 +#include <net/inet_sock.h>
15388 +#include <net/inet_timewait_sock.h>
15389 +
15390 +
15391 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15392 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
15393 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
15394 +
15395 +
15396 +/*
15397 + *     check if address is covered by socket
15398 + *
15399 + *     sk:     the socket to check against
15400 + *     addr:   the address in question (must be != 0)
15401 + */
15402 +
15403 +static inline
15404 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
15405 +{
15406 +       struct nx_info *nxi = sk->sk_nx_info;
15407 +       __be32 saddr = inet_rcv_saddr(sk);
15408 +
15409 +       vxdprintk(VXD_CBIT(net, 5),
15410 +               "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
15411 +               sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
15412 +               (sk->sk_socket?sk->sk_socket->flags:0));
15413 +
15414 +       if (saddr) {            /* direct address match */
15415 +               return v4_addr_match(nxa, saddr, -1);
15416 +       } else if (nxi) {       /* match against nx_info */
15417 +               return v4_nx_addr_in_nx_info(nxi, nxa, -1);
15418 +       } else {                /* unrestricted any socket */
15419 +               return 1;
15420 +       }
15421 +}
15422 +
15423 +
15424 +
15425 +static inline
15426 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
15427 +{
15428 +       vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p Â»%s«) %d",
15429 +               nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
15430 +               nxi ? dev_in_nx_info(dev, nxi) : 0);
15431 +
15432 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15433 +               return 1;
15434 +       if (dev_in_nx_info(dev, nxi))
15435 +               return 1;
15436 +       return 0;
15437 +}
15438 +
15439 +
15440 +static inline
15441 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
15442 +{
15443 +       if (!nxi)
15444 +               return 1;
15445 +       if (!ifa)
15446 +               return 0;
15447 +       return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
15448 +}
15449 +
15450 +static inline
15451 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
15452 +{
15453 +       vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
15454 +               nxi, nxi ? nxi->nx_id : 0, ifa,
15455 +               nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
15456 +
15457 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15458 +               return 1;
15459 +       if (v4_ifa_in_nx_info(ifa, nxi))
15460 +               return 1;
15461 +       return 0;
15462 +}
15463 +
15464 +
15465 +struct nx_v4_sock_addr {
15466 +       __be32 saddr;   /* Address used for validation */
15467 +       __be32 baddr;   /* Address used for socket bind */
15468 +};
15469 +
15470 +static inline
15471 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
15472 +       struct nx_v4_sock_addr *nsa)
15473 +{
15474 +       struct sock *sk = &inet->sk;
15475 +       struct nx_info *nxi = sk->sk_nx_info;
15476 +       __be32 saddr = addr->sin_addr.s_addr;
15477 +       __be32 baddr = saddr;
15478 +
15479 +       vxdprintk(VXD_CBIT(net, 3),
15480 +               "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
15481 +               sk, sk->sk_nx_info, sk->sk_socket,
15482 +               (sk->sk_socket ? sk->sk_socket->flags : 0),
15483 +               NIPQUAD(saddr));
15484 +
15485 +       if (nxi) {
15486 +               if (saddr == INADDR_ANY) {
15487 +                       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
15488 +                               baddr = nxi->v4.ip[0].s_addr;
15489 +               } else if (saddr == IPI_LOOPBACK) {
15490 +                       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15491 +                               baddr = nxi->v4_lback.s_addr;
15492 +               } else {        /* normal address bind */
15493 +                       if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
15494 +                               return -EADDRNOTAVAIL;
15495 +               }
15496 +       }
15497 +
15498 +       vxdprintk(VXD_CBIT(net, 3),
15499 +               "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
15500 +               sk, NIPQUAD(saddr), NIPQUAD(baddr));
15501 +
15502 +       nsa->saddr = saddr;
15503 +       nsa->baddr = baddr;
15504 +       return 0;
15505 +}
15506 +
15507 +static inline
15508 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
15509 +{
15510 +       inet->inet_saddr = nsa->baddr;
15511 +       inet->inet_rcv_saddr = nsa->baddr;
15512 +}
15513 +
15514 +
15515 +/*
15516 + *      helper to simplify inet_lookup_listener
15517 + *
15518 + *      nxi:   the socket's nx_info if any
15519 + *      addr:  to be verified address
15520 + *      saddr: socket address
15521 + */
15522 +static inline int v4_inet_addr_match (
15523 +       struct nx_info *nxi,
15524 +       __be32 addr,
15525 +       __be32 saddr)
15526 +{
15527 +       if (addr && (saddr == addr))
15528 +               return 1;
15529 +       if (!saddr)
15530 +               return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
15531 +       return 0;
15532 +}
15533 +
15534 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
15535 +{
15536 +       if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
15537 +               (addr == nxi->v4_lback.s_addr))
15538 +               return IPI_LOOPBACK;
15539 +       return addr;
15540 +}
15541 +
15542 +static inline
15543 +int nx_info_has_v4(struct nx_info *nxi)
15544 +{
15545 +       if (!nxi)
15546 +               return 1;
15547 +       if (NX_IPV4(nxi))
15548 +               return 1;
15549 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15550 +               return 1;
15551 +       return 0;
15552 +}
15553 +
15554 +#else /* CONFIG_INET */
15555 +
15556 +static inline
15557 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
15558 +{
15559 +       return 1;
15560 +}
15561 +
15562 +static inline
15563 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
15564 +{
15565 +       return 1;
15566 +}
15567 +
15568 +static inline
15569 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
15570 +{
15571 +       return 1;
15572 +}
15573 +
15574 +static inline
15575 +int nx_info_has_v4(struct nx_info *nxi)
15576 +{
15577 +       return 0;
15578 +}
15579 +
15580 +#endif /* CONFIG_INET */
15581 +
15582 +#define current_nx_info_has_v4() \
15583 +       nx_info_has_v4(current_nx_info())
15584 +
15585 +#else
15586 +// #warning duplicate inclusion
15587 +#endif
15588 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_limit.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_limit.h
15589 --- linux-2.6.33.2/include/linux/vs_limit.h     1970-01-01 01:00:00.000000000 +0100
15590 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_limit.h     2010-02-25 12:02:16.000000000 +0100
15591 @@ -0,0 +1,140 @@
15592 +#ifndef _VS_LIMIT_H
15593 +#define _VS_LIMIT_H
15594 +
15595 +#include "vserver/limit.h"
15596 +#include "vserver/base.h"
15597 +#include "vserver/context.h"
15598 +#include "vserver/debug.h"
15599 +#include "vserver/context.h"
15600 +#include "vserver/limit_int.h"
15601 +
15602 +
15603 +#define vx_acc_cres(v, d, p, r) \
15604 +       __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
15605 +
15606 +#define vx_acc_cres_cond(x, d, p, r) \
15607 +       __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15608 +       r, d, p, __FILE__, __LINE__)
15609 +
15610 +
15611 +#define vx_add_cres(v, a, p, r) \
15612 +       __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
15613 +#define vx_sub_cres(v, a, p, r)                vx_add_cres(v, -(a), p, r)
15614 +
15615 +#define vx_add_cres_cond(x, a, p, r) \
15616 +       __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15617 +       r, a, p, __FILE__, __LINE__)
15618 +#define vx_sub_cres_cond(x, a, p, r)   vx_add_cres_cond(x, -(a), p, r)
15619 +
15620 +
15621 +/* process and file limits */
15622 +
15623 +#define vx_nproc_inc(p) \
15624 +       vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
15625 +
15626 +#define vx_nproc_dec(p) \
15627 +       vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
15628 +
15629 +#define vx_files_inc(f) \
15630 +       vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
15631 +
15632 +#define vx_files_dec(f) \
15633 +       vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
15634 +
15635 +#define vx_locks_inc(l) \
15636 +       vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
15637 +
15638 +#define vx_locks_dec(l) \
15639 +       vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
15640 +
15641 +#define vx_openfd_inc(f) \
15642 +       vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
15643 +
15644 +#define vx_openfd_dec(f) \
15645 +       vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
15646 +
15647 +
15648 +#define vx_cres_avail(v, n, r) \
15649 +       __vx_cres_avail(v, r, n, __FILE__, __LINE__)
15650 +
15651 +
15652 +#define vx_nproc_avail(n) \
15653 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
15654 +
15655 +#define vx_files_avail(n) \
15656 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
15657 +
15658 +#define vx_locks_avail(n) \
15659 +       vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
15660 +
15661 +#define vx_openfd_avail(n) \
15662 +       vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
15663 +
15664 +
15665 +/* dentry limits */
15666 +
15667 +#define vx_dentry_inc(d) do {                                          \
15668 +       if (atomic_read(&d->d_count) == 1)                              \
15669 +               vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY);    \
15670 +       } while (0)
15671 +
15672 +#define vx_dentry_dec(d) do {                                          \
15673 +       if (atomic_read(&d->d_count) == 0)                              \
15674 +               vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY);    \
15675 +       } while (0)
15676 +
15677 +#define vx_dentry_avail(n) \
15678 +       vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
15679 +
15680 +
15681 +/* socket limits */
15682 +
15683 +#define vx_sock_inc(s) \
15684 +       vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
15685 +
15686 +#define vx_sock_dec(s) \
15687 +       vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
15688 +
15689 +#define vx_sock_avail(n) \
15690 +       vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
15691 +
15692 +
15693 +/* ipc resource limits */
15694 +
15695 +#define vx_ipcmsg_add(v, u, a) \
15696 +       vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
15697 +
15698 +#define vx_ipcmsg_sub(v, u, a) \
15699 +       vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
15700 +
15701 +#define vx_ipcmsg_avail(v, a) \
15702 +       vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
15703 +
15704 +
15705 +#define vx_ipcshm_add(v, k, a) \
15706 +       vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15707 +
15708 +#define vx_ipcshm_sub(v, k, a) \
15709 +       vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15710 +
15711 +#define vx_ipcshm_avail(v, a) \
15712 +       vx_cres_avail(v, a, VLIMIT_SHMEM)
15713 +
15714 +
15715 +#define vx_semary_inc(a) \
15716 +       vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
15717 +
15718 +#define vx_semary_dec(a) \
15719 +       vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
15720 +
15721 +
15722 +#define vx_nsems_add(a,n) \
15723 +       vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15724 +
15725 +#define vx_nsems_sub(a,n) \
15726 +       vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15727 +
15728 +
15729 +#else
15730 +#warning duplicate inclusion
15731 +#endif
15732 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_memory.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_memory.h
15733 --- linux-2.6.33.2/include/linux/vs_memory.h    1970-01-01 01:00:00.000000000 +0100
15734 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_memory.h    2010-02-25 12:02:16.000000000 +0100
15735 @@ -0,0 +1,159 @@
15736 +#ifndef _VS_MEMORY_H
15737 +#define _VS_MEMORY_H
15738 +
15739 +#include "vserver/limit.h"
15740 +#include "vserver/base.h"
15741 +#include "vserver/context.h"
15742 +#include "vserver/debug.h"
15743 +#include "vserver/context.h"
15744 +#include "vserver/limit_int.h"
15745 +
15746 +
15747 +#define __acc_add_long(a, v)   (*(v) += (a))
15748 +#define __acc_inc_long(v)      (++*(v))
15749 +#define __acc_dec_long(v)      (--*(v))
15750 +
15751 +#if    NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
15752 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
15753 +#define __acc_inc_atomic(v)    atomic_long_inc(v)
15754 +#define __acc_dec_atomic(v)    atomic_long_dec(v)
15755 +#else  /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
15756 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
15757 +#define __acc_inc_atomic(v)    __acc_inc_long(v)
15758 +#define __acc_dec_atomic(v)    __acc_dec_long(v)
15759 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
15760 +
15761 +
15762 +#define vx_acc_page(m, d, v, r) do {                                   \
15763 +       if ((d) > 0)                                                    \
15764 +               __acc_inc_long(&(m)->v);                                \
15765 +       else                                                            \
15766 +               __acc_dec_long(&(m)->v);                                \
15767 +       __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__);      \
15768 +} while (0)
15769 +
15770 +#define vx_acc_page_atomic(m, d, v, r) do {                            \
15771 +       if ((d) > 0)                                                    \
15772 +               __acc_inc_atomic(&(m)->v);                              \
15773 +       else                                                            \
15774 +               __acc_dec_atomic(&(m)->v);                              \
15775 +       __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__);      \
15776 +} while (0)
15777 +
15778 +
15779 +#define vx_acc_pages(m, p, v, r) do {                                  \
15780 +       unsigned long __p = (p);                                        \
15781 +       __acc_add_long(__p, &(m)->v);                                   \
15782 +       __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__);    \
15783 +} while (0)
15784 +
15785 +#define vx_acc_pages_atomic(m, p, v, r) do {                           \
15786 +       unsigned long __p = (p);                                        \
15787 +       __acc_add_atomic(__p, &(m)->v);                                 \
15788 +       __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__);    \
15789 +} while (0)
15790 +
15791 +
15792 +
15793 +#define vx_acc_vmpage(m, d) \
15794 +       vx_acc_page(m, d, total_vm,  RLIMIT_AS)
15795 +#define vx_acc_vmlpage(m, d) \
15796 +       vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
15797 +#define vx_acc_file_rsspage(m, d) \
15798 +       vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
15799 +#define vx_acc_anon_rsspage(m, d) \
15800 +       vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
15801 +
15802 +#define vx_acc_vmpages(m, p) \
15803 +       vx_acc_pages(m, p, total_vm,  RLIMIT_AS)
15804 +#define vx_acc_vmlpages(m, p) \
15805 +       vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
15806 +#define vx_acc_file_rsspages(m, p) \
15807 +       vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
15808 +#define vx_acc_anon_rsspages(m, p) \
15809 +       vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
15810 +
15811 +#define vx_pages_add(s, r, p)  __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
15812 +#define vx_pages_sub(s, r, p)  vx_pages_add(s, r, -(p))
15813 +
15814 +#define vx_vmpages_inc(m)              vx_acc_vmpage(m, 1)
15815 +#define vx_vmpages_dec(m)              vx_acc_vmpage(m, -1)
15816 +#define vx_vmpages_add(m, p)           vx_acc_vmpages(m, p)
15817 +#define vx_vmpages_sub(m, p)           vx_acc_vmpages(m, -(p))
15818 +
15819 +#define vx_vmlocked_inc(m)             vx_acc_vmlpage(m, 1)
15820 +#define vx_vmlocked_dec(m)             vx_acc_vmlpage(m, -1)
15821 +#define vx_vmlocked_add(m, p)          vx_acc_vmlpages(m, p)
15822 +#define vx_vmlocked_sub(m, p)          vx_acc_vmlpages(m, -(p))
15823 +
15824 +#define vx_file_rsspages_inc(m)                vx_acc_file_rsspage(m, 1)
15825 +#define vx_file_rsspages_dec(m)                vx_acc_file_rsspage(m, -1)
15826 +#define vx_file_rsspages_add(m, p)     vx_acc_file_rsspages(m, p)
15827 +#define vx_file_rsspages_sub(m, p)     vx_acc_file_rsspages(m, -(p))
15828 +
15829 +#define vx_anon_rsspages_inc(m)                vx_acc_anon_rsspage(m, 1)
15830 +#define vx_anon_rsspages_dec(m)                vx_acc_anon_rsspage(m, -1)
15831 +#define vx_anon_rsspages_add(m, p)     vx_acc_anon_rsspages(m, p)
15832 +#define vx_anon_rsspages_sub(m, p)     vx_acc_anon_rsspages(m, -(p))
15833 +
15834 +
15835 +#define vx_pages_avail(m, p, r) \
15836 +       __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
15837 +
15838 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
15839 +#define vx_vmlocked_avail(m, p)        vx_pages_avail(m, p, RLIMIT_MEMLOCK)
15840 +#define vx_anon_avail(m, p)    vx_pages_avail(m, p, VLIMIT_ANON)
15841 +#define vx_mapped_avail(m, p)  vx_pages_avail(m, p, VLIMIT_MAPPED)
15842 +
15843 +#define vx_rss_avail(m, p) \
15844 +       __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
15845 +
15846 +
15847 +enum {
15848 +       VXPT_UNKNOWN = 0,
15849 +       VXPT_ANON,
15850 +       VXPT_NONE,
15851 +       VXPT_FILE,
15852 +       VXPT_SWAP,
15853 +       VXPT_WRITE
15854 +};
15855 +
15856 +#if 0
15857 +#define        vx_page_fault(mm, vma, type, ret)
15858 +#else
15859 +
15860 +static inline
15861 +void __vx_page_fault(struct mm_struct *mm,
15862 +       struct vm_area_struct *vma, int type, int ret)
15863 +{
15864 +       struct vx_info *vxi = mm->mm_vx_info;
15865 +       int what;
15866 +/*
15867 +       static char *page_type[6] =
15868 +               { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
15869 +       static char *page_what[4] =
15870 +               { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
15871 +*/
15872 +
15873 +       if (!vxi)
15874 +               return;
15875 +
15876 +       what = (ret & 0x3);
15877 +
15878 +/*     printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
15879 +               type, what, ret, page_type[type], page_what[what]);
15880 +*/
15881 +       if (ret & VM_FAULT_WRITE)
15882 +               what |= 0x4;
15883 +       atomic_inc(&vxi->cacct.page[type][what]);
15884 +}
15885 +
15886 +#define        vx_page_fault(mm, vma, type, ret)       __vx_page_fault(mm, vma, type, ret)
15887 +#endif
15888 +
15889 +
15890 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
15891 +
15892 +#else
15893 +#warning duplicate inclusion
15894 +#endif
15895 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_network.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_network.h
15896 --- linux-2.6.33.2/include/linux/vs_network.h   1970-01-01 01:00:00.000000000 +0100
15897 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_network.h   2010-02-25 12:02:16.000000000 +0100
15898 @@ -0,0 +1,169 @@
15899 +#ifndef _NX_VS_NETWORK_H
15900 +#define _NX_VS_NETWORK_H
15901 +
15902 +#include "vserver/context.h"
15903 +#include "vserver/network.h"
15904 +#include "vserver/base.h"
15905 +#include "vserver/check.h"
15906 +#include "vserver/debug.h"
15907 +
15908 +#include <linux/sched.h>
15909 +
15910 +
15911 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
15912 +
15913 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
15914 +       const char *_file, int _line)
15915 +{
15916 +       if (!nxi)
15917 +               return NULL;
15918 +
15919 +       vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
15920 +               nxi, nxi ? nxi->nx_id : 0,
15921 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15922 +               _file, _line);
15923 +
15924 +       atomic_inc(&nxi->nx_usecnt);
15925 +       return nxi;
15926 +}
15927 +
15928 +
15929 +extern void free_nx_info(struct nx_info *);
15930 +
15931 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
15932 +
15933 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
15934 +{
15935 +       if (!nxi)
15936 +               return;
15937 +
15938 +       vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
15939 +               nxi, nxi ? nxi->nx_id : 0,
15940 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15941 +               _file, _line);
15942 +
15943 +       if (atomic_dec_and_test(&nxi->nx_usecnt))
15944 +               free_nx_info(nxi);
15945 +}
15946 +
15947 +
15948 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
15949 +
15950 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15951 +               const char *_file, int _line)
15952 +{
15953 +       if (nxi) {
15954 +               vxlprintk(VXD_CBIT(nid, 3),
15955 +                       "init_nx_info(%p[#%d.%d])",
15956 +                       nxi, nxi ? nxi->nx_id : 0,
15957 +                       nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15958 +                       _file, _line);
15959 +
15960 +               atomic_inc(&nxi->nx_usecnt);
15961 +       }
15962 +       *nxp = nxi;
15963 +}
15964 +
15965 +
15966 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
15967 +
15968 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15969 +       const char *_file, int _line)
15970 +{
15971 +       struct nx_info *nxo;
15972 +
15973 +       if (!nxi)
15974 +               return;
15975 +
15976 +       vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
15977 +               nxi, nxi ? nxi->nx_id : 0,
15978 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15979 +               _file, _line);
15980 +
15981 +       atomic_inc(&nxi->nx_usecnt);
15982 +       nxo = xchg(nxp, nxi);
15983 +       BUG_ON(nxo);
15984 +}
15985 +
15986 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
15987 +
15988 +static inline void __clr_nx_info(struct nx_info **nxp,
15989 +       const char *_file, int _line)
15990 +{
15991 +       struct nx_info *nxo;
15992 +
15993 +       nxo = xchg(nxp, NULL);
15994 +       if (!nxo)
15995 +               return;
15996 +
15997 +       vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
15998 +               nxo, nxo ? nxo->nx_id : 0,
15999 +               nxo ? atomic_read(&nxo->nx_usecnt) : 0,
16000 +               _file, _line);
16001 +
16002 +       if (atomic_dec_and_test(&nxo->nx_usecnt))
16003 +               free_nx_info(nxo);
16004 +}
16005 +
16006 +
16007 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
16008 +
16009 +static inline void __claim_nx_info(struct nx_info *nxi,
16010 +       struct task_struct *task, const char *_file, int _line)
16011 +{
16012 +       vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
16013 +               nxi, nxi ? nxi->nx_id : 0,
16014 +               nxi?atomic_read(&nxi->nx_usecnt):0,
16015 +               nxi?atomic_read(&nxi->nx_tasks):0,
16016 +               task, _file, _line);
16017 +
16018 +       atomic_inc(&nxi->nx_tasks);
16019 +}
16020 +
16021 +
16022 +extern void unhash_nx_info(struct nx_info *);
16023 +
16024 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
16025 +
16026 +static inline void __release_nx_info(struct nx_info *nxi,
16027 +       struct task_struct *task, const char *_file, int _line)
16028 +{
16029 +       vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
16030 +               nxi, nxi ? nxi->nx_id : 0,
16031 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16032 +               nxi ? atomic_read(&nxi->nx_tasks) : 0,
16033 +               task, _file, _line);
16034 +
16035 +       might_sleep();
16036 +
16037 +       if (atomic_dec_and_test(&nxi->nx_tasks))
16038 +               unhash_nx_info(nxi);
16039 +}
16040 +
16041 +
16042 +#define task_get_nx_info(i)    __task_get_nx_info(i, __FILE__, __LINE__)
16043 +
16044 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
16045 +       const char *_file, int _line)
16046 +{
16047 +       struct nx_info *nxi;
16048 +
16049 +       task_lock(p);
16050 +       vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
16051 +               p, _file, _line);
16052 +       nxi = __get_nx_info(p->nx_info, _file, _line);
16053 +       task_unlock(p);
16054 +       return nxi;
16055 +}
16056 +
16057 +
16058 +static inline void exit_nx_info(struct task_struct *p)
16059 +{
16060 +       if (p->nx_info)
16061 +               release_nx_info(p->nx_info, p);
16062 +}
16063 +
16064 +
16065 +#else
16066 +#warning duplicate inclusion
16067 +#endif
16068 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_pid.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_pid.h
16069 --- linux-2.6.33.2/include/linux/vs_pid.h       1970-01-01 01:00:00.000000000 +0100
16070 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_pid.h       2010-02-25 12:02:16.000000000 +0100
16071 @@ -0,0 +1,95 @@
16072 +#ifndef _VS_PID_H
16073 +#define _VS_PID_H
16074 +
16075 +#include "vserver/base.h"
16076 +#include "vserver/check.h"
16077 +#include "vserver/context.h"
16078 +#include "vserver/debug.h"
16079 +#include "vserver/pid.h"
16080 +#include <linux/pid_namespace.h>
16081 +
16082 +
16083 +#define VXF_FAKE_INIT  (VXF_INFO_INIT | VXF_STATE_INIT)
16084 +
16085 +static inline
16086 +int vx_proc_task_visible(struct task_struct *task)
16087 +{
16088 +       if ((task->pid == 1) &&
16089 +               !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
16090 +               /* show a blend through init */
16091 +               goto visible;
16092 +       if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
16093 +               goto visible;
16094 +       return 0;
16095 +visible:
16096 +       return 1;
16097 +}
16098 +
16099 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
16100 +
16101 +#if 0
16102 +
16103 +static inline
16104 +struct task_struct *vx_find_proc_task_by_pid(int pid)
16105 +{
16106 +       struct task_struct *task = find_task_by_real_pid(pid);
16107 +
16108 +       if (task && !vx_proc_task_visible(task)) {
16109 +               vxdprintk(VXD_CBIT(misc, 6),
16110 +                       "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
16111 +                       task, task->xid, task->pid,
16112 +                       current, current->xid, current->pid);
16113 +               task = NULL;
16114 +       }
16115 +       return task;
16116 +}
16117 +
16118 +#endif
16119 +
16120 +static inline
16121 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
16122 +{
16123 +       struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
16124 +
16125 +       if (task && !vx_proc_task_visible(task)) {
16126 +               vxdprintk(VXD_CBIT(misc, 6),
16127 +                       "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
16128 +                       task, task->xid, task->pid,
16129 +                       current, current->xid, current->pid);
16130 +               put_task_struct(task);
16131 +               task = NULL;
16132 +       }
16133 +       return task;
16134 +}
16135 +
16136 +#if 0
16137 +
16138 +static inline
16139 +struct task_struct *vx_child_reaper(struct task_struct *p)
16140 +{
16141 +       struct vx_info *vxi = p->vx_info;
16142 +       struct task_struct *reaper = child_reaper(p);
16143 +
16144 +       if (!vxi)
16145 +               goto out;
16146 +
16147 +       BUG_ON(!p->vx_info->vx_reaper);
16148 +
16149 +       /* child reaper for the guest reaper */
16150 +       if (vxi->vx_reaper == p)
16151 +               goto out;
16152 +
16153 +       reaper = vxi->vx_reaper;
16154 +out:
16155 +       vxdprintk(VXD_CBIT(xid, 7),
16156 +               "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
16157 +               p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
16158 +       return reaper;
16159 +}
16160 +
16161 +#endif
16162 +
16163 +
16164 +#else
16165 +#warning duplicate inclusion
16166 +#endif
16167 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_sched.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_sched.h
16168 --- linux-2.6.33.2/include/linux/vs_sched.h     1970-01-01 01:00:00.000000000 +0100
16169 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_sched.h     2010-02-25 12:02:16.000000000 +0100
16170 @@ -0,0 +1,110 @@
16171 +#ifndef _VS_SCHED_H
16172 +#define _VS_SCHED_H
16173 +
16174 +#include "vserver/base.h"
16175 +#include "vserver/context.h"
16176 +#include "vserver/sched.h"
16177 +
16178 +
16179 +#define VAVAVOOM_RATIO          50
16180 +
16181 +#define MAX_PRIO_BIAS           20
16182 +#define MIN_PRIO_BIAS          -20
16183 +
16184 +
16185 +#ifdef CONFIG_VSERVER_HARDCPU
16186 +
16187 +/*
16188 + * effective_prio - return the priority that is based on the static
16189 + * priority but is modified by bonuses/penalties.
16190 + *
16191 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
16192 + * into a -4 ... 0 ... +4 bonus/penalty range.
16193 + *
16194 + * Additionally, we scale another amount based on the number of
16195 + * CPU tokens currently held by the context, if the process is
16196 + * part of a context (and the appropriate SCHED flag is set).
16197 + * This ranges from -5 ... 0 ... +15, quadratically.
16198 + *
16199 + * So, the total bonus is -9 .. 0 .. +19
16200 + * We use ~50% of the full 0...39 priority range so that:
16201 + *
16202 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
16203 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
16204 + *    unless that context is far exceeding its CPU allocation.
16205 + *
16206 + * Both properties are important to certain workloads.
16207 + */
16208 +static inline
16209 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
16210 +{
16211 +       int vavavoom, max;
16212 +
16213 +       /* lots of tokens = lots of vavavoom
16214 +        *      no tokens = no vavavoom      */
16215 +       if ((vavavoom = sched_pc->tokens) >= 0) {
16216 +               max = sched_pc->tokens_max;
16217 +               vavavoom = max - vavavoom;
16218 +               max = max * max;
16219 +               vavavoom = max_prio * VAVAVOOM_RATIO / 100
16220 +                       * (vavavoom*vavavoom - (max >> 2)) / max;
16221 +               return vavavoom;
16222 +       }
16223 +       return 0;
16224 +}
16225 +
16226 +
16227 +static inline
16228 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
16229 +{
16230 +       struct vx_info *vxi = p->vx_info;
16231 +       struct _vx_sched_pc *sched_pc;
16232 +
16233 +       if (!vxi)
16234 +               return prio;
16235 +
16236 +       sched_pc = &vx_cpu(vxi, sched_pc);
16237 +       if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
16238 +               int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
16239 +
16240 +               sched_pc->vavavoom = vavavoom;
16241 +               prio += vavavoom;
16242 +       }
16243 +       prio += sched_pc->prio_bias;
16244 +       return prio;
16245 +}
16246 +
16247 +#else /* !CONFIG_VSERVER_HARDCPU */
16248 +
16249 +static inline
16250 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
16251 +{
16252 +       struct vx_info *vxi = p->vx_info;
16253 +
16254 +       if (vxi)
16255 +               prio += vx_cpu(vxi, sched_pc).prio_bias;
16256 +       return prio;
16257 +}
16258 +
16259 +#endif /* CONFIG_VSERVER_HARDCPU */
16260 +
16261 +
16262 +static inline void vx_account_user(struct vx_info *vxi,
16263 +       cputime_t cputime, int nice)
16264 +{
16265 +       if (!vxi)
16266 +               return;
16267 +       vx_cpu(vxi, sched_pc).user_ticks += cputime;
16268 +}
16269 +
16270 +static inline void vx_account_system(struct vx_info *vxi,
16271 +       cputime_t cputime, int idle)
16272 +{
16273 +       if (!vxi)
16274 +               return;
16275 +       vx_cpu(vxi, sched_pc).sys_ticks += cputime;
16276 +}
16277 +
16278 +#else
16279 +#warning duplicate inclusion
16280 +#endif
16281 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_socket.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_socket.h
16282 --- linux-2.6.33.2/include/linux/vs_socket.h    1970-01-01 01:00:00.000000000 +0100
16283 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_socket.h    2010-02-25 12:02:16.000000000 +0100
16284 @@ -0,0 +1,67 @@
16285 +#ifndef _VS_SOCKET_H
16286 +#define _VS_SOCKET_H
16287 +
16288 +#include "vserver/debug.h"
16289 +#include "vserver/base.h"
16290 +#include "vserver/cacct.h"
16291 +#include "vserver/context.h"
16292 +#include "vserver/tag.h"
16293 +
16294 +
16295 +/* socket accounting */
16296 +
16297 +#include <linux/socket.h>
16298 +
16299 +static inline int vx_sock_type(int family)
16300 +{
16301 +       switch (family) {
16302 +       case PF_UNSPEC:
16303 +               return VXA_SOCK_UNSPEC;
16304 +       case PF_UNIX:
16305 +               return VXA_SOCK_UNIX;
16306 +       case PF_INET:
16307 +               return VXA_SOCK_INET;
16308 +       case PF_INET6:
16309 +               return VXA_SOCK_INET6;
16310 +       case PF_PACKET:
16311 +               return VXA_SOCK_PACKET;
16312 +       default:
16313 +               return VXA_SOCK_OTHER;
16314 +       }
16315 +}
16316 +
16317 +#define vx_acc_sock(v, f, p, s) \
16318 +       __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
16319 +
16320 +static inline void __vx_acc_sock(struct vx_info *vxi,
16321 +       int family, int pos, int size, char *file, int line)
16322 +{
16323 +       if (vxi) {
16324 +               int type = vx_sock_type(family);
16325 +
16326 +               atomic_long_inc(&vxi->cacct.sock[type][pos].count);
16327 +               atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
16328 +       }
16329 +}
16330 +
16331 +#define vx_sock_recv(sk, s) \
16332 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
16333 +#define vx_sock_send(sk, s) \
16334 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
16335 +#define vx_sock_fail(sk, s) \
16336 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
16337 +
16338 +
16339 +#define sock_vx_init(s) do {           \
16340 +       (s)->sk_xid = 0;                \
16341 +       (s)->sk_vx_info = NULL;         \
16342 +       } while (0)
16343 +
16344 +#define sock_nx_init(s) do {           \
16345 +       (s)->sk_nid = 0;                \
16346 +       (s)->sk_nx_info = NULL;         \
16347 +       } while (0)
16348 +
16349 +#else
16350 +#warning duplicate inclusion
16351 +#endif
16352 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_tag.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_tag.h
16353 --- linux-2.6.33.2/include/linux/vs_tag.h       1970-01-01 01:00:00.000000000 +0100
16354 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_tag.h       2010-02-25 12:02:16.000000000 +0100
16355 @@ -0,0 +1,47 @@
16356 +#ifndef _VS_TAG_H
16357 +#define _VS_TAG_H
16358 +
16359 +#include <linux/vserver/tag.h>
16360 +
16361 +/* check conditions */
16362 +
16363 +#define DX_ADMIN       0x0001
16364 +#define DX_WATCH       0x0002
16365 +#define DX_HOSTID      0x0008
16366 +
16367 +#define DX_IDENT       0x0010
16368 +
16369 +#define DX_ARG_MASK    0x0010
16370 +
16371 +
16372 +#define dx_task_tag(t) ((t)->tag)
16373 +
16374 +#define dx_current_tag() dx_task_tag(current)
16375 +
16376 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
16377 +
16378 +#define dx_weak_check(c, m)    ((m) ? dx_check(c, m) : 1)
16379 +
16380 +
16381 +/*
16382 + * check current context for ADMIN/WATCH and
16383 + * optionally against supplied argument
16384 + */
16385 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
16386 +{
16387 +       if (mode & DX_ARG_MASK) {
16388 +               if ((mode & DX_IDENT) && (id == cid))
16389 +                       return 1;
16390 +       }
16391 +       return (((mode & DX_ADMIN) && (cid == 0)) ||
16392 +               ((mode & DX_WATCH) && (cid == 1)) ||
16393 +               ((mode & DX_HOSTID) && (id == 0)));
16394 +}
16395 +
16396 +struct inode;
16397 +int dx_permission(const struct inode *inode, int mask);
16398 +
16399 +
16400 +#else
16401 +#warning duplicate inclusion
16402 +#endif
16403 diff -NurpP --minimal linux-2.6.33.2/include/linux/vs_time.h linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_time.h
16404 --- linux-2.6.33.2/include/linux/vs_time.h      1970-01-01 01:00:00.000000000 +0100
16405 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/linux/vs_time.h      2010-02-25 12:02:16.000000000 +0100
16406 @@ -0,0 +1,19 @@
16407 +#ifndef _VS_TIME_H
16408 +#define _VS_TIME_H
16409 +
16410 +
16411 +/* time faking stuff */
16412 +
16413 +#ifdef CONFIG_VSERVER_VTIME
16414 +
16415 +extern void vx_gettimeofday(struct timeval *tv);
16416 +extern int vx_settimeofday(struct timespec *ts);
16417 +
16418 +#else
16419 +#define        vx_gettimeofday(t)      do_gettimeofday(t)
16420 +#define        vx_settimeofday(t)      do_settimeofday(t)
16421 +#endif
16422 +
16423 +#else
16424 +#warning duplicate inclusion
16425 +#endif
16426 diff -NurpP --minimal linux-2.6.33.2/include/net/addrconf.h linux-2.6.33.2-vs2.3.0.36.30.4/include/net/addrconf.h
16427 --- linux-2.6.33.2/include/net/addrconf.h       2009-12-03 20:02:57.000000000 +0100
16428 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/net/addrconf.h       2010-02-25 12:02:16.000000000 +0100
16429 @@ -84,7 +84,8 @@ extern int                    ipv6_dev_get_saddr(struct n
16430                                                struct net_device *dev,
16431                                                const struct in6_addr *daddr,
16432                                                unsigned int srcprefs,
16433 -                                              struct in6_addr *saddr);
16434 +                                              struct in6_addr *saddr,
16435 +                                              struct nx_info *nxi);
16436  extern int                     ipv6_get_lladdr(struct net_device *dev,
16437                                                 struct in6_addr *addr,
16438                                                 unsigned char banned_flags);
16439 diff -NurpP --minimal linux-2.6.33.2/include/net/af_unix.h linux-2.6.33.2-vs2.3.0.36.30.4/include/net/af_unix.h
16440 --- linux-2.6.33.2/include/net/af_unix.h        2008-12-25 00:26:37.000000000 +0100
16441 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/net/af_unix.h        2010-02-25 12:02:16.000000000 +0100
16442 @@ -4,6 +4,7 @@
16443  #include <linux/socket.h>
16444  #include <linux/un.h>
16445  #include <linux/mutex.h>
16446 +#include <linux/vs_base.h>
16447  #include <net/sock.h>
16448  
16449  extern void unix_inflight(struct file *fp);
16450 diff -NurpP --minimal linux-2.6.33.2/include/net/inet_timewait_sock.h linux-2.6.33.2-vs2.3.0.36.30.4/include/net/inet_timewait_sock.h
16451 --- linux-2.6.33.2/include/net/inet_timewait_sock.h     2010-02-25 11:52:08.000000000 +0100
16452 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/net/inet_timewait_sock.h     2010-02-25 12:02:16.000000000 +0100
16453 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
16454  #define tw_hash                        __tw_common.skc_hash
16455  #define tw_prot                        __tw_common.skc_prot
16456  #define tw_net                 __tw_common.skc_net
16457 +#define tw_xid                 __tw_common.skc_xid
16458 +#define tw_vx_info             __tw_common.skc_vx_info
16459 +#define tw_nid                 __tw_common.skc_nid
16460 +#define tw_nx_info             __tw_common.skc_nx_info
16461         int                     tw_timeout;
16462         volatile unsigned char  tw_substate;
16463         /* 3 bits hole, try to pack */
16464 diff -NurpP --minimal linux-2.6.33.2/include/net/route.h linux-2.6.33.2-vs2.3.0.36.30.4/include/net/route.h
16465 --- linux-2.6.33.2/include/net/route.h  2010-02-25 11:52:08.000000000 +0100
16466 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/net/route.h  2010-02-25 12:02:16.000000000 +0100
16467 @@ -132,6 +132,9 @@ static inline void ip_rt_put(struct rtab
16468                 dst_release(&rt->u.dst);
16469  }
16470  
16471 +#include <linux/vs_base.h>
16472 +#include <linux/vs_inet.h>
16473 +
16474  #define IPTOS_RT_MASK  (IPTOS_TOS_MASK & ~3)
16475  
16476  extern const __u8 ip_tos2prio[16];
16477 @@ -141,6 +144,9 @@ static inline char rt_tos2priority(u8 to
16478         return ip_tos2prio[IPTOS_TOS(tos)>>1];
16479  }
16480  
16481 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
16482 +       struct rtable **, struct flowi *);
16483 +
16484  static inline int ip_route_connect(struct rtable **rp, __be32 dst,
16485                                    __be32 src, u32 tos, int oif, u8 protocol,
16486                                    __be16 sport, __be16 dport, struct sock *sk,
16487 @@ -158,11 +164,24 @@ static inline int ip_route_connect(struc
16488  
16489         int err;
16490         struct net *net = sock_net(sk);
16491 +       struct nx_info *nx_info = current_nx_info();
16492  
16493         if (inet_sk(sk)->transparent)
16494                 fl.flags |= FLOWI_FLAG_ANYSRC;
16495  
16496 -       if (!dst || !src) {
16497 +       if (sk)
16498 +               nx_info = sk->sk_nx_info;
16499 +
16500 +       vxdprintk(VXD_CBIT(net, 4),
16501 +               "ip_route_connect(%p) %p,%p;%lx",
16502 +               sk, nx_info, sk->sk_socket,
16503 +               (sk->sk_socket?sk->sk_socket->flags:0));
16504 +
16505 +       err = ip_v4_find_src(net, nx_info, rp, &fl);
16506 +       if (err)
16507 +               return err;
16508 +
16509 +       if (!fl.fl4_dst || !fl.fl4_src) {
16510                 err = __ip_route_output_key(net, rp, &fl);
16511                 if (err)
16512                         return err;
16513 diff -NurpP --minimal linux-2.6.33.2/include/net/sock.h linux-2.6.33.2-vs2.3.0.36.30.4/include/net/sock.h
16514 --- linux-2.6.33.2/include/net/sock.h   2010-04-06 01:47:46.000000000 +0200
16515 +++ linux-2.6.33.2-vs2.3.0.36.30.4/include/net/sock.h   2010-04-06 01:59:25.000000000 +0200
16516 @@ -149,6 +149,10 @@ struct sock_common {
16517  #ifdef CONFIG_NET_NS
16518         struct net              *skc_net;
16519  #endif
16520 +       xid_t                   skc_xid;
16521 +       struct vx_info          *skc_vx_info;
16522 +       nid_t                   skc_nid;
16523 +       struct nx_info          *skc_nx_info;
16524  };
16525  
16526  /**
16527 @@ -236,6 +240,10 @@ struct sock {
16528  #define sk_bind_node           __sk_common.skc_bind_node
16529  #define sk_prot                        __sk_common.skc_prot
16530  #define sk_net                 __sk_common.skc_net
16531 +#define sk_xid                 __sk_common.skc_xid
16532 +#define sk_vx_info             __sk_common.skc_vx_info
16533 +#define sk_nid                 __sk_common.skc_nid
16534 +#define sk_nx_info             __sk_common.skc_nx_info
16535         kmemcheck_bitfield_begin(flags);
16536         unsigned int            sk_shutdown  : 2,
16537                                 sk_no_check  : 2,
16538 diff -NurpP --minimal linux-2.6.33.2/init/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/init/Kconfig
16539 --- linux-2.6.33.2/init/Kconfig 2010-02-25 11:52:09.000000000 +0100
16540 +++ linux-2.6.33.2-vs2.3.0.36.30.4/init/Kconfig 2010-02-25 16:27:44.000000000 +0100
16541 @@ -496,8 +496,22 @@ config CGROUP_SCHED
16542  
16543  endchoice
16544  
16545 +config CFS_HARD_LIMITS
16546 +       bool "Hard Limits for CFS Group Scheduler"
16547 +       depends on EXPERIMENTAL
16548 +       depends on FAIR_GROUP_SCHED && CGROUP_SCHED
16549 +       default y
16550 +       help
16551 +         This option enables hard limiting of CPU time obtained by
16552 +         a fair task group. Use this if you want to throttle a group of tasks
16553 +         based on its CPU usage. For more details refer to
16554 +         Documentation/scheduler/sched-cfs-hard-limits.txt
16555 +
16556 +         Say N if unsure.
16557 +
16558  menuconfig CGROUPS
16559         boolean "Control Group support"
16560 +       default y
16561         help
16562           This option adds support for grouping sets of processes together, for
16563           use with process control subsystems such as Cpusets, CFS, memory
16564 @@ -525,6 +539,7 @@ config CGROUP_DEBUG
16565  config CGROUP_NS
16566         bool "Namespace cgroup subsystem"
16567         depends on CGROUPS
16568 +       default n
16569         help
16570           Provides a simple namespace cgroup subsystem to
16571           provide hierarchical naming of sets of namespaces,
16572 diff -NurpP --minimal linux-2.6.33.2/init/main.c linux-2.6.33.2-vs2.3.0.36.30.4/init/main.c
16573 --- linux-2.6.33.2/init/main.c  2010-04-06 01:47:46.000000000 +0200
16574 +++ linux-2.6.33.2-vs2.3.0.36.30.4/init/main.c  2010-04-06 01:59:25.000000000 +0200
16575 @@ -70,6 +70,7 @@
16576  #include <linux/sfi.h>
16577  #include <linux/shmem_fs.h>
16578  #include <trace/boot.h>
16579 +#include <linux/vserver/percpu.h>
16580  
16581  #include <asm/io.h>
16582  #include <asm/bugs.h>
16583 diff -NurpP --minimal linux-2.6.33.2/ipc/mqueue.c linux-2.6.33.2-vs2.3.0.36.30.4/ipc/mqueue.c
16584 --- linux-2.6.33.2/ipc/mqueue.c 2010-04-06 01:47:46.000000000 +0200
16585 +++ linux-2.6.33.2-vs2.3.0.36.30.4/ipc/mqueue.c 2010-04-06 01:59:25.000000000 +0200
16586 @@ -32,6 +32,8 @@
16587  #include <linux/nsproxy.h>
16588  #include <linux/pid.h>
16589  #include <linux/ipc_namespace.h>
16590 +#include <linux/vs_context.h>
16591 +#include <linux/vs_limit.h>
16592  
16593  #include <net/sock.h>
16594  #include "util.h"
16595 @@ -65,6 +67,7 @@ struct mqueue_inode_info {
16596         struct sigevent notify;
16597         struct pid* notify_owner;
16598         struct user_struct *user;       /* user who created, for accounting */
16599 +       struct vx_info *vxi;
16600         struct sock *notify_sock;
16601         struct sk_buff *notify_cookie;
16602  
16603 @@ -124,6 +127,7 @@ static struct inode *mqueue_get_inode(st
16604                 if (S_ISREG(mode)) {
16605                         struct mqueue_inode_info *info;
16606                         struct task_struct *p = current;
16607 +                       struct vx_info *vxi = p->vx_info;
16608                         unsigned long mq_bytes, mq_msg_tblsz;
16609  
16610                         inode->i_fop = &mqueue_file_operations;
16611 @@ -138,6 +142,7 @@ static struct inode *mqueue_get_inode(st
16612                         info->notify_owner = NULL;
16613                         info->qsize = 0;
16614                         info->user = NULL;      /* set when all is ok */
16615 +                       info->vxi = NULL;
16616                         memset(&info->attr, 0, sizeof(info->attr));
16617                         info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
16618                         info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
16619 @@ -152,22 +157,26 @@ static struct inode *mqueue_get_inode(st
16620                         spin_lock(&mq_lock);
16621                         if (u->mq_bytes + mq_bytes < u->mq_bytes ||
16622                             u->mq_bytes + mq_bytes >
16623 -                           p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
16624 +                           p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
16625 +                           !vx_ipcmsg_avail(vxi, mq_bytes)) {
16626                                 spin_unlock(&mq_lock);
16627                                 goto out_inode;
16628                         }
16629                         u->mq_bytes += mq_bytes;
16630 +                       vx_ipcmsg_add(vxi, u, mq_bytes);
16631                         spin_unlock(&mq_lock);
16632  
16633                         info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
16634                         if (!info->messages) {
16635                                 spin_lock(&mq_lock);
16636                                 u->mq_bytes -= mq_bytes;
16637 +                               vx_ipcmsg_sub(vxi, u, mq_bytes);
16638                                 spin_unlock(&mq_lock);
16639                                 goto out_inode;
16640                         }
16641                         /* all is ok */
16642                         info->user = get_uid(u);
16643 +                       info->vxi = get_vx_info(vxi);
16644                 } else if (S_ISDIR(mode)) {
16645                         inc_nlink(inode);
16646                         /* Some things misbehave if size == 0 on a directory */
16647 @@ -268,8 +277,11 @@ static void mqueue_delete_inode(struct i
16648                    (info->attr.mq_maxmsg * info->attr.mq_msgsize));
16649         user = info->user;
16650         if (user) {
16651 +               struct vx_info *vxi = info->vxi;
16652 +
16653                 spin_lock(&mq_lock);
16654                 user->mq_bytes -= mq_bytes;
16655 +               vx_ipcmsg_sub(vxi, user, mq_bytes);
16656                 /*
16657                  * get_ns_from_inode() ensures that the
16658                  * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
16659 @@ -279,6 +291,7 @@ static void mqueue_delete_inode(struct i
16660                 if (ipc_ns)
16661                         ipc_ns->mq_queues_count--;
16662                 spin_unlock(&mq_lock);
16663 +               put_vx_info(vxi);
16664                 free_uid(user);
16665         }
16666         if (ipc_ns)
16667 diff -NurpP --minimal linux-2.6.33.2/ipc/msg.c linux-2.6.33.2-vs2.3.0.36.30.4/ipc/msg.c
16668 --- linux-2.6.33.2/ipc/msg.c    2010-02-25 11:52:09.000000000 +0100
16669 +++ linux-2.6.33.2-vs2.3.0.36.30.4/ipc/msg.c    2010-02-25 12:02:16.000000000 +0100
16670 @@ -38,6 +38,7 @@
16671  #include <linux/rwsem.h>
16672  #include <linux/nsproxy.h>
16673  #include <linux/ipc_namespace.h>
16674 +#include <linux/vs_base.h>
16675  
16676  #include <asm/current.h>
16677  #include <asm/uaccess.h>
16678 @@ -191,6 +192,7 @@ static int newque(struct ipc_namespace *
16679  
16680         msq->q_perm.mode = msgflg & S_IRWXUGO;
16681         msq->q_perm.key = key;
16682 +       msq->q_perm.xid = vx_current_xid();
16683  
16684         msq->q_perm.security = NULL;
16685         retval = security_msg_queue_alloc(msq);
16686 diff -NurpP --minimal linux-2.6.33.2/ipc/namespace.c linux-2.6.33.2-vs2.3.0.36.30.4/ipc/namespace.c
16687 --- linux-2.6.33.2/ipc/namespace.c      2009-09-10 15:26:27.000000000 +0200
16688 +++ linux-2.6.33.2-vs2.3.0.36.30.4/ipc/namespace.c      2010-02-25 12:02:16.000000000 +0100
16689 @@ -11,6 +11,8 @@
16690  #include <linux/slab.h>
16691  #include <linux/fs.h>
16692  #include <linux/mount.h>
16693 +#include <linux/vs_base.h>
16694 +#include <linux/vserver/global.h>
16695  
16696  #include "util.h"
16697  
16698 diff -NurpP --minimal linux-2.6.33.2/ipc/sem.c linux-2.6.33.2-vs2.3.0.36.30.4/ipc/sem.c
16699 --- linux-2.6.33.2/ipc/sem.c    2010-02-25 11:52:09.000000000 +0100
16700 +++ linux-2.6.33.2-vs2.3.0.36.30.4/ipc/sem.c    2010-02-25 12:02:16.000000000 +0100
16701 @@ -83,6 +83,8 @@
16702  #include <linux/rwsem.h>
16703  #include <linux/nsproxy.h>
16704  #include <linux/ipc_namespace.h>
16705 +#include <linux/vs_base.h>
16706 +#include <linux/vs_limit.h>
16707  
16708  #include <asm/uaccess.h>
16709  #include "util.h"
16710 @@ -257,6 +259,7 @@ static int newary(struct ipc_namespace *
16711  
16712         sma->sem_perm.mode = (semflg & S_IRWXUGO);
16713         sma->sem_perm.key = key;
16714 +       sma->sem_perm.xid = vx_current_xid();
16715  
16716         sma->sem_perm.security = NULL;
16717         retval = security_sem_alloc(sma);
16718 @@ -272,6 +275,9 @@ static int newary(struct ipc_namespace *
16719                 return id;
16720         }
16721         ns->used_sems += nsems;
16722 +       /* FIXME: obsoleted? */
16723 +       vx_semary_inc(sma);
16724 +       vx_nsems_add(sma, nsems);
16725  
16726         sma->sem_base = (struct sem *) &sma[1];
16727  
16728 @@ -595,6 +601,9 @@ static void freeary(struct ipc_namespace
16729         sem_unlock(sma);
16730  
16731         ns->used_sems -= sma->sem_nsems;
16732 +       /* FIXME: obsoleted? */
16733 +       vx_nsems_sub(sma, sma->sem_nsems);
16734 +       vx_semary_dec(sma);
16735         security_sem_free(sma);
16736         ipc_rcu_putref(sma);
16737  }
16738 diff -NurpP --minimal linux-2.6.33.2/ipc/shm.c linux-2.6.33.2-vs2.3.0.36.30.4/ipc/shm.c
16739 --- linux-2.6.33.2/ipc/shm.c    2010-02-25 11:52:09.000000000 +0100
16740 +++ linux-2.6.33.2-vs2.3.0.36.30.4/ipc/shm.c    2010-02-25 12:23:04.000000000 +0100
16741 @@ -39,6 +39,8 @@
16742  #include <linux/nsproxy.h>
16743  #include <linux/mount.h>
16744  #include <linux/ipc_namespace.h>
16745 +#include <linux/vs_context.h>
16746 +#include <linux/vs_limit.h>
16747  
16748  #include <asm/uaccess.h>
16749  
16750 @@ -169,7 +171,12 @@ static void shm_open(struct vm_area_stru
16751   */
16752  static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
16753  {
16754 -       ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16755 +       struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
16756 +       int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16757 +
16758 +       vx_ipcshm_sub(vxi, shp, numpages);
16759 +       ns->shm_tot -= numpages;
16760 +
16761         shm_rmid(ns, shp);
16762         shm_unlock(shp);
16763         if (!is_file_hugepages(shp->shm_file))
16764 @@ -179,6 +186,7 @@ static void shm_destroy(struct ipc_names
16765                                                 shp->mlock_user);
16766         fput (shp->shm_file);
16767         security_shm_free(shp);
16768 +       put_vx_info(vxi);
16769         ipc_rcu_putref(shp);
16770  }
16771  
16772 @@ -352,11 +360,15 @@ static int newseg(struct ipc_namespace *
16773         if (ns->shm_tot + numpages > ns->shm_ctlall)
16774                 return -ENOSPC;
16775  
16776 +       if (!vx_ipcshm_avail(current_vx_info(), numpages))
16777 +               return -ENOSPC;
16778 +
16779         shp = ipc_rcu_alloc(sizeof(*shp));
16780         if (!shp)
16781                 return -ENOMEM;
16782  
16783         shp->shm_perm.key = key;
16784 +       shp->shm_perm.xid = vx_current_xid();
16785         shp->shm_perm.mode = (shmflg & S_IRWXUGO);
16786         shp->mlock_user = NULL;
16787  
16788 @@ -410,6 +422,7 @@ static int newseg(struct ipc_namespace *
16789         ns->shm_tot += numpages;
16790         error = shp->shm_perm.id;
16791         shm_unlock(shp);
16792 +       vx_ipcshm_add(current_vx_info(), key, numpages);
16793         return error;
16794  
16795  no_id:
16796 diff -NurpP --minimal linux-2.6.33.2/kernel/capability.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/capability.c
16797 --- linux-2.6.33.2/kernel/capability.c  2010-02-25 11:52:09.000000000 +0100
16798 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/capability.c  2010-02-25 12:02:16.000000000 +0100
16799 @@ -14,6 +14,7 @@
16800  #include <linux/security.h>
16801  #include <linux/syscalls.h>
16802  #include <linux/pid_namespace.h>
16803 +#include <linux/vs_context.h>
16804  #include <asm/uaccess.h>
16805  #include "cred-internals.h"
16806  
16807 @@ -120,6 +121,7 @@ static int cap_validate_magic(cap_user_h
16808         return 0;
16809  }
16810  
16811 +
16812  /*
16813   * The only thing that can change the capabilities of the current
16814   * process is the current process. As such, we can't be in this code
16815 @@ -290,6 +292,8 @@ error:
16816         return ret;
16817  }
16818  
16819 +#include <linux/vserver/base.h>
16820 +
16821  /**
16822   * capable - Determine if the current task has a superior capability in effect
16823   * @cap: The capability to be tested for
16824 @@ -302,6 +306,9 @@ error:
16825   */
16826  int capable(int cap)
16827  {
16828 +       /* here for now so we don't require task locking */
16829 +       if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
16830 +               return 0;
16831         if (unlikely(!cap_valid(cap))) {
16832                 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
16833                 BUG();
16834 diff -NurpP --minimal linux-2.6.33.2/kernel/compat.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/compat.c
16835 --- linux-2.6.33.2/kernel/compat.c      2009-09-10 15:26:27.000000000 +0200
16836 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/compat.c      2010-02-25 12:02:16.000000000 +0100
16837 @@ -902,7 +902,7 @@ asmlinkage long compat_sys_time(compat_t
16838         compat_time_t i;
16839         struct timeval tv;
16840  
16841 -       do_gettimeofday(&tv);
16842 +       vx_gettimeofday(&tv);
16843         i = tv.tv_sec;
16844  
16845         if (tloc) {
16846 @@ -927,7 +927,7 @@ asmlinkage long compat_sys_stime(compat_
16847         if (err)
16848                 return err;
16849  
16850 -       do_settimeofday(&tv);
16851 +       vx_settimeofday(&tv);
16852         return 0;
16853  }
16854  
16855 diff -NurpP --minimal linux-2.6.33.2/kernel/exit.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/exit.c
16856 --- linux-2.6.33.2/kernel/exit.c        2010-02-25 11:52:09.000000000 +0100
16857 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/exit.c        2010-02-25 12:02:16.000000000 +0100
16858 @@ -48,6 +48,10 @@
16859  #include <linux/fs_struct.h>
16860  #include <linux/init_task.h>
16861  #include <linux/perf_event.h>
16862 +#include <linux/vs_limit.h>
16863 +#include <linux/vs_context.h>
16864 +#include <linux/vs_network.h>
16865 +#include <linux/vs_pid.h>
16866  #include <trace/events/sched.h>
16867  #include <linux/hw_breakpoint.h>
16868  
16869 @@ -489,9 +493,11 @@ static void close_files(struct files_str
16870                                         filp_close(file, files);
16871                                         cond_resched();
16872                                 }
16873 +                               vx_openfd_dec(i);
16874                         }
16875                         i++;
16876                         set >>= 1;
16877 +                       cond_resched();
16878                 }
16879         }
16880  }
16881 @@ -1019,11 +1025,16 @@ NORET_TYPE void do_exit(long code)
16882  
16883         validate_creds_for_do_exit(tsk);
16884  
16885 +       /* needs to stay after exit_notify() */
16886 +       exit_vx_info(tsk, code);
16887 +       exit_nx_info(tsk);
16888 +
16889         preempt_disable();
16890         exit_rcu();
16891         /* causes final put_task_struct in finish_task_switch(). */
16892         tsk->state = TASK_DEAD;
16893         schedule();
16894 +       printk("bad task: %p [%lx]\n", current, current->state);
16895         BUG();
16896         /* Avoid "noreturn function does return".  */
16897         for (;;)
16898 diff -NurpP --minimal linux-2.6.33.2/kernel/fork.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/fork.c
16899 --- linux-2.6.33.2/kernel/fork.c        2010-02-25 11:52:09.000000000 +0100
16900 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/fork.c        2010-02-25 12:23:31.000000000 +0100
16901 @@ -65,6 +65,10 @@
16902  #include <linux/perf_event.h>
16903  #include <linux/posix-timers.h>
16904  #include <linux/user-return-notifier.h>
16905 +#include <linux/vs_context.h>
16906 +#include <linux/vs_network.h>
16907 +#include <linux/vs_limit.h>
16908 +#include <linux/vs_memory.h>
16909  
16910  #include <asm/pgtable.h>
16911  #include <asm/pgalloc.h>
16912 @@ -152,6 +156,8 @@ void free_task(struct task_struct *tsk)
16913         account_kernel_stack(tsk->stack, -1);
16914         free_thread_info(tsk->stack);
16915         rt_mutex_debug_task_free(tsk);
16916 +       clr_vx_info(&tsk->vx_info);
16917 +       clr_nx_info(&tsk->nx_info);
16918         ftrace_graph_exit_task(tsk);
16919         free_task_struct(tsk);
16920  }
16921 @@ -298,6 +304,8 @@ static int dup_mmap(struct mm_struct *mm
16922         mm->free_area_cache = oldmm->mmap_base;
16923         mm->cached_hole_size = ~0UL;
16924         mm->map_count = 0;
16925 +       __set_mm_counter(mm, file_rss, 0);
16926 +       __set_mm_counter(mm, anon_rss, 0);
16927         cpumask_clear(mm_cpumask(mm));
16928         mm->mm_rb = RB_ROOT;
16929         rb_link = &mm->mm_rb.rb_node;
16930 @@ -312,7 +320,7 @@ static int dup_mmap(struct mm_struct *mm
16931  
16932                 if (mpnt->vm_flags & VM_DONTCOPY) {
16933                         long pages = vma_pages(mpnt);
16934 -                       mm->total_vm -= pages;
16935 +                       vx_vmpages_sub(mm, pages);
16936                         vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
16937                                                                 -pages);
16938                         continue;
16939 @@ -454,8 +462,8 @@ static struct mm_struct * mm_init(struct
16940                 (current->mm->flags & MMF_INIT_MASK) : default_dump_filter;
16941         mm->core_state = NULL;
16942         mm->nr_ptes = 0;
16943 -       set_mm_counter(mm, file_rss, 0);
16944 -       set_mm_counter(mm, anon_rss, 0);
16945 +       __set_mm_counter(mm, file_rss, 0);
16946 +       __set_mm_counter(mm, anon_rss, 0);
16947         spin_lock_init(&mm->page_table_lock);
16948         mm->free_area_cache = TASK_UNMAPPED_BASE;
16949         mm->cached_hole_size = ~0UL;
16950 @@ -465,6 +473,7 @@ static struct mm_struct * mm_init(struct
16951         if (likely(!mm_alloc_pgd(mm))) {
16952                 mm->def_flags = 0;
16953                 mmu_notifier_mm_init(mm);
16954 +               set_vx_info(&mm->mm_vx_info, p->vx_info);
16955                 return mm;
16956         }
16957  
16958 @@ -498,6 +507,7 @@ void __mmdrop(struct mm_struct *mm)
16959         mm_free_pgd(mm);
16960         destroy_context(mm);
16961         mmu_notifier_mm_destroy(mm);
16962 +       clr_vx_info(&mm->mm_vx_info);
16963         free_mm(mm);
16964  }
16965  EXPORT_SYMBOL_GPL(__mmdrop);
16966 @@ -633,6 +643,7 @@ struct mm_struct *dup_mm(struct task_str
16967                 goto fail_nomem;
16968  
16969         memcpy(mm, oldmm, sizeof(*mm));
16970 +       mm->mm_vx_info = NULL;
16971  
16972         /* Initializing for Swap token stuff */
16973         mm->token_priority = 0;
16974 @@ -671,6 +682,7 @@ fail_nocontext:
16975          * If init_new_context() failed, we cannot use mmput() to free the mm
16976          * because it calls destroy_context()
16977          */
16978 +       clr_vx_info(&mm->mm_vx_info);
16979         mm_free_pgd(mm);
16980         free_mm(mm);
16981         return NULL;
16982 @@ -985,6 +997,8 @@ static struct task_struct *copy_process(
16983         int retval;
16984         struct task_struct *p;
16985         int cgroup_callbacks_done = 0;
16986 +       struct vx_info *vxi;
16987 +       struct nx_info *nxi;
16988  
16989         if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
16990                 return ERR_PTR(-EINVAL);
16991 @@ -1031,12 +1045,28 @@ static struct task_struct *copy_process(
16992         DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
16993         DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
16994  #endif
16995 +       init_vx_info(&p->vx_info, current_vx_info());
16996 +       init_nx_info(&p->nx_info, current_nx_info());
16997 +
16998 +       /* check vserver memory */
16999 +       if (p->mm && !(clone_flags & CLONE_VM)) {
17000 +               if (vx_vmpages_avail(p->mm, p->mm->total_vm))
17001 +                       vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17002 +               else
17003 +                       goto bad_fork_free;
17004 +       }
17005 +       if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
17006 +               if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
17007 +                       goto bad_fork_cleanup_vm;
17008 +       }
17009         retval = -EAGAIN;
17010 +       if (!vx_nproc_avail(1))
17011 +               goto bad_fork_cleanup_vm;
17012         if (atomic_read(&p->real_cred->user->processes) >=
17013                         p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
17014                 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
17015                     p->real_cred->user != INIT_USER)
17016 -                       goto bad_fork_free;
17017 +                       goto bad_fork_cleanup_vm;
17018         }
17019  
17020         retval = copy_creds(p, clone_flags);
17021 @@ -1297,6 +1327,18 @@ static struct task_struct *copy_process(
17022  
17023         total_forks++;
17024         spin_unlock(&current->sighand->siglock);
17025 +
17026 +       /* p is copy of current */
17027 +       vxi = p->vx_info;
17028 +       if (vxi) {
17029 +               claim_vx_info(vxi, p);
17030 +               atomic_inc(&vxi->cvirt.nr_threads);
17031 +               atomic_inc(&vxi->cvirt.total_forks);
17032 +               vx_nproc_inc(p);
17033 +       }
17034 +       nxi = p->nx_info;
17035 +       if (nxi)
17036 +               claim_nx_info(nxi, p);
17037         write_unlock_irq(&tasklist_lock);
17038         proc_fork_connector(p);
17039         cgroup_post_fork(p);
17040 @@ -1339,6 +1381,9 @@ bad_fork_cleanup_cgroup:
17041  bad_fork_cleanup_count:
17042         atomic_dec(&p->cred->user->processes);
17043         exit_creds(p);
17044 +bad_fork_cleanup_vm:
17045 +       if (p->mm && !(clone_flags & CLONE_VM))
17046 +               vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17047  bad_fork_free:
17048         free_task(p);
17049  fork_out:
17050 diff -NurpP --minimal linux-2.6.33.2/kernel/kthread.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/kthread.c
17051 --- linux-2.6.33.2/kernel/kthread.c     2010-04-06 01:47:46.000000000 +0200
17052 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/kthread.c     2010-04-06 01:59:25.000000000 +0200
17053 @@ -14,6 +14,7 @@
17054  #include <linux/file.h>
17055  #include <linux/module.h>
17056  #include <linux/mutex.h>
17057 +#include <linux/vs_pid.h>
17058  #include <trace/events/sched.h>
17059  
17060  static DEFINE_SPINLOCK(kthread_create_lock);
17061 diff -NurpP --minimal linux-2.6.33.2/kernel/Makefile linux-2.6.33.2-vs2.3.0.36.30.4/kernel/Makefile
17062 --- linux-2.6.33.2/kernel/Makefile      2010-02-25 11:52:09.000000000 +0100
17063 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/Makefile      2010-02-25 12:02:16.000000000 +0100
17064 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
17065  CFLAGS_REMOVE_perf_event.o = -pg
17066  endif
17067  
17068 +obj-y += vserver/
17069  obj-$(CONFIG_FREEZER) += freezer.o
17070  obj-$(CONFIG_PROFILING) += profile.o
17071  obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
17072 diff -NurpP --minimal linux-2.6.33.2/kernel/nsproxy.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/nsproxy.c
17073 --- linux-2.6.33.2/kernel/nsproxy.c     2009-09-10 15:26:28.000000000 +0200
17074 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/nsproxy.c     2010-02-25 12:02:16.000000000 +0100
17075 @@ -19,6 +19,8 @@
17076  #include <linux/mnt_namespace.h>
17077  #include <linux/utsname.h>
17078  #include <linux/pid_namespace.h>
17079 +#include <linux/vserver/global.h>
17080 +#include <linux/vserver/debug.h>
17081  #include <net/net_namespace.h>
17082  #include <linux/ipc_namespace.h>
17083  
17084 @@ -31,8 +33,11 @@ static inline struct nsproxy *create_nsp
17085         struct nsproxy *nsproxy;
17086  
17087         nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
17088 -       if (nsproxy)
17089 +       if (nsproxy) {
17090                 atomic_set(&nsproxy->count, 1);
17091 +               atomic_inc(&vs_global_nsproxy);
17092 +       }
17093 +       vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
17094         return nsproxy;
17095  }
17096  
17097 @@ -41,41 +46,52 @@ static inline struct nsproxy *create_nsp
17098   * Return the newly created nsproxy.  Do not attach this to the task,
17099   * leave it to the caller to do proper locking and attach it to task.
17100   */
17101 -static struct nsproxy *create_new_namespaces(unsigned long flags,
17102 -                       struct task_struct *tsk, struct fs_struct *new_fs)
17103 +static struct nsproxy *unshare_namespaces(unsigned long flags,
17104 +                       struct nsproxy *orig, struct fs_struct *new_fs)
17105  {
17106         struct nsproxy *new_nsp;
17107         int err;
17108  
17109 +       vxdprintk(VXD_CBIT(space, 4),
17110 +               "unshare_namespaces(0x%08lx,%p,%p)",
17111 +               flags, orig, new_fs);
17112 +
17113         new_nsp = create_nsproxy();
17114         if (!new_nsp)
17115                 return ERR_PTR(-ENOMEM);
17116  
17117 -       new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
17118 +       new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
17119         if (IS_ERR(new_nsp->mnt_ns)) {
17120                 err = PTR_ERR(new_nsp->mnt_ns);
17121                 goto out_ns;
17122         }
17123  
17124 -       new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
17125 +       new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
17126         if (IS_ERR(new_nsp->uts_ns)) {
17127                 err = PTR_ERR(new_nsp->uts_ns);
17128                 goto out_uts;
17129         }
17130  
17131 -       new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
17132 +       new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
17133         if (IS_ERR(new_nsp->ipc_ns)) {
17134                 err = PTR_ERR(new_nsp->ipc_ns);
17135                 goto out_ipc;
17136         }
17137  
17138 -       new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
17139 +       new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
17140         if (IS_ERR(new_nsp->pid_ns)) {
17141                 err = PTR_ERR(new_nsp->pid_ns);
17142                 goto out_pid;
17143         }
17144  
17145 -       new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
17146 +       /* disabled now?
17147 +       new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
17148 +       if (IS_ERR(new_nsp->user_ns)) {
17149 +               err = PTR_ERR(new_nsp->user_ns);
17150 +               goto out_user;
17151 +       } */
17152 +
17153 +       new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
17154         if (IS_ERR(new_nsp->net_ns)) {
17155                 err = PTR_ERR(new_nsp->net_ns);
17156                 goto out_net;
17157 @@ -100,6 +116,38 @@ out_ns:
17158         return ERR_PTR(err);
17159  }
17160  
17161 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17162 +                       struct fs_struct *new_fs)
17163 +{
17164 +       return unshare_namespaces(flags, tsk->nsproxy, new_fs);
17165 +}
17166 +
17167 +/*
17168 + * copies the nsproxy, setting refcount to 1, and grabbing a
17169 + * reference to all contained namespaces.
17170 + */
17171 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
17172 +{
17173 +       struct nsproxy *ns = create_nsproxy();
17174 +
17175 +       if (ns) {
17176 +               memcpy(ns, orig, sizeof(struct nsproxy));
17177 +               atomic_set(&ns->count, 1);
17178 +
17179 +               if (ns->mnt_ns)
17180 +                       get_mnt_ns(ns->mnt_ns);
17181 +               if (ns->uts_ns)
17182 +                       get_uts_ns(ns->uts_ns);
17183 +               if (ns->ipc_ns)
17184 +                       get_ipc_ns(ns->ipc_ns);
17185 +               if (ns->pid_ns)
17186 +                       get_pid_ns(ns->pid_ns);
17187 +               if (ns->net_ns)
17188 +                       get_net(ns->net_ns);
17189 +       }
17190 +       return ns;
17191 +}
17192 +
17193  /*
17194   * called from clone.  This now handles copy for nsproxy and all
17195   * namespaces therein.
17196 @@ -107,9 +155,12 @@ out_ns:
17197  int copy_namespaces(unsigned long flags, struct task_struct *tsk)
17198  {
17199         struct nsproxy *old_ns = tsk->nsproxy;
17200 -       struct nsproxy *new_ns;
17201 +       struct nsproxy *new_ns = NULL;
17202         int err = 0;
17203  
17204 +       vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
17205 +               flags, tsk, old_ns);
17206 +
17207         if (!old_ns)
17208                 return 0;
17209  
17210 @@ -119,7 +170,7 @@ int copy_namespaces(unsigned long flags,
17211                                 CLONE_NEWPID | CLONE_NEWNET)))
17212                 return 0;
17213  
17214 -       if (!capable(CAP_SYS_ADMIN)) {
17215 +       if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
17216                 err = -EPERM;
17217                 goto out;
17218         }
17219 @@ -146,6 +197,9 @@ int copy_namespaces(unsigned long flags,
17220  
17221  out:
17222         put_nsproxy(old_ns);
17223 +       vxdprintk(VXD_CBIT(space, 3),
17224 +               "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
17225 +               flags, tsk, old_ns, err, new_ns);
17226         return err;
17227  }
17228  
17229 @@ -159,7 +213,9 @@ void free_nsproxy(struct nsproxy *ns)
17230                 put_ipc_ns(ns->ipc_ns);
17231         if (ns->pid_ns)
17232                 put_pid_ns(ns->pid_ns);
17233 -       put_net(ns->net_ns);
17234 +       if (ns->net_ns)
17235 +               put_net(ns->net_ns);
17236 +       atomic_dec(&vs_global_nsproxy);
17237         kmem_cache_free(nsproxy_cachep, ns);
17238  }
17239  
17240 @@ -172,11 +228,15 @@ int unshare_nsproxy_namespaces(unsigned 
17241  {
17242         int err = 0;
17243  
17244 +       vxdprintk(VXD_CBIT(space, 4),
17245 +               "unshare_nsproxy_namespaces(0x%08lx,[%p])",
17246 +               unshare_flags, current->nsproxy);
17247 +
17248         if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
17249                                CLONE_NEWNET)))
17250                 return 0;
17251  
17252 -       if (!capable(CAP_SYS_ADMIN))
17253 +       if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
17254                 return -EPERM;
17255  
17256         *new_nsp = create_new_namespaces(unshare_flags, current,
17257 diff -NurpP --minimal linux-2.6.33.2/kernel/pid.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/pid.c
17258 --- linux-2.6.33.2/kernel/pid.c 2010-02-25 11:52:09.000000000 +0100
17259 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/pid.c 2010-02-25 12:02:16.000000000 +0100
17260 @@ -36,6 +36,7 @@
17261  #include <linux/pid_namespace.h>
17262  #include <linux/init_task.h>
17263  #include <linux/syscalls.h>
17264 +#include <linux/vs_pid.h>
17265  
17266  #define pid_hashfn(nr, ns)     \
17267         hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
17268 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
17269  
17270  struct pid *find_vpid(int nr)
17271  {
17272 -       return find_pid_ns(nr, current->nsproxy->pid_ns);
17273 +       return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
17274  }
17275  EXPORT_SYMBOL_GPL(find_vpid);
17276  
17277 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
17278  struct task_struct *pid_task(struct pid *pid, enum pid_type type)
17279  {
17280         struct task_struct *result = NULL;
17281 +
17282 +       if (type == PIDTYPE_REALPID)
17283 +               type = PIDTYPE_PID;
17284         if (pid) {
17285                 struct hlist_node *first;
17286                 first = rcu_dereference(pid->tasks[type].first);
17287 @@ -380,7 +384,7 @@ EXPORT_SYMBOL(pid_task);
17288   */
17289  struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
17290  {
17291 -       return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
17292 +       return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
17293  }
17294  
17295  struct task_struct *find_task_by_vpid(pid_t vnr)
17296 @@ -422,7 +426,7 @@ struct pid *find_get_pid(pid_t nr)
17297  }
17298  EXPORT_SYMBOL_GPL(find_get_pid);
17299  
17300 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
17301 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
17302  {
17303         struct upid *upid;
17304         pid_t nr = 0;
17305 @@ -435,6 +439,11 @@ pid_t pid_nr_ns(struct pid *pid, struct 
17306         return nr;
17307  }
17308  
17309 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
17310 +{
17311 +       return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
17312 +}
17313 +
17314  pid_t pid_vnr(struct pid *pid)
17315  {
17316         return pid_nr_ns(pid, current->nsproxy->pid_ns);
17317 diff -NurpP --minimal linux-2.6.33.2/kernel/pid_namespace.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/pid_namespace.c
17318 --- linux-2.6.33.2/kernel/pid_namespace.c       2009-12-03 20:02:58.000000000 +0100
17319 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/pid_namespace.c       2010-02-25 12:02:16.000000000 +0100
17320 @@ -13,6 +13,7 @@
17321  #include <linux/syscalls.h>
17322  #include <linux/err.h>
17323  #include <linux/acct.h>
17324 +#include <linux/vserver/global.h>
17325  
17326  #define BITS_PER_PAGE          (PAGE_SIZE*8)
17327  
17328 @@ -86,6 +87,7 @@ static struct pid_namespace *create_pid_
17329                 goto out_free_map;
17330  
17331         kref_init(&ns->kref);
17332 +       atomic_inc(&vs_global_pid_ns);
17333         ns->level = level;
17334         ns->parent = get_pid_ns(parent_pid_ns);
17335  
17336 @@ -111,6 +113,7 @@ static void destroy_pid_namespace(struct
17337  
17338         for (i = 0; i < PIDMAP_ENTRIES; i++)
17339                 kfree(ns->pidmap[i].page);
17340 +       atomic_dec(&vs_global_pid_ns);
17341         kmem_cache_free(pid_ns_cachep, ns);
17342  }
17343  
17344 diff -NurpP --minimal linux-2.6.33.2/kernel/posix-timers.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/posix-timers.c
17345 --- linux-2.6.33.2/kernel/posix-timers.c        2009-12-03 20:02:58.000000000 +0100
17346 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/posix-timers.c        2010-02-25 12:02:16.000000000 +0100
17347 @@ -46,6 +46,7 @@
17348  #include <linux/wait.h>
17349  #include <linux/workqueue.h>
17350  #include <linux/module.h>
17351 +#include <linux/vs_context.h>
17352  
17353  /*
17354   * Management arrays for POSIX timers.  Timers are kept in slab memory
17355 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
17356  {
17357         struct task_struct *task;
17358         int shared, ret = -1;
17359 +
17360         /*
17361          * FIXME: if ->sigq is queued we can race with
17362          * dequeue_signal()->do_schedule_next_timer().
17363 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
17364         rcu_read_lock();
17365         task = pid_task(timr->it_pid, PIDTYPE_PID);
17366         if (task) {
17367 +               struct vx_info_save vxis;
17368 +               struct vx_info *vxi;
17369 +
17370 +               vxi = get_vx_info(task->vx_info);
17371 +               enter_vx_info(vxi, &vxis);
17372                 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
17373                 ret = send_sigqueue(timr->sigq, task, shared);
17374 +               leave_vx_info(&vxis);
17375 +               put_vx_info(vxi);
17376         }
17377         rcu_read_unlock();
17378 +
17379         /* If we failed to send the signal the timer stops. */
17380         return ret > 0;
17381  }
17382 diff -NurpP --minimal linux-2.6.33.2/kernel/printk.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/printk.c
17383 --- linux-2.6.33.2/kernel/printk.c      2010-02-25 11:52:09.000000000 +0100
17384 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/printk.c      2010-02-25 13:11:15.000000000 +0100
17385 @@ -35,6 +35,7 @@
17386  #include <linux/kexec.h>
17387  #include <linux/ratelimit.h>
17388  #include <linux/kmsg_dump.h>
17389 +#include <linux/vs_cvirt.h>
17390  
17391  #include <asm/uaccess.h>
17392  
17393 @@ -278,18 +279,13 @@ int do_syslog(int type, char __user *buf
17394         unsigned i, j, limit, count;
17395         int do_clear = 0;
17396         char c;
17397 -       int error = 0;
17398 +       int error;
17399  
17400         error = security_syslog(type);
17401         if (error)
17402                 return error;
17403  
17404 -       switch (type) {
17405 -       case 0:         /* Close log */
17406 -               break;
17407 -       case 1:         /* Open log */
17408 -               break;
17409 -       case 2:         /* Read from log */
17410 +       if ((type >= 2) && (type <= 4)) {
17411                 error = -EINVAL;
17412                 if (!buf || len < 0)
17413                         goto out;
17414 @@ -300,6 +296,16 @@ int do_syslog(int type, char __user *buf
17415                         error = -EFAULT;
17416                         goto out;
17417                 }
17418 +       }
17419 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
17420 +               return vx_do_syslog(type, buf, len);
17421 +
17422 +       switch (type) {
17423 +       case 0:         /* Close log */
17424 +               break;
17425 +       case 1:         /* Open log */
17426 +               break;
17427 +       case 2:         /* Read from log */
17428                 error = wait_event_interruptible(log_wait,
17429                                                         (log_start - log_end));
17430                 if (error)
17431 @@ -324,16 +330,6 @@ int do_syslog(int type, char __user *buf
17432                 do_clear = 1;
17433                 /* FALL THRU */
17434         case 3:         /* Read last kernel messages */
17435 -               error = -EINVAL;
17436 -               if (!buf || len < 0)
17437 -                       goto out;
17438 -               error = 0;
17439 -               if (!len)
17440 -                       goto out;
17441 -               if (!access_ok(VERIFY_WRITE, buf, len)) {
17442 -                       error = -EFAULT;
17443 -                       goto out;
17444 -               }
17445                 count = len;
17446                 if (count > log_buf_len)
17447                         count = log_buf_len;
17448 diff -NurpP --minimal linux-2.6.33.2/kernel/ptrace.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/ptrace.c
17449 --- linux-2.6.33.2/kernel/ptrace.c      2009-12-03 20:02:58.000000000 +0100
17450 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/ptrace.c      2010-02-25 12:02:16.000000000 +0100
17451 @@ -22,6 +22,7 @@
17452  #include <linux/pid_namespace.h>
17453  #include <linux/syscalls.h>
17454  #include <linux/uaccess.h>
17455 +#include <linux/vs_context.h>
17456  
17457  
17458  /*
17459 @@ -151,6 +152,11 @@ int __ptrace_may_access(struct task_stru
17460                 dumpable = get_dumpable(task->mm);
17461         if (!dumpable && !capable(CAP_SYS_PTRACE))
17462                 return -EPERM;
17463 +       if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
17464 +               return -EPERM;
17465 +       if (!vx_check(task->xid, VS_IDENT) &&
17466 +               !task_vx_flags(task, VXF_STATE_ADMIN, 0))
17467 +               return -EACCES;
17468  
17469         return security_ptrace_access_check(task, mode);
17470  }
17471 @@ -621,6 +627,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
17472                 goto out;
17473         }
17474  
17475 +       ret = -EPERM;
17476 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
17477 +               goto out_put_task_struct;
17478 +
17479         if (request == PTRACE_ATTACH) {
17480                 ret = ptrace_attach(child);
17481                 /*
17482 diff -NurpP --minimal linux-2.6.33.2/kernel/sched.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/sched.c
17483 --- linux-2.6.33.2/kernel/sched.c       2010-04-06 01:47:46.000000000 +0200
17484 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/sched.c       2010-04-06 01:59:25.000000000 +0200
17485 @@ -71,6 +71,8 @@
17486  #include <linux/debugfs.h>
17487  #include <linux/ctype.h>
17488  #include <linux/ftrace.h>
17489 +#include <linux/vs_sched.h>
17490 +#include <linux/vs_cvirt.h>
17491  
17492  #include <asm/tlb.h>
17493  #include <asm/irq_regs.h>
17494 @@ -3009,9 +3011,17 @@ EXPORT_SYMBOL(avenrun);
17495   */
17496  void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
17497  {
17498 -       loads[0] = (avenrun[0] + offset) << shift;
17499 -       loads[1] = (avenrun[1] + offset) << shift;
17500 -       loads[2] = (avenrun[2] + offset) << shift;
17501 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
17502 +               struct vx_info *vxi = current_vx_info();
17503 +
17504 +               loads[0] = (vxi->cvirt.load[0] + offset) << shift;
17505 +               loads[1] = (vxi->cvirt.load[1] + offset) << shift;
17506 +               loads[2] = (vxi->cvirt.load[2] + offset) << shift;
17507 +       } else {
17508 +               loads[0] = (avenrun[0] + offset) << shift;
17509 +               loads[1] = (avenrun[1] + offset) << shift;
17510 +               loads[2] = (avenrun[2] + offset) << shift;
17511 +       }
17512  }
17513  
17514  static unsigned long
17515 @@ -5067,16 +5077,19 @@ void account_user_time(struct task_struc
17516                        cputime_t cputime_scaled)
17517  {
17518         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17519 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17520         cputime64_t tmp;
17521 +       int nice = (TASK_NICE(p) > 0);
17522  
17523         /* Add user time to process. */
17524         p->utime = cputime_add(p->utime, cputime);
17525         p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
17526 +       vx_account_user(vxi, cputime, nice);
17527         account_group_user_time(p, cputime);
17528  
17529         /* Add user time to cpustat. */
17530         tmp = cputime_to_cputime64(cputime);
17531 -       if (TASK_NICE(p) > 0)
17532 +       if (nice)
17533                 cpustat->nice = cputime64_add(cpustat->nice, tmp);
17534         else
17535                 cpustat->user = cputime64_add(cpustat->user, tmp);
17536 @@ -5127,6 +5140,7 @@ void account_system_time(struct task_str
17537                          cputime_t cputime, cputime_t cputime_scaled)
17538  {
17539         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17540 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17541         cputime64_t tmp;
17542  
17543         if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
17544 @@ -5137,6 +5151,7 @@ void account_system_time(struct task_str
17545         /* Add system time to process. */
17546         p->stime = cputime_add(p->stime, cputime);
17547         p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
17548 +       vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
17549         account_group_system_time(p, cputime);
17550  
17551         /* Add system time to cpustat. */
17552 @@ -6202,7 +6217,7 @@ SYSCALL_DEFINE1(nice, int, increment)
17553                 nice = 19;
17554  
17555         if (increment < 0 && !can_nice(current, nice))
17556 -               return -EPERM;
17557 +               return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
17558  
17559         retval = security_task_setnice(current, nice);
17560         if (retval)
17561 diff -NurpP --minimal linux-2.6.33.2/kernel/sched_fair.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/sched_fair.c
17562 --- linux-2.6.33.2/kernel/sched_fair.c  2010-02-25 11:52:09.000000000 +0100
17563 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/sched_fair.c  2010-03-18 17:25:17.000000000 +0100
17564 @@ -794,6 +794,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
17565         check_spread(cfs_rq, se);
17566         if (se != cfs_rq->curr)
17567                 __enqueue_entity(cfs_rq, se);
17568 +
17569 +       if (entity_is_task(se))
17570 +               vx_activate_task(task_of(se));
17571  }
17572  
17573  static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
17574 @@ -837,6 +840,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
17575  
17576         if (se != cfs_rq->curr)
17577                 __dequeue_entity(cfs_rq, se);
17578 +       if (entity_is_task(se))
17579 +               vx_deactivate_task(task_of(se));
17580         account_entity_dequeue(cfs_rq, se);
17581         update_min_vruntime(cfs_rq);
17582  
17583 diff -NurpP --minimal linux-2.6.33.2/kernel/signal.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/signal.c
17584 --- linux-2.6.33.2/kernel/signal.c      2010-02-25 11:52:09.000000000 +0100
17585 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/signal.c      2010-03-10 20:32:43.000000000 +0100
17586 @@ -28,6 +28,8 @@
17587  #include <linux/freezer.h>
17588  #include <linux/pid_namespace.h>
17589  #include <linux/nsproxy.h>
17590 +#include <linux/vs_context.h>
17591 +#include <linux/vs_pid.h>
17592  #define CREATE_TRACE_POINTS
17593  #include <trace/events/signal.h>
17594  
17595 @@ -629,9 +631,18 @@ static int check_kill_permission(int sig
17596         struct pid *sid;
17597         int error;
17598  
17599 +       vxdprintk(VXD_CBIT(misc, 7),
17600 +               "check_kill_permission(%d,%p,%p[#%u,%u])",
17601 +               sig, info, t, vx_task_xid(t), t->pid);
17602 +
17603         if (!valid_signal(sig))
17604                 return -EINVAL;
17605  
17606 +/*     FIXME: needed? if so, why?
17607 +       if ((info != SEND_SIG_NOINFO) &&
17608 +               (is_si_special(info) || !si_fromuser(info)))
17609 +               goto skip;      */
17610 +
17611         if (!si_fromuser(info))
17612                 return 0;
17613  
17614 @@ -659,6 +670,20 @@ static int check_kill_permission(int sig
17615                 }
17616         }
17617  
17618 +       error = -EPERM;
17619 +       if (t->pid == 1 && current->xid)
17620 +               return error;
17621 +
17622 +       error = -ESRCH;
17623 +       /* FIXME: we shouldn't return ESRCH ever, to avoid
17624 +                 loops, maybe ENOENT or EACCES? */
17625 +       if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17626 +               vxdprintk(current->xid || VXD_CBIT(misc, 7),
17627 +                       "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17628 +                       sig, info, t, vx_task_xid(t), t->pid, current->xid);
17629 +               return error;
17630 +       }
17631 +/* skip: */
17632         return security_task_kill(t, info, sig, 0);
17633  }
17634  
17635 @@ -1147,7 +1172,7 @@ int kill_pid_info(int sig, struct siginf
17636         rcu_read_lock();
17637  retry:
17638         p = pid_task(pid, PIDTYPE_PID);
17639 -       if (p) {
17640 +       if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17641                 error = group_send_sig_info(sig, info, p);
17642                 if (unlikely(error == -ESRCH))
17643                         /*
17644 @@ -1187,7 +1212,7 @@ int kill_pid_info_as_uid(int sig, struct
17645  
17646         rcu_read_lock();
17647         p = pid_task(pid, PIDTYPE_PID);
17648 -       if (!p) {
17649 +       if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17650                 ret = -ESRCH;
17651                 goto out_unlock;
17652         }
17653 @@ -1242,8 +1267,10 @@ static int kill_something_info(int sig, 
17654                 struct task_struct * p;
17655  
17656                 for_each_process(p) {
17657 -                       if (task_pid_vnr(p) > 1 &&
17658 -                                       !same_thread_group(p, current)) {
17659 +                       if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17660 +                               task_pid_vnr(p) > 1 &&
17661 +                               !same_thread_group(p, current) &&
17662 +                               !vx_current_initpid(p->pid)) {
17663                                 int err = group_send_sig_info(sig, info, p);
17664                                 ++count;
17665                                 if (err != -EPERM)
17666 @@ -1910,6 +1937,11 @@ relock:
17667                                 !sig_kernel_only(signr))
17668                         continue;
17669  
17670 +               /* virtual init is protected against user signals */
17671 +               if ((info->si_code == SI_USER) &&
17672 +                       vx_current_initpid(current->pid))
17673 +                       continue;
17674 +
17675                 if (sig_kernel_stop(signr)) {
17676                         /*
17677                          * The default action is to stop all threads in
17678 diff -NurpP --minimal linux-2.6.33.2/kernel/softirq.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/softirq.c
17679 --- linux-2.6.33.2/kernel/softirq.c     2010-02-25 11:52:09.000000000 +0100
17680 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/softirq.c     2010-02-25 12:02:16.000000000 +0100
17681 @@ -24,6 +24,7 @@
17682  #include <linux/ftrace.h>
17683  #include <linux/smp.h>
17684  #include <linux/tick.h>
17685 +#include <linux/vs_context.h>
17686  
17687  #define CREATE_TRACE_POINTS
17688  #include <trace/events/irq.h>
17689 diff -NurpP --minimal linux-2.6.33.2/kernel/sys.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/sys.c
17690 --- linux-2.6.33.2/kernel/sys.c 2010-02-25 11:52:09.000000000 +0100
17691 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/sys.c 2010-02-25 13:13:03.000000000 +0100
17692 @@ -40,6 +40,7 @@
17693  #include <linux/syscalls.h>
17694  #include <linux/kprobes.h>
17695  #include <linux/user_namespace.h>
17696 +#include <linux/vs_pid.h>
17697  
17698  #include <asm/uaccess.h>
17699  #include <asm/io.h>
17700 @@ -129,7 +130,10 @@ static int set_one_prio(struct task_stru
17701                 goto out;
17702         }
17703         if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17704 -               error = -EACCES;
17705 +               if (vx_flags(VXF_IGNEG_NICE, 0))
17706 +                       error = 0;
17707 +               else
17708 +                       error = -EACCES;
17709                 goto out;
17710         }
17711         no_nice = security_task_setnice(p, niceval);
17712 @@ -179,6 +183,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17713                         else
17714                                 pgrp = task_pgrp(current);
17715                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17716 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17717 +                                       continue;
17718                                 error = set_one_prio(p, niceval, error);
17719                         } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17720                         break;
17721 @@ -242,6 +248,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17722                         else
17723                                 pgrp = task_pgrp(current);
17724                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17725 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17726 +                                       continue;
17727                                 niceval = 20 - task_nice(p);
17728                                 if (niceval > retval)
17729                                         retval = niceval;
17730 @@ -355,6 +363,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
17731  
17732  static DEFINE_MUTEX(reboot_mutex);
17733  
17734 +long vs_reboot(unsigned int, void __user *);
17735 +
17736  /*
17737   * Reboot system call: for obvious reasons only root may call it,
17738   * and even root needs to set up some magic numbers in the registers
17739 @@ -387,6 +397,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17740         if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17741                 cmd = LINUX_REBOOT_CMD_HALT;
17742  
17743 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
17744 +               return vs_reboot(cmd, arg);
17745 +
17746         mutex_lock(&reboot_mutex);
17747         switch (cmd) {
17748         case LINUX_REBOOT_CMD_RESTART:
17749 @@ -1136,7 +1149,7 @@ SYSCALL_DEFINE2(sethostname, char __user
17750         int errno;
17751         char tmp[__NEW_UTS_LEN];
17752  
17753 -       if (!capable(CAP_SYS_ADMIN))
17754 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17755                 return -EPERM;
17756         if (len < 0 || len > __NEW_UTS_LEN)
17757                 return -EINVAL;
17758 @@ -1185,7 +1198,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
17759         int errno;
17760         char tmp[__NEW_UTS_LEN];
17761  
17762 -       if (!capable(CAP_SYS_ADMIN))
17763 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17764                 return -EPERM;
17765         if (len < 0 || len > __NEW_UTS_LEN)
17766                 return -EINVAL;
17767 @@ -1254,7 +1267,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
17768                 return -EINVAL;
17769         old_rlim = current->signal->rlim + resource;
17770         if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17771 -           !capable(CAP_SYS_RESOURCE))
17772 +           !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17773                 return -EPERM;
17774         if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
17775                 return -EPERM;
17776 diff -NurpP --minimal linux-2.6.33.2/kernel/sysctl_binary.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/sysctl_binary.c
17777 --- linux-2.6.33.2/kernel/sysctl_binary.c       2010-02-25 11:52:09.000000000 +0100
17778 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/sysctl_binary.c       2010-02-25 12:40:06.000000000 +0100
17779 @@ -71,6 +71,7 @@ static const struct bin_table bin_kern_t
17780  
17781         { CTL_INT,      KERN_PANIC,                     "panic" },
17782         { CTL_INT,      KERN_REALROOTDEV,               "real-root-dev" },
17783 +       { CTL_STR,      KERN_VSHELPER,                  "vshelper" },
17784  
17785         { CTL_STR,      KERN_SPARC_REBOOT,              "reboot-cmd" },
17786         { CTL_INT,      KERN_CTLALTDEL,                 "ctrl-alt-del" },
17787 diff -NurpP --minimal linux-2.6.33.2/kernel/sysctl.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/sysctl.c
17788 --- linux-2.6.33.2/kernel/sysctl.c      2010-02-25 11:52:09.000000000 +0100
17789 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/sysctl.c      2010-02-25 14:43:48.000000000 +0100
17790 @@ -123,6 +123,7 @@ static int ngroups_max = NGROUPS_MAX;
17791  extern char modprobe_path[];
17792  extern int modules_disabled;
17793  #endif
17794 +extern char vshelper_path[];
17795  #ifdef CONFIG_CHR_DEV_SG
17796  extern int sg_big_buff;
17797  #endif
17798 @@ -553,6 +554,13 @@ static struct ctl_table kern_table[] = {
17799                 .proc_handler   = proc_dostring,
17800         },
17801  #endif
17802 +       {
17803 +               .procname       = "vshelper",
17804 +               .data           = &vshelper_path,
17805 +               .maxlen         = 256,
17806 +               .mode           = 0644,
17807 +               .proc_handler   = &proc_dostring,
17808 +       },
17809  #ifdef CONFIG_CHR_DEV_SG
17810         {
17811                 .procname       = "sg-big-buff",
17812 diff -NurpP --minimal linux-2.6.33.2/kernel/time.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/time.c
17813 --- linux-2.6.33.2/kernel/time.c        2010-02-25 11:52:09.000000000 +0100
17814 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/time.c        2010-02-25 12:02:16.000000000 +0100
17815 @@ -63,6 +63,7 @@ EXPORT_SYMBOL(sys_tz);
17816  SYSCALL_DEFINE1(time, time_t __user *, tloc)
17817  {
17818         time_t i = get_seconds();
17819 +/*     FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17820  
17821         if (tloc) {
17822                 if (put_user(i,tloc))
17823 @@ -93,7 +94,7 @@ SYSCALL_DEFINE1(stime, time_t __user *, 
17824         if (err)
17825                 return err;
17826  
17827 -       do_settimeofday(&tv);
17828 +       vx_settimeofday(&tv);
17829         return 0;
17830  }
17831  
17832 @@ -104,7 +105,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
17833  {
17834         if (likely(tv != NULL)) {
17835                 struct timeval ktv;
17836 -               do_gettimeofday(&ktv);
17837 +               vx_gettimeofday(&ktv);
17838                 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17839                         return -EFAULT;
17840         }
17841 @@ -179,7 +180,7 @@ int do_sys_settimeofday(struct timespec 
17842                 /* SMP safe, again the code in arch/foo/time.c should
17843                  * globally block out interrupts when it runs.
17844                  */
17845 -               return do_settimeofday(tv);
17846 +               return vx_settimeofday(tv);
17847         }
17848         return 0;
17849  }
17850 @@ -311,7 +312,7 @@ void getnstimeofday(struct timespec *tv)
17851  {
17852         struct timeval x;
17853  
17854 -       do_gettimeofday(&x);
17855 +       vx_gettimeofday(&x);
17856         tv->tv_sec = x.tv_sec;
17857         tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17858  }
17859 diff -NurpP --minimal linux-2.6.33.2/kernel/timer.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/timer.c
17860 --- linux-2.6.33.2/kernel/timer.c       2010-02-25 11:52:09.000000000 +0100
17861 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/timer.c       2010-02-25 12:02:16.000000000 +0100
17862 @@ -39,6 +39,10 @@
17863  #include <linux/kallsyms.h>
17864  #include <linux/perf_event.h>
17865  #include <linux/sched.h>
17866 +#include <linux/vs_base.h>
17867 +#include <linux/vs_cvirt.h>
17868 +#include <linux/vs_pid.h>
17869 +#include <linux/vserver/sched.h>
17870  
17871  #include <asm/uaccess.h>
17872  #include <asm/unistd.h>
17873 @@ -1252,12 +1256,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17874  
17875  #endif
17876  
17877 -#ifndef __alpha__
17878 -
17879 -/*
17880 - * The Alpha uses getxpid, getxuid, and getxgid instead.  Maybe this
17881 - * should be moved into arch/i386 instead?
17882 - */
17883  
17884  /**
17885   * sys_getpid - return the thread group id of the current process
17886 @@ -1286,10 +1284,23 @@ SYSCALL_DEFINE0(getppid)
17887         rcu_read_lock();
17888         pid = task_tgid_vnr(current->real_parent);
17889         rcu_read_unlock();
17890 +       return vx_map_pid(pid);
17891 +}
17892  
17893 -       return pid;
17894 +#ifdef __alpha__
17895 +
17896 +/*
17897 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17898 + */
17899 +
17900 +asmlinkage long do_getxpid(long *ppid)
17901 +{
17902 +       *ppid = sys_getppid();
17903 +       return sys_getpid();
17904  }
17905  
17906 +#else /* _alpha_ */
17907 +
17908  SYSCALL_DEFINE0(getuid)
17909  {
17910         /* Only we change this so SMP safe */
17911 diff -NurpP --minimal linux-2.6.33.2/kernel/user.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/user.c
17912 --- linux-2.6.33.2/kernel/user.c        2009-12-03 20:02:58.000000000 +0100
17913 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/user.c        2010-02-25 12:02:16.000000000 +0100
17914 @@ -251,10 +251,10 @@ static struct kobj_type uids_ktype = {
17915   *
17916   * See Documentation/scheduler/sched-design-CFS.txt for ramifications.
17917   */
17918 -static int uids_user_create(struct user_struct *up)
17919 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
17920  {
17921         struct kobject *kobj = &up->kobj;
17922 -       int error;
17923 +       int error = 0;
17924  
17925         memset(kobj, 0, sizeof(struct kobject));
17926         if (up->user_ns != &init_user_ns)
17927 @@ -282,7 +282,7 @@ int __init uids_sysfs_init(void)
17928         if (!uids_kset)
17929                 return -ENOMEM;
17930  
17931 -       return uids_user_create(&root_user);
17932 +       return uids_user_create(NULL, &root_user);
17933  }
17934  
17935  /* delayed work function to remove sysfs directory for a user and free up
17936 @@ -353,7 +353,8 @@ static struct user_struct *uid_hash_find
17937  }
17938  
17939  int uids_sysfs_init(void) { return 0; }
17940 -static inline int uids_user_create(struct user_struct *up) { return 0; }
17941 +static inline int uids_user_create(struct user_namespace *ns,
17942 +       struct user_struct *up) { return 0; }
17943  static inline void uids_mutex_lock(void) { }
17944  static inline void uids_mutex_unlock(void) { }
17945  
17946 @@ -450,7 +451,7 @@ struct user_struct *alloc_uid(struct use
17947  
17948                 new->user_ns = get_user_ns(ns);
17949  
17950 -               if (uids_user_create(new))
17951 +               if (uids_user_create(ns, new))
17952                         goto out_destoy_sched;
17953  
17954                 /*
17955 diff -NurpP --minimal linux-2.6.33.2/kernel/user_namespace.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/user_namespace.c
17956 --- linux-2.6.33.2/kernel/user_namespace.c      2009-03-24 14:22:45.000000000 +0100
17957 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/user_namespace.c      2010-02-25 12:02:16.000000000 +0100
17958 @@ -10,6 +10,7 @@
17959  #include <linux/slab.h>
17960  #include <linux/user_namespace.h>
17961  #include <linux/cred.h>
17962 +#include <linux/vserver/global.h>
17963  
17964  /*
17965   * Create a new user namespace, deriving the creator from the user in the
17966 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
17967                 return -ENOMEM;
17968  
17969         kref_init(&ns->kref);
17970 +       atomic_inc(&vs_global_user_ns);
17971  
17972         for (n = 0; n < UIDHASH_SZ; ++n)
17973                 INIT_HLIST_HEAD(ns->uidhash_table + n);
17974 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
17975         struct user_namespace *ns =
17976                 container_of(kref, struct user_namespace, kref);
17977  
17978 +       /* FIXME: maybe move into destroyer? */
17979 +       atomic_dec(&vs_global_user_ns);
17980         INIT_WORK(&ns->destroyer, free_user_ns_work);
17981         schedule_work(&ns->destroyer);
17982  }
17983 diff -NurpP --minimal linux-2.6.33.2/kernel/utsname.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/utsname.c
17984 --- linux-2.6.33.2/kernel/utsname.c     2009-09-10 15:26:28.000000000 +0200
17985 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/utsname.c     2010-02-25 12:02:16.000000000 +0100
17986 @@ -14,14 +14,17 @@
17987  #include <linux/utsname.h>
17988  #include <linux/err.h>
17989  #include <linux/slab.h>
17990 +#include <linux/vserver/global.h>
17991  
17992  static struct uts_namespace *create_uts_ns(void)
17993  {
17994         struct uts_namespace *uts_ns;
17995  
17996         uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17997 -       if (uts_ns)
17998 +       if (uts_ns) {
17999                 kref_init(&uts_ns->kref);
18000 +               atomic_inc(&vs_global_uts_ns);
18001 +       }
18002         return uts_ns;
18003  }
18004  
18005 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
18006         struct uts_namespace *ns;
18007  
18008         ns = container_of(kref, struct uts_namespace, kref);
18009 +       atomic_dec(&vs_global_uts_ns);
18010         kfree(ns);
18011  }
18012 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/cacct.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cacct.c
18013 --- linux-2.6.33.2/kernel/vserver/cacct.c       1970-01-01 01:00:00.000000000 +0100
18014 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cacct.c       2010-02-25 12:02:16.000000000 +0100
18015 @@ -0,0 +1,42 @@
18016 +/*
18017 + *  linux/kernel/vserver/cacct.c
18018 + *
18019 + *  Virtual Server: Context Accounting
18020 + *
18021 + *  Copyright (C) 2006-2007 Herbert Pötzl
18022 + *
18023 + *  V0.01  added accounting stats
18024 + *
18025 + */
18026 +
18027 +#include <linux/types.h>
18028 +#include <linux/vs_context.h>
18029 +#include <linux/vserver/cacct_cmd.h>
18030 +#include <linux/vserver/cacct_int.h>
18031 +
18032 +#include <asm/errno.h>
18033 +#include <asm/uaccess.h>
18034 +
18035 +
18036 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
18037 +{
18038 +       struct vcmd_sock_stat_v0 vc_data;
18039 +       int j, field;
18040 +
18041 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18042 +               return -EFAULT;
18043 +
18044 +       field = vc_data.field;
18045 +       if ((field < 0) || (field >= VXA_SOCK_SIZE))
18046 +               return -EINVAL;
18047 +
18048 +       for (j = 0; j < 3; j++) {
18049 +               vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
18050 +               vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
18051 +       }
18052 +
18053 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18054 +               return -EFAULT;
18055 +       return 0;
18056 +}
18057 +
18058 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/cacct_init.h linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cacct_init.h
18059 --- linux-2.6.33.2/kernel/vserver/cacct_init.h  1970-01-01 01:00:00.000000000 +0100
18060 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cacct_init.h  2010-02-25 12:02:16.000000000 +0100
18061 @@ -0,0 +1,25 @@
18062 +
18063 +
18064 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
18065 +{
18066 +       int i, j;
18067 +
18068 +
18069 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
18070 +               for (j = 0; j < 3; j++) {
18071 +                       atomic_long_set(&cacct->sock[i][j].count, 0);
18072 +                       atomic_long_set(&cacct->sock[i][j].total, 0);
18073 +               }
18074 +       }
18075 +       for (i = 0; i < 8; i++)
18076 +               atomic_set(&cacct->slab[i], 0);
18077 +       for (i = 0; i < 5; i++)
18078 +               for (j = 0; j < 4; j++)
18079 +                       atomic_set(&cacct->page[i][j], 0);
18080 +}
18081 +
18082 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
18083 +{
18084 +       return;
18085 +}
18086 +
18087 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/cacct_proc.h linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cacct_proc.h
18088 --- linux-2.6.33.2/kernel/vserver/cacct_proc.h  1970-01-01 01:00:00.000000000 +0100
18089 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cacct_proc.h  2010-02-25 12:02:16.000000000 +0100
18090 @@ -0,0 +1,53 @@
18091 +#ifndef _VX_CACCT_PROC_H
18092 +#define _VX_CACCT_PROC_H
18093 +
18094 +#include <linux/vserver/cacct_int.h>
18095 +
18096 +
18097 +#define VX_SOCKA_TOP   \
18098 +       "Type\t    recv #/bytes\t\t   send #/bytes\t\t    fail #/bytes\n"
18099 +
18100 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
18101 +{
18102 +       int i, j, length = 0;
18103 +       static char *type[VXA_SOCK_SIZE] = {
18104 +               "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
18105 +       };
18106 +
18107 +       length += sprintf(buffer + length, VX_SOCKA_TOP);
18108 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
18109 +               length += sprintf(buffer + length, "%s:", type[i]);
18110 +               for (j = 0; j < 3; j++) {
18111 +                       length += sprintf(buffer + length,
18112 +                               "\t%10lu/%-10lu",
18113 +                               vx_sock_count(cacct, i, j),
18114 +                               vx_sock_total(cacct, i, j));
18115 +               }
18116 +               buffer[length++] = '\n';
18117 +       }
18118 +
18119 +       length += sprintf(buffer + length, "\n");
18120 +       length += sprintf(buffer + length,
18121 +               "slab:\t %8u %8u %8u %8u\n",
18122 +               atomic_read(&cacct->slab[1]),
18123 +               atomic_read(&cacct->slab[4]),
18124 +               atomic_read(&cacct->slab[0]),
18125 +               atomic_read(&cacct->slab[2]));
18126 +
18127 +       length += sprintf(buffer + length, "\n");
18128 +       for (i = 0; i < 5; i++) {
18129 +               length += sprintf(buffer + length,
18130 +                       "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
18131 +                       atomic_read(&cacct->page[i][0]),
18132 +                       atomic_read(&cacct->page[i][1]),
18133 +                       atomic_read(&cacct->page[i][2]),
18134 +                       atomic_read(&cacct->page[i][3]),
18135 +                       atomic_read(&cacct->page[i][4]),
18136 +                       atomic_read(&cacct->page[i][5]),
18137 +                       atomic_read(&cacct->page[i][6]),
18138 +                       atomic_read(&cacct->page[i][7]));
18139 +       }
18140 +       return length;
18141 +}
18142 +
18143 +#endif /* _VX_CACCT_PROC_H */
18144 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/context.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/context.c
18145 --- linux-2.6.33.2/kernel/vserver/context.c     1970-01-01 01:00:00.000000000 +0100
18146 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/context.c     2010-03-10 20:35:53.000000000 +0100
18147 @@ -0,0 +1,1058 @@
18148 +/*
18149 + *  linux/kernel/vserver/context.c
18150 + *
18151 + *  Virtual Server: Context Support
18152 + *
18153 + *  Copyright (C) 2003-2007  Herbert Pötzl
18154 + *
18155 + *  V0.01  context helper
18156 + *  V0.02  vx_ctx_kill syscall command
18157 + *  V0.03  replaced context_info calls
18158 + *  V0.04  redesign of struct (de)alloc
18159 + *  V0.05  rlimit basic implementation
18160 + *  V0.06  task_xid and info commands
18161 + *  V0.07  context flags and caps
18162 + *  V0.08  switch to RCU based hash
18163 + *  V0.09  revert to non RCU for now
18164 + *  V0.10  and back to working RCU hash
18165 + *  V0.11  and back to locking again
18166 + *  V0.12  referenced context store
18167 + *  V0.13  separate per cpu data
18168 + *  V0.14  changed vcmds to vxi arg
18169 + *  V0.15  added context stat
18170 + *  V0.16  have __create claim() the vxi
18171 + *  V0.17  removed older and legacy stuff
18172 + *
18173 + */
18174 +
18175 +#include <linux/slab.h>
18176 +#include <linux/types.h>
18177 +#include <linux/security.h>
18178 +#include <linux/pid_namespace.h>
18179 +
18180 +#include <linux/vserver/context.h>
18181 +#include <linux/vserver/network.h>
18182 +#include <linux/vserver/debug.h>
18183 +#include <linux/vserver/limit.h>
18184 +#include <linux/vserver/limit_int.h>
18185 +#include <linux/vserver/space.h>
18186 +#include <linux/init_task.h>
18187 +#include <linux/fs_struct.h>
18188 +
18189 +#include <linux/vs_context.h>
18190 +#include <linux/vs_limit.h>
18191 +#include <linux/vs_pid.h>
18192 +#include <linux/vserver/context_cmd.h>
18193 +
18194 +#include "cvirt_init.h"
18195 +#include "cacct_init.h"
18196 +#include "limit_init.h"
18197 +#include "sched_init.h"
18198 +
18199 +
18200 +atomic_t vx_global_ctotal      = ATOMIC_INIT(0);
18201 +atomic_t vx_global_cactive     = ATOMIC_INIT(0);
18202 +
18203 +
18204 +/*     now inactive context structures */
18205 +
18206 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
18207 +
18208 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
18209 +
18210 +
18211 +/*     __alloc_vx_info()
18212 +
18213 +       * allocate an initialized vx_info struct
18214 +       * doesn't make it visible (hash)                        */
18215 +
18216 +static struct vx_info *__alloc_vx_info(xid_t xid)
18217 +{
18218 +       struct vx_info *new = NULL;
18219 +       int cpu, index;
18220 +
18221 +       vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
18222 +
18223 +       /* would this benefit from a slab cache? */
18224 +       new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
18225 +       if (!new)
18226 +               return 0;
18227 +
18228 +       memset(new, 0, sizeof(struct vx_info));
18229 +#ifdef CONFIG_SMP
18230 +       new->ptr_pc = alloc_percpu(struct _vx_info_pc);
18231 +       if (!new->ptr_pc)
18232 +               goto error;
18233 +#endif
18234 +       new->vx_id = xid;
18235 +       INIT_HLIST_NODE(&new->vx_hlist);
18236 +       atomic_set(&new->vx_usecnt, 0);
18237 +       atomic_set(&new->vx_tasks, 0);
18238 +       new->vx_parent = NULL;
18239 +       new->vx_state = 0;
18240 +       init_waitqueue_head(&new->vx_wait);
18241 +
18242 +       /* prepare reaper */
18243 +       get_task_struct(init_pid_ns.child_reaper);
18244 +       new->vx_reaper = init_pid_ns.child_reaper;
18245 +       new->vx_badness_bias = 0;
18246 +
18247 +       /* rest of init goes here */
18248 +       vx_info_init_limit(&new->limit);
18249 +       vx_info_init_sched(&new->sched);
18250 +       vx_info_init_cvirt(&new->cvirt);
18251 +       vx_info_init_cacct(&new->cacct);
18252 +
18253 +       /* per cpu data structures */
18254 +       for_each_possible_cpu(cpu) {
18255 +               vx_info_init_sched_pc(
18256 +                       &vx_per_cpu(new, sched_pc, cpu), cpu);
18257 +               vx_info_init_cvirt_pc(
18258 +                       &vx_per_cpu(new, cvirt_pc, cpu), cpu);
18259 +       }
18260 +
18261 +       new->vx_flags = VXF_INIT_SET;
18262 +       cap_set_init_eff(new->vx_bcaps);
18263 +       new->vx_ccaps = 0;
18264 +       new->vx_umask = 0;
18265 +
18266 +       new->reboot_cmd = 0;
18267 +       new->exit_code = 0;
18268 +
18269 +       // preconfig fs entries
18270 +       for (index = 0; index < VX_SPACES; index++) {
18271 +               write_lock(&init_fs.lock);
18272 +               init_fs.users++;
18273 +               write_unlock(&init_fs.lock);
18274 +               new->vx_fs[index] = &init_fs;
18275 +       }
18276 +
18277 +       vxdprintk(VXD_CBIT(xid, 0),
18278 +               "alloc_vx_info(%d) = %p", xid, new);
18279 +       vxh_alloc_vx_info(new);
18280 +       atomic_inc(&vx_global_ctotal);
18281 +       return new;
18282 +#ifdef CONFIG_SMP
18283 +error:
18284 +       kfree(new);
18285 +       return 0;
18286 +#endif
18287 +}
18288 +
18289 +/*     __dealloc_vx_info()
18290 +
18291 +       * final disposal of vx_info                             */
18292 +
18293 +static void __dealloc_vx_info(struct vx_info *vxi)
18294 +{
18295 +#ifdef CONFIG_VSERVER_WARN
18296 +       struct vx_info_save vxis;
18297 +       int cpu;
18298 +#endif
18299 +       vxdprintk(VXD_CBIT(xid, 0),
18300 +               "dealloc_vx_info(%p)", vxi);
18301 +       vxh_dealloc_vx_info(vxi);
18302 +
18303 +#ifdef CONFIG_VSERVER_WARN
18304 +       enter_vx_info(vxi, &vxis);
18305 +       vx_info_exit_limit(&vxi->limit);
18306 +       vx_info_exit_sched(&vxi->sched);
18307 +       vx_info_exit_cvirt(&vxi->cvirt);
18308 +       vx_info_exit_cacct(&vxi->cacct);
18309 +
18310 +       for_each_possible_cpu(cpu) {
18311 +               vx_info_exit_sched_pc(
18312 +                       &vx_per_cpu(vxi, sched_pc, cpu), cpu);
18313 +               vx_info_exit_cvirt_pc(
18314 +                       &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
18315 +       }
18316 +       leave_vx_info(&vxis);
18317 +#endif
18318 +
18319 +       vxi->vx_id = -1;
18320 +       vxi->vx_state |= VXS_RELEASED;
18321 +
18322 +#ifdef CONFIG_SMP
18323 +       free_percpu(vxi->ptr_pc);
18324 +#endif
18325 +       kfree(vxi);
18326 +       atomic_dec(&vx_global_ctotal);
18327 +}
18328 +
18329 +static void __shutdown_vx_info(struct vx_info *vxi)
18330 +{
18331 +       struct nsproxy *nsproxy;
18332 +       struct fs_struct *fs;
18333 +       int index, kill;
18334 +
18335 +       might_sleep();
18336 +
18337 +       vxi->vx_state |= VXS_SHUTDOWN;
18338 +       vs_state_change(vxi, VSC_SHUTDOWN);
18339 +
18340 +       for (index = 0; index < VX_SPACES; index++) {
18341 +               nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
18342 +               if (nsproxy)
18343 +                       put_nsproxy(nsproxy);
18344 +
18345 +               fs = xchg(&vxi->vx_fs[index], NULL);
18346 +               write_lock(&fs->lock);
18347 +               kill = !--fs->users;
18348 +               write_unlock(&fs->lock);
18349 +               if (kill)
18350 +                       free_fs_struct(fs);
18351 +       }
18352 +}
18353 +
18354 +/* exported stuff */
18355 +
18356 +void free_vx_info(struct vx_info *vxi)
18357 +{
18358 +       unsigned long flags;
18359 +       unsigned index;
18360 +
18361 +       /* check for reference counts first */
18362 +       BUG_ON(atomic_read(&vxi->vx_usecnt));
18363 +       BUG_ON(atomic_read(&vxi->vx_tasks));
18364 +
18365 +       /* context must not be hashed */
18366 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
18367 +
18368 +       /* context shutdown is mandatory */
18369 +       BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
18370 +
18371 +       /* nsproxy and fs check */
18372 +       for (index = 0; index < VX_SPACES; index++) {
18373 +               BUG_ON(vxi->vx_nsproxy[index]);
18374 +               BUG_ON(vxi->vx_fs[index]);
18375 +       }
18376 +
18377 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
18378 +       hlist_del(&vxi->vx_hlist);
18379 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18380 +
18381 +       __dealloc_vx_info(vxi);
18382 +}
18383 +
18384 +
18385 +/*     hash table for vx_info hash */
18386 +
18387 +#define VX_HASH_SIZE   13
18388 +
18389 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
18390 +       { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
18391 +
18392 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
18393 +
18394 +
18395 +static inline unsigned int __hashval(xid_t xid)
18396 +{
18397 +       return (xid % VX_HASH_SIZE);
18398 +}
18399 +
18400 +
18401 +
18402 +/*     __hash_vx_info()
18403 +
18404 +       * add the vxi to the global hash table
18405 +       * requires the hash_lock to be held                     */
18406 +
18407 +static inline void __hash_vx_info(struct vx_info *vxi)
18408 +{
18409 +       struct hlist_head *head;
18410 +
18411 +       vxd_assert_lock(&vx_info_hash_lock);
18412 +       vxdprintk(VXD_CBIT(xid, 4),
18413 +               "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
18414 +       vxh_hash_vx_info(vxi);
18415 +
18416 +       /* context must not be hashed */
18417 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
18418 +
18419 +       vxi->vx_state |= VXS_HASHED;
18420 +       head = &vx_info_hash[__hashval(vxi->vx_id)];
18421 +       hlist_add_head(&vxi->vx_hlist, head);
18422 +       atomic_inc(&vx_global_cactive);
18423 +}
18424 +
18425 +/*     __unhash_vx_info()
18426 +
18427 +       * remove the vxi from the global hash table
18428 +       * requires the hash_lock to be held                     */
18429 +
18430 +static inline void __unhash_vx_info(struct vx_info *vxi)
18431 +{
18432 +       unsigned long flags;
18433 +
18434 +       vxd_assert_lock(&vx_info_hash_lock);
18435 +       vxdprintk(VXD_CBIT(xid, 4),
18436 +               "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
18437 +               atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
18438 +       vxh_unhash_vx_info(vxi);
18439 +
18440 +       /* context must be hashed */
18441 +       BUG_ON(!vx_info_state(vxi, VXS_HASHED));
18442 +       /* but without tasks */
18443 +       BUG_ON(atomic_read(&vxi->vx_tasks));
18444 +
18445 +       vxi->vx_state &= ~VXS_HASHED;
18446 +       hlist_del_init(&vxi->vx_hlist);
18447 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
18448 +       hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
18449 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18450 +       atomic_dec(&vx_global_cactive);
18451 +}
18452 +
18453 +
18454 +/*     __lookup_vx_info()
18455 +
18456 +       * requires the hash_lock to be held
18457 +       * doesn't increment the vx_refcnt                       */
18458 +
18459 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
18460 +{
18461 +       struct hlist_head *head = &vx_info_hash[__hashval(xid)];
18462 +       struct hlist_node *pos;
18463 +       struct vx_info *vxi;
18464 +
18465 +       vxd_assert_lock(&vx_info_hash_lock);
18466 +       hlist_for_each(pos, head) {
18467 +               vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18468 +
18469 +               if (vxi->vx_id == xid)
18470 +                       goto found;
18471 +       }
18472 +       vxi = NULL;
18473 +found:
18474 +       vxdprintk(VXD_CBIT(xid, 0),
18475 +               "__lookup_vx_info(#%u): %p[#%u]",
18476 +               xid, vxi, vxi ? vxi->vx_id : 0);
18477 +       vxh_lookup_vx_info(vxi, xid);
18478 +       return vxi;
18479 +}
18480 +
18481 +
18482 +/*     __create_vx_info()
18483 +
18484 +       * create the requested context
18485 +       * get(), claim() and hash it                            */
18486 +
18487 +static struct vx_info *__create_vx_info(int id)
18488 +{
18489 +       struct vx_info *new, *vxi = NULL;
18490 +
18491 +       vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
18492 +
18493 +       if (!(new = __alloc_vx_info(id)))
18494 +               return ERR_PTR(-ENOMEM);
18495 +
18496 +       /* required to make dynamic xids unique */
18497 +       spin_lock(&vx_info_hash_lock);
18498 +
18499 +       /* static context requested */
18500 +       if ((vxi = __lookup_vx_info(id))) {
18501 +               vxdprintk(VXD_CBIT(xid, 0),
18502 +                       "create_vx_info(%d) = %p (already there)", id, vxi);
18503 +               if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18504 +                       vxi = ERR_PTR(-EBUSY);
18505 +               else
18506 +                       vxi = ERR_PTR(-EEXIST);
18507 +               goto out_unlock;
18508 +       }
18509 +       /* new context */
18510 +       vxdprintk(VXD_CBIT(xid, 0),
18511 +               "create_vx_info(%d) = %p (new)", id, new);
18512 +       claim_vx_info(new, NULL);
18513 +       __hash_vx_info(get_vx_info(new));
18514 +       vxi = new, new = NULL;
18515 +
18516 +out_unlock:
18517 +       spin_unlock(&vx_info_hash_lock);
18518 +       vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18519 +       if (new)
18520 +               __dealloc_vx_info(new);
18521 +       return vxi;
18522 +}
18523 +
18524 +
18525 +/*     exported stuff                                          */
18526 +
18527 +
18528 +void unhash_vx_info(struct vx_info *vxi)
18529 +{
18530 +       __shutdown_vx_info(vxi);
18531 +       spin_lock(&vx_info_hash_lock);
18532 +       __unhash_vx_info(vxi);
18533 +       spin_unlock(&vx_info_hash_lock);
18534 +       __wakeup_vx_info(vxi);
18535 +}
18536 +
18537 +
18538 +/*     lookup_vx_info()
18539 +
18540 +       * search for a vx_info and get() it
18541 +       * negative id means current                             */
18542 +
18543 +struct vx_info *lookup_vx_info(int id)
18544 +{
18545 +       struct vx_info *vxi = NULL;
18546 +
18547 +       if (id < 0) {
18548 +               vxi = get_vx_info(current_vx_info());
18549 +       } else if (id > 1) {
18550 +               spin_lock(&vx_info_hash_lock);
18551 +               vxi = get_vx_info(__lookup_vx_info(id));
18552 +               spin_unlock(&vx_info_hash_lock);
18553 +       }
18554 +       return vxi;
18555 +}
18556 +
18557 +/*     xid_is_hashed()
18558 +
18559 +       * verify that xid is still hashed                       */
18560 +
18561 +int xid_is_hashed(xid_t xid)
18562 +{
18563 +       int hashed;
18564 +
18565 +       spin_lock(&vx_info_hash_lock);
18566 +       hashed = (__lookup_vx_info(xid) != NULL);
18567 +       spin_unlock(&vx_info_hash_lock);
18568 +       return hashed;
18569 +}
18570 +
18571 +#ifdef CONFIG_PROC_FS
18572 +
18573 +/*     get_xid_list()
18574 +
18575 +       * get a subset of hashed xids for proc
18576 +       * assumes size is at least one                          */
18577 +
18578 +int get_xid_list(int index, unsigned int *xids, int size)
18579 +{
18580 +       int hindex, nr_xids = 0;
18581 +
18582 +       /* only show current and children */
18583 +       if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18584 +               if (index > 0)
18585 +                       return 0;
18586 +               xids[nr_xids] = vx_current_xid();
18587 +               return 1;
18588 +       }
18589 +
18590 +       for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18591 +               struct hlist_head *head = &vx_info_hash[hindex];
18592 +               struct hlist_node *pos;
18593 +
18594 +               spin_lock(&vx_info_hash_lock);
18595 +               hlist_for_each(pos, head) {
18596 +                       struct vx_info *vxi;
18597 +
18598 +                       if (--index > 0)
18599 +                               continue;
18600 +
18601 +                       vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18602 +                       xids[nr_xids] = vxi->vx_id;
18603 +                       if (++nr_xids >= size) {
18604 +                               spin_unlock(&vx_info_hash_lock);
18605 +                               goto out;
18606 +                       }
18607 +               }
18608 +               /* keep the lock time short */
18609 +               spin_unlock(&vx_info_hash_lock);
18610 +       }
18611 +out:
18612 +       return nr_xids;
18613 +}
18614 +#endif
18615 +
18616 +#ifdef CONFIG_VSERVER_DEBUG
18617 +
18618 +void   dump_vx_info_inactive(int level)
18619 +{
18620 +       struct hlist_node *entry, *next;
18621 +
18622 +       hlist_for_each_safe(entry, next, &vx_info_inactive) {
18623 +               struct vx_info *vxi =
18624 +                       list_entry(entry, struct vx_info, vx_hlist);
18625 +
18626 +               dump_vx_info(vxi, level);
18627 +       }
18628 +}
18629 +
18630 +#endif
18631 +
18632 +#if 0
18633 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18634 +{
18635 +       struct user_struct *new_user, *old_user;
18636 +
18637 +       if (!p || !vxi)
18638 +               BUG();
18639 +
18640 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18641 +               return -EACCES;
18642 +
18643 +       new_user = alloc_uid(vxi->vx_id, p->uid);
18644 +       if (!new_user)
18645 +               return -ENOMEM;
18646 +
18647 +       old_user = p->user;
18648 +       if (new_user != old_user) {
18649 +               atomic_inc(&new_user->processes);
18650 +               atomic_dec(&old_user->processes);
18651 +               p->user = new_user;
18652 +       }
18653 +       free_uid(old_user);
18654 +       return 0;
18655 +}
18656 +#endif
18657 +
18658 +#if 0
18659 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18660 +{
18661 +       // p->cap_effective &= vxi->vx_cap_bset;
18662 +       p->cap_effective =
18663 +               cap_intersect(p->cap_effective, vxi->cap_bset);
18664 +       // p->cap_inheritable &= vxi->vx_cap_bset;
18665 +       p->cap_inheritable =
18666 +               cap_intersect(p->cap_inheritable, vxi->cap_bset);
18667 +       // p->cap_permitted &= vxi->vx_cap_bset;
18668 +       p->cap_permitted =
18669 +               cap_intersect(p->cap_permitted, vxi->cap_bset);
18670 +}
18671 +#endif
18672 +
18673 +
18674 +#include <linux/file.h>
18675 +#include <linux/fdtable.h>
18676 +
18677 +static int vx_openfd_task(struct task_struct *tsk)
18678 +{
18679 +       struct files_struct *files = tsk->files;
18680 +       struct fdtable *fdt;
18681 +       const unsigned long *bptr;
18682 +       int count, total;
18683 +
18684 +       /* no rcu_read_lock() because of spin_lock() */
18685 +       spin_lock(&files->file_lock);
18686 +       fdt = files_fdtable(files);
18687 +       bptr = fdt->open_fds->fds_bits;
18688 +       count = fdt->max_fds / (sizeof(unsigned long) * 8);
18689 +       for (total = 0; count > 0; count--) {
18690 +               if (*bptr)
18691 +                       total += hweight_long(*bptr);
18692 +               bptr++;
18693 +       }
18694 +       spin_unlock(&files->file_lock);
18695 +       return total;
18696 +}
18697 +
18698 +
18699 +/*     for *space compatibility */
18700 +
18701 +asmlinkage long sys_unshare(unsigned long);
18702 +
18703 +/*
18704 + *     migrate task to new context
18705 + *     gets vxi, puts old_vxi on change
18706 + *     optionally unshares namespaces (hack)
18707 + */
18708 +
18709 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18710 +{
18711 +       struct vx_info *old_vxi;
18712 +       int ret = 0;
18713 +
18714 +       if (!p || !vxi)
18715 +               BUG();
18716 +
18717 +       vxdprintk(VXD_CBIT(xid, 5),
18718 +               "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18719 +               vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18720 +
18721 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18722 +               !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18723 +               return -EACCES;
18724 +
18725 +       if (vx_info_state(vxi, VXS_SHUTDOWN))
18726 +               return -EFAULT;
18727 +
18728 +       old_vxi = task_get_vx_info(p);
18729 +       if (old_vxi == vxi)
18730 +               goto out;
18731 +
18732 +//     if (!(ret = vx_migrate_user(p, vxi))) {
18733 +       {
18734 +               int openfd;
18735 +
18736 +               task_lock(p);
18737 +               openfd = vx_openfd_task(p);
18738 +
18739 +               if (old_vxi) {
18740 +                       atomic_dec(&old_vxi->cvirt.nr_threads);
18741 +                       atomic_dec(&old_vxi->cvirt.nr_running);
18742 +                       __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18743 +                       /* FIXME: what about the struct files here? */
18744 +                       __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18745 +                       /* account for the executable */
18746 +                       __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18747 +               }
18748 +               atomic_inc(&vxi->cvirt.nr_threads);
18749 +               atomic_inc(&vxi->cvirt.nr_running);
18750 +               __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18751 +               /* FIXME: what about the struct files here? */
18752 +               __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18753 +               /* account for the executable */
18754 +               __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18755 +
18756 +               if (old_vxi) {
18757 +                       release_vx_info(old_vxi, p);
18758 +                       clr_vx_info(&p->vx_info);
18759 +               }
18760 +               claim_vx_info(vxi, p);
18761 +               set_vx_info(&p->vx_info, vxi);
18762 +               p->xid = vxi->vx_id;
18763 +
18764 +               vxdprintk(VXD_CBIT(xid, 5),
18765 +                       "moved task %p into vxi:%p[#%d]",
18766 +                       p, vxi, vxi->vx_id);
18767 +
18768 +               // vx_mask_cap_bset(vxi, p);
18769 +               task_unlock(p);
18770 +
18771 +               /* hack for *spaces to provide compatibility */
18772 +               if (unshare) {
18773 +                       struct nsproxy *old_nsp, *new_nsp;
18774 +
18775 +                       ret = unshare_nsproxy_namespaces(
18776 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18777 +                               &new_nsp, NULL);
18778 +                       if (ret)
18779 +                               goto out;
18780 +
18781 +                       old_nsp = xchg(&p->nsproxy, new_nsp);
18782 +                       vx_set_space(vxi,
18783 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18784 +                       put_nsproxy(old_nsp);
18785 +               }
18786 +       }
18787 +out:
18788 +       put_vx_info(old_vxi);
18789 +       return ret;
18790 +}
18791 +
18792 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18793 +{
18794 +       struct task_struct *old_reaper;
18795 +
18796 +       if (!vxi)
18797 +               return -EINVAL;
18798 +
18799 +       vxdprintk(VXD_CBIT(xid, 6),
18800 +               "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18801 +               vxi, vxi->vx_id, p, p->xid, p->pid);
18802 +
18803 +       old_reaper = vxi->vx_reaper;
18804 +       if (old_reaper == p)
18805 +               return 0;
18806 +
18807 +       /* set new child reaper */
18808 +       get_task_struct(p);
18809 +       vxi->vx_reaper = p;
18810 +       put_task_struct(old_reaper);
18811 +       return 0;
18812 +}
18813 +
18814 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18815 +{
18816 +       if (!vxi)
18817 +               return -EINVAL;
18818 +
18819 +       vxdprintk(VXD_CBIT(xid, 6),
18820 +               "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18821 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18822 +
18823 +       vxi->vx_flags &= ~VXF_STATE_INIT;
18824 +       // vxi->vx_initpid = p->tgid;
18825 +       vxi->vx_initpid = p->pid;
18826 +       return 0;
18827 +}
18828 +
18829 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18830 +{
18831 +       vxdprintk(VXD_CBIT(xid, 6),
18832 +               "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18833 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18834 +
18835 +       vxi->exit_code = code;
18836 +       vxi->vx_initpid = 0;
18837 +}
18838 +
18839 +
18840 +void vx_set_persistent(struct vx_info *vxi)
18841 +{
18842 +       vxdprintk(VXD_CBIT(xid, 6),
18843 +               "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18844 +
18845 +       get_vx_info(vxi);
18846 +       claim_vx_info(vxi, NULL);
18847 +}
18848 +
18849 +void vx_clear_persistent(struct vx_info *vxi)
18850 +{
18851 +       vxdprintk(VXD_CBIT(xid, 6),
18852 +               "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18853 +
18854 +       release_vx_info(vxi, NULL);
18855 +       put_vx_info(vxi);
18856 +}
18857 +
18858 +void vx_update_persistent(struct vx_info *vxi)
18859 +{
18860 +       if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18861 +               vx_set_persistent(vxi);
18862 +       else
18863 +               vx_clear_persistent(vxi);
18864 +}
18865 +
18866 +
18867 +/*     task must be current or locked          */
18868 +
18869 +void   exit_vx_info(struct task_struct *p, int code)
18870 +{
18871 +       struct vx_info *vxi = p->vx_info;
18872 +
18873 +       if (vxi) {
18874 +               atomic_dec(&vxi->cvirt.nr_threads);
18875 +               vx_nproc_dec(p);
18876 +
18877 +               vxi->exit_code = code;
18878 +               release_vx_info(vxi, p);
18879 +       }
18880 +}
18881 +
18882 +void   exit_vx_info_early(struct task_struct *p, int code)
18883 +{
18884 +       struct vx_info *vxi = p->vx_info;
18885 +
18886 +       if (vxi) {
18887 +               if (vxi->vx_initpid == p->pid)
18888 +                       vx_exit_init(vxi, p, code);
18889 +               if (vxi->vx_reaper == p)
18890 +                       vx_set_reaper(vxi, init_pid_ns.child_reaper);
18891 +       }
18892 +}
18893 +
18894 +
18895 +/* vserver syscall commands below here */
18896 +
18897 +/* taks xid and vx_info functions */
18898 +
18899 +#include <asm/uaccess.h>
18900 +
18901 +
18902 +int vc_task_xid(uint32_t id)
18903 +{
18904 +       xid_t xid;
18905 +
18906 +       if (id) {
18907 +               struct task_struct *tsk;
18908 +
18909 +               read_lock(&tasklist_lock);
18910 +               tsk = find_task_by_real_pid(id);
18911 +               xid = (tsk) ? tsk->xid : -ESRCH;
18912 +               read_unlock(&tasklist_lock);
18913 +       } else
18914 +               xid = vx_current_xid();
18915 +       return xid;
18916 +}
18917 +
18918 +
18919 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18920 +{
18921 +       struct vcmd_vx_info_v0 vc_data;
18922 +
18923 +       vc_data.xid = vxi->vx_id;
18924 +       vc_data.initpid = vxi->vx_initpid;
18925 +
18926 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18927 +               return -EFAULT;
18928 +       return 0;
18929 +}
18930 +
18931 +
18932 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18933 +{
18934 +       struct vcmd_ctx_stat_v0 vc_data;
18935 +
18936 +       vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18937 +       vc_data.tasks = atomic_read(&vxi->vx_tasks);
18938 +
18939 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18940 +               return -EFAULT;
18941 +       return 0;
18942 +}
18943 +
18944 +
18945 +/* context functions */
18946 +
18947 +int vc_ctx_create(uint32_t xid, void __user *data)
18948 +{
18949 +       struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18950 +       struct vx_info *new_vxi;
18951 +       int ret;
18952 +
18953 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18954 +               return -EFAULT;
18955 +
18956 +       if ((xid > MAX_S_CONTEXT) || (xid < 2))
18957 +               return -EINVAL;
18958 +
18959 +       new_vxi = __create_vx_info(xid);
18960 +       if (IS_ERR(new_vxi))
18961 +               return PTR_ERR(new_vxi);
18962 +
18963 +       /* initial flags */
18964 +       new_vxi->vx_flags = vc_data.flagword;
18965 +
18966 +       ret = -ENOEXEC;
18967 +       if (vs_state_change(new_vxi, VSC_STARTUP))
18968 +               goto out;
18969 +
18970 +       ret = vx_migrate_task(current, new_vxi, (!data));
18971 +       if (ret)
18972 +               goto out;
18973 +
18974 +       /* return context id on success */
18975 +       ret = new_vxi->vx_id;
18976 +
18977 +       /* get a reference for persistent contexts */
18978 +       if ((vc_data.flagword & VXF_PERSISTENT))
18979 +               vx_set_persistent(new_vxi);
18980 +out:
18981 +       release_vx_info(new_vxi, NULL);
18982 +       put_vx_info(new_vxi);
18983 +       return ret;
18984 +}
18985 +
18986 +
18987 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18988 +{
18989 +       struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18990 +       int ret;
18991 +
18992 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18993 +               return -EFAULT;
18994 +
18995 +       ret = vx_migrate_task(current, vxi, 0);
18996 +       if (ret)
18997 +               return ret;
18998 +       if (vc_data.flagword & VXM_SET_INIT)
18999 +               ret = vx_set_init(vxi, current);
19000 +       if (ret)
19001 +               return ret;
19002 +       if (vc_data.flagword & VXM_SET_REAPER)
19003 +               ret = vx_set_reaper(vxi, current);
19004 +       return ret;
19005 +}
19006 +
19007 +
19008 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
19009 +{
19010 +       struct vcmd_ctx_flags_v0 vc_data;
19011 +
19012 +       vc_data.flagword = vxi->vx_flags;
19013 +
19014 +       /* special STATE flag handling */
19015 +       vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
19016 +
19017 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19018 +               return -EFAULT;
19019 +       return 0;
19020 +}
19021 +
19022 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
19023 +{
19024 +       struct vcmd_ctx_flags_v0 vc_data;
19025 +       uint64_t mask, trigger;
19026 +
19027 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19028 +               return -EFAULT;
19029 +
19030 +       /* special STATE flag handling */
19031 +       mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
19032 +       trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
19033 +
19034 +       if (vxi == current_vx_info()) {
19035 +               /* if (trigger & VXF_STATE_SETUP)
19036 +                       vx_mask_cap_bset(vxi, current); */
19037 +               if (trigger & VXF_STATE_INIT) {
19038 +                       int ret;
19039 +
19040 +                       ret = vx_set_init(vxi, current);
19041 +                       if (ret)
19042 +                               return ret;
19043 +                       ret = vx_set_reaper(vxi, current);
19044 +                       if (ret)
19045 +                               return ret;
19046 +               }
19047 +       }
19048 +
19049 +       vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
19050 +               vc_data.flagword, mask);
19051 +       if (trigger & VXF_PERSISTENT)
19052 +               vx_update_persistent(vxi);
19053 +
19054 +       return 0;
19055 +}
19056 +
19057 +
19058 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
19059 +{
19060 +       uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
19061 +
19062 +       // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
19063 +       return v;
19064 +}
19065 +
19066 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
19067 +{
19068 +       kernel_cap_t c = __cap_empty_set;
19069 +
19070 +       c.cap[0] = v & 0xFFFFFFFF;
19071 +       c.cap[1] = (v >> 32) & 0xFFFFFFFF;
19072 +
19073 +       // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
19074 +       return c;
19075 +}
19076 +
19077 +
19078 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
19079 +{
19080 +       if (bcaps)
19081 +               *bcaps = caps_from_cap_t(vxi->vx_bcaps);
19082 +       if (ccaps)
19083 +               *ccaps = vxi->vx_ccaps;
19084 +
19085 +       return 0;
19086 +}
19087 +
19088 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
19089 +{
19090 +       struct vcmd_ctx_caps_v1 vc_data;
19091 +       int ret;
19092 +
19093 +       ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
19094 +       if (ret)
19095 +               return ret;
19096 +       vc_data.cmask = ~0ULL;
19097 +
19098 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19099 +               return -EFAULT;
19100 +       return 0;
19101 +}
19102 +
19103 +static int do_set_caps(struct vx_info *vxi,
19104 +       uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
19105 +{
19106 +       uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
19107 +
19108 +#if 0
19109 +       printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
19110 +               bcaps, bmask, ccaps, cmask);
19111 +#endif
19112 +       vxi->vx_bcaps = cap_t_from_caps(
19113 +               vs_mask_flags(bcold, bcaps, bmask));
19114 +       vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
19115 +
19116 +       return 0;
19117 +}
19118 +
19119 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
19120 +{
19121 +       struct vcmd_ctx_caps_v1 vc_data;
19122 +
19123 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19124 +               return -EFAULT;
19125 +
19126 +       return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
19127 +}
19128 +
19129 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
19130 +{
19131 +       struct vcmd_bcaps vc_data;
19132 +       int ret;
19133 +
19134 +       ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
19135 +       if (ret)
19136 +               return ret;
19137 +       vc_data.bmask = ~0ULL;
19138 +
19139 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19140 +               return -EFAULT;
19141 +       return 0;
19142 +}
19143 +
19144 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
19145 +{
19146 +       struct vcmd_bcaps vc_data;
19147 +
19148 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19149 +               return -EFAULT;
19150 +
19151 +       return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
19152 +}
19153 +
19154 +
19155 +int vc_get_umask(struct vx_info *vxi, void __user *data)
19156 +{
19157 +       struct vcmd_umask vc_data;
19158 +
19159 +       vc_data.umask = vxi->vx_umask;
19160 +       vc_data.mask = ~0ULL;
19161 +
19162 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19163 +               return -EFAULT;
19164 +       return 0;
19165 +}
19166 +
19167 +int vc_set_umask(struct vx_info *vxi, void __user *data)
19168 +{
19169 +       struct vcmd_umask vc_data;
19170 +
19171 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19172 +               return -EFAULT;
19173 +
19174 +       vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
19175 +               vc_data.umask, vc_data.mask);
19176 +       return 0;
19177 +}
19178 +
19179 +
19180 +int vc_get_badness(struct vx_info *vxi, void __user *data)
19181 +{
19182 +       struct vcmd_badness_v0 vc_data;
19183 +
19184 +       vc_data.bias = vxi->vx_badness_bias;
19185 +
19186 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19187 +               return -EFAULT;
19188 +       return 0;
19189 +}
19190 +
19191 +int vc_set_badness(struct vx_info *vxi, void __user *data)
19192 +{
19193 +       struct vcmd_badness_v0 vc_data;
19194 +
19195 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19196 +               return -EFAULT;
19197 +
19198 +       vxi->vx_badness_bias = vc_data.bias;
19199 +       return 0;
19200 +}
19201 +
19202 +#include <linux/module.h>
19203 +
19204 +EXPORT_SYMBOL_GPL(free_vx_info);
19205 +
19206 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/cvirt.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cvirt.c
19207 --- linux-2.6.33.2/kernel/vserver/cvirt.c       1970-01-01 01:00:00.000000000 +0100
19208 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cvirt.c       2010-02-25 12:02:16.000000000 +0100
19209 @@ -0,0 +1,304 @@
19210 +/*
19211 + *  linux/kernel/vserver/cvirt.c
19212 + *
19213 + *  Virtual Server: Context Virtualization
19214 + *
19215 + *  Copyright (C) 2004-2007  Herbert Pötzl
19216 + *
19217 + *  V0.01  broken out from limit.c
19218 + *  V0.02  added utsname stuff
19219 + *  V0.03  changed vcmds to vxi arg
19220 + *
19221 + */
19222 +
19223 +#include <linux/types.h>
19224 +#include <linux/utsname.h>
19225 +#include <linux/vs_cvirt.h>
19226 +#include <linux/vserver/switch.h>
19227 +#include <linux/vserver/cvirt_cmd.h>
19228 +
19229 +#include <asm/uaccess.h>
19230 +
19231 +
19232 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
19233 +{
19234 +       struct vx_info *vxi = current_vx_info();
19235 +
19236 +       set_normalized_timespec(uptime,
19237 +               uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
19238 +               uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
19239 +       if (!idle)
19240 +               return;
19241 +       set_normalized_timespec(idle,
19242 +               idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
19243 +               idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
19244 +       return;
19245 +}
19246 +
19247 +uint64_t vx_idle_jiffies(void)
19248 +{
19249 +       return init_task.utime + init_task.stime;
19250 +}
19251 +
19252 +
19253 +
19254 +static inline uint32_t __update_loadavg(uint32_t load,
19255 +       int wsize, int delta, int n)
19256 +{
19257 +       unsigned long long calc, prev;
19258 +
19259 +       /* just set it to n */
19260 +       if (unlikely(delta >= wsize))
19261 +               return (n << FSHIFT);
19262 +
19263 +       calc = delta * n;
19264 +       calc <<= FSHIFT;
19265 +       prev = (wsize - delta);
19266 +       prev *= load;
19267 +       calc += prev;
19268 +       do_div(calc, wsize);
19269 +       return calc;
19270 +}
19271 +
19272 +
19273 +void vx_update_load(struct vx_info *vxi)
19274 +{
19275 +       uint32_t now, last, delta;
19276 +       unsigned int nr_running, nr_uninterruptible;
19277 +       unsigned int total;
19278 +       unsigned long flags;
19279 +
19280 +       spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
19281 +
19282 +       now = jiffies;
19283 +       last = vxi->cvirt.load_last;
19284 +       delta = now - last;
19285 +
19286 +       if (delta < 5*HZ)
19287 +               goto out;
19288 +
19289 +       nr_running = atomic_read(&vxi->cvirt.nr_running);
19290 +       nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
19291 +       total = nr_running + nr_uninterruptible;
19292 +
19293 +       vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
19294 +               60*HZ, delta, total);
19295 +       vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
19296 +               5*60*HZ, delta, total);
19297 +       vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
19298 +               15*60*HZ, delta, total);
19299 +
19300 +       vxi->cvirt.load_last = now;
19301 +out:
19302 +       atomic_inc(&vxi->cvirt.load_updates);
19303 +       spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
19304 +}
19305 +
19306 +
19307 +/*
19308 + * Commands to do_syslog:
19309 + *
19310 + *      0 -- Close the log.  Currently a NOP.
19311 + *      1 -- Open the log. Currently a NOP.
19312 + *      2 -- Read from the log.
19313 + *      3 -- Read all messages remaining in the ring buffer.
19314 + *      4 -- Read and clear all messages remaining in the ring buffer
19315 + *      5 -- Clear ring buffer.
19316 + *      6 -- Disable printk's to console
19317 + *      7 -- Enable printk's to console
19318 + *      8 -- Set level of messages printed to console
19319 + *      9 -- Return number of unread characters in the log buffer
19320 + *     10 -- Return size of the log buffer
19321 + */
19322 +int vx_do_syslog(int type, char __user *buf, int len)
19323 +{
19324 +       int error = 0;
19325 +       int do_clear = 0;
19326 +       struct vx_info *vxi = current_vx_info();
19327 +       struct _vx_syslog *log;
19328 +
19329 +       if (!vxi)
19330 +               return -EINVAL;
19331 +       log = &vxi->cvirt.syslog;
19332 +
19333 +       switch (type) {
19334 +       case 0:         /* Close log */
19335 +       case 1:         /* Open log */
19336 +               break;
19337 +       case 2:         /* Read from log */
19338 +               error = wait_event_interruptible(log->log_wait,
19339 +                       (log->log_start - log->log_end));
19340 +               if (error)
19341 +                       break;
19342 +               spin_lock_irq(&log->logbuf_lock);
19343 +               spin_unlock_irq(&log->logbuf_lock);
19344 +               break;
19345 +       case 4:         /* Read/clear last kernel messages */
19346 +               do_clear = 1;
19347 +               /* fall through */
19348 +       case 3:         /* Read last kernel messages */
19349 +               return 0;
19350 +
19351 +       case 5:         /* Clear ring buffer */
19352 +               return 0;
19353 +
19354 +       case 6:         /* Disable logging to console */
19355 +       case 7:         /* Enable logging to console */
19356 +       case 8:         /* Set level of messages printed to console */
19357 +               break;
19358 +
19359 +       case 9:         /* Number of chars in the log buffer */
19360 +               return 0;
19361 +       case 10:        /* Size of the log buffer */
19362 +               return 0;
19363 +       default:
19364 +               error = -EINVAL;
19365 +               break;
19366 +       }
19367 +       return error;
19368 +}
19369 +
19370 +
19371 +/* virtual host info names */
19372 +
19373 +static char *vx_vhi_name(struct vx_info *vxi, int id)
19374 +{
19375 +       struct nsproxy *nsproxy;
19376 +       struct uts_namespace *uts;
19377 +
19378 +       if (id == VHIN_CONTEXT)
19379 +               return vxi->vx_name;
19380 +
19381 +       nsproxy = vxi->vx_nsproxy[0];
19382 +       if (!nsproxy)
19383 +               return NULL;
19384 +
19385 +       uts = nsproxy->uts_ns;
19386 +       if (!uts)
19387 +               return NULL;
19388 +
19389 +       switch (id) {
19390 +       case VHIN_SYSNAME:
19391 +               return uts->name.sysname;
19392 +       case VHIN_NODENAME:
19393 +               return uts->name.nodename;
19394 +       case VHIN_RELEASE:
19395 +               return uts->name.release;
19396 +       case VHIN_VERSION:
19397 +               return uts->name.version;
19398 +       case VHIN_MACHINE:
19399 +               return uts->name.machine;
19400 +       case VHIN_DOMAINNAME:
19401 +               return uts->name.domainname;
19402 +       default:
19403 +               return NULL;
19404 +       }
19405 +       return NULL;
19406 +}
19407 +
19408 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
19409 +{
19410 +       struct vcmd_vhi_name_v0 vc_data;
19411 +       char *name;
19412 +
19413 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19414 +               return -EFAULT;
19415 +
19416 +       name = vx_vhi_name(vxi, vc_data.field);
19417 +       if (!name)
19418 +               return -EINVAL;
19419 +
19420 +       memcpy(name, vc_data.name, 65);
19421 +       return 0;
19422 +}
19423 +
19424 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
19425 +{
19426 +       struct vcmd_vhi_name_v0 vc_data;
19427 +       char *name;
19428 +
19429 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19430 +               return -EFAULT;
19431 +
19432 +       name = vx_vhi_name(vxi, vc_data.field);
19433 +       if (!name)
19434 +               return -EINVAL;
19435 +
19436 +       memcpy(vc_data.name, name, 65);
19437 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19438 +               return -EFAULT;
19439 +       return 0;
19440 +}
19441 +
19442 +
19443 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
19444 +{
19445 +       struct vcmd_virt_stat_v0 vc_data;
19446 +       struct _vx_cvirt *cvirt = &vxi->cvirt;
19447 +       struct timespec uptime;
19448 +
19449 +       do_posix_clock_monotonic_gettime(&uptime);
19450 +       set_normalized_timespec(&uptime,
19451 +               uptime.tv_sec - cvirt->bias_uptime.tv_sec,
19452 +               uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
19453 +
19454 +       vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
19455 +       vc_data.uptime = timespec_to_ns(&uptime);
19456 +       vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
19457 +       vc_data.nr_running = atomic_read(&cvirt->nr_running);
19458 +       vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
19459 +       vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
19460 +       vc_data.nr_forks = atomic_read(&cvirt->total_forks);
19461 +       vc_data.load[0] = cvirt->load[0];
19462 +       vc_data.load[1] = cvirt->load[1];
19463 +       vc_data.load[2] = cvirt->load[2];
19464 +
19465 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19466 +               return -EFAULT;
19467 +       return 0;
19468 +}
19469 +
19470 +
19471 +#ifdef CONFIG_VSERVER_VTIME
19472 +
19473 +/* virtualized time base */
19474 +
19475 +void vx_gettimeofday(struct timeval *tv)
19476 +{
19477 +       struct vx_info *vxi;
19478 +
19479 +       do_gettimeofday(tv);
19480 +       if (!vx_flags(VXF_VIRT_TIME, 0))
19481 +               return;
19482 +
19483 +       vxi = current_vx_info();
19484 +       tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
19485 +       tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
19486 +
19487 +       if (tv->tv_usec >= USEC_PER_SEC) {
19488 +               tv->tv_sec++;
19489 +               tv->tv_usec -= USEC_PER_SEC;
19490 +       } else if (tv->tv_usec < 0) {
19491 +               tv->tv_sec--;
19492 +               tv->tv_usec += USEC_PER_SEC;
19493 +       }
19494 +}
19495 +
19496 +int vx_settimeofday(struct timespec *ts)
19497 +{
19498 +       struct timeval tv;
19499 +       struct vx_info *vxi;
19500 +
19501 +       if (!vx_flags(VXF_VIRT_TIME, 0))
19502 +               return do_settimeofday(ts);
19503 +
19504 +       do_gettimeofday(&tv);
19505 +       vxi = current_vx_info();
19506 +       vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
19507 +       vxi->cvirt.bias_tv.tv_usec =
19508 +               (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
19509 +       return 0;
19510 +}
19511 +
19512 +#endif
19513 +
19514 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/cvirt_init.h linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cvirt_init.h
19515 --- linux-2.6.33.2/kernel/vserver/cvirt_init.h  1970-01-01 01:00:00.000000000 +0100
19516 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cvirt_init.h  2010-02-25 12:02:16.000000000 +0100
19517 @@ -0,0 +1,69 @@
19518 +
19519 +
19520 +extern uint64_t vx_idle_jiffies(void);
19521 +
19522 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19523 +{
19524 +       uint64_t idle_jiffies = vx_idle_jiffies();
19525 +       uint64_t nsuptime;
19526 +
19527 +       do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19528 +       nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19529 +               * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19530 +       cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19531 +       cvirt->bias_tv.tv_sec = 0;
19532 +       cvirt->bias_tv.tv_usec = 0;
19533 +
19534 +       jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19535 +       atomic_set(&cvirt->nr_threads, 0);
19536 +       atomic_set(&cvirt->nr_running, 0);
19537 +       atomic_set(&cvirt->nr_uninterruptible, 0);
19538 +       atomic_set(&cvirt->nr_onhold, 0);
19539 +
19540 +       spin_lock_init(&cvirt->load_lock);
19541 +       cvirt->load_last = jiffies;
19542 +       atomic_set(&cvirt->load_updates, 0);
19543 +       cvirt->load[0] = 0;
19544 +       cvirt->load[1] = 0;
19545 +       cvirt->load[2] = 0;
19546 +       atomic_set(&cvirt->total_forks, 0);
19547 +
19548 +       spin_lock_init(&cvirt->syslog.logbuf_lock);
19549 +       init_waitqueue_head(&cvirt->syslog.log_wait);
19550 +       cvirt->syslog.log_start = 0;
19551 +       cvirt->syslog.log_end = 0;
19552 +       cvirt->syslog.con_start = 0;
19553 +       cvirt->syslog.logged_chars = 0;
19554 +}
19555 +
19556 +static inline
19557 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19558 +{
19559 +       // cvirt_pc->cpustat = { 0 };
19560 +}
19561 +
19562 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19563 +{
19564 +       int value;
19565 +
19566 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19567 +               "!!! cvirt: %p[nr_threads] = %d on exit.",
19568 +               cvirt, value);
19569 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19570 +               "!!! cvirt: %p[nr_running] = %d on exit.",
19571 +               cvirt, value);
19572 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19573 +               "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19574 +               cvirt, value);
19575 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19576 +               "!!! cvirt: %p[nr_onhold] = %d on exit.",
19577 +               cvirt, value);
19578 +       return;
19579 +}
19580 +
19581 +static inline
19582 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19583 +{
19584 +       return;
19585 +}
19586 +
19587 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/cvirt_proc.h linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cvirt_proc.h
19588 --- linux-2.6.33.2/kernel/vserver/cvirt_proc.h  1970-01-01 01:00:00.000000000 +0100
19589 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/cvirt_proc.h  2010-02-25 12:02:16.000000000 +0100
19590 @@ -0,0 +1,135 @@
19591 +#ifndef _VX_CVIRT_PROC_H
19592 +#define _VX_CVIRT_PROC_H
19593 +
19594 +#include <linux/nsproxy.h>
19595 +#include <linux/mnt_namespace.h>
19596 +#include <linux/ipc_namespace.h>
19597 +#include <linux/utsname.h>
19598 +#include <linux/ipc.h>
19599 +
19600 +
19601 +static inline
19602 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19603 +{
19604 +       struct mnt_namespace *ns;
19605 +       struct uts_namespace *uts;
19606 +       struct ipc_namespace *ipc;
19607 +       struct path path;
19608 +       char *pstr, *root;
19609 +       int length = 0;
19610 +
19611 +       if (!nsproxy)
19612 +               goto out;
19613 +
19614 +       length += sprintf(buffer + length,
19615 +               "NSProxy:\t%p [%p,%p,%p]\n",
19616 +               nsproxy, nsproxy->mnt_ns,
19617 +               nsproxy->uts_ns, nsproxy->ipc_ns);
19618 +
19619 +       ns = nsproxy->mnt_ns;
19620 +       if (!ns)
19621 +               goto skip_ns;
19622 +
19623 +       pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19624 +       if (!pstr)
19625 +               goto skip_ns;
19626 +
19627 +       path.mnt = ns->root;
19628 +       path.dentry = ns->root->mnt_root;
19629 +       root = d_path(&path, pstr, PATH_MAX - 2);
19630 +       length += sprintf(buffer + length,
19631 +               "Namespace:\t%p [#%u]\n"
19632 +               "RootPath:\t%s\n",
19633 +               ns, atomic_read(&ns->count),
19634 +               root);
19635 +       kfree(pstr);
19636 +skip_ns:
19637 +
19638 +       uts = nsproxy->uts_ns;
19639 +       if (!uts)
19640 +               goto skip_uts;
19641 +
19642 +       length += sprintf(buffer + length,
19643 +               "SysName:\t%.*s\n"
19644 +               "NodeName:\t%.*s\n"
19645 +               "Release:\t%.*s\n"
19646 +               "Version:\t%.*s\n"
19647 +               "Machine:\t%.*s\n"
19648 +               "DomainName:\t%.*s\n",
19649 +               __NEW_UTS_LEN, uts->name.sysname,
19650 +               __NEW_UTS_LEN, uts->name.nodename,
19651 +               __NEW_UTS_LEN, uts->name.release,
19652 +               __NEW_UTS_LEN, uts->name.version,
19653 +               __NEW_UTS_LEN, uts->name.machine,
19654 +               __NEW_UTS_LEN, uts->name.domainname);
19655 +skip_uts:
19656 +
19657 +       ipc = nsproxy->ipc_ns;
19658 +       if (!ipc)
19659 +               goto skip_ipc;
19660 +
19661 +       length += sprintf(buffer + length,
19662 +               "SEMS:\t\t%d %d %d %d  %d\n"
19663 +               "MSG:\t\t%d %d %d\n"
19664 +               "SHM:\t\t%lu %lu  %d %d\n",
19665 +               ipc->sem_ctls[0], ipc->sem_ctls[1],
19666 +               ipc->sem_ctls[2], ipc->sem_ctls[3],
19667 +               ipc->used_sems,
19668 +               ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19669 +               (unsigned long)ipc->shm_ctlmax,
19670 +               (unsigned long)ipc->shm_ctlall,
19671 +               ipc->shm_ctlmni, ipc->shm_tot);
19672 +skip_ipc:
19673 +out:
19674 +       return length;
19675 +}
19676 +
19677 +
19678 +#include <linux/sched.h>
19679 +
19680 +#define LOAD_INT(x) ((x) >> FSHIFT)
19681 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19682 +
19683 +static inline
19684 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19685 +{
19686 +       int length = 0;
19687 +       int a, b, c;
19688 +
19689 +       length += sprintf(buffer + length,
19690 +               "BiasUptime:\t%lu.%02lu\n",
19691 +               (unsigned long)cvirt->bias_uptime.tv_sec,
19692 +               (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19693 +
19694 +       a = cvirt->load[0] + (FIXED_1 / 200);
19695 +       b = cvirt->load[1] + (FIXED_1 / 200);
19696 +       c = cvirt->load[2] + (FIXED_1 / 200);
19697 +       length += sprintf(buffer + length,
19698 +               "nr_threads:\t%d\n"
19699 +               "nr_running:\t%d\n"
19700 +               "nr_unintr:\t%d\n"
19701 +               "nr_onhold:\t%d\n"
19702 +               "load_updates:\t%d\n"
19703 +               "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19704 +               "total_forks:\t%d\n",
19705 +               atomic_read(&cvirt->nr_threads),
19706 +               atomic_read(&cvirt->nr_running),
19707 +               atomic_read(&cvirt->nr_uninterruptible),
19708 +               atomic_read(&cvirt->nr_onhold),
19709 +               atomic_read(&cvirt->load_updates),
19710 +               LOAD_INT(a), LOAD_FRAC(a),
19711 +               LOAD_INT(b), LOAD_FRAC(b),
19712 +               LOAD_INT(c), LOAD_FRAC(c),
19713 +               atomic_read(&cvirt->total_forks));
19714 +       return length;
19715 +}
19716 +
19717 +static inline
19718 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19719 +       char *buffer, int cpu)
19720 +{
19721 +       int length = 0;
19722 +       return length;
19723 +}
19724 +
19725 +#endif /* _VX_CVIRT_PROC_H */
19726 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/debug.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/debug.c
19727 --- linux-2.6.33.2/kernel/vserver/debug.c       1970-01-01 01:00:00.000000000 +0100
19728 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/debug.c       2010-02-25 12:02:16.000000000 +0100
19729 @@ -0,0 +1,32 @@
19730 +/*
19731 + *  kernel/vserver/debug.c
19732 + *
19733 + *  Copyright (C) 2005-2007 Herbert Pötzl
19734 + *
19735 + *  V0.01  vx_info dump support
19736 + *
19737 + */
19738 +
19739 +#include <linux/module.h>
19740 +
19741 +#include <linux/vserver/context.h>
19742 +
19743 +
19744 +void   dump_vx_info(struct vx_info *vxi, int level)
19745 +{
19746 +       printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19747 +               atomic_read(&vxi->vx_usecnt),
19748 +               atomic_read(&vxi->vx_tasks),
19749 +               vxi->vx_state);
19750 +       if (level > 0) {
19751 +               __dump_vx_limit(&vxi->limit);
19752 +               __dump_vx_sched(&vxi->sched);
19753 +               __dump_vx_cvirt(&vxi->cvirt);
19754 +               __dump_vx_cacct(&vxi->cacct);
19755 +       }
19756 +       printk("---\n");
19757 +}
19758 +
19759 +
19760 +EXPORT_SYMBOL_GPL(dump_vx_info);
19761 +
19762 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/device.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/device.c
19763 --- linux-2.6.33.2/kernel/vserver/device.c      1970-01-01 01:00:00.000000000 +0100
19764 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/device.c      2010-02-25 12:02:16.000000000 +0100
19765 @@ -0,0 +1,443 @@
19766 +/*
19767 + *  linux/kernel/vserver/device.c
19768 + *
19769 + *  Linux-VServer: Device Support
19770 + *
19771 + *  Copyright (C) 2006  Herbert Pötzl
19772 + *  Copyright (C) 2007  Daniel Hokka Zakrisson
19773 + *
19774 + *  V0.01  device mapping basics
19775 + *  V0.02  added defaults
19776 + *
19777 + */
19778 +
19779 +#include <linux/slab.h>
19780 +#include <linux/rcupdate.h>
19781 +#include <linux/fs.h>
19782 +#include <linux/namei.h>
19783 +#include <linux/hash.h>
19784 +
19785 +#include <asm/errno.h>
19786 +#include <asm/uaccess.h>
19787 +#include <linux/vserver/base.h>
19788 +#include <linux/vserver/debug.h>
19789 +#include <linux/vserver/context.h>
19790 +#include <linux/vserver/device.h>
19791 +#include <linux/vserver/device_cmd.h>
19792 +
19793 +
19794 +#define DMAP_HASH_BITS 4
19795 +
19796 +
19797 +struct vs_mapping {
19798 +       union {
19799 +               struct hlist_node hlist;
19800 +               struct list_head list;
19801 +       } u;
19802 +#define dm_hlist       u.hlist
19803 +#define dm_list                u.list
19804 +       xid_t xid;
19805 +       dev_t device;
19806 +       struct vx_dmap_target target;
19807 +};
19808 +
19809 +
19810 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19811 +
19812 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
19813 +
19814 +static struct vx_dmap_target dmap_defaults[2] = {
19815 +       { .flags = DATTR_OPEN },
19816 +       { .flags = DATTR_OPEN },
19817 +};
19818 +
19819 +
19820 +struct kmem_cache *dmap_cachep __read_mostly;
19821 +
19822 +int __init dmap_cache_init(void)
19823 +{
19824 +       dmap_cachep = kmem_cache_create("dmap_cache",
19825 +               sizeof(struct vs_mapping), 0,
19826 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19827 +       return 0;
19828 +}
19829 +
19830 +__initcall(dmap_cache_init);
19831 +
19832 +
19833 +static inline unsigned int __hashval(dev_t dev, int bits)
19834 +{
19835 +       return hash_long((unsigned long)dev, bits);
19836 +}
19837 +
19838 +
19839 +/*     __hash_mapping()
19840 + *     add the mapping to the hash table
19841 + */
19842 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19843 +{
19844 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19845 +       struct hlist_head *head, *hash = dmap_main_hash;
19846 +       int device = vdm->device;
19847 +
19848 +       spin_lock(hash_lock);
19849 +       vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19850 +               vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19851 +
19852 +       head = &hash[__hashval(device, DMAP_HASH_BITS)];
19853 +       hlist_add_head(&vdm->dm_hlist, head);
19854 +       spin_unlock(hash_lock);
19855 +}
19856 +
19857 +
19858 +static inline int __mode_to_default(umode_t mode)
19859 +{
19860 +       switch (mode) {
19861 +       case S_IFBLK:
19862 +               return 0;
19863 +       case S_IFCHR:
19864 +               return 1;
19865 +       default:
19866 +               BUG();
19867 +       }
19868 +}
19869 +
19870 +
19871 +/*     __set_default()
19872 + *     set a default
19873 + */
19874 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19875 +       struct vx_dmap_target *vdmt)
19876 +{
19877 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19878 +       spin_lock(hash_lock);
19879 +
19880 +       if (vxi)
19881 +               vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19882 +       else
19883 +               dmap_defaults[__mode_to_default(mode)] = *vdmt;
19884 +
19885 +
19886 +       spin_unlock(hash_lock);
19887 +
19888 +       vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19889 +                 vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19890 +}
19891 +
19892 +
19893 +/*     __remove_default()
19894 + *     remove a default
19895 + */
19896 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19897 +{
19898 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19899 +       spin_lock(hash_lock);
19900 +
19901 +       if (vxi)
19902 +               vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19903 +       else    /* remove == reset */
19904 +               dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19905 +
19906 +       spin_unlock(hash_lock);
19907 +       return 0;
19908 +}
19909 +
19910 +
19911 +/*     __find_mapping()
19912 + *     find a mapping in the hash table
19913 + *
19914 + *     caller must hold hash_lock
19915 + */
19916 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19917 +       struct vs_mapping **local, struct vs_mapping **global)
19918 +{
19919 +       struct hlist_head *hash = dmap_main_hash;
19920 +       struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19921 +       struct hlist_node *pos;
19922 +       struct vs_mapping *vdm;
19923 +
19924 +       *local = NULL;
19925 +       if (global)
19926 +               *global = NULL;
19927 +
19928 +       hlist_for_each(pos, head) {
19929 +               vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19930 +
19931 +               if ((vdm->device == device) &&
19932 +                       !((vdm->target.flags ^ mode) & S_IFMT)) {
19933 +                       if (vdm->xid == xid) {
19934 +                               *local = vdm;
19935 +                               return 1;
19936 +                       } else if (global && vdm->xid == 0)
19937 +                               *global = vdm;
19938 +               }
19939 +       }
19940 +
19941 +       if (global && *global)
19942 +               return 0;
19943 +       else
19944 +               return -ENOENT;
19945 +}
19946 +
19947 +
19948 +/*     __lookup_mapping()
19949 + *     find a mapping and store the result in target and flags
19950 + */
19951 +static inline int __lookup_mapping(struct vx_info *vxi,
19952 +       dev_t device, dev_t *target, int *flags, umode_t mode)
19953 +{
19954 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19955 +       struct vs_mapping *vdm, *global;
19956 +       struct vx_dmap_target *vdmt;
19957 +       int ret = 0;
19958 +       xid_t xid = vxi->vx_id;
19959 +       int index;
19960 +
19961 +       spin_lock(hash_lock);
19962 +       if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19963 +               ret = 1;
19964 +               vdmt = &vdm->target;
19965 +               goto found;
19966 +       }
19967 +
19968 +       index = __mode_to_default(mode);
19969 +       if (vxi && vxi->dmap.targets[index].flags) {
19970 +               ret = 2;
19971 +               vdmt = &vxi->dmap.targets[index];
19972 +       } else if (global) {
19973 +               ret = 3;
19974 +               vdmt = &global->target;
19975 +               goto found;
19976 +       } else {
19977 +               ret = 4;
19978 +               vdmt = &dmap_defaults[index];
19979 +       }
19980 +
19981 +found:
19982 +       if (target && (vdmt->flags & DATTR_REMAP))
19983 +               *target = vdmt->target;
19984 +       else if (target)
19985 +               *target = device;
19986 +       if (flags)
19987 +               *flags = vdmt->flags;
19988 +
19989 +       spin_unlock(hash_lock);
19990 +
19991 +       return ret;
19992 +}
19993 +
19994 +
19995 +/*     __remove_mapping()
19996 + *     remove a mapping from the hash table
19997 + */
19998 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19999 +       umode_t mode)
20000 +{
20001 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
20002 +       struct vs_mapping *vdm = NULL;
20003 +       int ret = 0;
20004 +
20005 +       spin_lock(hash_lock);
20006 +
20007 +       ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
20008 +               NULL);
20009 +       vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
20010 +               vxi, vxi ? vxi->vx_id : 0, device, mode);
20011 +       if (ret < 0)
20012 +               goto out;
20013 +       hlist_del(&vdm->dm_hlist);
20014 +
20015 +out:
20016 +       spin_unlock(hash_lock);
20017 +       if (vdm)
20018 +               kmem_cache_free(dmap_cachep, vdm);
20019 +       return ret;
20020 +}
20021 +
20022 +
20023 +
20024 +int vs_map_device(struct vx_info *vxi,
20025 +       dev_t device, dev_t *target, umode_t mode)
20026 +{
20027 +       int ret, flags = DATTR_MASK;
20028 +
20029 +       if (!vxi) {
20030 +               if (target)
20031 +                       *target = device;
20032 +               goto out;
20033 +       }
20034 +       ret = __lookup_mapping(vxi, device, target, &flags, mode);
20035 +       vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
20036 +               device, target ? *target : 0, flags, mode, ret);
20037 +out:
20038 +       return (flags & DATTR_MASK);
20039 +}
20040 +
20041 +
20042 +
20043 +static int do_set_mapping(struct vx_info *vxi,
20044 +       dev_t device, dev_t target, int flags, umode_t mode)
20045 +{
20046 +       if (device) {
20047 +               struct vs_mapping *new;
20048 +
20049 +               new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
20050 +               if (!new)
20051 +                       return -ENOMEM;
20052 +
20053 +               INIT_HLIST_NODE(&new->dm_hlist);
20054 +               new->device = device;
20055 +               new->target.target = target;
20056 +               new->target.flags = flags | mode;
20057 +               new->xid = (vxi ? vxi->vx_id : 0);
20058 +
20059 +               vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
20060 +               __hash_mapping(vxi, new);
20061 +       } else {
20062 +               struct vx_dmap_target new = {
20063 +                       .target = target,
20064 +                       .flags = flags | mode,
20065 +               };
20066 +               __set_default(vxi, mode, &new);
20067 +       }
20068 +       return 0;
20069 +}
20070 +
20071 +
20072 +static int do_unset_mapping(struct vx_info *vxi,
20073 +       dev_t device, dev_t target, int flags, umode_t mode)
20074 +{
20075 +       int ret = -EINVAL;
20076 +
20077 +       if (device) {
20078 +               ret = __remove_mapping(vxi, device, mode);
20079 +               if (ret < 0)
20080 +                       goto out;
20081 +       } else {
20082 +               ret = __remove_default(vxi, mode);
20083 +               if (ret < 0)
20084 +                       goto out;
20085 +       }
20086 +
20087 +out:
20088 +       return ret;
20089 +}
20090 +
20091 +
20092 +static inline int __user_device(const char __user *name, dev_t *dev,
20093 +       umode_t *mode)
20094 +{
20095 +       struct nameidata nd;
20096 +       int ret;
20097 +
20098 +       if (!name) {
20099 +               *dev = 0;
20100 +               return 0;
20101 +       }
20102 +       ret = user_lpath(name, &nd.path);
20103 +       if (ret)
20104 +               return ret;
20105 +       if (nd.path.dentry->d_inode) {
20106 +               *dev = nd.path.dentry->d_inode->i_rdev;
20107 +               *mode = nd.path.dentry->d_inode->i_mode;
20108 +       }
20109 +       path_put(&nd.path);
20110 +       return 0;
20111 +}
20112 +
20113 +static inline int __mapping_mode(dev_t device, dev_t target,
20114 +       umode_t device_mode, umode_t target_mode, umode_t *mode)
20115 +{
20116 +       if (device)
20117 +               *mode = device_mode & S_IFMT;
20118 +       else if (target)
20119 +               *mode = target_mode & S_IFMT;
20120 +       else
20121 +               return -EINVAL;
20122 +
20123 +       /* if both given, device and target mode have to match */
20124 +       if (device && target &&
20125 +               ((device_mode ^ target_mode) & S_IFMT))
20126 +               return -EINVAL;
20127 +       return 0;
20128 +}
20129 +
20130 +
20131 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
20132 +       const char __user *target_path, int flags, int set)
20133 +{
20134 +       dev_t device = ~0, target = ~0;
20135 +       umode_t device_mode = 0, target_mode = 0, mode;
20136 +       int ret;
20137 +
20138 +       ret = __user_device(device_path, &device, &device_mode);
20139 +       if (ret)
20140 +               return ret;
20141 +       ret = __user_device(target_path, &target, &target_mode);
20142 +       if (ret)
20143 +               return ret;
20144 +
20145 +       ret = __mapping_mode(device, target,
20146 +               device_mode, target_mode, &mode);
20147 +       if (ret)
20148 +               return ret;
20149 +
20150 +       if (set)
20151 +               return do_set_mapping(vxi, device, target,
20152 +                       flags, mode);
20153 +       else
20154 +               return do_unset_mapping(vxi, device, target,
20155 +                       flags, mode);
20156 +}
20157 +
20158 +
20159 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
20160 +{
20161 +       struct vcmd_set_mapping_v0 vc_data;
20162 +
20163 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20164 +               return -EFAULT;
20165 +
20166 +       return do_mapping(vxi, vc_data.device, vc_data.target,
20167 +               vc_data.flags, 1);
20168 +}
20169 +
20170 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
20171 +{
20172 +       struct vcmd_set_mapping_v0 vc_data;
20173 +
20174 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20175 +               return -EFAULT;
20176 +
20177 +       return do_mapping(vxi, vc_data.device, vc_data.target,
20178 +               vc_data.flags, 0);
20179 +}
20180 +
20181 +
20182 +#ifdef CONFIG_COMPAT
20183 +
20184 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
20185 +{
20186 +       struct vcmd_set_mapping_v0_x32 vc_data;
20187 +
20188 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20189 +               return -EFAULT;
20190 +
20191 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
20192 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
20193 +}
20194 +
20195 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
20196 +{
20197 +       struct vcmd_set_mapping_v0_x32 vc_data;
20198 +
20199 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20200 +               return -EFAULT;
20201 +
20202 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
20203 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
20204 +}
20205 +
20206 +#endif /* CONFIG_COMPAT */
20207 +
20208 +
20209 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/dlimit.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/dlimit.c
20210 --- linux-2.6.33.2/kernel/vserver/dlimit.c      1970-01-01 01:00:00.000000000 +0100
20211 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/dlimit.c      2010-02-25 12:02:16.000000000 +0100
20212 @@ -0,0 +1,529 @@
20213 +/*
20214 + *  linux/kernel/vserver/dlimit.c
20215 + *
20216 + *  Virtual Server: Context Disk Limits
20217 + *
20218 + *  Copyright (C) 2004-2009  Herbert Pötzl
20219 + *
20220 + *  V0.01  initial version
20221 + *  V0.02  compat32 splitup
20222 + *  V0.03  extended interface
20223 + *
20224 + */
20225 +
20226 +#include <linux/statfs.h>
20227 +#include <linux/sched.h>
20228 +#include <linux/namei.h>
20229 +#include <linux/vs_tag.h>
20230 +#include <linux/vs_dlimit.h>
20231 +#include <linux/vserver/dlimit_cmd.h>
20232 +
20233 +#include <asm/uaccess.h>
20234 +
20235 +/*     __alloc_dl_info()
20236 +
20237 +       * allocate an initialized dl_info struct
20238 +       * doesn't make it visible (hash)                        */
20239 +
20240 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
20241 +{
20242 +       struct dl_info *new = NULL;
20243 +
20244 +       vxdprintk(VXD_CBIT(dlim, 5),
20245 +               "alloc_dl_info(%p,%d)*", sb, tag);
20246 +
20247 +       /* would this benefit from a slab cache? */
20248 +       new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
20249 +       if (!new)
20250 +               return 0;
20251 +
20252 +       memset(new, 0, sizeof(struct dl_info));
20253 +       new->dl_tag = tag;
20254 +       new->dl_sb = sb;
20255 +       INIT_RCU_HEAD(&new->dl_rcu);
20256 +       INIT_HLIST_NODE(&new->dl_hlist);
20257 +       spin_lock_init(&new->dl_lock);
20258 +       atomic_set(&new->dl_refcnt, 0);
20259 +       atomic_set(&new->dl_usecnt, 0);
20260 +
20261 +       /* rest of init goes here */
20262 +
20263 +       vxdprintk(VXD_CBIT(dlim, 4),
20264 +               "alloc_dl_info(%p,%d) = %p", sb, tag, new);
20265 +       return new;
20266 +}
20267 +
20268 +/*     __dealloc_dl_info()
20269 +
20270 +       * final disposal of dl_info                             */
20271 +
20272 +static void __dealloc_dl_info(struct dl_info *dli)
20273 +{
20274 +       vxdprintk(VXD_CBIT(dlim, 4),
20275 +               "dealloc_dl_info(%p)", dli);
20276 +
20277 +       dli->dl_hlist.next = LIST_POISON1;
20278 +       dli->dl_tag = -1;
20279 +       dli->dl_sb = 0;
20280 +
20281 +       BUG_ON(atomic_read(&dli->dl_usecnt));
20282 +       BUG_ON(atomic_read(&dli->dl_refcnt));
20283 +
20284 +       kfree(dli);
20285 +}
20286 +
20287 +
20288 +/*     hash table for dl_info hash */
20289 +
20290 +#define DL_HASH_SIZE   13
20291 +
20292 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
20293 +
20294 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
20295 +
20296 +
20297 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
20298 +{
20299 +       return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
20300 +}
20301 +
20302 +
20303 +
20304 +/*     __hash_dl_info()
20305 +
20306 +       * add the dli to the global hash table
20307 +       * requires the hash_lock to be held                     */
20308 +
20309 +static inline void __hash_dl_info(struct dl_info *dli)
20310 +{
20311 +       struct hlist_head *head;
20312 +
20313 +       vxdprintk(VXD_CBIT(dlim, 6),
20314 +               "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
20315 +       get_dl_info(dli);
20316 +       head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
20317 +       hlist_add_head_rcu(&dli->dl_hlist, head);
20318 +}
20319 +
20320 +/*     __unhash_dl_info()
20321 +
20322 +       * remove the dli from the global hash table
20323 +       * requires the hash_lock to be held                     */
20324 +
20325 +static inline void __unhash_dl_info(struct dl_info *dli)
20326 +{
20327 +       vxdprintk(VXD_CBIT(dlim, 6),
20328 +               "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
20329 +       hlist_del_rcu(&dli->dl_hlist);
20330 +       put_dl_info(dli);
20331 +}
20332 +
20333 +
20334 +/*     __lookup_dl_info()
20335 +
20336 +       * requires the rcu_read_lock()
20337 +       * doesn't increment the dl_refcnt                       */
20338 +
20339 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
20340 +{
20341 +       struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
20342 +       struct hlist_node *pos;
20343 +       struct dl_info *dli;
20344 +
20345 +       hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
20346 +
20347 +               if (dli->dl_tag == tag && dli->dl_sb == sb) {
20348 +                       return dli;
20349 +               }
20350 +       }
20351 +       return NULL;
20352 +}
20353 +
20354 +
20355 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
20356 +{
20357 +       struct dl_info *dli;
20358 +
20359 +       rcu_read_lock();
20360 +       dli = get_dl_info(__lookup_dl_info(sb, tag));
20361 +       vxdprintk(VXD_CBIT(dlim, 7),
20362 +               "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
20363 +       rcu_read_unlock();
20364 +       return dli;
20365 +}
20366 +
20367 +void rcu_free_dl_info(struct rcu_head *head)
20368 +{
20369 +       struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
20370 +       int usecnt, refcnt;
20371 +
20372 +       BUG_ON(!dli || !head);
20373 +
20374 +       usecnt = atomic_read(&dli->dl_usecnt);
20375 +       BUG_ON(usecnt < 0);
20376 +
20377 +       refcnt = atomic_read(&dli->dl_refcnt);
20378 +       BUG_ON(refcnt < 0);
20379 +
20380 +       vxdprintk(VXD_CBIT(dlim, 3),
20381 +               "rcu_free_dl_info(%p)", dli);
20382 +       if (!usecnt)
20383 +               __dealloc_dl_info(dli);
20384 +       else
20385 +               printk("!!! rcu didn't free\n");
20386 +}
20387 +
20388 +
20389 +
20390 +
20391 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
20392 +       uint32_t flags, int add)
20393 +{
20394 +       struct path path;
20395 +       int ret;
20396 +
20397 +       ret = user_lpath(name, &path);
20398 +       if (!ret) {
20399 +               struct super_block *sb;
20400 +               struct dl_info *dli;
20401 +
20402 +               ret = -EINVAL;
20403 +               if (!path.dentry->d_inode)
20404 +                       goto out_release;
20405 +               if (!(sb = path.dentry->d_inode->i_sb))
20406 +                       goto out_release;
20407 +
20408 +               if (add) {
20409 +                       dli = __alloc_dl_info(sb, id);
20410 +                       spin_lock(&dl_info_hash_lock);
20411 +
20412 +                       ret = -EEXIST;
20413 +                       if (__lookup_dl_info(sb, id))
20414 +                               goto out_unlock;
20415 +                       __hash_dl_info(dli);
20416 +                       dli = NULL;
20417 +               } else {
20418 +                       spin_lock(&dl_info_hash_lock);
20419 +                       dli = __lookup_dl_info(sb, id);
20420 +
20421 +                       ret = -ESRCH;
20422 +                       if (!dli)
20423 +                               goto out_unlock;
20424 +                       __unhash_dl_info(dli);
20425 +               }
20426 +               ret = 0;
20427 +       out_unlock:
20428 +               spin_unlock(&dl_info_hash_lock);
20429 +               if (add && dli)
20430 +                       __dealloc_dl_info(dli);
20431 +       out_release:
20432 +               path_put(&path);
20433 +       }
20434 +       return ret;
20435 +}
20436 +
20437 +int vc_add_dlimit(uint32_t id, void __user *data)
20438 +{
20439 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
20440 +
20441 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20442 +               return -EFAULT;
20443 +
20444 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
20445 +}
20446 +
20447 +int vc_rem_dlimit(uint32_t id, void __user *data)
20448 +{
20449 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
20450 +
20451 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20452 +               return -EFAULT;
20453 +
20454 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
20455 +}
20456 +
20457 +#ifdef CONFIG_COMPAT
20458 +
20459 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
20460 +{
20461 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20462 +
20463 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20464 +               return -EFAULT;
20465 +
20466 +       return do_addrem_dlimit(id,
20467 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
20468 +}
20469 +
20470 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
20471 +{
20472 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20473 +
20474 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20475 +               return -EFAULT;
20476 +
20477 +       return do_addrem_dlimit(id,
20478 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
20479 +}
20480 +
20481 +#endif /* CONFIG_COMPAT */
20482 +
20483 +
20484 +static inline
20485 +int do_set_dlimit(uint32_t id, const char __user *name,
20486 +       uint32_t space_used, uint32_t space_total,
20487 +       uint32_t inodes_used, uint32_t inodes_total,
20488 +       uint32_t reserved, uint32_t flags)
20489 +{
20490 +       struct path path;
20491 +       int ret;
20492 +
20493 +       ret = user_lpath(name, &path);
20494 +       if (!ret) {
20495 +               struct super_block *sb;
20496 +               struct dl_info *dli;
20497 +
20498 +               ret = -EINVAL;
20499 +               if (!path.dentry->d_inode)
20500 +                       goto out_release;
20501 +               if (!(sb = path.dentry->d_inode->i_sb))
20502 +                       goto out_release;
20503 +
20504 +               /* sanity checks */
20505 +               if ((reserved != CDLIM_KEEP &&
20506 +                       reserved > 100) ||
20507 +                       (inodes_used != CDLIM_KEEP &&
20508 +                       inodes_used > inodes_total) ||
20509 +                       (space_used != CDLIM_KEEP &&
20510 +                       space_used > space_total))
20511 +                       goto out_release;
20512 +
20513 +               ret = -ESRCH;
20514 +               dli = locate_dl_info(sb, id);
20515 +               if (!dli)
20516 +                       goto out_release;
20517 +
20518 +               spin_lock(&dli->dl_lock);
20519 +
20520 +               if (inodes_used != CDLIM_KEEP)
20521 +                       dli->dl_inodes_used = inodes_used;
20522 +               if (inodes_total != CDLIM_KEEP)
20523 +                       dli->dl_inodes_total = inodes_total;
20524 +               if (space_used != CDLIM_KEEP)
20525 +                       dli->dl_space_used = dlimit_space_32to64(
20526 +                               space_used, flags, DLIMS_USED);
20527 +
20528 +               if (space_total == CDLIM_INFINITY)
20529 +                       dli->dl_space_total = DLIM_INFINITY;
20530 +               else if (space_total != CDLIM_KEEP)
20531 +                       dli->dl_space_total = dlimit_space_32to64(
20532 +                               space_total, flags, DLIMS_TOTAL);
20533 +
20534 +               if (reserved != CDLIM_KEEP)
20535 +                       dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20536 +
20537 +               spin_unlock(&dli->dl_lock);
20538 +
20539 +               put_dl_info(dli);
20540 +               ret = 0;
20541 +
20542 +       out_release:
20543 +               path_put(&path);
20544 +       }
20545 +       return ret;
20546 +}
20547 +
20548 +int vc_set_dlimit(uint32_t id, void __user *data)
20549 +{
20550 +       struct vcmd_ctx_dlimit_v0 vc_data;
20551 +
20552 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20553 +               return -EFAULT;
20554 +
20555 +       return do_set_dlimit(id, vc_data.name,
20556 +               vc_data.space_used, vc_data.space_total,
20557 +               vc_data.inodes_used, vc_data.inodes_total,
20558 +               vc_data.reserved, vc_data.flags);
20559 +}
20560 +
20561 +#ifdef CONFIG_COMPAT
20562 +
20563 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20564 +{
20565 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20566 +
20567 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20568 +               return -EFAULT;
20569 +
20570 +       return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20571 +               vc_data.space_used, vc_data.space_total,
20572 +               vc_data.inodes_used, vc_data.inodes_total,
20573 +               vc_data.reserved, vc_data.flags);
20574 +}
20575 +
20576 +#endif /* CONFIG_COMPAT */
20577 +
20578 +
20579 +static inline
20580 +int do_get_dlimit(uint32_t id, const char __user *name,
20581 +       uint32_t *space_used, uint32_t *space_total,
20582 +       uint32_t *inodes_used, uint32_t *inodes_total,
20583 +       uint32_t *reserved, uint32_t *flags)
20584 +{
20585 +       struct path path;
20586 +       int ret;
20587 +
20588 +       ret = user_lpath(name, &path);
20589 +       if (!ret) {
20590 +               struct super_block *sb;
20591 +               struct dl_info *dli;
20592 +
20593 +               ret = -EINVAL;
20594 +               if (!path.dentry->d_inode)
20595 +                       goto out_release;
20596 +               if (!(sb = path.dentry->d_inode->i_sb))
20597 +                       goto out_release;
20598 +
20599 +               ret = -ESRCH;
20600 +               dli = locate_dl_info(sb, id);
20601 +               if (!dli)
20602 +                       goto out_release;
20603 +
20604 +               spin_lock(&dli->dl_lock);
20605 +               *inodes_used = dli->dl_inodes_used;
20606 +               *inodes_total = dli->dl_inodes_total;
20607 +
20608 +               *space_used = dlimit_space_64to32(
20609 +                       dli->dl_space_used, flags, DLIMS_USED);
20610 +
20611 +               if (dli->dl_space_total == DLIM_INFINITY)
20612 +                       *space_total = CDLIM_INFINITY;
20613 +               else
20614 +                       *space_total = dlimit_space_64to32(
20615 +                               dli->dl_space_total, flags, DLIMS_TOTAL);
20616 +
20617 +               *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20618 +               spin_unlock(&dli->dl_lock);
20619 +
20620 +               put_dl_info(dli);
20621 +               ret = -EFAULT;
20622 +
20623 +               ret = 0;
20624 +       out_release:
20625 +               path_put(&path);
20626 +       }
20627 +       return ret;
20628 +}
20629 +
20630 +
20631 +int vc_get_dlimit(uint32_t id, void __user *data)
20632 +{
20633 +       struct vcmd_ctx_dlimit_v0 vc_data;
20634 +       int ret;
20635 +
20636 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20637 +               return -EFAULT;
20638 +
20639 +       ret = do_get_dlimit(id, vc_data.name,
20640 +               &vc_data.space_used, &vc_data.space_total,
20641 +               &vc_data.inodes_used, &vc_data.inodes_total,
20642 +               &vc_data.reserved, &vc_data.flags);
20643 +       if (ret)
20644 +               return ret;
20645 +
20646 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20647 +               return -EFAULT;
20648 +       return 0;
20649 +}
20650 +
20651 +#ifdef CONFIG_COMPAT
20652 +
20653 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20654 +{
20655 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20656 +       int ret;
20657 +
20658 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20659 +               return -EFAULT;
20660 +
20661 +       ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20662 +               &vc_data.space_used, &vc_data.space_total,
20663 +               &vc_data.inodes_used, &vc_data.inodes_total,
20664 +               &vc_data.reserved, &vc_data.flags);
20665 +       if (ret)
20666 +               return ret;
20667 +
20668 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20669 +               return -EFAULT;
20670 +       return 0;
20671 +}
20672 +
20673 +#endif /* CONFIG_COMPAT */
20674 +
20675 +
20676 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20677 +{
20678 +       struct dl_info *dli;
20679 +       __u64 blimit, bfree, bavail;
20680 +       __u32 ifree;
20681 +
20682 +       dli = locate_dl_info(sb, dx_current_tag());
20683 +       if (!dli)
20684 +               return;
20685 +
20686 +       spin_lock(&dli->dl_lock);
20687 +       if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20688 +               goto no_ilim;
20689 +
20690 +       /* reduce max inodes available to limit */
20691 +       if (buf->f_files > dli->dl_inodes_total)
20692 +               buf->f_files = dli->dl_inodes_total;
20693 +
20694 +       ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20695 +       /* reduce free inodes to min */
20696 +       if (ifree < buf->f_ffree)
20697 +               buf->f_ffree = ifree;
20698 +
20699 +no_ilim:
20700 +       if (dli->dl_space_total == DLIM_INFINITY)
20701 +               goto no_blim;
20702 +
20703 +       blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20704 +
20705 +       if (dli->dl_space_total < dli->dl_space_used)
20706 +               bfree = 0;
20707 +       else
20708 +               bfree = (dli->dl_space_total - dli->dl_space_used)
20709 +                       >> sb->s_blocksize_bits;
20710 +
20711 +       bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20712 +       if (bavail < dli->dl_space_used)
20713 +               bavail = 0;
20714 +       else
20715 +               bavail = (bavail - dli->dl_space_used)
20716 +                       >> sb->s_blocksize_bits;
20717 +
20718 +       /* reduce max space available to limit */
20719 +       if (buf->f_blocks > blimit)
20720 +               buf->f_blocks = blimit;
20721 +
20722 +       /* reduce free space to min */
20723 +       if (bfree < buf->f_bfree)
20724 +               buf->f_bfree = bfree;
20725 +
20726 +       /* reduce avail space to min */
20727 +       if (bavail < buf->f_bavail)
20728 +               buf->f_bavail = bavail;
20729 +
20730 +no_blim:
20731 +       spin_unlock(&dli->dl_lock);
20732 +       put_dl_info(dli);
20733 +
20734 +       return;
20735 +}
20736 +
20737 +#include <linux/module.h>
20738 +
20739 +EXPORT_SYMBOL_GPL(locate_dl_info);
20740 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20741 +
20742 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/helper.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/helper.c
20743 --- linux-2.6.33.2/kernel/vserver/helper.c      1970-01-01 01:00:00.000000000 +0100
20744 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/helper.c      2010-02-25 12:02:16.000000000 +0100
20745 @@ -0,0 +1,223 @@
20746 +/*
20747 + *  linux/kernel/vserver/helper.c
20748 + *
20749 + *  Virtual Context Support
20750 + *
20751 + *  Copyright (C) 2004-2007  Herbert Pötzl
20752 + *
20753 + *  V0.01  basic helper
20754 + *
20755 + */
20756 +
20757 +#include <linux/kmod.h>
20758 +#include <linux/reboot.h>
20759 +#include <linux/vs_context.h>
20760 +#include <linux/vs_network.h>
20761 +#include <linux/vserver/signal.h>
20762 +
20763 +
20764 +char vshelper_path[255] = "/sbin/vshelper";
20765 +
20766 +
20767 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20768 +{
20769 +       int ret;
20770 +
20771 +       if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20772 +               printk( KERN_WARNING
20773 +                       "%s: (%s %s) returned %s with %d\n",
20774 +                       name, argv[1], argv[2],
20775 +                       sync ? "sync" : "async", ret);
20776 +       }
20777 +       vxdprintk(VXD_CBIT(switch, 4),
20778 +               "%s: (%s %s) returned %s with %d",
20779 +               name, argv[1], argv[2], sync ? "sync" : "async", ret);
20780 +       return ret;
20781 +}
20782 +
20783 +/*
20784 + *      vshelper path is set via /proc/sys
20785 + *      invoked by vserver sys_reboot(), with
20786 + *      the following arguments
20787 + *
20788 + *      argv [0] = vshelper_path;
20789 + *      argv [1] = action: "restart", "halt", "poweroff", ...
20790 + *      argv [2] = context identifier
20791 + *
20792 + *      envp [*] = type-specific parameters
20793 + */
20794 +
20795 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20796 +{
20797 +       char id_buf[8], cmd_buf[16];
20798 +       char uid_buf[16], pid_buf[16];
20799 +       int ret;
20800 +
20801 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20802 +       char *envp[] = {"HOME=/", "TERM=linux",
20803 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20804 +                       uid_buf, pid_buf, cmd_buf, 0};
20805 +
20806 +       if (vx_info_state(vxi, VXS_HELPER))
20807 +               return -EAGAIN;
20808 +       vxi->vx_state |= VXS_HELPER;
20809 +
20810 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20811 +
20812 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20813 +       snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20814 +       snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20815 +
20816 +       switch (cmd) {
20817 +       case LINUX_REBOOT_CMD_RESTART:
20818 +               argv[1] = "restart";
20819 +               break;
20820 +
20821 +       case LINUX_REBOOT_CMD_HALT:
20822 +               argv[1] = "halt";
20823 +               break;
20824 +
20825 +       case LINUX_REBOOT_CMD_POWER_OFF:
20826 +               argv[1] = "poweroff";
20827 +               break;
20828 +
20829 +       case LINUX_REBOOT_CMD_SW_SUSPEND:
20830 +               argv[1] = "swsusp";
20831 +               break;
20832 +
20833 +       case LINUX_REBOOT_CMD_OOM:
20834 +               argv[1] = "oom";
20835 +               break;
20836 +
20837 +       default:
20838 +               vxi->vx_state &= ~VXS_HELPER;
20839 +               return 0;
20840 +       }
20841 +
20842 +       ret = do_vshelper(vshelper_path, argv, envp, 0);
20843 +       vxi->vx_state &= ~VXS_HELPER;
20844 +       __wakeup_vx_info(vxi);
20845 +       return (ret) ? -EPERM : 0;
20846 +}
20847 +
20848 +
20849 +long vs_reboot(unsigned int cmd, void __user *arg)
20850 +{
20851 +       struct vx_info *vxi = current_vx_info();
20852 +       long ret = 0;
20853 +
20854 +       vxdprintk(VXD_CBIT(misc, 5),
20855 +               "vs_reboot(%p[#%d],%u)",
20856 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20857 +
20858 +       ret = vs_reboot_helper(vxi, cmd, arg);
20859 +       if (ret)
20860 +               return ret;
20861 +
20862 +       vxi->reboot_cmd = cmd;
20863 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20864 +               switch (cmd) {
20865 +               case LINUX_REBOOT_CMD_RESTART:
20866 +               case LINUX_REBOOT_CMD_HALT:
20867 +               case LINUX_REBOOT_CMD_POWER_OFF:
20868 +                       vx_info_kill(vxi, 0, SIGKILL);
20869 +                       vx_info_kill(vxi, 1, SIGKILL);
20870 +               default:
20871 +                       break;
20872 +               }
20873 +       }
20874 +       return 0;
20875 +}
20876 +
20877 +long vs_oom_action(unsigned int cmd)
20878 +{
20879 +       struct vx_info *vxi = current_vx_info();
20880 +       long ret = 0;
20881 +
20882 +       vxdprintk(VXD_CBIT(misc, 5),
20883 +               "vs_oom_action(%p[#%d],%u)",
20884 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20885 +
20886 +       ret = vs_reboot_helper(vxi, cmd, NULL);
20887 +       if (ret)
20888 +               return ret;
20889 +
20890 +       vxi->reboot_cmd = cmd;
20891 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20892 +               vx_info_kill(vxi, 0, SIGKILL);
20893 +               vx_info_kill(vxi, 1, SIGKILL);
20894 +       }
20895 +       return 0;
20896 +}
20897 +
20898 +/*
20899 + *      argv [0] = vshelper_path;
20900 + *      argv [1] = action: "startup", "shutdown"
20901 + *      argv [2] = context identifier
20902 + *
20903 + *      envp [*] = type-specific parameters
20904 + */
20905 +
20906 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20907 +{
20908 +       char id_buf[8], cmd_buf[16];
20909 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20910 +       char *envp[] = {"HOME=/", "TERM=linux",
20911 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20912 +
20913 +       if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20914 +               return 0;
20915 +
20916 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20917 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20918 +
20919 +       switch (cmd) {
20920 +       case VSC_STARTUP:
20921 +               argv[1] = "startup";
20922 +               break;
20923 +       case VSC_SHUTDOWN:
20924 +               argv[1] = "shutdown";
20925 +               break;
20926 +       default:
20927 +               return 0;
20928 +       }
20929 +
20930 +       return do_vshelper(vshelper_path, argv, envp, 1);
20931 +}
20932 +
20933 +
20934 +/*
20935 + *      argv [0] = vshelper_path;
20936 + *      argv [1] = action: "netup", "netdown"
20937 + *      argv [2] = context identifier
20938 + *
20939 + *      envp [*] = type-specific parameters
20940 + */
20941 +
20942 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20943 +{
20944 +       char id_buf[8], cmd_buf[16];
20945 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20946 +       char *envp[] = {"HOME=/", "TERM=linux",
20947 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20948 +
20949 +       if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20950 +               return 0;
20951 +
20952 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20953 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20954 +
20955 +       switch (cmd) {
20956 +       case VSC_NETUP:
20957 +               argv[1] = "netup";
20958 +               break;
20959 +       case VSC_NETDOWN:
20960 +               argv[1] = "netdown";
20961 +               break;
20962 +       default:
20963 +               return 0;
20964 +       }
20965 +
20966 +       return do_vshelper(vshelper_path, argv, envp, 1);
20967 +}
20968 +
20969 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/history.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/history.c
20970 --- linux-2.6.33.2/kernel/vserver/history.c     1970-01-01 01:00:00.000000000 +0100
20971 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/history.c     2010-02-25 12:02:16.000000000 +0100
20972 @@ -0,0 +1,258 @@
20973 +/*
20974 + *  kernel/vserver/history.c
20975 + *
20976 + *  Virtual Context History Backtrace
20977 + *
20978 + *  Copyright (C) 2004-2007  Herbert Pötzl
20979 + *
20980 + *  V0.01  basic structure
20981 + *  V0.02  hash/unhash and trace
20982 + *  V0.03  preemption fixes
20983 + *
20984 + */
20985 +
20986 +#include <linux/module.h>
20987 +#include <asm/uaccess.h>
20988 +
20989 +#include <linux/vserver/context.h>
20990 +#include <linux/vserver/debug.h>
20991 +#include <linux/vserver/debug_cmd.h>
20992 +#include <linux/vserver/history.h>
20993 +
20994 +
20995 +#ifdef CONFIG_VSERVER_HISTORY
20996 +#define VXH_SIZE       CONFIG_VSERVER_HISTORY_SIZE
20997 +#else
20998 +#define VXH_SIZE       64
20999 +#endif
21000 +
21001 +struct _vx_history {
21002 +       unsigned int counter;
21003 +
21004 +       struct _vx_hist_entry entry[VXH_SIZE + 1];
21005 +};
21006 +
21007 +
21008 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
21009 +
21010 +unsigned volatile int vxh_active = 1;
21011 +
21012 +static atomic_t sequence = ATOMIC_INIT(0);
21013 +
21014 +
21015 +/*     vxh_advance()
21016 +
21017 +       * requires disabled preemption                          */
21018 +
21019 +struct _vx_hist_entry *vxh_advance(void *loc)
21020 +{
21021 +       unsigned int cpu = smp_processor_id();
21022 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
21023 +       struct _vx_hist_entry *entry;
21024 +       unsigned int index;
21025 +
21026 +       index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
21027 +       entry = &hist->entry[index];
21028 +
21029 +       entry->seq = atomic_inc_return(&sequence);
21030 +       entry->loc = loc;
21031 +       return entry;
21032 +}
21033 +
21034 +EXPORT_SYMBOL_GPL(vxh_advance);
21035 +
21036 +
21037 +#define VXH_LOC_FMTS   "(#%04x,*%d):%p"
21038 +
21039 +#define VXH_LOC_ARGS(e)        (e)->seq, cpu, (e)->loc
21040 +
21041 +
21042 +#define VXH_VXI_FMTS   "%p[#%d,%d.%d]"
21043 +
21044 +#define VXH_VXI_ARGS(e)        (e)->vxi.ptr,                           \
21045 +                       (e)->vxi.ptr ? (e)->vxi.xid : 0,        \
21046 +                       (e)->vxi.ptr ? (e)->vxi.usecnt : 0,     \
21047 +                       (e)->vxi.ptr ? (e)->vxi.tasks : 0
21048 +
21049 +void   vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
21050 +{
21051 +       switch (e->type) {
21052 +       case VXH_THROW_OOPS:
21053 +               printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
21054 +               break;
21055 +
21056 +       case VXH_GET_VX_INFO:
21057 +       case VXH_PUT_VX_INFO:
21058 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
21059 +                       VXH_LOC_ARGS(e),
21060 +                       (e->type == VXH_GET_VX_INFO) ? "get" : "put",
21061 +                       VXH_VXI_ARGS(e));
21062 +               break;
21063 +
21064 +       case VXH_INIT_VX_INFO:
21065 +       case VXH_SET_VX_INFO:
21066 +       case VXH_CLR_VX_INFO:
21067 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
21068 +                       VXH_LOC_ARGS(e),
21069 +                       (e->type == VXH_INIT_VX_INFO) ? "init" :
21070 +                       ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
21071 +                       VXH_VXI_ARGS(e), e->sc.data);
21072 +               break;
21073 +
21074 +       case VXH_CLAIM_VX_INFO:
21075 +       case VXH_RELEASE_VX_INFO:
21076 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
21077 +                       VXH_LOC_ARGS(e),
21078 +                       (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
21079 +                       VXH_VXI_ARGS(e), e->sc.data);
21080 +               break;
21081 +
21082 +       case VXH_ALLOC_VX_INFO:
21083 +       case VXH_DEALLOC_VX_INFO:
21084 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
21085 +                       VXH_LOC_ARGS(e),
21086 +                       (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
21087 +                       VXH_VXI_ARGS(e));
21088 +               break;
21089 +
21090 +       case VXH_HASH_VX_INFO:
21091 +       case VXH_UNHASH_VX_INFO:
21092 +               printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
21093 +                       VXH_LOC_ARGS(e),
21094 +                       (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
21095 +                       VXH_VXI_ARGS(e));
21096 +               break;
21097 +
21098 +       case VXH_LOC_VX_INFO:
21099 +       case VXH_LOOKUP_VX_INFO:
21100 +       case VXH_CREATE_VX_INFO:
21101 +               printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
21102 +                       VXH_LOC_ARGS(e),
21103 +                       (e->type == VXH_CREATE_VX_INFO) ? "create" :
21104 +                       ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
21105 +                       e->ll.arg, VXH_VXI_ARGS(e));
21106 +               break;
21107 +       }
21108 +}
21109 +
21110 +static void __vxh_dump_history(void)
21111 +{
21112 +       unsigned int i, cpu;
21113 +
21114 +       printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
21115 +               atomic_read(&sequence), NR_CPUS);
21116 +
21117 +       for (i = 0; i < VXH_SIZE; i++) {
21118 +               for_each_online_cpu(cpu) {
21119 +                       struct _vx_history *hist =
21120 +                               &per_cpu(vx_history_buffer, cpu);
21121 +                       unsigned int index = (hist->counter - i) % VXH_SIZE;
21122 +                       struct _vx_hist_entry *entry = &hist->entry[index];
21123 +
21124 +                       vxh_dump_entry(entry, cpu);
21125 +               }
21126 +       }
21127 +}
21128 +
21129 +void   vxh_dump_history(void)
21130 +{
21131 +       vxh_active = 0;
21132 +#ifdef CONFIG_SMP
21133 +       local_irq_enable();
21134 +       smp_send_stop();
21135 +       local_irq_disable();
21136 +#endif
21137 +       __vxh_dump_history();
21138 +}
21139 +
21140 +
21141 +/* vserver syscall commands below here */
21142 +
21143 +
21144 +int vc_dump_history(uint32_t id)
21145 +{
21146 +       vxh_active = 0;
21147 +       __vxh_dump_history();
21148 +       vxh_active = 1;
21149 +
21150 +       return 0;
21151 +}
21152 +
21153 +
21154 +int do_read_history(struct __user _vx_hist_entry *data,
21155 +       int cpu, uint32_t *index, uint32_t *count)
21156 +{
21157 +       int pos, ret = 0;
21158 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
21159 +       int end = hist->counter;
21160 +       int start = end - VXH_SIZE + 2;
21161 +       int idx = *index;
21162 +
21163 +       /* special case: get current pos */
21164 +       if (!*count) {
21165 +               *index = end;
21166 +               return 0;
21167 +       }
21168 +
21169 +       /* have we lost some data? */
21170 +       if (idx < start)
21171 +               idx = start;
21172 +
21173 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21174 +               struct _vx_hist_entry *entry =
21175 +                       &hist->entry[idx % VXH_SIZE];
21176 +
21177 +               /* send entry to userspace */
21178 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21179 +               if (ret)
21180 +                       break;
21181 +       }
21182 +       /* save new index and count */
21183 +       *index = idx;
21184 +       *count = pos;
21185 +       return ret ? ret : (*index < end);
21186 +}
21187 +
21188 +int vc_read_history(uint32_t id, void __user *data)
21189 +{
21190 +       struct vcmd_read_history_v0 vc_data;
21191 +       int ret;
21192 +
21193 +       if (id >= NR_CPUS)
21194 +               return -EINVAL;
21195 +
21196 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21197 +               return -EFAULT;
21198 +
21199 +       ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
21200 +               id, &vc_data.index, &vc_data.count);
21201 +
21202 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21203 +               return -EFAULT;
21204 +       return ret;
21205 +}
21206 +
21207 +#ifdef CONFIG_COMPAT
21208 +
21209 +int vc_read_history_x32(uint32_t id, void __user *data)
21210 +{
21211 +       struct vcmd_read_history_v0_x32 vc_data;
21212 +       int ret;
21213 +
21214 +       if (id >= NR_CPUS)
21215 +               return -EINVAL;
21216 +
21217 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21218 +               return -EFAULT;
21219 +
21220 +       ret = do_read_history((struct __user _vx_hist_entry *)
21221 +               compat_ptr(vc_data.data_ptr),
21222 +               id, &vc_data.index, &vc_data.count);
21223 +
21224 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21225 +               return -EFAULT;
21226 +       return ret;
21227 +}
21228 +
21229 +#endif /* CONFIG_COMPAT */
21230 +
21231 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/inet.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/inet.c
21232 --- linux-2.6.33.2/kernel/vserver/inet.c        1970-01-01 01:00:00.000000000 +0100
21233 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/inet.c        2010-02-25 12:02:16.000000000 +0100
21234 @@ -0,0 +1,225 @@
21235 +
21236 +#include <linux/in.h>
21237 +#include <linux/inetdevice.h>
21238 +#include <linux/vs_inet.h>
21239 +#include <linux/vs_inet6.h>
21240 +#include <linux/vserver/debug.h>
21241 +#include <net/route.h>
21242 +#include <net/addrconf.h>
21243 +
21244 +
21245 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
21246 +{
21247 +       int ret = 0;
21248 +
21249 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
21250 +               ret = 1;
21251 +       else {
21252 +               struct nx_addr_v4 *ptr;
21253 +
21254 +               for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
21255 +                       if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
21256 +                               ret = 1;
21257 +                               break;
21258 +                       }
21259 +               }
21260 +       }
21261 +
21262 +       vxdprintk(VXD_CBIT(net, 2),
21263 +               "nx_v4_addr_conflict(%p,%p): %d",
21264 +               nxi1, nxi2, ret);
21265 +
21266 +       return ret;
21267 +}
21268 +
21269 +
21270 +#ifdef CONFIG_IPV6
21271 +
21272 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
21273 +{
21274 +       int ret = 0;
21275 +
21276 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
21277 +               ret = 1;
21278 +       else {
21279 +               struct nx_addr_v6 *ptr;
21280 +
21281 +               for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
21282 +                       if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
21283 +                               ret = 1;
21284 +                               break;
21285 +                       }
21286 +               }
21287 +       }
21288 +
21289 +       vxdprintk(VXD_CBIT(net, 2),
21290 +               "nx_v6_addr_conflict(%p,%p): %d",
21291 +               nxi1, nxi2, ret);
21292 +
21293 +       return ret;
21294 +}
21295 +
21296 +#endif
21297 +
21298 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21299 +{
21300 +       struct in_device *in_dev;
21301 +       struct in_ifaddr **ifap;
21302 +       struct in_ifaddr *ifa;
21303 +       int ret = 0;
21304 +
21305 +       if (!dev)
21306 +               goto out;
21307 +       in_dev = in_dev_get(dev);
21308 +       if (!in_dev)
21309 +               goto out;
21310 +
21311 +       for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
21312 +               ifap = &ifa->ifa_next) {
21313 +               if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
21314 +                       ret = 1;
21315 +                       break;
21316 +               }
21317 +       }
21318 +       in_dev_put(in_dev);
21319 +out:
21320 +       return ret;
21321 +}
21322 +
21323 +
21324 +#ifdef CONFIG_IPV6
21325 +
21326 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21327 +{
21328 +       struct inet6_dev *in_dev;
21329 +       struct inet6_ifaddr **ifap;
21330 +       struct inet6_ifaddr *ifa;
21331 +       int ret = 0;
21332 +
21333 +       if (!dev)
21334 +               goto out;
21335 +       in_dev = in6_dev_get(dev);
21336 +       if (!in_dev)
21337 +               goto out;
21338 +
21339 +       for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
21340 +               ifap = &ifa->if_next) {
21341 +               if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
21342 +                       ret = 1;
21343 +                       break;
21344 +               }
21345 +       }
21346 +       in6_dev_put(in_dev);
21347 +out:
21348 +       return ret;
21349 +}
21350 +
21351 +#endif
21352 +
21353 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21354 +{
21355 +       int ret = 1;
21356 +
21357 +       if (!nxi)
21358 +               goto out;
21359 +       if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
21360 +               goto out;
21361 +#ifdef CONFIG_IPV6
21362 +       ret = 2;
21363 +       if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
21364 +               goto out;
21365 +#endif
21366 +       ret = 0;
21367 +out:
21368 +       vxdprintk(VXD_CBIT(net, 3),
21369 +               "dev_in_nx_info(%p,%p[#%d]) = %d",
21370 +               dev, nxi, nxi ? nxi->nx_id : 0, ret);
21371 +       return ret;
21372 +}
21373 +
21374 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
21375 +       struct rtable **rp, struct flowi *fl)
21376 +{
21377 +       if (!nxi)
21378 +               return 0;
21379 +
21380 +       /* FIXME: handle lback only case */
21381 +       if (!NX_IPV4(nxi))
21382 +               return -EPERM;
21383 +
21384 +       vxdprintk(VXD_CBIT(net, 4),
21385 +               "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
21386 +               nxi, nxi ? nxi->nx_id : 0,
21387 +               NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
21388 +
21389 +       /* single IP is unconditional */
21390 +       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
21391 +               (fl->fl4_src == INADDR_ANY))
21392 +               fl->fl4_src = nxi->v4.ip[0].s_addr;
21393 +
21394 +       if (fl->fl4_src == INADDR_ANY) {
21395 +               struct nx_addr_v4 *ptr;
21396 +               __be32 found = 0;
21397 +               int err;
21398 +
21399 +               err = __ip_route_output_key(net, rp, fl);
21400 +               if (!err) {
21401 +                       found = (*rp)->rt_src;
21402 +                       ip_rt_put(*rp);
21403 +                       vxdprintk(VXD_CBIT(net, 4),
21404 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21405 +                               nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
21406 +                       if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
21407 +                               goto found;
21408 +               }
21409 +
21410 +               for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
21411 +                       __be32 primary = ptr->ip[0].s_addr;
21412 +                       __be32 mask = ptr->mask.s_addr;
21413 +                       __be32 neta = primary & mask;
21414 +
21415 +                       vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
21416 +                               NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
21417 +                               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
21418 +                               NIPQUAD(mask), NIPQUAD(neta));
21419 +                       if ((found & mask) != neta)
21420 +                               continue;
21421 +
21422 +                       fl->fl4_src = primary;
21423 +                       err = __ip_route_output_key(net, rp, fl);
21424 +                       vxdprintk(VXD_CBIT(net, 4),
21425 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21426 +                               nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
21427 +                       if (!err) {
21428 +                               found = (*rp)->rt_src;
21429 +                               ip_rt_put(*rp);
21430 +                               if (found == primary)
21431 +                                       goto found;
21432 +                       }
21433 +               }
21434 +               /* still no source ip? */
21435 +               found = ipv4_is_loopback(fl->fl4_dst)
21436 +                       ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
21437 +       found:
21438 +               /* assign src ip to flow */
21439 +               fl->fl4_src = found;
21440 +
21441 +       } else {
21442 +               if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
21443 +                       return -EPERM;
21444 +       }
21445 +
21446 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
21447 +               if (ipv4_is_loopback(fl->fl4_dst))
21448 +                       fl->fl4_dst = nxi->v4_lback.s_addr;
21449 +               if (ipv4_is_loopback(fl->fl4_src))
21450 +                       fl->fl4_src = nxi->v4_lback.s_addr;
21451 +       } else if (ipv4_is_loopback(fl->fl4_dst) &&
21452 +               !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
21453 +               return -EPERM;
21454 +
21455 +       return 0;
21456 +}
21457 +
21458 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
21459 +
21460 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/init.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/init.c
21461 --- linux-2.6.33.2/kernel/vserver/init.c        1970-01-01 01:00:00.000000000 +0100
21462 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/init.c        2010-02-25 12:02:16.000000000 +0100
21463 @@ -0,0 +1,45 @@
21464 +/*
21465 + *  linux/kernel/init.c
21466 + *
21467 + *  Virtual Server Init
21468 + *
21469 + *  Copyright (C) 2004-2007  Herbert Pötzl
21470 + *
21471 + *  V0.01  basic structure
21472 + *
21473 + */
21474 +
21475 +#include <linux/init.h>
21476 +
21477 +int    vserver_register_sysctl(void);
21478 +void   vserver_unregister_sysctl(void);
21479 +
21480 +
21481 +static int __init init_vserver(void)
21482 +{
21483 +       int ret = 0;
21484 +
21485 +#ifdef CONFIG_VSERVER_DEBUG
21486 +       vserver_register_sysctl();
21487 +#endif
21488 +       return ret;
21489 +}
21490 +
21491 +
21492 +static void __exit exit_vserver(void)
21493 +{
21494 +
21495 +#ifdef CONFIG_VSERVER_DEBUG
21496 +       vserver_unregister_sysctl();
21497 +#endif
21498 +       return;
21499 +}
21500 +
21501 +/* FIXME: GFP_ZONETYPES gone
21502 +long vx_slab[GFP_ZONETYPES]; */
21503 +long vx_area;
21504 +
21505 +
21506 +module_init(init_vserver);
21507 +module_exit(exit_vserver);
21508 +
21509 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/inode.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/inode.c
21510 --- linux-2.6.33.2/kernel/vserver/inode.c       1970-01-01 01:00:00.000000000 +0100
21511 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/inode.c       2010-02-25 12:02:16.000000000 +0100
21512 @@ -0,0 +1,433 @@
21513 +/*
21514 + *  linux/kernel/vserver/inode.c
21515 + *
21516 + *  Virtual Server: File System Support
21517 + *
21518 + *  Copyright (C) 2004-2007  Herbert Pötzl
21519 + *
21520 + *  V0.01  separated from vcontext V0.05
21521 + *  V0.02  moved to tag (instead of xid)
21522 + *
21523 + */
21524 +
21525 +#include <linux/tty.h>
21526 +#include <linux/proc_fs.h>
21527 +#include <linux/devpts_fs.h>
21528 +#include <linux/fs.h>
21529 +#include <linux/file.h>
21530 +#include <linux/mount.h>
21531 +#include <linux/parser.h>
21532 +#include <linux/namei.h>
21533 +#include <linux/vserver/inode.h>
21534 +#include <linux/vserver/inode_cmd.h>
21535 +#include <linux/vs_base.h>
21536 +#include <linux/vs_tag.h>
21537 +
21538 +#include <asm/uaccess.h>
21539 +
21540 +
21541 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21542 +{
21543 +       struct proc_dir_entry *entry;
21544 +
21545 +       if (!in || !in->i_sb)
21546 +               return -ESRCH;
21547 +
21548 +       *flags = IATTR_TAG
21549 +               | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21550 +               | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21551 +               | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21552 +               | (IS_COW(in) ? IATTR_COW : 0);
21553 +       *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21554 +
21555 +       if (S_ISDIR(in->i_mode))
21556 +               *mask |= IATTR_BARRIER;
21557 +
21558 +       if (IS_TAGGED(in)) {
21559 +               *tag = in->i_tag;
21560 +               *mask |= IATTR_TAG;
21561 +       }
21562 +
21563 +       switch (in->i_sb->s_magic) {
21564 +       case PROC_SUPER_MAGIC:
21565 +               entry = PROC_I(in)->pde;
21566 +
21567 +               /* check for specific inodes? */
21568 +               if (entry)
21569 +                       *mask |= IATTR_FLAGS;
21570 +               if (entry)
21571 +                       *flags |= (entry->vx_flags & IATTR_FLAGS);
21572 +               else
21573 +                       *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21574 +               break;
21575 +
21576 +       case DEVPTS_SUPER_MAGIC:
21577 +               *tag = in->i_tag;
21578 +               *mask |= IATTR_TAG;
21579 +               break;
21580 +
21581 +       default:
21582 +               break;
21583 +       }
21584 +       return 0;
21585 +}
21586 +
21587 +int vc_get_iattr(void __user *data)
21588 +{
21589 +       struct path path;
21590 +       struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21591 +       int ret;
21592 +
21593 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21594 +               return -EFAULT;
21595 +
21596 +       ret = user_lpath(vc_data.name, &path);
21597 +       if (!ret) {
21598 +               ret = __vc_get_iattr(path.dentry->d_inode,
21599 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21600 +               path_put(&path);
21601 +       }
21602 +       if (ret)
21603 +               return ret;
21604 +
21605 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21606 +               ret = -EFAULT;
21607 +       return ret;
21608 +}
21609 +
21610 +#ifdef CONFIG_COMPAT
21611 +
21612 +int vc_get_iattr_x32(void __user *data)
21613 +{
21614 +       struct path path;
21615 +       struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21616 +       int ret;
21617 +
21618 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21619 +               return -EFAULT;
21620 +
21621 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21622 +       if (!ret) {
21623 +               ret = __vc_get_iattr(path.dentry->d_inode,
21624 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21625 +               path_put(&path);
21626 +       }
21627 +       if (ret)
21628 +               return ret;
21629 +
21630 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21631 +               ret = -EFAULT;
21632 +       return ret;
21633 +}
21634 +
21635 +#endif /* CONFIG_COMPAT */
21636 +
21637 +
21638 +int vc_fget_iattr(uint32_t fd, void __user *data)
21639 +{
21640 +       struct file *filp;
21641 +       struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21642 +       int ret;
21643 +
21644 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21645 +               return -EFAULT;
21646 +
21647 +       filp = fget(fd);
21648 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21649 +               return -EBADF;
21650 +
21651 +       ret = __vc_get_iattr(filp->f_dentry->d_inode,
21652 +               &vc_data.tag, &vc_data.flags, &vc_data.mask);
21653 +
21654 +       fput(filp);
21655 +
21656 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21657 +               ret = -EFAULT;
21658 +       return ret;
21659 +}
21660 +
21661 +
21662 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21663 +{
21664 +       struct inode *in = de->d_inode;
21665 +       int error = 0, is_proc = 0, has_tag = 0;
21666 +       struct iattr attr = { 0 };
21667 +
21668 +       if (!in || !in->i_sb)
21669 +               return -ESRCH;
21670 +
21671 +       is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21672 +       if ((*mask & IATTR_FLAGS) && !is_proc)
21673 +               return -EINVAL;
21674 +
21675 +       has_tag = IS_TAGGED(in) ||
21676 +               (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21677 +       if ((*mask & IATTR_TAG) && !has_tag)
21678 +               return -EINVAL;
21679 +
21680 +       mutex_lock(&in->i_mutex);
21681 +       if (*mask & IATTR_TAG) {
21682 +               attr.ia_tag = *tag;
21683 +               attr.ia_valid |= ATTR_TAG;
21684 +       }
21685 +
21686 +       if (*mask & IATTR_FLAGS) {
21687 +               struct proc_dir_entry *entry = PROC_I(in)->pde;
21688 +               unsigned int iflags = PROC_I(in)->vx_flags;
21689 +
21690 +               iflags = (iflags & ~(*mask & IATTR_FLAGS))
21691 +                       | (*flags & IATTR_FLAGS);
21692 +               PROC_I(in)->vx_flags = iflags;
21693 +               if (entry)
21694 +                       entry->vx_flags = iflags;
21695 +       }
21696 +
21697 +       if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21698 +               IATTR_BARRIER | IATTR_COW)) {
21699 +               int iflags = in->i_flags;
21700 +               int vflags = in->i_vflags;
21701 +
21702 +               if (*mask & IATTR_IMMUTABLE) {
21703 +                       if (*flags & IATTR_IMMUTABLE)
21704 +                               iflags |= S_IMMUTABLE;
21705 +                       else
21706 +                               iflags &= ~S_IMMUTABLE;
21707 +               }
21708 +               if (*mask & IATTR_IXUNLINK) {
21709 +                       if (*flags & IATTR_IXUNLINK)
21710 +                               iflags |= S_IXUNLINK;
21711 +                       else
21712 +                               iflags &= ~S_IXUNLINK;
21713 +               }
21714 +               if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21715 +                       if (*flags & IATTR_BARRIER)
21716 +                               vflags |= V_BARRIER;
21717 +                       else
21718 +                               vflags &= ~V_BARRIER;
21719 +               }
21720 +               if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21721 +                       if (*flags & IATTR_COW)
21722 +                               vflags |= V_COW;
21723 +                       else
21724 +                               vflags &= ~V_COW;
21725 +               }
21726 +               if (in->i_op && in->i_op->sync_flags) {
21727 +                       error = in->i_op->sync_flags(in, iflags, vflags);
21728 +                       if (error)
21729 +                               goto out;
21730 +               }
21731 +       }
21732 +
21733 +       if (attr.ia_valid) {
21734 +               if (in->i_op && in->i_op->setattr)
21735 +                       error = in->i_op->setattr(de, &attr);
21736 +               else {
21737 +                       error = inode_change_ok(in, &attr);
21738 +                       if (!error)
21739 +                               error = inode_setattr(in, &attr);
21740 +               }
21741 +       }
21742 +
21743 +out:
21744 +       mutex_unlock(&in->i_mutex);
21745 +       return error;
21746 +}
21747 +
21748 +int vc_set_iattr(void __user *data)
21749 +{
21750 +       struct path path;
21751 +       struct vcmd_ctx_iattr_v1 vc_data;
21752 +       int ret;
21753 +
21754 +       if (!capable(CAP_LINUX_IMMUTABLE))
21755 +               return -EPERM;
21756 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21757 +               return -EFAULT;
21758 +
21759 +       ret = user_lpath(vc_data.name, &path);
21760 +       if (!ret) {
21761 +               ret = __vc_set_iattr(path.dentry,
21762 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21763 +               path_put(&path);
21764 +       }
21765 +
21766 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21767 +               ret = -EFAULT;
21768 +       return ret;
21769 +}
21770 +
21771 +#ifdef CONFIG_COMPAT
21772 +
21773 +int vc_set_iattr_x32(void __user *data)
21774 +{
21775 +       struct path path;
21776 +       struct vcmd_ctx_iattr_v1_x32 vc_data;
21777 +       int ret;
21778 +
21779 +       if (!capable(CAP_LINUX_IMMUTABLE))
21780 +               return -EPERM;
21781 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21782 +               return -EFAULT;
21783 +
21784 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21785 +       if (!ret) {
21786 +               ret = __vc_set_iattr(path.dentry,
21787 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21788 +               path_put(&path);
21789 +       }
21790 +
21791 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21792 +               ret = -EFAULT;
21793 +       return ret;
21794 +}
21795 +
21796 +#endif /* CONFIG_COMPAT */
21797 +
21798 +int vc_fset_iattr(uint32_t fd, void __user *data)
21799 +{
21800 +       struct file *filp;
21801 +       struct vcmd_ctx_fiattr_v0 vc_data;
21802 +       int ret;
21803 +
21804 +       if (!capable(CAP_LINUX_IMMUTABLE))
21805 +               return -EPERM;
21806 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21807 +               return -EFAULT;
21808 +
21809 +       filp = fget(fd);
21810 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21811 +               return -EBADF;
21812 +
21813 +       ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21814 +               &vc_data.flags, &vc_data.mask);
21815 +
21816 +       fput(filp);
21817 +
21818 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21819 +               return -EFAULT;
21820 +       return ret;
21821 +}
21822 +
21823 +
21824 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21825 +
21826 +static match_table_t tokens = {
21827 +       {Opt_notagcheck, "notagcheck"},
21828 +#ifdef CONFIG_PROPAGATE
21829 +       {Opt_notag, "notag"},
21830 +       {Opt_tag, "tag"},
21831 +       {Opt_tagid, "tagid=%u"},
21832 +#endif
21833 +       {Opt_err, NULL}
21834 +};
21835 +
21836 +
21837 +static void __dx_parse_remove(char *string, char *opt)
21838 +{
21839 +       char *p = strstr(string, opt);
21840 +       char *q = p;
21841 +
21842 +       if (p) {
21843 +               while (*q != '\0' && *q != ',')
21844 +                       q++;
21845 +               while (*q)
21846 +                       *p++ = *q++;
21847 +               while (*p)
21848 +                       *p++ = '\0';
21849 +       }
21850 +}
21851 +
21852 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21853 +                unsigned long *flags)
21854 +{
21855 +       int set = 0;
21856 +       substring_t args[MAX_OPT_ARGS];
21857 +       int token, option = 0;
21858 +       char *s, *p, *opts;
21859 +
21860 +       if (!string)
21861 +               return 0;
21862 +       s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21863 +       if (!s)
21864 +               return 0;
21865 +
21866 +       opts = s;
21867 +       while ((p = strsep(&opts, ",")) != NULL) {
21868 +               token = match_token(p, tokens, args);
21869 +
21870 +               vxdprintk(VXD_CBIT(tag, 7),
21871 +                       "dx_parse_tag(»%s«): %d:#%d",
21872 +                       p, token, option);
21873 +
21874 +               switch (token) {
21875 +#ifdef CONFIG_PROPAGATE
21876 +               case Opt_tag:
21877 +                       if (tag)
21878 +                               *tag = 0;
21879 +                       if (remove)
21880 +                               __dx_parse_remove(s, "tag");
21881 +                       *mnt_flags |= MNT_TAGID;
21882 +                       set |= MNT_TAGID;
21883 +                       break;
21884 +               case Opt_notag:
21885 +                       if (remove)
21886 +                               __dx_parse_remove(s, "notag");
21887 +                       *mnt_flags |= MNT_NOTAG;
21888 +                       set |= MNT_NOTAG;
21889 +                       break;
21890 +               case Opt_tagid:
21891 +                       if (tag && !match_int(args, &option))
21892 +                               *tag = option;
21893 +                       if (remove)
21894 +                               __dx_parse_remove(s, "tagid");
21895 +                       *mnt_flags |= MNT_TAGID;
21896 +                       set |= MNT_TAGID;
21897 +                       break;
21898 +#endif
21899 +               case Opt_notagcheck:
21900 +                       if (remove)
21901 +                               __dx_parse_remove(s, "notagcheck");
21902 +                       *flags |= MS_NOTAGCHECK;
21903 +                       set |= MS_NOTAGCHECK;
21904 +                       break;
21905 +               }
21906 +       }
21907 +       if (set)
21908 +               strcpy(string, s);
21909 +       kfree(s);
21910 +       return set;
21911 +}
21912 +
21913 +#ifdef CONFIG_PROPAGATE
21914 +
21915 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21916 +{
21917 +       tag_t new_tag = 0;
21918 +       struct vfsmount *mnt;
21919 +       int propagate;
21920 +
21921 +       if (!nd)
21922 +               return;
21923 +       mnt = nd->path.mnt;
21924 +       if (!mnt)
21925 +               return;
21926 +
21927 +       propagate = (mnt->mnt_flags & MNT_TAGID);
21928 +       if (propagate)
21929 +               new_tag = mnt->mnt_tag;
21930 +
21931 +       vxdprintk(VXD_CBIT(tag, 7),
21932 +               "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21933 +               inode, inode->i_ino, inode->i_tag,
21934 +               new_tag, (propagate) ? 1 : 0);
21935 +
21936 +       if (propagate)
21937 +               inode->i_tag = new_tag;
21938 +}
21939 +
21940 +#include <linux/module.h>
21941 +
21942 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21943 +
21944 +#endif /* CONFIG_PROPAGATE */
21945 +
21946 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/Kconfig
21947 --- linux-2.6.33.2/kernel/vserver/Kconfig       1970-01-01 01:00:00.000000000 +0100
21948 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/Kconfig       2010-02-25 12:02:16.000000000 +0100
21949 @@ -0,0 +1,251 @@
21950 +#
21951 +# Linux VServer configuration
21952 +#
21953 +
21954 +menu "Linux VServer"
21955 +
21956 +config VSERVER_AUTO_LBACK
21957 +       bool    "Automatically Assign Loopback IP"
21958 +       default y
21959 +       help
21960 +         Automatically assign a guest specific loopback
21961 +         IP and add it to the kernel network stack on
21962 +         startup.
21963 +
21964 +config VSERVER_AUTO_SINGLE
21965 +       bool    "Automatic Single IP Special Casing"
21966 +       depends on EXPERIMENTAL
21967 +       default y
21968 +       help
21969 +         This allows network contexts with a single IP to
21970 +         automatically remap 0.0.0.0 bindings to that IP,
21971 +         avoiding further network checks and improving
21972 +         performance.
21973 +
21974 +         (note: such guests do not allow to change the ip
21975 +          on the fly and do not show loopback addresses)
21976 +
21977 +config VSERVER_COWBL
21978 +       bool    "Enable COW Immutable Link Breaking"
21979 +       default y
21980 +       help
21981 +         This enables the COW (Copy-On-Write) link break code.
21982 +         It allows you to treat unified files like normal files
21983 +         when writing to them (which will implicitely break the
21984 +         link and create a copy of the unified file)
21985 +
21986 +config VSERVER_VTIME
21987 +       bool    "Enable Virtualized Guest Time"
21988 +       depends on EXPERIMENTAL
21989 +       default n
21990 +       help
21991 +         This enables per guest time offsets to allow for
21992 +         adjusting the system clock individually per guest.
21993 +         this adds some overhead to the time functions and
21994 +         therefore should not be enabled without good reason.
21995 +
21996 +config VSERVER_DEVICE
21997 +       bool    "Enable Guest Device Mapping"
21998 +       depends on EXPERIMENTAL
21999 +       default n
22000 +       help
22001 +         This enables generic device remapping.
22002 +
22003 +config VSERVER_PROC_SECURE
22004 +       bool    "Enable Proc Security"
22005 +       depends on PROC_FS
22006 +       default y
22007 +       help
22008 +         This configures ProcFS security to initially hide
22009 +         non-process entries for all contexts except the main and
22010 +         spectator context (i.e. for all guests), which is a secure
22011 +         default.
22012 +
22013 +         (note: on 1.2x the entries were visible by default)
22014 +
22015 +config VSERVER_HARDCPU
22016 +       bool    "Enable Hard CPU Limits"
22017 +       default y
22018 +       help
22019 +         Activate the Hard CPU Limits
22020 +
22021 +         This will compile in code that allows the Token Bucket
22022 +         Scheduler to put processes on hold when a context's
22023 +         tokens are depleted (provided that its per-context
22024 +         sched_hard flag is set).
22025 +
22026 +         Processes belonging to that context will not be able
22027 +         to consume CPU resources again until a per-context
22028 +         configured minimum of tokens has been reached.
22029 +
22030 +config VSERVER_IDLETIME
22031 +       bool    "Avoid idle CPUs by skipping Time"
22032 +       depends on VSERVER_HARDCPU
22033 +       default y
22034 +       help
22035 +         This option allows the scheduler to artificially
22036 +         advance time (per cpu) when otherwise the idle
22037 +         task would be scheduled, thus keeping the cpu
22038 +         busy and sharing the available resources among
22039 +         certain contexts.
22040 +
22041 +config VSERVER_IDLELIMIT
22042 +       bool    "Limit the IDLE task"
22043 +       depends on VSERVER_HARDCPU
22044 +       default n
22045 +       help
22046 +         Limit the idle slices, so the the next context
22047 +         will be scheduled as soon as possible.
22048 +
22049 +         This might improve interactivity and latency, but
22050 +         will also marginally increase scheduling overhead.
22051 +
22052 +choice
22053 +       prompt  "Persistent Inode Tagging"
22054 +       default TAGGING_ID24
22055 +       help
22056 +         This adds persistent context information to filesystems
22057 +         mounted with the tagxid option. Tagging is a requirement
22058 +         for per-context disk limits and per-context quota.
22059 +
22060 +
22061 +config TAGGING_NONE
22062 +       bool    "Disabled"
22063 +       help
22064 +         do not store per-context information in inodes.
22065 +
22066 +config TAGGING_UID16
22067 +       bool    "UID16/GID32"
22068 +       help
22069 +         reduces UID to 16 bit, but leaves GID at 32 bit.
22070 +
22071 +config TAGGING_GID16
22072 +       bool    "UID32/GID16"
22073 +       help
22074 +         reduces GID to 16 bit, but leaves UID at 32 bit.
22075 +
22076 +config TAGGING_ID24
22077 +       bool    "UID24/GID24"
22078 +       help
22079 +         uses the upper 8bit from UID and GID for XID tagging
22080 +         which leaves 24bit for UID/GID each, which should be
22081 +         more than sufficient for normal use.
22082 +
22083 +config TAGGING_INTERN
22084 +       bool    "UID32/GID32"
22085 +       help
22086 +         this uses otherwise reserved inode fields in the on
22087 +         disk representation, which limits the use to a few
22088 +         filesystems (currently ext2 and ext3)
22089 +
22090 +endchoice
22091 +
22092 +config TAG_NFSD
22093 +       bool    "Tag NFSD User Auth and Files"
22094 +       default n
22095 +       help
22096 +         Enable this if you do want the in-kernel NFS
22097 +         Server to use the tagging specified above.
22098 +         (will require patched clients too)
22099 +
22100 +config VSERVER_PRIVACY
22101 +       bool    "Honor Privacy Aspects of Guests"
22102 +       default n
22103 +       help
22104 +         When enabled, most context checks will disallow
22105 +         access to structures assigned to a specific context,
22106 +         like ptys or loop devices.
22107 +
22108 +config VSERVER_CONTEXTS
22109 +       int     "Maximum number of Contexts (1-65533)"  if EMBEDDED
22110 +       range 1 65533
22111 +       default "768"   if 64BIT
22112 +       default "256"
22113 +       help
22114 +         This setting will optimize certain data structures
22115 +         and memory allocations according to the expected
22116 +         maximum.
22117 +
22118 +         note: this is not a strict upper limit.
22119 +
22120 +config VSERVER_WARN
22121 +       bool    "VServer Warnings"
22122 +       default y
22123 +       help
22124 +         This enables various runtime warnings, which will
22125 +         notify about potential manipulation attempts or
22126 +         resource shortage. It is generally considered to
22127 +         be a good idea to have that enabled.
22128 +
22129 +config VSERVER_DEBUG
22130 +       bool    "VServer Debugging Code"
22131 +       default n
22132 +       help
22133 +         Set this to yes if you want to be able to activate
22134 +         debugging output at runtime. It adds a very small
22135 +         overhead to all vserver related functions and
22136 +         increases the kernel size by about 20k.
22137 +
22138 +config VSERVER_HISTORY
22139 +       bool    "VServer History Tracing"
22140 +       depends on VSERVER_DEBUG
22141 +       default n
22142 +       help
22143 +         Set this to yes if you want to record the history of
22144 +         linux-vserver activities, so they can be replayed in
22145 +         the event of a kernel panic or oops.
22146 +
22147 +config VSERVER_HISTORY_SIZE
22148 +       int     "Per-CPU History Size (32-65536)"
22149 +       depends on VSERVER_HISTORY
22150 +       range 32 65536
22151 +       default 64
22152 +       help
22153 +         This allows you to specify the number of entries in
22154 +         the per-CPU history buffer.
22155 +
22156 +config VSERVER_MONITOR
22157 +       bool    "VServer Scheduling Monitor"
22158 +       depends on VSERVER_DISABLED
22159 +       default n
22160 +       help
22161 +         Set this to yes if you want to record the scheduling
22162 +         decisions, so that they can be relayed to userspace
22163 +         for detailed analysis.
22164 +
22165 +config VSERVER_MONITOR_SIZE
22166 +       int     "Per-CPU Monitor Queue Size (32-65536)"
22167 +       depends on VSERVER_MONITOR
22168 +       range 32 65536
22169 +       default 1024
22170 +       help
22171 +         This allows you to specify the number of entries in
22172 +         the per-CPU scheduling monitor buffer.
22173 +
22174 +config VSERVER_MONITOR_SYNC
22175 +       int     "Per-CPU Monitor Sync Interval (0-65536)"
22176 +       depends on VSERVER_MONITOR
22177 +       range 0 65536
22178 +       default 256
22179 +       help
22180 +         This allows you to specify the interval in ticks
22181 +         when a time sync entry is inserted.
22182 +
22183 +endmenu
22184 +
22185 +
22186 +config VSERVER
22187 +       bool
22188 +       default y
22189 +       select NAMESPACES
22190 +       select UTS_NS
22191 +       select IPC_NS
22192 +       select USER_NS
22193 +       select SYSVIPC
22194 +
22195 +config VSERVER_SECURITY
22196 +       bool
22197 +       depends on SECURITY
22198 +       default y
22199 +       select SECURITY_CAPABILITIES
22200 +
22201 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/limit.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/limit.c
22202 --- linux-2.6.33.2/kernel/vserver/limit.c       1970-01-01 01:00:00.000000000 +0100
22203 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/limit.c       2010-03-23 19:51:30.000000000 +0100
22204 @@ -0,0 +1,392 @@
22205 +/*
22206 + *  linux/kernel/vserver/limit.c
22207 + *
22208 + *  Virtual Server: Context Limits
22209 + *
22210 + *  Copyright (C) 2004-2010  Herbert Pötzl
22211 + *
22212 + *  V0.01  broken out from vcontext V0.05
22213 + *  V0.02  changed vcmds to vxi arg
22214 + *  V0.03  added memory cgroup support
22215 + *
22216 + */
22217 +
22218 +#include <linux/sched.h>
22219 +#include <linux/module.h>
22220 +#include <linux/memcontrol.h>
22221 +#include <linux/res_counter.h>
22222 +#include <linux/vs_limit.h>
22223 +#include <linux/vserver/limit.h>
22224 +#include <linux/vserver/limit_cmd.h>
22225 +
22226 +#include <asm/uaccess.h>
22227 +
22228 +
22229 +const char *vlimit_name[NUM_LIMITS] = {
22230 +       [RLIMIT_CPU]            = "CPU",
22231 +       [RLIMIT_RSS]            = "RSS",
22232 +       [RLIMIT_NPROC]          = "NPROC",
22233 +       [RLIMIT_NOFILE]         = "NOFILE",
22234 +       [RLIMIT_MEMLOCK]        = "VML",
22235 +       [RLIMIT_AS]             = "VM",
22236 +       [RLIMIT_LOCKS]          = "LOCKS",
22237 +       [RLIMIT_SIGPENDING]     = "SIGP",
22238 +       [RLIMIT_MSGQUEUE]       = "MSGQ",
22239 +
22240 +       [VLIMIT_NSOCK]          = "NSOCK",
22241 +       [VLIMIT_OPENFD]         = "OPENFD",
22242 +       [VLIMIT_ANON]           = "ANON",
22243 +       [VLIMIT_SHMEM]          = "SHMEM",
22244 +       [VLIMIT_DENTRY]         = "DENTRY",
22245 +};
22246 +
22247 +EXPORT_SYMBOL_GPL(vlimit_name);
22248 +
22249 +#define MASK_ENTRY(x)  (1 << (x))
22250 +
22251 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
22252 +               /* minimum */
22253 +       0
22254 +       ,       /* softlimit */
22255 +       MASK_ENTRY( RLIMIT_RSS          ) |
22256 +       MASK_ENTRY( VLIMIT_ANON         ) |
22257 +       0
22258 +       ,       /* maximum */
22259 +       MASK_ENTRY( RLIMIT_RSS          ) |
22260 +       MASK_ENTRY( RLIMIT_NPROC        ) |
22261 +       MASK_ENTRY( RLIMIT_NOFILE       ) |
22262 +       MASK_ENTRY( RLIMIT_MEMLOCK      ) |
22263 +       MASK_ENTRY( RLIMIT_AS           ) |
22264 +       MASK_ENTRY( RLIMIT_LOCKS        ) |
22265 +       MASK_ENTRY( RLIMIT_MSGQUEUE     ) |
22266 +
22267 +       MASK_ENTRY( VLIMIT_NSOCK        ) |
22268 +       MASK_ENTRY( VLIMIT_OPENFD       ) |
22269 +       MASK_ENTRY( VLIMIT_ANON         ) |
22270 +       MASK_ENTRY( VLIMIT_SHMEM        ) |
22271 +       MASK_ENTRY( VLIMIT_DENTRY       ) |
22272 +       0
22273 +};
22274 +               /* accounting only */
22275 +uint32_t account_mask =
22276 +       MASK_ENTRY( VLIMIT_SEMARY       ) |
22277 +       MASK_ENTRY( VLIMIT_NSEMS        ) |
22278 +       MASK_ENTRY( VLIMIT_MAPPED       ) |
22279 +       0;
22280 +
22281 +
22282 +static int is_valid_vlimit(int id)
22283 +{
22284 +       uint32_t mask = vlimit_mask.minimum |
22285 +               vlimit_mask.softlimit | vlimit_mask.maximum;
22286 +       return mask & (1 << id);
22287 +}
22288 +
22289 +static int is_accounted_vlimit(int id)
22290 +{
22291 +       if (is_valid_vlimit(id))
22292 +               return 1;
22293 +       return account_mask & (1 << id);
22294 +}
22295 +
22296 +
22297 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
22298 +{
22299 +       rlim_t limit = __rlim_soft(&vxi->limit, id);
22300 +       return VX_VLIM(limit);
22301 +}
22302 +
22303 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
22304 +{
22305 +       rlim_t limit = __rlim_hard(&vxi->limit, id);
22306 +       return VX_VLIM(limit);
22307 +}
22308 +
22309 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
22310 +       uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
22311 +{
22312 +       if (!is_valid_vlimit(id))
22313 +               return -EINVAL;
22314 +
22315 +       if (minimum)
22316 +               *minimum = CRLIM_UNSET;
22317 +       if (softlimit)
22318 +               *softlimit = vc_get_soft(vxi, id);
22319 +       if (maximum)
22320 +               *maximum = vc_get_hard(vxi, id);
22321 +       return 0;
22322 +}
22323 +
22324 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
22325 +{
22326 +       struct vcmd_ctx_rlimit_v0 vc_data;
22327 +       int ret;
22328 +
22329 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22330 +               return -EFAULT;
22331 +
22332 +       ret = do_get_rlimit(vxi, vc_data.id,
22333 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22334 +       if (ret)
22335 +               return ret;
22336 +
22337 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22338 +               return -EFAULT;
22339 +       return 0;
22340 +}
22341 +
22342 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
22343 +       uint64_t minimum, uint64_t softlimit, uint64_t maximum)
22344 +{
22345 +       if (!is_valid_vlimit(id))
22346 +               return -EINVAL;
22347 +
22348 +       if (maximum != CRLIM_KEEP)
22349 +               __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
22350 +       if (softlimit != CRLIM_KEEP)
22351 +               __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
22352 +
22353 +       /* clamp soft limit */
22354 +       if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
22355 +               __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
22356 +
22357 +       return 0;
22358 +}
22359 +
22360 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
22361 +{
22362 +       struct vcmd_ctx_rlimit_v0 vc_data;
22363 +
22364 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22365 +               return -EFAULT;
22366 +
22367 +       return do_set_rlimit(vxi, vc_data.id,
22368 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22369 +}
22370 +
22371 +#ifdef CONFIG_IA32_EMULATION
22372 +
22373 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
22374 +{
22375 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
22376 +
22377 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22378 +               return -EFAULT;
22379 +
22380 +       return do_set_rlimit(vxi, vc_data.id,
22381 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22382 +}
22383 +
22384 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
22385 +{
22386 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
22387 +       int ret;
22388 +
22389 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22390 +               return -EFAULT;
22391 +
22392 +       ret = do_get_rlimit(vxi, vc_data.id,
22393 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22394 +       if (ret)
22395 +               return ret;
22396 +
22397 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22398 +               return -EFAULT;
22399 +       return 0;
22400 +}
22401 +
22402 +#endif /* CONFIG_IA32_EMULATION */
22403 +
22404 +
22405 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
22406 +{
22407 +       if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
22408 +               return -EFAULT;
22409 +       return 0;
22410 +}
22411 +
22412 +
22413 +static inline void vx_reset_hits(struct _vx_limit *limit)
22414 +{
22415 +       int lim;
22416 +
22417 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22418 +               atomic_set(&__rlim_lhit(limit, lim), 0);
22419 +       }
22420 +}
22421 +
22422 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
22423 +{
22424 +       vx_reset_hits(&vxi->limit);
22425 +       return 0;
22426 +}
22427 +
22428 +static inline void vx_reset_minmax(struct _vx_limit *limit)
22429 +{
22430 +       rlim_t value;
22431 +       int lim;
22432 +
22433 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22434 +               value = __rlim_get(limit, lim);
22435 +               __rlim_rmax(limit, lim) = value;
22436 +               __rlim_rmin(limit, lim) = value;
22437 +       }
22438 +}
22439 +
22440 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
22441 +{
22442 +       vx_reset_minmax(&vxi->limit);
22443 +       return 0;
22444 +}
22445 +
22446 +
22447 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
22448 +{
22449 +       struct vcmd_rlimit_stat_v0 vc_data;
22450 +       struct _vx_limit *limit = &vxi->limit;
22451 +       int id;
22452 +
22453 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22454 +               return -EFAULT;
22455 +
22456 +       id = vc_data.id;
22457 +       if (!is_accounted_vlimit(id))
22458 +               return -EINVAL;
22459 +
22460 +       vx_limit_fixup(limit, id);
22461 +       vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
22462 +       vc_data.value = __rlim_get(limit, id);
22463 +       vc_data.minimum = __rlim_rmin(limit, id);
22464 +       vc_data.maximum = __rlim_rmax(limit, id);
22465 +
22466 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22467 +               return -EFAULT;
22468 +       return 0;
22469 +}
22470 +
22471 +
22472 +void vx_vsi_meminfo(struct sysinfo *val)
22473 +{
22474 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22475 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22476 +       u64 res_limit, res_usage;
22477 +
22478 +       if (!mcg)
22479 +               return;
22480 +
22481 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22482 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22483 +
22484 +       if (res_limit != RESOURCE_MAX)
22485 +               val->totalram = (res_limit >> PAGE_SHIFT);
22486 +       val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
22487 +       val->bufferram = 0;
22488 +#else  /* !CONFIG_CGROUP_MEM_RES_CTLR */
22489 +       struct vx_info *vxi = current_vx_info();
22490 +       unsigned long totalram, freeram;
22491 +       rlim_t v;
22492 +
22493 +       /* we blindly accept the max */
22494 +       v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22495 +       totalram = (v != RLIM_INFINITY) ? v : val->totalram;
22496 +
22497 +       /* total minus used equals free */
22498 +       v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22499 +       freeram = (v < totalram) ? totalram - v : 0;
22500 +
22501 +       val->totalram = totalram;
22502 +       val->freeram = freeram;
22503 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22504 +       val->totalhigh = 0;
22505 +       val->freehigh = 0;
22506 +       return;
22507 +}
22508 +
22509 +void vx_vsi_swapinfo(struct sysinfo *val)
22510 +{
22511 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22512 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
22513 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22514 +       u64 res_limit, res_usage, memsw_limit, memsw_usage;
22515 +       s64 swap_limit, swap_usage;
22516 +
22517 +       if (!mcg)
22518 +               return;
22519 +
22520 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22521 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22522 +       memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
22523 +       memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
22524 +
22525 +       if (res_limit == RESOURCE_MAX)
22526 +               return;
22527 +
22528 +       swap_limit = memsw_limit - res_limit;
22529 +       if (memsw_limit != RESOURCE_MAX)
22530 +               val->totalswap = swap_limit >> PAGE_SHIFT;
22531 +
22532 +       swap_usage = memsw_usage - res_usage;
22533 +       val->freeswap = (swap_usage < swap_limit) ?
22534 +               val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
22535 +#else  /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22536 +       val->totalswap = 0;
22537 +       val->freeswap = 0;
22538 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22539 +#else  /* !CONFIG_CGROUP_MEM_RES_CTLR */
22540 +       struct vx_info *vxi = current_vx_info();
22541 +       unsigned long totalswap, freeswap;
22542 +       rlim_t v, w;
22543 +
22544 +       v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22545 +       if (v == RLIM_INFINITY) {
22546 +               val->freeswap = val->totalswap;
22547 +               return;
22548 +       }
22549 +
22550 +       /* we blindly accept the max */
22551 +       w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
22552 +       totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
22553 +
22554 +       /* currently 'used' swap */
22555 +       w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22556 +       w -= (w > v) ? v : w;
22557 +
22558 +       /* total minus used equals free */
22559 +       freeswap = (w < totalswap) ? totalswap - w : 0;
22560 +
22561 +       val->totalswap = totalswap;
22562 +       val->freeswap = freeswap;
22563 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22564 +       return;
22565 +}
22566 +
22567 +long vx_vsi_cached(struct sysinfo *val)
22568 +{
22569 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22570 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22571 +
22572 +       return mem_cgroup_stat_read_cache(mcg);
22573 +#else
22574 +       return 0;
22575 +#endif
22576 +}
22577 +
22578 +
22579 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22580 +{
22581 +       struct vx_info *vxi = mm->mm_vx_info;
22582 +       unsigned long points;
22583 +       rlim_t v, w;
22584 +
22585 +       if (!vxi)
22586 +               return 0;
22587 +
22588 +       points = vxi->vx_badness_bias;
22589 +
22590 +       v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22591 +       w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22592 +       points += (v > w) ? (v - w) : 0;
22593 +
22594 +       return points;
22595 +}
22596 +
22597 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/limit_init.h linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/limit_init.h
22598 --- linux-2.6.33.2/kernel/vserver/limit_init.h  1970-01-01 01:00:00.000000000 +0100
22599 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/limit_init.h  2010-02-25 12:02:16.000000000 +0100
22600 @@ -0,0 +1,31 @@
22601 +
22602 +
22603 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22604 +{
22605 +       int lim;
22606 +
22607 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22608 +               __rlim_soft(limit, lim) = RLIM_INFINITY;
22609 +               __rlim_hard(limit, lim) = RLIM_INFINITY;
22610 +               __rlim_set(limit, lim, 0);
22611 +               atomic_set(&__rlim_lhit(limit, lim), 0);
22612 +               __rlim_rmin(limit, lim) = 0;
22613 +               __rlim_rmax(limit, lim) = 0;
22614 +       }
22615 +}
22616 +
22617 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22618 +{
22619 +       rlim_t value;
22620 +       int lim;
22621 +
22622 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22623 +               if ((1 << lim) & VLIM_NOCHECK)
22624 +                       continue;
22625 +               value = __rlim_get(limit, lim);
22626 +               vxwprintk_xid(value,
22627 +                       "!!! limit: %p[%s,%d] = %ld on exit.",
22628 +                       limit, vlimit_name[lim], lim, (long)value);
22629 +       }
22630 +}
22631 +
22632 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/limit_proc.h linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/limit_proc.h
22633 --- linux-2.6.33.2/kernel/vserver/limit_proc.h  1970-01-01 01:00:00.000000000 +0100
22634 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/limit_proc.h  2010-02-25 12:02:16.000000000 +0100
22635 @@ -0,0 +1,57 @@
22636 +#ifndef _VX_LIMIT_PROC_H
22637 +#define _VX_LIMIT_PROC_H
22638 +
22639 +#include <linux/vserver/limit_int.h>
22640 +
22641 +
22642 +#define VX_LIMIT_FMT   ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22643 +#define VX_LIMIT_TOP   \
22644 +       "Limit\t current\t     min/max\t\t    soft/hard\t\thits\n"
22645 +
22646 +#define VX_LIMIT_ARG(r)                                \
22647 +       (unsigned long)__rlim_get(limit, r),    \
22648 +       (unsigned long)__rlim_rmin(limit, r),   \
22649 +       (unsigned long)__rlim_rmax(limit, r),   \
22650 +       VX_VLIM(__rlim_soft(limit, r)),         \
22651 +       VX_VLIM(__rlim_hard(limit, r)),         \
22652 +       atomic_read(&__rlim_lhit(limit, r))
22653 +
22654 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22655 +{
22656 +       vx_limit_fixup(limit, -1);
22657 +       return sprintf(buffer, VX_LIMIT_TOP
22658 +               "PROC"  VX_LIMIT_FMT
22659 +               "VM"    VX_LIMIT_FMT
22660 +               "VML"   VX_LIMIT_FMT
22661 +               "RSS"   VX_LIMIT_FMT
22662 +               "ANON"  VX_LIMIT_FMT
22663 +               "RMAP"  VX_LIMIT_FMT
22664 +               "FILES" VX_LIMIT_FMT
22665 +               "OFD"   VX_LIMIT_FMT
22666 +               "LOCKS" VX_LIMIT_FMT
22667 +               "SOCK"  VX_LIMIT_FMT
22668 +               "MSGQ"  VX_LIMIT_FMT
22669 +               "SHM"   VX_LIMIT_FMT
22670 +               "SEMA"  VX_LIMIT_FMT
22671 +               "SEMS"  VX_LIMIT_FMT
22672 +               "DENT"  VX_LIMIT_FMT,
22673 +               VX_LIMIT_ARG(RLIMIT_NPROC),
22674 +               VX_LIMIT_ARG(RLIMIT_AS),
22675 +               VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22676 +               VX_LIMIT_ARG(RLIMIT_RSS),
22677 +               VX_LIMIT_ARG(VLIMIT_ANON),
22678 +               VX_LIMIT_ARG(VLIMIT_MAPPED),
22679 +               VX_LIMIT_ARG(RLIMIT_NOFILE),
22680 +               VX_LIMIT_ARG(VLIMIT_OPENFD),
22681 +               VX_LIMIT_ARG(RLIMIT_LOCKS),
22682 +               VX_LIMIT_ARG(VLIMIT_NSOCK),
22683 +               VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22684 +               VX_LIMIT_ARG(VLIMIT_SHMEM),
22685 +               VX_LIMIT_ARG(VLIMIT_SEMARY),
22686 +               VX_LIMIT_ARG(VLIMIT_NSEMS),
22687 +               VX_LIMIT_ARG(VLIMIT_DENTRY));
22688 +}
22689 +
22690 +#endif /* _VX_LIMIT_PROC_H */
22691 +
22692 +
22693 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/Makefile linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/Makefile
22694 --- linux-2.6.33.2/kernel/vserver/Makefile      1970-01-01 01:00:00.000000000 +0100
22695 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/Makefile      2010-02-25 12:02:16.000000000 +0100
22696 @@ -0,0 +1,18 @@
22697 +#
22698 +# Makefile for the Linux vserver routines.
22699 +#
22700 +
22701 +
22702 +obj-y          += vserver.o
22703 +
22704 +vserver-y      := switch.o context.o space.o sched.o network.o inode.o \
22705 +                  limit.o cvirt.o cacct.o signal.o helper.o init.o \
22706 +                  dlimit.o tag.o
22707 +
22708 +vserver-$(CONFIG_INET) += inet.o
22709 +vserver-$(CONFIG_PROC_FS) += proc.o
22710 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
22711 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
22712 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
22713 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
22714 +
22715 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/monitor.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/monitor.c
22716 --- linux-2.6.33.2/kernel/vserver/monitor.c     1970-01-01 01:00:00.000000000 +0100
22717 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/monitor.c     2010-02-25 12:02:16.000000000 +0100
22718 @@ -0,0 +1,138 @@
22719 +/*
22720 + *  kernel/vserver/monitor.c
22721 + *
22722 + *  Virtual Context Scheduler Monitor
22723 + *
22724 + *  Copyright (C) 2006-2007 Herbert Pötzl
22725 + *
22726 + *  V0.01  basic design
22727 + *
22728 + */
22729 +
22730 +#include <linux/module.h>
22731 +#include <linux/jiffies.h>
22732 +#include <asm/uaccess.h>
22733 +#include <asm/atomic.h>
22734 +
22735 +#include <linux/vserver/monitor.h>
22736 +#include <linux/vserver/debug_cmd.h>
22737 +
22738 +
22739 +#ifdef CONFIG_VSERVER_MONITOR
22740 +#define VXM_SIZE       CONFIG_VSERVER_MONITOR_SIZE
22741 +#else
22742 +#define VXM_SIZE       64
22743 +#endif
22744 +
22745 +struct _vx_monitor {
22746 +       unsigned int counter;
22747 +
22748 +       struct _vx_mon_entry entry[VXM_SIZE+1];
22749 +};
22750 +
22751 +
22752 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
22753 +
22754 +unsigned volatile int vxm_active = 1;
22755 +
22756 +static atomic_t sequence = ATOMIC_INIT(0);
22757 +
22758 +
22759 +/*     vxm_advance()
22760 +
22761 +       * requires disabled preemption                          */
22762 +
22763 +struct _vx_mon_entry *vxm_advance(int cpu)
22764 +{
22765 +       struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22766 +       struct _vx_mon_entry *entry;
22767 +       unsigned int index;
22768 +
22769 +       index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
22770 +       entry = &mon->entry[index];
22771 +
22772 +       entry->ev.seq = atomic_inc_return(&sequence);
22773 +       entry->ev.jif = jiffies;
22774 +       return entry;
22775 +}
22776 +
22777 +EXPORT_SYMBOL_GPL(vxm_advance);
22778 +
22779 +
22780 +int do_read_monitor(struct __user _vx_mon_entry *data,
22781 +       int cpu, uint32_t *index, uint32_t *count)
22782 +{
22783 +       int pos, ret = 0;
22784 +       struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22785 +       int end = mon->counter;
22786 +       int start = end - VXM_SIZE + 2;
22787 +       int idx = *index;
22788 +
22789 +       /* special case: get current pos */
22790 +       if (!*count) {
22791 +               *index = end;
22792 +               return 0;
22793 +       }
22794 +
22795 +       /* have we lost some data? */
22796 +       if (idx < start)
22797 +               idx = start;
22798 +
22799 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22800 +               struct _vx_mon_entry *entry =
22801 +                       &mon->entry[idx % VXM_SIZE];
22802 +
22803 +               /* send entry to userspace */
22804 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22805 +               if (ret)
22806 +                       break;
22807 +       }
22808 +       /* save new index and count */
22809 +       *index = idx;
22810 +       *count = pos;
22811 +       return ret ? ret : (*index < end);
22812 +}
22813 +
22814 +int vc_read_monitor(uint32_t id, void __user *data)
22815 +{
22816 +       struct vcmd_read_monitor_v0 vc_data;
22817 +       int ret;
22818 +
22819 +       if (id >= NR_CPUS)
22820 +               return -EINVAL;
22821 +
22822 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22823 +               return -EFAULT;
22824 +
22825 +       ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22826 +               id, &vc_data.index, &vc_data.count);
22827 +
22828 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22829 +               return -EFAULT;
22830 +       return ret;
22831 +}
22832 +
22833 +#ifdef CONFIG_COMPAT
22834 +
22835 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22836 +{
22837 +       struct vcmd_read_monitor_v0_x32 vc_data;
22838 +       int ret;
22839 +
22840 +       if (id >= NR_CPUS)
22841 +               return -EINVAL;
22842 +
22843 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22844 +               return -EFAULT;
22845 +
22846 +       ret = do_read_monitor((struct __user _vx_mon_entry *)
22847 +               compat_ptr(vc_data.data_ptr),
22848 +               id, &vc_data.index, &vc_data.count);
22849 +
22850 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22851 +               return -EFAULT;
22852 +       return ret;
22853 +}
22854 +
22855 +#endif /* CONFIG_COMPAT */
22856 +
22857 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/network.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/network.c
22858 --- linux-2.6.33.2/kernel/vserver/network.c     1970-01-01 01:00:00.000000000 +0100
22859 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/network.c     2010-02-25 12:02:16.000000000 +0100
22860 @@ -0,0 +1,864 @@
22861 +/*
22862 + *  linux/kernel/vserver/network.c
22863 + *
22864 + *  Virtual Server: Network Support
22865 + *
22866 + *  Copyright (C) 2003-2007  Herbert Pötzl
22867 + *
22868 + *  V0.01  broken out from vcontext V0.05
22869 + *  V0.02  cleaned up implementation
22870 + *  V0.03  added equiv nx commands
22871 + *  V0.04  switch to RCU based hash
22872 + *  V0.05  and back to locking again
22873 + *  V0.06  changed vcmds to nxi arg
22874 + *  V0.07  have __create claim() the nxi
22875 + *
22876 + */
22877 +
22878 +#include <linux/err.h>
22879 +#include <linux/slab.h>
22880 +#include <linux/rcupdate.h>
22881 +
22882 +#include <linux/vs_network.h>
22883 +#include <linux/vs_pid.h>
22884 +#include <linux/vserver/network_cmd.h>
22885 +
22886 +
22887 +atomic_t nx_global_ctotal      = ATOMIC_INIT(0);
22888 +atomic_t nx_global_cactive     = ATOMIC_INIT(0);
22889 +
22890 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22891 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22892 +
22893 +
22894 +static int __init init_network(void)
22895 +{
22896 +       nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22897 +               sizeof(struct nx_addr_v4), 0,
22898 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22899 +       nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22900 +               sizeof(struct nx_addr_v6), 0,
22901 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22902 +       return 0;
22903 +}
22904 +
22905 +
22906 +/*     __alloc_nx_addr_v4()                                    */
22907 +
22908 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22909 +{
22910 +       struct nx_addr_v4 *nxa = kmem_cache_alloc(
22911 +               nx_addr_v4_cachep, GFP_KERNEL);
22912 +
22913 +       if (!IS_ERR(nxa))
22914 +               memset(nxa, 0, sizeof(*nxa));
22915 +       return nxa;
22916 +}
22917 +
22918 +/*     __dealloc_nx_addr_v4()                                  */
22919 +
22920 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22921 +{
22922 +       kmem_cache_free(nx_addr_v4_cachep, nxa);
22923 +}
22924 +
22925 +/*     __dealloc_nx_addr_v4_all()                              */
22926 +
22927 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22928 +{
22929 +       while (nxa) {
22930 +               struct nx_addr_v4 *next = nxa->next;
22931 +
22932 +               __dealloc_nx_addr_v4(nxa);
22933 +               nxa = next;
22934 +       }
22935 +}
22936 +
22937 +
22938 +#ifdef CONFIG_IPV6
22939 +
22940 +/*     __alloc_nx_addr_v6()                                    */
22941 +
22942 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22943 +{
22944 +       struct nx_addr_v6 *nxa = kmem_cache_alloc(
22945 +               nx_addr_v6_cachep, GFP_KERNEL);
22946 +
22947 +       if (!IS_ERR(nxa))
22948 +               memset(nxa, 0, sizeof(*nxa));
22949 +       return nxa;
22950 +}
22951 +
22952 +/*     __dealloc_nx_addr_v6()                                  */
22953 +
22954 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22955 +{
22956 +       kmem_cache_free(nx_addr_v6_cachep, nxa);
22957 +}
22958 +
22959 +/*     __dealloc_nx_addr_v6_all()                              */
22960 +
22961 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22962 +{
22963 +       while (nxa) {
22964 +               struct nx_addr_v6 *next = nxa->next;
22965 +
22966 +               __dealloc_nx_addr_v6(nxa);
22967 +               nxa = next;
22968 +       }
22969 +}
22970 +
22971 +#endif /* CONFIG_IPV6 */
22972 +
22973 +/*     __alloc_nx_info()
22974 +
22975 +       * allocate an initialized nx_info struct
22976 +       * doesn't make it visible (hash)                        */
22977 +
22978 +static struct nx_info *__alloc_nx_info(nid_t nid)
22979 +{
22980 +       struct nx_info *new = NULL;
22981 +
22982 +       vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22983 +
22984 +       /* would this benefit from a slab cache? */
22985 +       new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22986 +       if (!new)
22987 +               return 0;
22988 +
22989 +       memset(new, 0, sizeof(struct nx_info));
22990 +       new->nx_id = nid;
22991 +       INIT_HLIST_NODE(&new->nx_hlist);
22992 +       atomic_set(&new->nx_usecnt, 0);
22993 +       atomic_set(&new->nx_tasks, 0);
22994 +       new->nx_state = 0;
22995 +
22996 +       new->nx_flags = NXF_INIT_SET;
22997 +
22998 +       /* rest of init goes here */
22999 +
23000 +       new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
23001 +       new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
23002 +
23003 +       vxdprintk(VXD_CBIT(nid, 0),
23004 +               "alloc_nx_info(%d) = %p", nid, new);
23005 +       atomic_inc(&nx_global_ctotal);
23006 +       return new;
23007 +}
23008 +
23009 +/*     __dealloc_nx_info()
23010 +
23011 +       * final disposal of nx_info                             */
23012 +
23013 +static void __dealloc_nx_info(struct nx_info *nxi)
23014 +{
23015 +       vxdprintk(VXD_CBIT(nid, 0),
23016 +               "dealloc_nx_info(%p)", nxi);
23017 +
23018 +       nxi->nx_hlist.next = LIST_POISON1;
23019 +       nxi->nx_id = -1;
23020 +
23021 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
23022 +       BUG_ON(atomic_read(&nxi->nx_tasks));
23023 +
23024 +       __dealloc_nx_addr_v4_all(nxi->v4.next);
23025 +
23026 +       nxi->nx_state |= NXS_RELEASED;
23027 +       kfree(nxi);
23028 +       atomic_dec(&nx_global_ctotal);
23029 +}
23030 +
23031 +static void __shutdown_nx_info(struct nx_info *nxi)
23032 +{
23033 +       nxi->nx_state |= NXS_SHUTDOWN;
23034 +       vs_net_change(nxi, VSC_NETDOWN);
23035 +}
23036 +
23037 +/*     exported stuff                                          */
23038 +
23039 +void free_nx_info(struct nx_info *nxi)
23040 +{
23041 +       /* context shutdown is mandatory */
23042 +       BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
23043 +
23044 +       /* context must not be hashed */
23045 +       BUG_ON(nxi->nx_state & NXS_HASHED);
23046 +
23047 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
23048 +       BUG_ON(atomic_read(&nxi->nx_tasks));
23049 +
23050 +       __dealloc_nx_info(nxi);
23051 +}
23052 +
23053 +
23054 +void __nx_set_lback(struct nx_info *nxi)
23055 +{
23056 +       int nid = nxi->nx_id;
23057 +       __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
23058 +
23059 +       nxi->v4_lback.s_addr = lback;
23060 +}
23061 +
23062 +extern int __nx_inet_add_lback(__be32 addr);
23063 +extern int __nx_inet_del_lback(__be32 addr);
23064 +
23065 +
23066 +/*     hash table for nx_info hash */
23067 +
23068 +#define NX_HASH_SIZE   13
23069 +
23070 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
23071 +
23072 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
23073 +
23074 +
23075 +static inline unsigned int __hashval(nid_t nid)
23076 +{
23077 +       return (nid % NX_HASH_SIZE);
23078 +}
23079 +
23080 +
23081 +
23082 +/*     __hash_nx_info()
23083 +
23084 +       * add the nxi to the global hash table
23085 +       * requires the hash_lock to be held                     */
23086 +
23087 +static inline void __hash_nx_info(struct nx_info *nxi)
23088 +{
23089 +       struct hlist_head *head;
23090 +
23091 +       vxd_assert_lock(&nx_info_hash_lock);
23092 +       vxdprintk(VXD_CBIT(nid, 4),
23093 +               "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
23094 +
23095 +       /* context must not be hashed */
23096 +       BUG_ON(nx_info_state(nxi, NXS_HASHED));
23097 +
23098 +       nxi->nx_state |= NXS_HASHED;
23099 +       head = &nx_info_hash[__hashval(nxi->nx_id)];
23100 +       hlist_add_head(&nxi->nx_hlist, head);
23101 +       atomic_inc(&nx_global_cactive);
23102 +}
23103 +
23104 +/*     __unhash_nx_info()
23105 +
23106 +       * remove the nxi from the global hash table
23107 +       * requires the hash_lock to be held                     */
23108 +
23109 +static inline void __unhash_nx_info(struct nx_info *nxi)
23110 +{
23111 +       vxd_assert_lock(&nx_info_hash_lock);
23112 +       vxdprintk(VXD_CBIT(nid, 4),
23113 +               "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
23114 +               atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
23115 +
23116 +       /* context must be hashed */
23117 +       BUG_ON(!nx_info_state(nxi, NXS_HASHED));
23118 +       /* but without tasks */
23119 +       BUG_ON(atomic_read(&nxi->nx_tasks));
23120 +
23121 +       nxi->nx_state &= ~NXS_HASHED;
23122 +       hlist_del(&nxi->nx_hlist);
23123 +       atomic_dec(&nx_global_cactive);
23124 +}
23125 +
23126 +
23127 +/*     __lookup_nx_info()
23128 +
23129 +       * requires the hash_lock to be held
23130 +       * doesn't increment the nx_refcnt                       */
23131 +
23132 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
23133 +{
23134 +       struct hlist_head *head = &nx_info_hash[__hashval(nid)];
23135 +       struct hlist_node *pos;
23136 +       struct nx_info *nxi;
23137 +
23138 +       vxd_assert_lock(&nx_info_hash_lock);
23139 +       hlist_for_each(pos, head) {
23140 +               nxi = hlist_entry(pos, struct nx_info, nx_hlist);
23141 +
23142 +               if (nxi->nx_id == nid)
23143 +                       goto found;
23144 +       }
23145 +       nxi = NULL;
23146 +found:
23147 +       vxdprintk(VXD_CBIT(nid, 0),
23148 +               "__lookup_nx_info(#%u): %p[#%u]",
23149 +               nid, nxi, nxi ? nxi->nx_id : 0);
23150 +       return nxi;
23151 +}
23152 +
23153 +
23154 +/*     __create_nx_info()
23155 +
23156 +       * create the requested context
23157 +       * get(), claim() and hash it                            */
23158 +
23159 +static struct nx_info *__create_nx_info(int id)
23160 +{
23161 +       struct nx_info *new, *nxi = NULL;
23162 +
23163 +       vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
23164 +
23165 +       if (!(new = __alloc_nx_info(id)))
23166 +               return ERR_PTR(-ENOMEM);
23167 +
23168 +       /* required to make dynamic xids unique */
23169 +       spin_lock(&nx_info_hash_lock);
23170 +
23171 +       /* static context requested */
23172 +       if ((nxi = __lookup_nx_info(id))) {
23173 +               vxdprintk(VXD_CBIT(nid, 0),
23174 +                       "create_nx_info(%d) = %p (already there)", id, nxi);
23175 +               if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
23176 +                       nxi = ERR_PTR(-EBUSY);
23177 +               else
23178 +                       nxi = ERR_PTR(-EEXIST);
23179 +               goto out_unlock;
23180 +       }
23181 +       /* new context */
23182 +       vxdprintk(VXD_CBIT(nid, 0),
23183 +               "create_nx_info(%d) = %p (new)", id, new);
23184 +       claim_nx_info(new, NULL);
23185 +       __nx_set_lback(new);
23186 +       __hash_nx_info(get_nx_info(new));
23187 +       nxi = new, new = NULL;
23188 +
23189 +out_unlock:
23190 +       spin_unlock(&nx_info_hash_lock);
23191 +       if (new)
23192 +               __dealloc_nx_info(new);
23193 +       return nxi;
23194 +}
23195 +
23196 +
23197 +
23198 +/*     exported stuff                                          */
23199 +
23200 +
23201 +void unhash_nx_info(struct nx_info *nxi)
23202 +{
23203 +       __shutdown_nx_info(nxi);
23204 +       spin_lock(&nx_info_hash_lock);
23205 +       __unhash_nx_info(nxi);
23206 +       spin_unlock(&nx_info_hash_lock);
23207 +}
23208 +
23209 +/*     lookup_nx_info()
23210 +
23211 +       * search for a nx_info and get() it
23212 +       * negative id means current                             */
23213 +
23214 +struct nx_info *lookup_nx_info(int id)
23215 +{
23216 +       struct nx_info *nxi = NULL;
23217 +
23218 +       if (id < 0) {
23219 +               nxi = get_nx_info(current_nx_info());
23220 +       } else if (id > 1) {
23221 +               spin_lock(&nx_info_hash_lock);
23222 +               nxi = get_nx_info(__lookup_nx_info(id));
23223 +               spin_unlock(&nx_info_hash_lock);
23224 +       }
23225 +       return nxi;
23226 +}
23227 +
23228 +/*     nid_is_hashed()
23229 +
23230 +       * verify that nid is still hashed                       */
23231 +
23232 +int nid_is_hashed(nid_t nid)
23233 +{
23234 +       int hashed;
23235 +
23236 +       spin_lock(&nx_info_hash_lock);
23237 +       hashed = (__lookup_nx_info(nid) != NULL);
23238 +       spin_unlock(&nx_info_hash_lock);
23239 +       return hashed;
23240 +}
23241 +
23242 +
23243 +#ifdef CONFIG_PROC_FS
23244 +
23245 +/*     get_nid_list()
23246 +
23247 +       * get a subset of hashed nids for proc
23248 +       * assumes size is at least one                          */
23249 +
23250 +int get_nid_list(int index, unsigned int *nids, int size)
23251 +{
23252 +       int hindex, nr_nids = 0;
23253 +
23254 +       /* only show current and children */
23255 +       if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
23256 +               if (index > 0)
23257 +                       return 0;
23258 +               nids[nr_nids] = nx_current_nid();
23259 +               return 1;
23260 +       }
23261 +
23262 +       for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
23263 +               struct hlist_head *head = &nx_info_hash[hindex];
23264 +               struct hlist_node *pos;
23265 +
23266 +               spin_lock(&nx_info_hash_lock);
23267 +               hlist_for_each(pos, head) {
23268 +                       struct nx_info *nxi;
23269 +
23270 +                       if (--index > 0)
23271 +                               continue;
23272 +
23273 +                       nxi = hlist_entry(pos, struct nx_info, nx_hlist);
23274 +                       nids[nr_nids] = nxi->nx_id;
23275 +                       if (++nr_nids >= size) {
23276 +                               spin_unlock(&nx_info_hash_lock);
23277 +                               goto out;
23278 +                       }
23279 +               }
23280 +               /* keep the lock time short */
23281 +               spin_unlock(&nx_info_hash_lock);
23282 +       }
23283 +out:
23284 +       return nr_nids;
23285 +}
23286 +#endif
23287 +
23288 +
23289 +/*
23290 + *     migrate task to new network
23291 + *     gets nxi, puts old_nxi on change
23292 + */
23293 +
23294 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
23295 +{
23296 +       struct nx_info *old_nxi;
23297 +       int ret = 0;
23298 +
23299 +       if (!p || !nxi)
23300 +               BUG();
23301 +
23302 +       vxdprintk(VXD_CBIT(nid, 5),
23303 +               "nx_migrate_task(%p,%p[#%d.%d.%d])",
23304 +               p, nxi, nxi->nx_id,
23305 +               atomic_read(&nxi->nx_usecnt),
23306 +               atomic_read(&nxi->nx_tasks));
23307 +
23308 +       if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
23309 +               !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
23310 +               return -EACCES;
23311 +
23312 +       if (nx_info_state(nxi, NXS_SHUTDOWN))
23313 +               return -EFAULT;
23314 +
23315 +       /* maybe disallow this completely? */
23316 +       old_nxi = task_get_nx_info(p);
23317 +       if (old_nxi == nxi)
23318 +               goto out;
23319 +
23320 +       task_lock(p);
23321 +       if (old_nxi)
23322 +               clr_nx_info(&p->nx_info);
23323 +       claim_nx_info(nxi, p);
23324 +       set_nx_info(&p->nx_info, nxi);
23325 +       p->nid = nxi->nx_id;
23326 +       task_unlock(p);
23327 +
23328 +       vxdprintk(VXD_CBIT(nid, 5),
23329 +               "moved task %p into nxi:%p[#%d]",
23330 +               p, nxi, nxi->nx_id);
23331 +
23332 +       if (old_nxi)
23333 +               release_nx_info(old_nxi, p);
23334 +       ret = 0;
23335 +out:
23336 +       put_nx_info(old_nxi);
23337 +       return ret;
23338 +}
23339 +
23340 +
23341 +void nx_set_persistent(struct nx_info *nxi)
23342 +{
23343 +       vxdprintk(VXD_CBIT(nid, 6),
23344 +               "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
23345 +
23346 +       get_nx_info(nxi);
23347 +       claim_nx_info(nxi, NULL);
23348 +}
23349 +
23350 +void nx_clear_persistent(struct nx_info *nxi)
23351 +{
23352 +       vxdprintk(VXD_CBIT(nid, 6),
23353 +               "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
23354 +
23355 +       release_nx_info(nxi, NULL);
23356 +       put_nx_info(nxi);
23357 +}
23358 +
23359 +void nx_update_persistent(struct nx_info *nxi)
23360 +{
23361 +       if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
23362 +               nx_set_persistent(nxi);
23363 +       else
23364 +               nx_clear_persistent(nxi);
23365 +}
23366 +
23367 +/* vserver syscall commands below here */
23368 +
23369 +/* taks nid and nx_info functions */
23370 +
23371 +#include <asm/uaccess.h>
23372 +
23373 +
23374 +int vc_task_nid(uint32_t id)
23375 +{
23376 +       nid_t nid;
23377 +
23378 +       if (id) {
23379 +               struct task_struct *tsk;
23380 +
23381 +               read_lock(&tasklist_lock);
23382 +               tsk = find_task_by_real_pid(id);
23383 +               nid = (tsk) ? tsk->nid : -ESRCH;
23384 +               read_unlock(&tasklist_lock);
23385 +       } else
23386 +               nid = nx_current_nid();
23387 +       return nid;
23388 +}
23389 +
23390 +
23391 +int vc_nx_info(struct nx_info *nxi, void __user *data)
23392 +{
23393 +       struct vcmd_nx_info_v0 vc_data;
23394 +
23395 +       vc_data.nid = nxi->nx_id;
23396 +
23397 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23398 +               return -EFAULT;
23399 +       return 0;
23400 +}
23401 +
23402 +
23403 +/* network functions */
23404 +
23405 +int vc_net_create(uint32_t nid, void __user *data)
23406 +{
23407 +       struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
23408 +       struct nx_info *new_nxi;
23409 +       int ret;
23410 +
23411 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23412 +               return -EFAULT;
23413 +
23414 +       if ((nid > MAX_S_CONTEXT) || (nid < 2))
23415 +               return -EINVAL;
23416 +
23417 +       new_nxi = __create_nx_info(nid);
23418 +       if (IS_ERR(new_nxi))
23419 +               return PTR_ERR(new_nxi);
23420 +
23421 +       /* initial flags */
23422 +       new_nxi->nx_flags = vc_data.flagword;
23423 +
23424 +       ret = -ENOEXEC;
23425 +       if (vs_net_change(new_nxi, VSC_NETUP))
23426 +               goto out;
23427 +
23428 +       ret = nx_migrate_task(current, new_nxi);
23429 +       if (ret)
23430 +               goto out;
23431 +
23432 +       /* return context id on success */
23433 +       ret = new_nxi->nx_id;
23434 +
23435 +       /* get a reference for persistent contexts */
23436 +       if ((vc_data.flagword & NXF_PERSISTENT))
23437 +               nx_set_persistent(new_nxi);
23438 +out:
23439 +       release_nx_info(new_nxi, NULL);
23440 +       put_nx_info(new_nxi);
23441 +       return ret;
23442 +}
23443 +
23444 +
23445 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
23446 +{
23447 +       return nx_migrate_task(current, nxi);
23448 +}
23449 +
23450 +
23451 +
23452 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
23453 +       uint16_t type, uint16_t flags)
23454 +{
23455 +       struct nx_addr_v4 *nxa = &nxi->v4;
23456 +
23457 +       if (NX_IPV4(nxi)) {
23458 +               /* locate last entry */
23459 +               for (; nxa->next; nxa = nxa->next);
23460 +               nxa->next = __alloc_nx_addr_v4();
23461 +               nxa = nxa->next;
23462 +
23463 +               if (IS_ERR(nxa))
23464 +                       return PTR_ERR(nxa);
23465 +       }
23466 +
23467 +       if (nxi->v4.next)
23468 +               /* remove single ip for ip list */
23469 +               nxi->nx_flags &= ~NXF_SINGLE_IP;
23470 +
23471 +       nxa->ip[0].s_addr = ip;
23472 +       nxa->ip[1].s_addr = ip2;
23473 +       nxa->mask.s_addr = mask;
23474 +       nxa->type = type;
23475 +       nxa->flags = flags;
23476 +       return 0;
23477 +}
23478 +
23479 +
23480 +int vc_net_add(struct nx_info *nxi, void __user *data)
23481 +{
23482 +       struct vcmd_net_addr_v0 vc_data;
23483 +       int index, ret = 0;
23484 +
23485 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23486 +               return -EFAULT;
23487 +
23488 +       switch (vc_data.type) {
23489 +       case NXA_TYPE_IPV4:
23490 +               if ((vc_data.count < 1) || (vc_data.count > 4))
23491 +                       return -EINVAL;
23492 +
23493 +               index = 0;
23494 +               while (index < vc_data.count) {
23495 +                       ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
23496 +                               vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
23497 +                       if (ret)
23498 +                               return ret;
23499 +                       index++;
23500 +               }
23501 +               ret = index;
23502 +               break;
23503 +
23504 +       case NXA_TYPE_IPV4|NXA_MOD_BCAST:
23505 +               nxi->v4_bcast = vc_data.ip[0];
23506 +               ret = 1;
23507 +               break;
23508 +
23509 +       case NXA_TYPE_IPV4|NXA_MOD_LBACK:
23510 +               nxi->v4_lback = vc_data.ip[0];
23511 +               ret = 1;
23512 +               break;
23513 +
23514 +       default:
23515 +               ret = -EINVAL;
23516 +               break;
23517 +       }
23518 +       return ret;
23519 +}
23520 +
23521 +int vc_net_remove(struct nx_info *nxi, void __user *data)
23522 +{
23523 +       struct vcmd_net_addr_v0 vc_data;
23524 +
23525 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23526 +               return -EFAULT;
23527 +
23528 +       switch (vc_data.type) {
23529 +       case NXA_TYPE_ANY:
23530 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23531 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
23532 +               break;
23533 +
23534 +       default:
23535 +               return -EINVAL;
23536 +       }
23537 +       return 0;
23538 +}
23539 +
23540 +
23541 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
23542 +{
23543 +       struct vcmd_net_addr_ipv4_v1 vc_data;
23544 +
23545 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23546 +               return -EFAULT;
23547 +
23548 +       switch (vc_data.type) {
23549 +       case NXA_TYPE_ADDR:
23550 +       case NXA_TYPE_RANGE:
23551 +       case NXA_TYPE_MASK:
23552 +               return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
23553 +                       vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23554 +
23555 +       case NXA_TYPE_ADDR | NXA_MOD_BCAST:
23556 +               nxi->v4_bcast = vc_data.ip;
23557 +               break;
23558 +
23559 +       case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23560 +               nxi->v4_lback = vc_data.ip;
23561 +               break;
23562 +
23563 +       default:
23564 +               return -EINVAL;
23565 +       }
23566 +       return 0;
23567 +}
23568 +
23569 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
23570 +{
23571 +       struct vcmd_net_addr_ipv4_v1 vc_data;
23572 +
23573 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23574 +               return -EFAULT;
23575 +
23576 +       switch (vc_data.type) {
23577 +/*     case NXA_TYPE_ADDR:
23578 +               break;          */
23579 +
23580 +       case NXA_TYPE_ANY:
23581 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23582 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
23583 +               break;
23584 +
23585 +       default:
23586 +               return -EINVAL;
23587 +       }
23588 +       return 0;
23589 +}
23590 +
23591 +
23592 +#ifdef CONFIG_IPV6
23593 +
23594 +int do_add_v6_addr(struct nx_info *nxi,
23595 +       struct in6_addr *ip, struct in6_addr *mask,
23596 +       uint32_t prefix, uint16_t type, uint16_t flags)
23597 +{
23598 +       struct nx_addr_v6 *nxa = &nxi->v6;
23599 +
23600 +       if (NX_IPV6(nxi)) {
23601 +               /* locate last entry */
23602 +               for (; nxa->next; nxa = nxa->next);
23603 +               nxa->next = __alloc_nx_addr_v6();
23604 +               nxa = nxa->next;
23605 +
23606 +               if (IS_ERR(nxa))
23607 +                       return PTR_ERR(nxa);
23608 +       }
23609 +
23610 +       nxa->ip = *ip;
23611 +       nxa->mask = *mask;
23612 +       nxa->prefix = prefix;
23613 +       nxa->type = type;
23614 +       nxa->flags = flags;
23615 +       return 0;
23616 +}
23617 +
23618 +
23619 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23620 +{
23621 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23622 +
23623 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23624 +               return -EFAULT;
23625 +
23626 +       switch (vc_data.type) {
23627 +       case NXA_TYPE_ADDR:
23628 +       case NXA_TYPE_MASK:
23629 +               return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23630 +                       vc_data.prefix, vc_data.type, vc_data.flags);
23631 +       default:
23632 +               return -EINVAL;
23633 +       }
23634 +       return 0;
23635 +}
23636 +
23637 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23638 +{
23639 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23640 +
23641 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23642 +               return -EFAULT;
23643 +
23644 +       switch (vc_data.type) {
23645 +       case NXA_TYPE_ANY:
23646 +               __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23647 +               memset(&nxi->v6, 0, sizeof(nxi->v6));
23648 +               break;
23649 +
23650 +       default:
23651 +               return -EINVAL;
23652 +       }
23653 +       return 0;
23654 +}
23655 +
23656 +#endif /* CONFIG_IPV6 */
23657 +
23658 +
23659 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23660 +{
23661 +       struct vcmd_net_flags_v0 vc_data;
23662 +
23663 +       vc_data.flagword = nxi->nx_flags;
23664 +
23665 +       /* special STATE flag handling */
23666 +       vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23667 +
23668 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23669 +               return -EFAULT;
23670 +       return 0;
23671 +}
23672 +
23673 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23674 +{
23675 +       struct vcmd_net_flags_v0 vc_data;
23676 +       uint64_t mask, trigger;
23677 +
23678 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23679 +               return -EFAULT;
23680 +
23681 +       /* special STATE flag handling */
23682 +       mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23683 +       trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23684 +
23685 +       nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23686 +               vc_data.flagword, mask);
23687 +       if (trigger & NXF_PERSISTENT)
23688 +               nx_update_persistent(nxi);
23689 +
23690 +       return 0;
23691 +}
23692 +
23693 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23694 +{
23695 +       struct vcmd_net_caps_v0 vc_data;
23696 +
23697 +       vc_data.ncaps = nxi->nx_ncaps;
23698 +       vc_data.cmask = ~0ULL;
23699 +
23700 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23701 +               return -EFAULT;
23702 +       return 0;
23703 +}
23704 +
23705 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23706 +{
23707 +       struct vcmd_net_caps_v0 vc_data;
23708 +
23709 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23710 +               return -EFAULT;
23711 +
23712 +       nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23713 +               vc_data.ncaps, vc_data.cmask);
23714 +       return 0;
23715 +}
23716 +
23717 +
23718 +#include <linux/module.h>
23719 +
23720 +module_init(init_network);
23721 +
23722 +EXPORT_SYMBOL_GPL(free_nx_info);
23723 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23724 +
23725 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/proc.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/proc.c
23726 --- linux-2.6.33.2/kernel/vserver/proc.c        1970-01-01 01:00:00.000000000 +0100
23727 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/proc.c        2010-02-25 12:02:16.000000000 +0100
23728 @@ -0,0 +1,1098 @@
23729 +/*
23730 + *  linux/kernel/vserver/proc.c
23731 + *
23732 + *  Virtual Context Support
23733 + *
23734 + *  Copyright (C) 2003-2007  Herbert Pötzl
23735 + *
23736 + *  V0.01  basic structure
23737 + *  V0.02  adaptation vs1.3.0
23738 + *  V0.03  proc permissions
23739 + *  V0.04  locking/generic
23740 + *  V0.05  next generation procfs
23741 + *  V0.06  inode validation
23742 + *  V0.07  generic rewrite vid
23743 + *  V0.08  remove inode type
23744 + *
23745 + */
23746 +
23747 +#include <linux/proc_fs.h>
23748 +#include <linux/fs_struct.h>
23749 +#include <linux/mount.h>
23750 +#include <asm/unistd.h>
23751 +
23752 +#include <linux/vs_context.h>
23753 +#include <linux/vs_network.h>
23754 +#include <linux/vs_cvirt.h>
23755 +
23756 +#include <linux/in.h>
23757 +#include <linux/inetdevice.h>
23758 +#include <linux/vs_inet.h>
23759 +#include <linux/vs_inet6.h>
23760 +
23761 +#include <linux/vserver/global.h>
23762 +
23763 +#include "cvirt_proc.h"
23764 +#include "cacct_proc.h"
23765 +#include "limit_proc.h"
23766 +#include "sched_proc.h"
23767 +#include "vci_config.h"
23768 +
23769 +
23770 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23771 +{
23772 +       unsigned __capi;
23773 +
23774 +       CAP_FOR_EACH_U32(__capi) {
23775 +               buffer += sprintf(buffer, "%08x",
23776 +                       c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23777 +       }
23778 +       return buffer;
23779 +}
23780 +
23781 +
23782 +static struct proc_dir_entry *proc_virtual;
23783 +
23784 +static struct proc_dir_entry *proc_virtnet;
23785 +
23786 +
23787 +/* first the actual feeds */
23788 +
23789 +
23790 +static int proc_vci(char *buffer)
23791 +{
23792 +       return sprintf(buffer,
23793 +               "VCIVersion:\t%04x:%04x\n"
23794 +               "VCISyscall:\t%d\n"
23795 +               "VCIKernel:\t%08x\n",
23796 +               VCI_VERSION >> 16,
23797 +               VCI_VERSION & 0xFFFF,
23798 +               __NR_vserver,
23799 +               vci_kernel_config());
23800 +}
23801 +
23802 +static int proc_virtual_info(char *buffer)
23803 +{
23804 +       return proc_vci(buffer);
23805 +}
23806 +
23807 +static int proc_virtual_status(char *buffer)
23808 +{
23809 +       return sprintf(buffer,
23810 +               "#CTotal:\t%d\n"
23811 +               "#CActive:\t%d\n"
23812 +               "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23813 +               "#InitTask:\t%d\t%d %d\n",
23814 +               atomic_read(&vx_global_ctotal),
23815 +               atomic_read(&vx_global_cactive),
23816 +               atomic_read(&vs_global_nsproxy),
23817 +               atomic_read(&vs_global_fs),
23818 +               atomic_read(&vs_global_mnt_ns),
23819 +               atomic_read(&vs_global_uts_ns),
23820 +               atomic_read(&nr_ipc_ns),
23821 +               atomic_read(&vs_global_user_ns),
23822 +               atomic_read(&vs_global_pid_ns),
23823 +               atomic_read(&init_task.usage),
23824 +               atomic_read(&init_task.nsproxy->count),
23825 +               init_task.fs->users);
23826 +}
23827 +
23828 +
23829 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23830 +{
23831 +       int length;
23832 +
23833 +       length = sprintf(buffer,
23834 +               "ID:\t%d\n"
23835 +               "Info:\t%p\n"
23836 +               "Init:\t%d\n"
23837 +               "OOM:\t%lld\n",
23838 +               vxi->vx_id,
23839 +               vxi,
23840 +               vxi->vx_initpid,
23841 +               vxi->vx_badness_bias);
23842 +       return length;
23843 +}
23844 +
23845 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23846 +{
23847 +       char *orig = buffer;
23848 +
23849 +       buffer += sprintf(buffer,
23850 +               "UseCnt:\t%d\n"
23851 +               "Tasks:\t%d\n"
23852 +               "Flags:\t%016llx\n",
23853 +               atomic_read(&vxi->vx_usecnt),
23854 +               atomic_read(&vxi->vx_tasks),
23855 +               (unsigned long long)vxi->vx_flags);
23856 +
23857 +       buffer += sprintf(buffer, "BCaps:\t");
23858 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23859 +       buffer += sprintf(buffer, "\n");
23860 +
23861 +       buffer += sprintf(buffer,
23862 +               "CCaps:\t%016llx\n"
23863 +               "Spaces:\t%08lx %08lx\n",
23864 +               (unsigned long long)vxi->vx_ccaps,
23865 +               vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
23866 +       return buffer - orig;
23867 +}
23868 +
23869 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23870 +{
23871 +       return vx_info_proc_limit(&vxi->limit, buffer);
23872 +}
23873 +
23874 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23875 +{
23876 +       int cpu, length;
23877 +
23878 +       length = vx_info_proc_sched(&vxi->sched, buffer);
23879 +       for_each_online_cpu(cpu) {
23880 +               length += vx_info_proc_sched_pc(
23881 +                       &vx_per_cpu(vxi, sched_pc, cpu),
23882 +                       buffer + length, cpu);
23883 +       }
23884 +       return length;
23885 +}
23886 +
23887 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23888 +{
23889 +       return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
23890 +}
23891 +
23892 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23893 +{
23894 +       return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
23895 +}
23896 +
23897 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23898 +{
23899 +       int cpu, length;
23900 +
23901 +       vx_update_load(vxi);
23902 +       length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23903 +       for_each_online_cpu(cpu) {
23904 +               length += vx_info_proc_cvirt_pc(
23905 +                       &vx_per_cpu(vxi, cvirt_pc, cpu),
23906 +                       buffer + length, cpu);
23907 +       }
23908 +       return length;
23909 +}
23910 +
23911 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23912 +{
23913 +       return vx_info_proc_cacct(&vxi->cacct, buffer);
23914 +}
23915 +
23916 +
23917 +static int proc_virtnet_info(char *buffer)
23918 +{
23919 +       return proc_vci(buffer);
23920 +}
23921 +
23922 +static int proc_virtnet_status(char *buffer)
23923 +{
23924 +       return sprintf(buffer,
23925 +               "#CTotal:\t%d\n"
23926 +               "#CActive:\t%d\n",
23927 +               atomic_read(&nx_global_ctotal),
23928 +               atomic_read(&nx_global_cactive));
23929 +}
23930 +
23931 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23932 +{
23933 +       struct nx_addr_v4 *v4a;
23934 +#ifdef CONFIG_IPV6
23935 +       struct nx_addr_v6 *v6a;
23936 +#endif
23937 +       int length, i;
23938 +
23939 +       length = sprintf(buffer,
23940 +               "ID:\t%d\n"
23941 +               "Info:\t%p\n"
23942 +               "Bcast:\t" NIPQUAD_FMT "\n"
23943 +               "Lback:\t" NIPQUAD_FMT "\n",
23944 +               nxi->nx_id,
23945 +               nxi,
23946 +               NIPQUAD(nxi->v4_bcast.s_addr),
23947 +               NIPQUAD(nxi->v4_lback.s_addr));
23948 +
23949 +       if (!NX_IPV4(nxi))
23950 +               goto skip_v4;
23951 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23952 +               length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23953 +                       i, NXAV4(v4a));
23954 +skip_v4:
23955 +#ifdef CONFIG_IPV6
23956 +       if (!NX_IPV6(nxi))
23957 +               goto skip_v6;
23958 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23959 +               length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23960 +                       i, NXAV6(v6a));
23961 +skip_v6:
23962 +#endif
23963 +       return length;
23964 +}
23965 +
23966 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23967 +{
23968 +       int length;
23969 +
23970 +       length = sprintf(buffer,
23971 +               "UseCnt:\t%d\n"
23972 +               "Tasks:\t%d\n"
23973 +               "Flags:\t%016llx\n"
23974 +               "NCaps:\t%016llx\n",
23975 +               atomic_read(&nxi->nx_usecnt),
23976 +               atomic_read(&nxi->nx_tasks),
23977 +               (unsigned long long)nxi->nx_flags,
23978 +               (unsigned long long)nxi->nx_ncaps);
23979 +       return length;
23980 +}
23981 +
23982 +
23983 +
23984 +/* here the inode helpers */
23985 +
23986 +struct vs_entry {
23987 +       int len;
23988 +       char *name;
23989 +       mode_t mode;
23990 +       struct inode_operations *iop;
23991 +       struct file_operations *fop;
23992 +       union proc_op op;
23993 +};
23994 +
23995 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23996 +{
23997 +       struct inode *inode = new_inode(sb);
23998 +
23999 +       if (!inode)
24000 +               goto out;
24001 +
24002 +       inode->i_mode = p->mode;
24003 +       if (p->iop)
24004 +               inode->i_op = p->iop;
24005 +       if (p->fop)
24006 +               inode->i_fop = p->fop;
24007 +
24008 +       inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
24009 +       inode->i_flags |= S_IMMUTABLE;
24010 +
24011 +       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
24012 +
24013 +       inode->i_uid = 0;
24014 +       inode->i_gid = 0;
24015 +       inode->i_tag = 0;
24016 +out:
24017 +       return inode;
24018 +}
24019 +
24020 +static struct dentry *vs_proc_instantiate(struct inode *dir,
24021 +       struct dentry *dentry, int id, void *ptr)
24022 +{
24023 +       struct vs_entry *p = ptr;
24024 +       struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
24025 +       struct dentry *error = ERR_PTR(-EINVAL);
24026 +
24027 +       if (!inode)
24028 +               goto out;
24029 +
24030 +       PROC_I(inode)->op = p->op;
24031 +       PROC_I(inode)->fd = id;
24032 +       d_add(dentry, inode);
24033 +       error = NULL;
24034 +out:
24035 +       return error;
24036 +}
24037 +
24038 +/* Lookups */
24039 +
24040 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
24041 +
24042 +/*
24043 + * Fill a directory entry.
24044 + *
24045 + * If possible create the dcache entry and derive our inode number and
24046 + * file type from dcache entry.
24047 + *
24048 + * Since all of the proc inode numbers are dynamically generated, the inode
24049 + * numbers do not exist until the inode is cache.  This means creating the
24050 + * the dcache entry in readdir is necessary to keep the inode numbers
24051 + * reported by readdir in sync with the inode numbers reported
24052 + * by stat.
24053 + */
24054 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
24055 +       char *name, int len, instantiate_t instantiate, int id, void *ptr)
24056 +{
24057 +       struct dentry *child, *dir = filp->f_dentry;
24058 +       struct inode *inode;
24059 +       struct qstr qname;
24060 +       ino_t ino = 0;
24061 +       unsigned type = DT_UNKNOWN;
24062 +
24063 +       qname.name = name;
24064 +       qname.len  = len;
24065 +       qname.hash = full_name_hash(name, len);
24066 +
24067 +       child = d_lookup(dir, &qname);
24068 +       if (!child) {
24069 +               struct dentry *new;
24070 +               new = d_alloc(dir, &qname);
24071 +               if (new) {
24072 +                       child = instantiate(dir->d_inode, new, id, ptr);
24073 +                       if (child)
24074 +                               dput(new);
24075 +                       else
24076 +                               child = new;
24077 +               }
24078 +       }
24079 +       if (!child || IS_ERR(child) || !child->d_inode)
24080 +               goto end_instantiate;
24081 +       inode = child->d_inode;
24082 +       if (inode) {
24083 +               ino = inode->i_ino;
24084 +               type = inode->i_mode >> 12;
24085 +       }
24086 +       dput(child);
24087 +end_instantiate:
24088 +       if (!ino)
24089 +               ino = find_inode_number(dir, &qname);
24090 +       if (!ino)
24091 +               ino = 1;
24092 +       return filldir(dirent, name, len, filp->f_pos, ino, type);
24093 +}
24094 +
24095 +
24096 +
24097 +/* get and revalidate vx_info/xid */
24098 +
24099 +static inline
24100 +struct vx_info *get_proc_vx_info(struct inode *inode)
24101 +{
24102 +       return lookup_vx_info(PROC_I(inode)->fd);
24103 +}
24104 +
24105 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
24106 +{
24107 +       struct inode *inode = dentry->d_inode;
24108 +       xid_t xid = PROC_I(inode)->fd;
24109 +
24110 +       if (!xid || xid_is_hashed(xid))
24111 +               return 1;
24112 +       d_drop(dentry);
24113 +       return 0;
24114 +}
24115 +
24116 +
24117 +/* get and revalidate nx_info/nid */
24118 +
24119 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
24120 +{
24121 +       struct inode *inode = dentry->d_inode;
24122 +       nid_t nid = PROC_I(inode)->fd;
24123 +
24124 +       if (!nid || nid_is_hashed(nid))
24125 +               return 1;
24126 +       d_drop(dentry);
24127 +       return 0;
24128 +}
24129 +
24130 +
24131 +
24132 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
24133 +
24134 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
24135 +                         size_t count, loff_t *ppos)
24136 +{
24137 +       struct inode *inode = file->f_dentry->d_inode;
24138 +       unsigned long page;
24139 +       ssize_t length = 0;
24140 +
24141 +       if (count > PROC_BLOCK_SIZE)
24142 +               count = PROC_BLOCK_SIZE;
24143 +
24144 +       /* fade that out as soon as stable */
24145 +       WARN_ON(PROC_I(inode)->fd);
24146 +
24147 +       if (!(page = __get_free_page(GFP_KERNEL)))
24148 +               return -ENOMEM;
24149 +
24150 +       BUG_ON(!PROC_I(inode)->op.proc_vs_read);
24151 +       length = PROC_I(inode)->op.proc_vs_read((char *)page);
24152 +
24153 +       if (length >= 0)
24154 +               length = simple_read_from_buffer(buf, count, ppos,
24155 +                       (char *)page, length);
24156 +
24157 +       free_page(page);
24158 +       return length;
24159 +}
24160 +
24161 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
24162 +                         size_t count, loff_t *ppos)
24163 +{
24164 +       struct inode *inode = file->f_dentry->d_inode;
24165 +       struct vx_info *vxi = NULL;
24166 +       xid_t xid = PROC_I(inode)->fd;
24167 +       unsigned long page;
24168 +       ssize_t length = 0;
24169 +
24170 +       if (count > PROC_BLOCK_SIZE)
24171 +               count = PROC_BLOCK_SIZE;
24172 +
24173 +       /* fade that out as soon as stable */
24174 +       WARN_ON(!xid);
24175 +       vxi = lookup_vx_info(xid);
24176 +       if (!vxi)
24177 +               goto out;
24178 +
24179 +       length = -ENOMEM;
24180 +       if (!(page = __get_free_page(GFP_KERNEL)))
24181 +               goto out_put;
24182 +
24183 +       BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
24184 +       length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
24185 +
24186 +       if (length >= 0)
24187 +               length = simple_read_from_buffer(buf, count, ppos,
24188 +                       (char *)page, length);
24189 +
24190 +       free_page(page);
24191 +out_put:
24192 +       put_vx_info(vxi);
24193 +out:
24194 +       return length;
24195 +}
24196 +
24197 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
24198 +                         size_t count, loff_t *ppos)
24199 +{
24200 +       struct inode *inode = file->f_dentry->d_inode;
24201 +       struct nx_info *nxi = NULL;
24202 +       nid_t nid = PROC_I(inode)->fd;
24203 +       unsigned long page;
24204 +       ssize_t length = 0;
24205 +
24206 +       if (count > PROC_BLOCK_SIZE)
24207 +               count = PROC_BLOCK_SIZE;
24208 +
24209 +       /* fade that out as soon as stable */
24210 +       WARN_ON(!nid);
24211 +       nxi = lookup_nx_info(nid);
24212 +       if (!nxi)
24213 +               goto out;
24214 +
24215 +       length = -ENOMEM;
24216 +       if (!(page = __get_free_page(GFP_KERNEL)))
24217 +               goto out_put;
24218 +
24219 +       BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
24220 +       length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
24221 +
24222 +       if (length >= 0)
24223 +               length = simple_read_from_buffer(buf, count, ppos,
24224 +                       (char *)page, length);
24225 +
24226 +       free_page(page);
24227 +out_put:
24228 +       put_nx_info(nxi);
24229 +out:
24230 +       return length;
24231 +}
24232 +
24233 +
24234 +
24235 +/* here comes the lower level */
24236 +
24237 +
24238 +#define NOD(NAME, MODE, IOP, FOP, OP) {        \
24239 +       .len  = sizeof(NAME) - 1,       \
24240 +       .name = (NAME),                 \
24241 +       .mode = MODE,                   \
24242 +       .iop  = IOP,                    \
24243 +       .fop  = FOP,                    \
24244 +       .op   = OP,                     \
24245 +}
24246 +
24247 +
24248 +#define DIR(NAME, MODE, OTYPE)                         \
24249 +       NOD(NAME, (S_IFDIR | (MODE)),                   \
24250 +               &proc_ ## OTYPE ## _inode_operations,   \
24251 +               &proc_ ## OTYPE ## _file_operations, { } )
24252 +
24253 +#define INF(NAME, MODE, OTYPE)                         \
24254 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
24255 +               &proc_vs_info_file_operations,          \
24256 +               { .proc_vs_read = &proc_##OTYPE } )
24257 +
24258 +#define VINF(NAME, MODE, OTYPE)                                \
24259 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
24260 +               &proc_vx_info_file_operations,          \
24261 +               { .proc_vxi_read = &proc_##OTYPE } )
24262 +
24263 +#define NINF(NAME, MODE, OTYPE)                                \
24264 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
24265 +               &proc_nx_info_file_operations,          \
24266 +               { .proc_nxi_read = &proc_##OTYPE } )
24267 +
24268 +
24269 +static struct file_operations proc_vs_info_file_operations = {
24270 +       .read =         proc_vs_info_read,
24271 +};
24272 +
24273 +static struct file_operations proc_vx_info_file_operations = {
24274 +       .read =         proc_vx_info_read,
24275 +};
24276 +
24277 +static struct dentry_operations proc_xid_dentry_operations = {
24278 +       .d_revalidate = proc_xid_revalidate,
24279 +};
24280 +
24281 +static struct vs_entry vx_base_stuff[] = {
24282 +       VINF("info",    S_IRUGO, vxi_info),
24283 +       VINF("status",  S_IRUGO, vxi_status),
24284 +       VINF("limit",   S_IRUGO, vxi_limit),
24285 +       VINF("sched",   S_IRUGO, vxi_sched),
24286 +       VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
24287 +       VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
24288 +       VINF("cvirt",   S_IRUGO, vxi_cvirt),
24289 +       VINF("cacct",   S_IRUGO, vxi_cacct),
24290 +       {}
24291 +};
24292 +
24293 +
24294 +
24295 +
24296 +static struct dentry *proc_xid_instantiate(struct inode *dir,
24297 +       struct dentry *dentry, int id, void *ptr)
24298 +{
24299 +       dentry->d_op = &proc_xid_dentry_operations;
24300 +       return vs_proc_instantiate(dir, dentry, id, ptr);
24301 +}
24302 +
24303 +static struct dentry *proc_xid_lookup(struct inode *dir,
24304 +       struct dentry *dentry, struct nameidata *nd)
24305 +{
24306 +       struct vs_entry *p = vx_base_stuff;
24307 +       struct dentry *error = ERR_PTR(-ENOENT);
24308 +
24309 +       for (; p->name; p++) {
24310 +               if (p->len != dentry->d_name.len)
24311 +                       continue;
24312 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24313 +                       break;
24314 +       }
24315 +       if (!p->name)
24316 +               goto out;
24317 +
24318 +       error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
24319 +out:
24320 +       return error;
24321 +}
24322 +
24323 +static int proc_xid_readdir(struct file *filp,
24324 +       void *dirent, filldir_t filldir)
24325 +{
24326 +       struct dentry *dentry = filp->f_dentry;
24327 +       struct inode *inode = dentry->d_inode;
24328 +       struct vs_entry *p = vx_base_stuff;
24329 +       int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
24330 +       int pos, index;
24331 +       u64 ino;
24332 +
24333 +       pos = filp->f_pos;
24334 +       switch (pos) {
24335 +       case 0:
24336 +               ino = inode->i_ino;
24337 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24338 +                       goto out;
24339 +               pos++;
24340 +               /* fall through */
24341 +       case 1:
24342 +               ino = parent_ino(dentry);
24343 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24344 +                       goto out;
24345 +               pos++;
24346 +               /* fall through */
24347 +       default:
24348 +               index = pos - 2;
24349 +               if (index >= size)
24350 +                       goto out;
24351 +               for (p += index; p->name; p++) {
24352 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24353 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
24354 +                               goto out;
24355 +                       pos++;
24356 +               }
24357 +       }
24358 +out:
24359 +       filp->f_pos = pos;
24360 +       return 1;
24361 +}
24362 +
24363 +
24364 +
24365 +static struct file_operations proc_nx_info_file_operations = {
24366 +       .read =         proc_nx_info_read,
24367 +};
24368 +
24369 +static struct dentry_operations proc_nid_dentry_operations = {
24370 +       .d_revalidate = proc_nid_revalidate,
24371 +};
24372 +
24373 +static struct vs_entry nx_base_stuff[] = {
24374 +       NINF("info",    S_IRUGO, nxi_info),
24375 +       NINF("status",  S_IRUGO, nxi_status),
24376 +       {}
24377 +};
24378 +
24379 +
24380 +static struct dentry *proc_nid_instantiate(struct inode *dir,
24381 +       struct dentry *dentry, int id, void *ptr)
24382 +{
24383 +       dentry->d_op = &proc_nid_dentry_operations;
24384 +       return vs_proc_instantiate(dir, dentry, id, ptr);
24385 +}
24386 +
24387 +static struct dentry *proc_nid_lookup(struct inode *dir,
24388 +       struct dentry *dentry, struct nameidata *nd)
24389 +{
24390 +       struct vs_entry *p = nx_base_stuff;
24391 +       struct dentry *error = ERR_PTR(-ENOENT);
24392 +
24393 +       for (; p->name; p++) {
24394 +               if (p->len != dentry->d_name.len)
24395 +                       continue;
24396 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24397 +                       break;
24398 +       }
24399 +       if (!p->name)
24400 +               goto out;
24401 +
24402 +       error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
24403 +out:
24404 +       return error;
24405 +}
24406 +
24407 +static int proc_nid_readdir(struct file *filp,
24408 +       void *dirent, filldir_t filldir)
24409 +{
24410 +       struct dentry *dentry = filp->f_dentry;
24411 +       struct inode *inode = dentry->d_inode;
24412 +       struct vs_entry *p = nx_base_stuff;
24413 +       int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
24414 +       int pos, index;
24415 +       u64 ino;
24416 +
24417 +       pos = filp->f_pos;
24418 +       switch (pos) {
24419 +       case 0:
24420 +               ino = inode->i_ino;
24421 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24422 +                       goto out;
24423 +               pos++;
24424 +               /* fall through */
24425 +       case 1:
24426 +               ino = parent_ino(dentry);
24427 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24428 +                       goto out;
24429 +               pos++;
24430 +               /* fall through */
24431 +       default:
24432 +               index = pos - 2;
24433 +               if (index >= size)
24434 +                       goto out;
24435 +               for (p += index; p->name; p++) {
24436 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24437 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
24438 +                               goto out;
24439 +                       pos++;
24440 +               }
24441 +       }
24442 +out:
24443 +       filp->f_pos = pos;
24444 +       return 1;
24445 +}
24446 +
24447 +
24448 +#define MAX_MULBY10    ((~0U - 9) / 10)
24449 +
24450 +static inline int atovid(const char *str, int len)
24451 +{
24452 +       int vid, c;
24453 +
24454 +       vid = 0;
24455 +       while (len-- > 0) {
24456 +               c = *str - '0';
24457 +               str++;
24458 +               if (c > 9)
24459 +                       return -1;
24460 +               if (vid >= MAX_MULBY10)
24461 +                       return -1;
24462 +               vid *= 10;
24463 +               vid += c;
24464 +               if (!vid)
24465 +                       return -1;
24466 +       }
24467 +       return vid;
24468 +}
24469 +
24470 +/* now the upper level (virtual) */
24471 +
24472 +
24473 +static struct file_operations proc_xid_file_operations = {
24474 +       .read =         generic_read_dir,
24475 +       .readdir =      proc_xid_readdir,
24476 +};
24477 +
24478 +static struct inode_operations proc_xid_inode_operations = {
24479 +       .lookup =       proc_xid_lookup,
24480 +};
24481 +
24482 +static struct vs_entry vx_virtual_stuff[] = {
24483 +       INF("info",     S_IRUGO, virtual_info),
24484 +       INF("status",   S_IRUGO, virtual_status),
24485 +       DIR(NULL,       S_IRUGO | S_IXUGO, xid),
24486 +};
24487 +
24488 +
24489 +static struct dentry *proc_virtual_lookup(struct inode *dir,
24490 +       struct dentry *dentry, struct nameidata *nd)
24491 +{
24492 +       struct vs_entry *p = vx_virtual_stuff;
24493 +       struct dentry *error = ERR_PTR(-ENOENT);
24494 +       int id = 0;
24495 +
24496 +       for (; p->name; p++) {
24497 +               if (p->len != dentry->d_name.len)
24498 +                       continue;
24499 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24500 +                       break;
24501 +       }
24502 +       if (p->name)
24503 +               goto instantiate;
24504 +
24505 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
24506 +       if ((id < 0) || !xid_is_hashed(id))
24507 +               goto out;
24508 +
24509 +instantiate:
24510 +       error = proc_xid_instantiate(dir, dentry, id, p);
24511 +out:
24512 +       return error;
24513 +}
24514 +
24515 +static struct file_operations proc_nid_file_operations = {
24516 +       .read =         generic_read_dir,
24517 +       .readdir =      proc_nid_readdir,
24518 +};
24519 +
24520 +static struct inode_operations proc_nid_inode_operations = {
24521 +       .lookup =       proc_nid_lookup,
24522 +};
24523 +
24524 +static struct vs_entry nx_virtnet_stuff[] = {
24525 +       INF("info",     S_IRUGO, virtnet_info),
24526 +       INF("status",   S_IRUGO, virtnet_status),
24527 +       DIR(NULL,       S_IRUGO | S_IXUGO, nid),
24528 +};
24529 +
24530 +
24531 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
24532 +       struct dentry *dentry, struct nameidata *nd)
24533 +{
24534 +       struct vs_entry *p = nx_virtnet_stuff;
24535 +       struct dentry *error = ERR_PTR(-ENOENT);
24536 +       int id = 0;
24537 +
24538 +       for (; p->name; p++) {
24539 +               if (p->len != dentry->d_name.len)
24540 +                       continue;
24541 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24542 +                       break;
24543 +       }
24544 +       if (p->name)
24545 +               goto instantiate;
24546 +
24547 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
24548 +       if ((id < 0) || !nid_is_hashed(id))
24549 +               goto out;
24550 +
24551 +instantiate:
24552 +       error = proc_nid_instantiate(dir, dentry, id, p);
24553 +out:
24554 +       return error;
24555 +}
24556 +
24557 +
24558 +#define PROC_MAXVIDS 32
24559 +
24560 +int proc_virtual_readdir(struct file *filp,
24561 +       void *dirent, filldir_t filldir)
24562 +{
24563 +       struct dentry *dentry = filp->f_dentry;
24564 +       struct inode *inode = dentry->d_inode;
24565 +       struct vs_entry *p = vx_virtual_stuff;
24566 +       int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24567 +       int pos, index;
24568 +       unsigned int xid_array[PROC_MAXVIDS];
24569 +       char buf[PROC_NUMBUF];
24570 +       unsigned int nr_xids, i;
24571 +       u64 ino;
24572 +
24573 +       pos = filp->f_pos;
24574 +       switch (pos) {
24575 +       case 0:
24576 +               ino = inode->i_ino;
24577 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24578 +                       goto out;
24579 +               pos++;
24580 +               /* fall through */
24581 +       case 1:
24582 +               ino = parent_ino(dentry);
24583 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24584 +                       goto out;
24585 +               pos++;
24586 +               /* fall through */
24587 +       default:
24588 +               index = pos - 2;
24589 +               if (index >= size)
24590 +                       goto entries;
24591 +               for (p += index; p->name; p++) {
24592 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24593 +                               vs_proc_instantiate, 0, p))
24594 +                               goto out;
24595 +                       pos++;
24596 +               }
24597 +       entries:
24598 +               index = pos - size;
24599 +               p = &vx_virtual_stuff[size - 1];
24600 +               nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24601 +               for (i = 0; i < nr_xids; i++) {
24602 +                       int n, xid = xid_array[i];
24603 +                       unsigned int j = PROC_NUMBUF;
24604 +
24605 +                       n = xid;
24606 +                       do
24607 +                               buf[--j] = '0' + (n % 10);
24608 +                       while (n /= 10);
24609 +
24610 +                       if (proc_fill_cache(filp, dirent, filldir,
24611 +                               buf + j, PROC_NUMBUF - j,
24612 +                               vs_proc_instantiate, xid, p))
24613 +                               goto out;
24614 +                       pos++;
24615 +               }
24616 +       }
24617 +out:
24618 +       filp->f_pos = pos;
24619 +       return 0;
24620 +}
24621 +
24622 +static int proc_virtual_getattr(struct vfsmount *mnt,
24623 +       struct dentry *dentry, struct kstat *stat)
24624 +{
24625 +       struct inode *inode = dentry->d_inode;
24626 +
24627 +       generic_fillattr(inode, stat);
24628 +       stat->nlink = 2 + atomic_read(&vx_global_cactive);
24629 +       return 0;
24630 +}
24631 +
24632 +static struct file_operations proc_virtual_dir_operations = {
24633 +       .read =         generic_read_dir,
24634 +       .readdir =      proc_virtual_readdir,
24635 +};
24636 +
24637 +static struct inode_operations proc_virtual_dir_inode_operations = {
24638 +       .getattr =      proc_virtual_getattr,
24639 +       .lookup =       proc_virtual_lookup,
24640 +};
24641 +
24642 +
24643 +
24644 +
24645 +
24646 +int proc_virtnet_readdir(struct file *filp,
24647 +       void *dirent, filldir_t filldir)
24648 +{
24649 +       struct dentry *dentry = filp->f_dentry;
24650 +       struct inode *inode = dentry->d_inode;
24651 +       struct vs_entry *p = nx_virtnet_stuff;
24652 +       int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24653 +       int pos, index;
24654 +       unsigned int nid_array[PROC_MAXVIDS];
24655 +       char buf[PROC_NUMBUF];
24656 +       unsigned int nr_nids, i;
24657 +       u64 ino;
24658 +
24659 +       pos = filp->f_pos;
24660 +       switch (pos) {
24661 +       case 0:
24662 +               ino = inode->i_ino;
24663 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24664 +                       goto out;
24665 +               pos++;
24666 +               /* fall through */
24667 +       case 1:
24668 +               ino = parent_ino(dentry);
24669 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24670 +                       goto out;
24671 +               pos++;
24672 +               /* fall through */
24673 +       default:
24674 +               index = pos - 2;
24675 +               if (index >= size)
24676 +                       goto entries;
24677 +               for (p += index; p->name; p++) {
24678 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24679 +                               vs_proc_instantiate, 0, p))
24680 +                               goto out;
24681 +                       pos++;
24682 +               }
24683 +       entries:
24684 +               index = pos - size;
24685 +               p = &nx_virtnet_stuff[size - 1];
24686 +               nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24687 +               for (i = 0; i < nr_nids; i++) {
24688 +                       int n, nid = nid_array[i];
24689 +                       unsigned int j = PROC_NUMBUF;
24690 +
24691 +                       n = nid;
24692 +                       do
24693 +                               buf[--j] = '0' + (n % 10);
24694 +                       while (n /= 10);
24695 +
24696 +                       if (proc_fill_cache(filp, dirent, filldir,
24697 +                               buf + j, PROC_NUMBUF - j,
24698 +                               vs_proc_instantiate, nid, p))
24699 +                               goto out;
24700 +                       pos++;
24701 +               }
24702 +       }
24703 +out:
24704 +       filp->f_pos = pos;
24705 +       return 0;
24706 +}
24707 +
24708 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24709 +       struct dentry *dentry, struct kstat *stat)
24710 +{
24711 +       struct inode *inode = dentry->d_inode;
24712 +
24713 +       generic_fillattr(inode, stat);
24714 +       stat->nlink = 2 + atomic_read(&nx_global_cactive);
24715 +       return 0;
24716 +}
24717 +
24718 +static struct file_operations proc_virtnet_dir_operations = {
24719 +       .read =         generic_read_dir,
24720 +       .readdir =      proc_virtnet_readdir,
24721 +};
24722 +
24723 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24724 +       .getattr =      proc_virtnet_getattr,
24725 +       .lookup =       proc_virtnet_lookup,
24726 +};
24727 +
24728 +
24729 +
24730 +void proc_vx_init(void)
24731 +{
24732 +       struct proc_dir_entry *ent;
24733 +
24734 +       ent = proc_mkdir("virtual", 0);
24735 +       if (ent) {
24736 +               ent->proc_fops = &proc_virtual_dir_operations;
24737 +               ent->proc_iops = &proc_virtual_dir_inode_operations;
24738 +       }
24739 +       proc_virtual = ent;
24740 +
24741 +       ent = proc_mkdir("virtnet", 0);
24742 +       if (ent) {
24743 +               ent->proc_fops = &proc_virtnet_dir_operations;
24744 +               ent->proc_iops = &proc_virtnet_dir_inode_operations;
24745 +       }
24746 +       proc_virtnet = ent;
24747 +}
24748 +
24749 +
24750 +
24751 +
24752 +/* per pid info */
24753 +
24754 +
24755 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24756 +{
24757 +       struct vx_info *vxi;
24758 +       char *orig = buffer;
24759 +
24760 +       buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24761 +
24762 +       vxi = task_get_vx_info(p);
24763 +       if (!vxi)
24764 +               goto out;
24765 +
24766 +       buffer += sprintf(buffer, "BCaps:\t");
24767 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24768 +       buffer += sprintf(buffer, "\n");
24769 +       buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24770 +               (unsigned long long)vxi->vx_ccaps);
24771 +       buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24772 +               (unsigned long long)vxi->vx_flags);
24773 +       buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24774 +
24775 +       put_vx_info(vxi);
24776 +out:
24777 +       return buffer - orig;
24778 +}
24779 +
24780 +
24781 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24782 +{
24783 +       struct nx_info *nxi;
24784 +       struct nx_addr_v4 *v4a;
24785 +#ifdef CONFIG_IPV6
24786 +       struct nx_addr_v6 *v6a;
24787 +#endif
24788 +       char *orig = buffer;
24789 +       int i;
24790 +
24791 +       buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24792 +
24793 +       nxi = task_get_nx_info(p);
24794 +       if (!nxi)
24795 +               goto out;
24796 +
24797 +       buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24798 +               (unsigned long long)nxi->nx_ncaps);
24799 +       buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24800 +               (unsigned long long)nxi->nx_flags);
24801 +
24802 +       buffer += sprintf(buffer,
24803 +               "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24804 +               NIPQUAD(nxi->v4_bcast.s_addr));
24805 +       buffer += sprintf (buffer,
24806 +               "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24807 +               NIPQUAD(nxi->v4_lback.s_addr));
24808 +       if (!NX_IPV4(nxi))
24809 +               goto skip_v4;
24810 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24811 +               buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24812 +                       i, NXAV4(v4a));
24813 +skip_v4:
24814 +#ifdef CONFIG_IPV6
24815 +       if (!NX_IPV6(nxi))
24816 +               goto skip_v6;
24817 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24818 +               buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24819 +                       i, NXAV6(v6a));
24820 +skip_v6:
24821 +#endif
24822 +       put_nx_info(nxi);
24823 +out:
24824 +       return buffer - orig;
24825 +}
24826 +
24827 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/sched.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/sched.c
24828 --- linux-2.6.33.2/kernel/vserver/sched.c       1970-01-01 01:00:00.000000000 +0100
24829 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/sched.c       2010-02-25 12:02:16.000000000 +0100
24830 @@ -0,0 +1,414 @@
24831 +/*
24832 + *  linux/kernel/vserver/sched.c
24833 + *
24834 + *  Virtual Server: Scheduler Support
24835 + *
24836 + *  Copyright (C) 2004-2007  Herbert Pötzl
24837 + *
24838 + *  V0.01  adapted Sam Vilains version to 2.6.3
24839 + *  V0.02  removed legacy interface
24840 + *  V0.03  changed vcmds to vxi arg
24841 + *  V0.04  removed older and legacy interfaces
24842 + *
24843 + */
24844 +
24845 +#include <linux/vs_context.h>
24846 +#include <linux/vs_sched.h>
24847 +#include <linux/vserver/sched_cmd.h>
24848 +
24849 +#include <asm/uaccess.h>
24850 +
24851 +
24852 +#define vxd_check_range(val, min, max) do {            \
24853 +       vxlprintk((val < min) || (val > max),           \
24854 +               "check_range(%ld,%ld,%ld)",             \
24855 +               (long)val, (long)min, (long)max,        \
24856 +               __FILE__, __LINE__);                    \
24857 +       } while (0)
24858 +
24859 +
24860 +void vx_update_sched_param(struct _vx_sched *sched,
24861 +       struct _vx_sched_pc *sched_pc)
24862 +{
24863 +       unsigned int set_mask = sched->update_mask;
24864 +
24865 +       if (set_mask & VXSM_FILL_RATE)
24866 +               sched_pc->fill_rate[0] = sched->fill_rate[0];
24867 +       if (set_mask & VXSM_INTERVAL)
24868 +               sched_pc->interval[0] = sched->interval[0];
24869 +       if (set_mask & VXSM_FILL_RATE2)
24870 +               sched_pc->fill_rate[1] = sched->fill_rate[1];
24871 +       if (set_mask & VXSM_INTERVAL2)
24872 +               sched_pc->interval[1] = sched->interval[1];
24873 +       if (set_mask & VXSM_TOKENS)
24874 +               sched_pc->tokens = sched->tokens;
24875 +       if (set_mask & VXSM_TOKENS_MIN)
24876 +               sched_pc->tokens_min = sched->tokens_min;
24877 +       if (set_mask & VXSM_TOKENS_MAX)
24878 +               sched_pc->tokens_max = sched->tokens_max;
24879 +       if (set_mask & VXSM_PRIO_BIAS)
24880 +               sched_pc->prio_bias = sched->prio_bias;
24881 +
24882 +       if (set_mask & VXSM_IDLE_TIME)
24883 +               sched_pc->flags |= VXSF_IDLE_TIME;
24884 +       else
24885 +               sched_pc->flags &= ~VXSF_IDLE_TIME;
24886 +
24887 +       /* reset time */
24888 +       sched_pc->norm_time = jiffies;
24889 +}
24890 +
24891 +
24892 +/*
24893 + * recalculate the context's scheduling tokens
24894 + *
24895 + * ret > 0 : number of tokens available
24896 + * ret < 0 : on hold, check delta_min[]
24897 + *          -1 only jiffies
24898 + *          -2 also idle time
24899 + *
24900 + */
24901 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24902 +       unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24903 +{
24904 +       long delta;
24905 +       long tokens = 0;
24906 +       int flags = sched_pc->flags;
24907 +
24908 +       /* how much time did pass? */
24909 +       delta = *norm_time - sched_pc->norm_time;
24910 +       // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
24911 +       vxd_check_range(delta, 0, INT_MAX);
24912 +
24913 +       if (delta >= sched_pc->interval[0]) {
24914 +               long tokens, integral;
24915 +
24916 +               /* calc integral token part */
24917 +               tokens = delta / sched_pc->interval[0];
24918 +               integral = tokens * sched_pc->interval[0];
24919 +               tokens *= sched_pc->fill_rate[0];
24920 +#ifdef CONFIG_VSERVER_HARDCPU
24921 +               delta_min[0] = delta - integral;
24922 +               vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24923 +#endif
24924 +               /* advance time */
24925 +               sched_pc->norm_time += delta;
24926 +
24927 +               /* add tokens */
24928 +               sched_pc->tokens += tokens;
24929 +               sched_pc->token_time += tokens;
24930 +       } else
24931 +               delta_min[0] = delta;
24932 +
24933 +#ifdef CONFIG_VSERVER_IDLETIME
24934 +       if (!(flags & VXSF_IDLE_TIME))
24935 +               goto skip_idle;
24936 +
24937 +       /* how much was the idle skip? */
24938 +       delta = *idle_time - sched_pc->idle_time;
24939 +       vxd_check_range(delta, 0, INT_MAX);
24940 +
24941 +       if (delta >= sched_pc->interval[1]) {
24942 +               long tokens, integral;
24943 +
24944 +               /* calc fair share token part */
24945 +               tokens = delta / sched_pc->interval[1];
24946 +               integral = tokens * sched_pc->interval[1];
24947 +               tokens *= sched_pc->fill_rate[1];
24948 +               delta_min[1] = delta - integral;
24949 +               vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24950 +
24951 +               /* advance idle time */
24952 +               sched_pc->idle_time += integral;
24953 +
24954 +               /* add tokens */
24955 +               sched_pc->tokens += tokens;
24956 +               sched_pc->token_time += tokens;
24957 +       } else
24958 +               delta_min[1] = delta;
24959 +skip_idle:
24960 +#endif
24961 +
24962 +       /* clip at maximum */
24963 +       if (sched_pc->tokens > sched_pc->tokens_max)
24964 +               sched_pc->tokens = sched_pc->tokens_max;
24965 +       tokens = sched_pc->tokens;
24966 +
24967 +       if ((flags & VXSF_ONHOLD)) {
24968 +               /* can we unhold? */
24969 +               if (tokens >= sched_pc->tokens_min) {
24970 +                       flags &= ~VXSF_ONHOLD;
24971 +                       sched_pc->hold_ticks +=
24972 +                               *norm_time - sched_pc->onhold;
24973 +               } else
24974 +                       goto on_hold;
24975 +       } else {
24976 +               /* put on hold? */
24977 +               if (tokens <= 0) {
24978 +                       flags |= VXSF_ONHOLD;
24979 +                       sched_pc->onhold = *norm_time;
24980 +                       goto on_hold;
24981 +               }
24982 +       }
24983 +       sched_pc->flags = flags;
24984 +       return tokens;
24985 +
24986 +on_hold:
24987 +       tokens = sched_pc->tokens_min - tokens;
24988 +       sched_pc->flags = flags;
24989 +       // BUG_ON(tokens < 0); probably doesn't hold anymore
24990 +
24991 +#ifdef CONFIG_VSERVER_HARDCPU
24992 +       /* next interval? */
24993 +       if (!sched_pc->fill_rate[0])
24994 +               delta_min[0] = HZ;
24995 +       else if (tokens > sched_pc->fill_rate[0])
24996 +               delta_min[0] += sched_pc->interval[0] *
24997 +                       tokens / sched_pc->fill_rate[0];
24998 +       else
24999 +               delta_min[0] = sched_pc->interval[0] - delta_min[0];
25000 +       vxd_check_range(delta_min[0], 0, INT_MAX);
25001 +
25002 +#ifdef CONFIG_VSERVER_IDLETIME
25003 +       if (!(flags & VXSF_IDLE_TIME))
25004 +               return -1;
25005 +
25006 +       /* next interval? */
25007 +       if (!sched_pc->fill_rate[1])
25008 +               delta_min[1] = HZ;
25009 +       else if (tokens > sched_pc->fill_rate[1])
25010 +               delta_min[1] += sched_pc->interval[1] *
25011 +                       tokens / sched_pc->fill_rate[1];
25012 +       else
25013 +               delta_min[1] = sched_pc->interval[1] - delta_min[1];
25014 +       vxd_check_range(delta_min[1], 0, INT_MAX);
25015 +
25016 +       return -2;
25017 +#else
25018 +       return -1;
25019 +#endif /* CONFIG_VSERVER_IDLETIME */
25020 +#else
25021 +       return 0;
25022 +#endif /* CONFIG_VSERVER_HARDCPU */
25023 +}
25024 +
25025 +static inline unsigned long msec_to_ticks(unsigned long msec)
25026 +{
25027 +       return msecs_to_jiffies(msec);
25028 +}
25029 +
25030 +static inline unsigned long ticks_to_msec(unsigned long ticks)
25031 +{
25032 +       return jiffies_to_msecs(ticks);
25033 +}
25034 +
25035 +static inline unsigned long ticks_to_usec(unsigned long ticks)
25036 +{
25037 +       return jiffies_to_usecs(ticks);
25038 +}
25039 +
25040 +
25041 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
25042 +{
25043 +       unsigned int set_mask = data->mask;
25044 +       unsigned int update_mask;
25045 +       int i, cpu;
25046 +
25047 +       /* Sanity check data values */
25048 +       if (data->tokens_max <= 0)
25049 +               data->tokens_max = HZ;
25050 +       if (data->tokens_min < 0)
25051 +               data->tokens_min = HZ / 3;
25052 +       if (data->tokens_min >= data->tokens_max)
25053 +               data->tokens_min = data->tokens_max;
25054 +
25055 +       if (data->prio_bias > MAX_PRIO_BIAS)
25056 +               data->prio_bias = MAX_PRIO_BIAS;
25057 +       if (data->prio_bias < MIN_PRIO_BIAS)
25058 +               data->prio_bias = MIN_PRIO_BIAS;
25059 +
25060 +       spin_lock(&vxi->sched.tokens_lock);
25061 +
25062 +       /* sync up on delayed updates */
25063 +       for_each_cpu_mask(cpu, vxi->sched.update)
25064 +               vx_update_sched_param(&vxi->sched,
25065 +                       &vx_per_cpu(vxi, sched_pc, cpu));
25066 +
25067 +       if (set_mask & VXSM_FILL_RATE)
25068 +               vxi->sched.fill_rate[0] = data->fill_rate[0];
25069 +       if (set_mask & VXSM_FILL_RATE2)
25070 +               vxi->sched.fill_rate[1] = data->fill_rate[1];
25071 +       if (set_mask & VXSM_INTERVAL)
25072 +               vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
25073 +                       msec_to_ticks(data->interval[0]) : data->interval[0];
25074 +       if (set_mask & VXSM_INTERVAL2)
25075 +               vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
25076 +                       msec_to_ticks(data->interval[1]) : data->interval[1];
25077 +       if (set_mask & VXSM_TOKENS)
25078 +               vxi->sched.tokens = data->tokens;
25079 +       if (set_mask & VXSM_TOKENS_MIN)
25080 +               vxi->sched.tokens_min = data->tokens_min;
25081 +       if (set_mask & VXSM_TOKENS_MAX)
25082 +               vxi->sched.tokens_max = data->tokens_max;
25083 +       if (set_mask & VXSM_PRIO_BIAS)
25084 +               vxi->sched.prio_bias = data->prio_bias;
25085 +
25086 +       /* Sanity check rate/interval */
25087 +       for (i = 0; i < 2; i++) {
25088 +               if (data->fill_rate[i] < 0)
25089 +                       data->fill_rate[i] = 0;
25090 +               if (data->interval[i] <= 0)
25091 +                       data->interval[i] = HZ;
25092 +       }
25093 +
25094 +       update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
25095 +       update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
25096 +       vxi->sched.update_mask = update_mask;
25097 +
25098 +#ifdef CONFIG_SMP
25099 +       rmb();
25100 +       if (set_mask & VXSM_CPU_ID) {
25101 +               vxi->sched.update = cpumask_of_cpu(data->cpu_id);
25102 +               cpus_and(vxi->sched.update, cpu_online_map,
25103 +                       vxi->sched.update);
25104 +       } else
25105 +               vxi->sched.update = cpu_online_map;
25106 +
25107 +       /* forced reload? */
25108 +       if (set_mask & VXSM_FORCE) {
25109 +               for_each_cpu_mask(cpu, vxi->sched.update)
25110 +                       vx_update_sched_param(&vxi->sched,
25111 +                               &vx_per_cpu(vxi, sched_pc, cpu));
25112 +               vxi->sched.update = CPU_MASK_NONE;
25113 +       }
25114 +#else
25115 +       /* on UP we update immediately */
25116 +       vx_update_sched_param(&vxi->sched,
25117 +               &vx_per_cpu(vxi, sched_pc, 0));
25118 +#endif
25119 +
25120 +       spin_unlock(&vxi->sched.tokens_lock);
25121 +       return 0;
25122 +}
25123 +
25124 +
25125 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
25126 +#define COPY_PRI(C) C(prio_bias)
25127 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
25128 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]);   \
25129 +                   C(fill_rate[1]); C(interval[1]);
25130 +
25131 +#define COPY_VALUE(name) vc_data.name = data->name
25132 +
25133 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
25134 +{
25135 +       struct vcmd_sched_v5 vc_data;
25136 +
25137 +       vc_data.mask = data->set_mask;
25138 +       COPY_IDS(COPY_VALUE);
25139 +       COPY_PRI(COPY_VALUE);
25140 +       COPY_TOK(COPY_VALUE);
25141 +       vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
25142 +       vc_data.interval[0] = vc_data.interval[1] = data->interval;
25143 +       return do_set_sched(vxi, &vc_data);
25144 +}
25145 +
25146 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
25147 +{
25148 +       struct vcmd_set_sched_v4 vc_data;
25149 +
25150 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25151 +               return -EFAULT;
25152 +
25153 +       return do_set_sched_v4(vxi, &vc_data);
25154 +}
25155 +
25156 +       /* latest interface is v5 */
25157 +
25158 +int vc_set_sched(struct vx_info *vxi, void __user *data)
25159 +{
25160 +       struct vcmd_sched_v5 vc_data;
25161 +
25162 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25163 +               return -EFAULT;
25164 +
25165 +       return do_set_sched(vxi, &vc_data);
25166 +}
25167 +
25168 +
25169 +#define COPY_PRI(C) C(prio_bias)
25170 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
25171 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]);    \
25172 +                   C(fill_rate[1]); C(interval[1]);
25173 +
25174 +#define COPY_VALUE(name) vc_data.name = data->name
25175 +
25176 +
25177 +int vc_get_sched(struct vx_info *vxi, void __user *data)
25178 +{
25179 +       struct vcmd_sched_v5 vc_data;
25180 +
25181 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25182 +               return -EFAULT;
25183 +
25184 +       if (vc_data.mask & VXSM_CPU_ID) {
25185 +               int cpu = vc_data.cpu_id;
25186 +               struct _vx_sched_pc *data;
25187 +
25188 +               if (!cpu_possible(cpu))
25189 +                       return -EINVAL;
25190 +
25191 +               data = &vx_per_cpu(vxi, sched_pc, cpu);
25192 +               COPY_TOK(COPY_VALUE);
25193 +               COPY_PRI(COPY_VALUE);
25194 +               COPY_FRI(COPY_VALUE);
25195 +
25196 +               if (data->flags & VXSF_IDLE_TIME)
25197 +                       vc_data.mask |= VXSM_IDLE_TIME;
25198 +       } else {
25199 +               struct _vx_sched *data = &vxi->sched;
25200 +
25201 +               COPY_TOK(COPY_VALUE);
25202 +               COPY_PRI(COPY_VALUE);
25203 +               COPY_FRI(COPY_VALUE);
25204 +       }
25205 +
25206 +       if (vc_data.mask & VXSM_MSEC) {
25207 +               vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
25208 +               vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
25209 +       }
25210 +
25211 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25212 +               return -EFAULT;
25213 +       return 0;
25214 +}
25215 +
25216 +
25217 +int vc_sched_info(struct vx_info *vxi, void __user *data)
25218 +{
25219 +       struct vcmd_sched_info vc_data;
25220 +       int cpu;
25221 +
25222 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25223 +               return -EFAULT;
25224 +
25225 +       cpu = vc_data.cpu_id;
25226 +       if (!cpu_possible(cpu))
25227 +               return -EINVAL;
25228 +
25229 +       if (vxi) {
25230 +               struct _vx_sched_pc *sched_pc =
25231 +                       &vx_per_cpu(vxi, sched_pc, cpu);
25232 +
25233 +               vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
25234 +               vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
25235 +               vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
25236 +               vc_data.vavavoom = sched_pc->vavavoom;
25237 +       }
25238 +       vc_data.token_usec = ticks_to_usec(1);
25239 +
25240 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25241 +               return -EFAULT;
25242 +       return 0;
25243 +}
25244 +
25245 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/sched_init.h linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/sched_init.h
25246 --- linux-2.6.33.2/kernel/vserver/sched_init.h  1970-01-01 01:00:00.000000000 +0100
25247 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/sched_init.h  2010-02-25 12:02:16.000000000 +0100
25248 @@ -0,0 +1,50 @@
25249 +
25250 +static inline void vx_info_init_sched(struct _vx_sched *sched)
25251 +{
25252 +       static struct lock_class_key tokens_lock_key;
25253 +
25254 +       /* scheduling; hard code starting values as constants */
25255 +       sched->fill_rate[0]     = 1;
25256 +       sched->interval[0]      = 4;
25257 +       sched->fill_rate[1]     = 1;
25258 +       sched->interval[1]      = 8;
25259 +       sched->tokens           = HZ >> 2;
25260 +       sched->tokens_min       = HZ >> 4;
25261 +       sched->tokens_max       = HZ >> 1;
25262 +       sched->tokens_lock      = SPIN_LOCK_UNLOCKED;
25263 +       sched->prio_bias        = 0;
25264 +
25265 +       lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
25266 +}
25267 +
25268 +static inline
25269 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
25270 +{
25271 +       sched_pc->fill_rate[0]  = 1;
25272 +       sched_pc->interval[0]   = 4;
25273 +       sched_pc->fill_rate[1]  = 1;
25274 +       sched_pc->interval[1]   = 8;
25275 +       sched_pc->tokens        = HZ >> 2;
25276 +       sched_pc->tokens_min    = HZ >> 4;
25277 +       sched_pc->tokens_max    = HZ >> 1;
25278 +       sched_pc->prio_bias     = 0;
25279 +       sched_pc->vavavoom      = 0;
25280 +       sched_pc->token_time    = 0;
25281 +       sched_pc->idle_time     = 0;
25282 +       sched_pc->norm_time     = jiffies;
25283 +
25284 +       sched_pc->user_ticks = 0;
25285 +       sched_pc->sys_ticks = 0;
25286 +       sched_pc->hold_ticks = 0;
25287 +}
25288 +
25289 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
25290 +{
25291 +       return;
25292 +}
25293 +
25294 +static inline
25295 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
25296 +{
25297 +       return;
25298 +}
25299 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/sched_proc.h linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/sched_proc.h
25300 --- linux-2.6.33.2/kernel/vserver/sched_proc.h  1970-01-01 01:00:00.000000000 +0100
25301 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/sched_proc.h  2010-02-25 12:02:16.000000000 +0100
25302 @@ -0,0 +1,57 @@
25303 +#ifndef _VX_SCHED_PROC_H
25304 +#define _VX_SCHED_PROC_H
25305 +
25306 +
25307 +static inline
25308 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
25309 +{
25310 +       int length = 0;
25311 +
25312 +       length += sprintf(buffer,
25313 +               "FillRate:\t%8d,%d\n"
25314 +               "Interval:\t%8d,%d\n"
25315 +               "TokensMin:\t%8d\n"
25316 +               "TokensMax:\t%8d\n"
25317 +               "PrioBias:\t%8d\n",
25318 +               sched->fill_rate[0],
25319 +               sched->fill_rate[1],
25320 +               sched->interval[0],
25321 +               sched->interval[1],
25322 +               sched->tokens_min,
25323 +               sched->tokens_max,
25324 +               sched->prio_bias);
25325 +       return length;
25326 +}
25327 +
25328 +static inline
25329 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
25330 +       char *buffer, int cpu)
25331 +{
25332 +       int length = 0;
25333 +
25334 +       length += sprintf(buffer + length,
25335 +               "cpu %d: %lld %lld %lld %ld %ld", cpu,
25336 +               (unsigned long long)sched_pc->user_ticks,
25337 +               (unsigned long long)sched_pc->sys_ticks,
25338 +               (unsigned long long)sched_pc->hold_ticks,
25339 +               sched_pc->token_time,
25340 +               sched_pc->idle_time);
25341 +       length += sprintf(buffer + length,
25342 +               " %c%c %d %d %d %d/%d %d/%d",
25343 +               (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
25344 +               (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
25345 +               sched_pc->tokens,
25346 +               sched_pc->tokens_min,
25347 +               sched_pc->tokens_max,
25348 +               sched_pc->fill_rate[0],
25349 +               sched_pc->interval[0],
25350 +               sched_pc->fill_rate[1],
25351 +               sched_pc->interval[1]);
25352 +       length += sprintf(buffer + length,
25353 +               " %d %d\n",
25354 +               sched_pc->prio_bias,
25355 +               sched_pc->vavavoom);
25356 +       return length;
25357 +}
25358 +
25359 +#endif /* _VX_SCHED_PROC_H */
25360 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/signal.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/signal.c
25361 --- linux-2.6.33.2/kernel/vserver/signal.c      1970-01-01 01:00:00.000000000 +0100
25362 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/signal.c      2010-02-25 12:02:16.000000000 +0100
25363 @@ -0,0 +1,132 @@
25364 +/*
25365 + *  linux/kernel/vserver/signal.c
25366 + *
25367 + *  Virtual Server: Signal Support
25368 + *
25369 + *  Copyright (C) 2003-2007  Herbert Pötzl
25370 + *
25371 + *  V0.01  broken out from vcontext V0.05
25372 + *  V0.02  changed vcmds to vxi arg
25373 + *  V0.03  adjusted siginfo for kill
25374 + *
25375 + */
25376 +
25377 +#include <asm/uaccess.h>
25378 +
25379 +#include <linux/vs_context.h>
25380 +#include <linux/vs_pid.h>
25381 +#include <linux/vserver/signal_cmd.h>
25382 +
25383 +
25384 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
25385 +{
25386 +       int retval, count = 0;
25387 +       struct task_struct *p;
25388 +       struct siginfo *sip = SEND_SIG_PRIV;
25389 +
25390 +       retval = -ESRCH;
25391 +       vxdprintk(VXD_CBIT(misc, 4),
25392 +               "vx_info_kill(%p[#%d],%d,%d)*",
25393 +               vxi, vxi->vx_id, pid, sig);
25394 +       read_lock(&tasklist_lock);
25395 +       switch (pid) {
25396 +       case  0:
25397 +       case -1:
25398 +               for_each_process(p) {
25399 +                       int err = 0;
25400 +
25401 +                       if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
25402 +                               (pid && vxi->vx_initpid == p->pid))
25403 +                               continue;
25404 +
25405 +                       err = group_send_sig_info(sig, sip, p);
25406 +                       ++count;
25407 +                       if (err != -EPERM)
25408 +                               retval = err;
25409 +               }
25410 +               break;
25411 +
25412 +       case 1:
25413 +               if (vxi->vx_initpid) {
25414 +                       pid = vxi->vx_initpid;
25415 +                       /* for now, only SIGINT to private init ... */
25416 +                       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
25417 +                               /* ... as long as there are tasks left */
25418 +                               (atomic_read(&vxi->vx_tasks) > 1))
25419 +                               sig = SIGINT;
25420 +               }
25421 +               /* fallthrough */
25422 +       default:
25423 +               p = find_task_by_real_pid(pid);
25424 +               if (p) {
25425 +                       if (vx_task_xid(p) == vxi->vx_id)
25426 +                               retval = group_send_sig_info(sig, sip, p);
25427 +               }
25428 +               break;
25429 +       }
25430 +       read_unlock(&tasklist_lock);
25431 +       vxdprintk(VXD_CBIT(misc, 4),
25432 +               "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
25433 +               vxi, vxi->vx_id, pid, sig, (long)sip, retval);
25434 +       return retval;
25435 +}
25436 +
25437 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
25438 +{
25439 +       struct vcmd_ctx_kill_v0 vc_data;
25440 +
25441 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25442 +               return -EFAULT;
25443 +
25444 +       /* special check to allow guest shutdown */
25445 +       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
25446 +               /* forbid killall pid=0 when init is present */
25447 +               (((vc_data.pid < 1) && vxi->vx_initpid) ||
25448 +               (vc_data.pid > 1)))
25449 +               return -EACCES;
25450 +
25451 +       return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
25452 +}
25453 +
25454 +
25455 +static int __wait_exit(struct vx_info *vxi)
25456 +{
25457 +       DECLARE_WAITQUEUE(wait, current);
25458 +       int ret = 0;
25459 +
25460 +       add_wait_queue(&vxi->vx_wait, &wait);
25461 +       set_current_state(TASK_INTERRUPTIBLE);
25462 +
25463 +wait:
25464 +       if (vx_info_state(vxi,
25465 +               VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
25466 +               goto out;
25467 +       if (signal_pending(current)) {
25468 +               ret = -ERESTARTSYS;
25469 +               goto out;
25470 +       }
25471 +       schedule();
25472 +       goto wait;
25473 +
25474 +out:
25475 +       set_current_state(TASK_RUNNING);
25476 +       remove_wait_queue(&vxi->vx_wait, &wait);
25477 +       return ret;
25478 +}
25479 +
25480 +
25481 +
25482 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
25483 +{
25484 +       struct vcmd_wait_exit_v0 vc_data;
25485 +       int ret;
25486 +
25487 +       ret = __wait_exit(vxi);
25488 +       vc_data.reboot_cmd = vxi->reboot_cmd;
25489 +       vc_data.exit_code = vxi->exit_code;
25490 +
25491 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25492 +               ret = -EFAULT;
25493 +       return ret;
25494 +}
25495 +
25496 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/space.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/space.c
25497 --- linux-2.6.33.2/kernel/vserver/space.c       1970-01-01 01:00:00.000000000 +0100
25498 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/space.c       2010-02-25 12:02:16.000000000 +0100
25499 @@ -0,0 +1,375 @@
25500 +/*
25501 + *  linux/kernel/vserver/space.c
25502 + *
25503 + *  Virtual Server: Context Space Support
25504 + *
25505 + *  Copyright (C) 2003-2007  Herbert Pötzl
25506 + *
25507 + *  V0.01  broken out from context.c 0.07
25508 + *  V0.02  added task locking for namespace
25509 + *  V0.03  broken out vx_enter_namespace
25510 + *  V0.04  added *space support and commands
25511 + *
25512 + */
25513 +
25514 +#include <linux/utsname.h>
25515 +#include <linux/nsproxy.h>
25516 +#include <linux/err.h>
25517 +#include <linux/fs_struct.h>
25518 +#include <asm/uaccess.h>
25519 +
25520 +#include <linux/vs_context.h>
25521 +#include <linux/vserver/space.h>
25522 +#include <linux/vserver/space_cmd.h>
25523 +
25524 +atomic_t vs_global_nsproxy     = ATOMIC_INIT(0);
25525 +atomic_t vs_global_fs          = ATOMIC_INIT(0);
25526 +atomic_t vs_global_mnt_ns      = ATOMIC_INIT(0);
25527 +atomic_t vs_global_uts_ns      = ATOMIC_INIT(0);
25528 +atomic_t vs_global_user_ns     = ATOMIC_INIT(0);
25529 +atomic_t vs_global_pid_ns      = ATOMIC_INIT(0);
25530 +
25531 +
25532 +/* namespace functions */
25533 +
25534 +#include <linux/mnt_namespace.h>
25535 +#include <linux/user_namespace.h>
25536 +#include <linux/pid_namespace.h>
25537 +#include <linux/ipc_namespace.h>
25538 +#include <net/net_namespace.h>
25539 +
25540 +
25541 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
25542 +       .mask = CLONE_FS |
25543 +               CLONE_NEWNS |
25544 +               CLONE_NEWUTS |
25545 +               CLONE_NEWIPC |
25546 +               CLONE_NEWUSER |
25547 +               0
25548 +};
25549 +
25550 +static const struct vcmd_space_mask_v1 space_mask = {
25551 +       .mask = CLONE_FS |
25552 +               CLONE_NEWNS |
25553 +               CLONE_NEWUTS |
25554 +               CLONE_NEWIPC |
25555 +               CLONE_NEWUSER |
25556 +#ifdef CONFIG_PID_NS
25557 +               CLONE_NEWPID |
25558 +#endif
25559 +#ifdef CONFIG_NET_NS
25560 +               CLONE_NEWNET |
25561 +#endif
25562 +               0
25563 +};
25564 +
25565 +static const struct vcmd_space_mask_v1 default_space_mask = {
25566 +       .mask = CLONE_FS |
25567 +               CLONE_NEWNS |
25568 +               CLONE_NEWUTS |
25569 +               CLONE_NEWIPC |
25570 +               CLONE_NEWUSER |
25571 +#ifdef CONFIG_PID_NS
25572 +//             CLONE_NEWPID |
25573 +#endif
25574 +               0
25575 +};
25576 +
25577 +/*
25578 + *     build a new nsproxy mix
25579 + *      assumes that both proxies are 'const'
25580 + *     does not touch nsproxy refcounts
25581 + *     will hold a reference on the result.
25582 + */
25583 +
25584 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
25585 +       struct nsproxy *new_nsproxy, unsigned long mask)
25586 +{
25587 +       struct mnt_namespace *old_ns;
25588 +       struct uts_namespace *old_uts;
25589 +       struct ipc_namespace *old_ipc;
25590 +#ifdef CONFIG_PID_NS
25591 +       struct pid_namespace *old_pid;
25592 +#endif
25593 +#ifdef CONFIG_NET_NS
25594 +       struct net *old_net;
25595 +#endif
25596 +       struct nsproxy *nsproxy;
25597 +
25598 +       nsproxy = copy_nsproxy(old_nsproxy);
25599 +       if (!nsproxy)
25600 +               goto out;
25601 +
25602 +       if (mask & CLONE_NEWNS) {
25603 +               old_ns = nsproxy->mnt_ns;
25604 +               nsproxy->mnt_ns = new_nsproxy->mnt_ns;
25605 +               if (nsproxy->mnt_ns)
25606 +                       get_mnt_ns(nsproxy->mnt_ns);
25607 +       } else
25608 +               old_ns = NULL;
25609 +
25610 +       if (mask & CLONE_NEWUTS) {
25611 +               old_uts = nsproxy->uts_ns;
25612 +               nsproxy->uts_ns = new_nsproxy->uts_ns;
25613 +               if (nsproxy->uts_ns)
25614 +                       get_uts_ns(nsproxy->uts_ns);
25615 +       } else
25616 +               old_uts = NULL;
25617 +
25618 +       if (mask & CLONE_NEWIPC) {
25619 +               old_ipc = nsproxy->ipc_ns;
25620 +               nsproxy->ipc_ns = new_nsproxy->ipc_ns;
25621 +               if (nsproxy->ipc_ns)
25622 +                       get_ipc_ns(nsproxy->ipc_ns);
25623 +       } else
25624 +               old_ipc = NULL;
25625 +
25626 +#ifdef CONFIG_PID_NS
25627 +       if (mask & CLONE_NEWPID) {
25628 +               old_pid = nsproxy->pid_ns;
25629 +               nsproxy->pid_ns = new_nsproxy->pid_ns;
25630 +               if (nsproxy->pid_ns)
25631 +                       get_pid_ns(nsproxy->pid_ns);
25632 +       } else
25633 +               old_pid = NULL;
25634 +#endif
25635 +#ifdef CONFIG_NET_NS
25636 +       if (mask & CLONE_NEWNET) {
25637 +               old_net = nsproxy->net_ns;
25638 +               nsproxy->net_ns = new_nsproxy->net_ns;
25639 +               if (nsproxy->net_ns)
25640 +                       get_net(nsproxy->net_ns);
25641 +       } else
25642 +               old_net = NULL;
25643 +#endif
25644 +       if (old_ns)
25645 +               put_mnt_ns(old_ns);
25646 +       if (old_uts)
25647 +               put_uts_ns(old_uts);
25648 +       if (old_ipc)
25649 +               put_ipc_ns(old_ipc);
25650 +#ifdef CONFIG_PID_NS
25651 +       if (old_pid)
25652 +               put_pid_ns(old_pid);
25653 +#endif
25654 +#ifdef CONFIG_NET_NS
25655 +       if (old_net)
25656 +               put_net(old_net);
25657 +#endif
25658 +out:
25659 +       return nsproxy;
25660 +}
25661 +
25662 +
25663 +/*
25664 + *     merge two nsproxy structs into a new one.
25665 + *     will hold a reference on the result.
25666 + */
25667 +
25668 +static inline
25669 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
25670 +       struct nsproxy *proxy, unsigned long mask)
25671 +{
25672 +       struct nsproxy null_proxy = { .mnt_ns = NULL };
25673 +
25674 +       if (!proxy)
25675 +               return NULL;
25676 +
25677 +       if (mask) {
25678 +               /* vs_mix_nsproxy returns with reference */
25679 +               return vs_mix_nsproxy(old ? old : &null_proxy,
25680 +                       proxy, mask);
25681 +       }
25682 +       get_nsproxy(proxy);
25683 +       return proxy;
25684 +}
25685 +
25686 +
25687 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25688 +{
25689 +       struct nsproxy *proxy, *proxy_cur, *proxy_new;
25690 +       struct fs_struct *fs_cur, *fs = NULL;
25691 +       int ret, kill = 0;
25692 +
25693 +       vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
25694 +               vxi, vxi->vx_id, mask, index);
25695 +
25696 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
25697 +               return -EACCES;
25698 +
25699 +       if (!mask)
25700 +               mask = vxi->vx_nsmask[index];
25701 +
25702 +       if ((mask & vxi->vx_nsmask[index]) != mask)
25703 +               return -EINVAL;
25704 +
25705 +       if (mask & CLONE_FS) {
25706 +               fs = copy_fs_struct(vxi->vx_fs[index]);
25707 +               if (!fs)
25708 +                       return -ENOMEM;
25709 +       }
25710 +       proxy = vxi->vx_nsproxy[index];
25711 +
25712 +       vxdprintk(VXD_CBIT(space, 9),
25713 +               "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
25714 +               vxi, vxi->vx_id, mask, index, proxy, fs);
25715 +
25716 +       task_lock(current);
25717 +       fs_cur = current->fs;
25718 +
25719 +       if (mask & CLONE_FS) {
25720 +               write_lock(&fs_cur->lock);
25721 +               current->fs = fs;
25722 +               kill = !--fs_cur->users;
25723 +               write_unlock(&fs_cur->lock);
25724 +       }
25725 +
25726 +       proxy_cur = current->nsproxy;
25727 +       get_nsproxy(proxy_cur);
25728 +       task_unlock(current);
25729 +
25730 +       if (kill)
25731 +               free_fs_struct(fs_cur);
25732 +
25733 +       proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
25734 +       if (IS_ERR(proxy_new)) {
25735 +               ret = PTR_ERR(proxy_new);
25736 +               goto out_put;
25737 +       }
25738 +
25739 +       proxy_new = xchg(&current->nsproxy, proxy_new);
25740 +       ret = 0;
25741 +
25742 +       if (proxy_new)
25743 +               put_nsproxy(proxy_new);
25744 +out_put:
25745 +       if (proxy_cur)
25746 +               put_nsproxy(proxy_cur);
25747 +       return ret;
25748 +}
25749 +
25750 +
25751 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25752 +{
25753 +       struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25754 +       struct fs_struct *fs_vxi, *fs;
25755 +       int ret, kill = 0;
25756 +
25757 +       vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
25758 +               vxi, vxi->vx_id, mask, index);
25759 +#if 0
25760 +       if (!mask)
25761 +               mask = default_space_mask.mask;
25762 +#endif
25763 +       if ((mask & space_mask.mask) != mask)
25764 +               return -EINVAL;
25765 +
25766 +       proxy_vxi = vxi->vx_nsproxy[index];
25767 +       fs_vxi = vxi->vx_fs[index];
25768 +
25769 +       if (mask & CLONE_FS) {
25770 +               fs = copy_fs_struct(current->fs);
25771 +               if (!fs)
25772 +                       return -ENOMEM;
25773 +       }
25774 +
25775 +       task_lock(current);
25776 +
25777 +       if (mask & CLONE_FS) {
25778 +               write_lock(&fs_vxi->lock);
25779 +               vxi->vx_fs[index] = fs;
25780 +               kill = !--fs_vxi->users;
25781 +               write_unlock(&fs_vxi->lock);
25782 +       }
25783 +
25784 +       proxy_cur = current->nsproxy;
25785 +       get_nsproxy(proxy_cur);
25786 +       task_unlock(current);
25787 +
25788 +       if (kill)
25789 +               free_fs_struct(fs_vxi);
25790 +
25791 +       proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25792 +       if (IS_ERR(proxy_new)) {
25793 +               ret = PTR_ERR(proxy_new);
25794 +               goto out_put;
25795 +       }
25796 +
25797 +       proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
25798 +       vxi->vx_nsmask[index] |= mask;
25799 +       ret = 0;
25800 +
25801 +       if (proxy_new)
25802 +               put_nsproxy(proxy_new);
25803 +out_put:
25804 +       if (proxy_cur)
25805 +               put_nsproxy(proxy_cur);
25806 +       return ret;
25807 +}
25808 +
25809 +
25810 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25811 +{
25812 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25813 +
25814 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25815 +               return -EFAULT;
25816 +
25817 +       return vx_enter_space(vxi, vc_data.mask, 0);
25818 +}
25819 +
25820 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25821 +{
25822 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25823 +
25824 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25825 +               return -EFAULT;
25826 +
25827 +       if (vc_data.index >= VX_SPACES)
25828 +               return -EINVAL;
25829 +
25830 +       return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25831 +}
25832 +
25833 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25834 +{
25835 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25836 +
25837 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25838 +               return -EFAULT;
25839 +
25840 +       return vx_set_space(vxi, vc_data.mask, 0);
25841 +}
25842 +
25843 +int vc_set_space(struct vx_info *vxi, void __user *data)
25844 +{
25845 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25846 +
25847 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25848 +               return -EFAULT;
25849 +
25850 +       if (vc_data.index >= VX_SPACES)
25851 +               return -EINVAL;
25852 +
25853 +       return vx_set_space(vxi, vc_data.mask, vc_data.index);
25854 +}
25855 +
25856 +int vc_get_space_mask(void __user *data, int type)
25857 +{
25858 +       const struct vcmd_space_mask_v1 *mask;
25859 +
25860 +       if (type == 0)
25861 +               mask = &space_mask_v0;
25862 +       else if (type == 1)
25863 +               mask = &space_mask;
25864 +       else
25865 +               mask = &default_space_mask;
25866 +
25867 +       vxdprintk(VXD_CBIT(space, 10),
25868 +               "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25869 +
25870 +       if (copy_to_user(data, mask, sizeof(*mask)))
25871 +               return -EFAULT;
25872 +       return 0;
25873 +}
25874 +
25875 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/switch.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/switch.c
25876 --- linux-2.6.33.2/kernel/vserver/switch.c      1970-01-01 01:00:00.000000000 +0100
25877 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/switch.c      2010-02-25 12:02:16.000000000 +0100
25878 @@ -0,0 +1,546 @@
25879 +/*
25880 + *  linux/kernel/vserver/switch.c
25881 + *
25882 + *  Virtual Server: Syscall Switch
25883 + *
25884 + *  Copyright (C) 2003-2007  Herbert Pötzl
25885 + *
25886 + *  V0.01  syscall switch
25887 + *  V0.02  added signal to context
25888 + *  V0.03  added rlimit functions
25889 + *  V0.04  added iattr, task/xid functions
25890 + *  V0.05  added debug/history stuff
25891 + *  V0.06  added compat32 layer
25892 + *  V0.07  vcmd args and perms
25893 + *  V0.08  added status commands
25894 + *  V0.09  added tag commands
25895 + *  V0.10  added oom bias
25896 + *  V0.11  added device commands
25897 + *
25898 + */
25899 +
25900 +#include <linux/vs_context.h>
25901 +#include <linux/vs_network.h>
25902 +#include <linux/vserver/switch.h>
25903 +
25904 +#include "vci_config.h"
25905 +
25906 +
25907 +static inline
25908 +int vc_get_version(uint32_t id)
25909 +{
25910 +       return VCI_VERSION;
25911 +}
25912 +
25913 +static inline
25914 +int vc_get_vci(uint32_t id)
25915 +{
25916 +       return vci_kernel_config();
25917 +}
25918 +
25919 +#include <linux/vserver/context_cmd.h>
25920 +#include <linux/vserver/cvirt_cmd.h>
25921 +#include <linux/vserver/cacct_cmd.h>
25922 +#include <linux/vserver/limit_cmd.h>
25923 +#include <linux/vserver/network_cmd.h>
25924 +#include <linux/vserver/sched_cmd.h>
25925 +#include <linux/vserver/debug_cmd.h>
25926 +#include <linux/vserver/inode_cmd.h>
25927 +#include <linux/vserver/dlimit_cmd.h>
25928 +#include <linux/vserver/signal_cmd.h>
25929 +#include <linux/vserver/space_cmd.h>
25930 +#include <linux/vserver/tag_cmd.h>
25931 +#include <linux/vserver/device_cmd.h>
25932 +
25933 +#include <linux/vserver/inode.h>
25934 +#include <linux/vserver/dlimit.h>
25935 +
25936 +
25937 +#ifdef CONFIG_COMPAT
25938 +#define __COMPAT(name, id, data, compat)       \
25939 +       (compat) ? name ## _x32(id, data) : name(id, data)
25940 +#define __COMPAT_NO_ID(name, data, compat)     \
25941 +       (compat) ? name ## _x32(data) : name(data)
25942 +#else
25943 +#define __COMPAT(name, id, data, compat)       \
25944 +       name(id, data)
25945 +#define __COMPAT_NO_ID(name, data, compat)     \
25946 +       name(data)
25947 +#endif
25948 +
25949 +
25950 +static inline
25951 +long do_vcmd(uint32_t cmd, uint32_t id,
25952 +       struct vx_info *vxi, struct nx_info *nxi,
25953 +       void __user *data, int compat)
25954 +{
25955 +       switch (cmd) {
25956 +
25957 +       case VCMD_get_version:
25958 +               return vc_get_version(id);
25959 +       case VCMD_get_vci:
25960 +               return vc_get_vci(id);
25961 +
25962 +       case VCMD_task_xid:
25963 +               return vc_task_xid(id);
25964 +       case VCMD_vx_info:
25965 +               return vc_vx_info(vxi, data);
25966 +
25967 +       case VCMD_task_nid:
25968 +               return vc_task_nid(id);
25969 +       case VCMD_nx_info:
25970 +               return vc_nx_info(nxi, data);
25971 +
25972 +       case VCMD_task_tag:
25973 +               return vc_task_tag(id);
25974 +
25975 +       case VCMD_set_space_v1:
25976 +               return vc_set_space_v1(vxi, data);
25977 +       /* this is version 2 */
25978 +       case VCMD_set_space:
25979 +               return vc_set_space(vxi, data);
25980 +
25981 +       case VCMD_get_space_mask_v0:
25982 +               return vc_get_space_mask(data, 0);
25983 +       /* this is version 1 */
25984 +       case VCMD_get_space_mask:
25985 +               return vc_get_space_mask(data, 1);
25986 +
25987 +       case VCMD_get_space_default:
25988 +               return vc_get_space_mask(data, -1);
25989 +
25990 +#ifdef CONFIG_IA32_EMULATION
25991 +       case VCMD_get_rlimit:
25992 +               return __COMPAT(vc_get_rlimit, vxi, data, compat);
25993 +       case VCMD_set_rlimit:
25994 +               return __COMPAT(vc_set_rlimit, vxi, data, compat);
25995 +#else
25996 +       case VCMD_get_rlimit:
25997 +               return vc_get_rlimit(vxi, data);
25998 +       case VCMD_set_rlimit:
25999 +               return vc_set_rlimit(vxi, data);
26000 +#endif
26001 +       case VCMD_get_rlimit_mask:
26002 +               return vc_get_rlimit_mask(id, data);
26003 +       case VCMD_reset_hits:
26004 +               return vc_reset_hits(vxi, data);
26005 +       case VCMD_reset_minmax:
26006 +               return vc_reset_minmax(vxi, data);
26007 +
26008 +       case VCMD_get_vhi_name:
26009 +               return vc_get_vhi_name(vxi, data);
26010 +       case VCMD_set_vhi_name:
26011 +               return vc_set_vhi_name(vxi, data);
26012 +
26013 +       case VCMD_ctx_stat:
26014 +               return vc_ctx_stat(vxi, data);
26015 +       case VCMD_virt_stat:
26016 +               return vc_virt_stat(vxi, data);
26017 +       case VCMD_sock_stat:
26018 +               return vc_sock_stat(vxi, data);
26019 +       case VCMD_rlimit_stat:
26020 +               return vc_rlimit_stat(vxi, data);
26021 +
26022 +       case VCMD_set_cflags:
26023 +               return vc_set_cflags(vxi, data);
26024 +       case VCMD_get_cflags:
26025 +               return vc_get_cflags(vxi, data);
26026 +
26027 +       /* this is version 1 */
26028 +       case VCMD_set_ccaps:
26029 +               return vc_set_ccaps(vxi, data);
26030 +       /* this is version 1 */
26031 +       case VCMD_get_ccaps:
26032 +               return vc_get_ccaps(vxi, data);
26033 +       case VCMD_set_bcaps:
26034 +               return vc_set_bcaps(vxi, data);
26035 +       case VCMD_get_bcaps:
26036 +               return vc_get_bcaps(vxi, data);
26037 +
26038 +       case VCMD_set_badness:
26039 +               return vc_set_badness(vxi, data);
26040 +       case VCMD_get_badness:
26041 +               return vc_get_badness(vxi, data);
26042 +
26043 +       case VCMD_set_nflags:
26044 +               return vc_set_nflags(nxi, data);
26045 +       case VCMD_get_nflags:
26046 +               return vc_get_nflags(nxi, data);
26047 +
26048 +       case VCMD_set_ncaps:
26049 +               return vc_set_ncaps(nxi, data);
26050 +       case VCMD_get_ncaps:
26051 +               return vc_get_ncaps(nxi, data);
26052 +
26053 +       case VCMD_set_sched_v4:
26054 +               return vc_set_sched_v4(vxi, data);
26055 +       /* this is version 5 */
26056 +       case VCMD_set_sched:
26057 +               return vc_set_sched(vxi, data);
26058 +       case VCMD_get_sched:
26059 +               return vc_get_sched(vxi, data);
26060 +       case VCMD_sched_info:
26061 +               return vc_sched_info(vxi, data);
26062 +
26063 +       case VCMD_add_dlimit:
26064 +               return __COMPAT(vc_add_dlimit, id, data, compat);
26065 +       case VCMD_rem_dlimit:
26066 +               return __COMPAT(vc_rem_dlimit, id, data, compat);
26067 +       case VCMD_set_dlimit:
26068 +               return __COMPAT(vc_set_dlimit, id, data, compat);
26069 +       case VCMD_get_dlimit:
26070 +               return __COMPAT(vc_get_dlimit, id, data, compat);
26071 +
26072 +       case VCMD_ctx_kill:
26073 +               return vc_ctx_kill(vxi, data);
26074 +
26075 +       case VCMD_wait_exit:
26076 +               return vc_wait_exit(vxi, data);
26077 +
26078 +       case VCMD_get_iattr:
26079 +               return __COMPAT_NO_ID(vc_get_iattr, data, compat);
26080 +       case VCMD_set_iattr:
26081 +               return __COMPAT_NO_ID(vc_set_iattr, data, compat);
26082 +
26083 +       case VCMD_fget_iattr:
26084 +               return vc_fget_iattr(id, data);
26085 +       case VCMD_fset_iattr:
26086 +               return vc_fset_iattr(id, data);
26087 +
26088 +       case VCMD_enter_space_v0:
26089 +               return vc_enter_space_v1(vxi, NULL);
26090 +       case VCMD_enter_space_v1:
26091 +               return vc_enter_space_v1(vxi, data);
26092 +       /* this is version 2 */
26093 +       case VCMD_enter_space:
26094 +               return vc_enter_space(vxi, data);
26095 +
26096 +       case VCMD_ctx_create_v0:
26097 +               return vc_ctx_create(id, NULL);
26098 +       case VCMD_ctx_create:
26099 +               return vc_ctx_create(id, data);
26100 +       case VCMD_ctx_migrate_v0:
26101 +               return vc_ctx_migrate(vxi, NULL);
26102 +       case VCMD_ctx_migrate:
26103 +               return vc_ctx_migrate(vxi, data);
26104 +
26105 +       case VCMD_net_create_v0:
26106 +               return vc_net_create(id, NULL);
26107 +       case VCMD_net_create:
26108 +               return vc_net_create(id, data);
26109 +       case VCMD_net_migrate:
26110 +               return vc_net_migrate(nxi, data);
26111 +
26112 +       case VCMD_tag_migrate:
26113 +               return vc_tag_migrate(id);
26114 +
26115 +       case VCMD_net_add:
26116 +               return vc_net_add(nxi, data);
26117 +       case VCMD_net_remove:
26118 +               return vc_net_remove(nxi, data);
26119 +
26120 +       case VCMD_net_add_ipv4:
26121 +               return vc_net_add_ipv4(nxi, data);
26122 +       case VCMD_net_remove_ipv4:
26123 +               return vc_net_remove_ipv4(nxi, data);
26124 +#ifdef CONFIG_IPV6
26125 +       case VCMD_net_add_ipv6:
26126 +               return vc_net_add_ipv6(nxi, data);
26127 +       case VCMD_net_remove_ipv6:
26128 +               return vc_net_remove_ipv6(nxi, data);
26129 +#endif
26130 +/*     case VCMD_add_match_ipv4:
26131 +               return vc_add_match_ipv4(nxi, data);
26132 +       case VCMD_get_match_ipv4:
26133 +               return vc_get_match_ipv4(nxi, data);
26134 +#ifdef CONFIG_IPV6
26135 +       case VCMD_add_match_ipv6:
26136 +               return vc_add_match_ipv6(nxi, data);
26137 +       case VCMD_get_match_ipv6:
26138 +               return vc_get_match_ipv6(nxi, data);
26139 +#endif */
26140 +
26141 +#ifdef CONFIG_VSERVER_DEVICE
26142 +       case VCMD_set_mapping:
26143 +               return __COMPAT(vc_set_mapping, vxi, data, compat);
26144 +       case VCMD_unset_mapping:
26145 +               return __COMPAT(vc_unset_mapping, vxi, data, compat);
26146 +#endif
26147 +#ifdef CONFIG_VSERVER_HISTORY
26148 +       case VCMD_dump_history:
26149 +               return vc_dump_history(id);
26150 +       case VCMD_read_history:
26151 +               return __COMPAT(vc_read_history, id, data, compat);
26152 +#endif
26153 +#ifdef CONFIG_VSERVER_MONITOR
26154 +       case VCMD_read_monitor:
26155 +               return __COMPAT(vc_read_monitor, id, data, compat);
26156 +#endif
26157 +       default:
26158 +               vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
26159 +                       VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
26160 +       }
26161 +       return -ENOSYS;
26162 +}
26163 +
26164 +
26165 +#define        __VCMD(vcmd, _perm, _args, _flags)              \
26166 +       case VCMD_ ## vcmd: perm = _perm;               \
26167 +               args = _args; flags = _flags; break
26168 +
26169 +
26170 +#define VCA_NONE       0x00
26171 +#define VCA_VXI                0x01
26172 +#define VCA_NXI                0x02
26173 +
26174 +#define VCF_NONE       0x00
26175 +#define VCF_INFO       0x01
26176 +#define VCF_ADMIN      0x02
26177 +#define VCF_ARES       0x06    /* includes admin */
26178 +#define VCF_SETUP      0x08
26179 +
26180 +#define VCF_ZIDOK      0x10    /* zero id okay */
26181 +
26182 +
26183 +static inline
26184 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
26185 +{
26186 +       long ret;
26187 +       int permit = -1, state = 0;
26188 +       int perm = -1, args = 0, flags = 0;
26189 +       struct vx_info *vxi = NULL;
26190 +       struct nx_info *nxi = NULL;
26191 +
26192 +       switch (cmd) {
26193 +       /* unpriviledged commands */
26194 +       __VCMD(get_version,      0, VCA_NONE,   0);
26195 +       __VCMD(get_vci,          0, VCA_NONE,   0);
26196 +       __VCMD(get_rlimit_mask,  0, VCA_NONE,   0);
26197 +       __VCMD(get_space_mask_v0,0, VCA_NONE,   0);
26198 +       __VCMD(get_space_mask,   0, VCA_NONE,   0);
26199 +       __VCMD(get_space_default,0, VCA_NONE,   0);
26200 +
26201 +       /* info commands */
26202 +       __VCMD(task_xid,         2, VCA_NONE,   0);
26203 +       __VCMD(reset_hits,       2, VCA_VXI,    0);
26204 +       __VCMD(reset_minmax,     2, VCA_VXI,    0);
26205 +       __VCMD(vx_info,          3, VCA_VXI,    VCF_INFO);
26206 +       __VCMD(get_bcaps,        3, VCA_VXI,    VCF_INFO);
26207 +       __VCMD(get_ccaps,        3, VCA_VXI,    VCF_INFO);
26208 +       __VCMD(get_cflags,       3, VCA_VXI,    VCF_INFO);
26209 +       __VCMD(get_badness,      3, VCA_VXI,    VCF_INFO);
26210 +       __VCMD(get_vhi_name,     3, VCA_VXI,    VCF_INFO);
26211 +       __VCMD(get_rlimit,       3, VCA_VXI,    VCF_INFO);
26212 +
26213 +       __VCMD(ctx_stat,         3, VCA_VXI,    VCF_INFO);
26214 +       __VCMD(virt_stat,        3, VCA_VXI,    VCF_INFO);
26215 +       __VCMD(sock_stat,        3, VCA_VXI,    VCF_INFO);
26216 +       __VCMD(rlimit_stat,      3, VCA_VXI,    VCF_INFO);
26217 +
26218 +       __VCMD(task_nid,         2, VCA_NONE,   0);
26219 +       __VCMD(nx_info,          3, VCA_NXI,    VCF_INFO);
26220 +       __VCMD(get_ncaps,        3, VCA_NXI,    VCF_INFO);
26221 +       __VCMD(get_nflags,       3, VCA_NXI,    VCF_INFO);
26222 +
26223 +       __VCMD(task_tag,         2, VCA_NONE,   0);
26224 +
26225 +       __VCMD(get_iattr,        2, VCA_NONE,   0);
26226 +       __VCMD(fget_iattr,       2, VCA_NONE,   0);
26227 +       __VCMD(get_dlimit,       3, VCA_NONE,   VCF_INFO);
26228 +       __VCMD(get_sched,        3, VCA_VXI,    VCF_INFO);
26229 +       __VCMD(sched_info,       3, VCA_VXI,    VCF_INFO | VCF_ZIDOK);
26230 +
26231 +       /* lower admin commands */
26232 +       __VCMD(wait_exit,        4, VCA_VXI,    VCF_INFO);
26233 +       __VCMD(ctx_create_v0,    5, VCA_NONE,   0);
26234 +       __VCMD(ctx_create,       5, VCA_NONE,   0);
26235 +       __VCMD(ctx_migrate_v0,   5, VCA_VXI,    VCF_ADMIN);
26236 +       __VCMD(ctx_migrate,      5, VCA_VXI,    VCF_ADMIN);
26237 +       __VCMD(enter_space_v0,   5, VCA_VXI,    VCF_ADMIN);
26238 +       __VCMD(enter_space_v1,   5, VCA_VXI,    VCF_ADMIN);
26239 +       __VCMD(enter_space,      5, VCA_VXI,    VCF_ADMIN);
26240 +
26241 +       __VCMD(net_create_v0,    5, VCA_NONE,   0);
26242 +       __VCMD(net_create,       5, VCA_NONE,   0);
26243 +       __VCMD(net_migrate,      5, VCA_NXI,    VCF_ADMIN);
26244 +
26245 +       __VCMD(tag_migrate,      5, VCA_NONE,   VCF_ADMIN);
26246 +
26247 +       /* higher admin commands */
26248 +       __VCMD(ctx_kill,         6, VCA_VXI,    VCF_ARES);
26249 +       __VCMD(set_space_v1,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26250 +       __VCMD(set_space,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26251 +
26252 +       __VCMD(set_ccaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26253 +       __VCMD(set_bcaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26254 +       __VCMD(set_cflags,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26255 +       __VCMD(set_badness,      7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26256 +
26257 +       __VCMD(set_vhi_name,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26258 +       __VCMD(set_rlimit,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26259 +       __VCMD(set_sched,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26260 +       __VCMD(set_sched_v4,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26261 +
26262 +       __VCMD(set_ncaps,        7, VCA_NXI,    VCF_ARES | VCF_SETUP);
26263 +       __VCMD(set_nflags,       7, VCA_NXI,    VCF_ARES | VCF_SETUP);
26264 +       __VCMD(net_add,          8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26265 +       __VCMD(net_remove,       8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26266 +       __VCMD(net_add_ipv4,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26267 +       __VCMD(net_remove_ipv4,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26268 +#ifdef CONFIG_IPV6
26269 +       __VCMD(net_add_ipv6,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26270 +       __VCMD(net_remove_ipv6,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26271 +#endif
26272 +       __VCMD(set_iattr,        7, VCA_NONE,   0);
26273 +       __VCMD(fset_iattr,       7, VCA_NONE,   0);
26274 +       __VCMD(set_dlimit,       7, VCA_NONE,   VCF_ARES);
26275 +       __VCMD(add_dlimit,       8, VCA_NONE,   VCF_ARES);
26276 +       __VCMD(rem_dlimit,       8, VCA_NONE,   VCF_ARES);
26277 +
26278 +#ifdef CONFIG_VSERVER_DEVICE
26279 +       __VCMD(set_mapping,      8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
26280 +       __VCMD(unset_mapping,    8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
26281 +#endif
26282 +       /* debug level admin commands */
26283 +#ifdef CONFIG_VSERVER_HISTORY
26284 +       __VCMD(dump_history,     9, VCA_NONE,   0);
26285 +       __VCMD(read_history,     9, VCA_NONE,   0);
26286 +#endif
26287 +#ifdef CONFIG_VSERVER_MONITOR
26288 +       __VCMD(read_monitor,     9, VCA_NONE,   0);
26289 +#endif
26290 +
26291 +       default:
26292 +               perm = -1;
26293 +       }
26294 +
26295 +       vxdprintk(VXD_CBIT(switch, 0),
26296 +               "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
26297 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
26298 +               VC_VERSION(cmd), id, data, compat,
26299 +               perm, args, flags);
26300 +
26301 +       ret = -ENOSYS;
26302 +       if (perm < 0)
26303 +               goto out;
26304 +
26305 +       state = 1;
26306 +       if (!capable(CAP_CONTEXT))
26307 +               goto out;
26308 +
26309 +       state = 2;
26310 +       /* moved here from the individual commands */
26311 +       ret = -EPERM;
26312 +       if ((perm > 1) && !capable(CAP_SYS_ADMIN))
26313 +               goto out;
26314 +
26315 +       state = 3;
26316 +       /* vcmd involves resource management  */
26317 +       ret = -EPERM;
26318 +       if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
26319 +               goto out;
26320 +
26321 +       state = 4;
26322 +       /* various legacy exceptions */
26323 +       switch (cmd) {
26324 +       /* will go away when spectator is a cap */
26325 +       case VCMD_ctx_migrate_v0:
26326 +       case VCMD_ctx_migrate:
26327 +               if (id == 1) {
26328 +                       current->xid = 1;
26329 +                       ret = 1;
26330 +                       goto out;
26331 +               }
26332 +               break;
26333 +
26334 +       /* will go away when spectator is a cap */
26335 +       case VCMD_net_migrate:
26336 +               if (id == 1) {
26337 +                       current->nid = 1;
26338 +                       ret = 1;
26339 +                       goto out;
26340 +               }
26341 +               break;
26342 +       }
26343 +
26344 +       /* vcmds are fine by default */
26345 +       permit = 1;
26346 +
26347 +       /* admin type vcmds require admin ... */
26348 +       if (flags & VCF_ADMIN)
26349 +               permit = vx_check(0, VS_ADMIN) ? 1 : 0;
26350 +
26351 +       /* ... but setup type vcmds override that */
26352 +       if (!permit && (flags & VCF_SETUP))
26353 +               permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
26354 +
26355 +       state = 5;
26356 +       ret = -EPERM;
26357 +       if (!permit)
26358 +               goto out;
26359 +
26360 +       state = 6;
26361 +       if (!id && (flags & VCF_ZIDOK))
26362 +               goto skip_id;
26363 +
26364 +       ret = -ESRCH;
26365 +       if (args & VCA_VXI) {
26366 +               vxi = lookup_vx_info(id);
26367 +               if (!vxi)
26368 +                       goto out;
26369 +
26370 +               if ((flags & VCF_ADMIN) &&
26371 +                       /* special case kill for shutdown */
26372 +                       (cmd != VCMD_ctx_kill) &&
26373 +                       /* can context be administrated? */
26374 +                       !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
26375 +                       ret = -EACCES;
26376 +                       goto out_vxi;
26377 +               }
26378 +       }
26379 +       state = 7;
26380 +       if (args & VCA_NXI) {
26381 +               nxi = lookup_nx_info(id);
26382 +               if (!nxi)
26383 +                       goto out_vxi;
26384 +
26385 +               if ((flags & VCF_ADMIN) &&
26386 +                       /* can context be administrated? */
26387 +                       !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
26388 +                       ret = -EACCES;
26389 +                       goto out_nxi;
26390 +               }
26391 +       }
26392 +skip_id:
26393 +       state = 8;
26394 +       ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
26395 +
26396 +out_nxi:
26397 +       if ((args & VCA_NXI) && nxi)
26398 +               put_nx_info(nxi);
26399 +out_vxi:
26400 +       if ((args & VCA_VXI) && vxi)
26401 +               put_vx_info(vxi);
26402 +out:
26403 +       vxdprintk(VXD_CBIT(switch, 1),
26404 +               "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
26405 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
26406 +               VC_VERSION(cmd), ret, ret, state, permit);
26407 +       return ret;
26408 +}
26409 +
26410 +asmlinkage long
26411 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
26412 +{
26413 +       return do_vserver(cmd, id, data, 0);
26414 +}
26415 +
26416 +#ifdef CONFIG_COMPAT
26417 +
26418 +asmlinkage long
26419 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
26420 +{
26421 +       return do_vserver(cmd, id, data, 1);
26422 +}
26423 +
26424 +#endif /* CONFIG_COMPAT */
26425 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/sysctl.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/sysctl.c
26426 --- linux-2.6.33.2/kernel/vserver/sysctl.c      1970-01-01 01:00:00.000000000 +0100
26427 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/sysctl.c      2010-02-25 15:14:16.000000000 +0100
26428 @@ -0,0 +1,241 @@
26429 +/*
26430 + *  kernel/vserver/sysctl.c
26431 + *
26432 + *  Virtual Context Support
26433 + *
26434 + *  Copyright (C) 2004-2007  Herbert Pötzl
26435 + *
26436 + *  V0.01  basic structure
26437 + *
26438 + */
26439 +
26440 +#include <linux/module.h>
26441 +#include <linux/ctype.h>
26442 +#include <linux/sysctl.h>
26443 +#include <linux/parser.h>
26444 +#include <asm/uaccess.h>
26445 +
26446 +enum {
26447 +       CTL_DEBUG_ERROR         = 0,
26448 +       CTL_DEBUG_SWITCH        = 1,
26449 +       CTL_DEBUG_XID,
26450 +       CTL_DEBUG_NID,
26451 +       CTL_DEBUG_TAG,
26452 +       CTL_DEBUG_NET,
26453 +       CTL_DEBUG_LIMIT,
26454 +       CTL_DEBUG_CRES,
26455 +       CTL_DEBUG_DLIM,
26456 +       CTL_DEBUG_QUOTA,
26457 +       CTL_DEBUG_CVIRT,
26458 +       CTL_DEBUG_SPACE,
26459 +       CTL_DEBUG_MISC,
26460 +};
26461 +
26462 +
26463 +unsigned int vx_debug_switch   = 0;
26464 +unsigned int vx_debug_xid      = 0;
26465 +unsigned int vx_debug_nid      = 0;
26466 +unsigned int vx_debug_tag      = 0;
26467 +unsigned int vx_debug_net      = 0;
26468 +unsigned int vx_debug_limit    = 0;
26469 +unsigned int vx_debug_cres     = 0;
26470 +unsigned int vx_debug_dlim     = 0;
26471 +unsigned int vx_debug_quota    = 0;
26472 +unsigned int vx_debug_cvirt    = 0;
26473 +unsigned int vx_debug_space    = 0;
26474 +unsigned int vx_debug_misc     = 0;
26475 +
26476 +
26477 +static struct ctl_table_header *vserver_table_header;
26478 +static ctl_table vserver_root_table[];
26479 +
26480 +
26481 +void vserver_register_sysctl(void)
26482 +{
26483 +       if (!vserver_table_header) {
26484 +               vserver_table_header = register_sysctl_table(vserver_root_table);
26485 +       }
26486 +
26487 +}
26488 +
26489 +void vserver_unregister_sysctl(void)
26490 +{
26491 +       if (vserver_table_header) {
26492 +               unregister_sysctl_table(vserver_table_header);
26493 +               vserver_table_header = NULL;
26494 +       }
26495 +}
26496 +
26497 +
26498 +static int proc_dodebug(ctl_table *table, int write,
26499 +       void __user *buffer, size_t *lenp, loff_t *ppos)
26500 +{
26501 +       char            tmpbuf[20], *p, c;
26502 +       unsigned int    value;
26503 +       size_t          left, len;
26504 +
26505 +       if ((*ppos && !write) || !*lenp) {
26506 +               *lenp = 0;
26507 +               return 0;
26508 +       }
26509 +
26510 +       left = *lenp;
26511 +
26512 +       if (write) {
26513 +               if (!access_ok(VERIFY_READ, buffer, left))
26514 +                       return -EFAULT;
26515 +               p = (char *)buffer;
26516 +               while (left && __get_user(c, p) >= 0 && isspace(c))
26517 +                       left--, p++;
26518 +               if (!left)
26519 +                       goto done;
26520 +
26521 +               if (left > sizeof(tmpbuf) - 1)
26522 +                       return -EINVAL;
26523 +               if (copy_from_user(tmpbuf, p, left))
26524 +                       return -EFAULT;
26525 +               tmpbuf[left] = '\0';
26526 +
26527 +               for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
26528 +                       value = 10 * value + (*p - '0');
26529 +               if (*p && !isspace(*p))
26530 +                       return -EINVAL;
26531 +               while (left && isspace(*p))
26532 +                       left--, p++;
26533 +               *(unsigned int *)table->data = value;
26534 +       } else {
26535 +               if (!access_ok(VERIFY_WRITE, buffer, left))
26536 +                       return -EFAULT;
26537 +               len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
26538 +               if (len > left)
26539 +                       len = left;
26540 +               if (__copy_to_user(buffer, tmpbuf, len))
26541 +                       return -EFAULT;
26542 +               if ((left -= len) > 0) {
26543 +                       if (put_user('\n', (char *)buffer + len))
26544 +                               return -EFAULT;
26545 +                       left--;
26546 +               }
26547 +       }
26548 +
26549 +done:
26550 +       *lenp -= left;
26551 +       *ppos += *lenp;
26552 +       return 0;
26553 +}
26554 +
26555 +static int zero;
26556 +
26557 +#define        CTL_ENTRY(ctl, name)                            \
26558 +       {                                               \
26559 +               .procname       = #name,                \
26560 +               .data           = &vx_ ## name,         \
26561 +               .maxlen         = sizeof(int),          \
26562 +               .mode           = 0644,                 \
26563 +               .proc_handler   = &proc_dodebug,        \
26564 +               .extra1         = &zero,                \
26565 +               .extra2         = &zero,                \
26566 +       }
26567 +
26568 +static ctl_table vserver_debug_table[] = {
26569 +       CTL_ENTRY(CTL_DEBUG_SWITCH,     debug_switch),
26570 +       CTL_ENTRY(CTL_DEBUG_XID,        debug_xid),
26571 +       CTL_ENTRY(CTL_DEBUG_NID,        debug_nid),
26572 +       CTL_ENTRY(CTL_DEBUG_TAG,        debug_tag),
26573 +       CTL_ENTRY(CTL_DEBUG_NET,        debug_net),
26574 +       CTL_ENTRY(CTL_DEBUG_LIMIT,      debug_limit),
26575 +       CTL_ENTRY(CTL_DEBUG_CRES,       debug_cres),
26576 +       CTL_ENTRY(CTL_DEBUG_DLIM,       debug_dlim),
26577 +       CTL_ENTRY(CTL_DEBUG_QUOTA,      debug_quota),
26578 +       CTL_ENTRY(CTL_DEBUG_CVIRT,      debug_cvirt),
26579 +       CTL_ENTRY(CTL_DEBUG_SPACE,      debug_space),
26580 +       CTL_ENTRY(CTL_DEBUG_MISC,       debug_misc),
26581 +       { 0 }
26582 +};
26583 +
26584 +static ctl_table vserver_root_table[] = {
26585 +       {
26586 +               .procname       = "vserver",
26587 +               .mode           = 0555,
26588 +               .child          = vserver_debug_table
26589 +       },
26590 +       { 0 }
26591 +};
26592 +
26593 +
26594 +static match_table_t tokens = {
26595 +       { CTL_DEBUG_SWITCH,     "switch=%x"     },
26596 +       { CTL_DEBUG_XID,        "xid=%x"        },
26597 +       { CTL_DEBUG_NID,        "nid=%x"        },
26598 +       { CTL_DEBUG_TAG,        "tag=%x"        },
26599 +       { CTL_DEBUG_NET,        "net=%x"        },
26600 +       { CTL_DEBUG_LIMIT,      "limit=%x"      },
26601 +       { CTL_DEBUG_CRES,       "cres=%x"       },
26602 +       { CTL_DEBUG_DLIM,       "dlim=%x"       },
26603 +       { CTL_DEBUG_QUOTA,      "quota=%x"      },
26604 +       { CTL_DEBUG_CVIRT,      "cvirt=%x"      },
26605 +       { CTL_DEBUG_SPACE,      "space=%x"      },
26606 +       { CTL_DEBUG_MISC,       "misc=%x"       },
26607 +       { CTL_DEBUG_ERROR,      NULL            }
26608 +};
26609 +
26610 +#define        HANDLE_CASE(id, name, val)                              \
26611 +       case CTL_DEBUG_ ## id:                                  \
26612 +               vx_debug_ ## name = val;                        \
26613 +               printk("vs_debug_" #name "=0x%x\n", val);       \
26614 +               break
26615 +
26616 +
26617 +static int __init vs_debug_setup(char *str)
26618 +{
26619 +       char *p;
26620 +       int token;
26621 +
26622 +       printk("vs_debug_setup(%s)\n", str);
26623 +       while ((p = strsep(&str, ",")) != NULL) {
26624 +               substring_t args[MAX_OPT_ARGS];
26625 +               unsigned int value;
26626 +
26627 +               if (!*p)
26628 +                       continue;
26629 +
26630 +               token = match_token(p, tokens, args);
26631 +               value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
26632 +
26633 +               switch (token) {
26634 +               HANDLE_CASE(SWITCH, switch, value);
26635 +               HANDLE_CASE(XID,    xid,    value);
26636 +               HANDLE_CASE(NID,    nid,    value);
26637 +               HANDLE_CASE(TAG,    tag,    value);
26638 +               HANDLE_CASE(NET,    net,    value);
26639 +               HANDLE_CASE(LIMIT,  limit,  value);
26640 +               HANDLE_CASE(CRES,   cres,   value);
26641 +               HANDLE_CASE(DLIM,   dlim,   value);
26642 +               HANDLE_CASE(QUOTA,  quota,  value);
26643 +               HANDLE_CASE(CVIRT,  cvirt,  value);
26644 +               HANDLE_CASE(SPACE,  space,  value);
26645 +               HANDLE_CASE(MISC,   misc,   value);
26646 +               default:
26647 +                       return -EINVAL;
26648 +                       break;
26649 +               }
26650 +       }
26651 +       return 1;
26652 +}
26653 +
26654 +__setup("vsdebug=", vs_debug_setup);
26655 +
26656 +
26657 +
26658 +EXPORT_SYMBOL_GPL(vx_debug_switch);
26659 +EXPORT_SYMBOL_GPL(vx_debug_xid);
26660 +EXPORT_SYMBOL_GPL(vx_debug_nid);
26661 +EXPORT_SYMBOL_GPL(vx_debug_net);
26662 +EXPORT_SYMBOL_GPL(vx_debug_limit);
26663 +EXPORT_SYMBOL_GPL(vx_debug_cres);
26664 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
26665 +EXPORT_SYMBOL_GPL(vx_debug_quota);
26666 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
26667 +EXPORT_SYMBOL_GPL(vx_debug_space);
26668 +EXPORT_SYMBOL_GPL(vx_debug_misc);
26669 +
26670 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/tag.c linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/tag.c
26671 --- linux-2.6.33.2/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
26672 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/tag.c 2010-02-25 12:02:16.000000000 +0100
26673 @@ -0,0 +1,63 @@
26674 +/*
26675 + *  linux/kernel/vserver/tag.c
26676 + *
26677 + *  Virtual Server: Shallow Tag Space
26678 + *
26679 + *  Copyright (C) 2007  Herbert Pötzl
26680 + *
26681 + *  V0.01  basic implementation
26682 + *
26683 + */
26684 +
26685 +#include <linux/sched.h>
26686 +#include <linux/vserver/debug.h>
26687 +#include <linux/vs_pid.h>
26688 +#include <linux/vs_tag.h>
26689 +
26690 +#include <linux/vserver/tag_cmd.h>
26691 +
26692 +
26693 +int dx_migrate_task(struct task_struct *p, tag_t tag)
26694 +{
26695 +       if (!p)
26696 +               BUG();
26697 +
26698 +       vxdprintk(VXD_CBIT(tag, 5),
26699 +               "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
26700 +
26701 +       task_lock(p);
26702 +       p->tag = tag;
26703 +       task_unlock(p);
26704 +
26705 +       vxdprintk(VXD_CBIT(tag, 5),
26706 +               "moved task %p into [#%d]", p, tag);
26707 +       return 0;
26708 +}
26709 +
26710 +/* vserver syscall commands below here */
26711 +
26712 +/* taks xid and vx_info functions */
26713 +
26714 +
26715 +int vc_task_tag(uint32_t id)
26716 +{
26717 +       tag_t tag;
26718 +
26719 +       if (id) {
26720 +               struct task_struct *tsk;
26721 +               read_lock(&tasklist_lock);
26722 +               tsk = find_task_by_real_pid(id);
26723 +               tag = (tsk) ? tsk->tag : -ESRCH;
26724 +               read_unlock(&tasklist_lock);
26725 +       } else
26726 +               tag = dx_current_tag();
26727 +       return tag;
26728 +}
26729 +
26730 +
26731 +int vc_tag_migrate(uint32_t tag)
26732 +{
26733 +       return dx_migrate_task(current, tag & 0xFFFF);
26734 +}
26735 +
26736 +
26737 diff -NurpP --minimal linux-2.6.33.2/kernel/vserver/vci_config.h linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/vci_config.h
26738 --- linux-2.6.33.2/kernel/vserver/vci_config.h  1970-01-01 01:00:00.000000000 +0100
26739 +++ linux-2.6.33.2-vs2.3.0.36.30.4/kernel/vserver/vci_config.h  2010-02-25 12:02:16.000000000 +0100
26740 @@ -0,0 +1,81 @@
26741 +
26742 +/*  interface version */
26743 +
26744 +#define VCI_VERSION            0x00020305
26745 +
26746 +
26747 +enum {
26748 +       VCI_KCBIT_NO_DYNAMIC = 0,
26749 +
26750 +       VCI_KCBIT_PROC_SECURE = 4,
26751 +       VCI_KCBIT_HARDCPU = 5,
26752 +       VCI_KCBIT_IDLELIMIT = 6,
26753 +       VCI_KCBIT_IDLETIME = 7,
26754 +
26755 +       VCI_KCBIT_COWBL = 8,
26756 +       VCI_KCBIT_FULLCOWBL = 9,
26757 +       VCI_KCBIT_SPACES = 10,
26758 +       VCI_KCBIT_NETV2 = 11,
26759 +
26760 +       VCI_KCBIT_DEBUG = 16,
26761 +       VCI_KCBIT_HISTORY = 20,
26762 +       VCI_KCBIT_TAGGED = 24,
26763 +       VCI_KCBIT_PPTAG = 28,
26764 +
26765 +       VCI_KCBIT_MORE = 31,
26766 +};
26767 +
26768 +
26769 +static inline uint32_t vci_kernel_config(void)
26770 +{
26771 +       return
26772 +       (1 << VCI_KCBIT_NO_DYNAMIC) |
26773 +
26774 +       /* configured features */
26775 +#ifdef CONFIG_VSERVER_PROC_SECURE
26776 +       (1 << VCI_KCBIT_PROC_SECURE) |
26777 +#endif
26778 +#ifdef CONFIG_VSERVER_HARDCPU
26779 +       (1 << VCI_KCBIT_HARDCPU) |
26780 +#endif
26781 +#ifdef CONFIG_VSERVER_IDLELIMIT
26782 +       (1 << VCI_KCBIT_IDLELIMIT) |
26783 +#endif
26784 +#ifdef CONFIG_VSERVER_IDLETIME
26785 +       (1 << VCI_KCBIT_IDLETIME) |
26786 +#endif
26787 +#ifdef CONFIG_VSERVER_COWBL
26788 +       (1 << VCI_KCBIT_COWBL) |
26789 +       (1 << VCI_KCBIT_FULLCOWBL) |
26790 +#endif
26791 +       (1 << VCI_KCBIT_SPACES) |
26792 +       (1 << VCI_KCBIT_NETV2) |
26793 +
26794 +       /* debug options */
26795 +#ifdef CONFIG_VSERVER_DEBUG
26796 +       (1 << VCI_KCBIT_DEBUG) |
26797 +#endif
26798 +#ifdef CONFIG_VSERVER_HISTORY
26799 +       (1 << VCI_KCBIT_HISTORY) |
26800 +#endif
26801 +
26802 +       /* inode context tagging */
26803 +#if    defined(CONFIG_TAGGING_NONE)
26804 +       (0 << VCI_KCBIT_TAGGED) |
26805 +#elif  defined(CONFIG_TAGGING_UID16)
26806 +       (1 << VCI_KCBIT_TAGGED) |
26807 +#elif  defined(CONFIG_TAGGING_GID16)
26808 +       (2 << VCI_KCBIT_TAGGED) |
26809 +#elif  defined(CONFIG_TAGGING_ID24)
26810 +       (3 << VCI_KCBIT_TAGGED) |
26811 +#elif  defined(CONFIG_TAGGING_INTERN)
26812 +       (4 << VCI_KCBIT_TAGGED) |
26813 +#elif  defined(CONFIG_TAGGING_RUNTIME)
26814 +       (5 << VCI_KCBIT_TAGGED) |
26815 +#else
26816 +       (7 << VCI_KCBIT_TAGGED) |
26817 +#endif
26818 +       (1 << VCI_KCBIT_PPTAG) |
26819 +       0;
26820 +}
26821 +
26822 diff -NurpP --minimal linux-2.6.33.2/mm/filemap_xip.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/filemap_xip.c
26823 --- linux-2.6.33.2/mm/filemap_xip.c     2009-12-03 20:02:58.000000000 +0100
26824 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/filemap_xip.c     2010-02-25 12:02:16.000000000 +0100
26825 @@ -17,6 +17,7 @@
26826  #include <linux/sched.h>
26827  #include <linux/seqlock.h>
26828  #include <linux/mutex.h>
26829 +#include <linux/vs_memory.h>
26830  #include <asm/tlbflush.h>
26831  #include <asm/io.h>
26832  
26833 diff -NurpP --minimal linux-2.6.33.2/mm/fremap.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/fremap.c
26834 --- linux-2.6.33.2/mm/fremap.c  2009-03-24 14:22:45.000000000 +0100
26835 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/fremap.c  2010-02-25 12:02:16.000000000 +0100
26836 @@ -16,6 +16,7 @@
26837  #include <linux/module.h>
26838  #include <linux/syscalls.h>
26839  #include <linux/mmu_notifier.h>
26840 +#include <linux/vs_memory.h>
26841  
26842  #include <asm/mmu_context.h>
26843  #include <asm/cacheflush.h>
26844 diff -NurpP --minimal linux-2.6.33.2/mm/hugetlb.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/hugetlb.c
26845 --- linux-2.6.33.2/mm/hugetlb.c 2010-02-25 11:52:09.000000000 +0100
26846 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/hugetlb.c 2010-02-25 12:16:11.000000000 +0100
26847 @@ -25,6 +25,7 @@
26848  
26849  #include <linux/hugetlb.h>
26850  #include <linux/node.h>
26851 +#include <linux/vs_memory.h>
26852  #include "internal.h"
26853  
26854  const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26855 diff -NurpP --minimal linux-2.6.33.2/mm/memcontrol.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/memcontrol.c
26856 --- linux-2.6.33.2/mm/memcontrol.c      2010-02-25 11:52:09.000000000 +0100
26857 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/memcontrol.c      2010-02-26 10:04:15.000000000 +0100
26858 @@ -555,6 +555,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26859                                 struct mem_cgroup, css);
26860  }
26861  
26862 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26863 +{
26864 +       return res_counter_read_u64(&mem->res, member);
26865 +}
26866 +
26867 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26868 +{
26869 +       return res_counter_read_u64(&mem->memsw, member);
26870 +}
26871 +
26872 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26873 +{
26874 +       return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_CACHE);
26875 +}
26876 +
26877 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26878 +{
26879 +       return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
26880 +}
26881 +
26882 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26883 +{
26884 +       return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_FILE_MAPPED);
26885 +}
26886 +
26887  static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26888  {
26889         struct mem_cgroup *mem = NULL;
26890 diff -NurpP --minimal linux-2.6.33.2/mm/memory.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/memory.c
26891 --- linux-2.6.33.2/mm/memory.c  2010-02-25 11:52:09.000000000 +0100
26892 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/memory.c  2010-02-25 12:02:16.000000000 +0100
26893 @@ -56,6 +56,7 @@
26894  #include <linux/kallsyms.h>
26895  #include <linux/swapops.h>
26896  #include <linux/elf.h>
26897 +// #include <linux/vs_memory.h>
26898  
26899  #include <asm/io.h>
26900  #include <asm/pgalloc.h>
26901 @@ -651,6 +652,9 @@ static int copy_pte_range(struct mm_stru
26902         int rss[2];
26903         swp_entry_t entry = (swp_entry_t){0};
26904  
26905 +       if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
26906 +               return -ENOMEM;
26907 +
26908  again:
26909         rss[1] = rss[0] = 0;
26910         dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
26911 @@ -2670,6 +2674,8 @@ static int do_anonymous_page(struct mm_s
26912         /* Allocate our own private page. */
26913         pte_unmap(page_table);
26914  
26915 +       if (!vx_rss_avail(mm, 1))
26916 +               goto oom;
26917         if (unlikely(anon_vma_prepare(vma)))
26918                 goto oom;
26919         page = alloc_zeroed_user_highpage_movable(vma, address);
26920 @@ -2961,6 +2967,7 @@ static inline int handle_pte_fault(struc
26921  {
26922         pte_t entry;
26923         spinlock_t *ptl;
26924 +       int ret = 0, type = VXPT_UNKNOWN;
26925  
26926         entry = *pte;
26927         if (!pte_present(entry)) {
26928 @@ -2985,9 +2992,12 @@ static inline int handle_pte_fault(struc
26929         if (unlikely(!pte_same(*pte, entry)))
26930                 goto unlock;
26931         if (flags & FAULT_FLAG_WRITE) {
26932 -               if (!pte_write(entry))
26933 -                       return do_wp_page(mm, vma, address,
26934 +               if (!pte_write(entry)) {
26935 +                       ret = do_wp_page(mm, vma, address,
26936                                         pte, pmd, ptl, entry);
26937 +                       type = VXPT_WRITE;
26938 +                       goto out;
26939 +               }
26940                 entry = pte_mkdirty(entry);
26941         }
26942         entry = pte_mkyoung(entry);
26943 @@ -3005,7 +3015,10 @@ static inline int handle_pte_fault(struc
26944         }
26945  unlock:
26946         pte_unmap_unlock(pte, ptl);
26947 -       return 0;
26948 +       ret = 0;
26949 +out:
26950 +       vx_page_fault(mm, vma, type, ret);
26951 +       return ret;
26952  }
26953  
26954  /*
26955 diff -NurpP --minimal linux-2.6.33.2/mm/mlock.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/mlock.c
26956 --- linux-2.6.33.2/mm/mlock.c   2010-02-25 11:52:09.000000000 +0100
26957 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/mlock.c   2010-02-25 12:02:16.000000000 +0100
26958 @@ -18,6 +18,7 @@
26959  #include <linux/rmap.h>
26960  #include <linux/mmzone.h>
26961  #include <linux/hugetlb.h>
26962 +#include <linux/vs_memory.h>
26963  
26964  #include "internal.h"
26965  
26966 @@ -398,7 +399,7 @@ success:
26967         nr_pages = (end - start) >> PAGE_SHIFT;
26968         if (!lock)
26969                 nr_pages = -nr_pages;
26970 -       mm->locked_vm += nr_pages;
26971 +       vx_vmlocked_add(mm, nr_pages);
26972  
26973         /*
26974          * vm_flags is protected by the mmap_sem held in write mode.
26975 @@ -471,7 +472,7 @@ static int do_mlock(unsigned long start,
26976  
26977  SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
26978  {
26979 -       unsigned long locked;
26980 +       unsigned long locked, grow;
26981         unsigned long lock_limit;
26982         int error = -ENOMEM;
26983  
26984 @@ -484,8 +485,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26985         len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
26986         start &= PAGE_MASK;
26987  
26988 -       locked = len >> PAGE_SHIFT;
26989 -       locked += current->mm->locked_vm;
26990 +       grow = len >> PAGE_SHIFT;
26991 +       if (!vx_vmlocked_avail(current->mm, grow))
26992 +               goto out;
26993 +       locked = current->mm->locked_vm + grow;
26994  
26995         lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
26996         lock_limit >>= PAGE_SHIFT;
26997 @@ -493,6 +496,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26998         /* check against resource limits */
26999         if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
27000                 error = do_mlock(start, len, 1);
27001 +out:
27002         up_write(&current->mm->mmap_sem);
27003         return error;
27004  }
27005 @@ -554,6 +558,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
27006         lock_limit >>= PAGE_SHIFT;
27007  
27008         ret = -ENOMEM;
27009 +       if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
27010 +               goto out;
27011         if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
27012             capable(CAP_IPC_LOCK))
27013                 ret = do_mlockall(flags);
27014 @@ -628,8 +634,10 @@ int account_locked_memory(struct mm_stru
27015         if (lim < vm)
27016                 goto out;
27017  
27018 -       mm->total_vm  += pgsz;
27019 -       mm->locked_vm += pgsz;
27020 +       // mm->total_vm  += pgsz;
27021 +       vx_vmpages_add(mm, pgsz);
27022 +       // mm->locked_vm += pgsz;
27023 +       vx_vmlocked_add(mm, pgsz);
27024  
27025         error = 0;
27026   out:
27027 @@ -643,8 +651,10 @@ void refund_locked_memory(struct mm_stru
27028  
27029         down_write(&mm->mmap_sem);
27030  
27031 -       mm->total_vm  -= pgsz;
27032 -       mm->locked_vm -= pgsz;
27033 +       // mm->total_vm  -= pgsz;
27034 +       vx_vmpages_sub(mm, pgsz);
27035 +       // mm->locked_vm -= pgsz;
27036 +       vx_vmlocked_sub(mm, pgsz);
27037  
27038         up_write(&mm->mmap_sem);
27039  }
27040 diff -NurpP --minimal linux-2.6.33.2/mm/mmap.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/mmap.c
27041 --- linux-2.6.33.2/mm/mmap.c    2010-02-25 11:52:09.000000000 +0100
27042 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/mmap.c    2010-02-25 12:02:16.000000000 +0100
27043 @@ -1262,7 +1262,8 @@ munmap_back:
27044  out:
27045         perf_event_mmap(vma);
27046  
27047 -       mm->total_vm += len >> PAGE_SHIFT;
27048 +       // mm->total_vm += len >> PAGE_SHIFT;
27049 +       vx_vmpages_add(mm, len >> PAGE_SHIFT);
27050         vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
27051         if (vm_flags & VM_LOCKED) {
27052                 /*
27053 @@ -1271,7 +1272,8 @@ out:
27054                 long nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
27055                 if (nr_pages < 0)
27056                         return nr_pages;        /* vma gone! */
27057 -               mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
27058 +               // mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
27059 +               vx_vmlocked_add(mm, (len >> PAGE_SHIFT) - nr_pages);
27060         } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
27061                 make_pages_present(addr, addr + len);
27062         return addr;
27063 @@ -1626,9 +1628,9 @@ static int acct_stack_growth(struct vm_a
27064                 return -ENOMEM;
27065  
27066         /* Ok, everything looks good - let it rip */
27067 -       mm->total_vm += grow;
27068 +       vx_vmpages_add(mm, grow);
27069         if (vma->vm_flags & VM_LOCKED)
27070 -               mm->locked_vm += grow;
27071 +               vx_vmlocked_add(mm, grow);
27072         vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
27073         return 0;
27074  }
27075 @@ -1803,7 +1805,8 @@ static void remove_vma_list(struct mm_st
27076         do {
27077                 long nrpages = vma_pages(vma);
27078  
27079 -               mm->total_vm -= nrpages;
27080 +               // mm->total_vm -= nrpages;
27081 +               vx_vmpages_sub(mm, nrpages);
27082                 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
27083                 vma = remove_vma(vma);
27084         } while (vma);
27085 @@ -1995,7 +1998,8 @@ int do_munmap(struct mm_struct *mm, unsi
27086                 struct vm_area_struct *tmp = vma;
27087                 while (tmp && tmp->vm_start < end) {
27088                         if (tmp->vm_flags & VM_LOCKED) {
27089 -                               mm->locked_vm -= vma_pages(tmp);
27090 +                               // mm->locked_vm -= vma_pages(tmp);
27091 +                               vx_vmlocked_sub(mm, vma_pages(tmp));
27092                                 munlock_vma_pages_all(tmp);
27093                         }
27094                         tmp = tmp->vm_next;
27095 @@ -2078,6 +2082,8 @@ unsigned long do_brk(unsigned long addr,
27096                 lock_limit >>= PAGE_SHIFT;
27097                 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
27098                         return -EAGAIN;
27099 +               if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
27100 +                       return -ENOMEM;
27101         }
27102  
27103         /*
27104 @@ -2104,7 +2110,8 @@ unsigned long do_brk(unsigned long addr,
27105         if (mm->map_count > sysctl_max_map_count)
27106                 return -ENOMEM;
27107  
27108 -       if (security_vm_enough_memory(len >> PAGE_SHIFT))
27109 +       if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
27110 +               !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
27111                 return -ENOMEM;
27112  
27113         /* Can we just expand an old private anonymous mapping? */
27114 @@ -2130,10 +2137,13 @@ unsigned long do_brk(unsigned long addr,
27115         vma->vm_page_prot = vm_get_page_prot(flags);
27116         vma_link(mm, vma, prev, rb_link, rb_parent);
27117  out:
27118 -       mm->total_vm += len >> PAGE_SHIFT;
27119 +       // mm->total_vm += len >> PAGE_SHIFT;
27120 +       vx_vmpages_add(mm, len >> PAGE_SHIFT);
27121 +
27122         if (flags & VM_LOCKED) {
27123                 if (!mlock_vma_pages_range(vma, addr, addr + len))
27124 -                       mm->locked_vm += (len >> PAGE_SHIFT);
27125 +                       // mm->locked_vm += (len >> PAGE_SHIFT);
27126 +                       vx_vmlocked_add(mm, len >> PAGE_SHIFT);
27127         }
27128         return addr;
27129  }
27130 @@ -2177,6 +2187,11 @@ void exit_mmap(struct mm_struct *mm)
27131         free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
27132         tlb_finish_mmu(tlb, 0, end);
27133  
27134 +       set_mm_counter(mm, file_rss, 0);
27135 +       set_mm_counter(mm, anon_rss, 0);
27136 +       vx_vmpages_sub(mm, mm->total_vm);
27137 +       vx_vmlocked_sub(mm, mm->locked_vm);
27138 +
27139         /*
27140          * Walk the list again, actually closing and freeing it,
27141          * with preemption enabled, without holding any MM locks.
27142 @@ -2216,7 +2231,8 @@ int insert_vm_struct(struct mm_struct * 
27143         if (__vma && __vma->vm_start < vma->vm_end)
27144                 return -ENOMEM;
27145         if ((vma->vm_flags & VM_ACCOUNT) &&
27146 -            security_vm_enough_memory_mm(mm, vma_pages(vma)))
27147 +               (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
27148 +               !vx_vmpages_avail(mm, vma_pages(vma))))
27149                 return -ENOMEM;
27150         vma_link(mm, vma, prev, rb_link, rb_parent);
27151         return 0;
27152 @@ -2292,6 +2308,8 @@ int may_expand_vm(struct mm_struct *mm, 
27153  
27154         if (cur + npages > lim)
27155                 return 0;
27156 +       if (!vx_vmpages_avail(mm, npages))
27157 +               return 0;
27158         return 1;
27159  }
27160  
27161 @@ -2369,7 +2387,7 @@ int install_special_mapping(struct mm_st
27162                 return -ENOMEM;
27163         }
27164  
27165 -       mm->total_vm += len >> PAGE_SHIFT;
27166 +       vx_vmpages_add(mm, len >> PAGE_SHIFT);
27167  
27168         perf_event_mmap(vma);
27169  
27170 diff -NurpP --minimal linux-2.6.33.2/mm/mremap.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/mremap.c
27171 --- linux-2.6.33.2/mm/mremap.c  2010-02-25 11:52:09.000000000 +0100
27172 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/mremap.c  2010-02-25 12:02:16.000000000 +0100
27173 @@ -20,6 +20,7 @@
27174  #include <linux/security.h>
27175  #include <linux/syscalls.h>
27176  #include <linux/mmu_notifier.h>
27177 +#include <linux/vs_memory.h>
27178  
27179  #include <asm/uaccess.h>
27180  #include <asm/cacheflush.h>
27181 @@ -234,7 +235,7 @@ static unsigned long move_vma(struct vm_
27182          * If this were a serious issue, we'd add a flag to do_munmap().
27183          */
27184         hiwater_vm = mm->hiwater_vm;
27185 -       mm->total_vm += new_len >> PAGE_SHIFT;
27186 +       vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
27187         vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
27188  
27189         if (do_munmap(mm, old_addr, old_len) < 0) {
27190 @@ -252,7 +253,7 @@ static unsigned long move_vma(struct vm_
27191         }
27192  
27193         if (vm_flags & VM_LOCKED) {
27194 -               mm->locked_vm += new_len >> PAGE_SHIFT;
27195 +               vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
27196                 if (new_len > old_len)
27197                         mlock_vma_pages_range(new_vma, new_addr + old_len,
27198                                                        new_addr + new_len);
27199 @@ -463,10 +464,12 @@ unsigned long do_mremap(unsigned long ad
27200                         vma_adjust(vma, vma->vm_start,
27201                                 addr + new_len, vma->vm_pgoff, NULL);
27202  
27203 -                       mm->total_vm += pages;
27204 +                       // mm->total_vm += pages;
27205 +                       vx_vmpages_add(mm, pages);
27206                         vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
27207                         if (vma->vm_flags & VM_LOCKED) {
27208 -                               mm->locked_vm += pages;
27209 +                               // mm->locked_vm += pages;
27210 +                               vx_vmlocked_add(mm, pages);
27211                                 mlock_vma_pages_range(vma, addr + old_len,
27212                                                    addr + new_len);
27213                         }
27214 diff -NurpP --minimal linux-2.6.33.2/mm/nommu.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/nommu.c
27215 --- linux-2.6.33.2/mm/nommu.c   2010-02-25 11:52:09.000000000 +0100
27216 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/nommu.c   2010-02-25 12:02:16.000000000 +0100
27217 @@ -1349,7 +1349,7 @@ unsigned long do_mmap_pgoff(struct file 
27218         /* okay... we have a mapping; now we have to register it */
27219         result = vma->vm_start;
27220  
27221 -       current->mm->total_vm += len >> PAGE_SHIFT;
27222 +       vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
27223  
27224  share:
27225         add_vma_to_mm(current->mm, vma);
27226 @@ -1637,7 +1637,7 @@ void exit_mmap(struct mm_struct *mm)
27227  
27228         kenter("");
27229  
27230 -       mm->total_vm = 0;
27231 +       vx_vmpages_sub(mm, mm->total_vm);
27232  
27233         while ((vma = mm->mmap)) {
27234                 mm->mmap = vma->vm_next;
27235 diff -NurpP --minimal linux-2.6.33.2/mm/oom_kill.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/oom_kill.c
27236 --- linux-2.6.33.2/mm/oom_kill.c        2010-02-25 11:52:09.000000000 +0100
27237 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/oom_kill.c        2010-02-25 12:20:14.000000000 +0100
27238 @@ -27,6 +27,9 @@
27239  #include <linux/notifier.h>
27240  #include <linux/memcontrol.h>
27241  #include <linux/security.h>
27242 +#include <linux/reboot.h>
27243 +#include <linux/vs_memory.h>
27244 +#include <linux/vs_context.h>
27245  
27246  int sysctl_panic_on_oom;
27247  int sysctl_oom_kill_allocating_task;
27248 @@ -186,9 +189,21 @@ unsigned long badness(struct task_struct
27249                         points >>= -(oom_adj);
27250         }
27251  
27252 +       /*
27253 +        * add points for context badness and
27254 +        * reduce badness for processes belonging to
27255 +        * a different context
27256 +        */
27257 +
27258 +       points += vx_badness(p, mm);
27259 +
27260 +       if ((vx_current_xid() > 1) &&
27261 +               vx_current_xid() != vx_task_xid(p))
27262 +               points /= 16;
27263 +
27264  #ifdef DEBUG
27265 -       printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
27266 -       p->pid, p->comm, points);
27267 +       printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
27268 +               task_pid_nr(p), p->xid, p->comm, points);
27269  #endif
27270         return points;
27271  }
27272 @@ -249,6 +264,7 @@ static struct task_struct *select_bad_pr
27273         struct task_struct *p;
27274         struct task_struct *chosen = NULL;
27275         struct timespec uptime;
27276 +       unsigned xid = vx_current_xid();
27277         *ppoints = 0;
27278  
27279         do_posix_clock_monotonic_gettime(&uptime);
27280 @@ -261,11 +277,14 @@ static struct task_struct *select_bad_pr
27281                  */
27282                 if (!p->mm)
27283                         continue;
27284 -               /* skip the init task */
27285 -               if (is_global_init(p))
27286 +               /* skip the init task, global and per guest */
27287 +               if (task_is_init(p))
27288                         continue;
27289                 if (mem && !task_in_mem_cgroup(p, mem))
27290                         continue;
27291 +               /* skip other guest and host processes if oom in guest */
27292 +               if (xid && vx_task_xid(p) != xid)
27293 +                       continue;
27294  
27295                 /*
27296                  * This task already has access to memory reserves and is
27297 @@ -397,9 +416,9 @@ static void __oom_kill_task(struct task_
27298         }
27299  
27300         if (verbose)
27301 -               printk(KERN_ERR "Killed process %d (%s) "
27302 +               printk(KERN_ERR "Killed process %s(%d:#%u) "
27303                        "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
27304 -                      task_pid_nr(p), p->comm,
27305 +                      p->comm, task_pid_nr(p), p->xid,
27306                        K(p->mm->total_vm),
27307                        K(get_mm_counter(p->mm, anon_rss)),
27308                        K(get_mm_counter(p->mm, file_rss)));
27309 @@ -452,8 +471,8 @@ static int oom_kill_process(struct task_
27310                 return 0;
27311         }
27312  
27313 -       printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
27314 -                                       message, task_pid_nr(p), p->comm, points);
27315 +       printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
27316 +               message, p->comm, task_pid_nr(p), p->xid, points);
27317  
27318         /* Try to kill a child first */
27319         list_for_each_entry(c, &p->children, sibling) {
27320 @@ -554,6 +573,8 @@ void clear_zonelist_oom(struct zonelist 
27321         spin_unlock(&zone_scan_lock);
27322  }
27323  
27324 +long vs_oom_action(unsigned int);
27325 +
27326  /*
27327   * Must be called with tasklist_lock held for read.
27328   */
27329 @@ -580,7 +601,11 @@ retry:
27330         if (!p) {
27331                 read_unlock(&tasklist_lock);
27332                 dump_header(NULL, gfp_mask, order, NULL);
27333 -               panic("Out of memory and no killable processes...\n");
27334 +               /* avoid panic for guest OOM */
27335 +               if (current->xid)
27336 +                       vs_oom_action(LINUX_REBOOT_CMD_OOM);
27337 +               else
27338 +                       panic("Out of memory and no killable processes...\n");
27339         }
27340  
27341         if (oom_kill_process(p, gfp_mask, order, points, NULL,
27342 diff -NurpP --minimal linux-2.6.33.2/mm/page_alloc.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/page_alloc.c
27343 --- linux-2.6.33.2/mm/page_alloc.c      2010-02-25 11:52:09.000000000 +0100
27344 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/page_alloc.c      2010-02-25 12:16:45.000000000 +0100
27345 @@ -49,6 +49,8 @@
27346  #include <linux/debugobjects.h>
27347  #include <linux/kmemleak.h>
27348  #include <linux/memory.h>
27349 +#include <linux/vs_base.h>
27350 +#include <linux/vs_limit.h>
27351  #include <trace/events/kmem.h>
27352  
27353  #include <asm/tlbflush.h>
27354 @@ -2138,6 +2140,9 @@ void si_meminfo(struct sysinfo *val)
27355         val->totalhigh = totalhigh_pages;
27356         val->freehigh = nr_free_highpages();
27357         val->mem_unit = PAGE_SIZE;
27358 +
27359 +       if (vx_flags(VXF_VIRT_MEM, 0))
27360 +               vx_vsi_meminfo(val);
27361  }
27362  
27363  EXPORT_SYMBOL(si_meminfo);
27364 @@ -2158,6 +2163,9 @@ void si_meminfo_node(struct sysinfo *val
27365         val->freehigh = 0;
27366  #endif
27367         val->mem_unit = PAGE_SIZE;
27368 +
27369 +       if (vx_flags(VXF_VIRT_MEM, 0))
27370 +               vx_vsi_meminfo(val);
27371  }
27372  #endif
27373  
27374 diff -NurpP --minimal linux-2.6.33.2/mm/rmap.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/rmap.c
27375 --- linux-2.6.33.2/mm/rmap.c    2010-02-25 11:52:09.000000000 +0100
27376 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/rmap.c    2010-02-25 12:02:16.000000000 +0100
27377 @@ -56,6 +56,7 @@
27378  #include <linux/memcontrol.h>
27379  #include <linux/mmu_notifier.h>
27380  #include <linux/migrate.h>
27381 +#include <linux/vs_memory.h>
27382  
27383  #include <asm/tlbflush.h>
27384  
27385 diff -NurpP --minimal linux-2.6.33.2/mm/shmem.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/shmem.c
27386 --- linux-2.6.33.2/mm/shmem.c   2010-02-25 11:52:09.000000000 +0100
27387 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/shmem.c   2010-02-25 12:02:16.000000000 +0100
27388 @@ -1788,7 +1788,7 @@ static int shmem_statfs(struct dentry *d
27389  {
27390         struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
27391  
27392 -       buf->f_type = TMPFS_MAGIC;
27393 +       buf->f_type = TMPFS_SUPER_MAGIC;
27394         buf->f_bsize = PAGE_CACHE_SIZE;
27395         buf->f_namelen = NAME_MAX;
27396         spin_lock(&sbinfo->stat_lock);
27397 @@ -2358,7 +2358,7 @@ int shmem_fill_super(struct super_block 
27398         sb->s_maxbytes = SHMEM_MAX_BYTES;
27399         sb->s_blocksize = PAGE_CACHE_SIZE;
27400         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
27401 -       sb->s_magic = TMPFS_MAGIC;
27402 +       sb->s_magic = TMPFS_SUPER_MAGIC;
27403         sb->s_op = &shmem_ops;
27404         sb->s_time_gran = 1;
27405  #ifdef CONFIG_TMPFS_POSIX_ACL
27406 diff -NurpP --minimal linux-2.6.33.2/mm/slab.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/slab.c
27407 --- linux-2.6.33.2/mm/slab.c    2010-04-06 01:47:46.000000000 +0200
27408 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/slab.c    2010-04-06 01:59:25.000000000 +0200
27409 @@ -431,6 +431,8 @@ static void kmem_list3_init(struct kmem_
27410  #define STATS_INC_FREEMISS(x)  do { } while (0)
27411  #endif
27412  
27413 +#include "slab_vs.h"
27414 +
27415  #if DEBUG
27416  
27417  /*
27418 @@ -3273,6 +3275,7 @@ retry:
27419  
27420         obj = slab_get_obj(cachep, slabp, nodeid);
27421         check_slabp(cachep, slabp);
27422 +       vx_slab_alloc(cachep, flags);
27423         l3->free_objects--;
27424         /* move slabp to correct slabp list: */
27425         list_del(&slabp->list);
27426 @@ -3349,6 +3352,7 @@ __cache_alloc_node(struct kmem_cache *ca
27427         /* ___cache_alloc_node can fall back to other nodes */
27428         ptr = ____cache_alloc_node(cachep, flags, nodeid);
27429    out:
27430 +       vx_slab_alloc(cachep, flags);
27431         local_irq_restore(save_flags);
27432         ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
27433         kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
27434 @@ -3535,6 +3539,7 @@ static inline void __cache_free(struct k
27435         check_irq_off();
27436         kmemleak_free_recursive(objp, cachep->flags);
27437         objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
27438 +       vx_slab_free(cachep);
27439  
27440         kmemcheck_slab_free(cachep, objp, obj_size(cachep));
27441  
27442 diff -NurpP --minimal linux-2.6.33.2/mm/slab_vs.h linux-2.6.33.2-vs2.3.0.36.30.4/mm/slab_vs.h
27443 --- linux-2.6.33.2/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
27444 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/slab_vs.h 2010-02-25 12:02:16.000000000 +0100
27445 @@ -0,0 +1,29 @@
27446 +
27447 +#include <linux/vserver/context.h>
27448 +
27449 +#include <linux/vs_context.h>
27450 +
27451 +static inline
27452 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
27453 +{
27454 +       int what = gfp_zone(cachep->gfpflags);
27455 +       struct vx_info *vxi = current_vx_info();
27456 +
27457 +       if (!vxi)
27458 +               return;
27459 +
27460 +       atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
27461 +}
27462 +
27463 +static inline
27464 +void vx_slab_free(struct kmem_cache *cachep)
27465 +{
27466 +       int what = gfp_zone(cachep->gfpflags);
27467 +       struct vx_info *vxi = current_vx_info();
27468 +
27469 +       if (!vxi)
27470 +               return;
27471 +
27472 +       atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
27473 +}
27474 +
27475 diff -NurpP --minimal linux-2.6.33.2/mm/swapfile.c linux-2.6.33.2-vs2.3.0.36.30.4/mm/swapfile.c
27476 --- linux-2.6.33.2/mm/swapfile.c        2010-02-25 11:52:09.000000000 +0100
27477 +++ linux-2.6.33.2-vs2.3.0.36.30.4/mm/swapfile.c        2010-02-25 12:02:16.000000000 +0100
27478 @@ -35,6 +35,8 @@
27479  #include <asm/tlbflush.h>
27480  #include <linux/swapops.h>
27481  #include <linux/page_cgroup.h>
27482 +#include <linux/vs_base.h>
27483 +#include <linux/vs_memory.h>
27484  
27485  static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
27486                                  unsigned char);
27487 @@ -1693,6 +1695,16 @@ static int swap_show(struct seq_file *sw
27488  
27489         if (si == SEQ_START_TOKEN) {
27490                 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
27491 +               if (vx_flags(VXF_VIRT_MEM, 0)) {
27492 +                       struct sysinfo si;
27493 +
27494 +                       vx_vsi_swapinfo(&si);
27495 +                       if (si.totalswap < (1 << 10))
27496 +                               return 0;
27497 +                       seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
27498 +                               "hdv0", "partition", si.totalswap >> 10,
27499 +                               (si.totalswap - si.freeswap) >> 10, -1);
27500 +               }
27501                 return 0;
27502         }
27503  
27504 @@ -2071,6 +2083,8 @@ void si_swapinfo(struct sysinfo *val)
27505         val->freeswap = nr_swap_pages + nr_to_be_unused;
27506         val->totalswap = total_swap_pages + nr_to_be_unused;
27507         spin_unlock(&swap_lock);
27508 +       if (vx_flags(VXF_VIRT_MEM, 0))
27509 +               vx_vsi_swapinfo(val);
27510  }
27511  
27512  /*
27513 diff -NurpP --minimal linux-2.6.33.2/net/core/dev.c linux-2.6.33.2-vs2.3.0.36.30.4/net/core/dev.c
27514 --- linux-2.6.33.2/net/core/dev.c       2010-04-06 01:47:46.000000000 +0200
27515 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/core/dev.c       2010-04-06 01:59:25.000000000 +0200
27516 @@ -128,6 +128,7 @@
27517  #include <linux/in.h>
27518  #include <linux/jhash.h>
27519  #include <linux/random.h>
27520 +#include <linux/vs_inet.h>
27521  #include <trace/events/napi.h>
27522  
27523  #include "net-sysfs.h"
27524 @@ -593,7 +594,8 @@ struct net_device *__dev_get_by_name(str
27525         struct hlist_head *head = dev_name_hash(net, name);
27526  
27527         hlist_for_each_entry(dev, p, head, name_hlist)
27528 -               if (!strncmp(dev->name, name, IFNAMSIZ))
27529 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
27530 +                   nx_dev_visible(current_nx_info(), dev))
27531                         return dev;
27532  
27533         return NULL;
27534 @@ -619,7 +621,8 @@ struct net_device *dev_get_by_name_rcu(s
27535         struct hlist_head *head = dev_name_hash(net, name);
27536  
27537         hlist_for_each_entry_rcu(dev, p, head, name_hlist)
27538 -               if (!strncmp(dev->name, name, IFNAMSIZ))
27539 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
27540 +                   nx_dev_visible(current_nx_info(), dev))
27541                         return dev;
27542  
27543         return NULL;
27544 @@ -670,7 +673,8 @@ struct net_device *__dev_get_by_index(st
27545         struct hlist_head *head = dev_index_hash(net, ifindex);
27546  
27547         hlist_for_each_entry(dev, p, head, index_hlist)
27548 -               if (dev->ifindex == ifindex)
27549 +               if ((dev->ifindex == ifindex) &&
27550 +                   nx_dev_visible(current_nx_info(), dev))
27551                         return dev;
27552  
27553         return NULL;
27554 @@ -695,7 +699,8 @@ struct net_device *dev_get_by_index_rcu(
27555         struct hlist_head *head = dev_index_hash(net, ifindex);
27556  
27557         hlist_for_each_entry_rcu(dev, p, head, index_hlist)
27558 -               if (dev->ifindex == ifindex)
27559 +               if ((dev->ifindex == ifindex) &&
27560 +                   nx_dev_visible(current_nx_info(), dev))
27561                         return dev;
27562  
27563         return NULL;
27564 @@ -748,10 +753,12 @@ struct net_device *dev_getbyhwaddr(struc
27565  
27566         ASSERT_RTNL();
27567  
27568 -       for_each_netdev(net, dev)
27569 +       for_each_netdev(net, dev) {
27570                 if (dev->type == type &&
27571 -                   !memcmp(dev->dev_addr, ha, dev->addr_len))
27572 +                   !memcmp(dev->dev_addr, ha, dev->addr_len) &&
27573 +                   nx_dev_visible(current_nx_info(), dev))
27574                         return dev;
27575 +       }
27576  
27577         return NULL;
27578  }
27579 @@ -762,9 +769,11 @@ struct net_device *__dev_getfirstbyhwtyp
27580         struct net_device *dev;
27581  
27582         ASSERT_RTNL();
27583 -       for_each_netdev(net, dev)
27584 -               if (dev->type == type)
27585 +       for_each_netdev(net, dev) {
27586 +               if ((dev->type == type) &&
27587 +                   nx_dev_visible(current_nx_info(), dev))
27588                         return dev;
27589 +       }
27590  
27591         return NULL;
27592  }
27593 @@ -883,6 +892,8 @@ static int __dev_alloc_name(struct net *
27594                                 continue;
27595                         if (i < 0 || i >= max_netdevices)
27596                                 continue;
27597 +                       if (!nx_dev_visible(current_nx_info(), d))
27598 +                               continue;
27599  
27600                         /*  avoid cases where sscanf is not exact inverse of printf */
27601                         snprintf(buf, IFNAMSIZ, name, i);
27602 @@ -3117,6 +3128,8 @@ static int dev_ifconf(struct net *net, c
27603  
27604         total = 0;
27605         for_each_netdev(net, dev) {
27606 +               if (!nx_dev_visible(current_nx_info(), dev))
27607 +                       continue;
27608                 for (i = 0; i < NPROTO; i++) {
27609                         if (gifconf_list[i]) {
27610                                 int done;
27611 @@ -3187,6 +3200,9 @@ static void dev_seq_printf_stats(struct 
27612  {
27613         const struct net_device_stats *stats = dev_get_stats(dev);
27614  
27615 +       if (!nx_dev_visible(current_nx_info(), dev))
27616 +               return;
27617 +
27618         seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
27619                    "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
27620                    dev->name, stats->rx_bytes, stats->rx_packets,
27621 @@ -5530,7 +5546,6 @@ int dev_change_net_namespace(struct net_
27622         if (dev->dev.parent)
27623                 goto out;
27624  #endif
27625 -
27626         /* Ensure the device has been registrered */
27627         err = -EINVAL;
27628         if (dev->reg_state != NETREG_REGISTERED)
27629 diff -NurpP --minimal linux-2.6.33.2/net/core/rtnetlink.c linux-2.6.33.2-vs2.3.0.36.30.4/net/core/rtnetlink.c
27630 --- linux-2.6.33.2/net/core/rtnetlink.c 2010-02-25 11:52:10.000000000 +0100
27631 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/core/rtnetlink.c 2010-02-25 13:59:02.000000000 +0100
27632 @@ -695,6 +695,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
27633                 hlist_for_each_entry(dev, node, head, index_hlist) {
27634                         if (idx < s_idx)
27635                                 goto cont;
27636 +                       if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
27637 +                               continue;
27638                         if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
27639                                              NETLINK_CB(cb->skb).pid,
27640                                              cb->nlh->nlmsg_seq, 0,
27641 @@ -1252,6 +1254,9 @@ void rtmsg_ifinfo(int type, struct net_d
27642         struct sk_buff *skb;
27643         int err = -ENOBUFS;
27644  
27645 +       if (!nx_dev_visible(current_nx_info(), dev))
27646 +               return;
27647 +
27648         skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
27649         if (skb == NULL)
27650                 goto errout;
27651 diff -NurpP --minimal linux-2.6.33.2/net/core/sock.c linux-2.6.33.2-vs2.3.0.36.30.4/net/core/sock.c
27652 --- linux-2.6.33.2/net/core/sock.c      2010-04-06 01:47:46.000000000 +0200
27653 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/core/sock.c      2010-04-06 01:59:25.000000000 +0200
27654 @@ -125,6 +125,10 @@
27655  #include <linux/ipsec.h>
27656  
27657  #include <linux/filter.h>
27658 +#include <linux/vs_socket.h>
27659 +#include <linux/vs_limit.h>
27660 +#include <linux/vs_context.h>
27661 +#include <linux/vs_network.h>
27662  
27663  #ifdef CONFIG_INET
27664  #include <net/tcp.h>
27665 @@ -1012,6 +1016,8 @@ static struct sock *sk_prot_alloc(struct
27666                         goto out_free_sec;
27667                 sk_tx_queue_clear(sk);
27668         }
27669 +               sock_vx_init(sk);
27670 +               sock_nx_init(sk);
27671  
27672         return sk;
27673  
27674 @@ -1091,6 +1097,11 @@ static void __sk_free(struct sock *sk)
27675                        __func__, atomic_read(&sk->sk_omem_alloc));
27676  
27677         put_net(sock_net(sk));
27678 +       vx_sock_dec(sk);
27679 +       clr_vx_info(&sk->sk_vx_info);
27680 +       sk->sk_xid = -1;
27681 +       clr_nx_info(&sk->sk_nx_info);
27682 +       sk->sk_nid = -1;
27683         sk_prot_free(sk->sk_prot_creator, sk);
27684  }
27685  
27686 @@ -1138,6 +1149,8 @@ struct sock *sk_clone(const struct sock 
27687  
27688                 /* SANITY */
27689                 get_net(sock_net(newsk));
27690 +               sock_vx_init(newsk);
27691 +               sock_nx_init(newsk);
27692                 sk_node_init(&newsk->sk_node);
27693                 sock_lock_init(newsk);
27694                 bh_lock_sock(newsk);
27695 @@ -1193,6 +1206,12 @@ struct sock *sk_clone(const struct sock 
27696                 smp_wmb();
27697                 atomic_set(&newsk->sk_refcnt, 2);
27698  
27699 +               set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
27700 +               newsk->sk_xid = sk->sk_xid;
27701 +               vx_sock_inc(newsk);
27702 +               set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
27703 +               newsk->sk_nid = sk->sk_nid;
27704 +
27705                 /*
27706                  * Increment the counter in the same struct proto as the master
27707                  * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
27708 @@ -1922,6 +1941,12 @@ void sock_init_data(struct socket *sock,
27709  
27710         sk->sk_stamp = ktime_set(-1L, 0);
27711  
27712 +       set_vx_info(&sk->sk_vx_info, current_vx_info());
27713 +       sk->sk_xid = vx_current_xid();
27714 +       vx_sock_inc(sk);
27715 +       set_nx_info(&sk->sk_nx_info, current_nx_info());
27716 +       sk->sk_nid = nx_current_nid();
27717 +
27718         /*
27719          * Before updating sk_refcnt, we must commit prior changes to memory
27720          * (Documentation/RCU/rculist_nulls.txt for details)
27721 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/af_inet.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/af_inet.c
27722 --- linux-2.6.33.2/net/ipv4/af_inet.c   2010-02-25 11:52:10.000000000 +0100
27723 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/af_inet.c   2010-02-25 15:53:12.000000000 +0100
27724 @@ -115,6 +115,7 @@
27725  #ifdef CONFIG_IP_MROUTE
27726  #include <linux/mroute.h>
27727  #endif
27728 +#include <linux/vs_limit.h>
27729  
27730  
27731  /* The inetsw table contains everything that inet_create needs to
27732 @@ -326,9 +327,13 @@ lookup_protocol:
27733         }
27734  
27735         err = -EPERM;
27736 +       if ((protocol == IPPROTO_ICMP) &&
27737 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
27738 +               goto override;
27739 +
27740         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
27741                 goto out_rcu_unlock;
27742 -
27743 +override:
27744         err = -EAFNOSUPPORT;
27745         if (!inet_netns_ok(net, protocol))
27746                 goto out_rcu_unlock;
27747 @@ -448,6 +453,7 @@ int inet_bind(struct socket *sock, struc
27748         struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
27749         struct sock *sk = sock->sk;
27750         struct inet_sock *inet = inet_sk(sk);
27751 +       struct nx_v4_sock_addr nsa;
27752         unsigned short snum;
27753         int chk_addr_ret;
27754         int err;
27755 @@ -461,7 +467,11 @@ int inet_bind(struct socket *sock, struc
27756         if (addr_len < sizeof(struct sockaddr_in))
27757                 goto out;
27758  
27759 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27760 +       err = v4_map_sock_addr(inet, addr, &nsa);
27761 +       if (err)
27762 +               goto out;
27763 +
27764 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27765  
27766         /* Not specified by any standard per-se, however it breaks too
27767          * many applications when removed.  It is unfortunate since
27768 @@ -473,7 +483,7 @@ int inet_bind(struct socket *sock, struc
27769         err = -EADDRNOTAVAIL;
27770         if (!sysctl_ip_nonlocal_bind &&
27771             !(inet->freebind || inet->transparent) &&
27772 -           addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
27773 +           nsa.saddr != htonl(INADDR_ANY) &&
27774             chk_addr_ret != RTN_LOCAL &&
27775             chk_addr_ret != RTN_MULTICAST &&
27776             chk_addr_ret != RTN_BROADCAST)
27777 @@ -498,7 +508,7 @@ int inet_bind(struct socket *sock, struc
27778         if (sk->sk_state != TCP_CLOSE || inet->inet_num)
27779                 goto out_release_sock;
27780  
27781 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
27782 +       v4_set_sock_addr(inet, &nsa);
27783         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27784                 inet->inet_saddr = 0;  /* Use device */
27785  
27786 @@ -695,11 +705,13 @@ int inet_getname(struct socket *sock, st
27787                      peer == 1))
27788                         return -ENOTCONN;
27789                 sin->sin_port = inet->inet_dport;
27790 -               sin->sin_addr.s_addr = inet->inet_daddr;
27791 +               sin->sin_addr.s_addr =
27792 +                       nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
27793         } else {
27794                 __be32 addr = inet->inet_rcv_saddr;
27795                 if (!addr)
27796                         addr = inet->inet_saddr;
27797 +               addr = nx_map_sock_lback(sk->sk_nx_info, addr);
27798                 sin->sin_port = inet->inet_sport;
27799                 sin->sin_addr.s_addr = addr;
27800         }
27801 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/devinet.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/devinet.c
27802 --- linux-2.6.33.2/net/ipv4/devinet.c   2010-02-25 11:52:10.000000000 +0100
27803 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/devinet.c   2010-02-25 14:19:58.000000000 +0100
27804 @@ -416,6 +416,7 @@ struct in_device *inetdev_by_index(struc
27805  }
27806  EXPORT_SYMBOL(inetdev_by_index);
27807  
27808 +
27809  /* Called only from RTNL semaphored context. No locks. */
27810  
27811  struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
27812 @@ -658,6 +659,8 @@ int devinet_ioctl(struct net *net, unsig
27813  
27814         in_dev = __in_dev_get_rtnl(dev);
27815         if (in_dev) {
27816 +               struct nx_info *nxi = current_nx_info();
27817 +
27818                 if (tryaddrmatch) {
27819                         /* Matthias Andree */
27820                         /* compare label and address (4.4BSD style) */
27821 @@ -666,6 +669,8 @@ int devinet_ioctl(struct net *net, unsig
27822                            This is checked above. */
27823                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27824                              ifap = &ifa->ifa_next) {
27825 +                               if (!nx_v4_ifa_visible(nxi, ifa))
27826 +                                       continue;
27827                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
27828                                     sin_orig.sin_addr.s_addr ==
27829                                                         ifa->ifa_address) {
27830 @@ -678,9 +683,12 @@ int devinet_ioctl(struct net *net, unsig
27831                    comparing just the label */
27832                 if (!ifa) {
27833                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27834 -                            ifap = &ifa->ifa_next)
27835 +                            ifap = &ifa->ifa_next) {
27836 +                               if (!nx_v4_ifa_visible(nxi, ifa))
27837 +                                       continue;
27838                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
27839                                         break;
27840 +                       }
27841                 }
27842         }
27843  
27844 @@ -832,6 +840,8 @@ static int inet_gifconf(struct net_devic
27845                 goto out;
27846  
27847         for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
27848 +               if (!nx_v4_ifa_visible(current_nx_info(), ifa))
27849 +                       continue;
27850                 if (!buf) {
27851                         done += sizeof(ifr);
27852                         continue;
27853 @@ -1180,6 +1190,7 @@ static int inet_dump_ifaddr(struct sk_bu
27854         struct net_device *dev;
27855         struct in_device *in_dev;
27856         struct in_ifaddr *ifa;
27857 +       struct sock *sk = skb->sk;
27858         struct hlist_head *head;
27859         struct hlist_node *node;
27860  
27861 @@ -1202,6 +1213,8 @@ static int inet_dump_ifaddr(struct sk_bu
27862  
27863                         for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
27864                              ifa = ifa->ifa_next, ip_idx++) {
27865 +                       if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
27866 +                               continue;
27867                                 if (ip_idx < s_ip_idx)
27868                                         continue;
27869                                 if (inet_fill_ifaddr(skb, ifa,
27870 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/fib_hash.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/fib_hash.c
27871 --- linux-2.6.33.2/net/ipv4/fib_hash.c  2010-02-25 11:52:10.000000000 +0100
27872 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/fib_hash.c  2010-02-25 12:02:16.000000000 +0100
27873 @@ -1016,7 +1016,7 @@ static int fib_seq_show(struct seq_file 
27874         prefix  = f->fn_key;
27875         mask    = FZ_MASK(iter->zone);
27876         flags   = fib_flag_trans(fa->fa_type, mask, fi);
27877 -       if (fi)
27878 +       if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
27879                 seq_printf(seq,
27880                          "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
27881                          fi->fib_dev ? fi->fib_dev->name : "*", prefix,
27882 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/inet_connection_sock.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/inet_connection_sock.c
27883 --- linux-2.6.33.2/net/ipv4/inet_connection_sock.c      2010-02-25 11:52:10.000000000 +0100
27884 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/inet_connection_sock.c      2010-02-25 12:02:16.000000000 +0100
27885 @@ -49,10 +49,40 @@ void inet_get_local_port_range(int *low,
27886  }
27887  EXPORT_SYMBOL(inet_get_local_port_range);
27888  
27889 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27890 +{
27891 +       __be32  sk1_rcv_saddr = inet_rcv_saddr(sk1),
27892 +               sk2_rcv_saddr = inet_rcv_saddr(sk2);
27893 +
27894 +       if (inet_v6_ipv6only(sk2))
27895 +               return 0;
27896 +
27897 +       if (sk1_rcv_saddr &&
27898 +           sk2_rcv_saddr &&
27899 +           sk1_rcv_saddr == sk2_rcv_saddr)
27900 +               return 1;
27901 +
27902 +       if (sk1_rcv_saddr &&
27903 +           !sk2_rcv_saddr &&
27904 +           v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
27905 +               return 1;
27906 +
27907 +       if (sk2_rcv_saddr &&
27908 +           !sk1_rcv_saddr &&
27909 +           v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
27910 +               return 1;
27911 +
27912 +       if (!sk1_rcv_saddr &&
27913 +           !sk2_rcv_saddr &&
27914 +           nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
27915 +               return 1;
27916 +
27917 +       return 0;
27918 +}
27919 +
27920  int inet_csk_bind_conflict(const struct sock *sk,
27921                            const struct inet_bind_bucket *tb)
27922  {
27923 -       const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27924         struct sock *sk2;
27925         struct hlist_node *node;
27926         int reuse = sk->sk_reuse;
27927 @@ -72,9 +102,7 @@ int inet_csk_bind_conflict(const struct 
27928                      sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27929                         if (!reuse || !sk2->sk_reuse ||
27930                             sk2->sk_state == TCP_LISTEN) {
27931 -                               const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27932 -                               if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27933 -                                   sk2_rcv_saddr == sk_rcv_saddr)
27934 +                               if (ipv4_rcv_saddr_equal(sk, sk2))
27935                                         break;
27936                         }
27937                 }
27938 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/inet_diag.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/inet_diag.c
27939 --- linux-2.6.33.2/net/ipv4/inet_diag.c 2010-02-25 11:52:10.000000000 +0100
27940 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/inet_diag.c 2010-02-25 14:16:01.000000000 +0100
27941 @@ -32,6 +32,8 @@
27942  #include <linux/stddef.h>
27943  
27944  #include <linux/inet_diag.h>
27945 +#include <linux/vs_network.h>
27946 +#include <linux/vs_inet.h>
27947  
27948  static const struct inet_diag_handler **inet_diag_table;
27949  
27950 @@ -118,8 +120,10 @@ static int inet_csk_diag_fill(struct soc
27951  
27952         r->id.idiag_sport = inet->inet_sport;
27953         r->id.idiag_dport = inet->inet_dport;
27954 -       r->id.idiag_src[0] = inet->inet_rcv_saddr;
27955 -       r->id.idiag_dst[0] = inet->inet_daddr;
27956 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
27957 +               inet->inet_rcv_saddr);
27958 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
27959 +               inet->inet_daddr);
27960  
27961  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27962         if (r->idiag_family == AF_INET6) {
27963 @@ -204,8 +208,8 @@ static int inet_twsk_diag_fill(struct in
27964         r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
27965         r->id.idiag_sport     = tw->tw_sport;
27966         r->id.idiag_dport     = tw->tw_dport;
27967 -       r->id.idiag_src[0]    = tw->tw_rcv_saddr;
27968 -       r->id.idiag_dst[0]    = tw->tw_daddr;
27969 +       r->id.idiag_src[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
27970 +       r->id.idiag_dst[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
27971         r->idiag_state        = tw->tw_substate;
27972         r->idiag_timer        = 3;
27973         r->idiag_expires      = DIV_ROUND_UP(tmo * 1000, HZ);
27974 @@ -262,6 +266,7 @@ static int inet_diag_get_exact(struct sk
27975         err = -EINVAL;
27976  
27977         if (req->idiag_family == AF_INET) {
27978 +               /* TODO: lback */
27979                 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
27980                                  req->id.idiag_dport, req->id.idiag_src[0],
27981                                  req->id.idiag_sport, req->id.idiag_if);
27982 @@ -504,6 +509,7 @@ static int inet_csk_diag_dump(struct soc
27983                 } else
27984  #endif
27985                 {
27986 +                       /* TODO: lback */
27987                         entry.saddr = &inet->inet_rcv_saddr;
27988                         entry.daddr = &inet->inet_daddr;
27989                 }
27990 @@ -540,6 +546,7 @@ static int inet_twsk_diag_dump(struct in
27991                 } else
27992  #endif
27993                 {
27994 +                       /* TODO: lback */
27995                         entry.saddr = &tw->tw_rcv_saddr;
27996                         entry.daddr = &tw->tw_daddr;
27997                 }
27998 @@ -586,8 +593,8 @@ static int inet_diag_fill_req(struct sk_
27999  
28000         r->id.idiag_sport = inet->inet_sport;
28001         r->id.idiag_dport = ireq->rmt_port;
28002 -       r->id.idiag_src[0] = ireq->loc_addr;
28003 -       r->id.idiag_dst[0] = ireq->rmt_addr;
28004 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
28005 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
28006         r->idiag_expires = jiffies_to_msecs(tmo);
28007         r->idiag_rqueue = 0;
28008         r->idiag_wqueue = 0;
28009 @@ -657,6 +664,7 @@ static int inet_diag_dump_reqs(struct sk
28010                                 continue;
28011  
28012                         if (bc) {
28013 +                               /* TODO: lback */
28014                                 entry.saddr =
28015  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
28016                                         (entry.family == AF_INET6) ?
28017 @@ -727,6 +735,8 @@ static int inet_diag_dump(struct sk_buff
28018                         sk_nulls_for_each(sk, node, &ilb->head) {
28019                                 struct inet_sock *inet = inet_sk(sk);
28020  
28021 +                               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28022 +                                       continue;
28023                                 if (num < s_num) {
28024                                         num++;
28025                                         continue;
28026 @@ -793,6 +803,8 @@ skip_listen_ht:
28027                 sk_nulls_for_each(sk, node, &head->chain) {
28028                         struct inet_sock *inet = inet_sk(sk);
28029  
28030 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28031 +                               continue;
28032                         if (num < s_num)
28033                                 goto next_normal;
28034                         if (!(r->idiag_states & (1 << sk->sk_state)))
28035 @@ -817,6 +829,8 @@ next_normal:
28036                         inet_twsk_for_each(tw, node,
28037                                     &head->twchain) {
28038  
28039 +                               if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
28040 +                                       continue;
28041                                 if (num < s_num)
28042                                         goto next_dying;
28043                                 if (r->id.idiag_sport != tw->tw_sport &&
28044 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/inet_hashtables.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/inet_hashtables.c
28045 --- linux-2.6.33.2/net/ipv4/inet_hashtables.c   2010-02-25 11:52:10.000000000 +0100
28046 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/inet_hashtables.c   2010-02-25 12:02:16.000000000 +0100
28047 @@ -21,6 +21,7 @@
28048  
28049  #include <net/inet_connection_sock.h>
28050  #include <net/inet_hashtables.h>
28051 +#include <net/route.h>
28052  #include <net/ip.h>
28053  
28054  /*
28055 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
28056                         if (rcv_saddr != daddr)
28057                                 return -1;
28058                         score += 2;
28059 +               } else {
28060 +                       /* block non nx_info ips */
28061 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
28062 +                               daddr, NXA_MASK_BIND))
28063 +                               return -1;
28064                 }
28065                 if (sk->sk_bound_dev_if) {
28066                         if (sk->sk_bound_dev_if != dif)
28067 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
28068   * wildcarded during the search since they can never be otherwise.
28069   */
28070  
28071 -
28072  struct sock *__inet_lookup_listener(struct net *net,
28073                                     struct inet_hashinfo *hashinfo,
28074                                     const __be32 daddr, const unsigned short hnum,
28075 @@ -174,6 +179,7 @@ begin:
28076                         hiscore = score;
28077                 }
28078         }
28079 +
28080         /*
28081          * if the nulls value we got at the end of this lookup is
28082          * not the expected one, we must restart lookup.
28083 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/netfilter/nf_nat_helper.c
28084 --- linux-2.6.33.2/net/ipv4/netfilter/nf_nat_helper.c   2010-02-25 11:52:10.000000000 +0100
28085 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/netfilter/nf_nat_helper.c   2010-02-25 12:02:16.000000000 +0100
28086 @@ -19,6 +19,7 @@
28087  #include <net/route.h>
28088  
28089  #include <linux/netfilter_ipv4.h>
28090 +#include <net/route.h>
28091  #include <net/netfilter/nf_conntrack.h>
28092  #include <net/netfilter/nf_conntrack_helper.h>
28093  #include <net/netfilter/nf_conntrack_ecache.h>
28094 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/netfilter.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/netfilter.c
28095 --- linux-2.6.33.2/net/ipv4/netfilter.c 2010-02-25 11:52:10.000000000 +0100
28096 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/netfilter.c 2010-02-25 12:02:16.000000000 +0100
28097 @@ -4,7 +4,7 @@
28098  #include <linux/netfilter_ipv4.h>
28099  #include <linux/ip.h>
28100  #include <linux/skbuff.h>
28101 -#include <net/route.h>
28102 +// #include <net/route.h>
28103  #include <net/xfrm.h>
28104  #include <net/ip.h>
28105  #include <net/netfilter/nf_queue.h>
28106 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/raw.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/raw.c
28107 --- linux-2.6.33.2/net/ipv4/raw.c       2010-02-25 11:52:10.000000000 +0100
28108 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/raw.c       2010-02-25 14:07:52.000000000 +0100
28109 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
28110  
28111                 if (net_eq(sock_net(sk), net) && inet->inet_num == num  &&
28112                     !(inet->inet_daddr && inet->inet_daddr != raddr)    &&
28113 -                   !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
28114 +                   v4_sock_addr_match(sk->sk_nx_info, inet, laddr)     &&
28115                     !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
28116                         goto found; /* gotcha */
28117         }
28118 @@ -382,6 +382,12 @@ static int raw_send_hdrinc(struct sock *
28119                 icmp_out_count(net, ((struct icmphdr *)
28120                         skb_transport_header(skb))->type);
28121  
28122 +       err = -EPERM;
28123 +       if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
28124 +               sk->sk_nx_info &&
28125 +               !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
28126 +               goto error_free;
28127 +
28128         err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
28129                       dst_output);
28130         if (err > 0)
28131 @@ -562,6 +568,13 @@ static int raw_sendmsg(struct kiocb *ioc
28132                 }
28133  
28134                 security_sk_classify_flow(sk, &fl);
28135 +               if (sk->sk_nx_info) {
28136 +                       err = ip_v4_find_src(sock_net(sk),
28137 +                               sk->sk_nx_info, &rt, &fl);
28138 +
28139 +                       if (err)
28140 +                               goto done;
28141 +               }
28142                 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
28143         }
28144         if (err)
28145 @@ -634,17 +647,19 @@ static int raw_bind(struct sock *sk, str
28146  {
28147         struct inet_sock *inet = inet_sk(sk);
28148         struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
28149 +       struct nx_v4_sock_addr nsa = { 0 };
28150         int ret = -EINVAL;
28151         int chk_addr_ret;
28152  
28153         if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
28154                 goto out;
28155 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
28156 +       v4_map_sock_addr(inet, addr, &nsa);
28157 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
28158         ret = -EADDRNOTAVAIL;
28159 -       if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
28160 +       if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
28161             chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
28162                 goto out;
28163 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
28164 +       v4_set_sock_addr(inet, &nsa);
28165         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
28166                 inet->inet_saddr = 0;  /* Use device */
28167         sk_dst_reset(sk);
28168 @@ -696,7 +711,8 @@ static int raw_recvmsg(struct kiocb *ioc
28169         /* Copy the address. */
28170         if (sin) {
28171                 sin->sin_family = AF_INET;
28172 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
28173 +               sin->sin_addr.s_addr =
28174 +                       nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
28175                 sin->sin_port = 0;
28176                 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
28177         }
28178 @@ -874,7 +890,8 @@ static struct sock *raw_get_first(struct
28179                 struct hlist_node *node;
28180  
28181                 sk_for_each(sk, node, &state->h->ht[state->bucket])
28182 -                       if (sock_net(sk) == seq_file_net(seq))
28183 +                       if ((sock_net(sk) == seq_file_net(seq)) &&
28184 +                               nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28185                                 goto found;
28186         }
28187         sk = NULL;
28188 @@ -890,7 +907,8 @@ static struct sock *raw_get_next(struct 
28189                 sk = sk_next(sk);
28190  try_again:
28191                 ;
28192 -       } while (sk && sock_net(sk) != seq_file_net(seq));
28193 +       } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
28194 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
28195  
28196         if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
28197                 sk = sk_head(&state->h->ht[state->bucket]);
28198 @@ -949,7 +967,10 @@ static void raw_sock_seq_show(struct seq
28199  
28200         seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
28201                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
28202 -               i, src, srcp, dest, destp, sp->sk_state,
28203 +               i,
28204 +               nx_map_sock_lback(current_nx_info(), src), srcp,
28205 +               nx_map_sock_lback(current_nx_info(), dest), destp,
28206 +               sp->sk_state,
28207                 sk_wmem_alloc_get(sp),
28208                 sk_rmem_alloc_get(sp),
28209                 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
28210 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/tcp.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/tcp.c
28211 --- linux-2.6.33.2/net/ipv4/tcp.c       2010-04-06 01:47:46.000000000 +0200
28212 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/tcp.c       2010-04-06 01:59:25.000000000 +0200
28213 @@ -265,6 +265,7 @@
28214  #include <linux/err.h>
28215  #include <linux/crypto.h>
28216  #include <linux/time.h>
28217 +#include <linux/in.h>
28218  
28219  #include <net/icmp.h>
28220  #include <net/tcp.h>
28221 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/tcp_ipv4.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/tcp_ipv4.c
28222 --- linux-2.6.33.2/net/ipv4/tcp_ipv4.c  2010-04-06 01:47:47.000000000 +0200
28223 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/tcp_ipv4.c  2010-04-06 01:59:25.000000000 +0200
28224 @@ -1990,6 +1990,12 @@ static void *listening_get_next(struct s
28225                 req = req->dl_next;
28226                 while (1) {
28227                         while (req) {
28228 +                               vxdprintk(VXD_CBIT(net, 6),
28229 +                                       "sk,req: %p [#%d] (from %d)", req->sk,
28230 +                                       (req->sk)?req->sk->sk_nid:0, nx_current_nid());
28231 +                               if (req->sk &&
28232 +                                       !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
28233 +                                       continue;
28234                                 if (req->rsk_ops->family == st->family) {
28235                                         cur = req;
28236                                         goto out;
28237 @@ -2014,6 +2020,10 @@ get_req:
28238         }
28239  get_sk:
28240         sk_nulls_for_each_from(sk, node) {
28241 +               vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
28242 +                       sk, sk->sk_nid, nx_current_nid());
28243 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28244 +                       continue;
28245                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
28246                         cur = sk;
28247                         goto out;
28248 @@ -2077,6 +2087,11 @@ static void *established_get_first(struc
28249  
28250                 spin_lock_bh(lock);
28251                 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
28252 +                       vxdprintk(VXD_CBIT(net, 6),
28253 +                               "sk,egf: %p [#%d] (from %d)",
28254 +                               sk, sk->sk_nid, nx_current_nid());
28255 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28256 +                               continue;
28257                         if (sk->sk_family != st->family ||
28258                             !net_eq(sock_net(sk), net)) {
28259                                 continue;
28260 @@ -2087,6 +2102,11 @@ static void *established_get_first(struc
28261                 st->state = TCP_SEQ_STATE_TIME_WAIT;
28262                 inet_twsk_for_each(tw, node,
28263                                    &tcp_hashinfo.ehash[st->bucket].twchain) {
28264 +                       vxdprintk(VXD_CBIT(net, 6),
28265 +                               "tw: %p [#%d] (from %d)",
28266 +                               tw, tw->tw_nid, nx_current_nid());
28267 +                       if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
28268 +                               continue;
28269                         if (tw->tw_family != st->family ||
28270                             !net_eq(twsk_net(tw), net)) {
28271                                 continue;
28272 @@ -2115,7 +2135,9 @@ static void *established_get_next(struct
28273                 tw = cur;
28274                 tw = tw_next(tw);
28275  get_tw:
28276 -               while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
28277 +               while (tw && (tw->tw_family != st->family ||
28278 +                       !net_eq(twsk_net(tw), net) ||
28279 +                       !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
28280                         tw = tw_next(tw);
28281                 }
28282                 if (tw) {
28283 @@ -2138,6 +2160,11 @@ get_tw:
28284                 sk = sk_nulls_next(sk);
28285  
28286         sk_nulls_for_each_from(sk, node) {
28287 +               vxdprintk(VXD_CBIT(net, 6),
28288 +                       "sk,egn: %p [#%d] (from %d)",
28289 +                       sk, sk->sk_nid, nx_current_nid());
28290 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28291 +                       continue;
28292                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
28293                         goto found;
28294         }
28295 @@ -2289,9 +2316,9 @@ static void get_openreq4(struct sock *sk
28296         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
28297                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
28298                 i,
28299 -               ireq->loc_addr,
28300 +               nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
28301                 ntohs(inet_sk(sk)->inet_sport),
28302 -               ireq->rmt_addr,
28303 +               nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
28304                 ntohs(ireq->rmt_port),
28305                 TCP_SYN_RECV,
28306                 0, 0, /* could print option size, but that is af dependent. */
28307 @@ -2343,7 +2370,10 @@ static void get_tcp4_sock(struct sock *s
28308  
28309         seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
28310                         "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
28311 -               i, src, srcp, dest, destp, sk->sk_state,
28312 +               i,
28313 +               nx_map_sock_lback(current_nx_info(), src), srcp,
28314 +               nx_map_sock_lback(current_nx_info(), dest), destp,
28315 +               sk->sk_state,
28316                 tp->write_seq - tp->snd_una,
28317                 rx_queue,
28318                 timer_active,
28319 @@ -2378,7 +2408,10 @@ static void get_timewait4_sock(struct in
28320  
28321         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
28322                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
28323 -               i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
28324 +               i,
28325 +               nx_map_sock_lback(current_nx_info(), src), srcp,
28326 +               nx_map_sock_lback(current_nx_info(), dest), destp,
28327 +               tw->tw_substate, 0, 0,
28328                 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
28329                 atomic_read(&tw->tw_refcnt), tw, len);
28330  }
28331 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/tcp_minisocks.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/tcp_minisocks.c
28332 --- linux-2.6.33.2/net/ipv4/tcp_minisocks.c     2010-04-06 01:47:47.000000000 +0200
28333 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/tcp_minisocks.c     2010-04-06 01:59:25.000000000 +0200
28334 @@ -22,6 +22,9 @@
28335  #include <linux/module.h>
28336  #include <linux/sysctl.h>
28337  #include <linux/workqueue.h>
28338 +#include <linux/vs_limit.h>
28339 +#include <linux/vs_socket.h>
28340 +#include <linux/vs_context.h>
28341  #include <net/tcp.h>
28342  #include <net/inet_common.h>
28343  #include <net/xfrm.h>
28344 @@ -289,6 +292,11 @@ void tcp_time_wait(struct sock *sk, int 
28345                 tcptw->tw_ts_recent     = tp->rx_opt.ts_recent;
28346                 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
28347  
28348 +               tw->tw_xid              = sk->sk_xid;
28349 +               tw->tw_vx_info          = NULL;
28350 +               tw->tw_nid              = sk->sk_nid;
28351 +               tw->tw_nx_info          = NULL;
28352 +
28353  #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
28354                 if (tw->tw_family == PF_INET6) {
28355                         struct ipv6_pinfo *np = inet6_sk(sk);
28356 diff -NurpP --minimal linux-2.6.33.2/net/ipv4/udp.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/udp.c
28357 --- linux-2.6.33.2/net/ipv4/udp.c       2010-04-06 01:47:47.000000000 +0200
28358 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv4/udp.c       2010-04-06 01:59:25.000000000 +0200
28359 @@ -294,14 +294,7 @@ fail:
28360  }
28361  EXPORT_SYMBOL(udp_lib_get_port);
28362  
28363 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
28364 -{
28365 -       struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
28366 -
28367 -       return  (!ipv6_only_sock(sk2)  &&
28368 -                (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
28369 -                  inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
28370 -}
28371 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
28372  
28373  static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
28374                                        unsigned int port)
28375 @@ -336,6 +329,11 @@ static inline int compute_score(struct s
28376                         if (inet->inet_rcv_saddr != daddr)
28377                                 return -1;
28378                         score += 2;
28379 +               } else {
28380 +                       /* block non nx_info ips */
28381 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
28382 +                               daddr, NXA_MASK_BIND))
28383 +                               return -1;
28384                 }
28385                 if (inet->inet_daddr) {
28386                         if (inet->inet_daddr != saddr)
28387 @@ -439,6 +437,7 @@ exact_match:
28388         return result;
28389  }
28390  
28391 +
28392  /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
28393   * harder than this. -DaveM
28394   */
28395 @@ -484,6 +483,11 @@ begin:
28396         sk_nulls_for_each_rcu(sk, node, &hslot->head) {
28397                 score = compute_score(sk, net, saddr, hnum, sport,
28398                                       daddr, dport, dif);
28399 +               /* FIXME: disabled?
28400 +               if (score == 9) {
28401 +                       result = sk;
28402 +                       break;
28403 +               } else */
28404                 if (score > badness) {
28405                         result = sk;
28406                         badness = score;
28407 @@ -497,6 +501,7 @@ begin:
28408         if (get_nulls_value(node) != slot)
28409                 goto begin;
28410  
28411 +
28412         if (result) {
28413                 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
28414                         result = NULL;
28415 @@ -506,6 +511,7 @@ begin:
28416                         goto begin;
28417                 }
28418         }
28419 +
28420         rcu_read_unlock();
28421         return result;
28422  }
28423 @@ -548,8 +554,7 @@ static inline struct sock *udp_v4_mcast_
28424                     udp_sk(s)->udp_port_hash != hnum ||
28425                     (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
28426                     (inet->inet_dport != rmt_port && inet->inet_dport) ||
28427 -                   (inet->inet_rcv_saddr &&
28428 -                    inet->inet_rcv_saddr != loc_addr) ||
28429 +                   !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
28430                     ipv6_only_sock(s) ||
28431                     (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
28432                         continue;
28433 @@ -898,8 +903,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
28434                                                { .sport = inet->inet_sport,
28435                                                  .dport = dport } } };
28436                 struct net *net = sock_net(sk);
28437 +               struct nx_info *nxi = sk->sk_nx_info;
28438  
28439                 security_sk_classify_flow(sk, &fl);
28440 +               err = ip_v4_find_src(net, nxi, &rt, &fl);
28441 +               if (err)
28442 +                       goto out;
28443 +
28444                 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
28445                 if (err) {
28446                         if (err == -ENETUNREACH)
28447 @@ -1180,7 +1190,8 @@ try_again:
28448         if (sin) {
28449                 sin->sin_family = AF_INET;
28450                 sin->sin_port = udp_hdr(skb)->source;
28451 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
28452 +               sin->sin_addr.s_addr = nx_map_sock_lback(
28453 +                       skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
28454                 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
28455         }
28456         if (inet->cmsg_flags)
28457 @@ -1867,6 +1878,8 @@ static struct sock *udp_get_first(struct
28458                 sk_nulls_for_each(sk, node, &hslot->head) {
28459                         if (!net_eq(sock_net(sk), net))
28460                                 continue;
28461 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28462 +                               continue;
28463                         if (sk->sk_family == state->family)
28464                                 goto found;
28465                 }
28466 @@ -1884,7 +1897,9 @@ static struct sock *udp_get_next(struct 
28467  
28468         do {
28469                 sk = sk_nulls_next(sk);
28470 -       } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
28471 +       } while (sk && (!net_eq(sock_net(sk), net) ||
28472 +               sk->sk_family != state->family ||
28473 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
28474  
28475         if (!sk) {
28476                 if (state->bucket <= state->udp_table->mask)
28477 @@ -1991,7 +2006,10 @@ static void udp4_format_sock(struct sock
28478  
28479         seq_printf(f, "%5d: %08X:%04X %08X:%04X"
28480                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
28481 -               bucket, src, srcp, dest, destp, sp->sk_state,
28482 +               bucket,
28483 +               nx_map_sock_lback(current_nx_info(), src), srcp,
28484 +               nx_map_sock_lback(current_nx_info(), dest), destp,
28485 +               sp->sk_state,
28486                 sk_wmem_alloc_get(sp),
28487                 sk_rmem_alloc_get(sp),
28488                 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
28489 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/addrconf.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/addrconf.c
28490 --- linux-2.6.33.2/net/ipv6/addrconf.c  2010-02-25 11:52:10.000000000 +0100
28491 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/addrconf.c  2010-02-25 13:40:38.000000000 +0100
28492 @@ -86,6 +86,8 @@
28493  
28494  #include <linux/proc_fs.h>
28495  #include <linux/seq_file.h>
28496 +#include <linux/vs_network.h>
28497 +#include <linux/vs_inet6.h>
28498  
28499  /* Set to 3 to get tracing... */
28500  #define ACONF_DEBUG 2
28501 @@ -1120,7 +1122,7 @@ out:
28502  
28503  int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
28504                        const struct in6_addr *daddr, unsigned int prefs,
28505 -                      struct in6_addr *saddr)
28506 +                      struct in6_addr *saddr, struct nx_info *nxi)
28507  {
28508         struct ipv6_saddr_score scores[2],
28509                                 *score = &scores[0], *hiscore = &scores[1];
28510 @@ -1192,6 +1194,8 @@ int ipv6_dev_get_saddr(struct net *net, 
28511                                                dev->name);
28512                                 continue;
28513                         }
28514 +                       if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
28515 +                               continue;
28516  
28517                         score->rule = -1;
28518                         bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
28519 @@ -2999,7 +3003,10 @@ static void if6_seq_stop(struct seq_file
28520  static int if6_seq_show(struct seq_file *seq, void *v)
28521  {
28522         struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
28523 -       seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
28524 +
28525 +       if (nx_check(0, VS_ADMIN|VS_WATCH) ||
28526 +           v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
28527 +               seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
28528                    &ifp->addr,
28529                    ifp->idev->dev->ifindex,
28530                    ifp->prefix_len,
28531 @@ -3494,6 +3501,11 @@ static int in6_dump_addrs(struct inet6_d
28532         struct ifacaddr6 *ifaca;
28533         int err = 1;
28534         int ip_idx = *p_ip_idx;
28535 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
28536 +
28537 +       /* disable ipv6 on non v6 guests */
28538 +       if (nxi && !nx_info_has_v6(nxi))
28539 +               return skb->len;
28540  
28541         read_lock_bh(&idev->lock);
28542         switch (type) {
28543 @@ -3503,6 +3515,8 @@ static int in6_dump_addrs(struct inet6_d
28544                      ifa = ifa->if_next, ip_idx++) {
28545                         if (ip_idx < s_ip_idx)
28546                                 continue;
28547 +                               if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
28548 +                                       continue;
28549                         err = inet6_fill_ifaddr(skb, ifa,
28550                                                 NETLINK_CB(cb->skb).pid,
28551                                                 cb->nlh->nlmsg_seq,
28552 @@ -3518,6 +3532,8 @@ static int in6_dump_addrs(struct inet6_d
28553                      ifmca = ifmca->next, ip_idx++) {
28554                         if (ip_idx < s_ip_idx)
28555                                 continue;
28556 +                               if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
28557 +                                       continue;
28558                         err = inet6_fill_ifmcaddr(skb, ifmca,
28559                                                   NETLINK_CB(cb->skb).pid,
28560                                                   cb->nlh->nlmsg_seq,
28561 @@ -3533,6 +3549,8 @@ static int in6_dump_addrs(struct inet6_d
28562                      ifaca = ifaca->aca_next, ip_idx++) {
28563                         if (ip_idx < s_ip_idx)
28564                                 continue;
28565 +                               if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
28566 +                                       continue;
28567                         err = inet6_fill_ifacaddr(skb, ifaca,
28568                                                   NETLINK_CB(cb->skb).pid,
28569                                                   cb->nlh->nlmsg_seq,
28570 @@ -3861,6 +3879,11 @@ static int inet6_dump_ifinfo(struct sk_b
28571         struct inet6_dev *idev;
28572         struct hlist_head *head;
28573         struct hlist_node *node;
28574 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
28575 +
28576 +       /* FIXME: maybe disable ipv6 on non v6 guests?
28577 +       if (skb->sk && skb->sk->sk_vx_info)
28578 +               return skb->len; */
28579  
28580         s_h = cb->args[0];
28581         s_idx = cb->args[1];
28582 @@ -3872,6 +3895,8 @@ static int inet6_dump_ifinfo(struct sk_b
28583                 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
28584                         if (idx < s_idx)
28585                                 goto cont;
28586 +                       if (!v6_dev_in_nx_info(dev, nxi))
28587 +                               goto cont;
28588                         idev = __in6_dev_get(dev);
28589                         if (!idev)
28590                                 goto cont;
28591 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/af_inet6.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/af_inet6.c
28592 --- linux-2.6.33.2/net/ipv6/af_inet6.c  2010-02-25 11:52:10.000000000 +0100
28593 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/af_inet6.c  2010-02-25 15:54:53.000000000 +0100
28594 @@ -41,6 +41,8 @@
28595  #include <linux/netdevice.h>
28596  #include <linux/icmpv6.h>
28597  #include <linux/netfilter_ipv6.h>
28598 +#include <linux/vs_inet.h>
28599 +#include <linux/vs_inet6.h>
28600  
28601  #include <net/ip.h>
28602  #include <net/ipv6.h>
28603 @@ -159,9 +161,12 @@ lookup_protocol:
28604         }
28605  
28606         err = -EPERM;
28607 +       if ((protocol == IPPROTO_ICMPV6) &&
28608 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
28609 +               goto override;
28610         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
28611                 goto out_rcu_unlock;
28612 -
28613 +override:
28614         sock->ops = answer->ops;
28615         answer_prot = answer->prot;
28616         answer_no_check = answer->no_check;
28617 @@ -260,6 +265,7 @@ int inet6_bind(struct socket *sock, stru
28618         struct inet_sock *inet = inet_sk(sk);
28619         struct ipv6_pinfo *np = inet6_sk(sk);
28620         struct net *net = sock_net(sk);
28621 +       struct nx_v6_sock_addr nsa;
28622         __be32 v4addr = 0;
28623         unsigned short snum;
28624         int addr_type = 0;
28625 @@ -271,6 +277,11 @@ int inet6_bind(struct socket *sock, stru
28626  
28627         if (addr_len < SIN6_LEN_RFC2133)
28628                 return -EINVAL;
28629 +
28630 +       err = v6_map_sock_addr(inet, addr, &nsa);
28631 +       if (err)
28632 +               return err;
28633 +
28634         addr_type = ipv6_addr_type(&addr->sin6_addr);
28635         if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
28636                 return -EINVAL;
28637 @@ -302,6 +313,7 @@ int inet6_bind(struct socket *sock, stru
28638                 /* Reproduce AF_INET checks to make the bindings consitant */
28639                 v4addr = addr->sin6_addr.s6_addr32[3];
28640                 chk_addr_ret = inet_addr_type(net, v4addr);
28641 +
28642                 if (!sysctl_ip_nonlocal_bind &&
28643                     !(inet->freebind || inet->transparent) &&
28644                     v4addr != htonl(INADDR_ANY) &&
28645 @@ -311,6 +323,10 @@ int inet6_bind(struct socket *sock, stru
28646                         err = -EADDRNOTAVAIL;
28647                         goto out;
28648                 }
28649 +               if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
28650 +                       err = -EADDRNOTAVAIL;
28651 +                       goto out;
28652 +               }
28653         } else {
28654                 if (addr_type != IPV6_ADDR_ANY) {
28655                         struct net_device *dev = NULL;
28656 @@ -337,6 +353,11 @@ int inet6_bind(struct socket *sock, stru
28657                                 }
28658                         }
28659  
28660 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28661 +                               err = -EADDRNOTAVAIL;
28662 +                               goto out;
28663 +                       }
28664 +
28665                         /* ipv4 addr of the socket is invalid.  Only the
28666                          * unspecified and mapped address have a v4 equivalent.
28667                          */
28668 @@ -352,6 +373,9 @@ int inet6_bind(struct socket *sock, stru
28669                 }
28670         }
28671  
28672 +       /* what's that for? */
28673 +       v6_set_sock_addr(inet, &nsa);
28674 +
28675         inet->inet_rcv_saddr = v4addr;
28676         inet->inet_saddr = v4addr;
28677  
28678 @@ -450,9 +474,11 @@ int inet6_getname(struct socket *sock, s
28679                         return -ENOTCONN;
28680                 sin->sin6_port = inet->inet_dport;
28681                 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
28682 +               /* FIXME: remap lback? */
28683                 if (np->sndflow)
28684                         sin->sin6_flowinfo = np->flow_label;
28685         } else {
28686 +               /* FIXME: remap lback? */
28687                 if (ipv6_addr_any(&np->rcv_saddr))
28688                         ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
28689                 else
28690 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/fib6_rules.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/fib6_rules.c
28691 --- linux-2.6.33.2/net/ipv6/fib6_rules.c        2010-02-25 11:52:10.000000000 +0100
28692 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/fib6_rules.c        2010-02-25 12:02:16.000000000 +0100
28693 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
28694                         if (ipv6_dev_get_saddr(net,
28695                                                ip6_dst_idev(&rt->u.dst)->dev,
28696                                                &flp->fl6_dst, srcprefs,
28697 -                                              &saddr))
28698 +                                              &saddr, NULL))
28699                                 goto again;
28700                         if (!ipv6_prefix_equal(&saddr, &r->src.addr,
28701                                                r->src.plen))
28702 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/inet6_hashtables.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/inet6_hashtables.c
28703 --- linux-2.6.33.2/net/ipv6/inet6_hashtables.c  2010-02-25 11:52:10.000000000 +0100
28704 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/inet6_hashtables.c  2010-02-25 12:02:16.000000000 +0100
28705 @@ -16,6 +16,7 @@
28706  
28707  #include <linux/module.h>
28708  #include <linux/random.h>
28709 +#include <linux/vs_inet6.h>
28710  
28711  #include <net/inet_connection_sock.h>
28712  #include <net/inet_hashtables.h>
28713 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
28714         unsigned int slot = hash & hashinfo->ehash_mask;
28715         struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
28716  
28717 -
28718         rcu_read_lock();
28719  begin:
28720         sk_nulls_for_each_rcu(sk, node, &head->chain) {
28721 @@ -94,7 +94,7 @@ begin:
28722                                 sock_put(sk);
28723                                 goto begin;
28724                         }
28725 -               goto out;
28726 +                       goto out;
28727                 }
28728         }
28729         if (get_nulls_value(node) != slot)
28730 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
28731                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28732                                 return -1;
28733                         score++;
28734 +               } else {
28735 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28736 +                               return -1;
28737                 }
28738                 if (sk->sk_bound_dev_if) {
28739                         if (sk->sk_bound_dev_if != dif)
28740 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/ip6_output.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/ip6_output.c
28741 --- linux-2.6.33.2/net/ipv6/ip6_output.c        2010-02-25 11:52:10.000000000 +0100
28742 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/ip6_output.c        2010-02-25 12:02:16.000000000 +0100
28743 @@ -933,7 +933,7 @@ static int ip6_dst_lookup_tail(struct so
28744                 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
28745                                          &fl->fl6_dst,
28746                                          sk ? inet6_sk(sk)->srcprefs : 0,
28747 -                                        &fl->fl6_src);
28748 +                                        &fl->fl6_src, sk->sk_nx_info);
28749                 if (err)
28750                         goto out_err_release;
28751         }
28752 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/Kconfig linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/Kconfig
28753 --- linux-2.6.33.2/net/ipv6/Kconfig     2010-02-25 11:52:10.000000000 +0100
28754 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/Kconfig     2010-02-25 12:02:16.000000000 +0100
28755 @@ -4,8 +4,8 @@
28756  
28757  #   IPv6 as module will cause a CRASH if you try to unload it
28758  menuconfig IPV6
28759 -       tristate "The IPv6 protocol"
28760 -       default m
28761 +       bool "The IPv6 protocol"
28762 +       default n
28763         ---help---
28764           This is complemental support for the IP version 6.
28765           You will still be able to do traditional IPv4 networking as well.
28766 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/ndisc.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/ndisc.c
28767 --- linux-2.6.33.2/net/ipv6/ndisc.c     2010-02-25 11:52:10.000000000 +0100
28768 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/ndisc.c     2010-02-25 12:02:16.000000000 +0100
28769 @@ -589,7 +589,7 @@ static void ndisc_send_na(struct net_dev
28770         } else {
28771                 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
28772                                        inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
28773 -                                      &tmpaddr))
28774 +                                      &tmpaddr, NULL /* FIXME: ? */ ))
28775                         return;
28776                 src_addr = &tmpaddr;
28777         }
28778 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/raw.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/raw.c
28779 --- linux-2.6.33.2/net/ipv6/raw.c       2010-02-25 11:52:11.000000000 +0100
28780 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/raw.c       2010-02-25 12:02:16.000000000 +0100
28781 @@ -29,6 +29,7 @@
28782  #include <linux/icmpv6.h>
28783  #include <linux/netfilter.h>
28784  #include <linux/netfilter_ipv6.h>
28785 +#include <linux/vs_inet6.h>
28786  #include <linux/skbuff.h>
28787  #include <asm/uaccess.h>
28788  #include <asm/ioctls.h>
28789 @@ -282,6 +283,13 @@ static int rawv6_bind(struct sock *sk, s
28790                                 goto out_unlock;
28791                 }
28792  
28793 +               if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28794 +                       err = -EADDRNOTAVAIL;
28795 +                       if (dev)
28796 +                               dev_put(dev);
28797 +                       goto out;
28798 +               }
28799 +
28800                 /* ipv4 addr of the socket is invalid.  Only the
28801                  * unspecified and mapped address have a v4 equivalent.
28802                  */
28803 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/route.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/route.c
28804 --- linux-2.6.33.2/net/ipv6/route.c     2010-04-06 01:47:47.000000000 +0200
28805 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/route.c     2010-04-06 01:59:25.000000000 +0200
28806 @@ -2263,7 +2263,8 @@ static int rt6_fill_node(struct net *net
28807                 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
28808                 struct in6_addr saddr_buf;
28809                 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
28810 -                                      dst, 0, &saddr_buf) == 0)
28811 +                       dst, 0, &saddr_buf,
28812 +                       (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
28813                         NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
28814         }
28815  
28816 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/tcp_ipv6.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/tcp_ipv6.c
28817 --- linux-2.6.33.2/net/ipv6/tcp_ipv6.c  2010-04-06 01:47:47.000000000 +0200
28818 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/tcp_ipv6.c  2010-04-06 01:59:25.000000000 +0200
28819 @@ -68,6 +68,7 @@
28820  
28821  #include <linux/crypto.h>
28822  #include <linux/scatterlist.h>
28823 +#include <linux/vs_inet6.h>
28824  
28825  static void    tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
28826  static void    tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
28827 @@ -156,8 +157,15 @@ static int tcp_v6_connect(struct sock *s
28828          *      connect() to INADDR_ANY means loopback (BSD'ism).
28829          */
28830  
28831 -       if(ipv6_addr_any(&usin->sin6_addr))
28832 -               usin->sin6_addr.s6_addr[15] = 0x1;
28833 +       if(ipv6_addr_any(&usin->sin6_addr)) {
28834 +               struct nx_info *nxi =  sk->sk_nx_info;
28835 +
28836 +               if (nxi && nx_info_has_v6(nxi))
28837 +                       /* FIXME: remap lback? */
28838 +                       usin->sin6_addr = nxi->v6.ip;
28839 +               else
28840 +                       usin->sin6_addr.s6_addr[15] = 0x1;
28841 +       }
28842  
28843         addr_type = ipv6_addr_type(&usin->sin6_addr);
28844  
28845 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/udp.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/udp.c
28846 --- linux-2.6.33.2/net/ipv6/udp.c       2010-04-06 01:47:47.000000000 +0200
28847 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/udp.c       2010-04-06 01:59:25.000000000 +0200
28848 @@ -47,13 +47,14 @@
28849  
28850  #include <linux/proc_fs.h>
28851  #include <linux/seq_file.h>
28852 +#include <linux/vs_inet6.h>
28853  #include "udp_impl.h"
28854  
28855  int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
28856  {
28857         const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
28858         const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
28859 -       __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28860 +       __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28861         __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28862         int sk_ipv6only = ipv6_only_sock(sk);
28863         int sk2_ipv6only = inet_v6_ipv6only(sk2);
28864 @@ -61,24 +62,49 @@ int ipv6_rcv_saddr_equal(const struct so
28865         int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
28866  
28867         /* if both are mapped, treat as IPv4 */
28868 -       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
28869 -               return (!sk2_ipv6only &&
28870 -                       (!sk1_rcv_saddr || !sk2_rcv_saddr ||
28871 -                         sk1_rcv_saddr == sk2_rcv_saddr));
28872 +       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
28873 +               if (!sk2_ipv6only &&
28874 +                       (!sk_rcv_saddr || !sk2_rcv_saddr ||
28875 +                         sk_rcv_saddr == sk2_rcv_saddr))
28876 +                       goto vs_v4;
28877 +               else
28878 +                       return 0;
28879 +       }
28880  
28881         if (addr_type2 == IPV6_ADDR_ANY &&
28882             !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
28883 -               return 1;
28884 +               goto vs;
28885  
28886         if (addr_type == IPV6_ADDR_ANY &&
28887             !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
28888 -               return 1;
28889 +               goto vs;
28890  
28891         if (sk2_rcv_saddr6 &&
28892             ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
28893 -               return 1;
28894 +               goto vs;
28895  
28896         return 0;
28897 +
28898 +vs_v4:
28899 +       if (!sk_rcv_saddr && !sk2_rcv_saddr)
28900 +               return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28901 +       if (!sk2_rcv_saddr)
28902 +               return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
28903 +       if (!sk_rcv_saddr)
28904 +               return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
28905 +       return 1;
28906 +vs:
28907 +       if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
28908 +               return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28909 +       else if (addr_type2 == IPV6_ADDR_ANY)
28910 +               return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
28911 +       else if (addr_type == IPV6_ADDR_ANY) {
28912 +               if (addr_type2 == IPV6_ADDR_MAPPED)
28913 +                       return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28914 +               else
28915 +                       return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
28916 +       }
28917 +       return 1;
28918  }
28919  
28920  static unsigned int udp6_portaddr_hash(struct net *net,
28921 @@ -133,6 +159,10 @@ static inline int compute_score(struct s
28922                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28923                                 return -1;
28924                         score++;
28925 +               } else {
28926 +                       /* block non nx_info ips */
28927 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28928 +                               return -1;
28929                 }
28930                 if (!ipv6_addr_any(&np->daddr)) {
28931                         if (!ipv6_addr_equal(&np->daddr, saddr))
28932 diff -NurpP --minimal linux-2.6.33.2/net/ipv6/xfrm6_policy.c linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/xfrm6_policy.c
28933 --- linux-2.6.33.2/net/ipv6/xfrm6_policy.c      2010-04-06 01:47:47.000000000 +0200
28934 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/ipv6/xfrm6_policy.c      2010-04-06 01:59:25.000000000 +0200
28935 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
28936         dev = ip6_dst_idev(dst)->dev;
28937         ipv6_dev_get_saddr(dev_net(dev), dev,
28938                            (struct in6_addr *)&daddr->a6, 0,
28939 -                          (struct in6_addr *)&saddr->a6);
28940 +                          (struct in6_addr *)&saddr->a6, NULL);
28941         dst_release(dst);
28942         return 0;
28943  }
28944 diff -NurpP --minimal linux-2.6.33.2/net/netlink/af_netlink.c linux-2.6.33.2-vs2.3.0.36.30.4/net/netlink/af_netlink.c
28945 --- linux-2.6.33.2/net/netlink/af_netlink.c     2010-04-06 01:47:47.000000000 +0200
28946 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/netlink/af_netlink.c     2010-04-06 01:59:25.000000000 +0200
28947 @@ -55,6 +55,9 @@
28948  #include <linux/types.h>
28949  #include <linux/audit.h>
28950  #include <linux/mutex.h>
28951 +#include <linux/vs_context.h>
28952 +#include <linux/vs_network.h>
28953 +#include <linux/vs_limit.h>
28954  
28955  #include <net/net_namespace.h>
28956  #include <net/sock.h>
28957 @@ -1916,6 +1919,8 @@ static struct sock *netlink_seq_socket_i
28958                         sk_for_each(s, node, &hash->table[j]) {
28959                                 if (sock_net(s) != seq_file_net(seq))
28960                                         continue;
28961 +                               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28962 +                                       continue;
28963                                 if (off == pos) {
28964                                         iter->link = i;
28965                                         iter->hash_idx = j;
28966 @@ -1950,7 +1955,8 @@ static void *netlink_seq_next(struct seq
28967         s = v;
28968         do {
28969                 s = sk_next(s);
28970 -       } while (s && sock_net(s) != seq_file_net(seq));
28971 +       } while (s && (sock_net(s) != seq_file_net(seq) ||
28972 +               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28973         if (s)
28974                 return s;
28975  
28976 @@ -1962,7 +1968,8 @@ static void *netlink_seq_next(struct seq
28977  
28978                 for (; j <= hash->mask; j++) {
28979                         s = sk_head(&hash->table[j]);
28980 -                       while (s && sock_net(s) != seq_file_net(seq))
28981 +                       while (s && (sock_net(s) != seq_file_net(seq) ||
28982 +                               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28983                                 s = sk_next(s);
28984                         if (s) {
28985                                 iter->link = i;
28986 diff -NurpP --minimal linux-2.6.33.2/net/sctp/ipv6.c linux-2.6.33.2-vs2.3.0.36.30.4/net/sctp/ipv6.c
28987 --- linux-2.6.33.2/net/sctp/ipv6.c      2010-02-25 11:52:12.000000000 +0100
28988 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/sctp/ipv6.c      2010-02-25 12:02:16.000000000 +0100
28989 @@ -316,7 +316,8 @@ static void sctp_v6_get_saddr(struct sct
28990                                    dst ? ip6_dst_idev(dst)->dev : NULL,
28991                                    &daddr->v6.sin6_addr,
28992                                    inet6_sk(&sk->inet.sk)->srcprefs,
28993 -                                  &saddr->v6.sin6_addr);
28994 +                                  &saddr->v6.sin6_addr,
28995 +                                  asoc->base.sk->sk_nx_info);
28996                 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
28997                                   &saddr->v6.sin6_addr);
28998                 return;
28999 diff -NurpP --minimal linux-2.6.33.2/net/socket.c linux-2.6.33.2-vs2.3.0.36.30.4/net/socket.c
29000 --- linux-2.6.33.2/net/socket.c 2010-02-25 11:52:12.000000000 +0100
29001 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/socket.c 2010-02-25 13:51:25.000000000 +0100
29002 @@ -96,6 +96,10 @@
29003  
29004  #include <net/sock.h>
29005  #include <linux/netfilter.h>
29006 +#include <linux/vs_base.h>
29007 +#include <linux/vs_socket.h>
29008 +#include <linux/vs_inet.h>
29009 +#include <linux/vs_inet6.h>
29010  
29011  #include <linux/if_tun.h>
29012  #include <linux/ipv6_route.h>
29013 @@ -539,7 +543,7 @@ static inline int __sock_sendmsg(struct 
29014                                  struct msghdr *msg, size_t size)
29015  {
29016         struct sock_iocb *si = kiocb_to_siocb(iocb);
29017 -       int err;
29018 +       int err, len;
29019  
29020         si->sock = sock;
29021         si->scm = NULL;
29022 @@ -550,7 +554,22 @@ static inline int __sock_sendmsg(struct 
29023         if (err)
29024                 return err;
29025  
29026 -       return sock->ops->sendmsg(iocb, sock, msg, size);
29027 +       len = sock->ops->sendmsg(iocb, sock, msg, size);
29028 +       if (sock->sk) {
29029 +               if (len == size)
29030 +                       vx_sock_send(sock->sk, size);
29031 +               else
29032 +                       vx_sock_fail(sock->sk, size);
29033 +       }
29034 +       vxdprintk(VXD_CBIT(net, 7),
29035 +               "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29036 +               sock, sock->sk,
29037 +               (sock->sk)?sock->sk->sk_nx_info:0,
29038 +               (sock->sk)?sock->sk->sk_vx_info:0,
29039 +               (sock->sk)?sock->sk->sk_xid:0,
29040 +               (sock->sk)?sock->sk->sk_nid:0,
29041 +               (unsigned int)size, len);
29042 +       return len;
29043  }
29044  
29045  int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
29046 @@ -667,6 +686,7 @@ static inline int __sock_recvmsg_nosec(s
29047                                        struct msghdr *msg, size_t size, int flags)
29048  {
29049         struct sock_iocb *si = kiocb_to_siocb(iocb);
29050 +       int len;
29051  
29052         si->sock = sock;
29053         si->scm = NULL;
29054 @@ -674,7 +694,18 @@ static inline int __sock_recvmsg_nosec(s
29055         si->size = size;
29056         si->flags = flags;
29057  
29058 -       return sock->ops->recvmsg(iocb, sock, msg, size, flags);
29059 +       len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
29060 +       if ((len >= 0) && sock->sk)
29061 +               vx_sock_recv(sock->sk, len);
29062 +       vxdprintk(VXD_CBIT(net, 7),
29063 +               "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29064 +               sock, sock->sk,
29065 +               (sock->sk)?sock->sk->sk_nx_info:0,
29066 +               (sock->sk)?sock->sk->sk_vx_info:0,
29067 +               (sock->sk)?sock->sk->sk_xid:0,
29068 +               (sock->sk)?sock->sk->sk_nid:0,
29069 +               (unsigned int)size, len);
29070 +       return len;
29071  }
29072  
29073  static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
29074 @@ -1182,6 +1213,13 @@ static int __sock_create(struct net *net
29075         if (type < 0 || type >= SOCK_MAX)
29076                 return -EINVAL;
29077  
29078 +       if (!nx_check(0, VS_ADMIN)) {
29079 +               if (family == PF_INET && !current_nx_info_has_v4())
29080 +                       return -EAFNOSUPPORT;
29081 +               if (family == PF_INET6 && !current_nx_info_has_v6())
29082 +                       return -EAFNOSUPPORT;
29083 +       }
29084 +
29085         /* Compatibility.
29086  
29087            This uglymoron is moved from INET layer to here to avoid
29088 @@ -1314,6 +1352,7 @@ SYSCALL_DEFINE3(socket, int, family, int
29089         if (retval < 0)
29090                 goto out;
29091  
29092 +       set_bit(SOCK_USER_SOCKET, &sock->flags);
29093         retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
29094         if (retval < 0)
29095                 goto out_release;
29096 @@ -1355,10 +1394,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
29097         err = sock_create(family, type, protocol, &sock1);
29098         if (err < 0)
29099                 goto out;
29100 +       set_bit(SOCK_USER_SOCKET, &sock1->flags);
29101  
29102         err = sock_create(family, type, protocol, &sock2);
29103         if (err < 0)
29104                 goto out_release_1;
29105 +       set_bit(SOCK_USER_SOCKET, &sock2->flags);
29106  
29107         err = sock1->ops->socketpair(sock1, sock2);
29108         if (err < 0)
29109 diff -NurpP --minimal linux-2.6.33.2/net/sunrpc/auth.c linux-2.6.33.2-vs2.3.0.36.30.4/net/sunrpc/auth.c
29110 --- linux-2.6.33.2/net/sunrpc/auth.c    2010-02-25 11:52:12.000000000 +0100
29111 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/sunrpc/auth.c    2010-02-25 12:02:16.000000000 +0100
29112 @@ -14,6 +14,7 @@
29113  #include <linux/hash.h>
29114  #include <linux/sunrpc/clnt.h>
29115  #include <linux/spinlock.h>
29116 +#include <linux/vs_tag.h>
29117  
29118  #ifdef RPC_DEBUG
29119  # define RPCDBG_FACILITY       RPCDBG_AUTH
29120 @@ -363,6 +364,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
29121         memset(&acred, 0, sizeof(acred));
29122         acred.uid = cred->fsuid;
29123         acred.gid = cred->fsgid;
29124 +       acred.tag = dx_current_tag();
29125         acred.group_info = get_group_info(((struct cred *)cred)->group_info);
29126  
29127         ret = auth->au_ops->lookup_cred(auth, &acred, flags);
29128 @@ -403,6 +405,7 @@ rpcauth_bind_root_cred(struct rpc_task *
29129         struct auth_cred acred = {
29130                 .uid = 0,
29131                 .gid = 0,
29132 +               .tag = dx_current_tag(),
29133         };
29134         struct rpc_cred *ret;
29135  
29136 diff -NurpP --minimal linux-2.6.33.2/net/sunrpc/auth_unix.c linux-2.6.33.2-vs2.3.0.36.30.4/net/sunrpc/auth_unix.c
29137 --- linux-2.6.33.2/net/sunrpc/auth_unix.c       2008-12-25 00:26:37.000000000 +0100
29138 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/sunrpc/auth_unix.c       2010-02-25 12:02:16.000000000 +0100
29139 @@ -11,12 +11,14 @@
29140  #include <linux/module.h>
29141  #include <linux/sunrpc/clnt.h>
29142  #include <linux/sunrpc/auth.h>
29143 +#include <linux/vs_tag.h>
29144  
29145  #define NFS_NGROUPS    16
29146  
29147  struct unx_cred {
29148         struct rpc_cred         uc_base;
29149         gid_t                   uc_gid;
29150 +       tag_t                   uc_tag;
29151         gid_t                   uc_gids[NFS_NGROUPS];
29152  };
29153  #define uc_uid                 uc_base.cr_uid
29154 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
29155                 groups = NFS_NGROUPS;
29156  
29157         cred->uc_gid = acred->gid;
29158 +       cred->uc_tag = acred->tag;
29159         for (i = 0; i < groups; i++)
29160                 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
29161         if (i < NFS_NGROUPS)
29162 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
29163         unsigned int i;
29164  
29165  
29166 -       if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
29167 +       if (cred->uc_uid != acred->uid ||
29168 +               cred->uc_gid != acred->gid ||
29169 +               cred->uc_tag != acred->tag)
29170                 return 0;
29171  
29172         if (acred->group_info != NULL)
29173 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
29174         struct rpc_clnt *clnt = task->tk_client;
29175         struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
29176         __be32          *base, *hold;
29177 -       int             i;
29178 +       int             i, tag;
29179  
29180         *p++ = htonl(RPC_AUTH_UNIX);
29181         base = p++;
29182 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
29183          * Copy the UTS nodename captured when the client was created.
29184          */
29185         p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
29186 +       tag = task->tk_client->cl_tag;
29187  
29188 -       *p++ = htonl((u32) cred->uc_uid);
29189 -       *p++ = htonl((u32) cred->uc_gid);
29190 +       *p++ = htonl((u32) TAGINO_UID(tag,
29191 +               cred->uc_uid, cred->uc_tag));
29192 +       *p++ = htonl((u32) TAGINO_GID(tag,
29193 +               cred->uc_gid, cred->uc_tag));
29194         hold = p++;
29195         for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
29196                 *p++ = htonl((u32) cred->uc_gids[i]);
29197 diff -NurpP --minimal linux-2.6.33.2/net/sunrpc/clnt.c linux-2.6.33.2-vs2.3.0.36.30.4/net/sunrpc/clnt.c
29198 --- linux-2.6.33.2/net/sunrpc/clnt.c    2010-02-25 11:52:12.000000000 +0100
29199 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/sunrpc/clnt.c    2010-02-25 12:02:16.000000000 +0100
29200 @@ -33,6 +33,7 @@
29201  #include <linux/utsname.h>
29202  #include <linux/workqueue.h>
29203  #include <linux/in6.h>
29204 +#include <linux/vs_cvirt.h>
29205  
29206  #include <linux/sunrpc/clnt.h>
29207  #include <linux/sunrpc/rpc_pipe_fs.h>
29208 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
29209         if (!(args->flags & RPC_CLNT_CREATE_QUIET))
29210                 clnt->cl_chatty = 1;
29211  
29212 +       /* TODO: handle RPC_CLNT_CREATE_TAGGED
29213 +       if (args->flags & RPC_CLNT_CREATE_TAGGED)
29214 +               clnt->cl_tag = 1; */
29215         return clnt;
29216  }
29217  EXPORT_SYMBOL_GPL(rpc_create);
29218 diff -NurpP --minimal linux-2.6.33.2/net/unix/af_unix.c linux-2.6.33.2-vs2.3.0.36.30.4/net/unix/af_unix.c
29219 --- linux-2.6.33.2/net/unix/af_unix.c   2010-02-25 11:52:12.000000000 +0100
29220 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/unix/af_unix.c   2010-02-25 12:02:16.000000000 +0100
29221 @@ -114,6 +114,8 @@
29222  #include <linux/mount.h>
29223  #include <net/checksum.h>
29224  #include <linux/security.h>
29225 +#include <linux/vs_context.h>
29226 +#include <linux/vs_limit.h>
29227  
29228  static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
29229  static DEFINE_SPINLOCK(unix_table_lock);
29230 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
29231                 if (!net_eq(sock_net(s), net))
29232                         continue;
29233  
29234 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
29235 +                       continue;
29236                 if (u->addr->len == len &&
29237                     !memcmp(u->addr->name, sunname, len))
29238                         goto found;
29239 @@ -2115,6 +2119,8 @@ static struct sock *unix_seq_idx(struct 
29240         for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
29241                 if (sock_net(s) != seq_file_net(seq))
29242                         continue;
29243 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
29244 +                       continue;
29245                 if (off == pos)
29246                         return s;
29247                 ++off;
29248 @@ -2139,7 +2145,8 @@ static void *unix_seq_next(struct seq_fi
29249                 sk = first_unix_socket(&iter->i);
29250         else
29251                 sk = next_unix_socket(&iter->i, sk);
29252 -       while (sk && (sock_net(sk) != seq_file_net(seq)))
29253 +       while (sk && (sock_net(sk) != seq_file_net(seq) ||
29254 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
29255                 sk = next_unix_socket(&iter->i, sk);
29256         return sk;
29257  }
29258 diff -NurpP --minimal linux-2.6.33.2/net/x25/af_x25.c linux-2.6.33.2-vs2.3.0.36.30.4/net/x25/af_x25.c
29259 --- linux-2.6.33.2/net/x25/af_x25.c     2010-02-25 11:52:12.000000000 +0100
29260 +++ linux-2.6.33.2-vs2.3.0.36.30.4/net/x25/af_x25.c     2010-02-25 12:02:16.000000000 +0100
29261 @@ -526,7 +526,10 @@ static int x25_create(struct net *net, s
29262  
29263         x25 = x25_sk(sk);
29264  
29265 -       sock_init_data(sock, sk);
29266 +       sk->sk_socket = sock;
29267 +       sk->sk_type = sock->type;
29268 +       sk->sk_sleep = &sock->wait;
29269 +       sock->sk = sk;
29270  
29271         x25_init_timers(sk);
29272  
29273 diff -NurpP --minimal linux-2.6.33.2/scripts/checksyscalls.sh linux-2.6.33.2-vs2.3.0.36.30.4/scripts/checksyscalls.sh
29274 --- linux-2.6.33.2/scripts/checksyscalls.sh     2009-09-10 15:26:31.000000000 +0200
29275 +++ linux-2.6.33.2-vs2.3.0.36.30.4/scripts/checksyscalls.sh     2010-02-25 12:02:16.000000000 +0100
29276 @@ -194,7 +194,6 @@ cat << EOF
29277  #define __IGNORE_afs_syscall
29278  #define __IGNORE_getpmsg
29279  #define __IGNORE_putpmsg
29280 -#define __IGNORE_vserver
29281  EOF
29282  }
29283  
29284 diff -NurpP --minimal linux-2.6.33.2/security/commoncap.c linux-2.6.33.2-vs2.3.0.36.30.4/security/commoncap.c
29285 --- linux-2.6.33.2/security/commoncap.c 2010-02-25 11:52:12.000000000 +0100
29286 +++ linux-2.6.33.2-vs2.3.0.36.30.4/security/commoncap.c 2010-03-05 15:30:01.000000000 +0100
29287 @@ -27,6 +27,7 @@
29288  #include <linux/sched.h>
29289  #include <linux/prctl.h>
29290  #include <linux/securebits.h>
29291 +#include <linux/vs_context.h>
29292  
29293  /*
29294   * If a non-root user executes a setuid-root binary in
29295 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
29296  
29297  int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
29298  {
29299 -       NETLINK_CB(skb).eff_cap = current_cap();
29300 +       NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
29301         return 0;
29302  }
29303  
29304 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
29305                 return -EPERM;
29306         return 0;
29307  }
29308 +
29309  EXPORT_SYMBOL(cap_netlink_recv);
29310  
29311  /**
29312 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
29313  int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
29314                 int audit)
29315  {
29316 -       return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
29317 +       struct vx_info *vxi = tsk->vx_info;
29318 +
29319 +#if 0
29320 +       printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
29321 +               vx_info_flags(vxi, VXF_STATE_SETUP, 0),
29322 +               cap_raised(tsk->cap_effective, cap),
29323 +               tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
29324 +#endif
29325 +
29326 +       /* special case SETUP */
29327 +       if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
29328 +               /* FIXME: maybe use cred instead? */
29329 +               cap_raised(tsk->cred->cap_effective, cap))
29330 +               return 0;
29331 +
29332 +       return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
29333  }
29334  
29335  /**
29336 @@ -570,7 +587,7 @@ int cap_inode_setxattr(struct dentry *de
29337  
29338         if (!strncmp(name, XATTR_SECURITY_PREFIX,
29339                      sizeof(XATTR_SECURITY_PREFIX) - 1)  &&
29340 -           !capable(CAP_SYS_ADMIN))
29341 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
29342                 return -EPERM;
29343         return 0;
29344  }
29345 @@ -596,7 +613,7 @@ int cap_inode_removexattr(struct dentry 
29346  
29347         if (!strncmp(name, XATTR_SECURITY_PREFIX,
29348                      sizeof(XATTR_SECURITY_PREFIX) - 1)  &&
29349 -           !capable(CAP_SYS_ADMIN))
29350 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
29351                 return -EPERM;
29352         return 0;
29353  }
29354 @@ -894,7 +911,8 @@ error:
29355   */
29356  int cap_syslog(int type)
29357  {
29358 -       if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
29359 +       if ((type != 3 && type != 10) &&
29360 +               !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
29361                 return -EPERM;
29362         return 0;
29363  }
29364 @@ -946,3 +964,4 @@ int cap_file_mmap(struct file *file, uns
29365         }
29366         return ret;
29367  }
29368 +
29369 diff -NurpP --minimal linux-2.6.33.2/security/selinux/av_permissions.h linux-2.6.33.2-vs2.3.0.36.30.4/security/selinux/av_permissions.h
29370 --- linux-2.6.33.2/security/selinux/av_permissions.h    1970-01-01 01:00:00.000000000 +0100
29371 +++ linux-2.6.33.2-vs2.3.0.36.30.4/security/selinux/av_permissions.h    2010-02-27 15:49:05.000000000 +0100
29372 @@ -0,0 +1,827 @@
29373 +/* This file is automatically generated.  Do not edit. */
29374 +#ifndef _SELINUX_AV_PERMISSIONS_H_
29375 +#define _SELINUX_AV_PERMISSIONS_H_
29376 +
29377 +#define SECURITY__COMPUTE_AV                      0x00000001UL
29378 +#define SECURITY__COMPUTE_CREATE                  0x00000002UL
29379 +#define SECURITY__COMPUTE_MEMBER                  0x00000004UL
29380 +#define SECURITY__CHECK_CONTEXT                   0x00000008UL
29381 +#define SECURITY__LOAD_POLICY                     0x00000010UL
29382 +#define SECURITY__COMPUTE_RELABEL                 0x00000020UL
29383 +#define SECURITY__COMPUTE_USER                    0x00000040UL
29384 +#define SECURITY__SETENFORCE                      0x00000080UL
29385 +#define SECURITY__SETBOOL                         0x00000100UL
29386 +#define SECURITY__SETSECPARAM                     0x00000200UL
29387 +#define SECURITY__SETCHECKREQPROT                 0x00000400UL
29388 +#define PROCESS__FORK                             0x00000001UL
29389 +#define PROCESS__TRANSITION                       0x00000002UL
29390 +#define PROCESS__SIGCHLD                          0x00000004UL
29391 +#define PROCESS__SIGKILL                          0x00000008UL
29392 +#define PROCESS__SIGSTOP                          0x00000010UL
29393 +#define PROCESS__SIGNULL                          0x00000020UL
29394 +#define PROCESS__SIGNAL                           0x00000040UL
29395 +#define PROCESS__PTRACE                           0x00000080UL
29396 +#define PROCESS__GETSCHED                         0x00000100UL
29397 +#define PROCESS__SETSCHED                         0x00000200UL
29398 +#define PROCESS__GETSESSION                       0x00000400UL
29399 +#define PROCESS__GETPGID                          0x00000800UL
29400 +#define PROCESS__SETPGID                          0x00001000UL
29401 +#define PROCESS__GETCAP                           0x00002000UL
29402 +#define PROCESS__SETCAP                           0x00004000UL
29403 +#define PROCESS__SHARE                            0x00008000UL
29404 +#define PROCESS__GETATTR                          0x00010000UL
29405 +#define PROCESS__SETEXEC                          0x00020000UL
29406 +#define PROCESS__SETFSCREATE                      0x00040000UL
29407 +#define PROCESS__NOATSECURE                       0x00080000UL
29408 +#define PROCESS__SIGINH                           0x00100000UL
29409 +#define PROCESS__SETRLIMIT                        0x00200000UL
29410 +#define PROCESS__RLIMITINH                        0x00400000UL
29411 +#define PROCESS__DYNTRANSITION                    0x00800000UL
29412 +#define PROCESS__SETCURRENT                       0x01000000UL
29413 +#define PROCESS__EXECMEM                          0x02000000UL
29414 +#define PROCESS__EXECSTACK                        0x04000000UL
29415 +#define PROCESS__EXECHEAP                         0x08000000UL
29416 +#define PROCESS__SETKEYCREATE                     0x10000000UL
29417 +#define PROCESS__SETSOCKCREATE                    0x20000000UL
29418 +#define SYSTEM__IPC_INFO                          0x00000001UL
29419 +#define SYSTEM__SYSLOG_READ                       0x00000002UL
29420 +#define SYSTEM__SYSLOG_MOD                        0x00000004UL
29421 +#define SYSTEM__SYSLOG_CONSOLE                    0x00000008UL
29422 +#define SYSTEM__MODULE_REQUEST                    0x00000010UL
29423 +#define CAPABILITY__CHOWN                         0x00000001UL
29424 +#define CAPABILITY__DAC_OVERRIDE                  0x00000002UL
29425 +#define CAPABILITY__DAC_READ_SEARCH               0x00000004UL
29426 +#define CAPABILITY__FOWNER                        0x00000008UL
29427 +#define CAPABILITY__FSETID                        0x00000010UL
29428 +#define CAPABILITY__KILL                          0x00000020UL
29429 +#define CAPABILITY__SETGID                        0x00000040UL
29430 +#define CAPABILITY__SETUID                        0x00000080UL
29431 +#define CAPABILITY__SETPCAP                       0x00000100UL
29432 +#define CAPABILITY__LINUX_IMMUTABLE               0x00000200UL
29433 +#define CAPABILITY__NET_BIND_SERVICE              0x00000400UL
29434 +#define CAPABILITY__NET_BROADCAST                 0x00000800UL
29435 +#define CAPABILITY__NET_ADMIN                     0x00001000UL
29436 +#define CAPABILITY__NET_RAW                       0x00002000UL
29437 +#define CAPABILITY__IPC_LOCK                      0x00004000UL
29438 +#define CAPABILITY__IPC_OWNER                     0x00008000UL
29439 +#define CAPABILITY__SYS_MODULE                    0x00010000UL
29440 +#define CAPABILITY__SYS_RAWIO                     0x00020000UL
29441 +#define CAPABILITY__SYS_CHROOT                    0x00040000UL
29442 +#define CAPABILITY__SYS_PTRACE                    0x00080000UL
29443 +#define CAPABILITY__SYS_PACCT                     0x00100000UL
29444 +#define CAPABILITY__SYS_ADMIN                     0x00200000UL
29445 +#define CAPABILITY__SYS_BOOT                      0x00400000UL
29446 +#define CAPABILITY__SYS_NICE                      0x00800000UL
29447 +#define CAPABILITY__SYS_RESOURCE                  0x01000000UL
29448 +#define CAPABILITY__SYS_TIME                      0x02000000UL
29449 +#define CAPABILITY__SYS_TTY_CONFIG                0x04000000UL
29450 +#define CAPABILITY__MKNOD                         0x08000000UL
29451 +#define CAPABILITY__LEASE                         0x10000000UL
29452 +#define CAPABILITY__AUDIT_WRITE                   0x20000000UL
29453 +#define CAPABILITY__AUDIT_CONTROL                 0x40000000UL
29454 +#define CAPABILITY__SETFCAP                       0x80000000UL
29455 +#define FILESYSTEM__MOUNT                         0x00000001UL
29456 +#define FILESYSTEM__REMOUNT                       0x00000002UL
29457 +#define FILESYSTEM__UNMOUNT                       0x00000004UL
29458 +#define FILESYSTEM__GETATTR                       0x00000008UL
29459 +#define FILESYSTEM__RELABELFROM                   0x00000010UL
29460 +#define FILESYSTEM__RELABELTO                     0x00000020UL
29461 +#define FILESYSTEM__TRANSITION                    0x00000040UL
29462 +#define FILESYSTEM__ASSOCIATE                     0x00000080UL
29463 +#define FILESYSTEM__QUOTAMOD                      0x00000100UL
29464 +#define FILESYSTEM__QUOTAGET                      0x00000200UL
29465 +#define FILE__IOCTL                               0x00000001UL
29466 +#define FILE__READ                                0x00000002UL
29467 +#define FILE__WRITE                               0x00000004UL
29468 +#define FILE__CREATE                              0x00000008UL
29469 +#define FILE__GETATTR                             0x00000010UL
29470 +#define FILE__SETATTR                             0x00000020UL
29471 +#define FILE__LOCK                                0x00000040UL
29472 +#define FILE__RELABELFROM                         0x00000080UL
29473 +#define FILE__RELABELTO                           0x00000100UL
29474 +#define FILE__APPEND                              0x00000200UL
29475 +#define FILE__UNLINK                              0x00000400UL
29476 +#define FILE__LINK                                0x00000800UL
29477 +#define FILE__RENAME                              0x00001000UL
29478 +#define FILE__EXECUTE                             0x00002000UL
29479 +#define FILE__SWAPON                              0x00004000UL
29480 +#define FILE__QUOTAON                             0x00008000UL
29481 +#define FILE__MOUNTON                             0x00010000UL
29482 +#define FILE__EXECUTE_NO_TRANS                    0x00020000UL
29483 +#define FILE__ENTRYPOINT                          0x00040000UL
29484 +#define FILE__EXECMOD                             0x00080000UL
29485 +#define FILE__OPEN                                0x00100000UL
29486 +#define DIR__IOCTL                                0x00000001UL
29487 +#define DIR__READ                                 0x00000002UL
29488 +#define DIR__WRITE                                0x00000004UL
29489 +#define DIR__CREATE                               0x00000008UL
29490 +#define DIR__GETATTR                              0x00000010UL
29491 +#define DIR__SETATTR                              0x00000020UL
29492 +#define DIR__LOCK                                 0x00000040UL
29493 +#define DIR__RELABELFROM                          0x00000080UL
29494 +#define DIR__RELABELTO                            0x00000100UL
29495 +#define DIR__APPEND                               0x00000200UL
29496 +#define DIR__UNLINK                               0x00000400UL
29497 +#define DIR__LINK                                 0x00000800UL
29498 +#define DIR__RENAME                               0x00001000UL
29499 +#define DIR__EXECUTE                              0x00002000UL
29500 +#define DIR__SWAPON                               0x00004000UL
29501 +#define DIR__QUOTAON                              0x00008000UL
29502 +#define DIR__MOUNTON                              0x00010000UL
29503 +#define DIR__ADD_NAME                             0x00020000UL
29504 +#define DIR__REMOVE_NAME                          0x00040000UL
29505 +#define DIR__REPARENT                             0x00080000UL
29506 +#define DIR__SEARCH                               0x00100000UL
29507 +#define DIR__RMDIR                                0x00200000UL
29508 +#define DIR__OPEN                                 0x00400000UL
29509 +#define FD__USE                                   0x00000001UL
29510 +#define LNK_FILE__IOCTL                           0x00000001UL
29511 +#define LNK_FILE__READ                            0x00000002UL
29512 +#define LNK_FILE__WRITE                           0x00000004UL
29513 +#define LNK_FILE__CREATE                          0x00000008UL
29514 +#define LNK_FILE__GETATTR                         0x00000010UL
29515 +#define LNK_FILE__SETATTR                         0x00000020UL
29516 +#define LNK_FILE__LOCK                            0x00000040UL
29517 +#define LNK_FILE__RELABELFROM                     0x00000080UL
29518 +#define LNK_FILE__RELABELTO                       0x00000100UL
29519 +#define LNK_FILE__APPEND                          0x00000200UL
29520 +#define LNK_FILE__UNLINK                          0x00000400UL
29521 +#define LNK_FILE__LINK                            0x00000800UL
29522 +#define LNK_FILE__RENAME                          0x00001000UL
29523 +#define LNK_FILE__EXECUTE                         0x00002000UL
29524 +#define LNK_FILE__SWAPON                          0x00004000UL
29525 +#define LNK_FILE__QUOTAON                         0x00008000UL
29526 +#define LNK_FILE__MOUNTON                         0x00010000UL
29527 +#define CHR_FILE__IOCTL                           0x00000001UL
29528 +#define CHR_FILE__READ                            0x00000002UL
29529 +#define CHR_FILE__WRITE                           0x00000004UL
29530 +#define CHR_FILE__CREATE                          0x00000008UL
29531 +#define CHR_FILE__GETATTR                         0x00000010UL
29532 +#define CHR_FILE__SETATTR                         0x00000020UL
29533 +#define CHR_FILE__LOCK                            0x00000040UL
29534 +#define CHR_FILE__RELABELFROM                     0x00000080UL
29535 +#define CHR_FILE__RELABELTO                       0x00000100UL
29536 +#define CHR_FILE__APPEND                          0x00000200UL
29537 +#define CHR_FILE__UNLINK                          0x00000400UL
29538 +#define CHR_FILE__LINK                            0x00000800UL
29539 +#define CHR_FILE__RENAME                          0x00001000UL
29540 +#define CHR_FILE__EXECUTE                         0x00002000UL
29541 +#define CHR_FILE__SWAPON                          0x00004000UL
29542 +#define CHR_FILE__QUOTAON                         0x00008000UL
29543 +#define CHR_FILE__MOUNTON                         0x00010000UL
29544 +#define CHR_FILE__EXECUTE_NO_TRANS                0x00020000UL
29545 +#define CHR_FILE__ENTRYPOINT                      0x00040000UL
29546 +#define CHR_FILE__EXECMOD                         0x00080000UL
29547 +#define CHR_FILE__OPEN                            0x00100000UL
29548 +#define BLK_FILE__IOCTL                           0x00000001UL
29549 +#define BLK_FILE__READ                            0x00000002UL
29550 +#define BLK_FILE__WRITE                           0x00000004UL
29551 +#define BLK_FILE__CREATE                          0x00000008UL
29552 +#define BLK_FILE__GETATTR                         0x00000010UL
29553 +#define BLK_FILE__SETATTR                         0x00000020UL
29554 +#define BLK_FILE__LOCK                            0x00000040UL
29555 +#define BLK_FILE__RELABELFROM                     0x00000080UL
29556 +#define BLK_FILE__RELABELTO                       0x00000100UL
29557 +#define BLK_FILE__APPEND                          0x00000200UL
29558 +#define BLK_FILE__UNLINK                          0x00000400UL
29559 +#define BLK_FILE__LINK                            0x00000800UL
29560 +#define BLK_FILE__RENAME                          0x00001000UL
29561 +#define BLK_FILE__EXECUTE                         0x00002000UL
29562 +#define BLK_FILE__SWAPON                          0x00004000UL
29563 +#define BLK_FILE__QUOTAON                         0x00008000UL
29564 +#define BLK_FILE__MOUNTON                         0x00010000UL
29565 +#define BLK_FILE__OPEN                            0x00020000UL
29566 +#define SOCK_FILE__IOCTL                          0x00000001UL
29567 +#define SOCK_FILE__READ                           0x00000002UL
29568 +#define SOCK_FILE__WRITE                          0x00000004UL
29569 +#define SOCK_FILE__CREATE                         0x00000008UL
29570 +#define SOCK_FILE__GETATTR                        0x00000010UL
29571 +#define SOCK_FILE__SETATTR                        0x00000020UL
29572 +#define SOCK_FILE__LOCK                           0x00000040UL
29573 +#define SOCK_FILE__RELABELFROM                    0x00000080UL
29574 +#define SOCK_FILE__RELABELTO                      0x00000100UL
29575 +#define SOCK_FILE__APPEND                         0x00000200UL
29576 +#define SOCK_FILE__UNLINK                         0x00000400UL
29577 +#define SOCK_FILE__LINK                           0x00000800UL
29578 +#define SOCK_FILE__RENAME                         0x00001000UL
29579 +#define SOCK_FILE__EXECUTE                        0x00002000UL
29580 +#define SOCK_FILE__SWAPON                         0x00004000UL
29581 +#define SOCK_FILE__QUOTAON                        0x00008000UL
29582 +#define SOCK_FILE__MOUNTON                        0x00010000UL
29583 +#define SOCK_FILE__OPEN                           0x00020000UL
29584 +#define FIFO_FILE__IOCTL                          0x00000001UL
29585 +#define FIFO_FILE__READ                           0x00000002UL
29586 +#define FIFO_FILE__WRITE                          0x00000004UL
29587 +#define FIFO_FILE__CREATE                         0x00000008UL
29588 +#define FIFO_FILE__GETATTR                        0x00000010UL
29589 +#define FIFO_FILE__SETATTR                        0x00000020UL
29590 +#define FIFO_FILE__LOCK                           0x00000040UL
29591 +#define FIFO_FILE__RELABELFROM                    0x00000080UL
29592 +#define FIFO_FILE__RELABELTO                      0x00000100UL
29593 +#define FIFO_FILE__APPEND                         0x00000200UL
29594 +#define FIFO_FILE__UNLINK                         0x00000400UL
29595 +#define FIFO_FILE__LINK                           0x00000800UL
29596 +#define FIFO_FILE__RENAME                         0x00001000UL
29597 +#define FIFO_FILE__EXECUTE                        0x00002000UL
29598 +#define FIFO_FILE__SWAPON                         0x00004000UL
29599 +#define FIFO_FILE__QUOTAON                        0x00008000UL
29600 +#define FIFO_FILE__MOUNTON                        0x00010000UL
29601 +#define FIFO_FILE__OPEN                           0x00020000UL
29602 +#define SOCKET__IOCTL                             0x00000001UL
29603 +#define SOCKET__READ                              0x00000002UL
29604 +#define SOCKET__WRITE                             0x00000004UL
29605 +#define SOCKET__CREATE                            0x00000008UL
29606 +#define SOCKET__GETATTR                           0x00000010UL
29607 +#define SOCKET__SETATTR                           0x00000020UL
29608 +#define SOCKET__LOCK                              0x00000040UL
29609 +#define SOCKET__RELABELFROM                       0x00000080UL
29610 +#define SOCKET__RELABELTO                         0x00000100UL
29611 +#define SOCKET__APPEND                            0x00000200UL
29612 +#define SOCKET__BIND                              0x00000400UL
29613 +#define SOCKET__CONNECT                           0x00000800UL
29614 +#define SOCKET__LISTEN                            0x00001000UL
29615 +#define SOCKET__ACCEPT                            0x00002000UL
29616 +#define SOCKET__GETOPT                            0x00004000UL
29617 +#define SOCKET__SETOPT                            0x00008000UL
29618 +#define SOCKET__SHUTDOWN                          0x00010000UL
29619 +#define SOCKET__RECVFROM                          0x00020000UL
29620 +#define SOCKET__SENDTO                            0x00040000UL
29621 +#define SOCKET__RECV_MSG                          0x00080000UL
29622 +#define SOCKET__SEND_MSG                          0x00100000UL
29623 +#define SOCKET__NAME_BIND                         0x00200000UL
29624 +#define TCP_SOCKET__IOCTL                         0x00000001UL
29625 +#define TCP_SOCKET__READ                          0x00000002UL
29626 +#define TCP_SOCKET__WRITE                         0x00000004UL
29627 +#define TCP_SOCKET__CREATE                        0x00000008UL
29628 +#define TCP_SOCKET__GETATTR                       0x00000010UL
29629 +#define TCP_SOCKET__SETATTR                       0x00000020UL
29630 +#define TCP_SOCKET__LOCK                          0x00000040UL
29631 +#define TCP_SOCKET__RELABELFROM                   0x00000080UL
29632 +#define TCP_SOCKET__RELABELTO                     0x00000100UL
29633 +#define TCP_SOCKET__APPEND                        0x00000200UL
29634 +#define TCP_SOCKET__BIND                          0x00000400UL
29635 +#define TCP_SOCKET__CONNECT                       0x00000800UL
29636 +#define TCP_SOCKET__LISTEN                        0x00001000UL
29637 +#define TCP_SOCKET__ACCEPT                        0x00002000UL
29638 +#define TCP_SOCKET__GETOPT                        0x00004000UL
29639 +#define TCP_SOCKET__SETOPT                        0x00008000UL
29640 +#define TCP_SOCKET__SHUTDOWN                      0x00010000UL
29641 +#define TCP_SOCKET__RECVFROM                      0x00020000UL
29642 +#define TCP_SOCKET__SENDTO                        0x00040000UL
29643 +#define TCP_SOCKET__RECV_MSG                      0x00080000UL
29644 +#define TCP_SOCKET__SEND_MSG                      0x00100000UL
29645 +#define TCP_SOCKET__NAME_BIND                     0x00200000UL
29646 +#define TCP_SOCKET__CONNECTTO                     0x00400000UL
29647 +#define TCP_SOCKET__NEWCONN                       0x00800000UL
29648 +#define TCP_SOCKET__ACCEPTFROM                    0x01000000UL
29649 +#define TCP_SOCKET__NODE_BIND                     0x02000000UL
29650 +#define TCP_SOCKET__NAME_CONNECT                  0x04000000UL
29651 +#define UDP_SOCKET__IOCTL                         0x00000001UL
29652 +#define UDP_SOCKET__READ                          0x00000002UL
29653 +#define UDP_SOCKET__WRITE                         0x00000004UL
29654 +#define UDP_SOCKET__CREATE                        0x00000008UL
29655 +#define UDP_SOCKET__GETATTR                       0x00000010UL
29656 +#define UDP_SOCKET__SETATTR                       0x00000020UL
29657 +#define UDP_SOCKET__LOCK                          0x00000040UL
29658 +#define UDP_SOCKET__RELABELFROM                   0x00000080UL
29659 +#define UDP_SOCKET__RELABELTO                     0x00000100UL
29660 +#define UDP_SOCKET__APPEND                        0x00000200UL
29661 +#define UDP_SOCKET__BIND                          0x00000400UL
29662 +#define UDP_SOCKET__CONNECT                       0x00000800UL
29663 +#define UDP_SOCKET__LISTEN                        0x00001000UL
29664 +#define UDP_SOCKET__ACCEPT                        0x00002000UL
29665 +#define UDP_SOCKET__GETOPT                        0x00004000UL
29666 +#define UDP_SOCKET__SETOPT                        0x00008000UL
29667 +#define UDP_SOCKET__SHUTDOWN                      0x00010000UL
29668 +#define UDP_SOCKET__RECVFROM                      0x00020000UL
29669 +#define UDP_SOCKET__SENDTO                        0x00040000UL
29670 +#define UDP_SOCKET__RECV_MSG                      0x00080000UL
29671 +#define UDP_SOCKET__SEND_MSG                      0x00100000UL
29672 +#define UDP_SOCKET__NAME_BIND                     0x00200000UL
29673 +#define UDP_SOCKET__NODE_BIND                     0x00400000UL
29674 +#define RAWIP_SOCKET__IOCTL                       0x00000001UL
29675 +#define RAWIP_SOCKET__READ                        0x00000002UL
29676 +#define RAWIP_SOCKET__WRITE                       0x00000004UL
29677 +#define RAWIP_SOCKET__CREATE                      0x00000008UL
29678 +#define RAWIP_SOCKET__GETATTR                     0x00000010UL
29679 +#define RAWIP_SOCKET__SETATTR                     0x00000020UL
29680 +#define RAWIP_SOCKET__LOCK                        0x00000040UL
29681 +#define RAWIP_SOCKET__RELABELFROM                 0x00000080UL
29682 +#define RAWIP_SOCKET__RELABELTO                   0x00000100UL
29683 +#define RAWIP_SOCKET__APPEND                      0x00000200UL
29684 +#define RAWIP_SOCKET__BIND                        0x00000400UL
29685 +#define RAWIP_SOCKET__CONNECT                     0x00000800UL
29686 +#define RAWIP_SOCKET__LISTEN                      0x00001000UL
29687 +#define RAWIP_SOCKET__ACCEPT                      0x00002000UL
29688 +#define RAWIP_SOCKET__GETOPT                      0x00004000UL
29689 +#define RAWIP_SOCKET__SETOPT                      0x00008000UL
29690 +#define RAWIP_SOCKET__SHUTDOWN                    0x00010000UL
29691 +#define RAWIP_SOCKET__RECVFROM                    0x00020000UL
29692 +#define RAWIP_SOCKET__SENDTO                      0x00040000UL
29693 +#define RAWIP_SOCKET__RECV_MSG                    0x00080000UL
29694 +#define RAWIP_SOCKET__SEND_MSG                    0x00100000UL
29695 +#define RAWIP_SOCKET__NAME_BIND                   0x00200000UL
29696 +#define RAWIP_SOCKET__NODE_BIND                   0x00400000UL
29697 +#define NODE__TCP_RECV                            0x00000001UL
29698 +#define NODE__TCP_SEND                            0x00000002UL
29699 +#define NODE__UDP_RECV                            0x00000004UL
29700 +#define NODE__UDP_SEND                            0x00000008UL
29701 +#define NODE__RAWIP_RECV                          0x00000010UL
29702 +#define NODE__RAWIP_SEND                          0x00000020UL
29703 +#define NODE__ENFORCE_DEST                        0x00000040UL
29704 +#define NODE__DCCP_RECV                           0x00000080UL
29705 +#define NODE__DCCP_SEND                           0x00000100UL
29706 +#define NODE__RECVFROM                            0x00000200UL
29707 +#define NODE__SENDTO                              0x00000400UL
29708 +#define NETIF__TCP_RECV                           0x00000001UL
29709 +#define NETIF__TCP_SEND                           0x00000002UL
29710 +#define NETIF__UDP_RECV                           0x00000004UL
29711 +#define NETIF__UDP_SEND                           0x00000008UL
29712 +#define NETIF__RAWIP_RECV                         0x00000010UL
29713 +#define NETIF__RAWIP_SEND                         0x00000020UL
29714 +#define NETIF__DCCP_RECV                          0x00000040UL
29715 +#define NETIF__DCCP_SEND                          0x00000080UL
29716 +#define NETIF__INGRESS                            0x00000100UL
29717 +#define NETIF__EGRESS                             0x00000200UL
29718 +#define NETLINK_SOCKET__IOCTL                     0x00000001UL
29719 +#define NETLINK_SOCKET__READ                      0x00000002UL
29720 +#define NETLINK_SOCKET__WRITE                     0x00000004UL
29721 +#define NETLINK_SOCKET__CREATE                    0x00000008UL
29722 +#define NETLINK_SOCKET__GETATTR                   0x00000010UL
29723 +#define NETLINK_SOCKET__SETATTR                   0x00000020UL
29724 +#define NETLINK_SOCKET__LOCK                      0x00000040UL
29725 +#define NETLINK_SOCKET__RELABELFROM               0x00000080UL
29726 +#define NETLINK_SOCKET__RELABELTO                 0x00000100UL
29727 +#define NETLINK_SOCKET__APPEND                    0x00000200UL
29728 +#define NETLINK_SOCKET__BIND                      0x00000400UL
29729 +#define NETLINK_SOCKET__CONNECT                   0x00000800UL
29730 +#define NETLINK_SOCKET__LISTEN                    0x00001000UL
29731 +#define NETLINK_SOCKET__ACCEPT                    0x00002000UL
29732 +#define NETLINK_SOCKET__GETOPT                    0x00004000UL
29733 +#define NETLINK_SOCKET__SETOPT                    0x00008000UL
29734 +#define NETLINK_SOCKET__SHUTDOWN                  0x00010000UL
29735 +#define NETLINK_SOCKET__RECVFROM                  0x00020000UL
29736 +#define NETLINK_SOCKET__SENDTO                    0x00040000UL
29737 +#define NETLINK_SOCKET__RECV_MSG                  0x00080000UL
29738 +#define NETLINK_SOCKET__SEND_MSG                  0x00100000UL
29739 +#define NETLINK_SOCKET__NAME_BIND                 0x00200000UL
29740 +#define PACKET_SOCKET__IOCTL                      0x00000001UL
29741 +#define PACKET_SOCKET__READ                       0x00000002UL
29742 +#define PACKET_SOCKET__WRITE                      0x00000004UL
29743 +#define PACKET_SOCKET__CREATE                     0x00000008UL
29744 +#define PACKET_SOCKET__GETATTR                    0x00000010UL
29745 +#define PACKET_SOCKET__SETATTR                    0x00000020UL
29746 +#define PACKET_SOCKET__LOCK                       0x00000040UL
29747 +#define PACKET_SOCKET__RELABELFROM                0x00000080UL
29748 +#define PACKET_SOCKET__RELABELTO                  0x00000100UL
29749 +#define PACKET_SOCKET__APPEND                     0x00000200UL
29750 +#define PACKET_SOCKET__BIND                       0x00000400UL
29751 +#define PACKET_SOCKET__CONNECT                    0x00000800UL
29752 +#define PACKET_SOCKET__LISTEN                     0x00001000UL
29753 +#define PACKET_SOCKET__ACCEPT                     0x00002000UL
29754 +#define PACKET_SOCKET__GETOPT                     0x00004000UL
29755 +#define PACKET_SOCKET__SETOPT                     0x00008000UL
29756 +#define PACKET_SOCKET__SHUTDOWN                   0x00010000UL
29757 +#define PACKET_SOCKET__RECVFROM                   0x00020000UL
29758 +#define PACKET_SOCKET__SENDTO                     0x00040000UL
29759 +#define PACKET_SOCKET__RECV_MSG                   0x00080000UL
29760 +#define PACKET_SOCKET__SEND_MSG                   0x00100000UL
29761 +#define PACKET_SOCKET__NAME_BIND                  0x00200000UL
29762 +#define KEY_SOCKET__IOCTL                         0x00000001UL
29763 +#define KEY_SOCKET__READ                          0x00000002UL
29764 +#define KEY_SOCKET__WRITE                         0x00000004UL
29765 +#define KEY_SOCKET__CREATE                        0x00000008UL
29766 +#define KEY_SOCKET__GETATTR                       0x00000010UL
29767 +#define KEY_SOCKET__SETATTR                       0x00000020UL
29768 +#define KEY_SOCKET__LOCK                          0x00000040UL
29769 +#define KEY_SOCKET__RELABELFROM                   0x00000080UL
29770 +#define KEY_SOCKET__RELABELTO                     0x00000100UL
29771 +#define KEY_SOCKET__APPEND                        0x00000200UL
29772 +#define KEY_SOCKET__BIND                          0x00000400UL
29773 +#define KEY_SOCKET__CONNECT                       0x00000800UL
29774 +#define KEY_SOCKET__LISTEN                        0x00001000UL
29775 +#define KEY_SOCKET__ACCEPT                        0x00002000UL
29776 +#define KEY_SOCKET__GETOPT                        0x00004000UL
29777 +#define KEY_SOCKET__SETOPT                        0x00008000UL
29778 +#define KEY_SOCKET__SHUTDOWN                      0x00010000UL
29779 +#define KEY_SOCKET__RECVFROM                      0x00020000UL
29780 +#define KEY_SOCKET__SENDTO                        0x00040000UL
29781 +#define KEY_SOCKET__RECV_MSG                      0x00080000UL
29782 +#define KEY_SOCKET__SEND_MSG                      0x00100000UL
29783 +#define KEY_SOCKET__NAME_BIND                     0x00200000UL
29784 +#define UNIX_STREAM_SOCKET__IOCTL                 0x00000001UL
29785 +#define UNIX_STREAM_SOCKET__READ                  0x00000002UL
29786 +#define UNIX_STREAM_SOCKET__WRITE                 0x00000004UL
29787 +#define UNIX_STREAM_SOCKET__CREATE                0x00000008UL
29788 +#define UNIX_STREAM_SOCKET__GETATTR               0x00000010UL
29789 +#define UNIX_STREAM_SOCKET__SETATTR               0x00000020UL
29790 +#define UNIX_STREAM_SOCKET__LOCK                  0x00000040UL
29791 +#define UNIX_STREAM_SOCKET__RELABELFROM           0x00000080UL
29792 +#define UNIX_STREAM_SOCKET__RELABELTO             0x00000100UL
29793 +#define UNIX_STREAM_SOCKET__APPEND                0x00000200UL
29794 +#define UNIX_STREAM_SOCKET__BIND                  0x00000400UL
29795 +#define UNIX_STREAM_SOCKET__CONNECT               0x00000800UL
29796 +#define UNIX_STREAM_SOCKET__LISTEN                0x00001000UL
29797 +#define UNIX_STREAM_SOCKET__ACCEPT                0x00002000UL
29798 +#define UNIX_STREAM_SOCKET__GETOPT                0x00004000UL
29799 +#define UNIX_STREAM_SOCKET__SETOPT                0x00008000UL
29800 +#define UNIX_STREAM_SOCKET__SHUTDOWN              0x00010000UL
29801 +#define UNIX_STREAM_SOCKET__RECVFROM              0x00020000UL
29802 +#define UNIX_STREAM_SOCKET__SENDTO                0x00040000UL
29803 +#define UNIX_STREAM_SOCKET__RECV_MSG              0x00080000UL
29804 +#define UNIX_STREAM_SOCKET__SEND_MSG              0x00100000UL
29805 +#define UNIX_STREAM_SOCKET__NAME_BIND             0x00200000UL
29806 +#define UNIX_STREAM_SOCKET__CONNECTTO             0x00400000UL
29807 +#define UNIX_STREAM_SOCKET__NEWCONN               0x00800000UL
29808 +#define UNIX_STREAM_SOCKET__ACCEPTFROM            0x01000000UL
29809 +#define UNIX_DGRAM_SOCKET__IOCTL                  0x00000001UL
29810 +#define UNIX_DGRAM_SOCKET__READ                   0x00000002UL
29811 +#define UNIX_DGRAM_SOCKET__WRITE                  0x00000004UL
29812 +#define UNIX_DGRAM_SOCKET__CREATE                 0x00000008UL
29813 +#define UNIX_DGRAM_SOCKET__GETATTR                0x00000010UL
29814 +#define UNIX_DGRAM_SOCKET__SETATTR                0x00000020UL
29815 +#define UNIX_DGRAM_SOCKET__LOCK                   0x00000040UL
29816 +#define UNIX_DGRAM_SOCKET__RELABELFROM            0x00000080UL
29817 +#define UNIX_DGRAM_SOCKET__RELABELTO              0x00000100UL
29818 +#define UNIX_DGRAM_SOCKET__APPEND                 0x00000200UL
29819 +#define UNIX_DGRAM_SOCKET__BIND                   0x00000400UL
29820 +#define UNIX_DGRAM_SOCKET__CONNECT                0x00000800UL
29821 +#define UNIX_DGRAM_SOCKET__LISTEN                 0x00001000UL
29822 +#define UNIX_DGRAM_SOCKET__ACCEPT                 0x00002000UL
29823 +#define UNIX_DGRAM_SOCKET__GETOPT                 0x00004000UL
29824 +#define UNIX_DGRAM_SOCKET__SETOPT                 0x00008000UL
29825 +#define UNIX_DGRAM_SOCKET__SHUTDOWN               0x00010000UL
29826 +#define UNIX_DGRAM_SOCKET__RECVFROM               0x00020000UL
29827 +#define UNIX_DGRAM_SOCKET__SENDTO                 0x00040000UL
29828 +#define UNIX_DGRAM_SOCKET__RECV_MSG               0x00080000UL
29829 +#define UNIX_DGRAM_SOCKET__SEND_MSG               0x00100000UL
29830 +#define UNIX_DGRAM_SOCKET__NAME_BIND              0x00200000UL
29831 +#define SEM__CREATE                               0x00000001UL
29832 +#define SEM__DESTROY                              0x00000002UL
29833 +#define SEM__GETATTR                              0x00000004UL
29834 +#define SEM__SETATTR                              0x00000008UL
29835 +#define SEM__READ                                 0x00000010UL
29836 +#define SEM__WRITE                                0x00000020UL
29837 +#define SEM__ASSOCIATE                            0x00000040UL
29838 +#define SEM__UNIX_READ                            0x00000080UL
29839 +#define SEM__UNIX_WRITE                           0x00000100UL
29840 +#define MSG__SEND                                 0x00000001UL
29841 +#define MSG__RECEIVE                              0x00000002UL
29842 +#define MSGQ__CREATE                              0x00000001UL
29843 +#define MSGQ__DESTROY                             0x00000002UL
29844 +#define MSGQ__GETATTR                             0x00000004UL
29845 +#define MSGQ__SETATTR                             0x00000008UL
29846 +#define MSGQ__READ                                0x00000010UL
29847 +#define MSGQ__WRITE                               0x00000020UL
29848 +#define MSGQ__ASSOCIATE                           0x00000040UL
29849 +#define MSGQ__UNIX_READ                           0x00000080UL
29850 +#define MSGQ__UNIX_WRITE                          0x00000100UL
29851 +#define MSGQ__ENQUEUE                             0x00000200UL
29852 +#define SHM__CREATE                               0x00000001UL
29853 +#define SHM__DESTROY                              0x00000002UL
29854 +#define SHM__GETATTR                              0x00000004UL
29855 +#define SHM__SETATTR                              0x00000008UL
29856 +#define SHM__READ                                 0x00000010UL
29857 +#define SHM__WRITE                                0x00000020UL
29858 +#define SHM__ASSOCIATE                            0x00000040UL
29859 +#define SHM__UNIX_READ                            0x00000080UL
29860 +#define SHM__UNIX_WRITE                           0x00000100UL
29861 +#define SHM__LOCK                                 0x00000200UL
29862 +#define IPC__CREATE                               0x00000001UL
29863 +#define IPC__DESTROY                              0x00000002UL
29864 +#define IPC__GETATTR                              0x00000004UL
29865 +#define IPC__SETATTR                              0x00000008UL
29866 +#define IPC__READ                                 0x00000010UL
29867 +#define IPC__WRITE                                0x00000020UL
29868 +#define IPC__ASSOCIATE                            0x00000040UL
29869 +#define IPC__UNIX_READ                            0x00000080UL
29870 +#define IPC__UNIX_WRITE                           0x00000100UL
29871 +#define NETLINK_ROUTE_SOCKET__IOCTL               0x00000001UL
29872 +#define NETLINK_ROUTE_SOCKET__READ                0x00000002UL
29873 +#define NETLINK_ROUTE_SOCKET__WRITE               0x00000004UL
29874 +#define NETLINK_ROUTE_SOCKET__CREATE              0x00000008UL
29875 +#define NETLINK_ROUTE_SOCKET__GETATTR             0x00000010UL
29876 +#define NETLINK_ROUTE_SOCKET__SETATTR             0x00000020UL
29877 +#define NETLINK_ROUTE_SOCKET__LOCK                0x00000040UL
29878 +#define NETLINK_ROUTE_SOCKET__RELABELFROM         0x00000080UL
29879 +#define NETLINK_ROUTE_SOCKET__RELABELTO           0x00000100UL
29880 +#define NETLINK_ROUTE_SOCKET__APPEND              0x00000200UL
29881 +#define NETLINK_ROUTE_SOCKET__BIND                0x00000400UL
29882 +#define NETLINK_ROUTE_SOCKET__CONNECT             0x00000800UL
29883 +#define NETLINK_ROUTE_SOCKET__LISTEN              0x00001000UL
29884 +#define NETLINK_ROUTE_SOCKET__ACCEPT              0x00002000UL
29885 +#define NETLINK_ROUTE_SOCKET__GETOPT              0x00004000UL
29886 +#define NETLINK_ROUTE_SOCKET__SETOPT              0x00008000UL
29887 +#define NETLINK_ROUTE_SOCKET__SHUTDOWN            0x00010000UL
29888 +#define NETLINK_ROUTE_SOCKET__RECVFROM            0x00020000UL
29889 +#define NETLINK_ROUTE_SOCKET__SENDTO              0x00040000UL
29890 +#define NETLINK_ROUTE_SOCKET__RECV_MSG            0x00080000UL
29891 +#define NETLINK_ROUTE_SOCKET__SEND_MSG            0x00100000UL
29892 +#define NETLINK_ROUTE_SOCKET__NAME_BIND           0x00200000UL
29893 +#define NETLINK_ROUTE_SOCKET__NLMSG_READ          0x00400000UL
29894 +#define NETLINK_ROUTE_SOCKET__NLMSG_WRITE         0x00800000UL
29895 +#define NETLINK_FIREWALL_SOCKET__IOCTL            0x00000001UL
29896 +#define NETLINK_FIREWALL_SOCKET__READ             0x00000002UL
29897 +#define NETLINK_FIREWALL_SOCKET__WRITE            0x00000004UL
29898 +#define NETLINK_FIREWALL_SOCKET__CREATE           0x00000008UL
29899 +#define NETLINK_FIREWALL_SOCKET__GETATTR          0x00000010UL
29900 +#define NETLINK_FIREWALL_SOCKET__SETATTR          0x00000020UL
29901 +#define NETLINK_FIREWALL_SOCKET__LOCK             0x00000040UL
29902 +#define NETLINK_FIREWALL_SOCKET__RELABELFROM      0x00000080UL
29903 +#define NETLINK_FIREWALL_SOCKET__RELABELTO        0x00000100UL
29904 +#define NETLINK_FIREWALL_SOCKET__APPEND           0x00000200UL
29905 +#define NETLINK_FIREWALL_SOCKET__BIND             0x00000400UL
29906 +#define NETLINK_FIREWALL_SOCKET__CONNECT          0x00000800UL
29907 +#define NETLINK_FIREWALL_SOCKET__LISTEN           0x00001000UL
29908 +#define NETLINK_FIREWALL_SOCKET__ACCEPT           0x00002000UL
29909 +#define NETLINK_FIREWALL_SOCKET__GETOPT           0x00004000UL
29910 +#define NETLINK_FIREWALL_SOCKET__SETOPT           0x00008000UL
29911 +#define NETLINK_FIREWALL_SOCKET__SHUTDOWN         0x00010000UL
29912 +#define NETLINK_FIREWALL_SOCKET__RECVFROM         0x00020000UL
29913 +#define NETLINK_FIREWALL_SOCKET__SENDTO           0x00040000UL
29914 +#define NETLINK_FIREWALL_SOCKET__RECV_MSG         0x00080000UL
29915 +#define NETLINK_FIREWALL_SOCKET__SEND_MSG         0x00100000UL
29916 +#define NETLINK_FIREWALL_SOCKET__NAME_BIND        0x00200000UL
29917 +#define NETLINK_FIREWALL_SOCKET__NLMSG_READ       0x00400000UL
29918 +#define NETLINK_FIREWALL_SOCKET__NLMSG_WRITE      0x00800000UL
29919 +#define NETLINK_TCPDIAG_SOCKET__IOCTL             0x00000001UL
29920 +#define NETLINK_TCPDIAG_SOCKET__READ              0x00000002UL
29921 +#define NETLINK_TCPDIAG_SOCKET__WRITE             0x00000004UL
29922 +#define NETLINK_TCPDIAG_SOCKET__CREATE            0x00000008UL
29923 +#define NETLINK_TCPDIAG_SOCKET__GETATTR           0x00000010UL
29924 +#define NETLINK_TCPDIAG_SOCKET__SETATTR           0x00000020UL
29925 +#define NETLINK_TCPDIAG_SOCKET__LOCK              0x00000040UL
29926 +#define NETLINK_TCPDIAG_SOCKET__RELABELFROM       0x00000080UL
29927 +#define NETLINK_TCPDIAG_SOCKET__RELABELTO         0x00000100UL
29928 +#define NETLINK_TCPDIAG_SOCKET__APPEND            0x00000200UL
29929 +#define NETLINK_TCPDIAG_SOCKET__BIND              0x00000400UL
29930 +#define NETLINK_TCPDIAG_SOCKET__CONNECT           0x00000800UL
29931 +#define NETLINK_TCPDIAG_SOCKET__LISTEN            0x00001000UL
29932 +#define NETLINK_TCPDIAG_SOCKET__ACCEPT            0x00002000UL
29933 +#define NETLINK_TCPDIAG_SOCKET__GETOPT            0x00004000UL
29934 +#define NETLINK_TCPDIAG_SOCKET__SETOPT            0x00008000UL
29935 +#define NETLINK_TCPDIAG_SOCKET__SHUTDOWN          0x00010000UL
29936 +#define NETLINK_TCPDIAG_SOCKET__RECVFROM          0x00020000UL
29937 +#define NETLINK_TCPDIAG_SOCKET__SENDTO            0x00040000UL
29938 +#define NETLINK_TCPDIAG_SOCKET__RECV_MSG          0x00080000UL
29939 +#define NETLINK_TCPDIAG_SOCKET__SEND_MSG          0x00100000UL
29940 +#define NETLINK_TCPDIAG_SOCKET__NAME_BIND         0x00200000UL
29941 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_READ        0x00400000UL
29942 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_WRITE       0x00800000UL
29943 +#define NETLINK_NFLOG_SOCKET__IOCTL               0x00000001UL
29944 +#define NETLINK_NFLOG_SOCKET__READ                0x00000002UL
29945 +#define NETLINK_NFLOG_SOCKET__WRITE               0x00000004UL
29946 +#define NETLINK_NFLOG_SOCKET__CREATE              0x00000008UL
29947 +#define NETLINK_NFLOG_SOCKET__GETATTR             0x00000010UL
29948 +#define NETLINK_NFLOG_SOCKET__SETATTR             0x00000020UL
29949 +#define NETLINK_NFLOG_SOCKET__LOCK                0x00000040UL
29950 +#define NETLINK_NFLOG_SOCKET__RELABELFROM         0x00000080UL
29951 +#define NETLINK_NFLOG_SOCKET__RELABELTO           0x00000100UL
29952 +#define NETLINK_NFLOG_SOCKET__APPEND              0x00000200UL
29953 +#define NETLINK_NFLOG_SOCKET__BIND                0x00000400UL
29954 +#define NETLINK_NFLOG_SOCKET__CONNECT             0x00000800UL
29955 +#define NETLINK_NFLOG_SOCKET__LISTEN              0x00001000UL
29956 +#define NETLINK_NFLOG_SOCKET__ACCEPT              0x00002000UL
29957 +#define NETLINK_NFLOG_SOCKET__GETOPT              0x00004000UL
29958 +#define NETLINK_NFLOG_SOCKET__SETOPT              0x00008000UL
29959 +#define NETLINK_NFLOG_SOCKET__SHUTDOWN            0x00010000UL
29960 +#define NETLINK_NFLOG_SOCKET__RECVFROM            0x00020000UL
29961 +#define NETLINK_NFLOG_SOCKET__SENDTO              0x00040000UL
29962 +#define NETLINK_NFLOG_SOCKET__RECV_MSG            0x00080000UL
29963 +#define NETLINK_NFLOG_SOCKET__SEND_MSG            0x00100000UL
29964 +#define NETLINK_NFLOG_SOCKET__NAME_BIND           0x00200000UL
29965 +#define NETLINK_XFRM_SOCKET__IOCTL                0x00000001UL
29966 +#define NETLINK_XFRM_SOCKET__READ                 0x00000002UL
29967 +#define NETLINK_XFRM_SOCKET__WRITE                0x00000004UL
29968 +#define NETLINK_XFRM_SOCKET__CREATE               0x00000008UL
29969 +#define NETLINK_XFRM_SOCKET__GETATTR              0x00000010UL
29970 +#define NETLINK_XFRM_SOCKET__SETATTR              0x00000020UL
29971 +#define NETLINK_XFRM_SOCKET__LOCK                 0x00000040UL
29972 +#define NETLINK_XFRM_SOCKET__RELABELFROM          0x00000080UL
29973 +#define NETLINK_XFRM_SOCKET__RELABELTO            0x00000100UL
29974 +#define NETLINK_XFRM_SOCKET__APPEND               0x00000200UL
29975 +#define NETLINK_XFRM_SOCKET__BIND                 0x00000400UL
29976 +#define NETLINK_XFRM_SOCKET__CONNECT              0x00000800UL
29977 +#define NETLINK_XFRM_SOCKET__LISTEN               0x00001000UL
29978 +#define NETLINK_XFRM_SOCKET__ACCEPT               0x00002000UL
29979 +#define NETLINK_XFRM_SOCKET__GETOPT               0x00004000UL
29980 +#define NETLINK_XFRM_SOCKET__SETOPT               0x00008000UL
29981 +#define NETLINK_XFRM_SOCKET__SHUTDOWN             0x00010000UL
29982 +#define NETLINK_XFRM_SOCKET__RECVFROM             0x00020000UL
29983 +#define NETLINK_XFRM_SOCKET__SENDTO               0x00040000UL
29984 +#define NETLINK_XFRM_SOCKET__RECV_MSG             0x00080000UL
29985 +#define NETLINK_XFRM_SOCKET__SEND_MSG             0x00100000UL
29986 +#define NETLINK_XFRM_SOCKET__NAME_BIND            0x00200000UL
29987 +#define NETLINK_XFRM_SOCKET__NLMSG_READ           0x00400000UL
29988 +#define NETLINK_XFRM_SOCKET__NLMSG_WRITE          0x00800000UL
29989 +#define NETLINK_SELINUX_SOCKET__IOCTL             0x00000001UL
29990 +#define NETLINK_SELINUX_SOCKET__READ              0x00000002UL
29991 +#define NETLINK_SELINUX_SOCKET__WRITE             0x00000004UL
29992 +#define NETLINK_SELINUX_SOCKET__CREATE            0x00000008UL
29993 +#define NETLINK_SELINUX_SOCKET__GETATTR           0x00000010UL
29994 +#define NETLINK_SELINUX_SOCKET__SETATTR           0x00000020UL
29995 +#define NETLINK_SELINUX_SOCKET__LOCK              0x00000040UL
29996 +#define NETLINK_SELINUX_SOCKET__RELABELFROM       0x00000080UL
29997 +#define NETLINK_SELINUX_SOCKET__RELABELTO         0x00000100UL
29998 +#define NETLINK_SELINUX_SOCKET__APPEND            0x00000200UL
29999 +#define NETLINK_SELINUX_SOCKET__BIND              0x00000400UL
30000 +#define NETLINK_SELINUX_SOCKET__CONNECT           0x00000800UL
30001 +#define NETLINK_SELINUX_SOCKET__LISTEN            0x00001000UL
30002 +#define NETLINK_SELINUX_SOCKET__ACCEPT            0x00002000UL
30003 +#define NETLINK_SELINUX_SOCKET__GETOPT            0x00004000UL
30004 +#define NETLINK_SELINUX_SOCKET__SETOPT            0x00008000UL
30005 +#define NETLINK_SELINUX_SOCKET__SHUTDOWN          0x00010000UL
30006 +#define NETLINK_SELINUX_SOCKET__RECVFROM          0x00020000UL
30007 +#define NETLINK_SELINUX_SOCKET__SENDTO            0x00040000UL
30008 +#define NETLINK_SELINUX_SOCKET__RECV_MSG          0x00080000UL
30009 +#define NETLINK_SELINUX_SOCKET__SEND_MSG          0x00100000UL
30010 +#define NETLINK_SELINUX_SOCKET__NAME_BIND         0x00200000UL
30011 +#define NETLINK_AUDIT_SOCKET__IOCTL               0x00000001UL
30012 +#define NETLINK_AUDIT_SOCKET__READ                0x00000002UL
30013 +#define NETLINK_AUDIT_SOCKET__WRITE               0x00000004UL
30014 +#define NETLINK_AUDIT_SOCKET__CREATE              0x00000008UL
30015 +#define NETLINK_AUDIT_SOCKET__GETATTR             0x00000010UL
30016 +#define NETLINK_AUDIT_SOCKET__SETATTR             0x00000020UL
30017 +#define NETLINK_AUDIT_SOCKET__LOCK                0x00000040UL
30018 +#define NETLINK_AUDIT_SOCKET__RELABELFROM         0x00000080UL
30019 +#define NETLINK_AUDIT_SOCKET__RELABELTO           0x00000100UL
30020 +#define NETLINK_AUDIT_SOCKET__APPEND              0x00000200UL
30021 +#define NETLINK_AUDIT_SOCKET__BIND                0x00000400UL
30022 +#define NETLINK_AUDIT_SOCKET__CONNECT             0x00000800UL
30023 +#define NETLINK_AUDIT_SOCKET__LISTEN              0x00001000UL
30024 +#define NETLINK_AUDIT_SOCKET__ACCEPT              0x00002000UL
30025 +#define NETLINK_AUDIT_SOCKET__GETOPT              0x00004000UL
30026 +#define NETLINK_AUDIT_SOCKET__SETOPT              0x00008000UL
30027 +#define NETLINK_AUDIT_SOCKET__SHUTDOWN            0x00010000UL
30028 +#define NETLINK_AUDIT_SOCKET__RECVFROM            0x00020000UL
30029 +#define NETLINK_AUDIT_SOCKET__SENDTO              0x00040000UL
30030 +#define NETLINK_AUDIT_SOCKET__RECV_MSG            0x00080000UL
30031 +#define NETLINK_AUDIT_SOCKET__SEND_MSG            0x00100000UL
30032 +#define NETLINK_AUDIT_SOCKET__NAME_BIND           0x00200000UL
30033 +#define NETLINK_AUDIT_SOCKET__NLMSG_READ          0x00400000UL
30034 +#define NETLINK_AUDIT_SOCKET__NLMSG_WRITE         0x00800000UL
30035 +#define NETLINK_AUDIT_SOCKET__NLMSG_RELAY         0x01000000UL
30036 +#define NETLINK_AUDIT_SOCKET__NLMSG_READPRIV      0x02000000UL
30037 +#define NETLINK_AUDIT_SOCKET__NLMSG_TTY_AUDIT     0x04000000UL
30038 +#define NETLINK_IP6FW_SOCKET__IOCTL               0x00000001UL
30039 +#define NETLINK_IP6FW_SOCKET__READ                0x00000002UL
30040 +#define NETLINK_IP6FW_SOCKET__WRITE               0x00000004UL
30041 +#define NETLINK_IP6FW_SOCKET__CREATE              0x00000008UL
30042 +#define NETLINK_IP6FW_SOCKET__GETATTR             0x00000010UL
30043 +#define NETLINK_IP6FW_SOCKET__SETATTR             0x00000020UL
30044 +#define NETLINK_IP6FW_SOCKET__LOCK                0x00000040UL
30045 +#define NETLINK_IP6FW_SOCKET__RELABELFROM         0x00000080UL
30046 +#define NETLINK_IP6FW_SOCKET__RELABELTO           0x00000100UL
30047 +#define NETLINK_IP6FW_SOCKET__APPEND              0x00000200UL
30048 +#define NETLINK_IP6FW_SOCKET__BIND                0x00000400UL
30049 +#define NETLINK_IP6FW_SOCKET__CONNECT             0x00000800UL
30050 +#define NETLINK_IP6FW_SOCKET__LISTEN              0x00001000UL
30051 +#define NETLINK_IP6FW_SOCKET__ACCEPT              0x00002000UL
30052 +#define NETLINK_IP6FW_SOCKET__GETOPT              0x00004000UL
30053 +#define NETLINK_IP6FW_SOCKET__SETOPT              0x00008000UL
30054 +#define NETLINK_IP6FW_SOCKET__SHUTDOWN            0x00010000UL
30055 +#define NETLINK_IP6FW_SOCKET__RECVFROM            0x00020000UL
30056 +#define NETLINK_IP6FW_SOCKET__SENDTO              0x00040000UL
30057 +#define NETLINK_IP6FW_SOCKET__RECV_MSG            0x00080000UL
30058 +#define NETLINK_IP6FW_SOCKET__SEND_MSG            0x00100000UL
30059 +#define NETLINK_IP6FW_SOCKET__NAME_BIND           0x00200000UL
30060 +#define NETLINK_IP6FW_SOCKET__NLMSG_READ          0x00400000UL
30061 +#define NETLINK_IP6FW_SOCKET__NLMSG_WRITE         0x00800000UL
30062 +#define NETLINK_DNRT_SOCKET__IOCTL                0x00000001UL
30063 +#define NETLINK_DNRT_SOCKET__READ                 0x00000002UL
30064 +#define NETLINK_DNRT_SOCKET__WRITE                0x00000004UL
30065 +#define NETLINK_DNRT_SOCKET__CREATE               0x00000008UL
30066 +#define NETLINK_DNRT_SOCKET__GETATTR              0x00000010UL
30067 +#define NETLINK_DNRT_SOCKET__SETATTR              0x00000020UL
30068 +#define NETLINK_DNRT_SOCKET__LOCK                 0x00000040UL
30069 +#define NETLINK_DNRT_SOCKET__RELABELFROM          0x00000080UL
30070 +#define NETLINK_DNRT_SOCKET__RELABELTO            0x00000100UL
30071 +#define NETLINK_DNRT_SOCKET__APPEND               0x00000200UL
30072 +#define NETLINK_DNRT_SOCKET__BIND                 0x00000400UL
30073 +#define NETLINK_DNRT_SOCKET__CONNECT              0x00000800UL
30074 +#define NETLINK_DNRT_SOCKET__LISTEN               0x00001000UL
30075 +#define NETLINK_DNRT_SOCKET__ACCEPT               0x00002000UL
30076 +#define NETLINK_DNRT_SOCKET__GETOPT               0x00004000UL
30077 +#define NETLINK_DNRT_SOCKET__SETOPT               0x00008000UL
30078 +#define NETLINK_DNRT_SOCKET__SHUTDOWN             0x00010000UL
30079 +#define NETLINK_DNRT_SOCKET__RECVFROM             0x00020000UL
30080 +#define NETLINK_DNRT_SOCKET__SENDTO               0x00040000UL
30081 +#define NETLINK_DNRT_SOCKET__RECV_MSG             0x00080000UL
30082 +#define NETLINK_DNRT_SOCKET__SEND_MSG             0x00100000UL
30083 +#define NETLINK_DNRT_SOCKET__NAME_BIND            0x00200000UL
30084 +#define ASSOCIATION__SENDTO                       0x00000001UL
30085 +#define ASSOCIATION__RECVFROM                     0x00000002UL
30086 +#define ASSOCIATION__SETCONTEXT                   0x00000004UL
30087 +#define ASSOCIATION__POLMATCH                     0x00000008UL
30088 +#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL      0x00000001UL
30089 +#define NETLINK_KOBJECT_UEVENT_SOCKET__READ       0x00000002UL
30090 +#define NETLINK_KOBJECT_UEVENT_SOCKET__WRITE      0x00000004UL
30091 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CREATE     0x00000008UL
30092 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETATTR    0x00000010UL
30093 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETATTR    0x00000020UL
30094 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LOCK       0x00000040UL
30095 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELFROM 0x00000080UL
30096 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELTO  0x00000100UL
30097 +#define NETLINK_KOBJECT_UEVENT_SOCKET__APPEND     0x00000200UL
30098 +#define NETLINK_KOBJECT_UEVENT_SOCKET__BIND       0x00000400UL
30099 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CONNECT    0x00000800UL
30100 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LISTEN     0x00001000UL
30101 +#define NETLINK_KOBJECT_UEVENT_SOCKET__ACCEPT     0x00002000UL
30102 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETOPT     0x00004000UL
30103 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETOPT     0x00008000UL
30104 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SHUTDOWN   0x00010000UL
30105 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECVFROM   0x00020000UL
30106 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SENDTO     0x00040000UL
30107 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECV_MSG   0x00080000UL
30108 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SEND_MSG   0x00100000UL
30109 +#define NETLINK_KOBJECT_UEVENT_SOCKET__NAME_BIND  0x00200000UL
30110 +#define APPLETALK_SOCKET__IOCTL                   0x00000001UL
30111 +#define APPLETALK_SOCKET__READ                    0x00000002UL
30112 +#define APPLETALK_SOCKET__WRITE                   0x00000004UL
30113 +#define APPLETALK_SOCKET__CREATE                  0x00000008UL
30114 +#define APPLETALK_SOCKET__GETATTR                 0x00000010UL
30115 +#define APPLETALK_SOCKET__SETATTR                 0x00000020UL
30116 +#define APPLETALK_SOCKET__LOCK                    0x00000040UL
30117 +#define APPLETALK_SOCKET__RELABELFROM             0x00000080UL
30118 +#define APPLETALK_SOCKET__RELABELTO               0x00000100UL
30119 +#define APPLETALK_SOCKET__APPEND                  0x00000200UL
30120 +#define APPLETALK_SOCKET__BIND                    0x00000400UL
30121 +#define APPLETALK_SOCKET__CONNECT                 0x00000800UL
30122 +#define APPLETALK_SOCKET__LISTEN                  0x00001000UL
30123 +#define APPLETALK_SOCKET__ACCEPT                  0x00002000UL
30124 +#define APPLETALK_SOCKET__GETOPT                  0x00004000UL
30125 +#define APPLETALK_SOCKET__SETOPT                  0x00008000UL
30126 +#define APPLETALK_SOCKET__SHUTDOWN                0x00010000UL
30127 +#define APPLETALK_SOCKET__RECVFROM                0x00020000UL
30128 +#define APPLETALK_SOCKET__SENDTO                  0x00040000UL
30129 +#define APPLETALK_SOCKET__RECV_MSG                0x00080000UL
30130 +#define APPLETALK_SOCKET__SEND_MSG                0x00100000UL
30131 +#define APPLETALK_SOCKET__NAME_BIND               0x00200000UL
30132 +#define PACKET__SEND                              0x00000001UL
30133 +#define PACKET__RECV                              0x00000002UL
30134 +#define PACKET__RELABELTO                         0x00000004UL
30135 +#define PACKET__FLOW_IN                           0x00000008UL
30136 +#define PACKET__FLOW_OUT                          0x00000010UL
30137 +#define PACKET__FORWARD_IN                        0x00000020UL
30138 +#define PACKET__FORWARD_OUT                       0x00000040UL
30139 +#define KEY__VIEW                                 0x00000001UL
30140 +#define KEY__READ                                 0x00000002UL
30141 +#define KEY__WRITE                                0x00000004UL
30142 +#define KEY__SEARCH                               0x00000008UL
30143 +#define KEY__LINK                                 0x00000010UL
30144 +#define KEY__SETATTR                              0x00000020UL
30145 +#define KEY__CREATE                               0x00000040UL
30146 +#define DCCP_SOCKET__IOCTL                        0x00000001UL
30147 +#define DCCP_SOCKET__READ                         0x00000002UL
30148 +#define DCCP_SOCKET__WRITE                        0x00000004UL
30149 +#define DCCP_SOCKET__CREATE                       0x00000008UL
30150 +#define DCCP_SOCKET__GETATTR                      0x00000010UL
30151 +#define DCCP_SOCKET__SETATTR                      0x00000020UL
30152 +#define DCCP_SOCKET__LOCK                         0x00000040UL
30153 +#define DCCP_SOCKET__RELABELFROM                  0x00000080UL
30154 +#define DCCP_SOCKET__RELABELTO                    0x00000100UL
30155 +#define DCCP_SOCKET__APPEND                       0x00000200UL
30156 +#define DCCP_SOCKET__BIND                         0x00000400UL
30157 +#define DCCP_SOCKET__CONNECT                      0x00000800UL
30158 +#define DCCP_SOCKET__LISTEN                       0x00001000UL
30159 +#define DCCP_SOCKET__ACCEPT                       0x00002000UL
30160 +#define DCCP_SOCKET__GETOPT                       0x00004000UL
30161 +#define DCCP_SOCKET__SETOPT                       0x00008000UL
30162 +#define DCCP_SOCKET__SHUTDOWN                     0x00010000UL
30163 +#define DCCP_SOCKET__RECVFROM                     0x00020000UL
30164 +#define DCCP_SOCKET__SENDTO                       0x00040000UL
30165 +#define DCCP_SOCKET__RECV_MSG                     0x00080000UL
30166 +#define DCCP_SOCKET__SEND_MSG                     0x00100000UL
30167 +#define DCCP_SOCKET__NAME_BIND                    0x00200000UL
30168 +#define DCCP_SOCKET__NODE_BIND                    0x00400000UL
30169 +#define DCCP_SOCKET__NAME_CONNECT                 0x00800000UL
30170 +#define MEMPROTECT__MMAP_ZERO                     0x00000001UL
30171 +#define PEER__RECV                                0x00000001UL
30172 +#define CAPABILITY2__MAC_OVERRIDE                 0x00000001UL
30173 +#define CAPABILITY2__MAC_ADMIN                    0x00000002UL
30174 +#define KERNEL_SERVICE__USE_AS_OVERRIDE           0x00000001UL
30175 +#define KERNEL_SERVICE__CREATE_FILES_AS           0x00000002UL
30176 +#define TUN_SOCKET__IOCTL                         0x00000001UL
30177 +#define TUN_SOCKET__READ                          0x00000002UL
30178 +#define TUN_SOCKET__WRITE                         0x00000004UL
30179 +#define TUN_SOCKET__CREATE                        0x00000008UL
30180 +#define TUN_SOCKET__GETATTR                       0x00000010UL
30181 +#define TUN_SOCKET__SETATTR                       0x00000020UL
30182 +#define TUN_SOCKET__LOCK                          0x00000040UL
30183 +#define TUN_SOCKET__RELABELFROM                   0x00000080UL
30184 +#define TUN_SOCKET__RELABELTO                     0x00000100UL
30185 +#define TUN_SOCKET__APPEND                        0x00000200UL
30186 +#define TUN_SOCKET__BIND                          0x00000400UL
30187 +#define TUN_SOCKET__CONNECT                       0x00000800UL
30188 +#define TUN_SOCKET__LISTEN                        0x00001000UL
30189 +#define TUN_SOCKET__ACCEPT                        0x00002000UL
30190 +#define TUN_SOCKET__GETOPT                        0x00004000UL
30191 +#define TUN_SOCKET__SETOPT                        0x00008000UL
30192 +#define TUN_SOCKET__SHUTDOWN                      0x00010000UL
30193 +#define TUN_SOCKET__RECVFROM                      0x00020000UL
30194 +#define TUN_SOCKET__SENDTO                        0x00040000UL
30195 +#define TUN_SOCKET__RECV_MSG                      0x00080000UL
30196 +#define TUN_SOCKET__SEND_MSG                      0x00100000UL
30197 +#define TUN_SOCKET__NAME_BIND                     0x00200000UL
30198 +
30199 +#endif
30200 diff -NurpP --minimal linux-2.6.33.2/security/selinux/hooks.c linux-2.6.33.2-vs2.3.0.36.30.4/security/selinux/hooks.c
30201 --- linux-2.6.33.2/security/selinux/hooks.c     2010-02-25 11:52:12.000000000 +0100
30202 +++ linux-2.6.33.2-vs2.3.0.36.30.4/security/selinux/hooks.c     2010-02-25 12:02:16.000000000 +0100
30203 @@ -64,7 +64,6 @@
30204  #include <linux/dccp.h>
30205  #include <linux/quota.h>
30206  #include <linux/un.h>          /* for Unix socket types */
30207 -#include <net/af_unix.h>       /* for Unix socket types */
30208  #include <linux/parser.h>
30209  #include <linux/nfs_mount.h>
30210  #include <net/ipv6.h>
30211 --- linux-2.6.27.45-vs2.3.x-N3/kernel/signal.c  2010-02-01 20:10:59.000000000 +0100
30212 +++ linux-2.6.31.13-vs2.3.x-N3/kernel/signal.c  2010-01-28 00:24:14.000000000 +0100
30213 @@ -1074,7 +1137,7 @@ int kill_pid_info(int sig, struct siginf
30214         rcu_read_lock();
30215  retry:
30216         p = pid_task(pid, PIDTYPE_PID);
30217 -       if (p && vx_check(vx_task_xid(p), VS_ADMIN | VS_IDENT)) {
30218 +       if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
30219                 error = group_send_sig_info(sig, info, p);
30220                 if (unlikely(error == -ESRCH))
30221                         /*
This page took 2.745242 seconds and 4 git commands to generate.