]> git.pld-linux.org Git - packages/kernel.git/blob - kernel-vserver-2.3.patch
34ab5201777981d7cf4d6014b48c5fa8d123690a
[packages/kernel.git] / kernel-vserver-2.3.patch
1 diff -NurpP --minimal linux-2.6.33.1/arch/alpha/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/alpha/Kconfig
2 --- linux-2.6.33.1/arch/alpha/Kconfig   2010-02-25 11:51:18.000000000 +0100
3 +++ linux-2.6.33.1-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.1/arch/alpha/kernel/entry.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/alpha/kernel/entry.S
14 --- linux-2.6.33.1/arch/alpha/kernel/entry.S    2009-06-11 17:11:46.000000000 +0200
15 +++ linux-2.6.33.1-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.1/arch/alpha/kernel/osf_sys.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/alpha/kernel/osf_sys.c
49 --- linux-2.6.33.1/arch/alpha/kernel/osf_sys.c  2010-02-25 11:51:19.000000000 +0100
50 +++ linux-2.6.33.1-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.1/arch/alpha/kernel/ptrace.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/alpha/kernel/ptrace.c
61 --- linux-2.6.33.1/arch/alpha/kernel/ptrace.c   2009-09-10 15:25:14.000000000 +0200
62 +++ linux-2.6.33.1-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.1/arch/alpha/kernel/systbls.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/alpha/kernel/systbls.S
72 --- linux-2.6.33.1/arch/alpha/kernel/systbls.S  2010-02-25 11:51:19.000000000 +0100
73 +++ linux-2.6.33.1-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.1/arch/alpha/kernel/traps.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/alpha/kernel/traps.c
84 --- linux-2.6.33.1/arch/alpha/kernel/traps.c    2009-06-11 17:11:46.000000000 +0200
85 +++ linux-2.6.33.1-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.1/arch/alpha/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/alpha/mm/fault.c
97 --- linux-2.6.33.1/arch/alpha/mm/fault.c        2009-09-10 15:25:14.000000000 +0200
98 +++ linux-2.6.33.1-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.1/arch/arm/include/asm/tlb.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/arm/include/asm/tlb.h
111 --- linux-2.6.33.1/arch/arm/include/asm/tlb.h   2009-09-10 15:25:15.000000000 +0200
112 +++ linux-2.6.33.1-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.1/arch/arm/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/arm/Kconfig
122 --- linux-2.6.33.1/arch/arm/Kconfig     2010-02-25 11:51:19.000000000 +0100
123 +++ linux-2.6.33.1-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.1/arch/arm/kernel/calls.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/arm/kernel/calls.S
134 --- linux-2.6.33.1/arch/arm/kernel/calls.S      2010-02-25 11:51:20.000000000 +0100
135 +++ linux-2.6.33.1-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.1/arch/arm/kernel/process.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/arm/kernel/process.c
146 --- linux-2.6.33.1/arch/arm/kernel/process.c    2010-02-25 11:51:20.000000000 +0100
147 +++ linux-2.6.33.1-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.1/arch/arm/kernel/traps.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/arm/kernel/traps.c
159 --- linux-2.6.33.1/arch/arm/kernel/traps.c      2009-12-03 20:01:50.000000000 +0100
160 +++ linux-2.6.33.1-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.1/arch/avr32/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/avr32/mm/fault.c
173 --- linux-2.6.33.1/arch/avr32/mm/fault.c        2009-09-10 15:25:20.000000000 +0200
174 +++ linux-2.6.33.1-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.1/arch/cris/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/cris/Kconfig
186 --- linux-2.6.33.1/arch/cris/Kconfig    2009-06-11 17:11:56.000000000 +0200
187 +++ linux-2.6.33.1-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.1/arch/cris/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/cris/mm/fault.c
198 --- linux-2.6.33.1/arch/cris/mm/fault.c 2010-02-25 11:51:26.000000000 +0100
199 +++ linux-2.6.33.1-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.1/arch/frv/kernel/kernel_thread.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/frv/kernel/kernel_thread.S
211 --- linux-2.6.33.1/arch/frv/kernel/kernel_thread.S      2008-12-25 00:26:37.000000000 +0100
212 +++ linux-2.6.33.1-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.1/arch/frv/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/frv/mm/fault.c
223 --- linux-2.6.33.1/arch/frv/mm/fault.c  2009-09-10 15:25:22.000000000 +0200
224 +++ linux-2.6.33.1-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.1/arch/h8300/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/h8300/Kconfig
236 --- linux-2.6.33.1/arch/h8300/Kconfig   2010-02-25 11:51:26.000000000 +0100
237 +++ linux-2.6.33.1-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.1/arch/ia64/ia32/ia32_entry.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/ia64/ia32/ia32_entry.S
248 --- linux-2.6.33.1/arch/ia64/ia32/ia32_entry.S  2010-02-25 11:51:26.000000000 +0100
249 +++ linux-2.6.33.1-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.1/arch/ia64/include/asm/tlb.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/ia64/include/asm/tlb.h
260 --- linux-2.6.33.1/arch/ia64/include/asm/tlb.h  2010-02-25 11:51:26.000000000 +0100
261 +++ linux-2.6.33.1-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.1/arch/ia64/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/ia64/Kconfig
271 --- linux-2.6.33.1/arch/ia64/Kconfig    2010-02-25 11:51:26.000000000 +0100
272 +++ linux-2.6.33.1-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.1/arch/ia64/kernel/entry.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/ia64/kernel/entry.S
283 --- linux-2.6.33.1/arch/ia64/kernel/entry.S     2010-02-25 11:51:26.000000000 +0100
284 +++ linux-2.6.33.1-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.1/arch/ia64/kernel/perfmon.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/ia64/kernel/perfmon.c
295 --- linux-2.6.33.1/arch/ia64/kernel/perfmon.c   2010-02-25 11:51:26.000000000 +0100
296 +++ linux-2.6.33.1-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.1/arch/ia64/kernel/process.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/ia64/kernel/process.c
315 --- linux-2.6.33.1/arch/ia64/kernel/process.c   2009-12-03 20:01:56.000000000 +0100
316 +++ linux-2.6.33.1-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.1/arch/ia64/kernel/ptrace.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/ia64/kernel/ptrace.c
329 --- linux-2.6.33.1/arch/ia64/kernel/ptrace.c    2009-09-10 15:25:22.000000000 +0200
330 +++ linux-2.6.33.1-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.1/arch/ia64/kernel/traps.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/ia64/kernel/traps.c
340 --- linux-2.6.33.1/arch/ia64/kernel/traps.c     2008-12-25 00:26:37.000000000 +0100
341 +++ linux-2.6.33.1-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.1/arch/ia64/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/ia64/mm/fault.c
367 --- linux-2.6.33.1/arch/ia64/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
368 +++ linux-2.6.33.1-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.1/arch/m32r/kernel/traps.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/m32r/kernel/traps.c
388 --- linux-2.6.33.1/arch/m32r/kernel/traps.c     2009-12-03 20:01:57.000000000 +0100
389 +++ linux-2.6.33.1-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.1/arch/m32r/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/m32r/mm/fault.c
403 --- linux-2.6.33.1/arch/m32r/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
404 +++ linux-2.6.33.1-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.1/arch/m68k/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/m68k/Kconfig
416 --- linux-2.6.33.1/arch/m68k/Kconfig    2009-12-03 20:01:57.000000000 +0100
417 +++ linux-2.6.33.1-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.1/arch/m68k/kernel/ptrace.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/m68k/kernel/ptrace.c
428 --- linux-2.6.33.1/arch/m68k/kernel/ptrace.c    2010-02-25 11:51:27.000000000 +0100
429 +++ linux-2.6.33.1-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.1/arch/m68k/kernel/traps.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/m68k/kernel/traps.c
448 --- linux-2.6.33.1/arch/m68k/kernel/traps.c     2009-09-10 15:25:23.000000000 +0200
449 +++ linux-2.6.33.1-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.1/arch/m68k/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/m68k/mm/fault.c
462 --- linux-2.6.33.1/arch/m68k/mm/fault.c 2009-09-10 15:25:23.000000000 +0200
463 +++ linux-2.6.33.1-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.1/arch/m68knommu/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/m68knommu/Kconfig
475 --- linux-2.6.33.1/arch/m68knommu/Kconfig       2010-02-25 11:51:27.000000000 +0100
476 +++ linux-2.6.33.1-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.1/arch/m68knommu/kernel/traps.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/m68knommu/kernel/traps.c
487 --- linux-2.6.33.1/arch/m68knommu/kernel/traps.c        2009-09-10 15:25:23.000000000 +0200
488 +++ linux-2.6.33.1-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.1/arch/microblaze/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/microblaze/mm/fault.c
502 --- linux-2.6.33.1/arch/microblaze/mm/fault.c   2009-09-10 15:25:24.000000000 +0200
503 +++ linux-2.6.33.1-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.1/arch/mips/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/mips/Kconfig
515 --- linux-2.6.33.1/arch/mips/Kconfig    2010-02-25 11:51:27.000000000 +0100
516 +++ linux-2.6.33.1-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.1/arch/mips/kernel/ptrace.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/mips/kernel/ptrace.c
527 --- linux-2.6.33.1/arch/mips/kernel/ptrace.c    2008-12-25 00:26:37.000000000 +0100
528 +++ linux-2.6.33.1-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.1/arch/mips/kernel/scall32-o32.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/mips/kernel/scall32-o32.S
548 --- linux-2.6.33.1/arch/mips/kernel/scall32-o32.S       2010-02-25 11:51:28.000000000 +0100
549 +++ linux-2.6.33.1-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.1/arch/mips/kernel/scall64-64.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/mips/kernel/scall64-64.S
560 --- linux-2.6.33.1/arch/mips/kernel/scall64-64.S        2010-02-25 11:51:28.000000000 +0100
561 +++ linux-2.6.33.1-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.1/arch/mips/kernel/scall64-n32.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/mips/kernel/scall64-n32.S
572 --- linux-2.6.33.1/arch/mips/kernel/scall64-n32.S       2010-02-25 11:51:28.000000000 +0100
573 +++ linux-2.6.33.1-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.1/arch/mips/kernel/scall64-o32.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/mips/kernel/scall64-o32.S
584 --- linux-2.6.33.1/arch/mips/kernel/scall64-o32.S       2010-02-25 11:51:28.000000000 +0100
585 +++ linux-2.6.33.1-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.1/arch/mips/kernel/traps.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/mips/kernel/traps.c
596 --- linux-2.6.33.1/arch/mips/kernel/traps.c     2010-02-25 11:51:28.000000000 +0100
597 +++ linux-2.6.33.1-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.1/arch/mn10300/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/mn10300/mm/fault.c
613 --- linux-2.6.33.1/arch/mn10300/mm/fault.c      2009-09-10 15:25:39.000000000 +0200
614 +++ linux-2.6.33.1-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.1/arch/parisc/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/parisc/Kconfig
626 --- linux-2.6.33.1/arch/parisc/Kconfig  2010-02-25 11:51:29.000000000 +0100
627 +++ linux-2.6.33.1-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.1/arch/parisc/kernel/syscall_table.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/parisc/kernel/syscall_table.S
638 --- linux-2.6.33.1/arch/parisc/kernel/syscall_table.S   2010-02-25 11:51:29.000000000 +0100
639 +++ linux-2.6.33.1-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.1/arch/parisc/kernel/traps.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/parisc/kernel/traps.c
650 --- linux-2.6.33.1/arch/parisc/kernel/traps.c   2009-09-10 15:25:40.000000000 +0200
651 +++ linux-2.6.33.1-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.1/arch/parisc/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/parisc/mm/fault.c
676 --- linux-2.6.33.1/arch/parisc/mm/fault.c       2009-09-10 15:25:40.000000000 +0200
677 +++ linux-2.6.33.1-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.1/arch/powerpc/include/asm/unistd.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/powerpc/include/asm/unistd.h
701 --- linux-2.6.33.1/arch/powerpc/include/asm/unistd.h    2009-12-03 20:02:01.000000000 +0100
702 +++ linux-2.6.33.1-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.1/arch/powerpc/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/powerpc/Kconfig
713 --- linux-2.6.33.1/arch/powerpc/Kconfig 2010-02-25 11:51:29.000000000 +0100
714 +++ linux-2.6.33.1-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.1/arch/powerpc/kernel/irq.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/powerpc/kernel/irq.c
725 --- linux-2.6.33.1/arch/powerpc/kernel/irq.c    2010-02-25 11:51:31.000000000 +0100
726 +++ linux-2.6.33.1-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.1/arch/powerpc/kernel/process.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/powerpc/kernel/process.c
736 --- linux-2.6.33.1/arch/powerpc/kernel/process.c        2010-02-25 11:51:31.000000000 +0100
737 +++ linux-2.6.33.1-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.1/arch/powerpc/kernel/traps.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/powerpc/kernel/traps.c
751 --- linux-2.6.33.1/arch/powerpc/kernel/traps.c  2010-02-25 11:51:31.000000000 +0100
752 +++ linux-2.6.33.1-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.1/arch/powerpc/kernel/vdso.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/powerpc/kernel/vdso.c
766 --- linux-2.6.33.1/arch/powerpc/kernel/vdso.c   2010-02-25 11:51:31.000000000 +0100
767 +++ linux-2.6.33.1-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.1/arch/powerpc/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/powerpc/mm/fault.c
777 --- linux-2.6.33.1/arch/powerpc/mm/fault.c      2010-02-25 11:51:31.000000000 +0100
778 +++ linux-2.6.33.1-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.1/arch/s390/include/asm/tlb.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/s390/include/asm/tlb.h
790 --- linux-2.6.33.1/arch/s390/include/asm/tlb.h  2009-09-10 15:25:43.000000000 +0200
791 +++ linux-2.6.33.1-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.1/arch/s390/include/asm/unistd.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/s390/include/asm/unistd.h
802 --- linux-2.6.33.1/arch/s390/include/asm/unistd.h       2010-02-25 11:51:32.000000000 +0100
803 +++ linux-2.6.33.1-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.1/arch/s390/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/s390/Kconfig
814 --- linux-2.6.33.1/arch/s390/Kconfig    2010-02-25 11:51:32.000000000 +0100
815 +++ linux-2.6.33.1-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.1/arch/s390/kernel/ptrace.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/s390/kernel/ptrace.c
826 --- linux-2.6.33.1/arch/s390/kernel/ptrace.c    2010-02-25 11:51:32.000000000 +0100
827 +++ linux-2.6.33.1-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.1/arch/s390/kernel/syscalls.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/s390/kernel/syscalls.S
837 --- linux-2.6.33.1/arch/s390/kernel/syscalls.S  2009-12-03 20:02:03.000000000 +0100
838 +++ linux-2.6.33.1-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.1/arch/sh/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/sh/Kconfig
849 --- linux-2.6.33.1/arch/sh/Kconfig      2010-02-25 11:51:32.000000000 +0100
850 +++ linux-2.6.33.1-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.1/arch/sh/kernel/irq.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/sh/kernel/irq.c
861 --- linux-2.6.33.1/arch/sh/kernel/irq.c 2010-02-25 11:51:33.000000000 +0100
862 +++ linux-2.6.33.1-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.1/arch/sh/kernel/vsyscall/vsyscall.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/sh/kernel/vsyscall/vsyscall.c
872 --- linux-2.6.33.1/arch/sh/kernel/vsyscall/vsyscall.c   2009-03-24 14:18:42.000000000 +0100
873 +++ linux-2.6.33.1-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.1/arch/sh/mm/fault_32.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/sh/mm/fault_32.c
883 --- linux-2.6.33.1/arch/sh/mm/fault_32.c        2009-12-03 20:02:14.000000000 +0100
884 +++ linux-2.6.33.1-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.1/arch/sh/mm/tlbflush_64.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/sh/mm/tlbflush_64.c
896 --- linux-2.6.33.1/arch/sh/mm/tlbflush_64.c     2009-12-03 20:02:14.000000000 +0100
897 +++ linux-2.6.33.1-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.1/arch/sparc/include/asm/tlb_64.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/sparc/include/asm/tlb_64.h
909 --- linux-2.6.33.1/arch/sparc/include/asm/tlb_64.h      2009-09-10 15:25:45.000000000 +0200
910 +++ linux-2.6.33.1-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.1/arch/sparc/include/asm/unistd.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/sparc/include/asm/unistd.h
920 --- linux-2.6.33.1/arch/sparc/include/asm/unistd.h      2010-02-25 11:51:34.000000000 +0100
921 +++ linux-2.6.33.1-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.1/arch/sparc/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/sparc/Kconfig
932 --- linux-2.6.33.1/arch/sparc/Kconfig   2010-02-25 11:51:33.000000000 +0100
933 +++ linux-2.6.33.1-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.1/arch/sparc/kernel/systbls_32.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/sparc/kernel/systbls_32.S
944 --- linux-2.6.33.1/arch/sparc/kernel/systbls_32.S       2010-02-25 11:51:34.000000000 +0100
945 +++ linux-2.6.33.1-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.1/arch/sparc/kernel/systbls_64.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/sparc/kernel/systbls_64.S
956 --- linux-2.6.33.1/arch/sparc/kernel/systbls_64.S       2010-02-25 11:51:34.000000000 +0100
957 +++ linux-2.6.33.1-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.1/arch/um/include/asm/tlb.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/um/include/asm/tlb.h
977 --- linux-2.6.33.1/arch/um/include/asm/tlb.h    2009-09-10 15:25:46.000000000 +0200
978 +++ linux-2.6.33.1-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.1/arch/um/include/shared/kern_constants.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/um/include/shared/kern_constants.h
988 --- linux-2.6.33.1/arch/um/include/shared/kern_constants.h      1970-01-01 01:00:00.000000000 +0100
989 +++ linux-2.6.33.1-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.1/arch/um/include/shared/user_constants.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/um/include/shared/user_constants.h
993 --- linux-2.6.33.1/arch/um/include/shared/user_constants.h      1970-01-01 01:00:00.000000000 +0100
994 +++ linux-2.6.33.1-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.1/arch/um/Kconfig.rest linux-2.6.33.1-vs2.3.0.36.30.4/arch/um/Kconfig.rest
1037 --- linux-2.6.33.1/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
1038 +++ linux-2.6.33.1-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.1/arch/um/kernel/config.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/um/kernel/config.c
1049 --- linux-2.6.33.1/arch/um/kernel/config.c      1970-01-01 01:00:00.000000000 +0100
1050 +++ linux-2.6.33.1-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.1/arch/um/kernel/config.tmp linux-2.6.33.1-vs2.3.0.36.30.4/arch/um/kernel/config.tmp
1470 --- linux-2.6.33.1/arch/um/kernel/config.tmp    1970-01-01 01:00:00.000000000 +0100
1471 +++ linux-2.6.33.1-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.1/arch/um/kernel/vmlinux.lds linux-2.6.33.1-vs2.3.0.36.30.4/arch/um/kernel/vmlinux.lds
1864 --- linux-2.6.33.1/arch/um/kernel/vmlinux.lds   1970-01-01 01:00:00.000000000 +0100
1865 +++ linux-2.6.33.1-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.1/arch/x86/ia32/ia32entry.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/x86/ia32/ia32entry.S
2415 --- linux-2.6.33.1/arch/x86/ia32/ia32entry.S    2010-02-25 11:51:34.000000000 +0100
2416 +++ linux-2.6.33.1-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.1/arch/x86/include/asm/unistd_64.h linux-2.6.33.1-vs2.3.0.36.30.4/arch/x86/include/asm/unistd_64.h
2427 --- linux-2.6.33.1/arch/x86/include/asm/unistd_64.h     2010-02-25 11:51:34.000000000 +0100
2428 +++ linux-2.6.33.1-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.1/arch/x86/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/arch/x86/Kconfig
2439 --- linux-2.6.33.1/arch/x86/Kconfig     2010-02-25 11:51:34.000000000 +0100
2440 +++ linux-2.6.33.1-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.1/arch/x86/kernel/syscall_table_32.S linux-2.6.33.1-vs2.3.0.36.30.4/arch/x86/kernel/syscall_table_32.S
2451 --- linux-2.6.33.1/arch/x86/kernel/syscall_table_32.S   2010-02-25 11:51:35.000000000 +0100
2452 +++ linux-2.6.33.1-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.1/arch/xtensa/mm/fault.c linux-2.6.33.1-vs2.3.0.36.30.4/arch/xtensa/mm/fault.c
2463 --- linux-2.6.33.1/arch/xtensa/mm/fault.c       2009-09-10 15:25:48.000000000 +0200
2464 +++ linux-2.6.33.1-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.1/Documentation/vserver/debug.txt linux-2.6.33.1-vs2.3.0.36.30.4/Documentation/vserver/debug.txt
2476 --- linux-2.6.33.1/Documentation/vserver/debug.txt      1970-01-01 01:00:00.000000000 +0100
2477 +++ linux-2.6.33.1-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.1/drivers/block/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/drivers/block/Kconfig
2634 --- linux-2.6.33.1/drivers/block/Kconfig        2010-02-25 11:51:36.000000000 +0100
2635 +++ linux-2.6.33.1-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.1/drivers/block/loop.c linux-2.6.33.1-vs2.3.0.36.30.4/drivers/block/loop.c
2651 --- linux-2.6.33.1/drivers/block/loop.c 2009-12-03 20:02:19.000000000 +0100
2652 +++ linux-2.6.33.1-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.1/drivers/block/Makefile linux-2.6.33.1-vs2.3.0.36.30.4/drivers/block/Makefile
2707 --- linux-2.6.33.1/drivers/block/Makefile       2010-02-25 11:51:36.000000000 +0100
2708 +++ linux-2.6.33.1-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.1/drivers/block/vroot.c linux-2.6.33.1-vs2.3.0.36.30.4/drivers/block/vroot.c
2718 --- linux-2.6.33.1/drivers/block/vroot.c        1970-01-01 01:00:00.000000000 +0100
2719 +++ linux-2.6.33.1-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.1/drivers/char/sysrq.c linux-2.6.33.1-vs2.3.0.36.30.4/drivers/char/sysrq.c
3003 --- linux-2.6.33.1/drivers/char/sysrq.c 2010-02-25 11:51:37.000000000 +0100
3004 +++ linux-2.6.33.1-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.1/drivers/char/tty_io.c linux-2.6.33.1-vs2.3.0.36.30.4/drivers/char/tty_io.c
3057 --- linux-2.6.33.1/drivers/char/tty_io.c        2010-02-25 11:51:37.000000000 +0100
3058 +++ linux-2.6.33.1-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.1/drivers/gpu/drm/radeon/r100_reg_safe.h linux-2.6.33.1-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r100_reg_safe.h
3086 --- linux-2.6.33.1/drivers/gpu/drm/radeon/r100_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3087 +++ linux-2.6.33.1-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.1/drivers/gpu/drm/radeon/r200_reg_safe.h linux-2.6.33.1-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r200_reg_safe.h
3118 --- linux-2.6.33.1/drivers/gpu/drm/radeon/r200_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3119 +++ linux-2.6.33.1-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.1/drivers/gpu/drm/radeon/r300_reg_safe.h linux-2.6.33.1-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r300_reg_safe.h
3150 --- linux-2.6.33.1/drivers/gpu/drm/radeon/r300_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3151 +++ linux-2.6.33.1-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.1/drivers/gpu/drm/radeon/r420_reg_safe.h linux-2.6.33.1-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/r420_reg_safe.h
3196 --- linux-2.6.33.1/drivers/gpu/drm/radeon/r420_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3197 +++ linux-2.6.33.1-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.1/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-2.6.33.1-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/rn50_reg_safe.h
3242 --- linux-2.6.33.1/drivers/gpu/drm/radeon/rn50_reg_safe.h       1970-01-01 01:00:00.000000000 +0100
3243 +++ linux-2.6.33.1-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.1/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-2.6.33.1-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/rs600_reg_safe.h
3274 --- linux-2.6.33.1/drivers/gpu/drm/radeon/rs600_reg_safe.h      1970-01-01 01:00:00.000000000 +0100
3275 +++ linux-2.6.33.1-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.1/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-2.6.33.1-vs2.3.0.36.30.4/drivers/gpu/drm/radeon/rv515_reg_safe.h
3335 --- linux-2.6.33.1/drivers/gpu/drm/radeon/rv515_reg_safe.h      1970-01-01 01:00:00.000000000 +0100
3336 +++ linux-2.6.33.1-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.1/drivers/infiniband/core/addr.c linux-2.6.33.1-vs2.3.0.36.30.4/drivers/infiniband/core/addr.c
3396 --- linux-2.6.33.1/drivers/infiniband/core/addr.c       2010-02-25 11:51:39.000000000 +0100
3397 +++ linux-2.6.33.1-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.1/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-2.6.33.1-vs2.3.0.36.30.4/drivers/infiniband/hw/ipath/ipath_user_pages.c
3408 --- linux-2.6.33.1/drivers/infiniband/hw/ipath/ipath_user_pages.c       2009-12-03 20:02:23.000000000 +0100
3409 +++ linux-2.6.33.1-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.1/drivers/md/dm.c linux-2.6.33.1-vs2.3.0.36.30.4/drivers/md/dm.c
3456 --- linux-2.6.33.1/drivers/md/dm.c      2010-03-18 16:25:14.000000000 +0100
3457 +++ linux-2.6.33.1-vs2.3.0.36.30.4/drivers/md/dm.c      2010-03-18 16:54:28.000000000 +0100
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.1/drivers/md/dm.h linux-2.6.33.1-vs2.3.0.36.30.4/drivers/md/dm.h
3532 --- linux-2.6.33.1/drivers/md/dm.h      2010-02-25 11:51:41.000000000 +0100
3533 +++ linux-2.6.33.1-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.1/drivers/md/dm-ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/drivers/md/dm-ioctl.c
3544 --- linux-2.6.33.1/drivers/md/dm-ioctl.c        2010-03-18 16:25:14.000000000 +0100
3545 +++ linux-2.6.33.1-vs2.3.0.36.30.4/drivers/md/dm-ioctl.c        2010-03-18 16:54:28.000000000 +0100
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.1/drivers/net/tun.c linux-2.6.33.1-vs2.3.0.36.30.4/drivers/net/tun.c
3628 --- linux-2.6.33.1/drivers/net/tun.c    2010-02-25 11:51:53.000000000 +0100
3629 +++ linux-2.6.33.1-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.1/fs/attr.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/attr.c
3700 --- linux-2.6.33.1/fs/attr.c    2009-12-03 20:02:51.000000000 +0100
3701 +++ linux-2.6.33.1-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.1/fs/binfmt_aout.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/binfmt_aout.c
3743 --- linux-2.6.33.1/fs/binfmt_aout.c     2010-02-25 11:52:04.000000000 +0100
3744 +++ linux-2.6.33.1-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.1/fs/binfmt_elf.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/binfmt_elf.c
3754 --- linux-2.6.33.1/fs/binfmt_elf.c      2010-02-25 11:52:04.000000000 +0100
3755 +++ linux-2.6.33.1-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.1/fs/binfmt_flat.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/binfmt_flat.c
3765 --- linux-2.6.33.1/fs/binfmt_flat.c     2010-02-25 11:52:04.000000000 +0100
3766 +++ linux-2.6.33.1-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.1/fs/binfmt_som.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/binfmt_som.c
3776 --- linux-2.6.33.1/fs/binfmt_som.c      2010-02-25 11:52:04.000000000 +0100
3777 +++ linux-2.6.33.1-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.1/fs/block_dev.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/block_dev.c
3787 --- linux-2.6.33.1/fs/block_dev.c       2010-02-25 11:52:04.000000000 +0100
3788 +++ linux-2.6.33.1-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.1/fs/btrfs/ctree.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/btrfs/ctree.h
3827 --- linux-2.6.33.1/fs/btrfs/ctree.h     2010-02-25 11:52:04.000000000 +0100
3828 +++ linux-2.6.33.1-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.1/fs/btrfs/disk-io.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/btrfs/disk-io.c
3882 --- linux-2.6.33.1/fs/btrfs/disk-io.c   2010-02-25 11:52:04.000000000 +0100
3883 +++ linux-2.6.33.1-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.1/fs/btrfs/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/btrfs/inode.c
3895 --- linux-2.6.33.1/fs/btrfs/inode.c     2010-02-25 11:52:04.000000000 +0100
3896 +++ linux-2.6.33.1-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.1/fs/btrfs/ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/btrfs/ioctl.c
3974 --- linux-2.6.33.1/fs/btrfs/ioctl.c     2010-02-25 11:52:04.000000000 +0100
3975 +++ linux-2.6.33.1-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.1/fs/btrfs/super.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/btrfs/super.c
4158 --- linux-2.6.33.1/fs/btrfs/super.c     2010-02-25 11:52:04.000000000 +0100
4159 +++ linux-2.6.33.1-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.1/fs/char_dev.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/char_dev.c
4216 --- linux-2.6.33.1/fs/char_dev.c        2009-12-03 20:02:51.000000000 +0100
4217 +++ linux-2.6.33.1-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.1/fs/dcache.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/dcache.c
4251 --- linux-2.6.33.1/fs/dcache.c  2010-02-25 11:52:05.000000000 +0100
4252 +++ linux-2.6.33.1-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.1/fs/devpts/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/devpts/inode.c
4305 --- linux-2.6.33.1/fs/devpts/inode.c    2010-02-25 11:52:05.000000000 +0100
4306 +++ linux-2.6.33.1-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.1/fs/exec.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/exec.c
4390 --- linux-2.6.33.1/fs/exec.c    2010-02-25 11:52:05.000000000 +0100
4391 +++ linux-2.6.33.1-vs2.3.0.36.30.4/fs/exec.c    2010-02-25 12:02:16.000000000 +0100
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.1/fs/ext2/balloc.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext2/balloc.c
4413 --- linux-2.6.33.1/fs/ext2/balloc.c     2009-06-11 17:13:03.000000000 +0200
4414 +++ linux-2.6.33.1-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.1/fs/ext2/ext2.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext2/ext2.h
4424 --- linux-2.6.33.1/fs/ext2/ext2.h       2010-02-25 11:52:05.000000000 +0100
4425 +++ linux-2.6.33.1-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.1/fs/ext2/file.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext2/file.c
4435 --- linux-2.6.33.1/fs/ext2/file.c       2010-02-25 11:52:05.000000000 +0100
4436 +++ linux-2.6.33.1-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.1/fs/ext2/ialloc.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext2/ialloc.c
4444 --- linux-2.6.33.1/fs/ext2/ialloc.c     2009-06-11 17:13:03.000000000 +0200
4445 +++ linux-2.6.33.1-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.1/fs/ext2/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext2/inode.c
4463 --- linux-2.6.33.1/fs/ext2/inode.c      2010-02-25 11:52:05.000000000 +0100
4464 +++ linux-2.6.33.1-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.1/fs/ext2/ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext2/ioctl.c
4614 --- linux-2.6.33.1/fs/ext2/ioctl.c      2009-09-10 15:26:21.000000000 +0200
4615 +++ linux-2.6.33.1-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.1/fs/ext2/namei.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext2/namei.c
4666 --- linux-2.6.33.1/fs/ext2/namei.c      2009-12-03 20:02:51.000000000 +0100
4667 +++ linux-2.6.33.1-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.1/fs/ext2/super.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext2/super.c
4693 --- linux-2.6.33.1/fs/ext2/super.c      2010-02-25 11:52:05.000000000 +0100
4694 +++ linux-2.6.33.1-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.1/fs/ext3/file.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext3/file.c
4761 --- linux-2.6.33.1/fs/ext3/file.c       2009-12-03 20:02:51.000000000 +0100
4762 +++ linux-2.6.33.1-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.1/fs/ext3/ialloc.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext3/ialloc.c
4771 --- linux-2.6.33.1/fs/ext3/ialloc.c     2009-09-10 15:26:21.000000000 +0200
4772 +++ linux-2.6.33.1-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.1/fs/ext3/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext3/inode.c
4790 --- linux-2.6.33.1/fs/ext3/inode.c      2010-02-25 11:52:05.000000000 +0100
4791 +++ linux-2.6.33.1-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.1/fs/ext3/ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext3/ioctl.c
4976 --- linux-2.6.33.1/fs/ext3/ioctl.c      2009-06-11 17:13:03.000000000 +0200
4977 +++ linux-2.6.33.1-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.1/fs/ext3/namei.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext3/namei.c
5054 --- linux-2.6.33.1/fs/ext3/namei.c      2010-02-25 11:52:05.000000000 +0100
5055 +++ linux-2.6.33.1-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.1/fs/ext3/super.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext3/super.c
5081 --- linux-2.6.33.1/fs/ext3/super.c      2010-02-25 11:52:05.000000000 +0100
5082 +++ linux-2.6.33.1-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.1/fs/ext4/ext4.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext4/ext4.h
5149 --- linux-2.6.33.1/fs/ext4/ext4.h       2010-02-25 11:52:05.000000000 +0100
5150 +++ linux-2.6.33.1-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.1/fs/ext4/file.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext4/file.c
5199 --- linux-2.6.33.1/fs/ext4/file.c       2009-12-03 20:02:51.000000000 +0100
5200 +++ linux-2.6.33.1-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.1/fs/ext4/ialloc.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext4/ialloc.c
5209 --- linux-2.6.33.1/fs/ext4/ialloc.c     2009-12-03 20:02:51.000000000 +0100
5210 +++ linux-2.6.33.1-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.1/fs/ext4/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext4/inode.c
5228 --- linux-2.6.33.1/fs/ext4/inode.c      2010-02-25 11:52:05.000000000 +0100
5229 +++ linux-2.6.33.1-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.1/fs/ext4/ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext4/ioctl.c
5413 --- linux-2.6.33.1/fs/ext4/ioctl.c      2010-02-25 11:52:05.000000000 +0100
5414 +++ linux-2.6.33.1-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.1/fs/ext4/namei.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext4/namei.c
5479 --- linux-2.6.33.1/fs/ext4/namei.c      2010-02-25 11:52:05.000000000 +0100
5480 +++ linux-2.6.33.1-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.1/fs/ext4/super.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ext4/super.c
5506 --- linux-2.6.33.1/fs/ext4/super.c      2010-02-25 11:52:05.000000000 +0100
5507 +++ linux-2.6.33.1-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.1/fs/fcntl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/fcntl.c
5573 --- linux-2.6.33.1/fs/fcntl.c   2010-02-25 11:52:05.000000000 +0100
5574 +++ linux-2.6.33.1-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.1/fs/file.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/file.c
5602 --- linux-2.6.33.1/fs/file.c    2009-12-03 20:02:51.000000000 +0100
5603 +++ linux-2.6.33.1-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.1/fs/file_table.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/file_table.c
5630 --- linux-2.6.33.1/fs/file_table.c      2010-03-18 16:25:15.000000000 +0100
5631 +++ linux-2.6.33.1-vs2.3.0.36.30.4/fs/file_table.c      2010-03-18 16:54:29.000000000 +0100
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.1/fs/fs_struct.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/fs_struct.c
5669 --- linux-2.6.33.1/fs/fs_struct.c       2009-06-11 17:13:04.000000000 +0200
5670 +++ linux-2.6.33.1-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.1/fs/gfs2/file.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/gfs2/file.c
5696 --- linux-2.6.33.1/fs/gfs2/file.c       2010-02-25 11:52:05.000000000 +0100
5697 +++ linux-2.6.33.1-vs2.3.0.36.30.4/fs/gfs2/file.c       2010-02-25 12:02:16.000000000 +0100
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.1/fs/gfs2/inode.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/gfs2/inode.h
5819 --- linux-2.6.33.1/fs/gfs2/inode.h      2009-09-10 15:26:22.000000000 +0200
5820 +++ linux-2.6.33.1-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.1/fs/gfs2/ops_inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/gfs2/ops_inode.c
5830 --- linux-2.6.33.1/fs/gfs2/ops_inode.c  2010-02-25 11:52:05.000000000 +0100
5831 +++ linux-2.6.33.1-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.1/fs/hfsplus/ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/hfsplus/ioctl.c
5849 --- linux-2.6.33.1/fs/hfsplus/ioctl.c   2008-12-25 00:26:37.000000000 +0100
5850 +++ linux-2.6.33.1-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.1/fs/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/inode.c
5860 --- linux-2.6.33.1/fs/inode.c   2010-02-25 11:52:05.000000000 +0100
5861 +++ linux-2.6.33.1-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.1/fs/ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ioctl.c
5902 --- linux-2.6.33.1/fs/ioctl.c   2009-12-03 20:02:52.000000000 +0100
5903 +++ linux-2.6.33.1-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.1/fs/ioprio.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ioprio.c
5915 --- linux-2.6.33.1/fs/ioprio.c  2009-03-24 14:22:26.000000000 +0100
5916 +++ linux-2.6.33.1-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.1/fs/jfs/acl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/jfs/acl.c
5944 --- linux-2.6.33.1/fs/jfs/acl.c 2009-12-03 20:02:52.000000000 +0100
5945 +++ linux-2.6.33.1-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.1/fs/jfs/file.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/jfs/file.c
5957 --- linux-2.6.33.1/fs/jfs/file.c        2009-12-03 20:02:52.000000000 +0100
5958 +++ linux-2.6.33.1-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.1/fs/jfs/ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/jfs/ioctl.c
5968 --- linux-2.6.33.1/fs/jfs/ioctl.c       2008-12-25 00:26:37.000000000 +0100
5969 +++ linux-2.6.33.1-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.1/fs/jfs/jfs_dinode.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/jfs/jfs_dinode.h
6028 --- linux-2.6.33.1/fs/jfs/jfs_dinode.h  2008-12-25 00:26:37.000000000 +0100
6029 +++ linux-2.6.33.1-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.1/fs/jfs/jfs_filsys.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/jfs/jfs_filsys.h
6047 --- linux-2.6.33.1/fs/jfs/jfs_filsys.h  2008-12-25 00:26:37.000000000 +0100
6048 +++ linux-2.6.33.1-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.1/fs/jfs/jfs_imap.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/jfs/jfs_imap.c
6058 --- linux-2.6.33.1/fs/jfs/jfs_imap.c    2009-09-10 15:26:22.000000000 +0200
6059 +++ linux-2.6.33.1-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.1/fs/jfs/jfs_inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/jfs/jfs_inode.c
6120 --- linux-2.6.33.1/fs/jfs/jfs_inode.c   2009-06-11 17:13:05.000000000 +0200
6121 +++ linux-2.6.33.1-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.1/fs/jfs/jfs_inode.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/jfs/jfs_inode.h
6204 --- linux-2.6.33.1/fs/jfs/jfs_inode.h   2009-06-11 17:13:05.000000000 +0200
6205 +++ linux-2.6.33.1-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.1/fs/jfs/namei.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/jfs/namei.c
6215 --- linux-2.6.33.1/fs/jfs/namei.c       2009-12-03 20:02:52.000000000 +0100
6216 +++ linux-2.6.33.1-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.1/fs/jfs/super.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/jfs/super.c
6242 --- linux-2.6.33.1/fs/jfs/super.c       2010-02-25 11:52:05.000000000 +0100
6243 +++ linux-2.6.33.1-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.1/fs/libfs.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/libfs.c
6310 --- linux-2.6.33.1/fs/libfs.c   2010-02-25 11:52:05.000000000 +0100
6311 +++ linux-2.6.33.1-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.1/fs/locks.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/locks.c
6359 --- linux-2.6.33.1/fs/locks.c   2009-12-03 20:02:52.000000000 +0100
6360 +++ linux-2.6.33.1-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.1/fs/namei.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/namei.c
6547 --- linux-2.6.33.1/fs/namei.c   2010-02-25 11:52:05.000000000 +0100
6548 +++ linux-2.6.33.1-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.1/fs/namespace.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/namespace.c
7025 --- linux-2.6.33.1/fs/namespace.c       2010-02-25 11:52:05.000000000 +0100
7026 +++ linux-2.6.33.1-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.1/fs/nfs/client.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfs/client.c
7317 --- linux-2.6.33.1/fs/nfs/client.c      2010-02-25 11:52:05.000000000 +0100
7318 +++ linux-2.6.33.1-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.1/fs/nfs/dir.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfs/dir.c
7341 --- linux-2.6.33.1/fs/nfs/dir.c 2010-02-25 11:52:05.000000000 +0100
7342 +++ linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfs/dir.c 2010-02-25 12:02:16.000000000 +0100
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.1/fs/nfs/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfs/inode.c
7360 --- linux-2.6.33.1/fs/nfs/inode.c       2010-02-25 11:52:05.000000000 +0100
7361 +++ linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfs/inode.c       2010-02-25 12:02:16.000000000 +0100
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.1/fs/nfs/nfs3xdr.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfs/nfs3xdr.c
7514 --- linux-2.6.33.1/fs/nfs/nfs3xdr.c     2009-12-03 20:02:52.000000000 +0100
7515 +++ linux-2.6.33.1-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.1/fs/nfs/nfsroot.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfs/nfsroot.c
7606 --- linux-2.6.33.1/fs/nfs/nfsroot.c     2009-09-10 15:26:23.000000000 +0200
7607 +++ linux-2.6.33.1-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.1/fs/nfs/super.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfs/super.c
7655 --- linux-2.6.33.1/fs/nfs/super.c       2010-02-25 11:52:05.000000000 +0100
7656 +++ linux-2.6.33.1-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.1/fs/nfsd/auth.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfsd/auth.c
7674 --- linux-2.6.33.1/fs/nfsd/auth.c       2010-02-25 11:52:05.000000000 +0100
7675 +++ linux-2.6.33.1-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.1/fs/nfsd/nfs3xdr.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfsd/nfs3xdr.c
7695 --- linux-2.6.33.1/fs/nfsd/nfs3xdr.c    2010-02-25 11:52:05.000000000 +0100
7696 +++ linux-2.6.33.1-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.1/fs/nfsd/nfs4xdr.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfsd/nfs4xdr.c
7748 --- linux-2.6.33.1/fs/nfsd/nfs4xdr.c    2010-02-25 11:52:05.000000000 +0100
7749 +++ linux-2.6.33.1-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.1/fs/nfsd/nfsxdr.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/nfsd/nfsxdr.c
7780 --- linux-2.6.33.1/fs/nfsd/nfsxdr.c     2010-02-25 11:52:05.000000000 +0100
7781 +++ linux-2.6.33.1-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.1/fs/ocfs2/dlm/dlmfs.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/dlm/dlmfs.c
7831 --- linux-2.6.33.1/fs/ocfs2/dlm/dlmfs.c 2009-12-03 20:02:53.000000000 +0100
7832 +++ linux-2.6.33.1-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.1/fs/ocfs2/dlmglue.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/dlmglue.c
7858 --- linux-2.6.33.1/fs/ocfs2/dlmglue.c   2010-02-25 11:52:06.000000000 +0100
7859 +++ linux-2.6.33.1-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.1/fs/ocfs2/dlmglue.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/dlmglue.h
7877 --- linux-2.6.33.1/fs/ocfs2/dlmglue.h   2009-12-03 20:02:53.000000000 +0100
7878 +++ linux-2.6.33.1-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.1/fs/ocfs2/file.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/file.c
7890 --- linux-2.6.33.1/fs/ocfs2/file.c      2010-02-25 11:52:06.000000000 +0100
7891 +++ linux-2.6.33.1-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.1/fs/ocfs2/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/inode.c
7910 --- linux-2.6.33.1/fs/ocfs2/inode.c     2010-02-25 11:52:06.000000000 +0100
7911 +++ linux-2.6.33.1-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.1/fs/ocfs2/inode.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/inode.h
8009 --- linux-2.6.33.1/fs/ocfs2/inode.h     2009-12-03 20:02:53.000000000 +0100
8010 +++ linux-2.6.33.1-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.1/fs/ocfs2/ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/ioctl.c
8020 --- linux-2.6.33.1/fs/ocfs2/ioctl.c     2010-02-25 11:52:06.000000000 +0100
8021 +++ linux-2.6.33.1-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.1/fs/ocfs2/namei.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/namei.c
8086 --- linux-2.6.33.1/fs/ocfs2/namei.c     2010-02-25 11:52:06.000000000 +0100
8087 +++ linux-2.6.33.1-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.1/fs/ocfs2/ocfs2_fs.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/ocfs2_fs.h
8119 --- linux-2.6.33.1/fs/ocfs2/ocfs2_fs.h  2010-02-25 11:52:06.000000000 +0100
8120 +++ linux-2.6.33.1-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.1/fs/ocfs2/ocfs2.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/ocfs2.h
8157 --- linux-2.6.33.1/fs/ocfs2/ocfs2.h     2010-02-25 11:52:06.000000000 +0100
8158 +++ linux-2.6.33.1-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.1/fs/ocfs2/super.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/ocfs2/super.c
8168 --- linux-2.6.33.1/fs/ocfs2/super.c     2010-02-25 11:52:06.000000000 +0100
8169 +++ linux-2.6.33.1-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.1/fs/open.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/open.c
8234 --- linux-2.6.33.1/fs/open.c    2010-02-25 11:52:06.000000000 +0100
8235 +++ linux-2.6.33.1-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.1/fs/proc/array.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/proc/array.c
8337 --- linux-2.6.33.1/fs/proc/array.c      2010-02-25 11:52:06.000000000 +0100
8338 +++ linux-2.6.33.1-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.1/fs/proc/base.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/proc/base.c
8453 --- linux-2.6.33.1/fs/proc/base.c       2010-02-25 11:52:06.000000000 +0100
8454 +++ linux-2.6.33.1-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.1/fs/proc/generic.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/proc/generic.c
8597 --- linux-2.6.33.1/fs/proc/generic.c    2010-02-25 11:52:06.000000000 +0100
8598 +++ linux-2.6.33.1-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.1/fs/proc/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/proc/inode.c
8661 --- linux-2.6.33.1/fs/proc/inode.c      2010-02-25 11:52:06.000000000 +0100
8662 +++ linux-2.6.33.1-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.1/fs/proc/internal.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/proc/internal.h
8673 --- linux-2.6.33.1/fs/proc/internal.h   2010-02-25 11:52:06.000000000 +0100
8674 +++ linux-2.6.33.1-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.1/fs/proc/loadavg.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/proc/loadavg.c
8712 --- linux-2.6.33.1/fs/proc/loadavg.c    2009-09-10 15:26:23.000000000 +0200
8713 +++ linux-2.6.33.1-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.1/fs/proc/meminfo.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/proc/meminfo.c
8744 --- linux-2.6.33.1/fs/proc/meminfo.c    2009-12-03 20:02:53.000000000 +0100
8745 +++ linux-2.6.33.1-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.1/fs/proc/root.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/proc/root.c
8757 --- linux-2.6.33.1/fs/proc/root.c       2009-06-11 17:13:07.000000000 +0200
8758 +++ linux-2.6.33.1-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.1/fs/proc/uptime.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/proc/uptime.c
8791 --- linux-2.6.33.1/fs/proc/uptime.c     2009-12-03 20:02:53.000000000 +0100
8792 +++ linux-2.6.33.1-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.1/fs/quota/quota.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/quota/quota.c
8823 --- linux-2.6.33.1/fs/quota/quota.c     2010-02-25 11:52:06.000000000 +0100
8824 +++ linux-2.6.33.1-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.1/fs/reiserfs/file.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/reiserfs/file.c
8931 --- linux-2.6.33.1/fs/reiserfs/file.c   2010-02-25 11:52:06.000000000 +0100
8932 +++ linux-2.6.33.1-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.1/fs/reiserfs/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/reiserfs/inode.c
8940 --- linux-2.6.33.1/fs/reiserfs/inode.c  2010-02-25 11:52:06.000000000 +0100
8941 +++ linux-2.6.33.1-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.1/fs/reiserfs/ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/reiserfs/ioctl.c
9111 --- linux-2.6.33.1/fs/reiserfs/ioctl.c  2010-02-25 11:52:06.000000000 +0100
9112 +++ linux-2.6.33.1-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.1/fs/reiserfs/namei.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/reiserfs/namei.c
9181 --- linux-2.6.33.1/fs/reiserfs/namei.c  2010-02-25 11:52:06.000000000 +0100
9182 +++ linux-2.6.33.1-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.1/fs/reiserfs/super.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/reiserfs/super.c
9216 --- linux-2.6.33.1/fs/reiserfs/super.c  2010-02-25 11:52:06.000000000 +0100
9217 +++ linux-2.6.33.1-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.1/fs/reiserfs/xattr.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/reiserfs/xattr.c
9260 --- linux-2.6.33.1/fs/reiserfs/xattr.c  2010-02-25 11:52:06.000000000 +0100
9261 +++ linux-2.6.33.1-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.1/fs/stat.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/stat.c
9271 --- linux-2.6.33.1/fs/stat.c    2010-02-25 11:52:06.000000000 +0100
9272 +++ linux-2.6.33.1-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.1/fs/super.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/super.c
9282 --- linux-2.6.33.1/fs/super.c   2010-02-25 11:52:06.000000000 +0100
9283 +++ linux-2.6.33.1-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.1/fs/sysfs/mount.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/sysfs/mount.c
9334 --- linux-2.6.33.1/fs/sysfs/mount.c     2009-06-11 17:13:08.000000000 +0200
9335 +++ linux-2.6.33.1-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.1/fs/utimes.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/utimes.c
9346 --- linux-2.6.33.1/fs/utimes.c  2009-03-24 14:22:37.000000000 +0100
9347 +++ linux-2.6.33.1-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.1/fs/xattr.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/xattr.c
9358 --- linux-2.6.33.1/fs/xattr.c   2010-02-25 11:52:06.000000000 +0100
9359 +++ linux-2.6.33.1-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.1/fs/xfs/linux-2.6/xfs_ioctl.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_ioctl.c
9378 --- linux-2.6.33.1/fs/xfs/linux-2.6/xfs_ioctl.c 2010-02-25 11:52:06.000000000 +0100
9379 +++ linux-2.6.33.1-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.1/fs/xfs/linux-2.6/xfs_ioctl.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_ioctl.h
9448 --- linux-2.6.33.1/fs/xfs/linux-2.6/xfs_ioctl.h 2009-03-24 14:22:37.000000000 +0100
9449 +++ linux-2.6.33.1-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.1/fs/xfs/linux-2.6/xfs_iops.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_iops.c
9464 --- linux-2.6.33.1/fs/xfs/linux-2.6/xfs_iops.c  2010-02-25 11:52:06.000000000 +0100
9465 +++ linux-2.6.33.1-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.1/fs/xfs/linux-2.6/xfs_linux.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_linux.h
9542 --- linux-2.6.33.1/fs/xfs/linux-2.6/xfs_linux.h 2010-02-25 11:52:06.000000000 +0100
9543 +++ linux-2.6.33.1-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.1/fs/xfs/linux-2.6/xfs_super.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/linux-2.6/xfs_super.c
9553 --- linux-2.6.33.1/fs/xfs/linux-2.6/xfs_super.c 2010-02-25 11:52:06.000000000 +0100
9554 +++ linux-2.6.33.1-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.1/fs/xfs/xfs_dinode.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/xfs_dinode.h
9628 --- linux-2.6.33.1/fs/xfs/xfs_dinode.h  2009-06-11 17:13:09.000000000 +0200
9629 +++ linux-2.6.33.1-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.1/fs/xfs/xfs_fs.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/xfs_fs.h
9671 --- linux-2.6.33.1/fs/xfs/xfs_fs.h      2009-12-03 20:02:53.000000000 +0100
9672 +++ linux-2.6.33.1-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.1/fs/xfs/xfs_ialloc.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/xfs_ialloc.c
9694 --- linux-2.6.33.1/fs/xfs/xfs_ialloc.c  2010-02-25 11:52:06.000000000 +0100
9695 +++ linux-2.6.33.1-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.1/fs/xfs/xfs_inode.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/xfs_inode.c
9705 --- linux-2.6.33.1/fs/xfs/xfs_inode.c   2010-02-25 11:52:06.000000000 +0100
9706 +++ linux-2.6.33.1-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.1/fs/xfs/xfs_inode.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/xfs_inode.h
9882 --- linux-2.6.33.1/fs/xfs/xfs_inode.h   2010-02-25 11:52:06.000000000 +0100
9883 +++ linux-2.6.33.1-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.1/fs/xfs/xfs_itable.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/xfs_itable.c
9905 --- linux-2.6.33.1/fs/xfs/xfs_itable.c  2009-12-03 20:02:54.000000000 +0100
9906 +++ linux-2.6.33.1-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.1/fs/xfs/xfs_log_recover.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/xfs_log_recover.c
9916 --- linux-2.6.33.1/fs/xfs/xfs_log_recover.c     2010-02-25 11:52:06.000000000 +0100
9917 +++ linux-2.6.33.1-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.1/fs/xfs/xfs_mount.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/xfs_mount.h
9929 --- linux-2.6.33.1/fs/xfs/xfs_mount.h   2010-02-25 11:52:06.000000000 +0100
9930 +++ linux-2.6.33.1-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.1/fs/xfs/xfs_vnodeops.c linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/xfs_vnodeops.c
9940 --- linux-2.6.33.1/fs/xfs/xfs_vnodeops.c        2010-02-25 11:52:06.000000000 +0100
9941 +++ linux-2.6.33.1-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.1/fs/xfs/xfs_vnodeops.h linux-2.6.33.1-vs2.3.0.36.30.4/fs/xfs/xfs_vnodeops.h
10082 --- linux-2.6.33.1/fs/xfs/xfs_vnodeops.h        2010-02-25 11:52:06.000000000 +0100
10083 +++ linux-2.6.33.1-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.1/include/asm-generic/tlb.h linux-2.6.33.1-vs2.3.0.36.30.4/include/asm-generic/tlb.h
10093 --- linux-2.6.33.1/include/asm-generic/tlb.h    2009-09-10 15:26:24.000000000 +0200
10094 +++ linux-2.6.33.1-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.1/include/linux/capability.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/capability.h
10104 --- linux-2.6.33.1/include/linux/capability.h   2010-02-25 11:52:07.000000000 +0100
10105 +++ linux-2.6.33.1-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.1/include/linux/devpts_fs.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/devpts_fs.h
10130 --- linux-2.6.33.1/include/linux/devpts_fs.h    2008-12-25 00:26:37.000000000 +0100
10131 +++ linux-2.6.33.1-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.1/include/linux/ext2_fs.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/ext2_fs.h
10139 --- linux-2.6.33.1/include/linux/ext2_fs.h      2010-02-25 11:52:07.000000000 +0100
10140 +++ linux-2.6.33.1-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.1/include/linux/ext3_fs.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/ext3_fs.h
10181 --- linux-2.6.33.1/include/linux/ext3_fs.h      2010-02-25 11:52:07.000000000 +0100
10182 +++ linux-2.6.33.1-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.1/include/linux/fs.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/fs.h
10235 --- linux-2.6.33.1/include/linux/fs.h   2010-03-18 16:25:15.000000000 +0100
10236 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/fs.h   2010-03-18 16:54:29.000000000 +0100
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.1/include/linux/gfs2_ondisk.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/gfs2_ondisk.h
10416 --- linux-2.6.33.1/include/linux/gfs2_ondisk.h  2010-02-25 11:52:07.000000000 +0100
10417 +++ linux-2.6.33.1-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.1/include/linux/if_tun.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/if_tun.h
10439 --- linux-2.6.33.1/include/linux/if_tun.h       2009-12-03 20:02:55.000000000 +0100
10440 +++ linux-2.6.33.1-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.1/include/linux/init_task.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/init_task.h
10450 --- linux-2.6.33.1/include/linux/init_task.h    2010-02-25 11:52:07.000000000 +0100
10451 +++ linux-2.6.33.1-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.1/include/linux/ipc.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/ipc.h
10464 --- linux-2.6.33.1/include/linux/ipc.h  2009-12-03 20:02:55.000000000 +0100
10465 +++ linux-2.6.33.1-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.1/include/linux/Kbuild linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/Kbuild
10475 --- linux-2.6.33.1/include/linux/Kbuild 2010-02-25 11:52:07.000000000 +0100
10476 +++ linux-2.6.33.1-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.1/include/linux/loop.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/loop.h
10487 --- linux-2.6.33.1/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
10488 +++ linux-2.6.33.1-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.1/include/linux/magic.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/magic.h
10498 --- linux-2.6.33.1/include/linux/magic.h        2009-12-03 20:02:55.000000000 +0100
10499 +++ linux-2.6.33.1-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.1/include/linux/major.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/major.h
10518 --- linux-2.6.33.1/include/linux/major.h        2009-09-10 15:26:25.000000000 +0200
10519 +++ linux-2.6.33.1-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.1/include/linux/memcontrol.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/memcontrol.h
10529 --- linux-2.6.33.1/include/linux/memcontrol.h   2010-02-25 11:52:07.000000000 +0100
10530 +++ linux-2.6.33.1-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.1/include/linux/mm_types.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/mm_types.h
10546 --- linux-2.6.33.1/include/linux/mm_types.h     2010-02-25 11:52:07.000000000 +0100
10547 +++ linux-2.6.33.1-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.1/include/linux/mount.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/mount.h
10557 --- linux-2.6.33.1/include/linux/mount.h        2009-09-10 15:26:25.000000000 +0200
10558 +++ linux-2.6.33.1-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.1/include/linux/net.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/net.h
10578 --- linux-2.6.33.1/include/linux/net.h  2010-02-25 11:52:07.000000000 +0100
10579 +++ linux-2.6.33.1-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.1/include/linux/nfs_mount.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/nfs_mount.h
10589 --- linux-2.6.33.1/include/linux/nfs_mount.h    2009-03-24 14:22:43.000000000 +0100
10590 +++ linux-2.6.33.1-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.1/include/linux/nsproxy.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/nsproxy.h
10602 --- linux-2.6.33.1/include/linux/nsproxy.h      2009-06-11 17:13:17.000000000 +0200
10603 +++ linux-2.6.33.1-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.1/include/linux/pid.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/pid.h
10653 --- linux-2.6.33.1/include/linux/pid.h  2009-03-24 14:22:43.000000000 +0100
10654 +++ linux-2.6.33.1-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.1/include/linux/proc_fs.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/proc_fs.h
10674 --- linux-2.6.33.1/include/linux/proc_fs.h      2009-12-03 20:02:56.000000000 +0100
10675 +++ linux-2.6.33.1-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.1/include/linux/quotaops.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/quotaops.h
10712 --- linux-2.6.33.1/include/linux/quotaops.h     2009-12-03 20:02:56.000000000 +0100
10713 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/quotaops.h     2010-02-25 12:02:16.000000000 +0100
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 @@ -154,10 +155,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 @@ -174,10 +179,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 @@ -194,22 +203,30 @@ 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         return 0;
10771  }
10772  
10773  static inline int vfs_dq_alloc_inode(struct inode *inode)
10774  {
10775 +       if (dl_alloc_inode(inode))
10776 +               return 1;
10777         if (sb_any_quota_active(inode->i_sb)) {
10778                 vfs_dq_init(inode);
10779 -               if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
10780 +               if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
10781 +                       dl_free_inode(inode);
10782                         return 1;
10783 +               }
10784         }
10785         return 0;
10786  }
10787 @@ -217,9 +234,13 @@ static inline int vfs_dq_alloc_inode(str
10788   */
10789  static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
10790  {
10791 +       if (dl_claim_space(inode, nr))
10792 +               return 1;
10793         if (sb_any_quota_active(inode->i_sb)) {
10794 -               if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
10795 +               if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) {
10796 +                       dl_release_space(inode, nr);
10797                         return 1;
10798 +               }
10799         } else
10800                 inode_add_bytes(inode, nr);
10801  
10802 @@ -235,8 +256,9 @@ void vfs_dq_release_reservation_space(st
10803  {
10804         if (sb_any_quota_active(inode->i_sb))
10805                 inode->i_sb->dq_op->release_rsv(inode, nr);
10806         else
10807                 inode_sub_rsv_space(inode, nr);
10808 +       dl_release_space(inode, nr);
10809  }
10810  
10811  static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
10812 @@ -243,6 +265,7 @@ static inline void vfs_dq_free_space_nod
10813                 inode->i_sb->dq_op->free_space(inode, nr);
10814         else
10815                 inode_sub_bytes(inode, nr);
10816 +       dl_free_space(inode, nr);
10817  }
10818  
10819  static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
10820 @@ -255,6 +278,7 @@ static inline void vfs_dq_free_inode(str
10821  {
10822         if (sb_any_quota_active(inode->i_sb))
10823                 inode->i_sb->dq_op->free_inode(inode, 1);
10824 +       dl_free_inode(inode);
10825  }
10826  
10827  /* Cannot be called inside a transaction */
10828 @@ -358,6 +382,8 @@ static inline int vfs_dq_transfer(struct
10829  
10830  static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
10831  {
10832 +       if (dl_alloc_space(inode, nr))
10833 +               return 1;
10834         inode_add_bytes(inode, nr);
10835         return 0;
10836  }
10837 @@ -371,6 +397,8 @@ static inline int vfs_dq_prealloc_space(
10838  
10839  static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
10840  {
10841 +       if (dl_alloc_space(inode, nr))
10842 +               return 1;
10843         inode_add_bytes(inode, nr);
10844         return 0;
10845  }
10846 @@ -384,22 +412,28 @@ static inline int vfs_dq_alloc_space(str
10847  
10848  static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
10849  {
10850 +       if (dl_reserve_space(inode, nr))
10851 +               return 1;
10852         return 0;
10853  }
10854  
10855  static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
10856  {
10857 +       if (dl_claim_space(inode, nr))
10858 +               return 1;
10859         return vfs_dq_alloc_space(inode, nr);
10860  }
10861  
10862  static inline
10863  int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
10864  {
10865 +       dl_release_space(inode, nr);
10866         return 0;
10867  }
10868  
10869  static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
10870  {
10871 +       dl_free_space(inode, nr);
10872         inode_sub_bytes(inode, nr);
10873  }
10874  
10875 diff -NurpP --minimal linux-2.6.33.1/include/linux/reboot.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/reboot.h
10876 --- linux-2.6.33.1/include/linux/reboot.h       2008-12-25 00:26:37.000000000 +0100
10877 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/reboot.h       2010-02-25 12:02:16.000000000 +0100
10878 @@ -33,6 +33,7 @@
10879  #define        LINUX_REBOOT_CMD_RESTART2       0xA1B2C3D4
10880  #define        LINUX_REBOOT_CMD_SW_SUSPEND     0xD000FCE2
10881  #define        LINUX_REBOOT_CMD_KEXEC          0x45584543
10882 +#define        LINUX_REBOOT_CMD_OOM            0xDEADBEEF
10883  
10884  
10885  #ifdef __KERNEL__
10886 diff -NurpP --minimal linux-2.6.33.1/include/linux/reiserfs_fs.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/reiserfs_fs.h
10887 --- linux-2.6.33.1/include/linux/reiserfs_fs.h  2010-02-25 11:52:07.000000000 +0100
10888 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/reiserfs_fs.h  2010-02-25 12:02:16.000000000 +0100
10889 @@ -977,6 +977,11 @@ struct stat_data_v1 {
10890  #define REISERFS_COMPR_FL     FS_COMPR_FL
10891  #define REISERFS_NOTAIL_FL    FS_NOTAIL_FL
10892  
10893 +/* unfortunately reiserfs sdattr is only 16 bit */
10894 +#define REISERFS_IXUNLINK_FL  (FS_IXUNLINK_FL >> 16)
10895 +#define REISERFS_BARRIER_FL   (FS_BARRIER_FL >> 16)
10896 +#define REISERFS_COW_FL       (FS_COW_FL >> 16)
10897 +
10898  /* persistent flags that file inherits from the parent directory */
10899  #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL |        \
10900                                 REISERFS_SYNC_FL |      \
10901 @@ -986,6 +991,9 @@ struct stat_data_v1 {
10902                                 REISERFS_COMPR_FL |     \
10903                                 REISERFS_NOTAIL_FL )
10904  
10905 +#define REISERFS_FL_USER_VISIBLE       0x80FF
10906 +#define REISERFS_FL_USER_MODIFIABLE    0x80FF
10907 +
10908  /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10909     address blocks) */
10910  struct stat_data {
10911 @@ -2071,6 +2079,7 @@ static inline void reiserfs_update_sd(st
10912  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10913  void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10914  int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10915 +int reiserfs_sync_flags(struct inode *inode, int, int);
10916  
10917  /* namei.c */
10918  void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
10919 diff -NurpP --minimal linux-2.6.33.1/include/linux/reiserfs_fs_sb.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/reiserfs_fs_sb.h
10920 --- linux-2.6.33.1/include/linux/reiserfs_fs_sb.h       2010-02-25 11:52:07.000000000 +0100
10921 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/reiserfs_fs_sb.h       2010-02-25 12:02:16.000000000 +0100
10922 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
10923         REISERFS_EXPOSE_PRIVROOT,
10924         REISERFS_BARRIER_NONE,
10925         REISERFS_BARRIER_FLUSH,
10926 +       REISERFS_TAGGED,
10927  
10928         /* Actions on error */
10929         REISERFS_ERROR_PANIC,
10930 diff -NurpP --minimal linux-2.6.33.1/include/linux/sched.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/sched.h
10931 --- linux-2.6.33.1/include/linux/sched.h        2010-03-18 16:25:15.000000000 +0100
10932 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/sched.h        2010-03-18 17:24:08.000000000 +0100
10933 @@ -401,25 +401,28 @@ static inline void arch_pick_mmap_layout
10934   * The mm counters are not protected by its page_table_lock,
10935   * so must be incremented atomically.
10936   */
10937 -#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value)
10938 -#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member))
10939 -#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member)
10940 -#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
10941 -#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
10942 +#define __set_mm_counter(mm, member, value) \
10943 +       atomic_long_set(&(mm)->_##member, value)
10944 +#define get_mm_counter(mm, member) \
10945 +       ((unsigned long)atomic_long_read(&(mm)->_##member))
10946  
10947  #else  /* !USE_SPLIT_PTLOCKS */
10948  /*
10949   * The mm counters are protected by its page_table_lock,
10950   * so can be incremented directly.
10951   */
10952 -#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
10953 +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value)
10954  #define get_mm_counter(mm, member) ((mm)->_##member)
10955 -#define add_mm_counter(mm, member, value) (mm)->_##member += (value)
10956 -#define inc_mm_counter(mm, member) (mm)->_##member++
10957 -#define dec_mm_counter(mm, member) (mm)->_##member--
10958  
10959  #endif /* !USE_SPLIT_PTLOCKS */
10960  
10961 +#define set_mm_counter(mm, member, value) \
10962 +       vx_ ## member ## pages_sub((mm), (get_mm_counter(mm, member) - value))
10963 +#define add_mm_counter(mm, member, value) \
10964 +       vx_ ## member ## pages_add((mm), (value))
10965 +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm))
10966 +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm))
10967 +
10968  #define get_mm_rss(mm)                                 \
10969         (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
10970  #define update_hiwater_rss(mm) do {                    \
10971 @@ -1415,6 +1418,14 @@ struct task_struct {
10972  #endif
10973         seccomp_t seccomp;
10974  
10975 +/* vserver context data */
10976 +       struct vx_info *vx_info;
10977 +       struct nx_info *nx_info;
10978 +
10979 +       xid_t xid;
10980 +       nid_t nid;
10981 +       tag_t tag;
10982 +
10983  /* Thread group tracking */
10984         u32 parent_exec_id;
10985         u32 self_exec_id;
10986 @@ -1648,6 +1659,11 @@ struct pid_namespace;
10987  pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
10988                         struct pid_namespace *ns);
10989  
10990 +#include <linux/vserver/base.h>
10991 +#include <linux/vserver/context.h>
10992 +#include <linux/vserver/debug.h>
10993 +#include <linux/vserver/pid.h>
10994 +
10995  static inline pid_t task_pid_nr(struct task_struct *tsk)
10996  {
10997         return tsk->pid;
10998 @@ -1661,7 +1677,8 @@ static inline pid_t task_pid_nr_ns(struc
10999  
11000  static inline pid_t task_pid_vnr(struct task_struct *tsk)
11001  {
11002 -       return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
11003 +       // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
11004 +       return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
11005  }
11006  
11007  
11008 @@ -1674,7 +1691,7 @@ pid_t task_tgid_nr_ns(struct task_struct
11009  
11010  static inline pid_t task_tgid_vnr(struct task_struct *tsk)
11011  {
11012 -       return pid_vnr(task_tgid(tsk));
11013 +       return vx_map_tgid(pid_vnr(task_tgid(tsk)));
11014  }
11015  
11016  
11017 diff -NurpP --minimal linux-2.6.33.1/include/linux/shmem_fs.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/shmem_fs.h
11018 --- linux-2.6.33.1/include/linux/shmem_fs.h     2010-02-25 11:52:08.000000000 +0100
11019 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/shmem_fs.h     2010-02-25 12:02:16.000000000 +0100
11020 @@ -8,6 +8,9 @@
11021  
11022  #define SHMEM_NR_DIRECT 16
11023  
11024 +#define TMPFS_SUPER_MAGIC      0x01021994
11025 +
11026 +
11027  struct shmem_inode_info {
11028         spinlock_t              lock;
11029         unsigned long           flags;
11030 diff -NurpP --minimal linux-2.6.33.1/include/linux/stat.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/stat.h
11031 --- linux-2.6.33.1/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
11032 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/stat.h 2010-02-25 12:02:16.000000000 +0100
11033 @@ -66,6 +66,7 @@ struct kstat {
11034         unsigned int    nlink;
11035         uid_t           uid;
11036         gid_t           gid;
11037 +       tag_t           tag;
11038         dev_t           rdev;
11039         loff_t          size;
11040         struct timespec  atime;
11041 diff -NurpP --minimal linux-2.6.33.1/include/linux/sunrpc/auth.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/sunrpc/auth.h
11042 --- linux-2.6.33.1/include/linux/sunrpc/auth.h  2009-12-03 20:02:56.000000000 +0100
11043 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/sunrpc/auth.h  2010-02-25 12:02:16.000000000 +0100
11044 @@ -25,6 +25,7 @@
11045  struct auth_cred {
11046         uid_t   uid;
11047         gid_t   gid;
11048 +       tag_t   tag;
11049         struct group_info *group_info;
11050         unsigned char machine_cred : 1;
11051  };
11052 diff -NurpP --minimal linux-2.6.33.1/include/linux/sunrpc/clnt.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/sunrpc/clnt.h
11053 --- linux-2.6.33.1/include/linux/sunrpc/clnt.h  2009-12-03 20:02:56.000000000 +0100
11054 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/sunrpc/clnt.h  2010-02-25 12:02:16.000000000 +0100
11055 @@ -49,7 +49,8 @@ struct rpc_clnt {
11056         unsigned int            cl_softrtry : 1,/* soft timeouts */
11057                                 cl_discrtry : 1,/* disconnect before retry */
11058                                 cl_autobind : 1,/* use getport() */
11059 -                               cl_chatty   : 1;/* be verbose */
11060 +                               cl_chatty   : 1,/* be verbose */
11061 +                               cl_tag      : 1;/* context tagging */
11062  
11063         struct rpc_rtt *        cl_rtt;         /* RTO estimator data */
11064         const struct rpc_timeout *cl_timeout;   /* Timeout strategy */
11065 diff -NurpP --minimal linux-2.6.33.1/include/linux/syscalls.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/syscalls.h
11066 --- linux-2.6.33.1/include/linux/syscalls.h     2010-03-18 16:25:15.000000000 +0100
11067 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/syscalls.h     2010-03-18 16:54:29.000000000 +0100
11068 @@ -498,6 +498,8 @@ asmlinkage long sys_symlink(const char _
11069  asmlinkage long sys_unlink(const char __user *pathname);
11070  asmlinkage long sys_rename(const char __user *oldname,
11071                                 const char __user *newname);
11072 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
11073 +                               umode_t mode);
11074  asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
11075  asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
11076  
11077 diff -NurpP --minimal linux-2.6.33.1/include/linux/sysctl.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/sysctl.h
11078 --- linux-2.6.33.1/include/linux/sysctl.h       2010-02-25 11:52:08.000000000 +0100
11079 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/sysctl.h       2010-02-25 12:02:16.000000000 +0100
11080 @@ -60,6 +60,7 @@ enum
11081         CTL_ABI=9,              /* Binary emulation */
11082         CTL_CPU=10,             /* CPU stuff (speed scaling, etc) */
11083         CTL_ARLAN=254,          /* arlan wireless driver */
11084 +       CTL_VSERVER=4242,       /* Linux-VServer debug */
11085         CTL_S390DBF=5677,       /* s390 debug */
11086         CTL_SUNRPC=7249,        /* sunrpc debug */
11087         CTL_PM=9899,            /* frv power management */
11088 @@ -94,6 +95,7 @@ enum
11089  
11090         KERN_PANIC=15,          /* int: panic timeout */
11091         KERN_REALROOTDEV=16,    /* real root device to mount after initrd */
11092 +       KERN_VSHELPER=17,       /* string: path to vshelper policy agent */
11093  
11094         KERN_SPARC_REBOOT=21,   /* reboot command on Sparc */
11095         KERN_CTLALTDEL=22,      /* int: allow ctl-alt-del to reboot */
11096 diff -NurpP --minimal linux-2.6.33.1/include/linux/sysfs.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/sysfs.h
11097 --- linux-2.6.33.1/include/linux/sysfs.h        2010-02-25 11:52:08.000000000 +0100
11098 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/sysfs.h        2010-02-25 12:02:16.000000000 +0100
11099 @@ -17,6 +17,8 @@
11100  #include <linux/list.h>
11101  #include <asm/atomic.h>
11102  
11103 +#define SYSFS_SUPER_MAGIC      0x62656572
11104 +
11105  struct kobject;
11106  struct module;
11107  
11108 diff -NurpP --minimal linux-2.6.33.1/include/linux/time.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/time.h
11109 --- linux-2.6.33.1/include/linux/time.h 2010-02-25 11:52:08.000000000 +0100
11110 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/time.h 2010-02-25 12:02:16.000000000 +0100
11111 @@ -238,6 +238,9 @@ static __always_inline void timespec_add
11112         a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
11113         a->tv_nsec = ns;
11114  }
11115 +
11116 +#include <linux/vs_time.h>
11117 +
11118  #endif /* __KERNEL__ */
11119  
11120  #define NFDBITS                        __NFDBITS
11121 diff -NurpP --minimal linux-2.6.33.1/include/linux/types.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/types.h
11122 --- linux-2.6.33.1/include/linux/types.h        2009-09-10 15:26:26.000000000 +0200
11123 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/types.h        2010-02-25 12:02:16.000000000 +0100
11124 @@ -37,6 +37,9 @@ typedef __kernel_uid32_t      uid_t;
11125  typedef __kernel_gid32_t       gid_t;
11126  typedef __kernel_uid16_t        uid16_t;
11127  typedef __kernel_gid16_t        gid16_t;
11128 +typedef unsigned int           xid_t;
11129 +typedef unsigned int           nid_t;
11130 +typedef unsigned int           tag_t;
11131  
11132  typedef unsigned long          uintptr_t;
11133  
11134 diff -NurpP --minimal linux-2.6.33.1/include/linux/vroot.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vroot.h
11135 --- linux-2.6.33.1/include/linux/vroot.h        1970-01-01 01:00:00.000000000 +0100
11136 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vroot.h        2010-02-25 12:02:16.000000000 +0100
11137 @@ -0,0 +1,51 @@
11138 +
11139 +/*
11140 + * include/linux/vroot.h
11141 + *
11142 + * written by Herbert Pötzl, 9/11/2002
11143 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
11144 + *
11145 + * Copyright (C) 2002-2007 by Herbert Pötzl.
11146 + * Redistribution of this file is permitted under the
11147 + * GNU General Public License.
11148 + */
11149 +
11150 +#ifndef _LINUX_VROOT_H
11151 +#define _LINUX_VROOT_H
11152 +
11153 +
11154 +#ifdef __KERNEL__
11155 +
11156 +/* Possible states of device */
11157 +enum {
11158 +       Vr_unbound,
11159 +       Vr_bound,
11160 +};
11161 +
11162 +struct vroot_device {
11163 +       int             vr_number;
11164 +       int             vr_refcnt;
11165 +
11166 +       struct semaphore        vr_ctl_mutex;
11167 +       struct block_device    *vr_device;
11168 +       int                     vr_state;
11169 +};
11170 +
11171 +
11172 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
11173 +
11174 +extern int register_vroot_grb(vroot_grb_func *);
11175 +extern int unregister_vroot_grb(vroot_grb_func *);
11176 +
11177 +#endif /* __KERNEL__ */
11178 +
11179 +#define MAX_VROOT_DEFAULT      8
11180 +
11181 +/*
11182 + * IOCTL commands --- we will commandeer 0x56 ('V')
11183 + */
11184 +
11185 +#define VROOT_SET_DEV          0x5600
11186 +#define VROOT_CLR_DEV          0x5601
11187 +
11188 +#endif /* _LINUX_VROOT_H */
11189 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_base.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_base.h
11190 --- linux-2.6.33.1/include/linux/vs_base.h      1970-01-01 01:00:00.000000000 +0100
11191 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_base.h      2010-02-25 12:02:16.000000000 +0100
11192 @@ -0,0 +1,10 @@
11193 +#ifndef _VS_BASE_H
11194 +#define _VS_BASE_H
11195 +
11196 +#include "vserver/base.h"
11197 +#include "vserver/check.h"
11198 +#include "vserver/debug.h"
11199 +
11200 +#else
11201 +#warning duplicate inclusion
11202 +#endif
11203 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_context.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_context.h
11204 --- linux-2.6.33.1/include/linux/vs_context.h   1970-01-01 01:00:00.000000000 +0100
11205 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_context.h   2010-02-25 12:02:16.000000000 +0100
11206 @@ -0,0 +1,242 @@
11207 +#ifndef _VS_CONTEXT_H
11208 +#define _VS_CONTEXT_H
11209 +
11210 +#include "vserver/base.h"
11211 +#include "vserver/check.h"
11212 +#include "vserver/context.h"
11213 +#include "vserver/history.h"
11214 +#include "vserver/debug.h"
11215 +
11216 +#include <linux/sched.h>
11217 +
11218 +
11219 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
11220 +
11221 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
11222 +       const char *_file, int _line, void *_here)
11223 +{
11224 +       if (!vxi)
11225 +               return NULL;
11226 +
11227 +       vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
11228 +               vxi, vxi ? vxi->vx_id : 0,
11229 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11230 +               _file, _line);
11231 +       __vxh_get_vx_info(vxi, _here);
11232 +
11233 +       atomic_inc(&vxi->vx_usecnt);
11234 +       return vxi;
11235 +}
11236 +
11237 +
11238 +extern void free_vx_info(struct vx_info *);
11239 +
11240 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
11241 +
11242 +static inline void __put_vx_info(struct vx_info *vxi,
11243 +       const char *_file, int _line, void *_here)
11244 +{
11245 +       if (!vxi)
11246 +               return;
11247 +
11248 +       vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
11249 +               vxi, vxi ? vxi->vx_id : 0,
11250 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11251 +               _file, _line);
11252 +       __vxh_put_vx_info(vxi, _here);
11253 +
11254 +       if (atomic_dec_and_test(&vxi->vx_usecnt))
11255 +               free_vx_info(vxi);
11256 +}
11257 +
11258 +
11259 +#define init_vx_info(p, i) \
11260 +       __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11261 +
11262 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11263 +       const char *_file, int _line, void *_here)
11264 +{
11265 +       if (vxi) {
11266 +               vxlprintk(VXD_CBIT(xid, 3),
11267 +                       "init_vx_info(%p[#%d.%d])",
11268 +                       vxi, vxi ? vxi->vx_id : 0,
11269 +                       vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11270 +                       _file, _line);
11271 +               __vxh_init_vx_info(vxi, vxp, _here);
11272 +
11273 +               atomic_inc(&vxi->vx_usecnt);
11274 +       }
11275 +       *vxp = vxi;
11276 +}
11277 +
11278 +
11279 +#define set_vx_info(p, i) \
11280 +       __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11281 +
11282 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11283 +       const char *_file, int _line, void *_here)
11284 +{
11285 +       struct vx_info *vxo;
11286 +
11287 +       if (!vxi)
11288 +               return;
11289 +
11290 +       vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
11291 +               vxi, vxi ? vxi->vx_id : 0,
11292 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11293 +               _file, _line);
11294 +       __vxh_set_vx_info(vxi, vxp, _here);
11295 +
11296 +       atomic_inc(&vxi->vx_usecnt);
11297 +       vxo = xchg(vxp, vxi);
11298 +       BUG_ON(vxo);
11299 +}
11300 +
11301 +
11302 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
11303 +
11304 +static inline void __clr_vx_info(struct vx_info **vxp,
11305 +       const char *_file, int _line, void *_here)
11306 +{
11307 +       struct vx_info *vxo;
11308 +
11309 +       vxo = xchg(vxp, NULL);
11310 +       if (!vxo)
11311 +               return;
11312 +
11313 +       vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
11314 +               vxo, vxo ? vxo->vx_id : 0,
11315 +               vxo ? atomic_read(&vxo->vx_usecnt) : 0,
11316 +               _file, _line);
11317 +       __vxh_clr_vx_info(vxo, vxp, _here);
11318 +
11319 +       if (atomic_dec_and_test(&vxo->vx_usecnt))
11320 +               free_vx_info(vxo);
11321 +}
11322 +
11323 +
11324 +#define claim_vx_info(v, p) \
11325 +       __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11326 +
11327 +static inline void __claim_vx_info(struct vx_info *vxi,
11328 +       struct task_struct *task,
11329 +       const char *_file, int _line, void *_here)
11330 +{
11331 +       vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
11332 +               vxi, vxi ? vxi->vx_id : 0,
11333 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11334 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11335 +               task, _file, _line);
11336 +       __vxh_claim_vx_info(vxi, task, _here);
11337 +
11338 +       atomic_inc(&vxi->vx_tasks);
11339 +}
11340 +
11341 +
11342 +extern void unhash_vx_info(struct vx_info *);
11343 +
11344 +#define release_vx_info(v, p) \
11345 +       __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11346 +
11347 +static inline void __release_vx_info(struct vx_info *vxi,
11348 +       struct task_struct *task,
11349 +       const char *_file, int _line, void *_here)
11350 +{
11351 +       vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
11352 +               vxi, vxi ? vxi->vx_id : 0,
11353 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11354 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11355 +               task, _file, _line);
11356 +       __vxh_release_vx_info(vxi, task, _here);
11357 +
11358 +       might_sleep();
11359 +
11360 +       if (atomic_dec_and_test(&vxi->vx_tasks))
11361 +               unhash_vx_info(vxi);
11362 +}
11363 +
11364 +
11365 +#define task_get_vx_info(p) \
11366 +       __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
11367 +
11368 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
11369 +       const char *_file, int _line, void *_here)
11370 +{
11371 +       struct vx_info *vxi;
11372 +
11373 +       task_lock(p);
11374 +       vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
11375 +               p, _file, _line);
11376 +       vxi = __get_vx_info(p->vx_info, _file, _line, _here);
11377 +       task_unlock(p);
11378 +       return vxi;
11379 +}
11380 +
11381 +
11382 +static inline void __wakeup_vx_info(struct vx_info *vxi)
11383 +{
11384 +       if (waitqueue_active(&vxi->vx_wait))
11385 +               wake_up_interruptible(&vxi->vx_wait);
11386 +}
11387 +
11388 +
11389 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
11390 +
11391 +static inline void __enter_vx_info(struct vx_info *vxi,
11392 +       struct vx_info_save *vxis, const char *_file, int _line)
11393 +{
11394 +       vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
11395 +               vxi, vxi ? vxi->vx_id : 0, vxis, current,
11396 +               current->xid, current->vx_info, _file, _line);
11397 +       vxis->vxi = xchg(&current->vx_info, vxi);
11398 +       vxis->xid = current->xid;
11399 +       current->xid = vxi ? vxi->vx_id : 0;
11400 +}
11401 +
11402 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
11403 +
11404 +static inline void __leave_vx_info(struct vx_info_save *vxis,
11405 +       const char *_file, int _line)
11406 +{
11407 +       vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
11408 +               vxis, vxis->xid, vxis->vxi, current,
11409 +               current->xid, current->vx_info, _file, _line);
11410 +       (void)xchg(&current->vx_info, vxis->vxi);
11411 +       current->xid = vxis->xid;
11412 +}
11413 +
11414 +
11415 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
11416 +{
11417 +       vxis->vxi = xchg(&current->vx_info, NULL);
11418 +       vxis->xid = xchg(&current->xid, (xid_t)0);
11419 +}
11420 +
11421 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
11422 +{
11423 +       (void)xchg(&current->xid, vxis->xid);
11424 +       (void)xchg(&current->vx_info, vxis->vxi);
11425 +}
11426 +
11427 +#define task_is_init(p) \
11428 +       __task_is_init(p, __FILE__, __LINE__, __HERE__)
11429 +
11430 +static inline int __task_is_init(struct task_struct *p,
11431 +       const char *_file, int _line, void *_here)
11432 +{
11433 +       int is_init = is_global_init(p);
11434 +
11435 +       task_lock(p);
11436 +       if (p->vx_info)
11437 +               is_init = p->vx_info->vx_initpid == p->pid;
11438 +       task_unlock(p);
11439 +       return is_init;
11440 +}
11441 +
11442 +extern void exit_vx_info(struct task_struct *, int);
11443 +extern void exit_vx_info_early(struct task_struct *, int);
11444 +
11445 +
11446 +#else
11447 +#warning duplicate inclusion
11448 +#endif
11449 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_cowbl.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_cowbl.h
11450 --- linux-2.6.33.1/include/linux/vs_cowbl.h     1970-01-01 01:00:00.000000000 +0100
11451 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_cowbl.h     2010-02-25 12:02:16.000000000 +0100
11452 @@ -0,0 +1,47 @@
11453 +#ifndef _VS_COWBL_H
11454 +#define _VS_COWBL_H
11455 +
11456 +#include <linux/fs.h>
11457 +#include <linux/dcache.h>
11458 +#include <linux/namei.h>
11459 +
11460 +extern struct dentry *cow_break_link(const char *pathname);
11461 +
11462 +static inline int cow_check_and_break(struct path *path)
11463 +{
11464 +       struct inode *inode = path->dentry->d_inode;
11465 +       int error = 0;
11466 +
11467 +       /* do we need this check? */
11468 +       if (IS_RDONLY(inode))
11469 +               return -EROFS;
11470 +
11471 +       if (IS_COW(inode)) {
11472 +               if (IS_COW_LINK(inode)) {
11473 +                       struct dentry *new_dentry, *old_dentry = path->dentry;
11474 +                       char *pp, *buf;
11475 +
11476 +                       buf = kmalloc(PATH_MAX, GFP_KERNEL);
11477 +                       if (!buf) {
11478 +                               return -ENOMEM;
11479 +                       }
11480 +                       pp = d_path(path, buf, PATH_MAX);
11481 +                       new_dentry = cow_break_link(pp);
11482 +                       kfree(buf);
11483 +                       if (!IS_ERR(new_dentry)) {
11484 +                               path->dentry = new_dentry;
11485 +                               dput(old_dentry);
11486 +                       } else
11487 +                               error = PTR_ERR(new_dentry);
11488 +               } else {
11489 +                       inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
11490 +                       inode->i_ctime = CURRENT_TIME;
11491 +                       mark_inode_dirty(inode);
11492 +               }
11493 +       }
11494 +       return error;
11495 +}
11496 +
11497 +#else
11498 +#warning duplicate inclusion
11499 +#endif
11500 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_cvirt.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_cvirt.h
11501 --- linux-2.6.33.1/include/linux/vs_cvirt.h     1970-01-01 01:00:00.000000000 +0100
11502 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_cvirt.h     2010-02-25 12:02:16.000000000 +0100
11503 @@ -0,0 +1,50 @@
11504 +#ifndef _VS_CVIRT_H
11505 +#define _VS_CVIRT_H
11506 +
11507 +#include "vserver/cvirt.h"
11508 +#include "vserver/context.h"
11509 +#include "vserver/base.h"
11510 +#include "vserver/check.h"
11511 +#include "vserver/debug.h"
11512 +
11513 +
11514 +static inline void vx_activate_task(struct task_struct *p)
11515 +{
11516 +       struct vx_info *vxi;
11517 +
11518 +       if ((vxi = p->vx_info)) {
11519 +               vx_update_load(vxi);
11520 +               atomic_inc(&vxi->cvirt.nr_running);
11521 +       }
11522 +}
11523 +
11524 +static inline void vx_deactivate_task(struct task_struct *p)
11525 +{
11526 +       struct vx_info *vxi;
11527 +
11528 +       if ((vxi = p->vx_info)) {
11529 +               vx_update_load(vxi);
11530 +               atomic_dec(&vxi->cvirt.nr_running);
11531 +       }
11532 +}
11533 +
11534 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11535 +{
11536 +       struct vx_info *vxi;
11537 +
11538 +       if ((vxi = p->vx_info))
11539 +               atomic_inc(&vxi->cvirt.nr_uninterruptible);
11540 +}
11541 +
11542 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11543 +{
11544 +       struct vx_info *vxi;
11545 +
11546 +       if ((vxi = p->vx_info))
11547 +               atomic_dec(&vxi->cvirt.nr_uninterruptible);
11548 +}
11549 +
11550 +
11551 +#else
11552 +#warning duplicate inclusion
11553 +#endif
11554 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_device.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_device.h
11555 --- linux-2.6.33.1/include/linux/vs_device.h    1970-01-01 01:00:00.000000000 +0100
11556 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_device.h    2010-02-25 12:02:16.000000000 +0100
11557 @@ -0,0 +1,45 @@
11558 +#ifndef _VS_DEVICE_H
11559 +#define _VS_DEVICE_H
11560 +
11561 +#include "vserver/base.h"
11562 +#include "vserver/device.h"
11563 +#include "vserver/debug.h"
11564 +
11565 +
11566 +#ifdef CONFIG_VSERVER_DEVICE
11567 +
11568 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
11569 +
11570 +#define vs_device_perm(v, d, m, p) \
11571 +       ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
11572 +
11573 +#else
11574 +
11575 +static inline
11576 +int vs_map_device(struct vx_info *vxi,
11577 +       dev_t device, dev_t *target, umode_t mode)
11578 +{
11579 +       if (target)
11580 +               *target = device;
11581 +       return ~0;
11582 +}
11583 +
11584 +#define vs_device_perm(v, d, m, p) ((p) == (p))
11585 +
11586 +#endif
11587 +
11588 +
11589 +#define vs_map_chrdev(d, t, p) \
11590 +       ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
11591 +#define vs_map_blkdev(d, t, p) \
11592 +       ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
11593 +
11594 +#define vs_chrdev_perm(d, p) \
11595 +       vs_device_perm(current_vx_info(), d, S_IFCHR, p)
11596 +#define vs_blkdev_perm(d, p) \
11597 +       vs_device_perm(current_vx_info(), d, S_IFBLK, p)
11598 +
11599 +
11600 +#else
11601 +#warning duplicate inclusion
11602 +#endif
11603 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_dlimit.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_dlimit.h
11604 --- linux-2.6.33.1/include/linux/vs_dlimit.h    1970-01-01 01:00:00.000000000 +0100
11605 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_dlimit.h    2010-03-21 06:38:55.000000000 +0100
11606 @@ -0,0 +1,215 @@
11607 +#ifndef _VS_DLIMIT_H
11608 +#define _VS_DLIMIT_H
11609 +
11610 +#include <linux/fs.h>
11611 +
11612 +#include "vserver/dlimit.h"
11613 +#include "vserver/base.h"
11614 +#include "vserver/debug.h"
11615 +
11616 +
11617 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11618 +
11619 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11620 +       const char *_file, int _line)
11621 +{
11622 +       if (!dli)
11623 +               return NULL;
11624 +       vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11625 +               dli, dli ? dli->dl_tag : 0,
11626 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11627 +               _file, _line);
11628 +       atomic_inc(&dli->dl_usecnt);
11629 +       return dli;
11630 +}
11631 +
11632 +
11633 +#define free_dl_info(i) \
11634 +       call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11635 +
11636 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11637 +
11638 +static inline void __put_dl_info(struct dl_info *dli,
11639 +       const char *_file, int _line)
11640 +{
11641 +       if (!dli)
11642 +               return;
11643 +       vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11644 +               dli, dli ? dli->dl_tag : 0,
11645 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11646 +               _file, _line);
11647 +       if (atomic_dec_and_test(&dli->dl_usecnt))
11648 +               free_dl_info(dli);
11649 +}
11650 +
11651 +
11652 +#define __dlimit_char(d)       ((d) ? '*' : ' ')
11653 +
11654 +static inline int __dl_alloc_space(struct super_block *sb,
11655 +       tag_t tag, dlsize_t nr, const char *file, int line)
11656 +{
11657 +       struct dl_info *dli = NULL;
11658 +       int ret = 0;
11659 +
11660 +       if (nr == 0)
11661 +               goto out;
11662 +       dli = locate_dl_info(sb, tag);
11663 +       if (!dli)
11664 +               goto out;
11665 +
11666 +       spin_lock(&dli->dl_lock);
11667 +       ret = (dli->dl_space_used + nr > dli->dl_space_total);
11668 +       if (!ret)
11669 +               dli->dl_space_used += nr;
11670 +       spin_unlock(&dli->dl_lock);
11671 +       put_dl_info(dli);
11672 +out:
11673 +       vxlprintk(VXD_CBIT(dlim, 1),
11674 +               "ALLOC (%p,#%d)%c %lld bytes (%d)",
11675 +               sb, tag, __dlimit_char(dli), (long long)nr,
11676 +               ret, file, line);
11677 +       return ret;
11678 +}
11679 +
11680 +static inline void __dl_free_space(struct super_block *sb,
11681 +       tag_t tag, dlsize_t nr, const char *_file, int _line)
11682 +{
11683 +       struct dl_info *dli = NULL;
11684 +
11685 +       if (nr == 0)
11686 +               goto out;
11687 +       dli = locate_dl_info(sb, tag);
11688 +       if (!dli)
11689 +               goto out;
11690 +
11691 +       spin_lock(&dli->dl_lock);
11692 +       if (dli->dl_space_used > nr)
11693 +               dli->dl_space_used -= nr;
11694 +       else
11695 +               dli->dl_space_used = 0;
11696 +       spin_unlock(&dli->dl_lock);
11697 +       put_dl_info(dli);
11698 +out:
11699 +       vxlprintk(VXD_CBIT(dlim, 1),
11700 +               "FREE  (%p,#%d)%c %lld bytes",
11701 +               sb, tag, __dlimit_char(dli), (long long)nr,
11702 +               _file, _line);
11703 +}
11704 +
11705 +static inline int __dl_alloc_inode(struct super_block *sb,
11706 +       tag_t tag, const char *_file, int _line)
11707 +{
11708 +       struct dl_info *dli;
11709 +       int ret = 0;
11710 +
11711 +       dli = locate_dl_info(sb, tag);
11712 +       if (!dli)
11713 +               goto out;
11714 +
11715 +       spin_lock(&dli->dl_lock);
11716 +       dli->dl_inodes_used++;
11717 +       ret = (dli->dl_inodes_used > dli->dl_inodes_total);
11718 +       spin_unlock(&dli->dl_lock);
11719 +       put_dl_info(dli);
11720 +out:
11721 +       vxlprintk(VXD_CBIT(dlim, 0),
11722 +               "ALLOC (%p,#%d)%c inode (%d)",
11723 +               sb, tag, __dlimit_char(dli), ret, _file, _line);
11724 +       return ret;
11725 +}
11726 +
11727 +static inline void __dl_free_inode(struct super_block *sb,
11728 +       tag_t tag, const char *_file, int _line)
11729 +{
11730 +       struct dl_info *dli;
11731 +
11732 +       dli = locate_dl_info(sb, tag);
11733 +       if (!dli)
11734 +               goto out;
11735 +
11736 +       spin_lock(&dli->dl_lock);
11737 +       if (dli->dl_inodes_used > 1)
11738 +               dli->dl_inodes_used--;
11739 +       else
11740 +               dli->dl_inodes_used = 0;
11741 +       spin_unlock(&dli->dl_lock);
11742 +       put_dl_info(dli);
11743 +out:
11744 +       vxlprintk(VXD_CBIT(dlim, 0),
11745 +               "FREE  (%p,#%d)%c inode",
11746 +               sb, tag, __dlimit_char(dli), _file, _line);
11747 +}
11748 +
11749 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11750 +       unsigned long long *free_blocks, unsigned long long *root_blocks,
11751 +       const char *_file, int _line)
11752 +{
11753 +       struct dl_info *dli;
11754 +       uint64_t broot, bfree;
11755 +
11756 +       dli = locate_dl_info(sb, tag);
11757 +       if (!dli)
11758 +               return;
11759 +
11760 +       spin_lock(&dli->dl_lock);
11761 +       broot = (dli->dl_space_total -
11762 +               (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11763 +               >> sb->s_blocksize_bits;
11764 +       bfree = (dli->dl_space_total - dli->dl_space_used)
11765 +                       >> sb->s_blocksize_bits;
11766 +       spin_unlock(&dli->dl_lock);
11767 +
11768 +       vxlprintk(VXD_CBIT(dlim, 2),
11769 +               "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11770 +               (long long)bfree, (long long)broot,
11771 +               *free_blocks, *root_blocks, dli->dl_nrlmult,
11772 +               _file, _line);
11773 +       if (free_blocks) {
11774 +               if (*free_blocks > bfree)
11775 +                       *free_blocks = bfree;
11776 +       }
11777 +       if (root_blocks) {
11778 +               if (*root_blocks > broot)
11779 +                       *root_blocks = broot;
11780 +       }
11781 +       put_dl_info(dli);
11782 +}
11783 +
11784 +#define dl_prealloc_space(in, bytes) \
11785 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11786 +               __FILE__, __LINE__ )
11787 +
11788 +#define dl_alloc_space(in, bytes) \
11789 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11790 +               __FILE__, __LINE__ )
11791 +
11792 +#define dl_reserve_space(in, bytes) \
11793 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11794 +               __FILE__, __LINE__ )
11795 +
11796 +#define dl_claim_space(in, bytes) (0)
11797 +
11798 +#define dl_release_space(in, bytes) \
11799 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11800 +               __FILE__, __LINE__ )
11801 +
11802 +#define dl_free_space(in, bytes) \
11803 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11804 +               __FILE__, __LINE__ )
11805 +
11806 +
11807 +
11808 +#define dl_alloc_inode(in) \
11809 +       __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11810 +
11811 +#define dl_free_inode(in) \
11812 +       __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11813 +
11814 +
11815 +#define dl_adjust_block(sb, tag, fb, rb) \
11816 +       __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11817 +
11818 +
11819 +#else
11820 +#warning duplicate inclusion
11821 +#endif
11822 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/base.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/base.h
11823 --- linux-2.6.33.1/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11824 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/base.h 2010-02-25 12:02:16.000000000 +0100
11825 @@ -0,0 +1,170 @@
11826 +#ifndef _VX_BASE_H
11827 +#define _VX_BASE_H
11828 +
11829 +
11830 +/* context state changes */
11831 +
11832 +enum {
11833 +       VSC_STARTUP = 1,
11834 +       VSC_SHUTDOWN,
11835 +
11836 +       VSC_NETUP,
11837 +       VSC_NETDOWN,
11838 +};
11839 +
11840 +
11841 +
11842 +#define vx_task_xid(t) ((t)->xid)
11843 +
11844 +#define vx_current_xid() vx_task_xid(current)
11845 +
11846 +#define current_vx_info() (current->vx_info)
11847 +
11848 +
11849 +#define nx_task_nid(t) ((t)->nid)
11850 +
11851 +#define nx_current_nid() nx_task_nid(current)
11852 +
11853 +#define current_nx_info() (current->nx_info)
11854 +
11855 +
11856 +/* generic flag merging */
11857 +
11858 +#define vs_check_flags(v, m, f)        (((v) & (m)) ^ (f))
11859 +
11860 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11861 +
11862 +#define vs_mask_mask(v, f, m)  (((v) & ~(m)) | ((v) & (f) & (m)))
11863 +
11864 +#define vs_check_bit(v, n)     ((v) & (1LL << (n)))
11865 +
11866 +
11867 +/* context flags */
11868 +
11869 +#define __vx_flags(v)  ((v) ? (v)->vx_flags : 0)
11870 +
11871 +#define vx_current_flags()     __vx_flags(current_vx_info())
11872 +
11873 +#define vx_info_flags(v, m, f) \
11874 +       vs_check_flags(__vx_flags(v), m, f)
11875 +
11876 +#define task_vx_flags(t, m, f) \
11877 +       ((t) && vx_info_flags((t)->vx_info, m, f))
11878 +
11879 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11880 +
11881 +
11882 +/* context caps */
11883 +
11884 +#define __vx_ccaps(v)  ((v) ? (v)->vx_ccaps : 0)
11885 +
11886 +#define vx_current_ccaps()     __vx_ccaps(current_vx_info())
11887 +
11888 +#define vx_info_ccaps(v, c)    (__vx_ccaps(v) & (c))
11889 +
11890 +#define vx_ccaps(c)    vx_info_ccaps(current_vx_info(), (c))
11891 +
11892 +
11893 +
11894 +/* network flags */
11895 +
11896 +#define __nx_flags(n)  ((n) ? (n)->nx_flags : 0)
11897 +
11898 +#define nx_current_flags()     __nx_flags(current_nx_info())
11899 +
11900 +#define nx_info_flags(n, m, f) \
11901 +       vs_check_flags(__nx_flags(n), m, f)
11902 +
11903 +#define task_nx_flags(t, m, f) \
11904 +       ((t) && nx_info_flags((t)->nx_info, m, f))
11905 +
11906 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11907 +
11908 +
11909 +/* network caps */
11910 +
11911 +#define __nx_ncaps(n)  ((n) ? (n)->nx_ncaps : 0)
11912 +
11913 +#define nx_current_ncaps()     __nx_ncaps(current_nx_info())
11914 +
11915 +#define nx_info_ncaps(n, c)    (__nx_ncaps(n) & (c))
11916 +
11917 +#define nx_ncaps(c)    nx_info_ncaps(current_nx_info(), c)
11918 +
11919 +
11920 +/* context mask capabilities */
11921 +
11922 +#define __vx_mcaps(v)  ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11923 +
11924 +#define vx_info_mcaps(v, c)    (__vx_mcaps(v) & (c))
11925 +
11926 +#define vx_mcaps(c)    vx_info_mcaps(current_vx_info(), c)
11927 +
11928 +
11929 +/* context bcap mask */
11930 +
11931 +#define __vx_bcaps(v)          ((v)->vx_bcaps)
11932 +
11933 +#define vx_current_bcaps()     __vx_bcaps(current_vx_info())
11934 +
11935 +
11936 +/* mask given bcaps */
11937 +
11938 +#define vx_info_mbcaps(v, c)   ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11939 +
11940 +#define vx_mbcaps(c)           vx_info_mbcaps(current_vx_info(), c)
11941 +
11942 +
11943 +/* masked cap_bset */
11944 +
11945 +#define vx_info_cap_bset(v)    vx_info_mbcaps(v, current->cap_bset)
11946 +
11947 +#define vx_current_cap_bset()  vx_info_cap_bset(current_vx_info())
11948 +
11949 +#if 0
11950 +#define vx_info_mbcap(v, b) \
11951 +       (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11952 +       vx_info_bcaps(v, b) : (b))
11953 +
11954 +#define task_vx_mbcap(t, b) \
11955 +       vx_info_mbcap((t)->vx_info, (t)->b)
11956 +
11957 +#define vx_mbcap(b)    task_vx_mbcap(current, b)
11958 +#endif
11959 +
11960 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11961 +
11962 +#define vx_capable(b, c) (capable(b) || \
11963 +       (cap_raised(current_cap(), b) && vx_ccaps(c)))
11964 +
11965 +#define nx_capable(b, c) (capable(b) || \
11966 +       (cap_raised(current_cap(), b) && nx_ncaps(c)))
11967 +
11968 +#define vx_task_initpid(t, n) \
11969 +       ((t)->vx_info && \
11970 +       ((t)->vx_info->vx_initpid == (n)))
11971 +
11972 +#define vx_current_initpid(n)  vx_task_initpid(current, n)
11973 +
11974 +
11975 +/* context unshare mask */
11976 +
11977 +#define __vx_umask(v)          ((v)->vx_umask)
11978 +
11979 +#define vx_current_umask()     __vx_umask(current_vx_info())
11980 +
11981 +#define vx_can_unshare(b, f) (capable(b) || \
11982 +       (cap_raised(current_cap(), b) && \
11983 +       !((f) & ~vx_current_umask())))
11984 +
11985 +
11986 +#define __vx_state(v)  ((v) ? ((v)->vx_state) : 0)
11987 +
11988 +#define vx_info_state(v, m)    (__vx_state(v) & (m))
11989 +
11990 +
11991 +#define __nx_state(n)  ((n) ? ((n)->nx_state) : 0)
11992 +
11993 +#define nx_info_state(n, m)    (__nx_state(n) & (m))
11994 +
11995 +#endif
11996 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/cacct_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cacct_cmd.h
11997 --- linux-2.6.33.1/include/linux/vserver/cacct_cmd.h    1970-01-01 01:00:00.000000000 +0100
11998 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cacct_cmd.h    2010-02-25 12:02:16.000000000 +0100
11999 @@ -0,0 +1,23 @@
12000 +#ifndef _VX_CACCT_CMD_H
12001 +#define _VX_CACCT_CMD_H
12002 +
12003 +
12004 +/* virtual host info name commands */
12005 +
12006 +#define VCMD_sock_stat         VC_CMD(VSTAT, 5, 0)
12007 +
12008 +struct vcmd_sock_stat_v0 {
12009 +       uint32_t field;
12010 +       uint32_t count[3];
12011 +       uint64_t total[3];
12012 +};
12013 +
12014 +
12015 +#ifdef __KERNEL__
12016 +
12017 +#include <linux/compiler.h>
12018 +
12019 +extern int vc_sock_stat(struct vx_info *, void __user *);
12020 +
12021 +#endif /* __KERNEL__ */
12022 +#endif /* _VX_CACCT_CMD_H */
12023 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/cacct_def.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cacct_def.h
12024 --- linux-2.6.33.1/include/linux/vserver/cacct_def.h    1970-01-01 01:00:00.000000000 +0100
12025 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cacct_def.h    2010-02-25 12:02:16.000000000 +0100
12026 @@ -0,0 +1,43 @@
12027 +#ifndef _VX_CACCT_DEF_H
12028 +#define _VX_CACCT_DEF_H
12029 +
12030 +#include <asm/atomic.h>
12031 +#include <linux/vserver/cacct.h>
12032 +
12033 +
12034 +struct _vx_sock_acc {
12035 +       atomic_long_t count;
12036 +       atomic_long_t total;
12037 +};
12038 +
12039 +/* context sub struct */
12040 +
12041 +struct _vx_cacct {
12042 +       struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
12043 +       atomic_t slab[8];
12044 +       atomic_t page[6][8];
12045 +};
12046 +
12047 +#ifdef CONFIG_VSERVER_DEBUG
12048 +
12049 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
12050 +{
12051 +       int i, j;
12052 +
12053 +       printk("\t_vx_cacct:");
12054 +       for (i = 0; i < 6; i++) {
12055 +               struct _vx_sock_acc *ptr = cacct->sock[i];
12056 +
12057 +               printk("\t [%d] =", i);
12058 +               for (j = 0; j < 3; j++) {
12059 +                       printk(" [%d] = %8lu, %8lu", j,
12060 +                               atomic_long_read(&ptr[j].count),
12061 +                               atomic_long_read(&ptr[j].total));
12062 +               }
12063 +               printk("\n");
12064 +       }
12065 +}
12066 +
12067 +#endif
12068 +
12069 +#endif /* _VX_CACCT_DEF_H */
12070 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/cacct.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cacct.h
12071 --- linux-2.6.33.1/include/linux/vserver/cacct.h        1970-01-01 01:00:00.000000000 +0100
12072 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cacct.h        2010-02-25 12:02:16.000000000 +0100
12073 @@ -0,0 +1,15 @@
12074 +#ifndef _VX_CACCT_H
12075 +#define _VX_CACCT_H
12076 +
12077 +
12078 +enum sock_acc_field {
12079 +       VXA_SOCK_UNSPEC = 0,
12080 +       VXA_SOCK_UNIX,
12081 +       VXA_SOCK_INET,
12082 +       VXA_SOCK_INET6,
12083 +       VXA_SOCK_PACKET,
12084 +       VXA_SOCK_OTHER,
12085 +       VXA_SOCK_SIZE   /* array size */
12086 +};
12087 +
12088 +#endif /* _VX_CACCT_H */
12089 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/cacct_int.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cacct_int.h
12090 --- linux-2.6.33.1/include/linux/vserver/cacct_int.h    1970-01-01 01:00:00.000000000 +0100
12091 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cacct_int.h    2010-02-25 12:02:16.000000000 +0100
12092 @@ -0,0 +1,21 @@
12093 +#ifndef _VX_CACCT_INT_H
12094 +#define _VX_CACCT_INT_H
12095 +
12096 +
12097 +#ifdef __KERNEL__
12098 +
12099 +static inline
12100 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
12101 +{
12102 +       return atomic_long_read(&cacct->sock[type][pos].count);
12103 +}
12104 +
12105 +
12106 +static inline
12107 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
12108 +{
12109 +       return atomic_long_read(&cacct->sock[type][pos].total);
12110 +}
12111 +
12112 +#endif /* __KERNEL__ */
12113 +#endif /* _VX_CACCT_INT_H */
12114 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/check.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/check.h
12115 --- linux-2.6.33.1/include/linux/vserver/check.h        1970-01-01 01:00:00.000000000 +0100
12116 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/check.h        2010-02-25 12:02:16.000000000 +0100
12117 @@ -0,0 +1,89 @@
12118 +#ifndef _VS_CHECK_H
12119 +#define _VS_CHECK_H
12120 +
12121 +
12122 +#define MAX_S_CONTEXT  65535   /* Arbitrary limit */
12123 +
12124 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
12125 +#define MIN_D_CONTEXT  49152   /* dynamic contexts start here */
12126 +#else
12127 +#define MIN_D_CONTEXT  65536
12128 +#endif
12129 +
12130 +/* check conditions */
12131 +
12132 +#define VS_ADMIN       0x0001
12133 +#define VS_WATCH       0x0002
12134 +#define VS_HIDE                0x0004
12135 +#define VS_HOSTID      0x0008
12136 +
12137 +#define VS_IDENT       0x0010
12138 +#define VS_EQUIV       0x0020
12139 +#define VS_PARENT      0x0040
12140 +#define VS_CHILD       0x0080
12141 +
12142 +#define VS_ARG_MASK    0x00F0
12143 +
12144 +#define VS_DYNAMIC     0x0100
12145 +#define VS_STATIC      0x0200
12146 +
12147 +#define VS_ATR_MASK    0x0F00
12148 +
12149 +#ifdef CONFIG_VSERVER_PRIVACY
12150 +#define VS_ADMIN_P     (0)
12151 +#define VS_WATCH_P     (0)
12152 +#else
12153 +#define VS_ADMIN_P     VS_ADMIN
12154 +#define VS_WATCH_P     VS_WATCH
12155 +#endif
12156 +
12157 +#define VS_HARDIRQ     0x1000
12158 +#define VS_SOFTIRQ     0x2000
12159 +#define VS_IRQ         0x4000
12160 +
12161 +#define VS_IRQ_MASK    0xF000
12162 +
12163 +#include <linux/hardirq.h>
12164 +
12165 +/*
12166 + * check current context for ADMIN/WATCH and
12167 + * optionally against supplied argument
12168 + */
12169 +static inline int __vs_check(int cid, int id, unsigned int mode)
12170 +{
12171 +       if (mode & VS_ARG_MASK) {
12172 +               if ((mode & VS_IDENT) && (id == cid))
12173 +                       return 1;
12174 +       }
12175 +       if (mode & VS_ATR_MASK) {
12176 +               if ((mode & VS_DYNAMIC) &&
12177 +                       (id >= MIN_D_CONTEXT) &&
12178 +                       (id <= MAX_S_CONTEXT))
12179 +                       return 1;
12180 +               if ((mode & VS_STATIC) &&
12181 +                       (id > 1) && (id < MIN_D_CONTEXT))
12182 +                       return 1;
12183 +       }
12184 +       if (mode & VS_IRQ_MASK) {
12185 +               if ((mode & VS_IRQ) && unlikely(in_interrupt()))
12186 +                       return 1;
12187 +               if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
12188 +                       return 1;
12189 +               if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
12190 +                       return 1;
12191 +       }
12192 +       return (((mode & VS_ADMIN) && (cid == 0)) ||
12193 +               ((mode & VS_WATCH) && (cid == 1)) ||
12194 +               ((mode & VS_HOSTID) && (id == 0)));
12195 +}
12196 +
12197 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
12198 +
12199 +#define vx_weak_check(c, m)    ((m) ? vx_check(c, m) : 1)
12200 +
12201 +
12202 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
12203 +
12204 +#define nx_weak_check(c, m)    ((m) ? nx_check(c, m) : 1)
12205 +
12206 +#endif
12207 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/context_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/context_cmd.h
12208 --- linux-2.6.33.1/include/linux/vserver/context_cmd.h  1970-01-01 01:00:00.000000000 +0100
12209 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/context_cmd.h  2010-02-25 12:02:16.000000000 +0100
12210 @@ -0,0 +1,145 @@
12211 +#ifndef _VX_CONTEXT_CMD_H
12212 +#define _VX_CONTEXT_CMD_H
12213 +
12214 +
12215 +/* vinfo commands */
12216 +
12217 +#define VCMD_task_xid          VC_CMD(VINFO, 1, 0)
12218 +
12219 +#ifdef __KERNEL__
12220 +extern int vc_task_xid(uint32_t);
12221 +
12222 +#endif /* __KERNEL__ */
12223 +
12224 +#define VCMD_vx_info           VC_CMD(VINFO, 5, 0)
12225 +
12226 +struct vcmd_vx_info_v0 {
12227 +       uint32_t xid;
12228 +       uint32_t initpid;
12229 +       /* more to come */
12230 +};
12231 +
12232 +#ifdef __KERNEL__
12233 +extern int vc_vx_info(struct vx_info *, void __user *);
12234 +
12235 +#endif /* __KERNEL__ */
12236 +
12237 +#define VCMD_ctx_stat          VC_CMD(VSTAT, 0, 0)
12238 +
12239 +struct vcmd_ctx_stat_v0 {
12240 +       uint32_t usecnt;
12241 +       uint32_t tasks;
12242 +       /* more to come */
12243 +};
12244 +
12245 +#ifdef __KERNEL__
12246 +extern int vc_ctx_stat(struct vx_info *, void __user *);
12247 +
12248 +#endif /* __KERNEL__ */
12249 +
12250 +/* context commands */
12251 +
12252 +#define VCMD_ctx_create_v0     VC_CMD(VPROC, 1, 0)
12253 +#define VCMD_ctx_create                VC_CMD(VPROC, 1, 1)
12254 +
12255 +struct vcmd_ctx_create {
12256 +       uint64_t flagword;
12257 +};
12258 +
12259 +#define VCMD_ctx_migrate_v0    VC_CMD(PROCMIG, 1, 0)
12260 +#define VCMD_ctx_migrate       VC_CMD(PROCMIG, 1, 1)
12261 +
12262 +struct vcmd_ctx_migrate {
12263 +       uint64_t flagword;
12264 +};
12265 +
12266 +#ifdef __KERNEL__
12267 +extern int vc_ctx_create(uint32_t, void __user *);
12268 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
12269 +
12270 +#endif /* __KERNEL__ */
12271 +
12272 +
12273 +/* flag commands */
12274 +
12275 +#define VCMD_get_cflags                VC_CMD(FLAGS, 1, 0)
12276 +#define VCMD_set_cflags                VC_CMD(FLAGS, 2, 0)
12277 +
12278 +struct vcmd_ctx_flags_v0 {
12279 +       uint64_t flagword;
12280 +       uint64_t mask;
12281 +};
12282 +
12283 +#ifdef __KERNEL__
12284 +extern int vc_get_cflags(struct vx_info *, void __user *);
12285 +extern int vc_set_cflags(struct vx_info *, void __user *);
12286 +
12287 +#endif /* __KERNEL__ */
12288 +
12289 +
12290 +/* context caps commands */
12291 +
12292 +#define VCMD_get_ccaps         VC_CMD(FLAGS, 3, 1)
12293 +#define VCMD_set_ccaps         VC_CMD(FLAGS, 4, 1)
12294 +
12295 +struct vcmd_ctx_caps_v1 {
12296 +       uint64_t ccaps;
12297 +       uint64_t cmask;
12298 +};
12299 +
12300 +#ifdef __KERNEL__
12301 +extern int vc_get_ccaps(struct vx_info *, void __user *);
12302 +extern int vc_set_ccaps(struct vx_info *, void __user *);
12303 +
12304 +#endif /* __KERNEL__ */
12305 +
12306 +
12307 +/* bcaps commands */
12308 +
12309 +#define VCMD_get_bcaps         VC_CMD(FLAGS, 9, 0)
12310 +#define VCMD_set_bcaps         VC_CMD(FLAGS, 10, 0)
12311 +
12312 +struct vcmd_bcaps {
12313 +       uint64_t bcaps;
12314 +       uint64_t bmask;
12315 +};
12316 +
12317 +#ifdef __KERNEL__
12318 +extern int vc_get_bcaps(struct vx_info *, void __user *);
12319 +extern int vc_set_bcaps(struct vx_info *, void __user *);
12320 +
12321 +#endif /* __KERNEL__ */
12322 +
12323 +
12324 +/* umask commands */
12325 +
12326 +#define VCMD_get_umask         VC_CMD(FLAGS, 13, 0)
12327 +#define VCMD_set_umask         VC_CMD(FLAGS, 14, 0)
12328 +
12329 +struct vcmd_umask {
12330 +       uint64_t umask;
12331 +       uint64_t mask;
12332 +};
12333 +
12334 +#ifdef __KERNEL__
12335 +extern int vc_get_umask(struct vx_info *, void __user *);
12336 +extern int vc_set_umask(struct vx_info *, void __user *);
12337 +
12338 +#endif /* __KERNEL__ */
12339 +
12340 +
12341 +/* OOM badness */
12342 +
12343 +#define VCMD_get_badness       VC_CMD(MEMCTRL, 5, 0)
12344 +#define VCMD_set_badness       VC_CMD(MEMCTRL, 6, 0)
12345 +
12346 +struct vcmd_badness_v0 {
12347 +       int64_t bias;
12348 +};
12349 +
12350 +#ifdef __KERNEL__
12351 +extern int vc_get_badness(struct vx_info *, void __user *);
12352 +extern int vc_set_badness(struct vx_info *, void __user *);
12353 +
12354 +#endif /* __KERNEL__ */
12355 +#endif /* _VX_CONTEXT_CMD_H */
12356 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/context.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/context.h
12357 --- linux-2.6.33.1/include/linux/vserver/context.h      1970-01-01 01:00:00.000000000 +0100
12358 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/context.h      2010-03-05 19:53:00.000000000 +0100
12359 @@ -0,0 +1,184 @@
12360 +#ifndef _VX_CONTEXT_H
12361 +#define _VX_CONTEXT_H
12362 +
12363 +#include <linux/types.h>
12364 +#include <linux/capability.h>
12365 +
12366 +
12367 +/* context flags */
12368 +
12369 +#define VXF_INFO_SCHED         0x00000002
12370 +#define VXF_INFO_NPROC         0x00000004
12371 +#define VXF_INFO_PRIVATE       0x00000008
12372 +
12373 +#define VXF_INFO_INIT          0x00000010
12374 +#define VXF_INFO_HIDE          0x00000020
12375 +#define VXF_INFO_ULIMIT                0x00000040
12376 +#define VXF_INFO_NSPACE                0x00000080
12377 +
12378 +#define VXF_SCHED_HARD         0x00000100
12379 +#define VXF_SCHED_PRIO         0x00000200
12380 +#define VXF_SCHED_PAUSE                0x00000400
12381 +
12382 +#define VXF_VIRT_MEM           0x00010000
12383 +#define VXF_VIRT_UPTIME                0x00020000
12384 +#define VXF_VIRT_CPU           0x00040000
12385 +#define VXF_VIRT_LOAD          0x00080000
12386 +#define VXF_VIRT_TIME          0x00100000
12387 +
12388 +#define VXF_HIDE_MOUNT         0x01000000
12389 +/* was VXF_HIDE_NETIF          0x02000000 */
12390 +#define VXF_HIDE_VINFO         0x04000000
12391 +
12392 +#define VXF_STATE_SETUP                (1ULL << 32)
12393 +#define VXF_STATE_INIT         (1ULL << 33)
12394 +#define VXF_STATE_ADMIN                (1ULL << 34)
12395 +
12396 +#define VXF_SC_HELPER          (1ULL << 36)
12397 +#define VXF_REBOOT_KILL                (1ULL << 37)
12398 +#define VXF_PERSISTENT         (1ULL << 38)
12399 +
12400 +#define VXF_FORK_RSS           (1ULL << 48)
12401 +#define VXF_PROLIFIC           (1ULL << 49)
12402 +
12403 +#define VXF_IGNEG_NICE         (1ULL << 52)
12404 +
12405 +#define VXF_ONE_TIME           (0x0007ULL << 32)
12406 +
12407 +#define VXF_INIT_SET           (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12408 +
12409 +
12410 +/* context migration */
12411 +
12412 +#define VXM_SET_INIT           0x00000001
12413 +#define VXM_SET_REAPER         0x00000002
12414 +
12415 +/* context caps */
12416 +
12417 +#define VXC_CAP_MASK           0x00000000
12418 +
12419 +#define VXC_SET_UTSNAME                0x00000001
12420 +#define VXC_SET_RLIMIT         0x00000002
12421 +#define VXC_FS_SECURITY                0x00000004
12422 +#define VXC_FS_TRUSTED         0x00000008
12423 +#define VXC_TIOCSTI            0x00000010
12424 +
12425 +/* was VXC_RAW_ICMP            0x00000100 */
12426 +#define VXC_SYSLOG             0x00001000
12427 +#define VXC_OOM_ADJUST         0x00002000
12428 +#define VXC_AUDIT_CONTROL      0x00004000
12429 +
12430 +#define VXC_SECURE_MOUNT       0x00010000
12431 +#define VXC_SECURE_REMOUNT     0x00020000
12432 +#define VXC_BINARY_MOUNT       0x00040000
12433 +
12434 +#define VXC_QUOTA_CTL          0x00100000
12435 +#define VXC_ADMIN_MAPPER       0x00200000
12436 +#define VXC_ADMIN_CLOOP                0x00400000
12437 +
12438 +#define VXC_KTHREAD            0x01000000
12439 +#define VXC_NAMESPACE          0x02000000
12440 +
12441 +
12442 +#ifdef __KERNEL__
12443 +
12444 +#include <linux/list.h>
12445 +#include <linux/spinlock.h>
12446 +#include <linux/rcupdate.h>
12447 +
12448 +#include "limit_def.h"
12449 +#include "sched_def.h"
12450 +#include "cvirt_def.h"
12451 +#include "cacct_def.h"
12452 +#include "device_def.h"
12453 +
12454 +#define VX_SPACES      2
12455 +
12456 +struct _vx_info_pc {
12457 +       struct _vx_sched_pc sched_pc;
12458 +       struct _vx_cvirt_pc cvirt_pc;
12459 +};
12460 +
12461 +struct vx_info {
12462 +       struct hlist_node vx_hlist;             /* linked list of contexts */
12463 +       xid_t vx_id;                            /* context id */
12464 +       atomic_t vx_usecnt;                     /* usage count */
12465 +       atomic_t vx_tasks;                      /* tasks count */
12466 +       struct vx_info *vx_parent;              /* parent context */
12467 +       int vx_state;                           /* context state */
12468 +
12469 +       unsigned long vx_nsmask[VX_SPACES];     /* assignment mask */
12470 +       struct nsproxy *vx_nsproxy[VX_SPACES];  /* private namespaces */
12471 +       struct fs_struct *vx_fs[VX_SPACES];     /* private namespace fs */
12472 +
12473 +       uint64_t vx_flags;                      /* context flags */
12474 +       uint64_t vx_ccaps;                      /* context caps (vserver) */
12475 +       kernel_cap_t vx_bcaps;                  /* bounding caps (system) */
12476 +       unsigned long vx_umask;                 /* unshare mask (guest) */
12477 +
12478 +       struct task_struct *vx_reaper;          /* guest reaper process */
12479 +       pid_t vx_initpid;                       /* PID of guest init */
12480 +       int64_t vx_badness_bias;                /* OOM points bias */
12481 +
12482 +       struct _vx_limit limit;                 /* vserver limits */
12483 +       struct _vx_sched sched;                 /* vserver scheduler */
12484 +       struct _vx_cvirt cvirt;                 /* virtual/bias stuff */
12485 +       struct _vx_cacct cacct;                 /* context accounting */
12486 +
12487 +       struct _vx_device dmap;                 /* default device map targets */
12488 +
12489 +#ifndef CONFIG_SMP
12490 +       struct _vx_info_pc info_pc;             /* per cpu data */
12491 +#else
12492 +       struct _vx_info_pc *ptr_pc;             /* per cpu array */
12493 +#endif
12494 +
12495 +       wait_queue_head_t vx_wait;              /* context exit waitqueue */
12496 +       int reboot_cmd;                         /* last sys_reboot() cmd */
12497 +       int exit_code;                          /* last process exit code */
12498 +
12499 +       char vx_name[65];                       /* vserver name */
12500 +};
12501 +
12502 +#ifndef CONFIG_SMP
12503 +#define        vx_ptr_pc(vxi)          (&(vxi)->info_pc)
12504 +#define        vx_per_cpu(vxi, v, id)  vx_ptr_pc(vxi)->v
12505 +#else
12506 +#define        vx_ptr_pc(vxi)          ((vxi)->ptr_pc)
12507 +#define        vx_per_cpu(vxi, v, id)  per_cpu_ptr(vx_ptr_pc(vxi), id)->v
12508 +#endif
12509 +
12510 +#define        vx_cpu(vxi, v)          vx_per_cpu(vxi, v, smp_processor_id())
12511 +
12512 +
12513 +struct vx_info_save {
12514 +       struct vx_info *vxi;
12515 +       xid_t xid;
12516 +};
12517 +
12518 +
12519 +/* status flags */
12520 +
12521 +#define VXS_HASHED     0x0001
12522 +#define VXS_PAUSED     0x0010
12523 +#define VXS_SHUTDOWN   0x0100
12524 +#define VXS_HELPER     0x1000
12525 +#define VXS_RELEASED   0x8000
12526 +
12527 +
12528 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
12529 +extern void release_vx_info(struct vx_info *, struct task_struct *);
12530 +
12531 +extern struct vx_info *lookup_vx_info(int);
12532 +extern struct vx_info *lookup_or_create_vx_info(int);
12533 +
12534 +extern int get_xid_list(int, unsigned int *, int);
12535 +extern int xid_is_hashed(xid_t);
12536 +
12537 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
12538 +
12539 +extern long vs_state_change(struct vx_info *, unsigned int);
12540 +
12541 +
12542 +#endif /* __KERNEL__ */
12543 +#endif /* _VX_CONTEXT_H */
12544 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/cvirt_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cvirt_cmd.h
12545 --- linux-2.6.33.1/include/linux/vserver/cvirt_cmd.h    1970-01-01 01:00:00.000000000 +0100
12546 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cvirt_cmd.h    2010-02-25 12:02:16.000000000 +0100
12547 @@ -0,0 +1,53 @@
12548 +#ifndef _VX_CVIRT_CMD_H
12549 +#define _VX_CVIRT_CMD_H
12550 +
12551 +
12552 +/* virtual host info name commands */
12553 +
12554 +#define VCMD_set_vhi_name      VC_CMD(VHOST, 1, 0)
12555 +#define VCMD_get_vhi_name      VC_CMD(VHOST, 2, 0)
12556 +
12557 +struct vcmd_vhi_name_v0 {
12558 +       uint32_t field;
12559 +       char name[65];
12560 +};
12561 +
12562 +
12563 +enum vhi_name_field {
12564 +       VHIN_CONTEXT = 0,
12565 +       VHIN_SYSNAME,
12566 +       VHIN_NODENAME,
12567 +       VHIN_RELEASE,
12568 +       VHIN_VERSION,
12569 +       VHIN_MACHINE,
12570 +       VHIN_DOMAINNAME,
12571 +};
12572 +
12573 +
12574 +#ifdef __KERNEL__
12575 +
12576 +#include <linux/compiler.h>
12577 +
12578 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
12579 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
12580 +
12581 +#endif /* __KERNEL__ */
12582 +
12583 +#define VCMD_virt_stat         VC_CMD(VSTAT, 3, 0)
12584 +
12585 +struct vcmd_virt_stat_v0 {
12586 +       uint64_t offset;
12587 +       uint64_t uptime;
12588 +       uint32_t nr_threads;
12589 +       uint32_t nr_running;
12590 +       uint32_t nr_uninterruptible;
12591 +       uint32_t nr_onhold;
12592 +       uint32_t nr_forks;
12593 +       uint32_t load[3];
12594 +};
12595 +
12596 +#ifdef __KERNEL__
12597 +extern int vc_virt_stat(struct vx_info *, void __user *);
12598 +
12599 +#endif /* __KERNEL__ */
12600 +#endif /* _VX_CVIRT_CMD_H */
12601 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/cvirt_def.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cvirt_def.h
12602 --- linux-2.6.33.1/include/linux/vserver/cvirt_def.h    1970-01-01 01:00:00.000000000 +0100
12603 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cvirt_def.h    2010-02-25 12:02:16.000000000 +0100
12604 @@ -0,0 +1,80 @@
12605 +#ifndef _VX_CVIRT_DEF_H
12606 +#define _VX_CVIRT_DEF_H
12607 +
12608 +#include <linux/jiffies.h>
12609 +#include <linux/spinlock.h>
12610 +#include <linux/wait.h>
12611 +#include <linux/time.h>
12612 +#include <asm/atomic.h>
12613 +
12614 +
12615 +struct _vx_usage_stat {
12616 +       uint64_t user;
12617 +       uint64_t nice;
12618 +       uint64_t system;
12619 +       uint64_t softirq;
12620 +       uint64_t irq;
12621 +       uint64_t idle;
12622 +       uint64_t iowait;
12623 +};
12624 +
12625 +struct _vx_syslog {
12626 +       wait_queue_head_t log_wait;
12627 +       spinlock_t logbuf_lock;         /* lock for the log buffer */
12628 +
12629 +       unsigned long log_start;        /* next char to be read by syslog() */
12630 +       unsigned long con_start;        /* next char to be sent to consoles */
12631 +       unsigned long log_end;  /* most-recently-written-char + 1 */
12632 +       unsigned long logged_chars;     /* #chars since last read+clear operation */
12633 +
12634 +       char log_buf[1024];
12635 +};
12636 +
12637 +
12638 +/* context sub struct */
12639 +
12640 +struct _vx_cvirt {
12641 +       atomic_t nr_threads;            /* number of current threads */
12642 +       atomic_t nr_running;            /* number of running threads */
12643 +       atomic_t nr_uninterruptible;    /* number of uninterruptible threads */
12644 +
12645 +       atomic_t nr_onhold;             /* processes on hold */
12646 +       uint32_t onhold_last;           /* jiffies when put on hold */
12647 +
12648 +       struct timeval bias_tv;         /* time offset to the host */
12649 +       struct timespec bias_idle;
12650 +       struct timespec bias_uptime;    /* context creation point */
12651 +       uint64_t bias_clock;            /* offset in clock_t */
12652 +
12653 +       spinlock_t load_lock;           /* lock for the load averages */
12654 +       atomic_t load_updates;          /* nr of load updates done so far */
12655 +       uint32_t load_last;             /* last time load was calculated */
12656 +       uint32_t load[3];               /* load averages 1,5,15 */
12657 +
12658 +       atomic_t total_forks;           /* number of forks so far */
12659 +
12660 +       struct _vx_syslog syslog;
12661 +};
12662 +
12663 +struct _vx_cvirt_pc {
12664 +       struct _vx_usage_stat cpustat;
12665 +};
12666 +
12667 +
12668 +#ifdef CONFIG_VSERVER_DEBUG
12669 +
12670 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
12671 +{
12672 +       printk("\t_vx_cvirt:\n");
12673 +       printk("\t threads: %4d, %4d, %4d, %4d\n",
12674 +               atomic_read(&cvirt->nr_threads),
12675 +               atomic_read(&cvirt->nr_running),
12676 +               atomic_read(&cvirt->nr_uninterruptible),
12677 +               atomic_read(&cvirt->nr_onhold));
12678 +       /* add rest here */
12679 +       printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
12680 +}
12681 +
12682 +#endif
12683 +
12684 +#endif /* _VX_CVIRT_DEF_H */
12685 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/cvirt.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cvirt.h
12686 --- linux-2.6.33.1/include/linux/vserver/cvirt.h        1970-01-01 01:00:00.000000000 +0100
12687 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/cvirt.h        2010-02-25 12:02:16.000000000 +0100
12688 @@ -0,0 +1,20 @@
12689 +#ifndef _VX_CVIRT_H
12690 +#define _VX_CVIRT_H
12691 +
12692 +
12693 +#ifdef __KERNEL__
12694 +
12695 +struct timespec;
12696 +
12697 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12698 +
12699 +
12700 +struct vx_info;
12701 +
12702 +void vx_update_load(struct vx_info *);
12703 +
12704 +
12705 +int vx_do_syslog(int, char __user *, int);
12706 +
12707 +#endif /* __KERNEL__ */
12708 +#endif /* _VX_CVIRT_H */
12709 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/debug_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/debug_cmd.h
12710 --- linux-2.6.33.1/include/linux/vserver/debug_cmd.h    1970-01-01 01:00:00.000000000 +0100
12711 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/debug_cmd.h    2010-02-25 12:02:16.000000000 +0100
12712 @@ -0,0 +1,58 @@
12713 +#ifndef _VX_DEBUG_CMD_H
12714 +#define _VX_DEBUG_CMD_H
12715 +
12716 +
12717 +/* debug commands */
12718 +
12719 +#define VCMD_dump_history      VC_CMD(DEBUG, 1, 0)
12720 +
12721 +#define VCMD_read_history      VC_CMD(DEBUG, 5, 0)
12722 +#define VCMD_read_monitor      VC_CMD(DEBUG, 6, 0)
12723 +
12724 +struct  vcmd_read_history_v0 {
12725 +       uint32_t index;
12726 +       uint32_t count;
12727 +       char __user *data;
12728 +};
12729 +
12730 +struct  vcmd_read_monitor_v0 {
12731 +       uint32_t index;
12732 +       uint32_t count;
12733 +       char __user *data;
12734 +};
12735 +
12736 +
12737 +#ifdef __KERNEL__
12738 +
12739 +#ifdef CONFIG_COMPAT
12740 +
12741 +#include <asm/compat.h>
12742 +
12743 +struct vcmd_read_history_v0_x32 {
12744 +       uint32_t index;
12745 +       uint32_t count;
12746 +       compat_uptr_t data_ptr;
12747 +};
12748 +
12749 +struct vcmd_read_monitor_v0_x32 {
12750 +       uint32_t index;
12751 +       uint32_t count;
12752 +       compat_uptr_t data_ptr;
12753 +};
12754 +
12755 +#endif  /* CONFIG_COMPAT */
12756 +
12757 +extern int vc_dump_history(uint32_t);
12758 +
12759 +extern int vc_read_history(uint32_t, void __user *);
12760 +extern int vc_read_monitor(uint32_t, void __user *);
12761 +
12762 +#ifdef CONFIG_COMPAT
12763 +
12764 +extern int vc_read_history_x32(uint32_t, void __user *);
12765 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12766 +
12767 +#endif  /* CONFIG_COMPAT */
12768 +
12769 +#endif /* __KERNEL__ */
12770 +#endif /* _VX_DEBUG_CMD_H */
12771 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/debug.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/debug.h
12772 --- linux-2.6.33.1/include/linux/vserver/debug.h        1970-01-01 01:00:00.000000000 +0100
12773 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/debug.h        2010-02-25 12:02:16.000000000 +0100
12774 @@ -0,0 +1,127 @@
12775 +#ifndef _VX_DEBUG_H
12776 +#define _VX_DEBUG_H
12777 +
12778 +
12779 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
12780 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
12781 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
12782 +
12783 +#define VXD_DEV(d)     (d), (d)->bd_inode->i_ino,              \
12784 +                       imajor((d)->bd_inode), iminor((d)->bd_inode)
12785 +#define VXF_DEV                "%p[%lu,%d:%d]"
12786 +
12787 +
12788 +#define vxd_path(p)                                            \
12789 +       ({ static char _buffer[PATH_MAX];                       \
12790 +          d_path(p, _buffer, sizeof(_buffer)); })
12791 +
12792 +#define vxd_cond_path(n)                                       \
12793 +       ((n) ? vxd_path(&(n)->path) : "<null>" )
12794 +
12795 +
12796 +#ifdef CONFIG_VSERVER_DEBUG
12797 +
12798 +extern unsigned int vx_debug_switch;
12799 +extern unsigned int vx_debug_xid;
12800 +extern unsigned int vx_debug_nid;
12801 +extern unsigned int vx_debug_tag;
12802 +extern unsigned int vx_debug_net;
12803 +extern unsigned int vx_debug_limit;
12804 +extern unsigned int vx_debug_cres;
12805 +extern unsigned int vx_debug_dlim;
12806 +extern unsigned int vx_debug_quota;
12807 +extern unsigned int vx_debug_cvirt;
12808 +extern unsigned int vx_debug_space;
12809 +extern unsigned int vx_debug_misc;
12810 +
12811 +
12812 +#define VX_LOGLEVEL    "vxD: "
12813 +#define VX_PROC_FMT    "%p: "
12814 +#define VX_PROCESS     current
12815 +
12816 +#define vxdprintk(c, f, x...)                                  \
12817 +       do {                                                    \
12818 +               if (c)                                          \
12819 +                       printk(VX_LOGLEVEL VX_PROC_FMT f "\n",  \
12820 +                               VX_PROCESS , ##x);              \
12821 +       } while (0)
12822 +
12823 +#define vxlprintk(c, f, x...)                                  \
12824 +       do {                                                    \
12825 +               if (c)                                          \
12826 +                       printk(VX_LOGLEVEL f " @%s:%d\n", x);   \
12827 +       } while (0)
12828 +
12829 +#define vxfprintk(c, f, x...)                                  \
12830 +       do {                                                    \
12831 +               if (c)                                          \
12832 +                       printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12833 +       } while (0)
12834 +
12835 +
12836 +struct vx_info;
12837 +
12838 +void dump_vx_info(struct vx_info *, int);
12839 +void dump_vx_info_inactive(int);
12840 +
12841 +#else  /* CONFIG_VSERVER_DEBUG */
12842 +
12843 +#define vx_debug_switch 0
12844 +#define vx_debug_xid   0
12845 +#define vx_debug_nid   0
12846 +#define vx_debug_tag   0
12847 +#define vx_debug_net   0
12848 +#define vx_debug_limit 0
12849 +#define vx_debug_cres  0
12850 +#define vx_debug_dlim  0
12851 +#define vx_debug_cvirt 0
12852 +
12853 +#define vxdprintk(x...) do { } while (0)
12854 +#define vxlprintk(x...) do { } while (0)
12855 +#define vxfprintk(x...) do { } while (0)
12856 +
12857 +#endif /* CONFIG_VSERVER_DEBUG */
12858 +
12859 +
12860 +#ifdef CONFIG_VSERVER_WARN
12861 +
12862 +#define VX_WARNLEVEL   KERN_WARNING "vxW: "
12863 +#define VX_WARN_TASK   "[»%s«,%u:#%u|%u|%u] "
12864 +#define VX_WARN_XID    "[xid #%u] "
12865 +#define VX_WARN_NID    "[nid #%u] "
12866 +#define VX_WARN_TAG    "[tag #%u] "
12867 +
12868 +#define vxwprintk(c, f, x...)                                  \
12869 +       do {                                                    \
12870 +               if (c)                                          \
12871 +                       printk(VX_WARNLEVEL f "\n", ##x);       \
12872 +       } while (0)
12873 +
12874 +#else  /* CONFIG_VSERVER_WARN */
12875 +
12876 +#define vxwprintk(x...) do { } while (0)
12877 +
12878 +#endif /* CONFIG_VSERVER_WARN */
12879 +
12880 +#define vxwprintk_task(c, f, x...)                             \
12881 +       vxwprintk(c, VX_WARN_TASK f,                            \
12882 +               current->comm, current->pid,                    \
12883 +               current->xid, current->nid, current->tag, ##x)
12884 +#define vxwprintk_xid(c, f, x...)                              \
12885 +       vxwprintk(c, VX_WARN_XID f, current->xid, x)
12886 +#define vxwprintk_nid(c, f, x...)                              \
12887 +       vxwprintk(c, VX_WARN_NID f, current->nid, x)
12888 +#define vxwprintk_tag(c, f, x...)                              \
12889 +       vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12890 +
12891 +#ifdef CONFIG_VSERVER_DEBUG
12892 +#define vxd_assert_lock(l)     assert_spin_locked(l)
12893 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12894 +       "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12895 +#else
12896 +#define vxd_assert_lock(l)     do { } while (0)
12897 +#define vxd_assert(c, f, x...) do { } while (0)
12898 +#endif
12899 +
12900 +
12901 +#endif /* _VX_DEBUG_H */
12902 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/device_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/device_cmd.h
12903 --- linux-2.6.33.1/include/linux/vserver/device_cmd.h   1970-01-01 01:00:00.000000000 +0100
12904 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/device_cmd.h   2010-02-25 12:02:16.000000000 +0100
12905 @@ -0,0 +1,44 @@
12906 +#ifndef _VX_DEVICE_CMD_H
12907 +#define _VX_DEVICE_CMD_H
12908 +
12909 +
12910 +/*  device vserver commands */
12911 +
12912 +#define VCMD_set_mapping       VC_CMD(DEVICE, 1, 0)
12913 +#define VCMD_unset_mapping     VC_CMD(DEVICE, 2, 0)
12914 +
12915 +struct vcmd_set_mapping_v0 {
12916 +       const char __user *device;
12917 +       const char __user *target;
12918 +       uint32_t flags;
12919 +};
12920 +
12921 +
12922 +#ifdef __KERNEL__
12923 +
12924 +#ifdef CONFIG_COMPAT
12925 +
12926 +#include <asm/compat.h>
12927 +
12928 +struct vcmd_set_mapping_v0_x32 {
12929 +       compat_uptr_t device_ptr;
12930 +       compat_uptr_t target_ptr;
12931 +       uint32_t flags;
12932 +};
12933 +
12934 +#endif /* CONFIG_COMPAT */
12935 +
12936 +#include <linux/compiler.h>
12937 +
12938 +extern int vc_set_mapping(struct vx_info *, void __user *);
12939 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12940 +
12941 +#ifdef CONFIG_COMPAT
12942 +
12943 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12944 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12945 +
12946 +#endif /* CONFIG_COMPAT */
12947 +
12948 +#endif /* __KERNEL__ */
12949 +#endif /* _VX_DEVICE_CMD_H */
12950 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/device_def.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/device_def.h
12951 --- linux-2.6.33.1/include/linux/vserver/device_def.h   1970-01-01 01:00:00.000000000 +0100
12952 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/device_def.h   2010-02-25 12:02:16.000000000 +0100
12953 @@ -0,0 +1,17 @@
12954 +#ifndef _VX_DEVICE_DEF_H
12955 +#define _VX_DEVICE_DEF_H
12956 +
12957 +#include <linux/types.h>
12958 +
12959 +struct vx_dmap_target {
12960 +       dev_t target;
12961 +       uint32_t flags;
12962 +};
12963 +
12964 +struct _vx_device {
12965 +#ifdef CONFIG_VSERVER_DEVICE
12966 +       struct vx_dmap_target targets[2];
12967 +#endif
12968 +};
12969 +
12970 +#endif /* _VX_DEVICE_DEF_H */
12971 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/device.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/device.h
12972 --- linux-2.6.33.1/include/linux/vserver/device.h       1970-01-01 01:00:00.000000000 +0100
12973 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/device.h       2010-02-25 12:02:16.000000000 +0100
12974 @@ -0,0 +1,15 @@
12975 +#ifndef _VX_DEVICE_H
12976 +#define _VX_DEVICE_H
12977 +
12978 +
12979 +#define DATTR_CREATE   0x00000001
12980 +#define DATTR_OPEN     0x00000002
12981 +
12982 +#define DATTR_REMAP    0x00000010
12983 +
12984 +#define DATTR_MASK     0x00000013
12985 +
12986 +
12987 +#else  /* _VX_DEVICE_H */
12988 +#warning duplicate inclusion
12989 +#endif /* _VX_DEVICE_H */
12990 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/dlimit_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/dlimit_cmd.h
12991 --- linux-2.6.33.1/include/linux/vserver/dlimit_cmd.h   1970-01-01 01:00:00.000000000 +0100
12992 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/dlimit_cmd.h   2010-02-25 12:02:16.000000000 +0100
12993 @@ -0,0 +1,109 @@
12994 +#ifndef _VX_DLIMIT_CMD_H
12995 +#define _VX_DLIMIT_CMD_H
12996 +
12997 +
12998 +/*  dlimit vserver commands */
12999 +
13000 +#define VCMD_add_dlimit                VC_CMD(DLIMIT, 1, 0)
13001 +#define VCMD_rem_dlimit                VC_CMD(DLIMIT, 2, 0)
13002 +
13003 +#define VCMD_set_dlimit                VC_CMD(DLIMIT, 5, 0)
13004 +#define VCMD_get_dlimit                VC_CMD(DLIMIT, 6, 0)
13005 +
13006 +struct vcmd_ctx_dlimit_base_v0 {
13007 +       const char __user *name;
13008 +       uint32_t flags;
13009 +};
13010 +
13011 +struct vcmd_ctx_dlimit_v0 {
13012 +       const char __user *name;
13013 +       uint32_t space_used;                    /* used space in kbytes */
13014 +       uint32_t space_total;                   /* maximum space in kbytes */
13015 +       uint32_t inodes_used;                   /* used inodes */
13016 +       uint32_t inodes_total;                  /* maximum inodes */
13017 +       uint32_t reserved;                      /* reserved for root in % */
13018 +       uint32_t flags;
13019 +};
13020 +
13021 +#define CDLIM_UNSET            ((uint32_t)0UL)
13022 +#define CDLIM_INFINITY         ((uint32_t)~0UL)
13023 +#define CDLIM_KEEP             ((uint32_t)~1UL)
13024 +
13025 +#define DLIME_UNIT     0
13026 +#define DLIME_KILO     1
13027 +#define DLIME_MEGA     2
13028 +#define DLIME_GIGA     3
13029 +
13030 +#define DLIMF_SHIFT    0x10
13031 +
13032 +#define DLIMS_USED     0
13033 +#define DLIMS_TOTAL    2
13034 +
13035 +static inline
13036 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
13037 +{
13038 +       int exp = (flags & DLIMF_SHIFT) ?
13039 +               (flags >> shift) & DLIME_GIGA : DLIME_KILO;
13040 +       return ((uint64_t)val) << (10 * exp);
13041 +}
13042 +
13043 +static inline
13044 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
13045 +{
13046 +       int exp = 0;
13047 +
13048 +       if (*flags & DLIMF_SHIFT) {
13049 +               while (val > (1LL << 32) && (exp < 3)) {
13050 +                       val >>= 10;
13051 +                       exp++;
13052 +               }
13053 +               *flags &= ~(DLIME_GIGA << shift);
13054 +               *flags |= exp << shift;
13055 +       } else
13056 +               val >>= 10;
13057 +       return val;
13058 +}
13059 +
13060 +#ifdef __KERNEL__
13061 +
13062 +#ifdef CONFIG_COMPAT
13063 +
13064 +#include <asm/compat.h>
13065 +
13066 +struct vcmd_ctx_dlimit_base_v0_x32 {
13067 +       compat_uptr_t name_ptr;
13068 +       uint32_t flags;
13069 +};
13070 +
13071 +struct vcmd_ctx_dlimit_v0_x32 {
13072 +       compat_uptr_t name_ptr;
13073 +       uint32_t space_used;                    /* used space in kbytes */
13074 +       uint32_t space_total;                   /* maximum space in kbytes */
13075 +       uint32_t inodes_used;                   /* used inodes */
13076 +       uint32_t inodes_total;                  /* maximum inodes */
13077 +       uint32_t reserved;                      /* reserved for root in % */
13078 +       uint32_t flags;
13079 +};
13080 +
13081 +#endif /* CONFIG_COMPAT */
13082 +
13083 +#include <linux/compiler.h>
13084 +
13085 +extern int vc_add_dlimit(uint32_t, void __user *);
13086 +extern int vc_rem_dlimit(uint32_t, void __user *);
13087 +
13088 +extern int vc_set_dlimit(uint32_t, void __user *);
13089 +extern int vc_get_dlimit(uint32_t, void __user *);
13090 +
13091 +#ifdef CONFIG_COMPAT
13092 +
13093 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
13094 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
13095 +
13096 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
13097 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
13098 +
13099 +#endif /* CONFIG_COMPAT */
13100 +
13101 +#endif /* __KERNEL__ */
13102 +#endif /* _VX_DLIMIT_CMD_H */
13103 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/dlimit.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/dlimit.h
13104 --- linux-2.6.33.1/include/linux/vserver/dlimit.h       1970-01-01 01:00:00.000000000 +0100
13105 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/dlimit.h       2010-02-25 12:02:16.000000000 +0100
13106 @@ -0,0 +1,54 @@
13107 +#ifndef _VX_DLIMIT_H
13108 +#define _VX_DLIMIT_H
13109 +
13110 +#include "switch.h"
13111 +
13112 +
13113 +#ifdef __KERNEL__
13114 +
13115 +/*      keep in sync with CDLIM_INFINITY       */
13116 +
13117 +#define DLIM_INFINITY          (~0ULL)
13118 +
13119 +#include <linux/spinlock.h>
13120 +#include <linux/rcupdate.h>
13121 +
13122 +struct super_block;
13123 +
13124 +struct dl_info {
13125 +       struct hlist_node dl_hlist;             /* linked list of contexts */
13126 +       struct rcu_head dl_rcu;                 /* the rcu head */
13127 +       tag_t dl_tag;                           /* context tag */
13128 +       atomic_t dl_usecnt;                     /* usage count */
13129 +       atomic_t dl_refcnt;                     /* reference count */
13130 +
13131 +       struct super_block *dl_sb;              /* associated superblock */
13132 +
13133 +       spinlock_t dl_lock;                     /* protect the values */
13134 +
13135 +       unsigned long long dl_space_used;       /* used space in bytes */
13136 +       unsigned long long dl_space_total;      /* maximum space in bytes */
13137 +       unsigned long dl_inodes_used;           /* used inodes */
13138 +       unsigned long dl_inodes_total;          /* maximum inodes */
13139 +
13140 +       unsigned int dl_nrlmult;                /* non root limit mult */
13141 +};
13142 +
13143 +struct rcu_head;
13144 +
13145 +extern void rcu_free_dl_info(struct rcu_head *);
13146 +extern void unhash_dl_info(struct dl_info *);
13147 +
13148 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
13149 +
13150 +
13151 +struct kstatfs;
13152 +
13153 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
13154 +
13155 +typedef uint64_t dlsize_t;
13156 +
13157 +#endif /* __KERNEL__ */
13158 +#else  /* _VX_DLIMIT_H */
13159 +#warning duplicate inclusion
13160 +#endif /* _VX_DLIMIT_H */
13161 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/global.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/global.h
13162 --- linux-2.6.33.1/include/linux/vserver/global.h       1970-01-01 01:00:00.000000000 +0100
13163 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/global.h       2010-02-25 12:02:16.000000000 +0100
13164 @@ -0,0 +1,19 @@
13165 +#ifndef _VX_GLOBAL_H
13166 +#define _VX_GLOBAL_H
13167 +
13168 +
13169 +extern atomic_t vx_global_ctotal;
13170 +extern atomic_t vx_global_cactive;
13171 +
13172 +extern atomic_t nx_global_ctotal;
13173 +extern atomic_t nx_global_cactive;
13174 +
13175 +extern atomic_t vs_global_nsproxy;
13176 +extern atomic_t vs_global_fs;
13177 +extern atomic_t vs_global_mnt_ns;
13178 +extern atomic_t vs_global_uts_ns;
13179 +extern atomic_t vs_global_user_ns;
13180 +extern atomic_t vs_global_pid_ns;
13181 +
13182 +
13183 +#endif /* _VX_GLOBAL_H */
13184 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/history.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/history.h
13185 --- linux-2.6.33.1/include/linux/vserver/history.h      1970-01-01 01:00:00.000000000 +0100
13186 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/history.h      2010-02-25 12:02:16.000000000 +0100
13187 @@ -0,0 +1,197 @@
13188 +#ifndef _VX_HISTORY_H
13189 +#define _VX_HISTORY_H
13190 +
13191 +
13192 +enum {
13193 +       VXH_UNUSED = 0,
13194 +       VXH_THROW_OOPS = 1,
13195 +
13196 +       VXH_GET_VX_INFO,
13197 +       VXH_PUT_VX_INFO,
13198 +       VXH_INIT_VX_INFO,
13199 +       VXH_SET_VX_INFO,
13200 +       VXH_CLR_VX_INFO,
13201 +       VXH_CLAIM_VX_INFO,
13202 +       VXH_RELEASE_VX_INFO,
13203 +       VXH_ALLOC_VX_INFO,
13204 +       VXH_DEALLOC_VX_INFO,
13205 +       VXH_HASH_VX_INFO,
13206 +       VXH_UNHASH_VX_INFO,
13207 +       VXH_LOC_VX_INFO,
13208 +       VXH_LOOKUP_VX_INFO,
13209 +       VXH_CREATE_VX_INFO,
13210 +};
13211 +
13212 +struct _vxhe_vxi {
13213 +       struct vx_info *ptr;
13214 +       unsigned xid;
13215 +       unsigned usecnt;
13216 +       unsigned tasks;
13217 +};
13218 +
13219 +struct _vxhe_set_clr {
13220 +       void *data;
13221 +};
13222 +
13223 +struct _vxhe_loc_lookup {
13224 +       unsigned arg;
13225 +};
13226 +
13227 +struct _vx_hist_entry {
13228 +       void *loc;
13229 +       unsigned short seq;
13230 +       unsigned short type;
13231 +       struct _vxhe_vxi vxi;
13232 +       union {
13233 +               struct _vxhe_set_clr sc;
13234 +               struct _vxhe_loc_lookup ll;
13235 +       };
13236 +};
13237 +
13238 +#ifdef CONFIG_VSERVER_HISTORY
13239 +
13240 +extern unsigned volatile int vxh_active;
13241 +
13242 +struct _vx_hist_entry *vxh_advance(void *loc);
13243 +
13244 +
13245 +static inline
13246 +void   __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
13247 +{
13248 +       entry->vxi.ptr = vxi;
13249 +       if (vxi) {
13250 +               entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
13251 +               entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
13252 +               entry->vxi.xid = vxi->vx_id;
13253 +       }
13254 +}
13255 +
13256 +
13257 +#define        __HERE__ current_text_addr()
13258 +
13259 +#define __VXH_BODY(__type, __data, __here)     \
13260 +       struct _vx_hist_entry *entry;           \
13261 +                                               \
13262 +       preempt_disable();                      \
13263 +       entry = vxh_advance(__here);            \
13264 +       __data;                                 \
13265 +       entry->type = __type;                   \
13266 +       preempt_enable();
13267 +
13268 +
13269 +       /* pass vxi only */
13270 +
13271 +#define __VXH_SMPL                             \
13272 +       __vxh_copy_vxi(entry, vxi)
13273 +
13274 +static inline
13275 +void   __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
13276 +{
13277 +       __VXH_BODY(__type, __VXH_SMPL, __here)
13278 +}
13279 +
13280 +       /* pass vxi and data (void *) */
13281 +
13282 +#define __VXH_DATA                             \
13283 +       __vxh_copy_vxi(entry, vxi);             \
13284 +       entry->sc.data = data
13285 +
13286 +static inline
13287 +void   __vxh_data(struct vx_info *vxi, void *data,
13288 +                       int __type, void *__here)
13289 +{
13290 +       __VXH_BODY(__type, __VXH_DATA, __here)
13291 +}
13292 +
13293 +       /* pass vxi and arg (long) */
13294 +
13295 +#define __VXH_LONG                             \
13296 +       __vxh_copy_vxi(entry, vxi);             \
13297 +       entry->ll.arg = arg
13298 +
13299 +static inline
13300 +void   __vxh_long(struct vx_info *vxi, long arg,
13301 +                       int __type, void *__here)
13302 +{
13303 +       __VXH_BODY(__type, __VXH_LONG, __here)
13304 +}
13305 +
13306 +
13307 +static inline
13308 +void   __vxh_throw_oops(void *__here)
13309 +{
13310 +       __VXH_BODY(VXH_THROW_OOPS, {}, __here);
13311 +       /* prevent further acquisition */
13312 +       vxh_active = 0;
13313 +}
13314 +
13315 +
13316 +#define vxh_throw_oops()       __vxh_throw_oops(__HERE__);
13317 +
13318 +#define __vxh_get_vx_info(v, h)        __vxh_smpl(v, VXH_GET_VX_INFO, h);
13319 +#define __vxh_put_vx_info(v, h)        __vxh_smpl(v, VXH_PUT_VX_INFO, h);
13320 +
13321 +#define __vxh_init_vx_info(v, d, h) \
13322 +       __vxh_data(v, d, VXH_INIT_VX_INFO, h);
13323 +#define __vxh_set_vx_info(v, d, h) \
13324 +       __vxh_data(v, d, VXH_SET_VX_INFO, h);
13325 +#define __vxh_clr_vx_info(v, d, h) \
13326 +       __vxh_data(v, d, VXH_CLR_VX_INFO, h);
13327 +
13328 +#define __vxh_claim_vx_info(v, d, h) \
13329 +       __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
13330 +#define __vxh_release_vx_info(v, d, h) \
13331 +       __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
13332 +
13333 +#define vxh_alloc_vx_info(v) \
13334 +       __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
13335 +#define vxh_dealloc_vx_info(v) \
13336 +       __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
13337 +
13338 +#define vxh_hash_vx_info(v) \
13339 +       __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
13340 +#define vxh_unhash_vx_info(v) \
13341 +       __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
13342 +
13343 +#define vxh_loc_vx_info(v, l) \
13344 +       __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
13345 +#define vxh_lookup_vx_info(v, l) \
13346 +       __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
13347 +#define vxh_create_vx_info(v, l) \
13348 +       __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
13349 +
13350 +extern void vxh_dump_history(void);
13351 +
13352 +
13353 +#else  /* CONFIG_VSERVER_HISTORY */
13354 +
13355 +#define        __HERE__        0
13356 +
13357 +#define vxh_throw_oops()               do { } while (0)
13358 +
13359 +#define __vxh_get_vx_info(v, h)                do { } while (0)
13360 +#define __vxh_put_vx_info(v, h)                do { } while (0)
13361 +
13362 +#define __vxh_init_vx_info(v, d, h)    do { } while (0)
13363 +#define __vxh_set_vx_info(v, d, h)     do { } while (0)
13364 +#define __vxh_clr_vx_info(v, d, h)     do { } while (0)
13365 +
13366 +#define __vxh_claim_vx_info(v, d, h)   do { } while (0)
13367 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
13368 +
13369 +#define vxh_alloc_vx_info(v)           do { } while (0)
13370 +#define vxh_dealloc_vx_info(v)         do { } while (0)
13371 +
13372 +#define vxh_hash_vx_info(v)            do { } while (0)
13373 +#define vxh_unhash_vx_info(v)          do { } while (0)
13374 +
13375 +#define vxh_loc_vx_info(v, l)          do { } while (0)
13376 +#define vxh_lookup_vx_info(v, l)       do { } while (0)
13377 +#define vxh_create_vx_info(v, l)       do { } while (0)
13378 +
13379 +#define vxh_dump_history()             do { } while (0)
13380 +
13381 +
13382 +#endif /* CONFIG_VSERVER_HISTORY */
13383 +
13384 +#endif /* _VX_HISTORY_H */
13385 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/inode_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/inode_cmd.h
13386 --- linux-2.6.33.1/include/linux/vserver/inode_cmd.h    1970-01-01 01:00:00.000000000 +0100
13387 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/inode_cmd.h    2010-02-25 12:02:16.000000000 +0100
13388 @@ -0,0 +1,59 @@
13389 +#ifndef _VX_INODE_CMD_H
13390 +#define _VX_INODE_CMD_H
13391 +
13392 +
13393 +/*  inode vserver commands */
13394 +
13395 +#define VCMD_get_iattr         VC_CMD(INODE, 1, 1)
13396 +#define VCMD_set_iattr         VC_CMD(INODE, 2, 1)
13397 +
13398 +#define VCMD_fget_iattr                VC_CMD(INODE, 3, 0)
13399 +#define VCMD_fset_iattr                VC_CMD(INODE, 4, 0)
13400 +
13401 +struct vcmd_ctx_iattr_v1 {
13402 +       const char __user *name;
13403 +       uint32_t tag;
13404 +       uint32_t flags;
13405 +       uint32_t mask;
13406 +};
13407 +
13408 +struct vcmd_ctx_fiattr_v0 {
13409 +       uint32_t tag;
13410 +       uint32_t flags;
13411 +       uint32_t mask;
13412 +};
13413 +
13414 +
13415 +#ifdef __KERNEL__
13416 +
13417 +
13418 +#ifdef CONFIG_COMPAT
13419 +
13420 +#include <asm/compat.h>
13421 +
13422 +struct vcmd_ctx_iattr_v1_x32 {
13423 +       compat_uptr_t name_ptr;
13424 +       uint32_t tag;
13425 +       uint32_t flags;
13426 +       uint32_t mask;
13427 +};
13428 +
13429 +#endif /* CONFIG_COMPAT */
13430 +
13431 +#include <linux/compiler.h>
13432 +
13433 +extern int vc_get_iattr(void __user *);
13434 +extern int vc_set_iattr(void __user *);
13435 +
13436 +extern int vc_fget_iattr(uint32_t, void __user *);
13437 +extern int vc_fset_iattr(uint32_t, void __user *);
13438 +
13439 +#ifdef CONFIG_COMPAT
13440 +
13441 +extern int vc_get_iattr_x32(void __user *);
13442 +extern int vc_set_iattr_x32(void __user *);
13443 +
13444 +#endif /* CONFIG_COMPAT */
13445 +
13446 +#endif /* __KERNEL__ */
13447 +#endif /* _VX_INODE_CMD_H */
13448 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/inode.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/inode.h
13449 --- linux-2.6.33.1/include/linux/vserver/inode.h        1970-01-01 01:00:00.000000000 +0100
13450 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/inode.h        2010-02-25 12:02:16.000000000 +0100
13451 @@ -0,0 +1,39 @@
13452 +#ifndef _VX_INODE_H
13453 +#define _VX_INODE_H
13454 +
13455 +
13456 +#define IATTR_TAG      0x01000000
13457 +
13458 +#define IATTR_ADMIN    0x00000001
13459 +#define IATTR_WATCH    0x00000002
13460 +#define IATTR_HIDE     0x00000004
13461 +#define IATTR_FLAGS    0x00000007
13462 +
13463 +#define IATTR_BARRIER  0x00010000
13464 +#define IATTR_IXUNLINK 0x00020000
13465 +#define IATTR_IMMUTABLE 0x00040000
13466 +#define IATTR_COW      0x00080000
13467 +
13468 +#ifdef __KERNEL__
13469 +
13470 +
13471 +#ifdef CONFIG_VSERVER_PROC_SECURE
13472 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN | IATTR_HIDE )
13473 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
13474 +#else
13475 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN )
13476 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
13477 +#endif
13478 +
13479 +#define vx_hide_check(c, m)    (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
13480 +
13481 +#endif /* __KERNEL__ */
13482 +
13483 +/* inode ioctls */
13484 +
13485 +#define FIOC_GETXFLG   _IOR('x', 5, long)
13486 +#define FIOC_SETXFLG   _IOW('x', 6, long)
13487 +
13488 +#else  /* _VX_INODE_H */
13489 +#warning duplicate inclusion
13490 +#endif /* _VX_INODE_H */
13491 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/Kbuild linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/Kbuild
13492 --- linux-2.6.33.1/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
13493 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/Kbuild 2010-02-25 12:02:16.000000000 +0100
13494 @@ -0,0 +1,8 @@
13495 +
13496 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
13497 +       cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
13498 +       inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
13499 +       debug_cmd.h device_cmd.h
13500 +
13501 +unifdef-y += switch.h network.h monitor.h inode.h device.h
13502 +
13503 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/limit_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/limit_cmd.h
13504 --- linux-2.6.33.1/include/linux/vserver/limit_cmd.h    1970-01-01 01:00:00.000000000 +0100
13505 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/limit_cmd.h    2010-02-25 12:02:16.000000000 +0100
13506 @@ -0,0 +1,71 @@
13507 +#ifndef _VX_LIMIT_CMD_H
13508 +#define _VX_LIMIT_CMD_H
13509 +
13510 +
13511 +/*  rlimit vserver commands */
13512 +
13513 +#define VCMD_get_rlimit                VC_CMD(RLIMIT, 1, 0)
13514 +#define VCMD_set_rlimit                VC_CMD(RLIMIT, 2, 0)
13515 +#define VCMD_get_rlimit_mask   VC_CMD(RLIMIT, 3, 0)
13516 +#define VCMD_reset_hits                VC_CMD(RLIMIT, 7, 0)
13517 +#define VCMD_reset_minmax      VC_CMD(RLIMIT, 9, 0)
13518 +
13519 +struct vcmd_ctx_rlimit_v0 {
13520 +       uint32_t id;
13521 +       uint64_t minimum;
13522 +       uint64_t softlimit;
13523 +       uint64_t maximum;
13524 +};
13525 +
13526 +struct vcmd_ctx_rlimit_mask_v0 {
13527 +       uint32_t minimum;
13528 +       uint32_t softlimit;
13529 +       uint32_t maximum;
13530 +};
13531 +
13532 +#define VCMD_rlimit_stat       VC_CMD(VSTAT, 1, 0)
13533 +
13534 +struct vcmd_rlimit_stat_v0 {
13535 +       uint32_t id;
13536 +       uint32_t hits;
13537 +       uint64_t value;
13538 +       uint64_t minimum;
13539 +       uint64_t maximum;
13540 +};
13541 +
13542 +#define CRLIM_UNSET            (0ULL)
13543 +#define CRLIM_INFINITY         (~0ULL)
13544 +#define CRLIM_KEEP             (~1ULL)
13545 +
13546 +#ifdef __KERNEL__
13547 +
13548 +#ifdef CONFIG_IA32_EMULATION
13549 +
13550 +struct vcmd_ctx_rlimit_v0_x32 {
13551 +       uint32_t id;
13552 +       uint64_t minimum;
13553 +       uint64_t softlimit;
13554 +       uint64_t maximum;
13555 +} __attribute__ ((packed));
13556 +
13557 +#endif /* CONFIG_IA32_EMULATION */
13558 +
13559 +#include <linux/compiler.h>
13560 +
13561 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
13562 +extern int vc_get_rlimit(struct vx_info *, void __user *);
13563 +extern int vc_set_rlimit(struct vx_info *, void __user *);
13564 +extern int vc_reset_hits(struct vx_info *, void __user *);
13565 +extern int vc_reset_minmax(struct vx_info *, void __user *);
13566 +
13567 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
13568 +
13569 +#ifdef CONFIG_IA32_EMULATION
13570 +
13571 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
13572 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
13573 +
13574 +#endif /* CONFIG_IA32_EMULATION */
13575 +
13576 +#endif /* __KERNEL__ */
13577 +#endif /* _VX_LIMIT_CMD_H */
13578 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/limit_def.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/limit_def.h
13579 --- linux-2.6.33.1/include/linux/vserver/limit_def.h    1970-01-01 01:00:00.000000000 +0100
13580 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/limit_def.h    2010-02-25 12:02:16.000000000 +0100
13581 @@ -0,0 +1,47 @@
13582 +#ifndef _VX_LIMIT_DEF_H
13583 +#define _VX_LIMIT_DEF_H
13584 +
13585 +#include <asm/atomic.h>
13586 +#include <asm/resource.h>
13587 +
13588 +#include "limit.h"
13589 +
13590 +
13591 +struct _vx_res_limit {
13592 +       rlim_t soft;            /* Context soft limit */
13593 +       rlim_t hard;            /* Context hard limit */
13594 +
13595 +       rlim_atomic_t rcur;     /* Current value */
13596 +       rlim_t rmin;            /* Context minimum */
13597 +       rlim_t rmax;            /* Context maximum */
13598 +
13599 +       atomic_t lhit;          /* Limit hits */
13600 +};
13601 +
13602 +/* context sub struct */
13603 +
13604 +struct _vx_limit {
13605 +       struct _vx_res_limit res[NUM_LIMITS];
13606 +};
13607 +
13608 +#ifdef CONFIG_VSERVER_DEBUG
13609 +
13610 +static inline void __dump_vx_limit(struct _vx_limit *limit)
13611 +{
13612 +       int i;
13613 +
13614 +       printk("\t_vx_limit:");
13615 +       for (i = 0; i < NUM_LIMITS; i++) {
13616 +               printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
13617 +                       i, (unsigned long)__rlim_get(limit, i),
13618 +                       (unsigned long)__rlim_rmin(limit, i),
13619 +                       (unsigned long)__rlim_rmax(limit, i),
13620 +                       (long)__rlim_soft(limit, i),
13621 +                       (long)__rlim_hard(limit, i),
13622 +                       atomic_read(&__rlim_lhit(limit, i)));
13623 +       }
13624 +}
13625 +
13626 +#endif
13627 +
13628 +#endif /* _VX_LIMIT_DEF_H */
13629 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/limit.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/limit.h
13630 --- linux-2.6.33.1/include/linux/vserver/limit.h        1970-01-01 01:00:00.000000000 +0100
13631 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/limit.h        2010-02-25 12:02:16.000000000 +0100
13632 @@ -0,0 +1,71 @@
13633 +#ifndef _VX_LIMIT_H
13634 +#define _VX_LIMIT_H
13635 +
13636 +#define VLIMIT_NSOCK   16
13637 +#define VLIMIT_OPENFD  17
13638 +#define VLIMIT_ANON    18
13639 +#define VLIMIT_SHMEM   19
13640 +#define VLIMIT_SEMARY  20
13641 +#define VLIMIT_NSEMS   21
13642 +#define VLIMIT_DENTRY  22
13643 +#define VLIMIT_MAPPED  23
13644 +
13645 +
13646 +#ifdef __KERNEL__
13647 +
13648 +#define        VLIM_NOCHECK    ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
13649 +
13650 +/*     keep in sync with CRLIM_INFINITY */
13651 +
13652 +#define        VLIM_INFINITY   (~0ULL)
13653 +
13654 +#include <asm/atomic.h>
13655 +#include <asm/resource.h>
13656 +
13657 +#ifndef RLIM_INFINITY
13658 +#warning RLIM_INFINITY is undefined
13659 +#endif
13660 +
13661 +#define __rlim_val(l, r, v)    ((l)->res[r].v)
13662 +
13663 +#define __rlim_soft(l, r)      __rlim_val(l, r, soft)
13664 +#define __rlim_hard(l, r)      __rlim_val(l, r, hard)
13665 +
13666 +#define __rlim_rcur(l, r)      __rlim_val(l, r, rcur)
13667 +#define __rlim_rmin(l, r)      __rlim_val(l, r, rmin)
13668 +#define __rlim_rmax(l, r)      __rlim_val(l, r, rmax)
13669 +
13670 +#define __rlim_lhit(l, r)      __rlim_val(l, r, lhit)
13671 +#define __rlim_hit(l, r)       atomic_inc(&__rlim_lhit(l, r))
13672 +
13673 +typedef atomic_long_t rlim_atomic_t;
13674 +typedef unsigned long rlim_t;
13675 +
13676 +#define __rlim_get(l, r)       atomic_long_read(&__rlim_rcur(l, r))
13677 +#define __rlim_set(l, r, v)    atomic_long_set(&__rlim_rcur(l, r), v)
13678 +#define __rlim_inc(l, r)       atomic_long_inc(&__rlim_rcur(l, r))
13679 +#define __rlim_dec(l, r)       atomic_long_dec(&__rlim_rcur(l, r))
13680 +#define __rlim_add(l, r, v)    atomic_long_add(v, &__rlim_rcur(l, r))
13681 +#define __rlim_sub(l, r, v)    atomic_long_sub(v, &__rlim_rcur(l, r))
13682 +
13683 +
13684 +#if    (RLIM_INFINITY == VLIM_INFINITY)
13685 +#define        VX_VLIM(r) ((long long)(long)(r))
13686 +#define        VX_RLIM(v) ((rlim_t)(v))
13687 +#else
13688 +#define        VX_VLIM(r) (((r) == RLIM_INFINITY) \
13689 +               ? VLIM_INFINITY : (long long)(r))
13690 +#define        VX_RLIM(v) (((v) == VLIM_INFINITY) \
13691 +               ? RLIM_INFINITY : (rlim_t)(v))
13692 +#endif
13693 +
13694 +struct sysinfo;
13695 +
13696 +void vx_vsi_meminfo(struct sysinfo *);
13697 +void vx_vsi_swapinfo(struct sysinfo *);
13698 +long vx_vsi_cached(struct sysinfo *);
13699 +
13700 +#define NUM_LIMITS     24
13701 +
13702 +#endif /* __KERNEL__ */
13703 +#endif /* _VX_LIMIT_H */
13704 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/limit_int.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/limit_int.h
13705 --- linux-2.6.33.1/include/linux/vserver/limit_int.h    1970-01-01 01:00:00.000000000 +0100
13706 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/limit_int.h    2010-02-25 12:02:16.000000000 +0100
13707 @@ -0,0 +1,198 @@
13708 +#ifndef _VX_LIMIT_INT_H
13709 +#define _VX_LIMIT_INT_H
13710 +
13711 +#include "context.h"
13712 +
13713 +#ifdef __KERNEL__
13714 +
13715 +#define VXD_RCRES_COND(r)      VXD_CBIT(cres, r)
13716 +#define VXD_RLIMIT_COND(r)     VXD_CBIT(limit, r)
13717 +
13718 +extern const char *vlimit_name[NUM_LIMITS];
13719 +
13720 +static inline void __vx_acc_cres(struct vx_info *vxi,
13721 +       int res, int dir, void *_data, char *_file, int _line)
13722 +{
13723 +       if (VXD_RCRES_COND(res))
13724 +               vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
13725 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13726 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13727 +                       (dir > 0) ? "++" : "--", _data, _file, _line);
13728 +       if (!vxi)
13729 +               return;
13730 +
13731 +       if (dir > 0)
13732 +               __rlim_inc(&vxi->limit, res);
13733 +       else
13734 +               __rlim_dec(&vxi->limit, res);
13735 +}
13736 +
13737 +static inline void __vx_add_cres(struct vx_info *vxi,
13738 +       int res, int amount, void *_data, char *_file, int _line)
13739 +{
13740 +       if (VXD_RCRES_COND(res))
13741 +               vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
13742 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13743 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13744 +                       amount, _data, _file, _line);
13745 +       if (amount == 0)
13746 +               return;
13747 +       if (!vxi)
13748 +               return;
13749 +       __rlim_add(&vxi->limit, res, amount);
13750 +}
13751 +
13752 +static inline
13753 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
13754 +{
13755 +       int cond = (value > __rlim_rmax(limit, res));
13756 +
13757 +       if (cond)
13758 +               __rlim_rmax(limit, res) = value;
13759 +       return cond;
13760 +}
13761 +
13762 +static inline
13763 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13764 +{
13765 +       int cond = (value < __rlim_rmin(limit, res));
13766 +
13767 +       if (cond)
13768 +               __rlim_rmin(limit, res) = value;
13769 +       return cond;
13770 +}
13771 +
13772 +static inline
13773 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13774 +{
13775 +       if (!__vx_cres_adjust_max(limit, res, value))
13776 +               __vx_cres_adjust_min(limit, res, value);
13777 +}
13778 +
13779 +
13780 +/*     return values:
13781 +        +1 ... no limit hit
13782 +        -1 ... over soft limit
13783 +         0 ... over hard limit         */
13784 +
13785 +static inline int __vx_cres_avail(struct vx_info *vxi,
13786 +       int res, int num, char *_file, int _line)
13787 +{
13788 +       struct _vx_limit *limit;
13789 +       rlim_t value;
13790 +
13791 +       if (VXD_RLIMIT_COND(res))
13792 +               vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13793 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13794 +                       (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13795 +                       (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13796 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13797 +                       num, _file, _line);
13798 +       if (!vxi)
13799 +               return 1;
13800 +
13801 +       limit = &vxi->limit;
13802 +       value = __rlim_get(limit, res);
13803 +
13804 +       if (!__vx_cres_adjust_max(limit, res, value))
13805 +               __vx_cres_adjust_min(limit, res, value);
13806 +
13807 +       if (num == 0)
13808 +               return 1;
13809 +
13810 +       if (__rlim_soft(limit, res) == RLIM_INFINITY)
13811 +               return -1;
13812 +       if (value + num <= __rlim_soft(limit, res))
13813 +               return -1;
13814 +
13815 +       if (__rlim_hard(limit, res) == RLIM_INFINITY)
13816 +               return 1;
13817 +       if (value + num <= __rlim_hard(limit, res))
13818 +               return 1;
13819 +
13820 +       __rlim_hit(limit, res);
13821 +       return 0;
13822 +}
13823 +
13824 +
13825 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13826 +
13827 +static inline
13828 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13829 +{
13830 +       rlim_t value, sum = 0;
13831 +       int res;
13832 +
13833 +       while ((res = *array++)) {
13834 +               value = __rlim_get(limit, res);
13835 +               __vx_cres_fixup(limit, res, value);
13836 +               sum += value;
13837 +       }
13838 +       return sum;
13839 +}
13840 +
13841 +static inline
13842 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13843 +{
13844 +       rlim_t value = __vx_cres_array_sum(limit, array + 1);
13845 +       int res = *array;
13846 +
13847 +       if (value == __rlim_get(limit, res))
13848 +               return value;
13849 +
13850 +       __rlim_set(limit, res, value);
13851 +       /* now adjust min/max */
13852 +       if (!__vx_cres_adjust_max(limit, res, value))
13853 +               __vx_cres_adjust_min(limit, res, value);
13854 +
13855 +       return value;
13856 +}
13857 +
13858 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13859 +       const int *array, int num, char *_file, int _line)
13860 +{
13861 +       struct _vx_limit *limit;
13862 +       rlim_t value = 0;
13863 +       int res;
13864 +
13865 +       if (num == 0)
13866 +               return 1;
13867 +       if (!vxi)
13868 +               return 1;
13869 +
13870 +       limit = &vxi->limit;
13871 +       res = *array;
13872 +       value = __vx_cres_array_sum(limit, array + 1);
13873 +
13874 +       __rlim_set(limit, res, value);
13875 +       __vx_cres_fixup(limit, res, value);
13876 +
13877 +       return __vx_cres_avail(vxi, res, num, _file, _line);
13878 +}
13879 +
13880 +
13881 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13882 +{
13883 +       rlim_t value;
13884 +       int res;
13885 +
13886 +       /* complex resources first */
13887 +       if ((id < 0) || (id == RLIMIT_RSS))
13888 +               __vx_cres_array_fixup(limit, VLA_RSS);
13889 +
13890 +       for (res = 0; res < NUM_LIMITS; res++) {
13891 +               if ((id > 0) && (res != id))
13892 +                       continue;
13893 +
13894 +               value = __rlim_get(limit, res);
13895 +               __vx_cres_fixup(limit, res, value);
13896 +
13897 +               /* not supposed to happen, maybe warn? */
13898 +               if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13899 +                       __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13900 +       }
13901 +}
13902 +
13903 +
13904 +#endif /* __KERNEL__ */
13905 +#endif /* _VX_LIMIT_INT_H */
13906 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/monitor.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/monitor.h
13907 --- linux-2.6.33.1/include/linux/vserver/monitor.h      1970-01-01 01:00:00.000000000 +0100
13908 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/monitor.h      2010-02-25 12:02:16.000000000 +0100
13909 @@ -0,0 +1,96 @@
13910 +#ifndef _VX_MONITOR_H
13911 +#define _VX_MONITOR_H
13912 +
13913 +#include <linux/types.h>
13914 +
13915 +enum {
13916 +       VXM_UNUSED = 0,
13917 +
13918 +       VXM_SYNC = 0x10,
13919 +
13920 +       VXM_UPDATE = 0x20,
13921 +       VXM_UPDATE_1,
13922 +       VXM_UPDATE_2,
13923 +
13924 +       VXM_RQINFO_1 = 0x24,
13925 +       VXM_RQINFO_2,
13926 +
13927 +       VXM_ACTIVATE = 0x40,
13928 +       VXM_DEACTIVATE,
13929 +       VXM_IDLE,
13930 +
13931 +       VXM_HOLD = 0x44,
13932 +       VXM_UNHOLD,
13933 +
13934 +       VXM_MIGRATE = 0x48,
13935 +       VXM_RESCHED,
13936 +
13937 +       /* all other bits are flags */
13938 +       VXM_SCHED = 0x80,
13939 +};
13940 +
13941 +struct _vxm_update_1 {
13942 +       uint32_t tokens_max;
13943 +       uint32_t fill_rate;
13944 +       uint32_t interval;
13945 +};
13946 +
13947 +struct _vxm_update_2 {
13948 +       uint32_t tokens_min;
13949 +       uint32_t fill_rate;
13950 +       uint32_t interval;
13951 +};
13952 +
13953 +struct _vxm_rqinfo_1 {
13954 +       uint16_t running;
13955 +       uint16_t onhold;
13956 +       uint16_t iowait;
13957 +       uint16_t uintr;
13958 +       uint32_t idle_tokens;
13959 +};
13960 +
13961 +struct _vxm_rqinfo_2 {
13962 +       uint32_t norm_time;
13963 +       uint32_t idle_time;
13964 +       uint32_t idle_skip;
13965 +};
13966 +
13967 +struct _vxm_sched {
13968 +       uint32_t tokens;
13969 +       uint32_t norm_time;
13970 +       uint32_t idle_time;
13971 +};
13972 +
13973 +struct _vxm_task {
13974 +       uint16_t pid;
13975 +       uint16_t state;
13976 +};
13977 +
13978 +struct _vxm_event {
13979 +       uint32_t jif;
13980 +       union {
13981 +               uint32_t seq;
13982 +               uint32_t sec;
13983 +       };
13984 +       union {
13985 +               uint32_t tokens;
13986 +               uint32_t nsec;
13987 +               struct _vxm_task tsk;
13988 +       };
13989 +};
13990 +
13991 +struct _vx_mon_entry {
13992 +       uint16_t type;
13993 +       uint16_t xid;
13994 +       union {
13995 +               struct _vxm_event ev;
13996 +               struct _vxm_sched sd;
13997 +               struct _vxm_update_1 u1;
13998 +               struct _vxm_update_2 u2;
13999 +               struct _vxm_rqinfo_1 q1;
14000 +               struct _vxm_rqinfo_2 q2;
14001 +       };
14002 +};
14003 +
14004 +
14005 +#endif /* _VX_MONITOR_H */
14006 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/network_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/network_cmd.h
14007 --- linux-2.6.33.1/include/linux/vserver/network_cmd.h  1970-01-01 01:00:00.000000000 +0100
14008 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/network_cmd.h  2010-02-25 12:02:16.000000000 +0100
14009 @@ -0,0 +1,150 @@
14010 +#ifndef _VX_NETWORK_CMD_H
14011 +#define _VX_NETWORK_CMD_H
14012 +
14013 +
14014 +/* vinfo commands */
14015 +
14016 +#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
14017 +
14018 +#ifdef __KERNEL__
14019 +extern int vc_task_nid(uint32_t);
14020 +
14021 +#endif /* __KERNEL__ */
14022 +
14023 +#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
14024 +
14025 +struct vcmd_nx_info_v0 {
14026 +       uint32_t nid;
14027 +       /* more to come */
14028 +};
14029 +
14030 +#ifdef __KERNEL__
14031 +extern int vc_nx_info(struct nx_info *, void __user *);
14032 +
14033 +#endif /* __KERNEL__ */
14034 +
14035 +#include <linux/in.h>
14036 +#include <linux/in6.h>
14037 +
14038 +#define VCMD_net_create_v0     VC_CMD(VNET, 1, 0)
14039 +#define VCMD_net_create                VC_CMD(VNET, 1, 1)
14040 +
14041 +struct  vcmd_net_create {
14042 +       uint64_t flagword;
14043 +};
14044 +
14045 +#define VCMD_net_migrate       VC_CMD(NETMIG, 1, 0)
14046 +
14047 +#define VCMD_net_add           VC_CMD(NETALT, 1, 0)
14048 +#define VCMD_net_remove                VC_CMD(NETALT, 2, 0)
14049 +
14050 +struct vcmd_net_addr_v0 {
14051 +       uint16_t type;
14052 +       uint16_t count;
14053 +       struct in_addr ip[4];
14054 +       struct in_addr mask[4];
14055 +};
14056 +
14057 +#define VCMD_net_add_ipv4      VC_CMD(NETALT, 1, 1)
14058 +#define VCMD_net_remove_ipv4   VC_CMD(NETALT, 2, 1)
14059 +
14060 +struct vcmd_net_addr_ipv4_v1 {
14061 +       uint16_t type;
14062 +       uint16_t flags;
14063 +       struct in_addr ip;
14064 +       struct in_addr mask;
14065 +};
14066 +
14067 +#define VCMD_net_add_ipv6      VC_CMD(NETALT, 3, 1)
14068 +#define VCMD_net_remove_ipv6   VC_CMD(NETALT, 4, 1)
14069 +
14070 +struct vcmd_net_addr_ipv6_v1 {
14071 +       uint16_t type;
14072 +       uint16_t flags;
14073 +       uint32_t prefix;
14074 +       struct in6_addr ip;
14075 +       struct in6_addr mask;
14076 +};
14077 +
14078 +#define VCMD_add_match_ipv4    VC_CMD(NETALT, 5, 0)
14079 +#define VCMD_get_match_ipv4    VC_CMD(NETALT, 6, 0)
14080 +
14081 +struct vcmd_match_ipv4_v0 {
14082 +       uint16_t type;
14083 +       uint16_t flags;
14084 +       uint16_t parent;
14085 +       uint16_t prefix;
14086 +       struct in_addr ip;
14087 +       struct in_addr ip2;
14088 +       struct in_addr mask;
14089 +};
14090 +
14091 +#define VCMD_add_match_ipv6    VC_CMD(NETALT, 7, 0)
14092 +#define VCMD_get_match_ipv6    VC_CMD(NETALT, 8, 0)
14093 +
14094 +struct vcmd_match_ipv6_v0 {
14095 +       uint16_t type;
14096 +       uint16_t flags;
14097 +       uint16_t parent;
14098 +       uint16_t prefix;
14099 +       struct in6_addr ip;
14100 +       struct in6_addr ip2;
14101 +       struct in6_addr mask;
14102 +};
14103 +
14104 +
14105 +#ifdef __KERNEL__
14106 +extern int vc_net_create(uint32_t, void __user *);
14107 +extern int vc_net_migrate(struct nx_info *, void __user *);
14108 +
14109 +extern int vc_net_add(struct nx_info *, void __user *);
14110 +extern int vc_net_remove(struct nx_info *, void __user *);
14111 +
14112 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
14113 +extern int vc_net_remove_ipv4(struct nx_info *, void __user *);
14114 +
14115 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
14116 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
14117 +
14118 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
14119 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
14120 +
14121 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
14122 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
14123 +
14124 +#endif /* __KERNEL__ */
14125 +
14126 +
14127 +/* flag commands */
14128 +
14129 +#define VCMD_get_nflags                VC_CMD(FLAGS, 5, 0)
14130 +#define VCMD_set_nflags                VC_CMD(FLAGS, 6, 0)
14131 +
14132 +struct vcmd_net_flags_v0 {
14133 +       uint64_t flagword;
14134 +       uint64_t mask;
14135 +};
14136 +
14137 +#ifdef __KERNEL__
14138 +extern int vc_get_nflags(struct nx_info *, void __user *);
14139 +extern int vc_set_nflags(struct nx_info *, void __user *);
14140 +
14141 +#endif /* __KERNEL__ */
14142 +
14143 +
14144 +/* network caps commands */
14145 +
14146 +#define VCMD_get_ncaps         VC_CMD(FLAGS, 7, 0)
14147 +#define VCMD_set_ncaps         VC_CMD(FLAGS, 8, 0)
14148 +
14149 +struct vcmd_net_caps_v0 {
14150 +       uint64_t ncaps;
14151 +       uint64_t cmask;
14152 +};
14153 +
14154 +#ifdef __KERNEL__
14155 +extern int vc_get_ncaps(struct nx_info *, void __user *);
14156 +extern int vc_set_ncaps(struct nx_info *, void __user *);
14157 +
14158 +#endif /* __KERNEL__ */
14159 +#endif /* _VX_CONTEXT_CMD_H */
14160 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/network.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/network.h
14161 --- linux-2.6.33.1/include/linux/vserver/network.h      1970-01-01 01:00:00.000000000 +0100
14162 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/network.h      2010-02-25 12:02:16.000000000 +0100
14163 @@ -0,0 +1,146 @@
14164 +#ifndef _VX_NETWORK_H
14165 +#define _VX_NETWORK_H
14166 +
14167 +#include <linux/types.h>
14168 +
14169 +
14170 +#define MAX_N_CONTEXT  65535   /* Arbitrary limit */
14171 +
14172 +
14173 +/* network flags */
14174 +
14175 +#define NXF_INFO_PRIVATE       0x00000008
14176 +
14177 +#define NXF_SINGLE_IP          0x00000100
14178 +#define NXF_LBACK_REMAP                0x00000200
14179 +#define NXF_LBACK_ALLOW                0x00000400
14180 +
14181 +#define NXF_HIDE_NETIF         0x02000000
14182 +#define NXF_HIDE_LBACK         0x04000000
14183 +
14184 +#define NXF_STATE_SETUP                (1ULL << 32)
14185 +#define NXF_STATE_ADMIN                (1ULL << 34)
14186 +
14187 +#define NXF_SC_HELPER          (1ULL << 36)
14188 +#define NXF_PERSISTENT         (1ULL << 38)
14189 +
14190 +#define NXF_ONE_TIME           (0x0005ULL << 32)
14191 +
14192 +
14193 +#define        NXF_INIT_SET            (__nxf_init_set())
14194 +
14195 +static inline uint64_t __nxf_init_set(void) {
14196 +       return    NXF_STATE_ADMIN
14197 +#ifdef CONFIG_VSERVER_AUTO_LBACK
14198 +               | NXF_LBACK_REMAP
14199 +               | NXF_HIDE_LBACK
14200 +#endif
14201 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
14202 +               | NXF_SINGLE_IP
14203 +#endif
14204 +               | NXF_HIDE_NETIF;
14205 +}
14206 +
14207 +
14208 +/* network caps */
14209 +
14210 +#define NXC_TUN_CREATE         0x00000001
14211 +
14212 +#define NXC_RAW_ICMP           0x00000100
14213 +
14214 +
14215 +/* address types */
14216 +
14217 +#define NXA_TYPE_IPV4          0x0001
14218 +#define NXA_TYPE_IPV6          0x0002
14219 +
14220 +#define NXA_TYPE_NONE          0x0000
14221 +#define NXA_TYPE_ANY           0x00FF
14222 +
14223 +#define NXA_TYPE_ADDR          0x0010
14224 +#define NXA_TYPE_MASK          0x0020
14225 +#define NXA_TYPE_RANGE         0x0040
14226 +
14227 +#define NXA_MASK_ALL           (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
14228 +
14229 +#define NXA_MOD_BCAST          0x0100
14230 +#define NXA_MOD_LBACK          0x0200
14231 +
14232 +#define NXA_LOOPBACK           0x1000
14233 +
14234 +#define NXA_MASK_BIND          (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
14235 +#define NXA_MASK_SHOW          (NXA_MASK_ALL | NXA_LOOPBACK)
14236 +
14237 +#ifdef __KERNEL__
14238 +
14239 +#include <linux/list.h>
14240 +#include <linux/spinlock.h>
14241 +#include <linux/rcupdate.h>
14242 +#include <linux/in.h>
14243 +#include <linux/in6.h>
14244 +#include <asm/atomic.h>
14245 +
14246 +struct nx_addr_v4 {
14247 +       struct nx_addr_v4 *next;
14248 +       struct in_addr ip[2];
14249 +       struct in_addr mask;
14250 +       uint16_t type;
14251 +       uint16_t flags;
14252 +};
14253 +
14254 +struct nx_addr_v6 {
14255 +       struct nx_addr_v6 *next;
14256 +       struct in6_addr ip;
14257 +       struct in6_addr mask;
14258 +       uint32_t prefix;
14259 +       uint16_t type;
14260 +       uint16_t flags;
14261 +};
14262 +
14263 +struct nx_info {
14264 +       struct hlist_node nx_hlist;     /* linked list of nxinfos */
14265 +       nid_t nx_id;                    /* vnet id */
14266 +       atomic_t nx_usecnt;             /* usage count */
14267 +       atomic_t nx_tasks;              /* tasks count */
14268 +       int nx_state;                   /* context state */
14269 +
14270 +       uint64_t nx_flags;              /* network flag word */
14271 +       uint64_t nx_ncaps;              /* network capabilities */
14272 +
14273 +       struct in_addr v4_lback;        /* Loopback address */
14274 +       struct in_addr v4_bcast;        /* Broadcast address */
14275 +       struct nx_addr_v4 v4;           /* First/Single ipv4 address */
14276 +#ifdef CONFIG_IPV6
14277 +       struct nx_addr_v6 v6;           /* First/Single ipv6 address */
14278 +#endif
14279 +       char nx_name[65];               /* network context name */
14280 +};
14281 +
14282 +
14283 +/* status flags */
14284 +
14285 +#define NXS_HASHED      0x0001
14286 +#define NXS_SHUTDOWN    0x0100
14287 +#define NXS_RELEASED    0x8000
14288 +
14289 +extern struct nx_info *lookup_nx_info(int);
14290 +
14291 +extern int get_nid_list(int, unsigned int *, int);
14292 +extern int nid_is_hashed(nid_t);
14293 +
14294 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
14295 +
14296 +extern long vs_net_change(struct nx_info *, unsigned int);
14297 +
14298 +struct sock;
14299 +
14300 +
14301 +#define NX_IPV4(n)     ((n)->v4.type != NXA_TYPE_NONE)
14302 +#ifdef  CONFIG_IPV6
14303 +#define NX_IPV6(n)     ((n)->v6.type != NXA_TYPE_NONE)
14304 +#else
14305 +#define NX_IPV6(n)     (0)
14306 +#endif
14307 +
14308 +#endif /* __KERNEL__ */
14309 +#endif /* _VX_NETWORK_H */
14310 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/percpu.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/percpu.h
14311 --- linux-2.6.33.1/include/linux/vserver/percpu.h       1970-01-01 01:00:00.000000000 +0100
14312 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/percpu.h       2010-02-25 12:02:16.000000000 +0100
14313 @@ -0,0 +1,14 @@
14314 +#ifndef _VX_PERCPU_H
14315 +#define _VX_PERCPU_H
14316 +
14317 +#include "cvirt_def.h"
14318 +#include "sched_def.h"
14319 +
14320 +struct _vx_percpu {
14321 +       struct _vx_cvirt_pc cvirt;
14322 +       struct _vx_sched_pc sched;
14323 +};
14324 +
14325 +#define        PERCPU_PERCTX   (sizeof(struct _vx_percpu))
14326 +
14327 +#endif /* _VX_PERCPU_H */
14328 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/pid.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/pid.h
14329 --- linux-2.6.33.1/include/linux/vserver/pid.h  1970-01-01 01:00:00.000000000 +0100
14330 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/pid.h  2010-02-25 12:02:16.000000000 +0100
14331 @@ -0,0 +1,51 @@
14332 +#ifndef _VSERVER_PID_H
14333 +#define _VSERVER_PID_H
14334 +
14335 +/* pid faking stuff */
14336 +
14337 +#define vx_info_map_pid(v, p) \
14338 +       __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
14339 +#define vx_info_map_tgid(v,p)  vx_info_map_pid(v,p)
14340 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
14341 +#define vx_map_tgid(p) vx_map_pid(p)
14342 +
14343 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
14344 +       const char *func, const char *file, int line)
14345 +{
14346 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14347 +               vxfprintk(VXD_CBIT(cvirt, 2),
14348 +                       "vx_map_tgid: %p/%llx: %d -> %d",
14349 +                       vxi, (long long)vxi->vx_flags, pid,
14350 +                       (pid && pid == vxi->vx_initpid) ? 1 : pid,
14351 +                       func, file, line);
14352 +               if (pid == 0)
14353 +                       return 0;
14354 +               if (pid == vxi->vx_initpid)
14355 +                       return 1;
14356 +       }
14357 +       return pid;
14358 +}
14359 +
14360 +#define vx_info_rmap_pid(v, p) \
14361 +       __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
14362 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
14363 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
14364 +
14365 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
14366 +       const char *func, const char *file, int line)
14367 +{
14368 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
14369 +               vxfprintk(VXD_CBIT(cvirt, 2),
14370 +                       "vx_rmap_tgid: %p/%llx: %d -> %d",
14371 +                       vxi, (long long)vxi->vx_flags, pid,
14372 +                       (pid == 1) ? vxi->vx_initpid : pid,
14373 +                       func, file, line);
14374 +               if ((pid == 1) && vxi->vx_initpid)
14375 +                       return vxi->vx_initpid;
14376 +               if (pid == vxi->vx_initpid)
14377 +                       return ~0U;
14378 +       }
14379 +       return pid;
14380 +}
14381 +
14382 +#endif
14383 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/sched_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/sched_cmd.h
14384 --- linux-2.6.33.1/include/linux/vserver/sched_cmd.h    1970-01-01 01:00:00.000000000 +0100
14385 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/sched_cmd.h    2010-02-25 12:02:16.000000000 +0100
14386 @@ -0,0 +1,108 @@
14387 +#ifndef _VX_SCHED_CMD_H
14388 +#define _VX_SCHED_CMD_H
14389 +
14390 +
14391 +/*  sched vserver commands */
14392 +
14393 +#define VCMD_set_sched_v2      VC_CMD(SCHED, 1, 2)
14394 +#define VCMD_set_sched_v3      VC_CMD(SCHED, 1, 3)
14395 +#define VCMD_set_sched_v4      VC_CMD(SCHED, 1, 4)
14396 +
14397 +struct vcmd_set_sched_v2 {
14398 +       int32_t fill_rate;
14399 +       int32_t interval;
14400 +       int32_t tokens;
14401 +       int32_t tokens_min;
14402 +       int32_t tokens_max;
14403 +       uint64_t cpu_mask;
14404 +};
14405 +
14406 +struct vcmd_set_sched_v3 {
14407 +       uint32_t set_mask;
14408 +       int32_t fill_rate;
14409 +       int32_t interval;
14410 +       int32_t tokens;
14411 +       int32_t tokens_min;
14412 +       int32_t tokens_max;
14413 +       int32_t priority_bias;
14414 +};
14415 +
14416 +struct vcmd_set_sched_v4 {
14417 +       uint32_t set_mask;
14418 +       int32_t fill_rate;
14419 +       int32_t interval;
14420 +       int32_t tokens;
14421 +       int32_t tokens_min;
14422 +       int32_t tokens_max;
14423 +       int32_t prio_bias;
14424 +       int32_t cpu_id;
14425 +       int32_t bucket_id;
14426 +};
14427 +
14428 +#define VCMD_set_sched         VC_CMD(SCHED, 1, 5)
14429 +#define VCMD_get_sched         VC_CMD(SCHED, 2, 5)
14430 +
14431 +struct vcmd_sched_v5 {
14432 +       uint32_t mask;
14433 +       int32_t cpu_id;
14434 +       int32_t bucket_id;
14435 +       int32_t fill_rate[2];
14436 +       int32_t interval[2];
14437 +       int32_t tokens;
14438 +       int32_t tokens_min;
14439 +       int32_t tokens_max;
14440 +       int32_t prio_bias;
14441 +};
14442 +
14443 +#define VXSM_FILL_RATE         0x0001
14444 +#define VXSM_INTERVAL          0x0002
14445 +#define VXSM_FILL_RATE2                0x0004
14446 +#define VXSM_INTERVAL2         0x0008
14447 +#define VXSM_TOKENS            0x0010
14448 +#define VXSM_TOKENS_MIN                0x0020
14449 +#define VXSM_TOKENS_MAX                0x0040
14450 +#define VXSM_PRIO_BIAS         0x0100
14451 +
14452 +#define VXSM_IDLE_TIME         0x0200
14453 +#define VXSM_FORCE             0x0400
14454 +
14455 +#define        VXSM_V3_MASK            0x0173
14456 +#define        VXSM_SET_MASK           0x01FF
14457 +
14458 +#define VXSM_CPU_ID            0x1000
14459 +#define VXSM_BUCKET_ID         0x2000
14460 +
14461 +#define VXSM_MSEC              0x4000
14462 +
14463 +#define SCHED_KEEP             (-2)    /* only for v2 */
14464 +
14465 +#ifdef __KERNEL__
14466 +
14467 +#include <linux/compiler.h>
14468 +
14469 +extern int vc_set_sched_v2(struct vx_info *, void __user *);
14470 +extern int vc_set_sched_v3(struct vx_info *, void __user *);
14471 +extern int vc_set_sched_v4(struct vx_info *, void __user *);
14472 +extern int vc_set_sched(struct vx_info *, void __user *);
14473 +extern int vc_get_sched(struct vx_info *, void __user *);
14474 +
14475 +#endif /* __KERNEL__ */
14476 +
14477 +#define VCMD_sched_info                VC_CMD(SCHED, 3, 0)
14478 +
14479 +struct vcmd_sched_info {
14480 +       int32_t cpu_id;
14481 +       int32_t bucket_id;
14482 +       uint64_t user_msec;
14483 +       uint64_t sys_msec;
14484 +       uint64_t hold_msec;
14485 +       uint32_t token_usec;
14486 +       int32_t vavavoom;
14487 +};
14488 +
14489 +#ifdef __KERNEL__
14490 +
14491 +extern int vc_sched_info(struct vx_info *, void __user *);
14492 +
14493 +#endif /* __KERNEL__ */
14494 +#endif /* _VX_SCHED_CMD_H */
14495 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/sched_def.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/sched_def.h
14496 --- linux-2.6.33.1/include/linux/vserver/sched_def.h    1970-01-01 01:00:00.000000000 +0100
14497 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/sched_def.h    2010-02-25 12:02:16.000000000 +0100
14498 @@ -0,0 +1,68 @@
14499 +#ifndef _VX_SCHED_DEF_H
14500 +#define _VX_SCHED_DEF_H
14501 +
14502 +#include <linux/spinlock.h>
14503 +#include <linux/jiffies.h>
14504 +#include <linux/cpumask.h>
14505 +#include <asm/atomic.h>
14506 +#include <asm/param.h>
14507 +
14508 +
14509 +/* context sub struct */
14510 +
14511 +struct _vx_sched {
14512 +       spinlock_t tokens_lock;         /* lock for token bucket */
14513 +
14514 +       int tokens;                     /* number of CPU tokens */
14515 +       int fill_rate[2];               /* Fill rate: add X tokens... */
14516 +       int interval[2];                /* Divisor:   per Y jiffies   */
14517 +       int tokens_min;                 /* Limit:     minimum for unhold */
14518 +       int tokens_max;                 /* Limit:     no more than N tokens */
14519 +
14520 +       int prio_bias;                  /* bias offset for priority */
14521 +
14522 +       unsigned update_mask;           /* which features should be updated */
14523 +       cpumask_t update;               /* CPUs which should update */
14524 +};
14525 +
14526 +struct _vx_sched_pc {
14527 +       int tokens;                     /* number of CPU tokens */
14528 +       int flags;                      /* bucket flags */
14529 +
14530 +       int fill_rate[2];               /* Fill rate: add X tokens... */
14531 +       int interval[2];                /* Divisor:   per Y jiffies   */
14532 +       int tokens_min;                 /* Limit:     minimum for unhold */
14533 +       int tokens_max;                 /* Limit:     no more than N tokens */
14534 +
14535 +       int prio_bias;                  /* bias offset for priority */
14536 +       int vavavoom;                   /* last calculated vavavoom */
14537 +
14538 +       unsigned long norm_time;        /* last time accounted */
14539 +       unsigned long idle_time;        /* non linear time for fair sched */
14540 +       unsigned long token_time;       /* token time for accounting */
14541 +       unsigned long onhold;           /* jiffies when put on hold */
14542 +
14543 +       uint64_t user_ticks;            /* token tick events */
14544 +       uint64_t sys_ticks;             /* token tick events */
14545 +       uint64_t hold_ticks;            /* token ticks paused */
14546 +};
14547 +
14548 +
14549 +#define VXSF_ONHOLD    0x0001
14550 +#define VXSF_IDLE_TIME 0x0100
14551 +
14552 +#ifdef CONFIG_VSERVER_DEBUG
14553 +
14554 +static inline void __dump_vx_sched(struct _vx_sched *sched)
14555 +{
14556 +       printk("\t_vx_sched:\n");
14557 +       printk("\t tokens: %4d/%4d, %4d/%4d, %4d, %4d\n",
14558 +               sched->fill_rate[0], sched->interval[0],
14559 +               sched->fill_rate[1], sched->interval[1],
14560 +               sched->tokens_min, sched->tokens_max);
14561 +       printk("\t priority = %4d\n", sched->prio_bias);
14562 +}
14563 +
14564 +#endif
14565 +
14566 +#endif /* _VX_SCHED_DEF_H */
14567 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/sched.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/sched.h
14568 --- linux-2.6.33.1/include/linux/vserver/sched.h        1970-01-01 01:00:00.000000000 +0100
14569 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/sched.h        2010-02-25 12:02:16.000000000 +0100
14570 @@ -0,0 +1,26 @@
14571 +#ifndef _VX_SCHED_H
14572 +#define _VX_SCHED_H
14573 +
14574 +
14575 +#ifdef __KERNEL__
14576 +
14577 +struct timespec;
14578 +
14579 +void vx_vsi_uptime(struct timespec *, struct timespec *);
14580 +
14581 +
14582 +struct vx_info;
14583 +
14584 +void vx_update_load(struct vx_info *);
14585 +
14586 +
14587 +int vx_tokens_recalc(struct _vx_sched_pc *,
14588 +       unsigned long *, unsigned long *, int [2]);
14589 +
14590 +void vx_update_sched_param(struct _vx_sched *sched,
14591 +       struct _vx_sched_pc *sched_pc);
14592 +
14593 +#endif /* __KERNEL__ */
14594 +#else  /* _VX_SCHED_H */
14595 +#warning duplicate inclusion
14596 +#endif /* _VX_SCHED_H */
14597 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/signal_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/signal_cmd.h
14598 --- linux-2.6.33.1/include/linux/vserver/signal_cmd.h   1970-01-01 01:00:00.000000000 +0100
14599 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/signal_cmd.h   2010-02-25 12:02:16.000000000 +0100
14600 @@ -0,0 +1,43 @@
14601 +#ifndef _VX_SIGNAL_CMD_H
14602 +#define _VX_SIGNAL_CMD_H
14603 +
14604 +
14605 +/*  signalling vserver commands */
14606 +
14607 +#define VCMD_ctx_kill          VC_CMD(PROCTRL, 1, 0)
14608 +#define VCMD_wait_exit         VC_CMD(EVENT, 99, 0)
14609 +
14610 +struct vcmd_ctx_kill_v0 {
14611 +       int32_t pid;
14612 +       int32_t sig;
14613 +};
14614 +
14615 +struct vcmd_wait_exit_v0 {
14616 +       int32_t reboot_cmd;
14617 +       int32_t exit_code;
14618 +};
14619 +
14620 +#ifdef __KERNEL__
14621 +
14622 +extern int vc_ctx_kill(struct vx_info *, void __user *);
14623 +extern int vc_wait_exit(struct vx_info *, void __user *);
14624 +
14625 +#endif /* __KERNEL__ */
14626 +
14627 +/*  process alteration commands */
14628 +
14629 +#define VCMD_get_pflags                VC_CMD(PROCALT, 5, 0)
14630 +#define VCMD_set_pflags                VC_CMD(PROCALT, 6, 0)
14631 +
14632 +struct vcmd_pflags_v0 {
14633 +       uint32_t flagword;
14634 +       uint32_t mask;
14635 +};
14636 +
14637 +#ifdef __KERNEL__
14638 +
14639 +extern int vc_get_pflags(uint32_t pid, void __user *);
14640 +extern int vc_set_pflags(uint32_t pid, void __user *);
14641 +
14642 +#endif /* __KERNEL__ */
14643 +#endif /* _VX_SIGNAL_CMD_H */
14644 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/signal.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/signal.h
14645 --- linux-2.6.33.1/include/linux/vserver/signal.h       1970-01-01 01:00:00.000000000 +0100
14646 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/signal.h       2010-02-25 12:02:16.000000000 +0100
14647 @@ -0,0 +1,14 @@
14648 +#ifndef _VX_SIGNAL_H
14649 +#define _VX_SIGNAL_H
14650 +
14651 +
14652 +#ifdef __KERNEL__
14653 +
14654 +struct vx_info;
14655 +
14656 +int vx_info_kill(struct vx_info *, int, int);
14657 +
14658 +#endif /* __KERNEL__ */
14659 +#else  /* _VX_SIGNAL_H */
14660 +#warning duplicate inclusion
14661 +#endif /* _VX_SIGNAL_H */
14662 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/space_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/space_cmd.h
14663 --- linux-2.6.33.1/include/linux/vserver/space_cmd.h    1970-01-01 01:00:00.000000000 +0100
14664 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/space_cmd.h    2010-02-25 12:02:16.000000000 +0100
14665 @@ -0,0 +1,38 @@
14666 +#ifndef _VX_SPACE_CMD_H
14667 +#define _VX_SPACE_CMD_H
14668 +
14669 +
14670 +#define VCMD_enter_space_v0    VC_CMD(PROCALT, 1, 0)
14671 +#define VCMD_enter_space_v1    VC_CMD(PROCALT, 1, 1)
14672 +#define VCMD_enter_space       VC_CMD(PROCALT, 1, 2)
14673 +
14674 +#define VCMD_set_space_v0      VC_CMD(PROCALT, 3, 0)
14675 +#define VCMD_set_space_v1      VC_CMD(PROCALT, 3, 1)
14676 +#define VCMD_set_space         VC_CMD(PROCALT, 3, 2)
14677 +
14678 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
14679 +
14680 +#define VCMD_get_space_mask    VC_CMD(VSPACE, 0, 1)
14681 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
14682 +
14683 +
14684 +struct vcmd_space_mask_v1 {
14685 +       uint64_t mask;
14686 +};
14687 +
14688 +struct vcmd_space_mask_v2 {
14689 +       uint64_t mask;
14690 +       uint32_t index;
14691 +};
14692 +
14693 +
14694 +#ifdef __KERNEL__
14695 +
14696 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
14697 +extern int vc_set_space_v1(struct vx_info *, void __user *);
14698 +extern int vc_enter_space(struct vx_info *, void __user *);
14699 +extern int vc_set_space(struct vx_info *, void __user *);
14700 +extern int vc_get_space_mask(void __user *, int);
14701 +
14702 +#endif /* __KERNEL__ */
14703 +#endif /* _VX_SPACE_CMD_H */
14704 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/space.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/space.h
14705 --- linux-2.6.33.1/include/linux/vserver/space.h        1970-01-01 01:00:00.000000000 +0100
14706 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/space.h        2010-02-25 12:02:16.000000000 +0100
14707 @@ -0,0 +1,12 @@
14708 +#ifndef _VX_SPACE_H
14709 +#define _VX_SPACE_H
14710 +
14711 +#include <linux/types.h>
14712 +
14713 +struct vx_info;
14714 +
14715 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
14716 +
14717 +#else  /* _VX_SPACE_H */
14718 +#warning duplicate inclusion
14719 +#endif /* _VX_SPACE_H */
14720 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/switch.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/switch.h
14721 --- linux-2.6.33.1/include/linux/vserver/switch.h       1970-01-01 01:00:00.000000000 +0100
14722 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/switch.h       2010-02-25 12:02:16.000000000 +0100
14723 @@ -0,0 +1,98 @@
14724 +#ifndef _VX_SWITCH_H
14725 +#define _VX_SWITCH_H
14726 +
14727 +#include <linux/types.h>
14728 +
14729 +
14730 +#define VC_CATEGORY(c)         (((c) >> 24) & 0x3F)
14731 +#define VC_COMMAND(c)          (((c) >> 16) & 0xFF)
14732 +#define VC_VERSION(c)          ((c) & 0xFFF)
14733 +
14734 +#define VC_CMD(c, i, v)                ((((VC_CAT_ ## c) & 0x3F) << 24) \
14735 +                               | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
14736 +
14737 +/*
14738 +
14739 +  Syscall Matrix V2.8
14740 +
14741 +        |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
14742 +        |STATS  |DESTROY|ALTER  |CHANGE |LIMIT  |TEST   | |       |       |
14743 +        |INFO   |SETUP  |       |MOVE   |       |       | |       |       |
14744 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14745 +  SYSTEM |VERSION|VSETUP |VHOST  |       |       |       | |DEVICE |       |
14746 +  HOST   |     00|     01|     02|     03|     04|     05| |     06|     07|
14747 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14748 +  CPU    |       |VPROC  |PROCALT|PROCMIG|PROCTRL|       | |SCHED. |       |
14749 +  PROCESS|     08|     09|     10|     11|     12|     13| |     14|     15|
14750 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14751 +  MEMORY |       |       |       |       |MEMCTRL|       | |SWAP   |       |
14752 +        |     16|     17|     18|     19|     20|     21| |     22|     23|
14753 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14754 +  NETWORK|       |VNET   |NETALT |NETMIG |NETCTL |       | |SERIAL |       |
14755 +        |     24|     25|     26|     27|     28|     29| |     30|     31|
14756 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14757 +  DISK   |       |       |       |TAGMIG |DLIMIT |       | |INODE  |       |
14758 +  VFS    |     32|     33|     34|     35|     36|     37| |     38|     39|
14759 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14760 +  OTHER  |VSTAT  |       |       |       |       |       | |VINFO  |       |
14761 +        |     40|     41|     42|     43|     44|     45| |     46|     47|
14762 +  =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
14763 +  SPECIAL|EVENT  |       |       |       |FLAGS  |       | |VSPACE |       |
14764 +        |     48|     49|     50|     51|     52|     53| |     54|     55|
14765 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14766 +  SPECIAL|DEBUG  |       |       |       |RLIMIT |SYSCALL| |       |COMPAT |
14767 +        |     56|     57|     58|     59|     60|TEST 61| |     62|     63|
14768 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
14769 +
14770 +*/
14771 +
14772 +#define VC_CAT_VERSION         0
14773 +
14774 +#define VC_CAT_VSETUP          1
14775 +#define VC_CAT_VHOST           2
14776 +
14777 +#define VC_CAT_DEVICE          6
14778 +
14779 +#define VC_CAT_VPROC           9
14780 +#define VC_CAT_PROCALT         10
14781 +#define VC_CAT_PROCMIG         11
14782 +#define VC_CAT_PROCTRL         12
14783 +
14784 +#define VC_CAT_SCHED           14
14785 +#define VC_CAT_MEMCTRL         20
14786 +
14787 +#define VC_CAT_VNET            25
14788 +#define VC_CAT_NETALT          26
14789 +#define VC_CAT_NETMIG          27
14790 +#define VC_CAT_NETCTRL         28
14791 +
14792 +#define VC_CAT_TAGMIG          35
14793 +#define VC_CAT_DLIMIT          36
14794 +#define VC_CAT_INODE           38
14795 +
14796 +#define VC_CAT_VSTAT           40
14797 +#define VC_CAT_VINFO           46
14798 +#define VC_CAT_EVENT           48
14799 +
14800 +#define VC_CAT_FLAGS           52
14801 +#define VC_CAT_VSPACE          54
14802 +#define VC_CAT_DEBUG           56
14803 +#define VC_CAT_RLIMIT          60
14804 +
14805 +#define VC_CAT_SYSTEST         61
14806 +#define VC_CAT_COMPAT          63
14807 +
14808 +/*  query version */
14809 +
14810 +#define VCMD_get_version       VC_CMD(VERSION, 0, 0)
14811 +#define VCMD_get_vci           VC_CMD(VERSION, 1, 0)
14812 +
14813 +
14814 +#ifdef __KERNEL__
14815 +
14816 +#include <linux/errno.h>
14817 +
14818 +#endif /* __KERNEL__ */
14819 +
14820 +#endif /* _VX_SWITCH_H */
14821 +
14822 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/tag_cmd.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/tag_cmd.h
14823 --- linux-2.6.33.1/include/linux/vserver/tag_cmd.h      1970-01-01 01:00:00.000000000 +0100
14824 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/tag_cmd.h      2010-02-25 12:02:16.000000000 +0100
14825 @@ -0,0 +1,22 @@
14826 +#ifndef _VX_TAG_CMD_H
14827 +#define _VX_TAG_CMD_H
14828 +
14829 +
14830 +/* vinfo commands */
14831 +
14832 +#define VCMD_task_tag          VC_CMD(VINFO, 3, 0)
14833 +
14834 +#ifdef __KERNEL__
14835 +extern int vc_task_tag(uint32_t);
14836 +
14837 +#endif /* __KERNEL__ */
14838 +
14839 +/* context commands */
14840 +
14841 +#define VCMD_tag_migrate       VC_CMD(TAGMIG, 1, 0)
14842 +
14843 +#ifdef __KERNEL__
14844 +extern int vc_tag_migrate(uint32_t);
14845 +
14846 +#endif /* __KERNEL__ */
14847 +#endif /* _VX_TAG_CMD_H */
14848 diff -NurpP --minimal linux-2.6.33.1/include/linux/vserver/tag.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/tag.h
14849 --- linux-2.6.33.1/include/linux/vserver/tag.h  1970-01-01 01:00:00.000000000 +0100
14850 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vserver/tag.h  2010-02-25 12:02:16.000000000 +0100
14851 @@ -0,0 +1,143 @@
14852 +#ifndef _DX_TAG_H
14853 +#define _DX_TAG_H
14854 +
14855 +#include <linux/types.h>
14856 +
14857 +
14858 +#define DX_TAG(in)     (IS_TAGGED(in))
14859 +
14860 +
14861 +#ifdef CONFIG_TAG_NFSD
14862 +#define DX_TAG_NFSD    1
14863 +#else
14864 +#define DX_TAG_NFSD    0
14865 +#endif
14866 +
14867 +
14868 +#ifdef CONFIG_TAGGING_NONE
14869 +
14870 +#define MAX_UID                0xFFFFFFFF
14871 +#define MAX_GID                0xFFFFFFFF
14872 +
14873 +#define INOTAG_TAG(cond, uid, gid, tag)        (0)
14874 +
14875 +#define TAGINO_UID(cond, uid, tag)     (uid)
14876 +#define TAGINO_GID(cond, gid, tag)     (gid)
14877 +
14878 +#endif
14879 +
14880 +
14881 +#ifdef CONFIG_TAGGING_GID16
14882 +
14883 +#define MAX_UID                0xFFFFFFFF
14884 +#define MAX_GID                0x0000FFFF
14885 +
14886 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14887 +       ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
14888 +
14889 +#define TAGINO_UID(cond, uid, tag)     (uid)
14890 +#define TAGINO_GID(cond, gid, tag)     \
14891 +       ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14892 +
14893 +#endif
14894 +
14895 +
14896 +#ifdef CONFIG_TAGGING_ID24
14897 +
14898 +#define MAX_UID                0x00FFFFFF
14899 +#define MAX_GID                0x00FFFFFF
14900 +
14901 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14902 +       ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14903 +
14904 +#define TAGINO_UID(cond, uid, tag)     \
14905 +       ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14906 +#define TAGINO_GID(cond, gid, tag)     \
14907 +       ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14908 +
14909 +#endif
14910 +
14911 +
14912 +#ifdef CONFIG_TAGGING_UID16
14913 +
14914 +#define MAX_UID                0x0000FFFF
14915 +#define MAX_GID                0xFFFFFFFF
14916 +
14917 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14918 +       ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14919 +
14920 +#define TAGINO_UID(cond, uid, tag)     \
14921 +       ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14922 +#define TAGINO_GID(cond, gid, tag)     (gid)
14923 +
14924 +#endif
14925 +
14926 +
14927 +#ifdef CONFIG_TAGGING_INTERN
14928 +
14929 +#define MAX_UID                0xFFFFFFFF
14930 +#define MAX_GID                0xFFFFFFFF
14931 +
14932 +#define INOTAG_TAG(cond, uid, gid, tag)        \
14933 +       ((cond) ? (tag) : 0)
14934 +
14935 +#define TAGINO_UID(cond, uid, tag)     (uid)
14936 +#define TAGINO_GID(cond, gid, tag)     (gid)
14937 +
14938 +#endif
14939 +
14940 +
14941 +#ifndef CONFIG_TAGGING_NONE
14942 +#define dx_current_fstag(sb)   \
14943 +       ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14944 +#else
14945 +#define dx_current_fstag(sb)   (0)
14946 +#endif
14947 +
14948 +#ifndef CONFIG_TAGGING_INTERN
14949 +#define TAGINO_TAG(cond, tag)  (0)
14950 +#else
14951 +#define TAGINO_TAG(cond, tag)  ((cond) ? (tag) : 0)
14952 +#endif
14953 +
14954 +#define INOTAG_UID(cond, uid, gid)     \
14955 +       ((cond) ? ((uid) & MAX_UID) : (uid))
14956 +#define INOTAG_GID(cond, uid, gid)     \
14957 +       ((cond) ? ((gid) & MAX_GID) : (gid))
14958 +
14959 +
14960 +static inline uid_t dx_map_uid(uid_t uid)
14961 +{
14962 +       if ((uid > MAX_UID) && (uid != -1))
14963 +               uid = -2;
14964 +       return (uid & MAX_UID);
14965 +}
14966 +
14967 +static inline gid_t dx_map_gid(gid_t gid)
14968 +{
14969 +       if ((gid > MAX_GID) && (gid != -1))
14970 +               gid = -2;
14971 +       return (gid & MAX_GID);
14972 +}
14973 +
14974 +struct peer_tag {
14975 +       int32_t xid;
14976 +       int32_t nid;
14977 +};
14978 +
14979 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14980 +
14981 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14982 +                unsigned long *flags);
14983 +
14984 +#ifdef CONFIG_PROPAGATE
14985 +
14986 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14987 +
14988 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14989 +
14990 +#else
14991 +#define dx_propagate_tag(n, i) do { } while (0)
14992 +#endif
14993 +
14994 +#endif /* _DX_TAG_H */
14995 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_inet6.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_inet6.h
14996 --- linux-2.6.33.1/include/linux/vs_inet6.h     1970-01-01 01:00:00.000000000 +0100
14997 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_inet6.h     2010-02-25 14:47:08.000000000 +0100
14998 @@ -0,0 +1,246 @@
14999 +#ifndef _VS_INET6_H
15000 +#define _VS_INET6_H
15001 +
15002 +#include "vserver/base.h"
15003 +#include "vserver/network.h"
15004 +#include "vserver/debug.h"
15005 +
15006 +#include <net/ipv6.h>
15007 +
15008 +#define NXAV6(a)       &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
15009 +#define NXAV6_FMT      "[%pI6/%pI6/%d:%04x]"
15010 +
15011 +
15012 +#ifdef CONFIG_IPV6
15013 +
15014 +static inline
15015 +int v6_addr_match(struct nx_addr_v6 *nxa,
15016 +       const struct in6_addr *addr, uint16_t mask)
15017 +{
15018 +       int ret = 0;
15019 +
15020 +       switch (nxa->type & mask) {
15021 +       case NXA_TYPE_MASK:
15022 +               ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
15023 +               break;
15024 +       case NXA_TYPE_ADDR:
15025 +               ret = ipv6_addr_equal(&nxa->ip, addr);
15026 +               break;
15027 +       case NXA_TYPE_ANY:
15028 +               ret = 1;
15029 +               break;
15030 +       }
15031 +       vxdprintk(VXD_CBIT(net, 0),
15032 +               "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
15033 +               nxa, NXAV6(nxa), addr, mask, ret);
15034 +       return ret;
15035 +}
15036 +
15037 +static inline
15038 +int v6_addr_in_nx_info(struct nx_info *nxi,
15039 +       const struct in6_addr *addr, uint16_t mask)
15040 +{
15041 +       struct nx_addr_v6 *nxa;
15042 +       int ret = 1;
15043 +
15044 +       if (!nxi)
15045 +               goto out;
15046 +       for (nxa = &nxi->v6; nxa; nxa = nxa->next)
15047 +               if (v6_addr_match(nxa, addr, mask))
15048 +                       goto out;
15049 +       ret = 0;
15050 +out:
15051 +       vxdprintk(VXD_CBIT(net, 0),
15052 +               "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
15053 +               nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
15054 +       return ret;
15055 +}
15056 +
15057 +static inline
15058 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
15059 +{
15060 +       /* FIXME: needs full range checks */
15061 +       return v6_addr_match(nxa, &addr->ip, mask);
15062 +}
15063 +
15064 +static inline
15065 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
15066 +{
15067 +       struct nx_addr_v6 *ptr;
15068 +
15069 +       for (ptr = &nxi->v6; ptr; ptr = ptr->next)
15070 +               if (v6_nx_addr_match(ptr, nxa, mask))
15071 +                       return 1;
15072 +       return 0;
15073 +}
15074 +
15075 +
15076 +/*
15077 + *     Check if a given address matches for a socket
15078 + *
15079 + *     nxi:            the socket's nx_info if any
15080 + *     addr:           to be verified address
15081 + */
15082 +static inline
15083 +int v6_sock_addr_match (
15084 +       struct nx_info *nxi,
15085 +       struct inet_sock *inet,
15086 +       struct in6_addr *addr)
15087 +{
15088 +       struct sock *sk = &inet->sk;
15089 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
15090 +
15091 +       if (!ipv6_addr_any(addr) &&
15092 +               ipv6_addr_equal(saddr, addr))
15093 +               return 1;
15094 +       if (ipv6_addr_any(saddr))
15095 +               return v6_addr_in_nx_info(nxi, addr, -1);
15096 +       return 0;
15097 +}
15098 +
15099 +/*
15100 + *     check if address is covered by socket
15101 + *
15102 + *     sk:     the socket to check against
15103 + *     addr:   the address in question (must be != 0)
15104 + */
15105 +
15106 +static inline
15107 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
15108 +{
15109 +       struct nx_info *nxi = sk->sk_nx_info;
15110 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
15111 +
15112 +       vxdprintk(VXD_CBIT(net, 5),
15113 +               "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
15114 +               sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
15115 +               (sk->sk_socket?sk->sk_socket->flags:0));
15116 +
15117 +       if (!ipv6_addr_any(saddr)) {    /* direct address match */
15118 +               return v6_addr_match(nxa, saddr, -1);
15119 +       } else if (nxi) {               /* match against nx_info */
15120 +               return v6_nx_addr_in_nx_info(nxi, nxa, -1);
15121 +       } else {                        /* unrestricted any socket */
15122 +               return 1;
15123 +       }
15124 +}
15125 +
15126 +
15127 +/* inet related checks and helpers */
15128 +
15129 +
15130 +struct in_ifaddr;
15131 +struct net_device;
15132 +struct sock;
15133 +
15134 +
15135 +#include <linux/netdevice.h>
15136 +#include <linux/inetdevice.h>
15137 +#include <net/inet_timewait_sock.h>
15138 +
15139 +
15140 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15141 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
15142 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
15143 +
15144 +
15145 +
15146 +static inline
15147 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
15148 +{
15149 +       if (!nxi)
15150 +               return 1;
15151 +       if (!ifa)
15152 +               return 0;
15153 +       return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
15154 +}
15155 +
15156 +static inline
15157 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
15158 +{
15159 +       vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
15160 +               nxi, nxi ? nxi->nx_id : 0, ifa,
15161 +               nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
15162 +
15163 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15164 +               return 1;
15165 +       if (v6_ifa_in_nx_info(ifa, nxi))
15166 +               return 1;
15167 +       return 0;
15168 +}
15169 +
15170 +
15171 +struct nx_v6_sock_addr {
15172 +       struct in6_addr saddr;  /* Address used for validation */
15173 +       struct in6_addr baddr;  /* Address used for socket bind */
15174 +};
15175 +
15176 +static inline
15177 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
15178 +       struct nx_v6_sock_addr *nsa)
15179 +{
15180 +       // struct sock *sk = &inet->sk;
15181 +       // struct nx_info *nxi = sk->sk_nx_info;
15182 +       struct in6_addr saddr = addr->sin6_addr;
15183 +       struct in6_addr baddr = saddr;
15184 +
15185 +       nsa->saddr = saddr;
15186 +       nsa->baddr = baddr;
15187 +       return 0;
15188 +}
15189 +
15190 +static inline
15191 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
15192 +{
15193 +       // struct sock *sk = &inet->sk;
15194 +       // struct in6_addr *saddr = inet6_rcv_saddr(sk);
15195 +
15196 +       // *saddr = nsa->baddr;
15197 +       // inet->inet_saddr = nsa->baddr;
15198 +}
15199 +
15200 +static inline
15201 +int nx_info_has_v6(struct nx_info *nxi)
15202 +{
15203 +       if (!nxi)
15204 +               return 1;
15205 +       if (NX_IPV6(nxi))
15206 +               return 1;
15207 +       return 0;
15208 +}
15209 +
15210 +#else /* CONFIG_IPV6 */
15211 +
15212 +static inline
15213 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
15214 +{
15215 +       return 1;
15216 +}
15217 +
15218 +
15219 +static inline
15220 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
15221 +{
15222 +       return 1;
15223 +}
15224 +
15225 +static inline
15226 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
15227 +{
15228 +       return 1;
15229 +}
15230 +
15231 +static inline
15232 +int nx_info_has_v6(struct nx_info *nxi)
15233 +{
15234 +       return 0;
15235 +}
15236 +
15237 +#endif /* CONFIG_IPV6 */
15238 +
15239 +#define current_nx_info_has_v6() \
15240 +       nx_info_has_v6(current_nx_info())
15241 +
15242 +#else
15243 +#warning duplicate inclusion
15244 +#endif
15245 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_inet.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_inet.h
15246 --- linux-2.6.33.1/include/linux/vs_inet.h      1970-01-01 01:00:00.000000000 +0100
15247 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_inet.h      2010-02-25 14:45:44.000000000 +0100
15248 @@ -0,0 +1,342 @@
15249 +#ifndef _VS_INET_H
15250 +#define _VS_INET_H
15251 +
15252 +#include "vserver/base.h"
15253 +#include "vserver/network.h"
15254 +#include "vserver/debug.h"
15255 +
15256 +#define IPI_LOOPBACK   htonl(INADDR_LOOPBACK)
15257 +
15258 +#define NXAV4(a)       NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
15259 +                       NIPQUAD((a)->mask), (a)->type
15260 +#define NXAV4_FMT      "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
15261 +
15262 +
15263 +static inline
15264 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
15265 +{
15266 +       __be32 ip = nxa->ip[0].s_addr;
15267 +       __be32 mask = nxa->mask.s_addr;
15268 +       __be32 bcast = ip | ~mask;
15269 +       int ret = 0;
15270 +
15271 +       switch (nxa->type & tmask) {
15272 +       case NXA_TYPE_MASK:
15273 +               ret = (ip == (addr & mask));
15274 +               break;
15275 +       case NXA_TYPE_ADDR:
15276 +               ret = 3;
15277 +               if (addr == ip)
15278 +                       break;
15279 +               /* fall through to broadcast */
15280 +       case NXA_MOD_BCAST:
15281 +               ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
15282 +               break;
15283 +       case NXA_TYPE_RANGE:
15284 +               ret = ((nxa->ip[0].s_addr <= addr) &&
15285 +                       (nxa->ip[1].s_addr > addr));
15286 +               break;
15287 +       case NXA_TYPE_ANY:
15288 +               ret = 2;
15289 +               break;
15290 +       }
15291 +
15292 +       vxdprintk(VXD_CBIT(net, 0),
15293 +               "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
15294 +               nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
15295 +       return ret;
15296 +}
15297 +
15298 +static inline
15299 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
15300 +{
15301 +       struct nx_addr_v4 *nxa;
15302 +       int ret = 1;
15303 +
15304 +       if (!nxi)
15305 +               goto out;
15306 +
15307 +       ret = 2;
15308 +       /* allow 127.0.0.1 when remapping lback */
15309 +       if ((tmask & NXA_LOOPBACK) &&
15310 +               (addr == IPI_LOOPBACK) &&
15311 +               nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15312 +               goto out;
15313 +       ret = 3;
15314 +       /* check for lback address */
15315 +       if ((tmask & NXA_MOD_LBACK) &&
15316 +               (nxi->v4_lback.s_addr == addr))
15317 +               goto out;
15318 +       ret = 4;
15319 +       /* check for broadcast address */
15320 +       if ((tmask & NXA_MOD_BCAST) &&
15321 +               (nxi->v4_bcast.s_addr == addr))
15322 +               goto out;
15323 +       ret = 5;
15324 +       /* check for v4 addresses */
15325 +       for (nxa = &nxi->v4; nxa; nxa = nxa->next)
15326 +               if (v4_addr_match(nxa, addr, tmask))
15327 +                       goto out;
15328 +       ret = 0;
15329 +out:
15330 +       vxdprintk(VXD_CBIT(net, 0),
15331 +               "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
15332 +               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
15333 +       return ret;
15334 +}
15335 +
15336 +static inline
15337 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
15338 +{
15339 +       /* FIXME: needs full range checks */
15340 +       return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
15341 +}
15342 +
15343 +static inline
15344 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
15345 +{
15346 +       struct nx_addr_v4 *ptr;
15347 +
15348 +       for (ptr = &nxi->v4; ptr; ptr = ptr->next)
15349 +               if (v4_nx_addr_match(ptr, nxa, mask))
15350 +                       return 1;
15351 +       return 0;
15352 +}
15353 +
15354 +#include <net/inet_sock.h>
15355 +
15356 +/*
15357 + *     Check if a given address matches for a socket
15358 + *
15359 + *     nxi:            the socket's nx_info if any
15360 + *     addr:           to be verified address
15361 + */
15362 +static inline
15363 +int v4_sock_addr_match (
15364 +       struct nx_info *nxi,
15365 +       struct inet_sock *inet,
15366 +       __be32 addr)
15367 +{
15368 +       __be32 saddr = inet->inet_rcv_saddr;
15369 +       __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
15370 +
15371 +       if (addr && (saddr == addr || bcast == addr))
15372 +               return 1;
15373 +       if (!saddr)
15374 +               return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
15375 +       return 0;
15376 +}
15377 +
15378 +
15379 +/* inet related checks and helpers */
15380 +
15381 +
15382 +struct in_ifaddr;
15383 +struct net_device;
15384 +struct sock;
15385 +
15386 +#ifdef CONFIG_INET
15387 +
15388 +#include <linux/netdevice.h>
15389 +#include <linux/inetdevice.h>
15390 +#include <net/inet_sock.h>
15391 +#include <net/inet_timewait_sock.h>
15392 +
15393 +
15394 +int dev_in_nx_info(struct net_device *, struct nx_info *);
15395 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
15396 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
15397 +
15398 +
15399 +/*
15400 + *     check if address is covered by socket
15401 + *
15402 + *     sk:     the socket to check against
15403 + *     addr:   the address in question (must be != 0)
15404 + */
15405 +
15406 +static inline
15407 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
15408 +{
15409 +       struct nx_info *nxi = sk->sk_nx_info;
15410 +       __be32 saddr = inet_rcv_saddr(sk);
15411 +
15412 +       vxdprintk(VXD_CBIT(net, 5),
15413 +               "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
15414 +               sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
15415 +               (sk->sk_socket?sk->sk_socket->flags:0));
15416 +
15417 +       if (saddr) {            /* direct address match */
15418 +               return v4_addr_match(nxa, saddr, -1);
15419 +       } else if (nxi) {       /* match against nx_info */
15420 +               return v4_nx_addr_in_nx_info(nxi, nxa, -1);
15421 +       } else {                /* unrestricted any socket */
15422 +               return 1;
15423 +       }
15424 +}
15425 +
15426 +
15427 +
15428 +static inline
15429 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
15430 +{
15431 +       vxdprintk(VXD_CBIT(net, 1), "nx_dev_visible(%p[#%u],%p Â»%s«) %d",
15432 +               nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
15433 +               nxi ? dev_in_nx_info(dev, nxi) : 0);
15434 +
15435 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15436 +               return 1;
15437 +       if (dev_in_nx_info(dev, nxi))
15438 +               return 1;
15439 +       return 0;
15440 +}
15441 +
15442 +
15443 +static inline
15444 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
15445 +{
15446 +       if (!nxi)
15447 +               return 1;
15448 +       if (!ifa)
15449 +               return 0;
15450 +       return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
15451 +}
15452 +
15453 +static inline
15454 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
15455 +{
15456 +       vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
15457 +               nxi, nxi ? nxi->nx_id : 0, ifa,
15458 +               nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
15459 +
15460 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
15461 +               return 1;
15462 +       if (v4_ifa_in_nx_info(ifa, nxi))
15463 +               return 1;
15464 +       return 0;
15465 +}
15466 +
15467 +
15468 +struct nx_v4_sock_addr {
15469 +       __be32 saddr;   /* Address used for validation */
15470 +       __be32 baddr;   /* Address used for socket bind */
15471 +};
15472 +
15473 +static inline
15474 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
15475 +       struct nx_v4_sock_addr *nsa)
15476 +{
15477 +       struct sock *sk = &inet->sk;
15478 +       struct nx_info *nxi = sk->sk_nx_info;
15479 +       __be32 saddr = addr->sin_addr.s_addr;
15480 +       __be32 baddr = saddr;
15481 +
15482 +       vxdprintk(VXD_CBIT(net, 3),
15483 +               "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
15484 +               sk, sk->sk_nx_info, sk->sk_socket,
15485 +               (sk->sk_socket ? sk->sk_socket->flags : 0),
15486 +               NIPQUAD(saddr));
15487 +
15488 +       if (nxi) {
15489 +               if (saddr == INADDR_ANY) {
15490 +                       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
15491 +                               baddr = nxi->v4.ip[0].s_addr;
15492 +               } else if (saddr == IPI_LOOPBACK) {
15493 +                       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15494 +                               baddr = nxi->v4_lback.s_addr;
15495 +               } else {        /* normal address bind */
15496 +                       if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
15497 +                               return -EADDRNOTAVAIL;
15498 +               }
15499 +       }
15500 +
15501 +       vxdprintk(VXD_CBIT(net, 3),
15502 +               "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
15503 +               sk, NIPQUAD(saddr), NIPQUAD(baddr));
15504 +
15505 +       nsa->saddr = saddr;
15506 +       nsa->baddr = baddr;
15507 +       return 0;
15508 +}
15509 +
15510 +static inline
15511 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
15512 +{
15513 +       inet->inet_saddr = nsa->baddr;
15514 +       inet->inet_rcv_saddr = nsa->baddr;
15515 +}
15516 +
15517 +
15518 +/*
15519 + *      helper to simplify inet_lookup_listener
15520 + *
15521 + *      nxi:   the socket's nx_info if any
15522 + *      addr:  to be verified address
15523 + *      saddr: socket address
15524 + */
15525 +static inline int v4_inet_addr_match (
15526 +       struct nx_info *nxi,
15527 +       __be32 addr,
15528 +       __be32 saddr)
15529 +{
15530 +       if (addr && (saddr == addr))
15531 +               return 1;
15532 +       if (!saddr)
15533 +               return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
15534 +       return 0;
15535 +}
15536 +
15537 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
15538 +{
15539 +       if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
15540 +               (addr == nxi->v4_lback.s_addr))
15541 +               return IPI_LOOPBACK;
15542 +       return addr;
15543 +}
15544 +
15545 +static inline
15546 +int nx_info_has_v4(struct nx_info *nxi)
15547 +{
15548 +       if (!nxi)
15549 +               return 1;
15550 +       if (NX_IPV4(nxi))
15551 +               return 1;
15552 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
15553 +               return 1;
15554 +       return 0;
15555 +}
15556 +
15557 +#else /* CONFIG_INET */
15558 +
15559 +static inline
15560 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
15561 +{
15562 +       return 1;
15563 +}
15564 +
15565 +static inline
15566 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
15567 +{
15568 +       return 1;
15569 +}
15570 +
15571 +static inline
15572 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
15573 +{
15574 +       return 1;
15575 +}
15576 +
15577 +static inline
15578 +int nx_info_has_v4(struct nx_info *nxi)
15579 +{
15580 +       return 0;
15581 +}
15582 +
15583 +#endif /* CONFIG_INET */
15584 +
15585 +#define current_nx_info_has_v4() \
15586 +       nx_info_has_v4(current_nx_info())
15587 +
15588 +#else
15589 +// #warning duplicate inclusion
15590 +#endif
15591 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_limit.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_limit.h
15592 --- linux-2.6.33.1/include/linux/vs_limit.h     1970-01-01 01:00:00.000000000 +0100
15593 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_limit.h     2010-02-25 12:02:16.000000000 +0100
15594 @@ -0,0 +1,140 @@
15595 +#ifndef _VS_LIMIT_H
15596 +#define _VS_LIMIT_H
15597 +
15598 +#include "vserver/limit.h"
15599 +#include "vserver/base.h"
15600 +#include "vserver/context.h"
15601 +#include "vserver/debug.h"
15602 +#include "vserver/context.h"
15603 +#include "vserver/limit_int.h"
15604 +
15605 +
15606 +#define vx_acc_cres(v, d, p, r) \
15607 +       __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
15608 +
15609 +#define vx_acc_cres_cond(x, d, p, r) \
15610 +       __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15611 +       r, d, p, __FILE__, __LINE__)
15612 +
15613 +
15614 +#define vx_add_cres(v, a, p, r) \
15615 +       __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
15616 +#define vx_sub_cres(v, a, p, r)                vx_add_cres(v, -(a), p, r)
15617 +
15618 +#define vx_add_cres_cond(x, a, p, r) \
15619 +       __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
15620 +       r, a, p, __FILE__, __LINE__)
15621 +#define vx_sub_cres_cond(x, a, p, r)   vx_add_cres_cond(x, -(a), p, r)
15622 +
15623 +
15624 +/* process and file limits */
15625 +
15626 +#define vx_nproc_inc(p) \
15627 +       vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
15628 +
15629 +#define vx_nproc_dec(p) \
15630 +       vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
15631 +
15632 +#define vx_files_inc(f) \
15633 +       vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
15634 +
15635 +#define vx_files_dec(f) \
15636 +       vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
15637 +
15638 +#define vx_locks_inc(l) \
15639 +       vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
15640 +
15641 +#define vx_locks_dec(l) \
15642 +       vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
15643 +
15644 +#define vx_openfd_inc(f) \
15645 +       vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
15646 +
15647 +#define vx_openfd_dec(f) \
15648 +       vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
15649 +
15650 +
15651 +#define vx_cres_avail(v, n, r) \
15652 +       __vx_cres_avail(v, r, n, __FILE__, __LINE__)
15653 +
15654 +
15655 +#define vx_nproc_avail(n) \
15656 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
15657 +
15658 +#define vx_files_avail(n) \
15659 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
15660 +
15661 +#define vx_locks_avail(n) \
15662 +       vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
15663 +
15664 +#define vx_openfd_avail(n) \
15665 +       vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
15666 +
15667 +
15668 +/* dentry limits */
15669 +
15670 +#define vx_dentry_inc(d) do {                                          \
15671 +       if (atomic_read(&d->d_count) == 1)                              \
15672 +               vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY);    \
15673 +       } while (0)
15674 +
15675 +#define vx_dentry_dec(d) do {                                          \
15676 +       if (atomic_read(&d->d_count) == 0)                              \
15677 +               vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY);    \
15678 +       } while (0)
15679 +
15680 +#define vx_dentry_avail(n) \
15681 +       vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
15682 +
15683 +
15684 +/* socket limits */
15685 +
15686 +#define vx_sock_inc(s) \
15687 +       vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
15688 +
15689 +#define vx_sock_dec(s) \
15690 +       vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
15691 +
15692 +#define vx_sock_avail(n) \
15693 +       vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
15694 +
15695 +
15696 +/* ipc resource limits */
15697 +
15698 +#define vx_ipcmsg_add(v, u, a) \
15699 +       vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
15700 +
15701 +#define vx_ipcmsg_sub(v, u, a) \
15702 +       vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
15703 +
15704 +#define vx_ipcmsg_avail(v, a) \
15705 +       vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
15706 +
15707 +
15708 +#define vx_ipcshm_add(v, k, a) \
15709 +       vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15710 +
15711 +#define vx_ipcshm_sub(v, k, a) \
15712 +       vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
15713 +
15714 +#define vx_ipcshm_avail(v, a) \
15715 +       vx_cres_avail(v, a, VLIMIT_SHMEM)
15716 +
15717 +
15718 +#define vx_semary_inc(a) \
15719 +       vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
15720 +
15721 +#define vx_semary_dec(a) \
15722 +       vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
15723 +
15724 +
15725 +#define vx_nsems_add(a,n) \
15726 +       vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15727 +
15728 +#define vx_nsems_sub(a,n) \
15729 +       vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
15730 +
15731 +
15732 +#else
15733 +#warning duplicate inclusion
15734 +#endif
15735 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_memory.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_memory.h
15736 --- linux-2.6.33.1/include/linux/vs_memory.h    1970-01-01 01:00:00.000000000 +0100
15737 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_memory.h    2010-02-25 12:02:16.000000000 +0100
15738 @@ -0,0 +1,159 @@
15739 +#ifndef _VS_MEMORY_H
15740 +#define _VS_MEMORY_H
15741 +
15742 +#include "vserver/limit.h"
15743 +#include "vserver/base.h"
15744 +#include "vserver/context.h"
15745 +#include "vserver/debug.h"
15746 +#include "vserver/context.h"
15747 +#include "vserver/limit_int.h"
15748 +
15749 +
15750 +#define __acc_add_long(a, v)   (*(v) += (a))
15751 +#define __acc_inc_long(v)      (++*(v))
15752 +#define __acc_dec_long(v)      (--*(v))
15753 +
15754 +#if    NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
15755 +#define __acc_add_atomic(a, v) atomic_long_add(a, v)
15756 +#define __acc_inc_atomic(v)    atomic_long_inc(v)
15757 +#define __acc_dec_atomic(v)    atomic_long_dec(v)
15758 +#else  /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
15759 +#define __acc_add_atomic(a, v) __acc_add_long(a, v)
15760 +#define __acc_inc_atomic(v)    __acc_inc_long(v)
15761 +#define __acc_dec_atomic(v)    __acc_dec_long(v)
15762 +#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */
15763 +
15764 +
15765 +#define vx_acc_page(m, d, v, r) do {                                   \
15766 +       if ((d) > 0)                                                    \
15767 +               __acc_inc_long(&(m)->v);                                \
15768 +       else                                                            \
15769 +               __acc_dec_long(&(m)->v);                                \
15770 +       __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__);      \
15771 +} while (0)
15772 +
15773 +#define vx_acc_page_atomic(m, d, v, r) do {                            \
15774 +       if ((d) > 0)                                                    \
15775 +               __acc_inc_atomic(&(m)->v);                              \
15776 +       else                                                            \
15777 +               __acc_dec_atomic(&(m)->v);                              \
15778 +       __vx_acc_cres(m->mm_vx_info, r, d, m, __FILE__, __LINE__);      \
15779 +} while (0)
15780 +
15781 +
15782 +#define vx_acc_pages(m, p, v, r) do {                                  \
15783 +       unsigned long __p = (p);                                        \
15784 +       __acc_add_long(__p, &(m)->v);                                   \
15785 +       __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__);    \
15786 +} while (0)
15787 +
15788 +#define vx_acc_pages_atomic(m, p, v, r) do {                           \
15789 +       unsigned long __p = (p);                                        \
15790 +       __acc_add_atomic(__p, &(m)->v);                                 \
15791 +       __vx_add_cres(m->mm_vx_info, r, __p, m, __FILE__, __LINE__);    \
15792 +} while (0)
15793 +
15794 +
15795 +
15796 +#define vx_acc_vmpage(m, d) \
15797 +       vx_acc_page(m, d, total_vm,  RLIMIT_AS)
15798 +#define vx_acc_vmlpage(m, d) \
15799 +       vx_acc_page(m, d, locked_vm, RLIMIT_MEMLOCK)
15800 +#define vx_acc_file_rsspage(m, d) \
15801 +       vx_acc_page_atomic(m, d, _file_rss, VLIMIT_MAPPED)
15802 +#define vx_acc_anon_rsspage(m, d) \
15803 +       vx_acc_page_atomic(m, d, _anon_rss, VLIMIT_ANON)
15804 +
15805 +#define vx_acc_vmpages(m, p) \
15806 +       vx_acc_pages(m, p, total_vm,  RLIMIT_AS)
15807 +#define vx_acc_vmlpages(m, p) \
15808 +       vx_acc_pages(m, p, locked_vm, RLIMIT_MEMLOCK)
15809 +#define vx_acc_file_rsspages(m, p) \
15810 +       vx_acc_pages_atomic(m, p, _file_rss, VLIMIT_MAPPED)
15811 +#define vx_acc_anon_rsspages(m, p) \
15812 +       vx_acc_pages_atomic(m, p, _anon_rss, VLIMIT_ANON)
15813 +
15814 +#define vx_pages_add(s, r, p)  __vx_add_cres(s, r, p, 0, __FILE__, __LINE__)
15815 +#define vx_pages_sub(s, r, p)  vx_pages_add(s, r, -(p))
15816 +
15817 +#define vx_vmpages_inc(m)              vx_acc_vmpage(m, 1)
15818 +#define vx_vmpages_dec(m)              vx_acc_vmpage(m, -1)
15819 +#define vx_vmpages_add(m, p)           vx_acc_vmpages(m, p)
15820 +#define vx_vmpages_sub(m, p)           vx_acc_vmpages(m, -(p))
15821 +
15822 +#define vx_vmlocked_inc(m)             vx_acc_vmlpage(m, 1)
15823 +#define vx_vmlocked_dec(m)             vx_acc_vmlpage(m, -1)
15824 +#define vx_vmlocked_add(m, p)          vx_acc_vmlpages(m, p)
15825 +#define vx_vmlocked_sub(m, p)          vx_acc_vmlpages(m, -(p))
15826 +
15827 +#define vx_file_rsspages_inc(m)                vx_acc_file_rsspage(m, 1)
15828 +#define vx_file_rsspages_dec(m)                vx_acc_file_rsspage(m, -1)
15829 +#define vx_file_rsspages_add(m, p)     vx_acc_file_rsspages(m, p)
15830 +#define vx_file_rsspages_sub(m, p)     vx_acc_file_rsspages(m, -(p))
15831 +
15832 +#define vx_anon_rsspages_inc(m)                vx_acc_anon_rsspage(m, 1)
15833 +#define vx_anon_rsspages_dec(m)                vx_acc_anon_rsspage(m, -1)
15834 +#define vx_anon_rsspages_add(m, p)     vx_acc_anon_rsspages(m, p)
15835 +#define vx_anon_rsspages_sub(m, p)     vx_acc_anon_rsspages(m, -(p))
15836 +
15837 +
15838 +#define vx_pages_avail(m, p, r) \
15839 +       __vx_cres_avail((m)->mm_vx_info, r, p, __FILE__, __LINE__)
15840 +
15841 +#define vx_vmpages_avail(m, p) vx_pages_avail(m, p, RLIMIT_AS)
15842 +#define vx_vmlocked_avail(m, p)        vx_pages_avail(m, p, RLIMIT_MEMLOCK)
15843 +#define vx_anon_avail(m, p)    vx_pages_avail(m, p, VLIMIT_ANON)
15844 +#define vx_mapped_avail(m, p)  vx_pages_avail(m, p, VLIMIT_MAPPED)
15845 +
15846 +#define vx_rss_avail(m, p) \
15847 +       __vx_cres_array_avail((m)->mm_vx_info, VLA_RSS, p, __FILE__, __LINE__)
15848 +
15849 +
15850 +enum {
15851 +       VXPT_UNKNOWN = 0,
15852 +       VXPT_ANON,
15853 +       VXPT_NONE,
15854 +       VXPT_FILE,
15855 +       VXPT_SWAP,
15856 +       VXPT_WRITE
15857 +};
15858 +
15859 +#if 0
15860 +#define        vx_page_fault(mm, vma, type, ret)
15861 +#else
15862 +
15863 +static inline
15864 +void __vx_page_fault(struct mm_struct *mm,
15865 +       struct vm_area_struct *vma, int type, int ret)
15866 +{
15867 +       struct vx_info *vxi = mm->mm_vx_info;
15868 +       int what;
15869 +/*
15870 +       static char *page_type[6] =
15871 +               { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
15872 +       static char *page_what[4] =
15873 +               { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
15874 +*/
15875 +
15876 +       if (!vxi)
15877 +               return;
15878 +
15879 +       what = (ret & 0x3);
15880 +
15881 +/*     printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
15882 +               type, what, ret, page_type[type], page_what[what]);
15883 +*/
15884 +       if (ret & VM_FAULT_WRITE)
15885 +               what |= 0x4;
15886 +       atomic_inc(&vxi->cacct.page[type][what]);
15887 +}
15888 +
15889 +#define        vx_page_fault(mm, vma, type, ret)       __vx_page_fault(mm, vma, type, ret)
15890 +#endif
15891 +
15892 +
15893 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
15894 +
15895 +#else
15896 +#warning duplicate inclusion
15897 +#endif
15898 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_network.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_network.h
15899 --- linux-2.6.33.1/include/linux/vs_network.h   1970-01-01 01:00:00.000000000 +0100
15900 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_network.h   2010-02-25 12:02:16.000000000 +0100
15901 @@ -0,0 +1,169 @@
15902 +#ifndef _NX_VS_NETWORK_H
15903 +#define _NX_VS_NETWORK_H
15904 +
15905 +#include "vserver/context.h"
15906 +#include "vserver/network.h"
15907 +#include "vserver/base.h"
15908 +#include "vserver/check.h"
15909 +#include "vserver/debug.h"
15910 +
15911 +#include <linux/sched.h>
15912 +
15913 +
15914 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
15915 +
15916 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
15917 +       const char *_file, int _line)
15918 +{
15919 +       if (!nxi)
15920 +               return NULL;
15921 +
15922 +       vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
15923 +               nxi, nxi ? nxi->nx_id : 0,
15924 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15925 +               _file, _line);
15926 +
15927 +       atomic_inc(&nxi->nx_usecnt);
15928 +       return nxi;
15929 +}
15930 +
15931 +
15932 +extern void free_nx_info(struct nx_info *);
15933 +
15934 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
15935 +
15936 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
15937 +{
15938 +       if (!nxi)
15939 +               return;
15940 +
15941 +       vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
15942 +               nxi, nxi ? nxi->nx_id : 0,
15943 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15944 +               _file, _line);
15945 +
15946 +       if (atomic_dec_and_test(&nxi->nx_usecnt))
15947 +               free_nx_info(nxi);
15948 +}
15949 +
15950 +
15951 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
15952 +
15953 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15954 +               const char *_file, int _line)
15955 +{
15956 +       if (nxi) {
15957 +               vxlprintk(VXD_CBIT(nid, 3),
15958 +                       "init_nx_info(%p[#%d.%d])",
15959 +                       nxi, nxi ? nxi->nx_id : 0,
15960 +                       nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15961 +                       _file, _line);
15962 +
15963 +               atomic_inc(&nxi->nx_usecnt);
15964 +       }
15965 +       *nxp = nxi;
15966 +}
15967 +
15968 +
15969 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
15970 +
15971 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
15972 +       const char *_file, int _line)
15973 +{
15974 +       struct nx_info *nxo;
15975 +
15976 +       if (!nxi)
15977 +               return;
15978 +
15979 +       vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
15980 +               nxi, nxi ? nxi->nx_id : 0,
15981 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
15982 +               _file, _line);
15983 +
15984 +       atomic_inc(&nxi->nx_usecnt);
15985 +       nxo = xchg(nxp, nxi);
15986 +       BUG_ON(nxo);
15987 +}
15988 +
15989 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
15990 +
15991 +static inline void __clr_nx_info(struct nx_info **nxp,
15992 +       const char *_file, int _line)
15993 +{
15994 +       struct nx_info *nxo;
15995 +
15996 +       nxo = xchg(nxp, NULL);
15997 +       if (!nxo)
15998 +               return;
15999 +
16000 +       vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
16001 +               nxo, nxo ? nxo->nx_id : 0,
16002 +               nxo ? atomic_read(&nxo->nx_usecnt) : 0,
16003 +               _file, _line);
16004 +
16005 +       if (atomic_dec_and_test(&nxo->nx_usecnt))
16006 +               free_nx_info(nxo);
16007 +}
16008 +
16009 +
16010 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
16011 +
16012 +static inline void __claim_nx_info(struct nx_info *nxi,
16013 +       struct task_struct *task, const char *_file, int _line)
16014 +{
16015 +       vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
16016 +               nxi, nxi ? nxi->nx_id : 0,
16017 +               nxi?atomic_read(&nxi->nx_usecnt):0,
16018 +               nxi?atomic_read(&nxi->nx_tasks):0,
16019 +               task, _file, _line);
16020 +
16021 +       atomic_inc(&nxi->nx_tasks);
16022 +}
16023 +
16024 +
16025 +extern void unhash_nx_info(struct nx_info *);
16026 +
16027 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
16028 +
16029 +static inline void __release_nx_info(struct nx_info *nxi,
16030 +       struct task_struct *task, const char *_file, int _line)
16031 +{
16032 +       vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
16033 +               nxi, nxi ? nxi->nx_id : 0,
16034 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
16035 +               nxi ? atomic_read(&nxi->nx_tasks) : 0,
16036 +               task, _file, _line);
16037 +
16038 +       might_sleep();
16039 +
16040 +       if (atomic_dec_and_test(&nxi->nx_tasks))
16041 +               unhash_nx_info(nxi);
16042 +}
16043 +
16044 +
16045 +#define task_get_nx_info(i)    __task_get_nx_info(i, __FILE__, __LINE__)
16046 +
16047 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
16048 +       const char *_file, int _line)
16049 +{
16050 +       struct nx_info *nxi;
16051 +
16052 +       task_lock(p);
16053 +       vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
16054 +               p, _file, _line);
16055 +       nxi = __get_nx_info(p->nx_info, _file, _line);
16056 +       task_unlock(p);
16057 +       return nxi;
16058 +}
16059 +
16060 +
16061 +static inline void exit_nx_info(struct task_struct *p)
16062 +{
16063 +       if (p->nx_info)
16064 +               release_nx_info(p->nx_info, p);
16065 +}
16066 +
16067 +
16068 +#else
16069 +#warning duplicate inclusion
16070 +#endif
16071 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_pid.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_pid.h
16072 --- linux-2.6.33.1/include/linux/vs_pid.h       1970-01-01 01:00:00.000000000 +0100
16073 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_pid.h       2010-02-25 12:02:16.000000000 +0100
16074 @@ -0,0 +1,95 @@
16075 +#ifndef _VS_PID_H
16076 +#define _VS_PID_H
16077 +
16078 +#include "vserver/base.h"
16079 +#include "vserver/check.h"
16080 +#include "vserver/context.h"
16081 +#include "vserver/debug.h"
16082 +#include "vserver/pid.h"
16083 +#include <linux/pid_namespace.h>
16084 +
16085 +
16086 +#define VXF_FAKE_INIT  (VXF_INFO_INIT | VXF_STATE_INIT)
16087 +
16088 +static inline
16089 +int vx_proc_task_visible(struct task_struct *task)
16090 +{
16091 +       if ((task->pid == 1) &&
16092 +               !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
16093 +               /* show a blend through init */
16094 +               goto visible;
16095 +       if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
16096 +               goto visible;
16097 +       return 0;
16098 +visible:
16099 +       return 1;
16100 +}
16101 +
16102 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
16103 +
16104 +#if 0
16105 +
16106 +static inline
16107 +struct task_struct *vx_find_proc_task_by_pid(int pid)
16108 +{
16109 +       struct task_struct *task = find_task_by_real_pid(pid);
16110 +
16111 +       if (task && !vx_proc_task_visible(task)) {
16112 +               vxdprintk(VXD_CBIT(misc, 6),
16113 +                       "dropping task (find) %p[#%u,%u] for %p[#%u,%u]",
16114 +                       task, task->xid, task->pid,
16115 +                       current, current->xid, current->pid);
16116 +               task = NULL;
16117 +       }
16118 +       return task;
16119 +}
16120 +
16121 +#endif
16122 +
16123 +static inline
16124 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
16125 +{
16126 +       struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
16127 +
16128 +       if (task && !vx_proc_task_visible(task)) {
16129 +               vxdprintk(VXD_CBIT(misc, 6),
16130 +                       "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
16131 +                       task, task->xid, task->pid,
16132 +                       current, current->xid, current->pid);
16133 +               put_task_struct(task);
16134 +               task = NULL;
16135 +       }
16136 +       return task;
16137 +}
16138 +
16139 +#if 0
16140 +
16141 +static inline
16142 +struct task_struct *vx_child_reaper(struct task_struct *p)
16143 +{
16144 +       struct vx_info *vxi = p->vx_info;
16145 +       struct task_struct *reaper = child_reaper(p);
16146 +
16147 +       if (!vxi)
16148 +               goto out;
16149 +
16150 +       BUG_ON(!p->vx_info->vx_reaper);
16151 +
16152 +       /* child reaper for the guest reaper */
16153 +       if (vxi->vx_reaper == p)
16154 +               goto out;
16155 +
16156 +       reaper = vxi->vx_reaper;
16157 +out:
16158 +       vxdprintk(VXD_CBIT(xid, 7),
16159 +               "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]",
16160 +               p, p->xid, p->pid, reaper, reaper->xid, reaper->pid);
16161 +       return reaper;
16162 +}
16163 +
16164 +#endif
16165 +
16166 +
16167 +#else
16168 +#warning duplicate inclusion
16169 +#endif
16170 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_sched.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_sched.h
16171 --- linux-2.6.33.1/include/linux/vs_sched.h     1970-01-01 01:00:00.000000000 +0100
16172 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_sched.h     2010-02-25 12:02:16.000000000 +0100
16173 @@ -0,0 +1,110 @@
16174 +#ifndef _VS_SCHED_H
16175 +#define _VS_SCHED_H
16176 +
16177 +#include "vserver/base.h"
16178 +#include "vserver/context.h"
16179 +#include "vserver/sched.h"
16180 +
16181 +
16182 +#define VAVAVOOM_RATIO          50
16183 +
16184 +#define MAX_PRIO_BIAS           20
16185 +#define MIN_PRIO_BIAS          -20
16186 +
16187 +
16188 +#ifdef CONFIG_VSERVER_HARDCPU
16189 +
16190 +/*
16191 + * effective_prio - return the priority that is based on the static
16192 + * priority but is modified by bonuses/penalties.
16193 + *
16194 + * We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
16195 + * into a -4 ... 0 ... +4 bonus/penalty range.
16196 + *
16197 + * Additionally, we scale another amount based on the number of
16198 + * CPU tokens currently held by the context, if the process is
16199 + * part of a context (and the appropriate SCHED flag is set).
16200 + * This ranges from -5 ... 0 ... +15, quadratically.
16201 + *
16202 + * So, the total bonus is -9 .. 0 .. +19
16203 + * We use ~50% of the full 0...39 priority range so that:
16204 + *
16205 + * 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
16206 + * 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
16207 + *    unless that context is far exceeding its CPU allocation.
16208 + *
16209 + * Both properties are important to certain workloads.
16210 + */
16211 +static inline
16212 +int vx_effective_vavavoom(struct _vx_sched_pc *sched_pc, int max_prio)
16213 +{
16214 +       int vavavoom, max;
16215 +
16216 +       /* lots of tokens = lots of vavavoom
16217 +        *      no tokens = no vavavoom      */
16218 +       if ((vavavoom = sched_pc->tokens) >= 0) {
16219 +               max = sched_pc->tokens_max;
16220 +               vavavoom = max - vavavoom;
16221 +               max = max * max;
16222 +               vavavoom = max_prio * VAVAVOOM_RATIO / 100
16223 +                       * (vavavoom*vavavoom - (max >> 2)) / max;
16224 +               return vavavoom;
16225 +       }
16226 +       return 0;
16227 +}
16228 +
16229 +
16230 +static inline
16231 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
16232 +{
16233 +       struct vx_info *vxi = p->vx_info;
16234 +       struct _vx_sched_pc *sched_pc;
16235 +
16236 +       if (!vxi)
16237 +               return prio;
16238 +
16239 +       sched_pc = &vx_cpu(vxi, sched_pc);
16240 +       if (vx_info_flags(vxi, VXF_SCHED_PRIO, 0)) {
16241 +               int vavavoom = vx_effective_vavavoom(sched_pc, max_user);
16242 +
16243 +               sched_pc->vavavoom = vavavoom;
16244 +               prio += vavavoom;
16245 +       }
16246 +       prio += sched_pc->prio_bias;
16247 +       return prio;
16248 +}
16249 +
16250 +#else /* !CONFIG_VSERVER_HARDCPU */
16251 +
16252 +static inline
16253 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
16254 +{
16255 +       struct vx_info *vxi = p->vx_info;
16256 +
16257 +       if (vxi)
16258 +               prio += vx_cpu(vxi, sched_pc).prio_bias;
16259 +       return prio;
16260 +}
16261 +
16262 +#endif /* CONFIG_VSERVER_HARDCPU */
16263 +
16264 +
16265 +static inline void vx_account_user(struct vx_info *vxi,
16266 +       cputime_t cputime, int nice)
16267 +{
16268 +       if (!vxi)
16269 +               return;
16270 +       vx_cpu(vxi, sched_pc).user_ticks += cputime;
16271 +}
16272 +
16273 +static inline void vx_account_system(struct vx_info *vxi,
16274 +       cputime_t cputime, int idle)
16275 +{
16276 +       if (!vxi)
16277 +               return;
16278 +       vx_cpu(vxi, sched_pc).sys_ticks += cputime;
16279 +}
16280 +
16281 +#else
16282 +#warning duplicate inclusion
16283 +#endif
16284 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_socket.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_socket.h
16285 --- linux-2.6.33.1/include/linux/vs_socket.h    1970-01-01 01:00:00.000000000 +0100
16286 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_socket.h    2010-02-25 12:02:16.000000000 +0100
16287 @@ -0,0 +1,67 @@
16288 +#ifndef _VS_SOCKET_H
16289 +#define _VS_SOCKET_H
16290 +
16291 +#include "vserver/debug.h"
16292 +#include "vserver/base.h"
16293 +#include "vserver/cacct.h"
16294 +#include "vserver/context.h"
16295 +#include "vserver/tag.h"
16296 +
16297 +
16298 +/* socket accounting */
16299 +
16300 +#include <linux/socket.h>
16301 +
16302 +static inline int vx_sock_type(int family)
16303 +{
16304 +       switch (family) {
16305 +       case PF_UNSPEC:
16306 +               return VXA_SOCK_UNSPEC;
16307 +       case PF_UNIX:
16308 +               return VXA_SOCK_UNIX;
16309 +       case PF_INET:
16310 +               return VXA_SOCK_INET;
16311 +       case PF_INET6:
16312 +               return VXA_SOCK_INET6;
16313 +       case PF_PACKET:
16314 +               return VXA_SOCK_PACKET;
16315 +       default:
16316 +               return VXA_SOCK_OTHER;
16317 +       }
16318 +}
16319 +
16320 +#define vx_acc_sock(v, f, p, s) \
16321 +       __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
16322 +
16323 +static inline void __vx_acc_sock(struct vx_info *vxi,
16324 +       int family, int pos, int size, char *file, int line)
16325 +{
16326 +       if (vxi) {
16327 +               int type = vx_sock_type(family);
16328 +
16329 +               atomic_long_inc(&vxi->cacct.sock[type][pos].count);
16330 +               atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
16331 +       }
16332 +}
16333 +
16334 +#define vx_sock_recv(sk, s) \
16335 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
16336 +#define vx_sock_send(sk, s) \
16337 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
16338 +#define vx_sock_fail(sk, s) \
16339 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
16340 +
16341 +
16342 +#define sock_vx_init(s) do {           \
16343 +       (s)->sk_xid = 0;                \
16344 +       (s)->sk_vx_info = NULL;         \
16345 +       } while (0)
16346 +
16347 +#define sock_nx_init(s) do {           \
16348 +       (s)->sk_nid = 0;                \
16349 +       (s)->sk_nx_info = NULL;         \
16350 +       } while (0)
16351 +
16352 +#else
16353 +#warning duplicate inclusion
16354 +#endif
16355 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_tag.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_tag.h
16356 --- linux-2.6.33.1/include/linux/vs_tag.h       1970-01-01 01:00:00.000000000 +0100
16357 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_tag.h       2010-02-25 12:02:16.000000000 +0100
16358 @@ -0,0 +1,47 @@
16359 +#ifndef _VS_TAG_H
16360 +#define _VS_TAG_H
16361 +
16362 +#include <linux/vserver/tag.h>
16363 +
16364 +/* check conditions */
16365 +
16366 +#define DX_ADMIN       0x0001
16367 +#define DX_WATCH       0x0002
16368 +#define DX_HOSTID      0x0008
16369 +
16370 +#define DX_IDENT       0x0010
16371 +
16372 +#define DX_ARG_MASK    0x0010
16373 +
16374 +
16375 +#define dx_task_tag(t) ((t)->tag)
16376 +
16377 +#define dx_current_tag() dx_task_tag(current)
16378 +
16379 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
16380 +
16381 +#define dx_weak_check(c, m)    ((m) ? dx_check(c, m) : 1)
16382 +
16383 +
16384 +/*
16385 + * check current context for ADMIN/WATCH and
16386 + * optionally against supplied argument
16387 + */
16388 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
16389 +{
16390 +       if (mode & DX_ARG_MASK) {
16391 +               if ((mode & DX_IDENT) && (id == cid))
16392 +                       return 1;
16393 +       }
16394 +       return (((mode & DX_ADMIN) && (cid == 0)) ||
16395 +               ((mode & DX_WATCH) && (cid == 1)) ||
16396 +               ((mode & DX_HOSTID) && (id == 0)));
16397 +}
16398 +
16399 +struct inode;
16400 +int dx_permission(const struct inode *inode, int mask);
16401 +
16402 +
16403 +#else
16404 +#warning duplicate inclusion
16405 +#endif
16406 diff -NurpP --minimal linux-2.6.33.1/include/linux/vs_time.h linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_time.h
16407 --- linux-2.6.33.1/include/linux/vs_time.h      1970-01-01 01:00:00.000000000 +0100
16408 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/linux/vs_time.h      2010-02-25 12:02:16.000000000 +0100
16409 @@ -0,0 +1,19 @@
16410 +#ifndef _VS_TIME_H
16411 +#define _VS_TIME_H
16412 +
16413 +
16414 +/* time faking stuff */
16415 +
16416 +#ifdef CONFIG_VSERVER_VTIME
16417 +
16418 +extern void vx_gettimeofday(struct timeval *tv);
16419 +extern int vx_settimeofday(struct timespec *ts);
16420 +
16421 +#else
16422 +#define        vx_gettimeofday(t)      do_gettimeofday(t)
16423 +#define        vx_settimeofday(t)      do_settimeofday(t)
16424 +#endif
16425 +
16426 +#else
16427 +#warning duplicate inclusion
16428 +#endif
16429 diff -NurpP --minimal linux-2.6.33.1/include/net/addrconf.h linux-2.6.33.1-vs2.3.0.36.30.4/include/net/addrconf.h
16430 --- linux-2.6.33.1/include/net/addrconf.h       2009-12-03 20:02:57.000000000 +0100
16431 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/net/addrconf.h       2010-02-25 12:02:16.000000000 +0100
16432 @@ -84,7 +84,8 @@ extern int                    ipv6_dev_get_saddr(struct n
16433                                                struct net_device *dev,
16434                                                const struct in6_addr *daddr,
16435                                                unsigned int srcprefs,
16436 -                                              struct in6_addr *saddr);
16437 +                                              struct in6_addr *saddr,
16438 +                                              struct nx_info *nxi);
16439  extern int                     ipv6_get_lladdr(struct net_device *dev,
16440                                                 struct in6_addr *addr,
16441                                                 unsigned char banned_flags);
16442 diff -NurpP --minimal linux-2.6.33.1/include/net/af_unix.h linux-2.6.33.1-vs2.3.0.36.30.4/include/net/af_unix.h
16443 --- linux-2.6.33.1/include/net/af_unix.h        2008-12-25 00:26:37.000000000 +0100
16444 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/net/af_unix.h        2010-02-25 12:02:16.000000000 +0100
16445 @@ -4,6 +4,7 @@
16446  #include <linux/socket.h>
16447  #include <linux/un.h>
16448  #include <linux/mutex.h>
16449 +#include <linux/vs_base.h>
16450  #include <net/sock.h>
16451  
16452  extern void unix_inflight(struct file *fp);
16453 diff -NurpP --minimal linux-2.6.33.1/include/net/inet_timewait_sock.h linux-2.6.33.1-vs2.3.0.36.30.4/include/net/inet_timewait_sock.h
16454 --- linux-2.6.33.1/include/net/inet_timewait_sock.h     2010-02-25 11:52:08.000000000 +0100
16455 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/net/inet_timewait_sock.h     2010-02-25 12:02:16.000000000 +0100
16456 @@ -117,6 +117,10 @@ struct inet_timewait_sock {
16457  #define tw_hash                        __tw_common.skc_hash
16458  #define tw_prot                        __tw_common.skc_prot
16459  #define tw_net                 __tw_common.skc_net
16460 +#define tw_xid                 __tw_common.skc_xid
16461 +#define tw_vx_info             __tw_common.skc_vx_info
16462 +#define tw_nid                 __tw_common.skc_nid
16463 +#define tw_nx_info             __tw_common.skc_nx_info
16464         int                     tw_timeout;
16465         volatile unsigned char  tw_substate;
16466         /* 3 bits hole, try to pack */
16467 diff -NurpP --minimal linux-2.6.33.1/include/net/route.h linux-2.6.33.1-vs2.3.0.36.30.4/include/net/route.h
16468 --- linux-2.6.33.1/include/net/route.h  2010-02-25 11:52:08.000000000 +0100
16469 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/net/route.h  2010-02-25 12:02:16.000000000 +0100
16470 @@ -132,6 +132,9 @@ static inline void ip_rt_put(struct rtab
16471                 dst_release(&rt->u.dst);
16472  }
16473  
16474 +#include <linux/vs_base.h>
16475 +#include <linux/vs_inet.h>
16476 +
16477  #define IPTOS_RT_MASK  (IPTOS_TOS_MASK & ~3)
16478  
16479  extern const __u8 ip_tos2prio[16];
16480 @@ -141,6 +144,9 @@ static inline char rt_tos2priority(u8 to
16481         return ip_tos2prio[IPTOS_TOS(tos)>>1];
16482  }
16483  
16484 +extern int ip_v4_find_src(struct net *net, struct nx_info *,
16485 +       struct rtable **, struct flowi *);
16486 +
16487  static inline int ip_route_connect(struct rtable **rp, __be32 dst,
16488                                    __be32 src, u32 tos, int oif, u8 protocol,
16489                                    __be16 sport, __be16 dport, struct sock *sk,
16490 @@ -158,11 +164,24 @@ static inline int ip_route_connect(struc
16491  
16492         int err;
16493         struct net *net = sock_net(sk);
16494 +       struct nx_info *nx_info = current_nx_info();
16495  
16496         if (inet_sk(sk)->transparent)
16497                 fl.flags |= FLOWI_FLAG_ANYSRC;
16498  
16499 -       if (!dst || !src) {
16500 +       if (sk)
16501 +               nx_info = sk->sk_nx_info;
16502 +
16503 +       vxdprintk(VXD_CBIT(net, 4),
16504 +               "ip_route_connect(%p) %p,%p;%lx",
16505 +               sk, nx_info, sk->sk_socket,
16506 +               (sk->sk_socket?sk->sk_socket->flags:0));
16507 +
16508 +       err = ip_v4_find_src(net, nx_info, rp, &fl);
16509 +       if (err)
16510 +               return err;
16511 +
16512 +       if (!fl.fl4_dst || !fl.fl4_src) {
16513                 err = __ip_route_output_key(net, rp, &fl);
16514                 if (err)
16515                         return err;
16516 diff -NurpP --minimal linux-2.6.33.1/include/net/sock.h linux-2.6.33.1-vs2.3.0.36.30.4/include/net/sock.h
16517 --- linux-2.6.33.1/include/net/sock.h   2010-02-25 11:52:08.000000000 +0100
16518 +++ linux-2.6.33.1-vs2.3.0.36.30.4/include/net/sock.h   2010-02-25 12:02:16.000000000 +0100
16519 @@ -149,6 +149,10 @@ struct sock_common {
16520  #ifdef CONFIG_NET_NS
16521         struct net              *skc_net;
16522  #endif
16523 +       xid_t                   skc_xid;
16524 +       struct vx_info          *skc_vx_info;
16525 +       nid_t                   skc_nid;
16526 +       struct nx_info          *skc_nx_info;
16527  };
16528  
16529  /**
16530 @@ -236,6 +240,10 @@ struct sock {
16531  #define sk_bind_node           __sk_common.skc_bind_node
16532  #define sk_prot                        __sk_common.skc_prot
16533  #define sk_net                 __sk_common.skc_net
16534 +#define sk_xid                 __sk_common.skc_xid
16535 +#define sk_vx_info             __sk_common.skc_vx_info
16536 +#define sk_nid                 __sk_common.skc_nid
16537 +#define sk_nx_info             __sk_common.skc_nx_info
16538         kmemcheck_bitfield_begin(flags);
16539         unsigned int            sk_shutdown  : 2,
16540                                 sk_no_check  : 2,
16541 diff -NurpP --minimal linux-2.6.33.1/init/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/init/Kconfig
16542 --- linux-2.6.33.1/init/Kconfig 2010-02-25 11:52:09.000000000 +0100
16543 +++ linux-2.6.33.1-vs2.3.0.36.30.4/init/Kconfig 2010-02-25 16:27:44.000000000 +0100
16544 @@ -496,8 +496,22 @@ config CGROUP_SCHED
16545  
16546  endchoice
16547  
16548 +config CFS_HARD_LIMITS
16549 +       bool "Hard Limits for CFS Group Scheduler"
16550 +       depends on EXPERIMENTAL
16551 +       depends on FAIR_GROUP_SCHED && CGROUP_SCHED
16552 +       default y
16553 +       help
16554 +         This option enables hard limiting of CPU time obtained by
16555 +         a fair task group. Use this if you want to throttle a group of tasks
16556 +         based on its CPU usage. For more details refer to
16557 +         Documentation/scheduler/sched-cfs-hard-limits.txt
16558 +
16559 +         Say N if unsure.
16560 +
16561  menuconfig CGROUPS
16562         boolean "Control Group support"
16563 +       default y
16564         help
16565           This option adds support for grouping sets of processes together, for
16566           use with process control subsystems such as Cpusets, CFS, memory
16567 @@ -525,6 +539,7 @@ config CGROUP_DEBUG
16568  config CGROUP_NS
16569         bool "Namespace cgroup subsystem"
16570         depends on CGROUPS
16571 +       default n
16572         help
16573           Provides a simple namespace cgroup subsystem to
16574           provide hierarchical naming of sets of namespaces,
16575 diff -NurpP --minimal linux-2.6.33.1/init/main.c linux-2.6.33.1-vs2.3.0.36.30.4/init/main.c
16576 --- linux-2.6.33.1/init/main.c  2010-02-25 11:52:09.000000000 +0100
16577 +++ linux-2.6.33.1-vs2.3.0.36.30.4/init/main.c  2010-02-25 12:02:16.000000000 +0100
16578 @@ -70,6 +70,7 @@
16579  #include <linux/sfi.h>
16580  #include <linux/shmem_fs.h>
16581  #include <trace/boot.h>
16582 +#include <linux/vserver/percpu.h>
16583  
16584  #include <asm/io.h>
16585  #include <asm/bugs.h>
16586 diff -NurpP --minimal linux-2.6.33.1/ipc/mqueue.c linux-2.6.33.1-vs2.3.0.36.30.4/ipc/mqueue.c
16587 --- linux-2.6.33.1/ipc/mqueue.c 2010-02-25 11:52:09.000000000 +0100
16588 +++ linux-2.6.33.1-vs2.3.0.36.30.4/ipc/mqueue.c 2010-02-25 12:21:21.000000000 +0100
16589 @@ -32,6 +32,8 @@
16590  #include <linux/nsproxy.h>
16591  #include <linux/pid.h>
16592  #include <linux/ipc_namespace.h>
16593 +#include <linux/vs_context.h>
16594 +#include <linux/vs_limit.h>
16595  
16596  #include <net/sock.h>
16597  #include "util.h"
16598 @@ -65,6 +67,7 @@ struct mqueue_inode_info {
16599         struct sigevent notify;
16600         struct pid* notify_owner;
16601         struct user_struct *user;       /* user who created, for accounting */
16602 +       struct vx_info *vxi;
16603         struct sock *notify_sock;
16604         struct sk_buff *notify_cookie;
16605  
16606 @@ -124,6 +127,7 @@ static struct inode *mqueue_get_inode(st
16607                 if (S_ISREG(mode)) {
16608                         struct mqueue_inode_info *info;
16609                         struct task_struct *p = current;
16610 +                       struct vx_info *vxi = p->vx_info;
16611                         unsigned long mq_bytes, mq_msg_tblsz;
16612  
16613                         inode->i_fop = &mqueue_file_operations;
16614 @@ -138,6 +142,7 @@ static struct inode *mqueue_get_inode(st
16615                         info->notify_owner = NULL;
16616                         info->qsize = 0;
16617                         info->user = NULL;      /* set when all is ok */
16618 +                       info->vxi = NULL;
16619                         memset(&info->attr, 0, sizeof(info->attr));
16620                         info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
16621                         info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
16622 @@ -152,22 +157,26 @@ static struct inode *mqueue_get_inode(st
16623                         spin_lock(&mq_lock);
16624                         if (u->mq_bytes + mq_bytes < u->mq_bytes ||
16625                             u->mq_bytes + mq_bytes >
16626 -                           p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
16627 +                           p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur ||
16628 +                           !vx_ipcmsg_avail(vxi, mq_bytes)) {
16629                                 spin_unlock(&mq_lock);
16630                                 goto out_inode;
16631                         }
16632                         u->mq_bytes += mq_bytes;
16633 +                       vx_ipcmsg_add(vxi, u, mq_bytes);
16634                         spin_unlock(&mq_lock);
16635  
16636                         info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
16637                         if (!info->messages) {
16638                                 spin_lock(&mq_lock);
16639                                 u->mq_bytes -= mq_bytes;
16640 +                               vx_ipcmsg_sub(vxi, u, mq_bytes);
16641                                 spin_unlock(&mq_lock);
16642                                 goto out_inode;
16643                         }
16644                         /* all is ok */
16645                         info->user = get_uid(u);
16646 +                       info->vxi = get_vx_info(vxi);
16647                 } else if (S_ISDIR(mode)) {
16648                         inc_nlink(inode);
16649                         /* Some things misbehave if size == 0 on a directory */
16650 @@ -268,8 +277,11 @@ static void mqueue_delete_inode(struct i
16651                    (info->attr.mq_maxmsg * info->attr.mq_msgsize));
16652         user = info->user;
16653         if (user) {
16654 +               struct vx_info *vxi = info->vxi;
16655 +
16656                 spin_lock(&mq_lock);
16657                 user->mq_bytes -= mq_bytes;
16658 +               vx_ipcmsg_sub(vxi, user, mq_bytes);
16659                 /*
16660                  * get_ns_from_inode() ensures that the
16661                  * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
16662 @@ -279,6 +291,7 @@ static void mqueue_delete_inode(struct i
16663                 if (ipc_ns)
16664                         ipc_ns->mq_queues_count--;
16665                 spin_unlock(&mq_lock);
16666 +               put_vx_info(vxi);
16667                 free_uid(user);
16668         }
16669         if (ipc_ns)
16670 diff -NurpP --minimal linux-2.6.33.1/ipc/msg.c linux-2.6.33.1-vs2.3.0.36.30.4/ipc/msg.c
16671 --- linux-2.6.33.1/ipc/msg.c    2010-02-25 11:52:09.000000000 +0100
16672 +++ linux-2.6.33.1-vs2.3.0.36.30.4/ipc/msg.c    2010-02-25 12:02:16.000000000 +0100
16673 @@ -38,6 +38,7 @@
16674  #include <linux/rwsem.h>
16675  #include <linux/nsproxy.h>
16676  #include <linux/ipc_namespace.h>
16677 +#include <linux/vs_base.h>
16678  
16679  #include <asm/current.h>
16680  #include <asm/uaccess.h>
16681 @@ -191,6 +192,7 @@ static int newque(struct ipc_namespace *
16682  
16683         msq->q_perm.mode = msgflg & S_IRWXUGO;
16684         msq->q_perm.key = key;
16685 +       msq->q_perm.xid = vx_current_xid();
16686  
16687         msq->q_perm.security = NULL;
16688         retval = security_msg_queue_alloc(msq);
16689 diff -NurpP --minimal linux-2.6.33.1/ipc/namespace.c linux-2.6.33.1-vs2.3.0.36.30.4/ipc/namespace.c
16690 --- linux-2.6.33.1/ipc/namespace.c      2009-09-10 15:26:27.000000000 +0200
16691 +++ linux-2.6.33.1-vs2.3.0.36.30.4/ipc/namespace.c      2010-02-25 12:02:16.000000000 +0100
16692 @@ -11,6 +11,8 @@
16693  #include <linux/slab.h>
16694  #include <linux/fs.h>
16695  #include <linux/mount.h>
16696 +#include <linux/vs_base.h>
16697 +#include <linux/vserver/global.h>
16698  
16699  #include "util.h"
16700  
16701 diff -NurpP --minimal linux-2.6.33.1/ipc/sem.c linux-2.6.33.1-vs2.3.0.36.30.4/ipc/sem.c
16702 --- linux-2.6.33.1/ipc/sem.c    2010-02-25 11:52:09.000000000 +0100
16703 +++ linux-2.6.33.1-vs2.3.0.36.30.4/ipc/sem.c    2010-02-25 12:02:16.000000000 +0100
16704 @@ -83,6 +83,8 @@
16705  #include <linux/rwsem.h>
16706  #include <linux/nsproxy.h>
16707  #include <linux/ipc_namespace.h>
16708 +#include <linux/vs_base.h>
16709 +#include <linux/vs_limit.h>
16710  
16711  #include <asm/uaccess.h>
16712  #include "util.h"
16713 @@ -257,6 +259,7 @@ static int newary(struct ipc_namespace *
16714  
16715         sma->sem_perm.mode = (semflg & S_IRWXUGO);
16716         sma->sem_perm.key = key;
16717 +       sma->sem_perm.xid = vx_current_xid();
16718  
16719         sma->sem_perm.security = NULL;
16720         retval = security_sem_alloc(sma);
16721 @@ -272,6 +275,9 @@ static int newary(struct ipc_namespace *
16722                 return id;
16723         }
16724         ns->used_sems += nsems;
16725 +       /* FIXME: obsoleted? */
16726 +       vx_semary_inc(sma);
16727 +       vx_nsems_add(sma, nsems);
16728  
16729         sma->sem_base = (struct sem *) &sma[1];
16730  
16731 @@ -595,6 +601,9 @@ static void freeary(struct ipc_namespace
16732         sem_unlock(sma);
16733  
16734         ns->used_sems -= sma->sem_nsems;
16735 +       /* FIXME: obsoleted? */
16736 +       vx_nsems_sub(sma, sma->sem_nsems);
16737 +       vx_semary_dec(sma);
16738         security_sem_free(sma);
16739         ipc_rcu_putref(sma);
16740  }
16741 diff -NurpP --minimal linux-2.6.33.1/ipc/shm.c linux-2.6.33.1-vs2.3.0.36.30.4/ipc/shm.c
16742 --- linux-2.6.33.1/ipc/shm.c    2010-02-25 11:52:09.000000000 +0100
16743 +++ linux-2.6.33.1-vs2.3.0.36.30.4/ipc/shm.c    2010-02-25 12:23:04.000000000 +0100
16744 @@ -39,6 +39,8 @@
16745  #include <linux/nsproxy.h>
16746  #include <linux/mount.h>
16747  #include <linux/ipc_namespace.h>
16748 +#include <linux/vs_context.h>
16749 +#include <linux/vs_limit.h>
16750  
16751  #include <asm/uaccess.h>
16752  
16753 @@ -169,7 +171,12 @@ static void shm_open(struct vm_area_stru
16754   */
16755  static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
16756  {
16757 -       ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16758 +       struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
16759 +       int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16760 +
16761 +       vx_ipcshm_sub(vxi, shp, numpages);
16762 +       ns->shm_tot -= numpages;
16763 +
16764         shm_rmid(ns, shp);
16765         shm_unlock(shp);
16766         if (!is_file_hugepages(shp->shm_file))
16767 @@ -179,6 +186,7 @@ static void shm_destroy(struct ipc_names
16768                                                 shp->mlock_user);
16769         fput (shp->shm_file);
16770         security_shm_free(shp);
16771 +       put_vx_info(vxi);
16772         ipc_rcu_putref(shp);
16773  }
16774  
16775 @@ -352,11 +360,15 @@ static int newseg(struct ipc_namespace *
16776         if (ns->shm_tot + numpages > ns->shm_ctlall)
16777                 return -ENOSPC;
16778  
16779 +       if (!vx_ipcshm_avail(current_vx_info(), numpages))
16780 +               return -ENOSPC;
16781 +
16782         shp = ipc_rcu_alloc(sizeof(*shp));
16783         if (!shp)
16784                 return -ENOMEM;
16785  
16786         shp->shm_perm.key = key;
16787 +       shp->shm_perm.xid = vx_current_xid();
16788         shp->shm_perm.mode = (shmflg & S_IRWXUGO);
16789         shp->mlock_user = NULL;
16790  
16791 @@ -410,6 +422,7 @@ static int newseg(struct ipc_namespace *
16792         ns->shm_tot += numpages;
16793         error = shp->shm_perm.id;
16794         shm_unlock(shp);
16795 +       vx_ipcshm_add(current_vx_info(), key, numpages);
16796         return error;
16797  
16798  no_id:
16799 diff -NurpP --minimal linux-2.6.33.1/kernel/capability.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/capability.c
16800 --- linux-2.6.33.1/kernel/capability.c  2010-02-25 11:52:09.000000000 +0100
16801 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/capability.c  2010-02-25 12:02:16.000000000 +0100
16802 @@ -14,6 +14,7 @@
16803  #include <linux/security.h>
16804  #include <linux/syscalls.h>
16805  #include <linux/pid_namespace.h>
16806 +#include <linux/vs_context.h>
16807  #include <asm/uaccess.h>
16808  #include "cred-internals.h"
16809  
16810 @@ -120,6 +121,7 @@ static int cap_validate_magic(cap_user_h
16811         return 0;
16812  }
16813  
16814 +
16815  /*
16816   * The only thing that can change the capabilities of the current
16817   * process is the current process. As such, we can't be in this code
16818 @@ -290,6 +292,8 @@ error:
16819         return ret;
16820  }
16821  
16822 +#include <linux/vserver/base.h>
16823 +
16824  /**
16825   * capable - Determine if the current task has a superior capability in effect
16826   * @cap: The capability to be tested for
16827 @@ -302,6 +306,9 @@ error:
16828   */
16829  int capable(int cap)
16830  {
16831 +       /* here for now so we don't require task locking */
16832 +       if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
16833 +               return 0;
16834         if (unlikely(!cap_valid(cap))) {
16835                 printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
16836                 BUG();
16837 diff -NurpP --minimal linux-2.6.33.1/kernel/compat.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/compat.c
16838 --- linux-2.6.33.1/kernel/compat.c      2009-09-10 15:26:27.000000000 +0200
16839 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/compat.c      2010-02-25 12:02:16.000000000 +0100
16840 @@ -902,7 +902,7 @@ asmlinkage long compat_sys_time(compat_t
16841         compat_time_t i;
16842         struct timeval tv;
16843  
16844 -       do_gettimeofday(&tv);
16845 +       vx_gettimeofday(&tv);
16846         i = tv.tv_sec;
16847  
16848         if (tloc) {
16849 @@ -927,7 +927,7 @@ asmlinkage long compat_sys_stime(compat_
16850         if (err)
16851                 return err;
16852  
16853 -       do_settimeofday(&tv);
16854 +       vx_settimeofday(&tv);
16855         return 0;
16856  }
16857  
16858 diff -NurpP --minimal linux-2.6.33.1/kernel/exit.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/exit.c
16859 --- linux-2.6.33.1/kernel/exit.c        2010-02-25 11:52:09.000000000 +0100
16860 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/exit.c        2010-02-25 12:02:16.000000000 +0100
16861 @@ -48,6 +48,10 @@
16862  #include <linux/fs_struct.h>
16863  #include <linux/init_task.h>
16864  #include <linux/perf_event.h>
16865 +#include <linux/vs_limit.h>
16866 +#include <linux/vs_context.h>
16867 +#include <linux/vs_network.h>
16868 +#include <linux/vs_pid.h>
16869  #include <trace/events/sched.h>
16870  #include <linux/hw_breakpoint.h>
16871  
16872 @@ -489,9 +493,11 @@ static void close_files(struct files_str
16873                                         filp_close(file, files);
16874                                         cond_resched();
16875                                 }
16876 +                               vx_openfd_dec(i);
16877                         }
16878                         i++;
16879                         set >>= 1;
16880 +                       cond_resched();
16881                 }
16882         }
16883  }
16884 @@ -1019,11 +1025,16 @@ NORET_TYPE void do_exit(long code)
16885  
16886         validate_creds_for_do_exit(tsk);
16887  
16888 +       /* needs to stay after exit_notify() */
16889 +       exit_vx_info(tsk, code);
16890 +       exit_nx_info(tsk);
16891 +
16892         preempt_disable();
16893         exit_rcu();
16894         /* causes final put_task_struct in finish_task_switch(). */
16895         tsk->state = TASK_DEAD;
16896         schedule();
16897 +       printk("bad task: %p [%lx]\n", current, current->state);
16898         BUG();
16899         /* Avoid "noreturn function does return".  */
16900         for (;;)
16901 diff -NurpP --minimal linux-2.6.33.1/kernel/fork.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/fork.c
16902 --- linux-2.6.33.1/kernel/fork.c        2010-02-25 11:52:09.000000000 +0100
16903 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/fork.c        2010-02-25 12:23:31.000000000 +0100
16904 @@ -65,6 +65,10 @@
16905  #include <linux/perf_event.h>
16906  #include <linux/posix-timers.h>
16907  #include <linux/user-return-notifier.h>
16908 +#include <linux/vs_context.h>
16909 +#include <linux/vs_network.h>
16910 +#include <linux/vs_limit.h>
16911 +#include <linux/vs_memory.h>
16912  
16913  #include <asm/pgtable.h>
16914  #include <asm/pgalloc.h>
16915 @@ -152,6 +156,8 @@ void free_task(struct task_struct *tsk)
16916         account_kernel_stack(tsk->stack, -1);
16917         free_thread_info(tsk->stack);
16918         rt_mutex_debug_task_free(tsk);
16919 +       clr_vx_info(&tsk->vx_info);
16920 +       clr_nx_info(&tsk->nx_info);
16921         ftrace_graph_exit_task(tsk);
16922         free_task_struct(tsk);
16923  }
16924 @@ -298,6 +304,8 @@ static int dup_mmap(struct mm_struct *mm
16925         mm->free_area_cache = oldmm->mmap_base;
16926         mm->cached_hole_size = ~0UL;
16927         mm->map_count = 0;
16928 +       __set_mm_counter(mm, file_rss, 0);
16929 +       __set_mm_counter(mm, anon_rss, 0);
16930         cpumask_clear(mm_cpumask(mm));
16931         mm->mm_rb = RB_ROOT;
16932         rb_link = &mm->mm_rb.rb_node;
16933 @@ -312,7 +320,7 @@ static int dup_mmap(struct mm_struct *mm
16934  
16935                 if (mpnt->vm_flags & VM_DONTCOPY) {
16936                         long pages = vma_pages(mpnt);
16937 -                       mm->total_vm -= pages;
16938 +                       vx_vmpages_sub(mm, pages);
16939                         vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
16940                                                                 -pages);
16941                         continue;
16942 @@ -454,8 +462,8 @@ static struct mm_struct * mm_init(struct
16943                 (current->mm->flags & MMF_INIT_MASK) : default_dump_filter;
16944         mm->core_state = NULL;
16945         mm->nr_ptes = 0;
16946 -       set_mm_counter(mm, file_rss, 0);
16947 -       set_mm_counter(mm, anon_rss, 0);
16948 +       __set_mm_counter(mm, file_rss, 0);
16949 +       __set_mm_counter(mm, anon_rss, 0);
16950         spin_lock_init(&mm->page_table_lock);
16951         mm->free_area_cache = TASK_UNMAPPED_BASE;
16952         mm->cached_hole_size = ~0UL;
16953 @@ -465,6 +473,7 @@ static struct mm_struct * mm_init(struct
16954         if (likely(!mm_alloc_pgd(mm))) {
16955                 mm->def_flags = 0;
16956                 mmu_notifier_mm_init(mm);
16957 +               set_vx_info(&mm->mm_vx_info, p->vx_info);
16958                 return mm;
16959         }
16960  
16961 @@ -498,6 +507,7 @@ void __mmdrop(struct mm_struct *mm)
16962         mm_free_pgd(mm);
16963         destroy_context(mm);
16964         mmu_notifier_mm_destroy(mm);
16965 +       clr_vx_info(&mm->mm_vx_info);
16966         free_mm(mm);
16967  }
16968  EXPORT_SYMBOL_GPL(__mmdrop);
16969 @@ -633,6 +643,7 @@ struct mm_struct *dup_mm(struct task_str
16970                 goto fail_nomem;
16971  
16972         memcpy(mm, oldmm, sizeof(*mm));
16973 +       mm->mm_vx_info = NULL;
16974  
16975         /* Initializing for Swap token stuff */
16976         mm->token_priority = 0;
16977 @@ -671,6 +682,7 @@ fail_nocontext:
16978          * If init_new_context() failed, we cannot use mmput() to free the mm
16979          * because it calls destroy_context()
16980          */
16981 +       clr_vx_info(&mm->mm_vx_info);
16982         mm_free_pgd(mm);
16983         free_mm(mm);
16984         return NULL;
16985 @@ -985,6 +997,8 @@ static struct task_struct *copy_process(
16986         int retval;
16987         struct task_struct *p;
16988         int cgroup_callbacks_done = 0;
16989 +       struct vx_info *vxi;
16990 +       struct nx_info *nxi;
16991  
16992         if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
16993                 return ERR_PTR(-EINVAL);
16994 @@ -1031,12 +1045,28 @@ static struct task_struct *copy_process(
16995         DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
16996         DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
16997  #endif
16998 +       init_vx_info(&p->vx_info, current_vx_info());
16999 +       init_nx_info(&p->nx_info, current_nx_info());
17000 +
17001 +       /* check vserver memory */
17002 +       if (p->mm && !(clone_flags & CLONE_VM)) {
17003 +               if (vx_vmpages_avail(p->mm, p->mm->total_vm))
17004 +                       vx_pages_add(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17005 +               else
17006 +                       goto bad_fork_free;
17007 +       }
17008 +       if (p->mm && vx_flags(VXF_FORK_RSS, 0)) {
17009 +               if (!vx_rss_avail(p->mm, get_mm_counter(p->mm, file_rss)))
17010 +                       goto bad_fork_cleanup_vm;
17011 +       }
17012         retval = -EAGAIN;
17013 +       if (!vx_nproc_avail(1))
17014 +               goto bad_fork_cleanup_vm;
17015         if (atomic_read(&p->real_cred->user->processes) >=
17016                         p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
17017                 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
17018                     p->real_cred->user != INIT_USER)
17019 -                       goto bad_fork_free;
17020 +                       goto bad_fork_cleanup_vm;
17021         }
17022  
17023         retval = copy_creds(p, clone_flags);
17024 @@ -1297,6 +1327,18 @@ static struct task_struct *copy_process(
17025  
17026         total_forks++;
17027         spin_unlock(&current->sighand->siglock);
17028 +
17029 +       /* p is copy of current */
17030 +       vxi = p->vx_info;
17031 +       if (vxi) {
17032 +               claim_vx_info(vxi, p);
17033 +               atomic_inc(&vxi->cvirt.nr_threads);
17034 +               atomic_inc(&vxi->cvirt.total_forks);
17035 +               vx_nproc_inc(p);
17036 +       }
17037 +       nxi = p->nx_info;
17038 +       if (nxi)
17039 +               claim_nx_info(nxi, p);
17040         write_unlock_irq(&tasklist_lock);
17041         proc_fork_connector(p);
17042         cgroup_post_fork(p);
17043 @@ -1339,6 +1381,9 @@ bad_fork_cleanup_cgroup:
17044  bad_fork_cleanup_count:
17045         atomic_dec(&p->cred->user->processes);
17046         exit_creds(p);
17047 +bad_fork_cleanup_vm:
17048 +       if (p->mm && !(clone_flags & CLONE_VM))
17049 +               vx_pages_sub(p->vx_info, RLIMIT_AS, p->mm->total_vm);
17050  bad_fork_free:
17051         free_task(p);
17052  fork_out:
17053 diff -NurpP --minimal linux-2.6.33.1/kernel/kthread.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/kthread.c
17054 --- linux-2.6.33.1/kernel/kthread.c     2010-02-25 11:52:09.000000000 +0100
17055 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/kthread.c     2010-02-25 12:02:16.000000000 +0100
17056 @@ -14,6 +14,7 @@
17057  #include <linux/file.h>
17058  #include <linux/module.h>
17059  #include <linux/mutex.h>
17060 +#include <linux/vs_pid.h>
17061  #include <trace/events/sched.h>
17062  
17063  static DEFINE_SPINLOCK(kthread_create_lock);
17064 diff -NurpP --minimal linux-2.6.33.1/kernel/Makefile linux-2.6.33.1-vs2.3.0.36.30.4/kernel/Makefile
17065 --- linux-2.6.33.1/kernel/Makefile      2010-02-25 11:52:09.000000000 +0100
17066 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/Makefile      2010-02-25 12:02:16.000000000 +0100
17067 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
17068  CFLAGS_REMOVE_perf_event.o = -pg
17069  endif
17070  
17071 +obj-y += vserver/
17072  obj-$(CONFIG_FREEZER) += freezer.o
17073  obj-$(CONFIG_PROFILING) += profile.o
17074  obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
17075 diff -NurpP --minimal linux-2.6.33.1/kernel/nsproxy.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/nsproxy.c
17076 --- linux-2.6.33.1/kernel/nsproxy.c     2009-09-10 15:26:28.000000000 +0200
17077 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/nsproxy.c     2010-02-25 12:02:16.000000000 +0100
17078 @@ -19,6 +19,8 @@
17079  #include <linux/mnt_namespace.h>
17080  #include <linux/utsname.h>
17081  #include <linux/pid_namespace.h>
17082 +#include <linux/vserver/global.h>
17083 +#include <linux/vserver/debug.h>
17084  #include <net/net_namespace.h>
17085  #include <linux/ipc_namespace.h>
17086  
17087 @@ -31,8 +33,11 @@ static inline struct nsproxy *create_nsp
17088         struct nsproxy *nsproxy;
17089  
17090         nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
17091 -       if (nsproxy)
17092 +       if (nsproxy) {
17093                 atomic_set(&nsproxy->count, 1);
17094 +               atomic_inc(&vs_global_nsproxy);
17095 +       }
17096 +       vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
17097         return nsproxy;
17098  }
17099  
17100 @@ -41,41 +46,52 @@ static inline struct nsproxy *create_nsp
17101   * Return the newly created nsproxy.  Do not attach this to the task,
17102   * leave it to the caller to do proper locking and attach it to task.
17103   */
17104 -static struct nsproxy *create_new_namespaces(unsigned long flags,
17105 -                       struct task_struct *tsk, struct fs_struct *new_fs)
17106 +static struct nsproxy *unshare_namespaces(unsigned long flags,
17107 +                       struct nsproxy *orig, struct fs_struct *new_fs)
17108  {
17109         struct nsproxy *new_nsp;
17110         int err;
17111  
17112 +       vxdprintk(VXD_CBIT(space, 4),
17113 +               "unshare_namespaces(0x%08lx,%p,%p)",
17114 +               flags, orig, new_fs);
17115 +
17116         new_nsp = create_nsproxy();
17117         if (!new_nsp)
17118                 return ERR_PTR(-ENOMEM);
17119  
17120 -       new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
17121 +       new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
17122         if (IS_ERR(new_nsp->mnt_ns)) {
17123                 err = PTR_ERR(new_nsp->mnt_ns);
17124                 goto out_ns;
17125         }
17126  
17127 -       new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
17128 +       new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns);
17129         if (IS_ERR(new_nsp->uts_ns)) {
17130                 err = PTR_ERR(new_nsp->uts_ns);
17131                 goto out_uts;
17132         }
17133  
17134 -       new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
17135 +       new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns);
17136         if (IS_ERR(new_nsp->ipc_ns)) {
17137                 err = PTR_ERR(new_nsp->ipc_ns);
17138                 goto out_ipc;
17139         }
17140  
17141 -       new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
17142 +       new_nsp->pid_ns = copy_pid_ns(flags, orig->pid_ns);
17143         if (IS_ERR(new_nsp->pid_ns)) {
17144                 err = PTR_ERR(new_nsp->pid_ns);
17145                 goto out_pid;
17146         }
17147  
17148 -       new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
17149 +       /* disabled now?
17150 +       new_nsp->user_ns = copy_user_ns(flags, orig->user_ns);
17151 +       if (IS_ERR(new_nsp->user_ns)) {
17152 +               err = PTR_ERR(new_nsp->user_ns);
17153 +               goto out_user;
17154 +       } */
17155 +
17156 +       new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
17157         if (IS_ERR(new_nsp->net_ns)) {
17158                 err = PTR_ERR(new_nsp->net_ns);
17159                 goto out_net;
17160 @@ -100,6 +116,38 @@ out_ns:
17161         return ERR_PTR(err);
17162  }
17163  
17164 +static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
17165 +                       struct fs_struct *new_fs)
17166 +{
17167 +       return unshare_namespaces(flags, tsk->nsproxy, new_fs);
17168 +}
17169 +
17170 +/*
17171 + * copies the nsproxy, setting refcount to 1, and grabbing a
17172 + * reference to all contained namespaces.
17173 + */
17174 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
17175 +{
17176 +       struct nsproxy *ns = create_nsproxy();
17177 +
17178 +       if (ns) {
17179 +               memcpy(ns, orig, sizeof(struct nsproxy));
17180 +               atomic_set(&ns->count, 1);
17181 +
17182 +               if (ns->mnt_ns)
17183 +                       get_mnt_ns(ns->mnt_ns);
17184 +               if (ns->uts_ns)
17185 +                       get_uts_ns(ns->uts_ns);
17186 +               if (ns->ipc_ns)
17187 +                       get_ipc_ns(ns->ipc_ns);
17188 +               if (ns->pid_ns)
17189 +                       get_pid_ns(ns->pid_ns);
17190 +               if (ns->net_ns)
17191 +                       get_net(ns->net_ns);
17192 +       }
17193 +       return ns;
17194 +}
17195 +
17196  /*
17197   * called from clone.  This now handles copy for nsproxy and all
17198   * namespaces therein.
17199 @@ -107,9 +155,12 @@ out_ns:
17200  int copy_namespaces(unsigned long flags, struct task_struct *tsk)
17201  {
17202         struct nsproxy *old_ns = tsk->nsproxy;
17203 -       struct nsproxy *new_ns;
17204 +       struct nsproxy *new_ns = NULL;
17205         int err = 0;
17206  
17207 +       vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
17208 +               flags, tsk, old_ns);
17209 +
17210         if (!old_ns)
17211                 return 0;
17212  
17213 @@ -119,7 +170,7 @@ int copy_namespaces(unsigned long flags,
17214                                 CLONE_NEWPID | CLONE_NEWNET)))
17215                 return 0;
17216  
17217 -       if (!capable(CAP_SYS_ADMIN)) {
17218 +       if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
17219                 err = -EPERM;
17220                 goto out;
17221         }
17222 @@ -146,6 +197,9 @@ int copy_namespaces(unsigned long flags,
17223  
17224  out:
17225         put_nsproxy(old_ns);
17226 +       vxdprintk(VXD_CBIT(space, 3),
17227 +               "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
17228 +               flags, tsk, old_ns, err, new_ns);
17229         return err;
17230  }
17231  
17232 @@ -159,7 +213,9 @@ void free_nsproxy(struct nsproxy *ns)
17233                 put_ipc_ns(ns->ipc_ns);
17234         if (ns->pid_ns)
17235                 put_pid_ns(ns->pid_ns);
17236 -       put_net(ns->net_ns);
17237 +       if (ns->net_ns)
17238 +               put_net(ns->net_ns);
17239 +       atomic_dec(&vs_global_nsproxy);
17240         kmem_cache_free(nsproxy_cachep, ns);
17241  }
17242  
17243 @@ -172,11 +228,15 @@ int unshare_nsproxy_namespaces(unsigned 
17244  {
17245         int err = 0;
17246  
17247 +       vxdprintk(VXD_CBIT(space, 4),
17248 +               "unshare_nsproxy_namespaces(0x%08lx,[%p])",
17249 +               unshare_flags, current->nsproxy);
17250 +
17251         if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
17252                                CLONE_NEWNET)))
17253                 return 0;
17254  
17255 -       if (!capable(CAP_SYS_ADMIN))
17256 +       if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
17257                 return -EPERM;
17258  
17259         *new_nsp = create_new_namespaces(unshare_flags, current,
17260 diff -NurpP --minimal linux-2.6.33.1/kernel/pid.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/pid.c
17261 --- linux-2.6.33.1/kernel/pid.c 2010-02-25 11:52:09.000000000 +0100
17262 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/pid.c 2010-02-25 12:02:16.000000000 +0100
17263 @@ -36,6 +36,7 @@
17264  #include <linux/pid_namespace.h>
17265  #include <linux/init_task.h>
17266  #include <linux/syscalls.h>
17267 +#include <linux/vs_pid.h>
17268  
17269  #define pid_hashfn(nr, ns)     \
17270         hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
17271 @@ -305,7 +306,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
17272  
17273  struct pid *find_vpid(int nr)
17274  {
17275 -       return find_pid_ns(nr, current->nsproxy->pid_ns);
17276 +       return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
17277  }
17278  EXPORT_SYMBOL_GPL(find_vpid);
17279  
17280 @@ -365,6 +366,9 @@ void transfer_pid(struct task_struct *ol
17281  struct task_struct *pid_task(struct pid *pid, enum pid_type type)
17282  {
17283         struct task_struct *result = NULL;
17284 +
17285 +       if (type == PIDTYPE_REALPID)
17286 +               type = PIDTYPE_PID;
17287         if (pid) {
17288                 struct hlist_node *first;
17289                 first = rcu_dereference(pid->tasks[type].first);
17290 @@ -380,7 +384,7 @@ EXPORT_SYMBOL(pid_task);
17291   */
17292  struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
17293  {
17294 -       return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
17295 +       return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
17296  }
17297  
17298  struct task_struct *find_task_by_vpid(pid_t vnr)
17299 @@ -422,7 +426,7 @@ struct pid *find_get_pid(pid_t nr)
17300  }
17301  EXPORT_SYMBOL_GPL(find_get_pid);
17302  
17303 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
17304 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
17305  {
17306         struct upid *upid;
17307         pid_t nr = 0;
17308 @@ -435,6 +439,11 @@ pid_t pid_nr_ns(struct pid *pid, struct 
17309         return nr;
17310  }
17311  
17312 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
17313 +{
17314 +       return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
17315 +}
17316 +
17317  pid_t pid_vnr(struct pid *pid)
17318  {
17319         return pid_nr_ns(pid, current->nsproxy->pid_ns);
17320 diff -NurpP --minimal linux-2.6.33.1/kernel/pid_namespace.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/pid_namespace.c
17321 --- linux-2.6.33.1/kernel/pid_namespace.c       2009-12-03 20:02:58.000000000 +0100
17322 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/pid_namespace.c       2010-02-25 12:02:16.000000000 +0100
17323 @@ -13,6 +13,7 @@
17324  #include <linux/syscalls.h>
17325  #include <linux/err.h>
17326  #include <linux/acct.h>
17327 +#include <linux/vserver/global.h>
17328  
17329  #define BITS_PER_PAGE          (PAGE_SIZE*8)
17330  
17331 @@ -86,6 +87,7 @@ static struct pid_namespace *create_pid_
17332                 goto out_free_map;
17333  
17334         kref_init(&ns->kref);
17335 +       atomic_inc(&vs_global_pid_ns);
17336         ns->level = level;
17337         ns->parent = get_pid_ns(parent_pid_ns);
17338  
17339 @@ -111,6 +113,7 @@ static void destroy_pid_namespace(struct
17340  
17341         for (i = 0; i < PIDMAP_ENTRIES; i++)
17342                 kfree(ns->pidmap[i].page);
17343 +       atomic_dec(&vs_global_pid_ns);
17344         kmem_cache_free(pid_ns_cachep, ns);
17345  }
17346  
17347 diff -NurpP --minimal linux-2.6.33.1/kernel/posix-timers.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/posix-timers.c
17348 --- linux-2.6.33.1/kernel/posix-timers.c        2009-12-03 20:02:58.000000000 +0100
17349 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/posix-timers.c        2010-02-25 12:02:16.000000000 +0100
17350 @@ -46,6 +46,7 @@
17351  #include <linux/wait.h>
17352  #include <linux/workqueue.h>
17353  #include <linux/module.h>
17354 +#include <linux/vs_context.h>
17355  
17356  /*
17357   * Management arrays for POSIX timers.  Timers are kept in slab memory
17358 @@ -363,6 +364,7 @@ int posix_timer_event(struct k_itimer *t
17359  {
17360         struct task_struct *task;
17361         int shared, ret = -1;
17362 +
17363         /*
17364          * FIXME: if ->sigq is queued we can race with
17365          * dequeue_signal()->do_schedule_next_timer().
17366 @@ -379,10 +381,18 @@ int posix_timer_event(struct k_itimer *t
17367         rcu_read_lock();
17368         task = pid_task(timr->it_pid, PIDTYPE_PID);
17369         if (task) {
17370 +               struct vx_info_save vxis;
17371 +               struct vx_info *vxi;
17372 +
17373 +               vxi = get_vx_info(task->vx_info);
17374 +               enter_vx_info(vxi, &vxis);
17375                 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
17376                 ret = send_sigqueue(timr->sigq, task, shared);
17377 +               leave_vx_info(&vxis);
17378 +               put_vx_info(vxi);
17379         }
17380         rcu_read_unlock();
17381 +
17382         /* If we failed to send the signal the timer stops. */
17383         return ret > 0;
17384  }
17385 diff -NurpP --minimal linux-2.6.33.1/kernel/printk.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/printk.c
17386 --- linux-2.6.33.1/kernel/printk.c      2010-02-25 11:52:09.000000000 +0100
17387 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/printk.c      2010-02-25 13:11:15.000000000 +0100
17388 @@ -35,6 +35,7 @@
17389  #include <linux/kexec.h>
17390  #include <linux/ratelimit.h>
17391  #include <linux/kmsg_dump.h>
17392 +#include <linux/vs_cvirt.h>
17393  
17394  #include <asm/uaccess.h>
17395  
17396 @@ -278,18 +279,13 @@ int do_syslog(int type, char __user *buf
17397         unsigned i, j, limit, count;
17398         int do_clear = 0;
17399         char c;
17400 -       int error = 0;
17401 +       int error;
17402  
17403         error = security_syslog(type);
17404         if (error)
17405                 return error;
17406  
17407 -       switch (type) {
17408 -       case 0:         /* Close log */
17409 -               break;
17410 -       case 1:         /* Open log */
17411 -               break;
17412 -       case 2:         /* Read from log */
17413 +       if ((type >= 2) && (type <= 4)) {
17414                 error = -EINVAL;
17415                 if (!buf || len < 0)
17416                         goto out;
17417 @@ -300,6 +296,16 @@ int do_syslog(int type, char __user *buf
17418                         error = -EFAULT;
17419                         goto out;
17420                 }
17421 +       }
17422 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
17423 +               return vx_do_syslog(type, buf, len);
17424 +
17425 +       switch (type) {
17426 +       case 0:         /* Close log */
17427 +               break;
17428 +       case 1:         /* Open log */
17429 +               break;
17430 +       case 2:         /* Read from log */
17431                 error = wait_event_interruptible(log_wait,
17432                                                         (log_start - log_end));
17433                 if (error)
17434 @@ -324,16 +330,6 @@ int do_syslog(int type, char __user *buf
17435                 do_clear = 1;
17436                 /* FALL THRU */
17437         case 3:         /* Read last kernel messages */
17438 -               error = -EINVAL;
17439 -               if (!buf || len < 0)
17440 -                       goto out;
17441 -               error = 0;
17442 -               if (!len)
17443 -                       goto out;
17444 -               if (!access_ok(VERIFY_WRITE, buf, len)) {
17445 -                       error = -EFAULT;
17446 -                       goto out;
17447 -               }
17448                 count = len;
17449                 if (count > log_buf_len)
17450                         count = log_buf_len;
17451 diff -NurpP --minimal linux-2.6.33.1/kernel/ptrace.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/ptrace.c
17452 --- linux-2.6.33.1/kernel/ptrace.c      2009-12-03 20:02:58.000000000 +0100
17453 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/ptrace.c      2010-02-25 12:02:16.000000000 +0100
17454 @@ -22,6 +22,7 @@
17455  #include <linux/pid_namespace.h>
17456  #include <linux/syscalls.h>
17457  #include <linux/uaccess.h>
17458 +#include <linux/vs_context.h>
17459  
17460  
17461  /*
17462 @@ -151,6 +152,11 @@ int __ptrace_may_access(struct task_stru
17463                 dumpable = get_dumpable(task->mm);
17464         if (!dumpable && !capable(CAP_SYS_PTRACE))
17465                 return -EPERM;
17466 +       if (!vx_check(task->xid, VS_ADMIN_P|VS_IDENT))
17467 +               return -EPERM;
17468 +       if (!vx_check(task->xid, VS_IDENT) &&
17469 +               !task_vx_flags(task, VXF_STATE_ADMIN, 0))
17470 +               return -EACCES;
17471  
17472         return security_ptrace_access_check(task, mode);
17473  }
17474 @@ -621,6 +627,10 @@ SYSCALL_DEFINE4(ptrace, long, request, l
17475                 goto out;
17476         }
17477  
17478 +       ret = -EPERM;
17479 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
17480 +               goto out_put_task_struct;
17481 +
17482         if (request == PTRACE_ATTACH) {
17483                 ret = ptrace_attach(child);
17484                 /*
17485 diff -NurpP --minimal linux-2.6.33.1/kernel/sched.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/sched.c
17486 --- linux-2.6.33.1/kernel/sched.c       2010-03-18 16:25:15.000000000 +0100
17487 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/sched.c       2010-03-18 17:24:11.000000000 +0100
17488 @@ -71,6 +71,8 @@
17489  #include <linux/debugfs.h>
17490  #include <linux/ctype.h>
17491  #include <linux/ftrace.h>
17492 +#include <linux/vs_sched.h>
17493 +#include <linux/vs_cvirt.h>
17494  
17495  #include <asm/tlb.h>
17496  #include <asm/irq_regs.h>
17497 @@ -3009,9 +3011,17 @@ EXPORT_SYMBOL(avenrun);
17498   */
17499  void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
17500  {
17501 -       loads[0] = (avenrun[0] + offset) << shift;
17502 -       loads[1] = (avenrun[1] + offset) << shift;
17503 -       loads[2] = (avenrun[2] + offset) << shift;
17504 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
17505 +               struct vx_info *vxi = current_vx_info();
17506 +
17507 +               loads[0] = (vxi->cvirt.load[0] + offset) << shift;
17508 +               loads[1] = (vxi->cvirt.load[1] + offset) << shift;
17509 +               loads[2] = (vxi->cvirt.load[2] + offset) << shift;
17510 +       } else {
17511 +               loads[0] = (avenrun[0] + offset) << shift;
17512 +               loads[1] = (avenrun[1] + offset) << shift;
17513 +               loads[2] = (avenrun[2] + offset) << shift;
17514 +       }
17515  }
17516  
17517  static unsigned long
17518 @@ -5057,16 +5067,19 @@ void account_user_time(struct task_struc
17519                        cputime_t cputime_scaled)
17520  {
17521         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17522 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17523         cputime64_t tmp;
17524 +       int nice = (TASK_NICE(p) > 0);
17525  
17526         /* Add user time to process. */
17527         p->utime = cputime_add(p->utime, cputime);
17528         p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
17529 +       vx_account_user(vxi, cputime, nice);
17530         account_group_user_time(p, cputime);
17531  
17532         /* Add user time to cpustat. */
17533         tmp = cputime_to_cputime64(cputime);
17534 -       if (TASK_NICE(p) > 0)
17535 +       if (nice)
17536                 cpustat->nice = cputime64_add(cpustat->nice, tmp);
17537         else
17538                 cpustat->user = cputime64_add(cpustat->user, tmp);
17539 @@ -5117,6 +5130,7 @@ void account_system_time(struct task_str
17540                          cputime_t cputime, cputime_t cputime_scaled)
17541  {
17542         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17543 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17544         cputime64_t tmp;
17545  
17546         if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
17547 @@ -5127,6 +5141,7 @@ void account_system_time(struct task_str
17548         /* Add system time to process. */
17549         p->stime = cputime_add(p->stime, cputime);
17550         p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
17551 +       vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
17552         account_group_system_time(p, cputime);
17553  
17554         /* Add system time to cpustat. */
17555 @@ -6192,7 +6207,7 @@ SYSCALL_DEFINE1(nice, int, increment)
17556                 nice = 19;
17557  
17558         if (increment < 0 && !can_nice(current, nice))
17559 -               return -EPERM;
17560 +               return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
17561  
17562         retval = security_task_setnice(current, nice);
17563         if (retval)
17564 diff -NurpP --minimal linux-2.6.33.1/kernel/sched_fair.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/sched_fair.c
17565 --- linux-2.6.33.1/kernel/sched_fair.c  2010-02-25 11:52:09.000000000 +0100
17566 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/sched_fair.c  2010-03-18 17:25:17.000000000 +0100
17567 @@ -794,6 +794,9 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
17568         check_spread(cfs_rq, se);
17569         if (se != cfs_rq->curr)
17570                 __enqueue_entity(cfs_rq, se);
17571 +
17572 +       if (entity_is_task(se))
17573 +               vx_activate_task(task_of(se));
17574  }
17575  
17576  static void __clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
17577 @@ -837,6 +840,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
17578  
17579         if (se != cfs_rq->curr)
17580                 __dequeue_entity(cfs_rq, se);
17581 +       if (entity_is_task(se))
17582 +               vx_deactivate_task(task_of(se));
17583         account_entity_dequeue(cfs_rq, se);
17584         update_min_vruntime(cfs_rq);
17585  
17586 diff -NurpP --minimal linux-2.6.33.1/kernel/signal.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/signal.c
17587 --- linux-2.6.33.1/kernel/signal.c      2010-02-25 11:52:09.000000000 +0100
17588 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/signal.c      2010-03-10 20:32:43.000000000 +0100
17589 @@ -28,6 +28,8 @@
17590  #include <linux/freezer.h>
17591  #include <linux/pid_namespace.h>
17592  #include <linux/nsproxy.h>
17593 +#include <linux/vs_context.h>
17594 +#include <linux/vs_pid.h>
17595  #define CREATE_TRACE_POINTS
17596  #include <trace/events/signal.h>
17597  
17598 @@ -629,9 +631,18 @@ static int check_kill_permission(int sig
17599         struct pid *sid;
17600         int error;
17601  
17602 +       vxdprintk(VXD_CBIT(misc, 7),
17603 +               "check_kill_permission(%d,%p,%p[#%u,%u])",
17604 +               sig, info, t, vx_task_xid(t), t->pid);
17605 +
17606         if (!valid_signal(sig))
17607                 return -EINVAL;
17608  
17609 +/*     FIXME: needed? if so, why?
17610 +       if ((info != SEND_SIG_NOINFO) &&
17611 +               (is_si_special(info) || !si_fromuser(info)))
17612 +               goto skip;      */
17613 +
17614         if (!si_fromuser(info))
17615                 return 0;
17616  
17617 @@ -659,6 +670,20 @@ static int check_kill_permission(int sig
17618                 }
17619         }
17620  
17621 +       error = -EPERM;
17622 +       if (t->pid == 1 && current->xid)
17623 +               return error;
17624 +
17625 +       error = -ESRCH;
17626 +       /* FIXME: we shouldn't return ESRCH ever, to avoid
17627 +                 loops, maybe ENOENT or EACCES? */
17628 +       if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17629 +               vxdprintk(current->xid || VXD_CBIT(misc, 7),
17630 +                       "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17631 +                       sig, info, t, vx_task_xid(t), t->pid, current->xid);
17632 +               return error;
17633 +       }
17634 +/* skip: */
17635         return security_task_kill(t, info, sig, 0);
17636  }
17637  
17638 @@ -1147,7 +1172,7 @@ int kill_pid_info(int sig, struct siginf
17639         rcu_read_lock();
17640  retry:
17641         p = pid_task(pid, PIDTYPE_PID);
17642 -       if (p) {
17643 +       if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17644                 error = group_send_sig_info(sig, info, p);
17645                 if (unlikely(error == -ESRCH))
17646                         /*
17647 @@ -1187,7 +1212,7 @@ int kill_pid_info_as_uid(int sig, struct
17648  
17649         rcu_read_lock();
17650         p = pid_task(pid, PIDTYPE_PID);
17651 -       if (!p) {
17652 +       if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17653                 ret = -ESRCH;
17654                 goto out_unlock;
17655         }
17656 @@ -1242,8 +1267,10 @@ static int kill_something_info(int sig, 
17657                 struct task_struct * p;
17658  
17659                 for_each_process(p) {
17660 -                       if (task_pid_vnr(p) > 1 &&
17661 -                                       !same_thread_group(p, current)) {
17662 +                       if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17663 +                               task_pid_vnr(p) > 1 &&
17664 +                               !same_thread_group(p, current) &&
17665 +                               !vx_current_initpid(p->pid)) {
17666                                 int err = group_send_sig_info(sig, info, p);
17667                                 ++count;
17668                                 if (err != -EPERM)
17669 @@ -1910,6 +1937,11 @@ relock:
17670                                 !sig_kernel_only(signr))
17671                         continue;
17672  
17673 +               /* virtual init is protected against user signals */
17674 +               if ((info->si_code == SI_USER) &&
17675 +                       vx_current_initpid(current->pid))
17676 +                       continue;
17677 +
17678                 if (sig_kernel_stop(signr)) {
17679                         /*
17680                          * The default action is to stop all threads in
17681 diff -NurpP --minimal linux-2.6.33.1/kernel/softirq.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/softirq.c
17682 --- linux-2.6.33.1/kernel/softirq.c     2010-02-25 11:52:09.000000000 +0100
17683 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/softirq.c     2010-02-25 12:02:16.000000000 +0100
17684 @@ -24,6 +24,7 @@
17685  #include <linux/ftrace.h>
17686  #include <linux/smp.h>
17687  #include <linux/tick.h>
17688 +#include <linux/vs_context.h>
17689  
17690  #define CREATE_TRACE_POINTS
17691  #include <trace/events/irq.h>
17692 diff -NurpP --minimal linux-2.6.33.1/kernel/sys.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/sys.c
17693 --- linux-2.6.33.1/kernel/sys.c 2010-02-25 11:52:09.000000000 +0100
17694 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/sys.c 2010-02-25 13:13:03.000000000 +0100
17695 @@ -40,6 +40,7 @@
17696  #include <linux/syscalls.h>
17697  #include <linux/kprobes.h>
17698  #include <linux/user_namespace.h>
17699 +#include <linux/vs_pid.h>
17700  
17701  #include <asm/uaccess.h>
17702  #include <asm/io.h>
17703 @@ -129,7 +130,10 @@ static int set_one_prio(struct task_stru
17704                 goto out;
17705         }
17706         if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17707 -               error = -EACCES;
17708 +               if (vx_flags(VXF_IGNEG_NICE, 0))
17709 +                       error = 0;
17710 +               else
17711 +                       error = -EACCES;
17712                 goto out;
17713         }
17714         no_nice = security_task_setnice(p, niceval);
17715 @@ -179,6 +183,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17716                         else
17717                                 pgrp = task_pgrp(current);
17718                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17719 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17720 +                                       continue;
17721                                 error = set_one_prio(p, niceval, error);
17722                         } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17723                         break;
17724 @@ -242,6 +248,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17725                         else
17726                                 pgrp = task_pgrp(current);
17727                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17728 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17729 +                                       continue;
17730                                 niceval = 20 - task_nice(p);
17731                                 if (niceval > retval)
17732                                         retval = niceval;
17733 @@ -355,6 +363,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
17734  
17735  static DEFINE_MUTEX(reboot_mutex);
17736  
17737 +long vs_reboot(unsigned int, void __user *);
17738 +
17739  /*
17740   * Reboot system call: for obvious reasons only root may call it,
17741   * and even root needs to set up some magic numbers in the registers
17742 @@ -387,6 +397,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17743         if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17744                 cmd = LINUX_REBOOT_CMD_HALT;
17745  
17746 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
17747 +               return vs_reboot(cmd, arg);
17748 +
17749         mutex_lock(&reboot_mutex);
17750         switch (cmd) {
17751         case LINUX_REBOOT_CMD_RESTART:
17752 @@ -1136,7 +1149,7 @@ SYSCALL_DEFINE2(sethostname, char __user
17753         int errno;
17754         char tmp[__NEW_UTS_LEN];
17755  
17756 -       if (!capable(CAP_SYS_ADMIN))
17757 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17758                 return -EPERM;
17759         if (len < 0 || len > __NEW_UTS_LEN)
17760                 return -EINVAL;
17761 @@ -1185,7 +1198,7 @@ SYSCALL_DEFINE2(setdomainname, char __us
17762         int errno;
17763         char tmp[__NEW_UTS_LEN];
17764  
17765 -       if (!capable(CAP_SYS_ADMIN))
17766 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17767                 return -EPERM;
17768         if (len < 0 || len > __NEW_UTS_LEN)
17769                 return -EINVAL;
17770 @@ -1254,7 +1267,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
17771                 return -EINVAL;
17772         old_rlim = current->signal->rlim + resource;
17773         if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
17774 -           !capable(CAP_SYS_RESOURCE))
17775 +           !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17776                 return -EPERM;
17777         if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
17778                 return -EPERM;
17779 diff -NurpP --minimal linux-2.6.33.1/kernel/sysctl_binary.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/sysctl_binary.c
17780 --- linux-2.6.33.1/kernel/sysctl_binary.c       2010-02-25 11:52:09.000000000 +0100
17781 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/sysctl_binary.c       2010-02-25 12:40:06.000000000 +0100
17782 @@ -71,6 +71,7 @@ static const struct bin_table bin_kern_t
17783  
17784         { CTL_INT,      KERN_PANIC,                     "panic" },
17785         { CTL_INT,      KERN_REALROOTDEV,               "real-root-dev" },
17786 +       { CTL_STR,      KERN_VSHELPER,                  "vshelper" },
17787  
17788         { CTL_STR,      KERN_SPARC_REBOOT,              "reboot-cmd" },
17789         { CTL_INT,      KERN_CTLALTDEL,                 "ctrl-alt-del" },
17790 diff -NurpP --minimal linux-2.6.33.1/kernel/sysctl.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/sysctl.c
17791 --- linux-2.6.33.1/kernel/sysctl.c      2010-02-25 11:52:09.000000000 +0100
17792 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/sysctl.c      2010-02-25 14:43:48.000000000 +0100
17793 @@ -123,6 +123,7 @@ static int ngroups_max = NGROUPS_MAX;
17794  extern char modprobe_path[];
17795  extern int modules_disabled;
17796  #endif
17797 +extern char vshelper_path[];
17798  #ifdef CONFIG_CHR_DEV_SG
17799  extern int sg_big_buff;
17800  #endif
17801 @@ -553,6 +554,13 @@ static struct ctl_table kern_table[] = {
17802                 .proc_handler   = proc_dostring,
17803         },
17804  #endif
17805 +       {
17806 +               .procname       = "vshelper",
17807 +               .data           = &vshelper_path,
17808 +               .maxlen         = 256,
17809 +               .mode           = 0644,
17810 +               .proc_handler   = &proc_dostring,
17811 +       },
17812  #ifdef CONFIG_CHR_DEV_SG
17813         {
17814                 .procname       = "sg-big-buff",
17815 diff -NurpP --minimal linux-2.6.33.1/kernel/time.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/time.c
17816 --- linux-2.6.33.1/kernel/time.c        2010-02-25 11:52:09.000000000 +0100
17817 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/time.c        2010-02-25 12:02:16.000000000 +0100
17818 @@ -63,6 +63,7 @@ EXPORT_SYMBOL(sys_tz);
17819  SYSCALL_DEFINE1(time, time_t __user *, tloc)
17820  {
17821         time_t i = get_seconds();
17822 +/*     FIXME: do_gettimeofday(&tv) -> vx_gettimeofday(&tv) */
17823  
17824         if (tloc) {
17825                 if (put_user(i,tloc))
17826 @@ -93,7 +94,7 @@ SYSCALL_DEFINE1(stime, time_t __user *, 
17827         if (err)
17828                 return err;
17829  
17830 -       do_settimeofday(&tv);
17831 +       vx_settimeofday(&tv);
17832         return 0;
17833  }
17834  
17835 @@ -104,7 +105,7 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
17836  {
17837         if (likely(tv != NULL)) {
17838                 struct timeval ktv;
17839 -               do_gettimeofday(&ktv);
17840 +               vx_gettimeofday(&ktv);
17841                 if (copy_to_user(tv, &ktv, sizeof(ktv)))
17842                         return -EFAULT;
17843         }
17844 @@ -179,7 +180,7 @@ int do_sys_settimeofday(struct timespec 
17845                 /* SMP safe, again the code in arch/foo/time.c should
17846                  * globally block out interrupts when it runs.
17847                  */
17848 -               return do_settimeofday(tv);
17849 +               return vx_settimeofday(tv);
17850         }
17851         return 0;
17852  }
17853 @@ -311,7 +312,7 @@ void getnstimeofday(struct timespec *tv)
17854  {
17855         struct timeval x;
17856  
17857 -       do_gettimeofday(&x);
17858 +       vx_gettimeofday(&x);
17859         tv->tv_sec = x.tv_sec;
17860         tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
17861  }
17862 diff -NurpP --minimal linux-2.6.33.1/kernel/timer.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/timer.c
17863 --- linux-2.6.33.1/kernel/timer.c       2010-02-25 11:52:09.000000000 +0100
17864 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/timer.c       2010-02-25 12:02:16.000000000 +0100
17865 @@ -39,6 +39,10 @@
17866  #include <linux/kallsyms.h>
17867  #include <linux/perf_event.h>
17868  #include <linux/sched.h>
17869 +#include <linux/vs_base.h>
17870 +#include <linux/vs_cvirt.h>
17871 +#include <linux/vs_pid.h>
17872 +#include <linux/vserver/sched.h>
17873  
17874  #include <asm/uaccess.h>
17875  #include <asm/unistd.h>
17876 @@ -1252,12 +1256,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17877  
17878  #endif
17879  
17880 -#ifndef __alpha__
17881 -
17882 -/*
17883 - * The Alpha uses getxpid, getxuid, and getxgid instead.  Maybe this
17884 - * should be moved into arch/i386 instead?
17885 - */
17886  
17887  /**
17888   * sys_getpid - return the thread group id of the current process
17889 @@ -1286,10 +1284,23 @@ SYSCALL_DEFINE0(getppid)
17890         rcu_read_lock();
17891         pid = task_tgid_vnr(current->real_parent);
17892         rcu_read_unlock();
17893 +       return vx_map_pid(pid);
17894 +}
17895  
17896 -       return pid;
17897 +#ifdef __alpha__
17898 +
17899 +/*
17900 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17901 + */
17902 +
17903 +asmlinkage long do_getxpid(long *ppid)
17904 +{
17905 +       *ppid = sys_getppid();
17906 +       return sys_getpid();
17907  }
17908  
17909 +#else /* _alpha_ */
17910 +
17911  SYSCALL_DEFINE0(getuid)
17912  {
17913         /* Only we change this so SMP safe */
17914 diff -NurpP --minimal linux-2.6.33.1/kernel/user.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/user.c
17915 --- linux-2.6.33.1/kernel/user.c        2009-12-03 20:02:58.000000000 +0100
17916 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/user.c        2010-02-25 12:02:16.000000000 +0100
17917 @@ -251,10 +251,10 @@ static struct kobj_type uids_ktype = {
17918   *
17919   * See Documentation/scheduler/sched-design-CFS.txt for ramifications.
17920   */
17921 -static int uids_user_create(struct user_struct *up)
17922 +static int uids_user_create(struct user_namespace *ns, struct user_struct *up)
17923  {
17924         struct kobject *kobj = &up->kobj;
17925 -       int error;
17926 +       int error = 0;
17927  
17928         memset(kobj, 0, sizeof(struct kobject));
17929         if (up->user_ns != &init_user_ns)
17930 @@ -282,7 +282,7 @@ int __init uids_sysfs_init(void)
17931         if (!uids_kset)
17932                 return -ENOMEM;
17933  
17934 -       return uids_user_create(&root_user);
17935 +       return uids_user_create(NULL, &root_user);
17936  }
17937  
17938  /* delayed work function to remove sysfs directory for a user and free up
17939 @@ -353,7 +353,8 @@ static struct user_struct *uid_hash_find
17940  }
17941  
17942  int uids_sysfs_init(void) { return 0; }
17943 -static inline int uids_user_create(struct user_struct *up) { return 0; }
17944 +static inline int uids_user_create(struct user_namespace *ns,
17945 +       struct user_struct *up) { return 0; }
17946  static inline void uids_mutex_lock(void) { }
17947  static inline void uids_mutex_unlock(void) { }
17948  
17949 @@ -450,7 +451,7 @@ struct user_struct *alloc_uid(struct use
17950  
17951                 new->user_ns = get_user_ns(ns);
17952  
17953 -               if (uids_user_create(new))
17954 +               if (uids_user_create(ns, new))
17955                         goto out_destoy_sched;
17956  
17957                 /*
17958 diff -NurpP --minimal linux-2.6.33.1/kernel/user_namespace.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/user_namespace.c
17959 --- linux-2.6.33.1/kernel/user_namespace.c      2009-03-24 14:22:45.000000000 +0100
17960 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/user_namespace.c      2010-02-25 12:02:16.000000000 +0100
17961 @@ -10,6 +10,7 @@
17962  #include <linux/slab.h>
17963  #include <linux/user_namespace.h>
17964  #include <linux/cred.h>
17965 +#include <linux/vserver/global.h>
17966  
17967  /*
17968   * Create a new user namespace, deriving the creator from the user in the
17969 @@ -30,6 +31,7 @@ int create_user_ns(struct cred *new)
17970                 return -ENOMEM;
17971  
17972         kref_init(&ns->kref);
17973 +       atomic_inc(&vs_global_user_ns);
17974  
17975         for (n = 0; n < UIDHASH_SZ; ++n)
17976                 INIT_HLIST_HEAD(ns->uidhash_table + n);
17977 @@ -78,6 +80,8 @@ void free_user_ns(struct kref *kref)
17978         struct user_namespace *ns =
17979                 container_of(kref, struct user_namespace, kref);
17980  
17981 +       /* FIXME: maybe move into destroyer? */
17982 +       atomic_dec(&vs_global_user_ns);
17983         INIT_WORK(&ns->destroyer, free_user_ns_work);
17984         schedule_work(&ns->destroyer);
17985  }
17986 diff -NurpP --minimal linux-2.6.33.1/kernel/utsname.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/utsname.c
17987 --- linux-2.6.33.1/kernel/utsname.c     2009-09-10 15:26:28.000000000 +0200
17988 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/utsname.c     2010-02-25 12:02:16.000000000 +0100
17989 @@ -14,14 +14,17 @@
17990  #include <linux/utsname.h>
17991  #include <linux/err.h>
17992  #include <linux/slab.h>
17993 +#include <linux/vserver/global.h>
17994  
17995  static struct uts_namespace *create_uts_ns(void)
17996  {
17997         struct uts_namespace *uts_ns;
17998  
17999         uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
18000 -       if (uts_ns)
18001 +       if (uts_ns) {
18002                 kref_init(&uts_ns->kref);
18003 +               atomic_inc(&vs_global_uts_ns);
18004 +       }
18005         return uts_ns;
18006  }
18007  
18008 @@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
18009         struct uts_namespace *ns;
18010  
18011         ns = container_of(kref, struct uts_namespace, kref);
18012 +       atomic_dec(&vs_global_uts_ns);
18013         kfree(ns);
18014  }
18015 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/cacct.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cacct.c
18016 --- linux-2.6.33.1/kernel/vserver/cacct.c       1970-01-01 01:00:00.000000000 +0100
18017 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cacct.c       2010-02-25 12:02:16.000000000 +0100
18018 @@ -0,0 +1,42 @@
18019 +/*
18020 + *  linux/kernel/vserver/cacct.c
18021 + *
18022 + *  Virtual Server: Context Accounting
18023 + *
18024 + *  Copyright (C) 2006-2007 Herbert Pötzl
18025 + *
18026 + *  V0.01  added accounting stats
18027 + *
18028 + */
18029 +
18030 +#include <linux/types.h>
18031 +#include <linux/vs_context.h>
18032 +#include <linux/vserver/cacct_cmd.h>
18033 +#include <linux/vserver/cacct_int.h>
18034 +
18035 +#include <asm/errno.h>
18036 +#include <asm/uaccess.h>
18037 +
18038 +
18039 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
18040 +{
18041 +       struct vcmd_sock_stat_v0 vc_data;
18042 +       int j, field;
18043 +
18044 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18045 +               return -EFAULT;
18046 +
18047 +       field = vc_data.field;
18048 +       if ((field < 0) || (field >= VXA_SOCK_SIZE))
18049 +               return -EINVAL;
18050 +
18051 +       for (j = 0; j < 3; j++) {
18052 +               vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
18053 +               vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
18054 +       }
18055 +
18056 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18057 +               return -EFAULT;
18058 +       return 0;
18059 +}
18060 +
18061 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/cacct_init.h linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cacct_init.h
18062 --- linux-2.6.33.1/kernel/vserver/cacct_init.h  1970-01-01 01:00:00.000000000 +0100
18063 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cacct_init.h  2010-02-25 12:02:16.000000000 +0100
18064 @@ -0,0 +1,25 @@
18065 +
18066 +
18067 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
18068 +{
18069 +       int i, j;
18070 +
18071 +
18072 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
18073 +               for (j = 0; j < 3; j++) {
18074 +                       atomic_long_set(&cacct->sock[i][j].count, 0);
18075 +                       atomic_long_set(&cacct->sock[i][j].total, 0);
18076 +               }
18077 +       }
18078 +       for (i = 0; i < 8; i++)
18079 +               atomic_set(&cacct->slab[i], 0);
18080 +       for (i = 0; i < 5; i++)
18081 +               for (j = 0; j < 4; j++)
18082 +                       atomic_set(&cacct->page[i][j], 0);
18083 +}
18084 +
18085 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
18086 +{
18087 +       return;
18088 +}
18089 +
18090 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/cacct_proc.h linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cacct_proc.h
18091 --- linux-2.6.33.1/kernel/vserver/cacct_proc.h  1970-01-01 01:00:00.000000000 +0100
18092 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cacct_proc.h  2010-02-25 12:02:16.000000000 +0100
18093 @@ -0,0 +1,53 @@
18094 +#ifndef _VX_CACCT_PROC_H
18095 +#define _VX_CACCT_PROC_H
18096 +
18097 +#include <linux/vserver/cacct_int.h>
18098 +
18099 +
18100 +#define VX_SOCKA_TOP   \
18101 +       "Type\t    recv #/bytes\t\t   send #/bytes\t\t    fail #/bytes\n"
18102 +
18103 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
18104 +{
18105 +       int i, j, length = 0;
18106 +       static char *type[VXA_SOCK_SIZE] = {
18107 +               "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
18108 +       };
18109 +
18110 +       length += sprintf(buffer + length, VX_SOCKA_TOP);
18111 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
18112 +               length += sprintf(buffer + length, "%s:", type[i]);
18113 +               for (j = 0; j < 3; j++) {
18114 +                       length += sprintf(buffer + length,
18115 +                               "\t%10lu/%-10lu",
18116 +                               vx_sock_count(cacct, i, j),
18117 +                               vx_sock_total(cacct, i, j));
18118 +               }
18119 +               buffer[length++] = '\n';
18120 +       }
18121 +
18122 +       length += sprintf(buffer + length, "\n");
18123 +       length += sprintf(buffer + length,
18124 +               "slab:\t %8u %8u %8u %8u\n",
18125 +               atomic_read(&cacct->slab[1]),
18126 +               atomic_read(&cacct->slab[4]),
18127 +               atomic_read(&cacct->slab[0]),
18128 +               atomic_read(&cacct->slab[2]));
18129 +
18130 +       length += sprintf(buffer + length, "\n");
18131 +       for (i = 0; i < 5; i++) {
18132 +               length += sprintf(buffer + length,
18133 +                       "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
18134 +                       atomic_read(&cacct->page[i][0]),
18135 +                       atomic_read(&cacct->page[i][1]),
18136 +                       atomic_read(&cacct->page[i][2]),
18137 +                       atomic_read(&cacct->page[i][3]),
18138 +                       atomic_read(&cacct->page[i][4]),
18139 +                       atomic_read(&cacct->page[i][5]),
18140 +                       atomic_read(&cacct->page[i][6]),
18141 +                       atomic_read(&cacct->page[i][7]));
18142 +       }
18143 +       return length;
18144 +}
18145 +
18146 +#endif /* _VX_CACCT_PROC_H */
18147 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/context.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/context.c
18148 --- linux-2.6.33.1/kernel/vserver/context.c     1970-01-01 01:00:00.000000000 +0100
18149 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/context.c     2010-03-10 20:35:53.000000000 +0100
18150 @@ -0,0 +1,1058 @@
18151 +/*
18152 + *  linux/kernel/vserver/context.c
18153 + *
18154 + *  Virtual Server: Context Support
18155 + *
18156 + *  Copyright (C) 2003-2007  Herbert Pötzl
18157 + *
18158 + *  V0.01  context helper
18159 + *  V0.02  vx_ctx_kill syscall command
18160 + *  V0.03  replaced context_info calls
18161 + *  V0.04  redesign of struct (de)alloc
18162 + *  V0.05  rlimit basic implementation
18163 + *  V0.06  task_xid and info commands
18164 + *  V0.07  context flags and caps
18165 + *  V0.08  switch to RCU based hash
18166 + *  V0.09  revert to non RCU for now
18167 + *  V0.10  and back to working RCU hash
18168 + *  V0.11  and back to locking again
18169 + *  V0.12  referenced context store
18170 + *  V0.13  separate per cpu data
18171 + *  V0.14  changed vcmds to vxi arg
18172 + *  V0.15  added context stat
18173 + *  V0.16  have __create claim() the vxi
18174 + *  V0.17  removed older and legacy stuff
18175 + *
18176 + */
18177 +
18178 +#include <linux/slab.h>
18179 +#include <linux/types.h>
18180 +#include <linux/security.h>
18181 +#include <linux/pid_namespace.h>
18182 +
18183 +#include <linux/vserver/context.h>
18184 +#include <linux/vserver/network.h>
18185 +#include <linux/vserver/debug.h>
18186 +#include <linux/vserver/limit.h>
18187 +#include <linux/vserver/limit_int.h>
18188 +#include <linux/vserver/space.h>
18189 +#include <linux/init_task.h>
18190 +#include <linux/fs_struct.h>
18191 +
18192 +#include <linux/vs_context.h>
18193 +#include <linux/vs_limit.h>
18194 +#include <linux/vs_pid.h>
18195 +#include <linux/vserver/context_cmd.h>
18196 +
18197 +#include "cvirt_init.h"
18198 +#include "cacct_init.h"
18199 +#include "limit_init.h"
18200 +#include "sched_init.h"
18201 +
18202 +
18203 +atomic_t vx_global_ctotal      = ATOMIC_INIT(0);
18204 +atomic_t vx_global_cactive     = ATOMIC_INIT(0);
18205 +
18206 +
18207 +/*     now inactive context structures */
18208 +
18209 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
18210 +
18211 +static spinlock_t vx_info_inactive_lock = SPIN_LOCK_UNLOCKED;
18212 +
18213 +
18214 +/*     __alloc_vx_info()
18215 +
18216 +       * allocate an initialized vx_info struct
18217 +       * doesn't make it visible (hash)                        */
18218 +
18219 +static struct vx_info *__alloc_vx_info(xid_t xid)
18220 +{
18221 +       struct vx_info *new = NULL;
18222 +       int cpu, index;
18223 +
18224 +       vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
18225 +
18226 +       /* would this benefit from a slab cache? */
18227 +       new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
18228 +       if (!new)
18229 +               return 0;
18230 +
18231 +       memset(new, 0, sizeof(struct vx_info));
18232 +#ifdef CONFIG_SMP
18233 +       new->ptr_pc = alloc_percpu(struct _vx_info_pc);
18234 +       if (!new->ptr_pc)
18235 +               goto error;
18236 +#endif
18237 +       new->vx_id = xid;
18238 +       INIT_HLIST_NODE(&new->vx_hlist);
18239 +       atomic_set(&new->vx_usecnt, 0);
18240 +       atomic_set(&new->vx_tasks, 0);
18241 +       new->vx_parent = NULL;
18242 +       new->vx_state = 0;
18243 +       init_waitqueue_head(&new->vx_wait);
18244 +
18245 +       /* prepare reaper */
18246 +       get_task_struct(init_pid_ns.child_reaper);
18247 +       new->vx_reaper = init_pid_ns.child_reaper;
18248 +       new->vx_badness_bias = 0;
18249 +
18250 +       /* rest of init goes here */
18251 +       vx_info_init_limit(&new->limit);
18252 +       vx_info_init_sched(&new->sched);
18253 +       vx_info_init_cvirt(&new->cvirt);
18254 +       vx_info_init_cacct(&new->cacct);
18255 +
18256 +       /* per cpu data structures */
18257 +       for_each_possible_cpu(cpu) {
18258 +               vx_info_init_sched_pc(
18259 +                       &vx_per_cpu(new, sched_pc, cpu), cpu);
18260 +               vx_info_init_cvirt_pc(
18261 +                       &vx_per_cpu(new, cvirt_pc, cpu), cpu);
18262 +       }
18263 +
18264 +       new->vx_flags = VXF_INIT_SET;
18265 +       cap_set_init_eff(new->vx_bcaps);
18266 +       new->vx_ccaps = 0;
18267 +       new->vx_umask = 0;
18268 +
18269 +       new->reboot_cmd = 0;
18270 +       new->exit_code = 0;
18271 +
18272 +       // preconfig fs entries
18273 +       for (index = 0; index < VX_SPACES; index++) {
18274 +               write_lock(&init_fs.lock);
18275 +               init_fs.users++;
18276 +               write_unlock(&init_fs.lock);
18277 +               new->vx_fs[index] = &init_fs;
18278 +       }
18279 +
18280 +       vxdprintk(VXD_CBIT(xid, 0),
18281 +               "alloc_vx_info(%d) = %p", xid, new);
18282 +       vxh_alloc_vx_info(new);
18283 +       atomic_inc(&vx_global_ctotal);
18284 +       return new;
18285 +#ifdef CONFIG_SMP
18286 +error:
18287 +       kfree(new);
18288 +       return 0;
18289 +#endif
18290 +}
18291 +
18292 +/*     __dealloc_vx_info()
18293 +
18294 +       * final disposal of vx_info                             */
18295 +
18296 +static void __dealloc_vx_info(struct vx_info *vxi)
18297 +{
18298 +#ifdef CONFIG_VSERVER_WARN
18299 +       struct vx_info_save vxis;
18300 +       int cpu;
18301 +#endif
18302 +       vxdprintk(VXD_CBIT(xid, 0),
18303 +               "dealloc_vx_info(%p)", vxi);
18304 +       vxh_dealloc_vx_info(vxi);
18305 +
18306 +#ifdef CONFIG_VSERVER_WARN
18307 +       enter_vx_info(vxi, &vxis);
18308 +       vx_info_exit_limit(&vxi->limit);
18309 +       vx_info_exit_sched(&vxi->sched);
18310 +       vx_info_exit_cvirt(&vxi->cvirt);
18311 +       vx_info_exit_cacct(&vxi->cacct);
18312 +
18313 +       for_each_possible_cpu(cpu) {
18314 +               vx_info_exit_sched_pc(
18315 +                       &vx_per_cpu(vxi, sched_pc, cpu), cpu);
18316 +               vx_info_exit_cvirt_pc(
18317 +                       &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
18318 +       }
18319 +       leave_vx_info(&vxis);
18320 +#endif
18321 +
18322 +       vxi->vx_id = -1;
18323 +       vxi->vx_state |= VXS_RELEASED;
18324 +
18325 +#ifdef CONFIG_SMP
18326 +       free_percpu(vxi->ptr_pc);
18327 +#endif
18328 +       kfree(vxi);
18329 +       atomic_dec(&vx_global_ctotal);
18330 +}
18331 +
18332 +static void __shutdown_vx_info(struct vx_info *vxi)
18333 +{
18334 +       struct nsproxy *nsproxy;
18335 +       struct fs_struct *fs;
18336 +       int index, kill;
18337 +
18338 +       might_sleep();
18339 +
18340 +       vxi->vx_state |= VXS_SHUTDOWN;
18341 +       vs_state_change(vxi, VSC_SHUTDOWN);
18342 +
18343 +       for (index = 0; index < VX_SPACES; index++) {
18344 +               nsproxy = xchg(&vxi->vx_nsproxy[index], NULL);
18345 +               if (nsproxy)
18346 +                       put_nsproxy(nsproxy);
18347 +
18348 +               fs = xchg(&vxi->vx_fs[index], NULL);
18349 +               write_lock(&fs->lock);
18350 +               kill = !--fs->users;
18351 +               write_unlock(&fs->lock);
18352 +               if (kill)
18353 +                       free_fs_struct(fs);
18354 +       }
18355 +}
18356 +
18357 +/* exported stuff */
18358 +
18359 +void free_vx_info(struct vx_info *vxi)
18360 +{
18361 +       unsigned long flags;
18362 +       unsigned index;
18363 +
18364 +       /* check for reference counts first */
18365 +       BUG_ON(atomic_read(&vxi->vx_usecnt));
18366 +       BUG_ON(atomic_read(&vxi->vx_tasks));
18367 +
18368 +       /* context must not be hashed */
18369 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
18370 +
18371 +       /* context shutdown is mandatory */
18372 +       BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
18373 +
18374 +       /* nsproxy and fs check */
18375 +       for (index = 0; index < VX_SPACES; index++) {
18376 +               BUG_ON(vxi->vx_nsproxy[index]);
18377 +               BUG_ON(vxi->vx_fs[index]);
18378 +       }
18379 +
18380 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
18381 +       hlist_del(&vxi->vx_hlist);
18382 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18383 +
18384 +       __dealloc_vx_info(vxi);
18385 +}
18386 +
18387 +
18388 +/*     hash table for vx_info hash */
18389 +
18390 +#define VX_HASH_SIZE   13
18391 +
18392 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
18393 +       { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
18394 +
18395 +static spinlock_t vx_info_hash_lock = SPIN_LOCK_UNLOCKED;
18396 +
18397 +
18398 +static inline unsigned int __hashval(xid_t xid)
18399 +{
18400 +       return (xid % VX_HASH_SIZE);
18401 +}
18402 +
18403 +
18404 +
18405 +/*     __hash_vx_info()
18406 +
18407 +       * add the vxi to the global hash table
18408 +       * requires the hash_lock to be held                     */
18409 +
18410 +static inline void __hash_vx_info(struct vx_info *vxi)
18411 +{
18412 +       struct hlist_head *head;
18413 +
18414 +       vxd_assert_lock(&vx_info_hash_lock);
18415 +       vxdprintk(VXD_CBIT(xid, 4),
18416 +               "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
18417 +       vxh_hash_vx_info(vxi);
18418 +
18419 +       /* context must not be hashed */
18420 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
18421 +
18422 +       vxi->vx_state |= VXS_HASHED;
18423 +       head = &vx_info_hash[__hashval(vxi->vx_id)];
18424 +       hlist_add_head(&vxi->vx_hlist, head);
18425 +       atomic_inc(&vx_global_cactive);
18426 +}
18427 +
18428 +/*     __unhash_vx_info()
18429 +
18430 +       * remove the vxi from the global hash table
18431 +       * requires the hash_lock to be held                     */
18432 +
18433 +static inline void __unhash_vx_info(struct vx_info *vxi)
18434 +{
18435 +       unsigned long flags;
18436 +
18437 +       vxd_assert_lock(&vx_info_hash_lock);
18438 +       vxdprintk(VXD_CBIT(xid, 4),
18439 +               "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
18440 +               atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
18441 +       vxh_unhash_vx_info(vxi);
18442 +
18443 +       /* context must be hashed */
18444 +       BUG_ON(!vx_info_state(vxi, VXS_HASHED));
18445 +       /* but without tasks */
18446 +       BUG_ON(atomic_read(&vxi->vx_tasks));
18447 +
18448 +       vxi->vx_state &= ~VXS_HASHED;
18449 +       hlist_del_init(&vxi->vx_hlist);
18450 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
18451 +       hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
18452 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18453 +       atomic_dec(&vx_global_cactive);
18454 +}
18455 +
18456 +
18457 +/*     __lookup_vx_info()
18458 +
18459 +       * requires the hash_lock to be held
18460 +       * doesn't increment the vx_refcnt                       */
18461 +
18462 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
18463 +{
18464 +       struct hlist_head *head = &vx_info_hash[__hashval(xid)];
18465 +       struct hlist_node *pos;
18466 +       struct vx_info *vxi;
18467 +
18468 +       vxd_assert_lock(&vx_info_hash_lock);
18469 +       hlist_for_each(pos, head) {
18470 +               vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18471 +
18472 +               if (vxi->vx_id == xid)
18473 +                       goto found;
18474 +       }
18475 +       vxi = NULL;
18476 +found:
18477 +       vxdprintk(VXD_CBIT(xid, 0),
18478 +               "__lookup_vx_info(#%u): %p[#%u]",
18479 +               xid, vxi, vxi ? vxi->vx_id : 0);
18480 +       vxh_lookup_vx_info(vxi, xid);
18481 +       return vxi;
18482 +}
18483 +
18484 +
18485 +/*     __create_vx_info()
18486 +
18487 +       * create the requested context
18488 +       * get(), claim() and hash it                            */
18489 +
18490 +static struct vx_info *__create_vx_info(int id)
18491 +{
18492 +       struct vx_info *new, *vxi = NULL;
18493 +
18494 +       vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
18495 +
18496 +       if (!(new = __alloc_vx_info(id)))
18497 +               return ERR_PTR(-ENOMEM);
18498 +
18499 +       /* required to make dynamic xids unique */
18500 +       spin_lock(&vx_info_hash_lock);
18501 +
18502 +       /* static context requested */
18503 +       if ((vxi = __lookup_vx_info(id))) {
18504 +               vxdprintk(VXD_CBIT(xid, 0),
18505 +                       "create_vx_info(%d) = %p (already there)", id, vxi);
18506 +               if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18507 +                       vxi = ERR_PTR(-EBUSY);
18508 +               else
18509 +                       vxi = ERR_PTR(-EEXIST);
18510 +               goto out_unlock;
18511 +       }
18512 +       /* new context */
18513 +       vxdprintk(VXD_CBIT(xid, 0),
18514 +               "create_vx_info(%d) = %p (new)", id, new);
18515 +       claim_vx_info(new, NULL);
18516 +       __hash_vx_info(get_vx_info(new));
18517 +       vxi = new, new = NULL;
18518 +
18519 +out_unlock:
18520 +       spin_unlock(&vx_info_hash_lock);
18521 +       vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18522 +       if (new)
18523 +               __dealloc_vx_info(new);
18524 +       return vxi;
18525 +}
18526 +
18527 +
18528 +/*     exported stuff                                          */
18529 +
18530 +
18531 +void unhash_vx_info(struct vx_info *vxi)
18532 +{
18533 +       __shutdown_vx_info(vxi);
18534 +       spin_lock(&vx_info_hash_lock);
18535 +       __unhash_vx_info(vxi);
18536 +       spin_unlock(&vx_info_hash_lock);
18537 +       __wakeup_vx_info(vxi);
18538 +}
18539 +
18540 +
18541 +/*     lookup_vx_info()
18542 +
18543 +       * search for a vx_info and get() it
18544 +       * negative id means current                             */
18545 +
18546 +struct vx_info *lookup_vx_info(int id)
18547 +{
18548 +       struct vx_info *vxi = NULL;
18549 +
18550 +       if (id < 0) {
18551 +               vxi = get_vx_info(current_vx_info());
18552 +       } else if (id > 1) {
18553 +               spin_lock(&vx_info_hash_lock);
18554 +               vxi = get_vx_info(__lookup_vx_info(id));
18555 +               spin_unlock(&vx_info_hash_lock);
18556 +       }
18557 +       return vxi;
18558 +}
18559 +
18560 +/*     xid_is_hashed()
18561 +
18562 +       * verify that xid is still hashed                       */
18563 +
18564 +int xid_is_hashed(xid_t xid)
18565 +{
18566 +       int hashed;
18567 +
18568 +       spin_lock(&vx_info_hash_lock);
18569 +       hashed = (__lookup_vx_info(xid) != NULL);
18570 +       spin_unlock(&vx_info_hash_lock);
18571 +       return hashed;
18572 +}
18573 +
18574 +#ifdef CONFIG_PROC_FS
18575 +
18576 +/*     get_xid_list()
18577 +
18578 +       * get a subset of hashed xids for proc
18579 +       * assumes size is at least one                          */
18580 +
18581 +int get_xid_list(int index, unsigned int *xids, int size)
18582 +{
18583 +       int hindex, nr_xids = 0;
18584 +
18585 +       /* only show current and children */
18586 +       if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18587 +               if (index > 0)
18588 +                       return 0;
18589 +               xids[nr_xids] = vx_current_xid();
18590 +               return 1;
18591 +       }
18592 +
18593 +       for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18594 +               struct hlist_head *head = &vx_info_hash[hindex];
18595 +               struct hlist_node *pos;
18596 +
18597 +               spin_lock(&vx_info_hash_lock);
18598 +               hlist_for_each(pos, head) {
18599 +                       struct vx_info *vxi;
18600 +
18601 +                       if (--index > 0)
18602 +                               continue;
18603 +
18604 +                       vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18605 +                       xids[nr_xids] = vxi->vx_id;
18606 +                       if (++nr_xids >= size) {
18607 +                               spin_unlock(&vx_info_hash_lock);
18608 +                               goto out;
18609 +                       }
18610 +               }
18611 +               /* keep the lock time short */
18612 +               spin_unlock(&vx_info_hash_lock);
18613 +       }
18614 +out:
18615 +       return nr_xids;
18616 +}
18617 +#endif
18618 +
18619 +#ifdef CONFIG_VSERVER_DEBUG
18620 +
18621 +void   dump_vx_info_inactive(int level)
18622 +{
18623 +       struct hlist_node *entry, *next;
18624 +
18625 +       hlist_for_each_safe(entry, next, &vx_info_inactive) {
18626 +               struct vx_info *vxi =
18627 +                       list_entry(entry, struct vx_info, vx_hlist);
18628 +
18629 +               dump_vx_info(vxi, level);
18630 +       }
18631 +}
18632 +
18633 +#endif
18634 +
18635 +#if 0
18636 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18637 +{
18638 +       struct user_struct *new_user, *old_user;
18639 +
18640 +       if (!p || !vxi)
18641 +               BUG();
18642 +
18643 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18644 +               return -EACCES;
18645 +
18646 +       new_user = alloc_uid(vxi->vx_id, p->uid);
18647 +       if (!new_user)
18648 +               return -ENOMEM;
18649 +
18650 +       old_user = p->user;
18651 +       if (new_user != old_user) {
18652 +               atomic_inc(&new_user->processes);
18653 +               atomic_dec(&old_user->processes);
18654 +               p->user = new_user;
18655 +       }
18656 +       free_uid(old_user);
18657 +       return 0;
18658 +}
18659 +#endif
18660 +
18661 +#if 0
18662 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18663 +{
18664 +       // p->cap_effective &= vxi->vx_cap_bset;
18665 +       p->cap_effective =
18666 +               cap_intersect(p->cap_effective, vxi->cap_bset);
18667 +       // p->cap_inheritable &= vxi->vx_cap_bset;
18668 +       p->cap_inheritable =
18669 +               cap_intersect(p->cap_inheritable, vxi->cap_bset);
18670 +       // p->cap_permitted &= vxi->vx_cap_bset;
18671 +       p->cap_permitted =
18672 +               cap_intersect(p->cap_permitted, vxi->cap_bset);
18673 +}
18674 +#endif
18675 +
18676 +
18677 +#include <linux/file.h>
18678 +#include <linux/fdtable.h>
18679 +
18680 +static int vx_openfd_task(struct task_struct *tsk)
18681 +{
18682 +       struct files_struct *files = tsk->files;
18683 +       struct fdtable *fdt;
18684 +       const unsigned long *bptr;
18685 +       int count, total;
18686 +
18687 +       /* no rcu_read_lock() because of spin_lock() */
18688 +       spin_lock(&files->file_lock);
18689 +       fdt = files_fdtable(files);
18690 +       bptr = fdt->open_fds->fds_bits;
18691 +       count = fdt->max_fds / (sizeof(unsigned long) * 8);
18692 +       for (total = 0; count > 0; count--) {
18693 +               if (*bptr)
18694 +                       total += hweight_long(*bptr);
18695 +               bptr++;
18696 +       }
18697 +       spin_unlock(&files->file_lock);
18698 +       return total;
18699 +}
18700 +
18701 +
18702 +/*     for *space compatibility */
18703 +
18704 +asmlinkage long sys_unshare(unsigned long);
18705 +
18706 +/*
18707 + *     migrate task to new context
18708 + *     gets vxi, puts old_vxi on change
18709 + *     optionally unshares namespaces (hack)
18710 + */
18711 +
18712 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18713 +{
18714 +       struct vx_info *old_vxi;
18715 +       int ret = 0;
18716 +
18717 +       if (!p || !vxi)
18718 +               BUG();
18719 +
18720 +       vxdprintk(VXD_CBIT(xid, 5),
18721 +               "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18722 +               vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18723 +
18724 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18725 +               !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18726 +               return -EACCES;
18727 +
18728 +       if (vx_info_state(vxi, VXS_SHUTDOWN))
18729 +               return -EFAULT;
18730 +
18731 +       old_vxi = task_get_vx_info(p);
18732 +       if (old_vxi == vxi)
18733 +               goto out;
18734 +
18735 +//     if (!(ret = vx_migrate_user(p, vxi))) {
18736 +       {
18737 +               int openfd;
18738 +
18739 +               task_lock(p);
18740 +               openfd = vx_openfd_task(p);
18741 +
18742 +               if (old_vxi) {
18743 +                       atomic_dec(&old_vxi->cvirt.nr_threads);
18744 +                       atomic_dec(&old_vxi->cvirt.nr_running);
18745 +                       __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18746 +                       /* FIXME: what about the struct files here? */
18747 +                       __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18748 +                       /* account for the executable */
18749 +                       __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18750 +               }
18751 +               atomic_inc(&vxi->cvirt.nr_threads);
18752 +               atomic_inc(&vxi->cvirt.nr_running);
18753 +               __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18754 +               /* FIXME: what about the struct files here? */
18755 +               __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18756 +               /* account for the executable */
18757 +               __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18758 +
18759 +               if (old_vxi) {
18760 +                       release_vx_info(old_vxi, p);
18761 +                       clr_vx_info(&p->vx_info);
18762 +               }
18763 +               claim_vx_info(vxi, p);
18764 +               set_vx_info(&p->vx_info, vxi);
18765 +               p->xid = vxi->vx_id;
18766 +
18767 +               vxdprintk(VXD_CBIT(xid, 5),
18768 +                       "moved task %p into vxi:%p[#%d]",
18769 +                       p, vxi, vxi->vx_id);
18770 +
18771 +               // vx_mask_cap_bset(vxi, p);
18772 +               task_unlock(p);
18773 +
18774 +               /* hack for *spaces to provide compatibility */
18775 +               if (unshare) {
18776 +                       struct nsproxy *old_nsp, *new_nsp;
18777 +
18778 +                       ret = unshare_nsproxy_namespaces(
18779 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18780 +                               &new_nsp, NULL);
18781 +                       if (ret)
18782 +                               goto out;
18783 +
18784 +                       old_nsp = xchg(&p->nsproxy, new_nsp);
18785 +                       vx_set_space(vxi,
18786 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18787 +                       put_nsproxy(old_nsp);
18788 +               }
18789 +       }
18790 +out:
18791 +       put_vx_info(old_vxi);
18792 +       return ret;
18793 +}
18794 +
18795 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18796 +{
18797 +       struct task_struct *old_reaper;
18798 +
18799 +       if (!vxi)
18800 +               return -EINVAL;
18801 +
18802 +       vxdprintk(VXD_CBIT(xid, 6),
18803 +               "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18804 +               vxi, vxi->vx_id, p, p->xid, p->pid);
18805 +
18806 +       old_reaper = vxi->vx_reaper;
18807 +       if (old_reaper == p)
18808 +               return 0;
18809 +
18810 +       /* set new child reaper */
18811 +       get_task_struct(p);
18812 +       vxi->vx_reaper = p;
18813 +       put_task_struct(old_reaper);
18814 +       return 0;
18815 +}
18816 +
18817 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18818 +{
18819 +       if (!vxi)
18820 +               return -EINVAL;
18821 +
18822 +       vxdprintk(VXD_CBIT(xid, 6),
18823 +               "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18824 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18825 +
18826 +       vxi->vx_flags &= ~VXF_STATE_INIT;
18827 +       // vxi->vx_initpid = p->tgid;
18828 +       vxi->vx_initpid = p->pid;
18829 +       return 0;
18830 +}
18831 +
18832 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18833 +{
18834 +       vxdprintk(VXD_CBIT(xid, 6),
18835 +               "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18836 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18837 +
18838 +       vxi->exit_code = code;
18839 +       vxi->vx_initpid = 0;
18840 +}
18841 +
18842 +
18843 +void vx_set_persistent(struct vx_info *vxi)
18844 +{
18845 +       vxdprintk(VXD_CBIT(xid, 6),
18846 +               "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18847 +
18848 +       get_vx_info(vxi);
18849 +       claim_vx_info(vxi, NULL);
18850 +}
18851 +
18852 +void vx_clear_persistent(struct vx_info *vxi)
18853 +{
18854 +       vxdprintk(VXD_CBIT(xid, 6),
18855 +               "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18856 +
18857 +       release_vx_info(vxi, NULL);
18858 +       put_vx_info(vxi);
18859 +}
18860 +
18861 +void vx_update_persistent(struct vx_info *vxi)
18862 +{
18863 +       if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18864 +               vx_set_persistent(vxi);
18865 +       else
18866 +               vx_clear_persistent(vxi);
18867 +}
18868 +
18869 +
18870 +/*     task must be current or locked          */
18871 +
18872 +void   exit_vx_info(struct task_struct *p, int code)
18873 +{
18874 +       struct vx_info *vxi = p->vx_info;
18875 +
18876 +       if (vxi) {
18877 +               atomic_dec(&vxi->cvirt.nr_threads);
18878 +               vx_nproc_dec(p);
18879 +
18880 +               vxi->exit_code = code;
18881 +               release_vx_info(vxi, p);
18882 +       }
18883 +}
18884 +
18885 +void   exit_vx_info_early(struct task_struct *p, int code)
18886 +{
18887 +       struct vx_info *vxi = p->vx_info;
18888 +
18889 +       if (vxi) {
18890 +               if (vxi->vx_initpid == p->pid)
18891 +                       vx_exit_init(vxi, p, code);
18892 +               if (vxi->vx_reaper == p)
18893 +                       vx_set_reaper(vxi, init_pid_ns.child_reaper);
18894 +       }
18895 +}
18896 +
18897 +
18898 +/* vserver syscall commands below here */
18899 +
18900 +/* taks xid and vx_info functions */
18901 +
18902 +#include <asm/uaccess.h>
18903 +
18904 +
18905 +int vc_task_xid(uint32_t id)
18906 +{
18907 +       xid_t xid;
18908 +
18909 +       if (id) {
18910 +               struct task_struct *tsk;
18911 +
18912 +               read_lock(&tasklist_lock);
18913 +               tsk = find_task_by_real_pid(id);
18914 +               xid = (tsk) ? tsk->xid : -ESRCH;
18915 +               read_unlock(&tasklist_lock);
18916 +       } else
18917 +               xid = vx_current_xid();
18918 +       return xid;
18919 +}
18920 +
18921 +
18922 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18923 +{
18924 +       struct vcmd_vx_info_v0 vc_data;
18925 +
18926 +       vc_data.xid = vxi->vx_id;
18927 +       vc_data.initpid = vxi->vx_initpid;
18928 +
18929 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18930 +               return -EFAULT;
18931 +       return 0;
18932 +}
18933 +
18934 +
18935 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18936 +{
18937 +       struct vcmd_ctx_stat_v0 vc_data;
18938 +
18939 +       vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18940 +       vc_data.tasks = atomic_read(&vxi->vx_tasks);
18941 +
18942 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18943 +               return -EFAULT;
18944 +       return 0;
18945 +}
18946 +
18947 +
18948 +/* context functions */
18949 +
18950 +int vc_ctx_create(uint32_t xid, void __user *data)
18951 +{
18952 +       struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18953 +       struct vx_info *new_vxi;
18954 +       int ret;
18955 +
18956 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18957 +               return -EFAULT;
18958 +
18959 +       if ((xid > MAX_S_CONTEXT) || (xid < 2))
18960 +               return -EINVAL;
18961 +
18962 +       new_vxi = __create_vx_info(xid);
18963 +       if (IS_ERR(new_vxi))
18964 +               return PTR_ERR(new_vxi);
18965 +
18966 +       /* initial flags */
18967 +       new_vxi->vx_flags = vc_data.flagword;
18968 +
18969 +       ret = -ENOEXEC;
18970 +       if (vs_state_change(new_vxi, VSC_STARTUP))
18971 +               goto out;
18972 +
18973 +       ret = vx_migrate_task(current, new_vxi, (!data));
18974 +       if (ret)
18975 +               goto out;
18976 +
18977 +       /* return context id on success */
18978 +       ret = new_vxi->vx_id;
18979 +
18980 +       /* get a reference for persistent contexts */
18981 +       if ((vc_data.flagword & VXF_PERSISTENT))
18982 +               vx_set_persistent(new_vxi);
18983 +out:
18984 +       release_vx_info(new_vxi, NULL);
18985 +       put_vx_info(new_vxi);
18986 +       return ret;
18987 +}
18988 +
18989 +
18990 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18991 +{
18992 +       struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18993 +       int ret;
18994 +
18995 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18996 +               return -EFAULT;
18997 +
18998 +       ret = vx_migrate_task(current, vxi, 0);
18999 +       if (ret)
19000 +               return ret;
19001 +       if (vc_data.flagword & VXM_SET_INIT)
19002 +               ret = vx_set_init(vxi, current);
19003 +       if (ret)
19004 +               return ret;
19005 +       if (vc_data.flagword & VXM_SET_REAPER)
19006 +               ret = vx_set_reaper(vxi, current);
19007 +       return ret;
19008 +}
19009 +
19010 +
19011 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
19012 +{
19013 +       struct vcmd_ctx_flags_v0 vc_data;
19014 +
19015 +       vc_data.flagword = vxi->vx_flags;
19016 +
19017 +       /* special STATE flag handling */
19018 +       vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
19019 +
19020 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19021 +               return -EFAULT;
19022 +       return 0;
19023 +}
19024 +
19025 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
19026 +{
19027 +       struct vcmd_ctx_flags_v0 vc_data;
19028 +       uint64_t mask, trigger;
19029 +
19030 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19031 +               return -EFAULT;
19032 +
19033 +       /* special STATE flag handling */
19034 +       mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
19035 +       trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
19036 +
19037 +       if (vxi == current_vx_info()) {
19038 +               /* if (trigger & VXF_STATE_SETUP)
19039 +                       vx_mask_cap_bset(vxi, current); */
19040 +               if (trigger & VXF_STATE_INIT) {
19041 +                       int ret;
19042 +
19043 +                       ret = vx_set_init(vxi, current);
19044 +                       if (ret)
19045 +                               return ret;
19046 +                       ret = vx_set_reaper(vxi, current);
19047 +                       if (ret)
19048 +                               return ret;
19049 +               }
19050 +       }
19051 +
19052 +       vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
19053 +               vc_data.flagword, mask);
19054 +       if (trigger & VXF_PERSISTENT)
19055 +               vx_update_persistent(vxi);
19056 +
19057 +       return 0;
19058 +}
19059 +
19060 +
19061 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
19062 +{
19063 +       uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
19064 +
19065 +       // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
19066 +       return v;
19067 +}
19068 +
19069 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
19070 +{
19071 +       kernel_cap_t c = __cap_empty_set;
19072 +
19073 +       c.cap[0] = v & 0xFFFFFFFF;
19074 +       c.cap[1] = (v >> 32) & 0xFFFFFFFF;
19075 +
19076 +       // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
19077 +       return c;
19078 +}
19079 +
19080 +
19081 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
19082 +{
19083 +       if (bcaps)
19084 +               *bcaps = caps_from_cap_t(vxi->vx_bcaps);
19085 +       if (ccaps)
19086 +               *ccaps = vxi->vx_ccaps;
19087 +
19088 +       return 0;
19089 +}
19090 +
19091 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
19092 +{
19093 +       struct vcmd_ctx_caps_v1 vc_data;
19094 +       int ret;
19095 +
19096 +       ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
19097 +       if (ret)
19098 +               return ret;
19099 +       vc_data.cmask = ~0ULL;
19100 +
19101 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19102 +               return -EFAULT;
19103 +       return 0;
19104 +}
19105 +
19106 +static int do_set_caps(struct vx_info *vxi,
19107 +       uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
19108 +{
19109 +       uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
19110 +
19111 +#if 0
19112 +       printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
19113 +               bcaps, bmask, ccaps, cmask);
19114 +#endif
19115 +       vxi->vx_bcaps = cap_t_from_caps(
19116 +               vs_mask_flags(bcold, bcaps, bmask));
19117 +       vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
19118 +
19119 +       return 0;
19120 +}
19121 +
19122 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
19123 +{
19124 +       struct vcmd_ctx_caps_v1 vc_data;
19125 +
19126 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19127 +               return -EFAULT;
19128 +
19129 +       return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
19130 +}
19131 +
19132 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
19133 +{
19134 +       struct vcmd_bcaps vc_data;
19135 +       int ret;
19136 +
19137 +       ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
19138 +       if (ret)
19139 +               return ret;
19140 +       vc_data.bmask = ~0ULL;
19141 +
19142 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19143 +               return -EFAULT;
19144 +       return 0;
19145 +}
19146 +
19147 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
19148 +{
19149 +       struct vcmd_bcaps vc_data;
19150 +
19151 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19152 +               return -EFAULT;
19153 +
19154 +       return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
19155 +}
19156 +
19157 +
19158 +int vc_get_umask(struct vx_info *vxi, void __user *data)
19159 +{
19160 +       struct vcmd_umask vc_data;
19161 +
19162 +       vc_data.umask = vxi->vx_umask;
19163 +       vc_data.mask = ~0ULL;
19164 +
19165 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19166 +               return -EFAULT;
19167 +       return 0;
19168 +}
19169 +
19170 +int vc_set_umask(struct vx_info *vxi, void __user *data)
19171 +{
19172 +       struct vcmd_umask vc_data;
19173 +
19174 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19175 +               return -EFAULT;
19176 +
19177 +       vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
19178 +               vc_data.umask, vc_data.mask);
19179 +       return 0;
19180 +}
19181 +
19182 +
19183 +int vc_get_badness(struct vx_info *vxi, void __user *data)
19184 +{
19185 +       struct vcmd_badness_v0 vc_data;
19186 +
19187 +       vc_data.bias = vxi->vx_badness_bias;
19188 +
19189 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19190 +               return -EFAULT;
19191 +       return 0;
19192 +}
19193 +
19194 +int vc_set_badness(struct vx_info *vxi, void __user *data)
19195 +{
19196 +       struct vcmd_badness_v0 vc_data;
19197 +
19198 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19199 +               return -EFAULT;
19200 +
19201 +       vxi->vx_badness_bias = vc_data.bias;
19202 +       return 0;
19203 +}
19204 +
19205 +#include <linux/module.h>
19206 +
19207 +EXPORT_SYMBOL_GPL(free_vx_info);
19208 +
19209 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/cvirt.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cvirt.c
19210 --- linux-2.6.33.1/kernel/vserver/cvirt.c       1970-01-01 01:00:00.000000000 +0100
19211 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cvirt.c       2010-02-25 12:02:16.000000000 +0100
19212 @@ -0,0 +1,304 @@
19213 +/*
19214 + *  linux/kernel/vserver/cvirt.c
19215 + *
19216 + *  Virtual Server: Context Virtualization
19217 + *
19218 + *  Copyright (C) 2004-2007  Herbert Pötzl
19219 + *
19220 + *  V0.01  broken out from limit.c
19221 + *  V0.02  added utsname stuff
19222 + *  V0.03  changed vcmds to vxi arg
19223 + *
19224 + */
19225 +
19226 +#include <linux/types.h>
19227 +#include <linux/utsname.h>
19228 +#include <linux/vs_cvirt.h>
19229 +#include <linux/vserver/switch.h>
19230 +#include <linux/vserver/cvirt_cmd.h>
19231 +
19232 +#include <asm/uaccess.h>
19233 +
19234 +
19235 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
19236 +{
19237 +       struct vx_info *vxi = current_vx_info();
19238 +
19239 +       set_normalized_timespec(uptime,
19240 +               uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
19241 +               uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
19242 +       if (!idle)
19243 +               return;
19244 +       set_normalized_timespec(idle,
19245 +               idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
19246 +               idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
19247 +       return;
19248 +}
19249 +
19250 +uint64_t vx_idle_jiffies(void)
19251 +{
19252 +       return init_task.utime + init_task.stime;
19253 +}
19254 +
19255 +
19256 +
19257 +static inline uint32_t __update_loadavg(uint32_t load,
19258 +       int wsize, int delta, int n)
19259 +{
19260 +       unsigned long long calc, prev;
19261 +
19262 +       /* just set it to n */
19263 +       if (unlikely(delta >= wsize))
19264 +               return (n << FSHIFT);
19265 +
19266 +       calc = delta * n;
19267 +       calc <<= FSHIFT;
19268 +       prev = (wsize - delta);
19269 +       prev *= load;
19270 +       calc += prev;
19271 +       do_div(calc, wsize);
19272 +       return calc;
19273 +}
19274 +
19275 +
19276 +void vx_update_load(struct vx_info *vxi)
19277 +{
19278 +       uint32_t now, last, delta;
19279 +       unsigned int nr_running, nr_uninterruptible;
19280 +       unsigned int total;
19281 +       unsigned long flags;
19282 +
19283 +       spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
19284 +
19285 +       now = jiffies;
19286 +       last = vxi->cvirt.load_last;
19287 +       delta = now - last;
19288 +
19289 +       if (delta < 5*HZ)
19290 +               goto out;
19291 +
19292 +       nr_running = atomic_read(&vxi->cvirt.nr_running);
19293 +       nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
19294 +       total = nr_running + nr_uninterruptible;
19295 +
19296 +       vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
19297 +               60*HZ, delta, total);
19298 +       vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
19299 +               5*60*HZ, delta, total);
19300 +       vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
19301 +               15*60*HZ, delta, total);
19302 +
19303 +       vxi->cvirt.load_last = now;
19304 +out:
19305 +       atomic_inc(&vxi->cvirt.load_updates);
19306 +       spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
19307 +}
19308 +
19309 +
19310 +/*
19311 + * Commands to do_syslog:
19312 + *
19313 + *      0 -- Close the log.  Currently a NOP.
19314 + *      1 -- Open the log. Currently a NOP.
19315 + *      2 -- Read from the log.
19316 + *      3 -- Read all messages remaining in the ring buffer.
19317 + *      4 -- Read and clear all messages remaining in the ring buffer
19318 + *      5 -- Clear ring buffer.
19319 + *      6 -- Disable printk's to console
19320 + *      7 -- Enable printk's to console
19321 + *      8 -- Set level of messages printed to console
19322 + *      9 -- Return number of unread characters in the log buffer
19323 + *     10 -- Return size of the log buffer
19324 + */
19325 +int vx_do_syslog(int type, char __user *buf, int len)
19326 +{
19327 +       int error = 0;
19328 +       int do_clear = 0;
19329 +       struct vx_info *vxi = current_vx_info();
19330 +       struct _vx_syslog *log;
19331 +
19332 +       if (!vxi)
19333 +               return -EINVAL;
19334 +       log = &vxi->cvirt.syslog;
19335 +
19336 +       switch (type) {
19337 +       case 0:         /* Close log */
19338 +       case 1:         /* Open log */
19339 +               break;
19340 +       case 2:         /* Read from log */
19341 +               error = wait_event_interruptible(log->log_wait,
19342 +                       (log->log_start - log->log_end));
19343 +               if (error)
19344 +                       break;
19345 +               spin_lock_irq(&log->logbuf_lock);
19346 +               spin_unlock_irq(&log->logbuf_lock);
19347 +               break;
19348 +       case 4:         /* Read/clear last kernel messages */
19349 +               do_clear = 1;
19350 +               /* fall through */
19351 +       case 3:         /* Read last kernel messages */
19352 +               return 0;
19353 +
19354 +       case 5:         /* Clear ring buffer */
19355 +               return 0;
19356 +
19357 +       case 6:         /* Disable logging to console */
19358 +       case 7:         /* Enable logging to console */
19359 +       case 8:         /* Set level of messages printed to console */
19360 +               break;
19361 +
19362 +       case 9:         /* Number of chars in the log buffer */
19363 +               return 0;
19364 +       case 10:        /* Size of the log buffer */
19365 +               return 0;
19366 +       default:
19367 +               error = -EINVAL;
19368 +               break;
19369 +       }
19370 +       return error;
19371 +}
19372 +
19373 +
19374 +/* virtual host info names */
19375 +
19376 +static char *vx_vhi_name(struct vx_info *vxi, int id)
19377 +{
19378 +       struct nsproxy *nsproxy;
19379 +       struct uts_namespace *uts;
19380 +
19381 +       if (id == VHIN_CONTEXT)
19382 +               return vxi->vx_name;
19383 +
19384 +       nsproxy = vxi->vx_nsproxy[0];
19385 +       if (!nsproxy)
19386 +               return NULL;
19387 +
19388 +       uts = nsproxy->uts_ns;
19389 +       if (!uts)
19390 +               return NULL;
19391 +
19392 +       switch (id) {
19393 +       case VHIN_SYSNAME:
19394 +               return uts->name.sysname;
19395 +       case VHIN_NODENAME:
19396 +               return uts->name.nodename;
19397 +       case VHIN_RELEASE:
19398 +               return uts->name.release;
19399 +       case VHIN_VERSION:
19400 +               return uts->name.version;
19401 +       case VHIN_MACHINE:
19402 +               return uts->name.machine;
19403 +       case VHIN_DOMAINNAME:
19404 +               return uts->name.domainname;
19405 +       default:
19406 +               return NULL;
19407 +       }
19408 +       return NULL;
19409 +}
19410 +
19411 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
19412 +{
19413 +       struct vcmd_vhi_name_v0 vc_data;
19414 +       char *name;
19415 +
19416 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19417 +               return -EFAULT;
19418 +
19419 +       name = vx_vhi_name(vxi, vc_data.field);
19420 +       if (!name)
19421 +               return -EINVAL;
19422 +
19423 +       memcpy(name, vc_data.name, 65);
19424 +       return 0;
19425 +}
19426 +
19427 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
19428 +{
19429 +       struct vcmd_vhi_name_v0 vc_data;
19430 +       char *name;
19431 +
19432 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19433 +               return -EFAULT;
19434 +
19435 +       name = vx_vhi_name(vxi, vc_data.field);
19436 +       if (!name)
19437 +               return -EINVAL;
19438 +
19439 +       memcpy(vc_data.name, name, 65);
19440 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19441 +               return -EFAULT;
19442 +       return 0;
19443 +}
19444 +
19445 +
19446 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
19447 +{
19448 +       struct vcmd_virt_stat_v0 vc_data;
19449 +       struct _vx_cvirt *cvirt = &vxi->cvirt;
19450 +       struct timespec uptime;
19451 +
19452 +       do_posix_clock_monotonic_gettime(&uptime);
19453 +       set_normalized_timespec(&uptime,
19454 +               uptime.tv_sec - cvirt->bias_uptime.tv_sec,
19455 +               uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
19456 +
19457 +       vc_data.offset = timeval_to_ns(&cvirt->bias_tv);
19458 +       vc_data.uptime = timespec_to_ns(&uptime);
19459 +       vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
19460 +       vc_data.nr_running = atomic_read(&cvirt->nr_running);
19461 +       vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
19462 +       vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
19463 +       vc_data.nr_forks = atomic_read(&cvirt->total_forks);
19464 +       vc_data.load[0] = cvirt->load[0];
19465 +       vc_data.load[1] = cvirt->load[1];
19466 +       vc_data.load[2] = cvirt->load[2];
19467 +
19468 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19469 +               return -EFAULT;
19470 +       return 0;
19471 +}
19472 +
19473 +
19474 +#ifdef CONFIG_VSERVER_VTIME
19475 +
19476 +/* virtualized time base */
19477 +
19478 +void vx_gettimeofday(struct timeval *tv)
19479 +{
19480 +       struct vx_info *vxi;
19481 +
19482 +       do_gettimeofday(tv);
19483 +       if (!vx_flags(VXF_VIRT_TIME, 0))
19484 +               return;
19485 +
19486 +       vxi = current_vx_info();
19487 +       tv->tv_sec += vxi->cvirt.bias_tv.tv_sec;
19488 +       tv->tv_usec += vxi->cvirt.bias_tv.tv_usec;
19489 +
19490 +       if (tv->tv_usec >= USEC_PER_SEC) {
19491 +               tv->tv_sec++;
19492 +               tv->tv_usec -= USEC_PER_SEC;
19493 +       } else if (tv->tv_usec < 0) {
19494 +               tv->tv_sec--;
19495 +               tv->tv_usec += USEC_PER_SEC;
19496 +       }
19497 +}
19498 +
19499 +int vx_settimeofday(struct timespec *ts)
19500 +{
19501 +       struct timeval tv;
19502 +       struct vx_info *vxi;
19503 +
19504 +       if (!vx_flags(VXF_VIRT_TIME, 0))
19505 +               return do_settimeofday(ts);
19506 +
19507 +       do_gettimeofday(&tv);
19508 +       vxi = current_vx_info();
19509 +       vxi->cvirt.bias_tv.tv_sec = ts->tv_sec - tv.tv_sec;
19510 +       vxi->cvirt.bias_tv.tv_usec =
19511 +               (ts->tv_nsec/NSEC_PER_USEC) - tv.tv_usec;
19512 +       return 0;
19513 +}
19514 +
19515 +#endif
19516 +
19517 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/cvirt_init.h linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cvirt_init.h
19518 --- linux-2.6.33.1/kernel/vserver/cvirt_init.h  1970-01-01 01:00:00.000000000 +0100
19519 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cvirt_init.h  2010-02-25 12:02:16.000000000 +0100
19520 @@ -0,0 +1,69 @@
19521 +
19522 +
19523 +extern uint64_t vx_idle_jiffies(void);
19524 +
19525 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19526 +{
19527 +       uint64_t idle_jiffies = vx_idle_jiffies();
19528 +       uint64_t nsuptime;
19529 +
19530 +       do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19531 +       nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19532 +               * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19533 +       cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19534 +       cvirt->bias_tv.tv_sec = 0;
19535 +       cvirt->bias_tv.tv_usec = 0;
19536 +
19537 +       jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19538 +       atomic_set(&cvirt->nr_threads, 0);
19539 +       atomic_set(&cvirt->nr_running, 0);
19540 +       atomic_set(&cvirt->nr_uninterruptible, 0);
19541 +       atomic_set(&cvirt->nr_onhold, 0);
19542 +
19543 +       spin_lock_init(&cvirt->load_lock);
19544 +       cvirt->load_last = jiffies;
19545 +       atomic_set(&cvirt->load_updates, 0);
19546 +       cvirt->load[0] = 0;
19547 +       cvirt->load[1] = 0;
19548 +       cvirt->load[2] = 0;
19549 +       atomic_set(&cvirt->total_forks, 0);
19550 +
19551 +       spin_lock_init(&cvirt->syslog.logbuf_lock);
19552 +       init_waitqueue_head(&cvirt->syslog.log_wait);
19553 +       cvirt->syslog.log_start = 0;
19554 +       cvirt->syslog.log_end = 0;
19555 +       cvirt->syslog.con_start = 0;
19556 +       cvirt->syslog.logged_chars = 0;
19557 +}
19558 +
19559 +static inline
19560 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19561 +{
19562 +       // cvirt_pc->cpustat = { 0 };
19563 +}
19564 +
19565 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19566 +{
19567 +       int value;
19568 +
19569 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19570 +               "!!! cvirt: %p[nr_threads] = %d on exit.",
19571 +               cvirt, value);
19572 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19573 +               "!!! cvirt: %p[nr_running] = %d on exit.",
19574 +               cvirt, value);
19575 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19576 +               "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19577 +               cvirt, value);
19578 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19579 +               "!!! cvirt: %p[nr_onhold] = %d on exit.",
19580 +               cvirt, value);
19581 +       return;
19582 +}
19583 +
19584 +static inline
19585 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19586 +{
19587 +       return;
19588 +}
19589 +
19590 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/cvirt_proc.h linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cvirt_proc.h
19591 --- linux-2.6.33.1/kernel/vserver/cvirt_proc.h  1970-01-01 01:00:00.000000000 +0100
19592 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/cvirt_proc.h  2010-02-25 12:02:16.000000000 +0100
19593 @@ -0,0 +1,135 @@
19594 +#ifndef _VX_CVIRT_PROC_H
19595 +#define _VX_CVIRT_PROC_H
19596 +
19597 +#include <linux/nsproxy.h>
19598 +#include <linux/mnt_namespace.h>
19599 +#include <linux/ipc_namespace.h>
19600 +#include <linux/utsname.h>
19601 +#include <linux/ipc.h>
19602 +
19603 +
19604 +static inline
19605 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19606 +{
19607 +       struct mnt_namespace *ns;
19608 +       struct uts_namespace *uts;
19609 +       struct ipc_namespace *ipc;
19610 +       struct path path;
19611 +       char *pstr, *root;
19612 +       int length = 0;
19613 +
19614 +       if (!nsproxy)
19615 +               goto out;
19616 +
19617 +       length += sprintf(buffer + length,
19618 +               "NSProxy:\t%p [%p,%p,%p]\n",
19619 +               nsproxy, nsproxy->mnt_ns,
19620 +               nsproxy->uts_ns, nsproxy->ipc_ns);
19621 +
19622 +       ns = nsproxy->mnt_ns;
19623 +       if (!ns)
19624 +               goto skip_ns;
19625 +
19626 +       pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19627 +       if (!pstr)
19628 +               goto skip_ns;
19629 +
19630 +       path.mnt = ns->root;
19631 +       path.dentry = ns->root->mnt_root;
19632 +       root = d_path(&path, pstr, PATH_MAX - 2);
19633 +       length += sprintf(buffer + length,
19634 +               "Namespace:\t%p [#%u]\n"
19635 +               "RootPath:\t%s\n",
19636 +               ns, atomic_read(&ns->count),
19637 +               root);
19638 +       kfree(pstr);
19639 +skip_ns:
19640 +
19641 +       uts = nsproxy->uts_ns;
19642 +       if (!uts)
19643 +               goto skip_uts;
19644 +
19645 +       length += sprintf(buffer + length,
19646 +               "SysName:\t%.*s\n"
19647 +               "NodeName:\t%.*s\n"
19648 +               "Release:\t%.*s\n"
19649 +               "Version:\t%.*s\n"
19650 +               "Machine:\t%.*s\n"
19651 +               "DomainName:\t%.*s\n",
19652 +               __NEW_UTS_LEN, uts->name.sysname,
19653 +               __NEW_UTS_LEN, uts->name.nodename,
19654 +               __NEW_UTS_LEN, uts->name.release,
19655 +               __NEW_UTS_LEN, uts->name.version,
19656 +               __NEW_UTS_LEN, uts->name.machine,
19657 +               __NEW_UTS_LEN, uts->name.domainname);
19658 +skip_uts:
19659 +
19660 +       ipc = nsproxy->ipc_ns;
19661 +       if (!ipc)
19662 +               goto skip_ipc;
19663 +
19664 +       length += sprintf(buffer + length,
19665 +               "SEMS:\t\t%d %d %d %d  %d\n"
19666 +               "MSG:\t\t%d %d %d\n"
19667 +               "SHM:\t\t%lu %lu  %d %d\n",
19668 +               ipc->sem_ctls[0], ipc->sem_ctls[1],
19669 +               ipc->sem_ctls[2], ipc->sem_ctls[3],
19670 +               ipc->used_sems,
19671 +               ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19672 +               (unsigned long)ipc->shm_ctlmax,
19673 +               (unsigned long)ipc->shm_ctlall,
19674 +               ipc->shm_ctlmni, ipc->shm_tot);
19675 +skip_ipc:
19676 +out:
19677 +       return length;
19678 +}
19679 +
19680 +
19681 +#include <linux/sched.h>
19682 +
19683 +#define LOAD_INT(x) ((x) >> FSHIFT)
19684 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19685 +
19686 +static inline
19687 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19688 +{
19689 +       int length = 0;
19690 +       int a, b, c;
19691 +
19692 +       length += sprintf(buffer + length,
19693 +               "BiasUptime:\t%lu.%02lu\n",
19694 +               (unsigned long)cvirt->bias_uptime.tv_sec,
19695 +               (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19696 +
19697 +       a = cvirt->load[0] + (FIXED_1 / 200);
19698 +       b = cvirt->load[1] + (FIXED_1 / 200);
19699 +       c = cvirt->load[2] + (FIXED_1 / 200);
19700 +       length += sprintf(buffer + length,
19701 +               "nr_threads:\t%d\n"
19702 +               "nr_running:\t%d\n"
19703 +               "nr_unintr:\t%d\n"
19704 +               "nr_onhold:\t%d\n"
19705 +               "load_updates:\t%d\n"
19706 +               "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19707 +               "total_forks:\t%d\n",
19708 +               atomic_read(&cvirt->nr_threads),
19709 +               atomic_read(&cvirt->nr_running),
19710 +               atomic_read(&cvirt->nr_uninterruptible),
19711 +               atomic_read(&cvirt->nr_onhold),
19712 +               atomic_read(&cvirt->load_updates),
19713 +               LOAD_INT(a), LOAD_FRAC(a),
19714 +               LOAD_INT(b), LOAD_FRAC(b),
19715 +               LOAD_INT(c), LOAD_FRAC(c),
19716 +               atomic_read(&cvirt->total_forks));
19717 +       return length;
19718 +}
19719 +
19720 +static inline
19721 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19722 +       char *buffer, int cpu)
19723 +{
19724 +       int length = 0;
19725 +       return length;
19726 +}
19727 +
19728 +#endif /* _VX_CVIRT_PROC_H */
19729 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/debug.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/debug.c
19730 --- linux-2.6.33.1/kernel/vserver/debug.c       1970-01-01 01:00:00.000000000 +0100
19731 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/debug.c       2010-02-25 12:02:16.000000000 +0100
19732 @@ -0,0 +1,32 @@
19733 +/*
19734 + *  kernel/vserver/debug.c
19735 + *
19736 + *  Copyright (C) 2005-2007 Herbert Pötzl
19737 + *
19738 + *  V0.01  vx_info dump support
19739 + *
19740 + */
19741 +
19742 +#include <linux/module.h>
19743 +
19744 +#include <linux/vserver/context.h>
19745 +
19746 +
19747 +void   dump_vx_info(struct vx_info *vxi, int level)
19748 +{
19749 +       printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19750 +               atomic_read(&vxi->vx_usecnt),
19751 +               atomic_read(&vxi->vx_tasks),
19752 +               vxi->vx_state);
19753 +       if (level > 0) {
19754 +               __dump_vx_limit(&vxi->limit);
19755 +               __dump_vx_sched(&vxi->sched);
19756 +               __dump_vx_cvirt(&vxi->cvirt);
19757 +               __dump_vx_cacct(&vxi->cacct);
19758 +       }
19759 +       printk("---\n");
19760 +}
19761 +
19762 +
19763 +EXPORT_SYMBOL_GPL(dump_vx_info);
19764 +
19765 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/device.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/device.c
19766 --- linux-2.6.33.1/kernel/vserver/device.c      1970-01-01 01:00:00.000000000 +0100
19767 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/device.c      2010-02-25 12:02:16.000000000 +0100
19768 @@ -0,0 +1,443 @@
19769 +/*
19770 + *  linux/kernel/vserver/device.c
19771 + *
19772 + *  Linux-VServer: Device Support
19773 + *
19774 + *  Copyright (C) 2006  Herbert Pötzl
19775 + *  Copyright (C) 2007  Daniel Hokka Zakrisson
19776 + *
19777 + *  V0.01  device mapping basics
19778 + *  V0.02  added defaults
19779 + *
19780 + */
19781 +
19782 +#include <linux/slab.h>
19783 +#include <linux/rcupdate.h>
19784 +#include <linux/fs.h>
19785 +#include <linux/namei.h>
19786 +#include <linux/hash.h>
19787 +
19788 +#include <asm/errno.h>
19789 +#include <asm/uaccess.h>
19790 +#include <linux/vserver/base.h>
19791 +#include <linux/vserver/debug.h>
19792 +#include <linux/vserver/context.h>
19793 +#include <linux/vserver/device.h>
19794 +#include <linux/vserver/device_cmd.h>
19795 +
19796 +
19797 +#define DMAP_HASH_BITS 4
19798 +
19799 +
19800 +struct vs_mapping {
19801 +       union {
19802 +               struct hlist_node hlist;
19803 +               struct list_head list;
19804 +       } u;
19805 +#define dm_hlist       u.hlist
19806 +#define dm_list                u.list
19807 +       xid_t xid;
19808 +       dev_t device;
19809 +       struct vx_dmap_target target;
19810 +};
19811 +
19812 +
19813 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19814 +
19815 +static spinlock_t dmap_main_hash_lock = SPIN_LOCK_UNLOCKED;
19816 +
19817 +static struct vx_dmap_target dmap_defaults[2] = {
19818 +       { .flags = DATTR_OPEN },
19819 +       { .flags = DATTR_OPEN },
19820 +};
19821 +
19822 +
19823 +struct kmem_cache *dmap_cachep __read_mostly;
19824 +
19825 +int __init dmap_cache_init(void)
19826 +{
19827 +       dmap_cachep = kmem_cache_create("dmap_cache",
19828 +               sizeof(struct vs_mapping), 0,
19829 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19830 +       return 0;
19831 +}
19832 +
19833 +__initcall(dmap_cache_init);
19834 +
19835 +
19836 +static inline unsigned int __hashval(dev_t dev, int bits)
19837 +{
19838 +       return hash_long((unsigned long)dev, bits);
19839 +}
19840 +
19841 +
19842 +/*     __hash_mapping()
19843 + *     add the mapping to the hash table
19844 + */
19845 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19846 +{
19847 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19848 +       struct hlist_head *head, *hash = dmap_main_hash;
19849 +       int device = vdm->device;
19850 +
19851 +       spin_lock(hash_lock);
19852 +       vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19853 +               vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19854 +
19855 +       head = &hash[__hashval(device, DMAP_HASH_BITS)];
19856 +       hlist_add_head(&vdm->dm_hlist, head);
19857 +       spin_unlock(hash_lock);
19858 +}
19859 +
19860 +
19861 +static inline int __mode_to_default(umode_t mode)
19862 +{
19863 +       switch (mode) {
19864 +       case S_IFBLK:
19865 +               return 0;
19866 +       case S_IFCHR:
19867 +               return 1;
19868 +       default:
19869 +               BUG();
19870 +       }
19871 +}
19872 +
19873 +
19874 +/*     __set_default()
19875 + *     set a default
19876 + */
19877 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19878 +       struct vx_dmap_target *vdmt)
19879 +{
19880 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19881 +       spin_lock(hash_lock);
19882 +
19883 +       if (vxi)
19884 +               vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19885 +       else
19886 +               dmap_defaults[__mode_to_default(mode)] = *vdmt;
19887 +
19888 +
19889 +       spin_unlock(hash_lock);
19890 +
19891 +       vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19892 +                 vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19893 +}
19894 +
19895 +
19896 +/*     __remove_default()
19897 + *     remove a default
19898 + */
19899 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19900 +{
19901 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19902 +       spin_lock(hash_lock);
19903 +
19904 +       if (vxi)
19905 +               vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19906 +       else    /* remove == reset */
19907 +               dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19908 +
19909 +       spin_unlock(hash_lock);
19910 +       return 0;
19911 +}
19912 +
19913 +
19914 +/*     __find_mapping()
19915 + *     find a mapping in the hash table
19916 + *
19917 + *     caller must hold hash_lock
19918 + */
19919 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19920 +       struct vs_mapping **local, struct vs_mapping **global)
19921 +{
19922 +       struct hlist_head *hash = dmap_main_hash;
19923 +       struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19924 +       struct hlist_node *pos;
19925 +       struct vs_mapping *vdm;
19926 +
19927 +       *local = NULL;
19928 +       if (global)
19929 +               *global = NULL;
19930 +
19931 +       hlist_for_each(pos, head) {
19932 +               vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19933 +
19934 +               if ((vdm->device == device) &&
19935 +                       !((vdm->target.flags ^ mode) & S_IFMT)) {
19936 +                       if (vdm->xid == xid) {
19937 +                               *local = vdm;
19938 +                               return 1;
19939 +                       } else if (global && vdm->xid == 0)
19940 +                               *global = vdm;
19941 +               }
19942 +       }
19943 +
19944 +       if (global && *global)
19945 +               return 0;
19946 +       else
19947 +               return -ENOENT;
19948 +}
19949 +
19950 +
19951 +/*     __lookup_mapping()
19952 + *     find a mapping and store the result in target and flags
19953 + */
19954 +static inline int __lookup_mapping(struct vx_info *vxi,
19955 +       dev_t device, dev_t *target, int *flags, umode_t mode)
19956 +{
19957 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19958 +       struct vs_mapping *vdm, *global;
19959 +       struct vx_dmap_target *vdmt;
19960 +       int ret = 0;
19961 +       xid_t xid = vxi->vx_id;
19962 +       int index;
19963 +
19964 +       spin_lock(hash_lock);
19965 +       if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19966 +               ret = 1;
19967 +               vdmt = &vdm->target;
19968 +               goto found;
19969 +       }
19970 +
19971 +       index = __mode_to_default(mode);
19972 +       if (vxi && vxi->dmap.targets[index].flags) {
19973 +               ret = 2;
19974 +               vdmt = &vxi->dmap.targets[index];
19975 +       } else if (global) {
19976 +               ret = 3;
19977 +               vdmt = &global->target;
19978 +               goto found;
19979 +       } else {
19980 +               ret = 4;
19981 +               vdmt = &dmap_defaults[index];
19982 +       }
19983 +
19984 +found:
19985 +       if (target && (vdmt->flags & DATTR_REMAP))
19986 +               *target = vdmt->target;
19987 +       else if (target)
19988 +               *target = device;
19989 +       if (flags)
19990 +               *flags = vdmt->flags;
19991 +
19992 +       spin_unlock(hash_lock);
19993 +
19994 +       return ret;
19995 +}
19996 +
19997 +
19998 +/*     __remove_mapping()
19999 + *     remove a mapping from the hash table
20000 + */
20001 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
20002 +       umode_t mode)
20003 +{
20004 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
20005 +       struct vs_mapping *vdm = NULL;
20006 +       int ret = 0;
20007 +
20008 +       spin_lock(hash_lock);
20009 +
20010 +       ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
20011 +               NULL);
20012 +       vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
20013 +               vxi, vxi ? vxi->vx_id : 0, device, mode);
20014 +       if (ret < 0)
20015 +               goto out;
20016 +       hlist_del(&vdm->dm_hlist);
20017 +
20018 +out:
20019 +       spin_unlock(hash_lock);
20020 +       if (vdm)
20021 +               kmem_cache_free(dmap_cachep, vdm);
20022 +       return ret;
20023 +}
20024 +
20025 +
20026 +
20027 +int vs_map_device(struct vx_info *vxi,
20028 +       dev_t device, dev_t *target, umode_t mode)
20029 +{
20030 +       int ret, flags = DATTR_MASK;
20031 +
20032 +       if (!vxi) {
20033 +               if (target)
20034 +                       *target = device;
20035 +               goto out;
20036 +       }
20037 +       ret = __lookup_mapping(vxi, device, target, &flags, mode);
20038 +       vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
20039 +               device, target ? *target : 0, flags, mode, ret);
20040 +out:
20041 +       return (flags & DATTR_MASK);
20042 +}
20043 +
20044 +
20045 +
20046 +static int do_set_mapping(struct vx_info *vxi,
20047 +       dev_t device, dev_t target, int flags, umode_t mode)
20048 +{
20049 +       if (device) {
20050 +               struct vs_mapping *new;
20051 +
20052 +               new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
20053 +               if (!new)
20054 +                       return -ENOMEM;
20055 +
20056 +               INIT_HLIST_NODE(&new->dm_hlist);
20057 +               new->device = device;
20058 +               new->target.target = target;
20059 +               new->target.flags = flags | mode;
20060 +               new->xid = (vxi ? vxi->vx_id : 0);
20061 +
20062 +               vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
20063 +               __hash_mapping(vxi, new);
20064 +       } else {
20065 +               struct vx_dmap_target new = {
20066 +                       .target = target,
20067 +                       .flags = flags | mode,
20068 +               };
20069 +               __set_default(vxi, mode, &new);
20070 +       }
20071 +       return 0;
20072 +}
20073 +
20074 +
20075 +static int do_unset_mapping(struct vx_info *vxi,
20076 +       dev_t device, dev_t target, int flags, umode_t mode)
20077 +{
20078 +       int ret = -EINVAL;
20079 +
20080 +       if (device) {
20081 +               ret = __remove_mapping(vxi, device, mode);
20082 +               if (ret < 0)
20083 +                       goto out;
20084 +       } else {
20085 +               ret = __remove_default(vxi, mode);
20086 +               if (ret < 0)
20087 +                       goto out;
20088 +       }
20089 +
20090 +out:
20091 +       return ret;
20092 +}
20093 +
20094 +
20095 +static inline int __user_device(const char __user *name, dev_t *dev,
20096 +       umode_t *mode)
20097 +{
20098 +       struct nameidata nd;
20099 +       int ret;
20100 +
20101 +       if (!name) {
20102 +               *dev = 0;
20103 +               return 0;
20104 +       }
20105 +       ret = user_lpath(name, &nd.path);
20106 +       if (ret)
20107 +               return ret;
20108 +       if (nd.path.dentry->d_inode) {
20109 +               *dev = nd.path.dentry->d_inode->i_rdev;
20110 +               *mode = nd.path.dentry->d_inode->i_mode;
20111 +       }
20112 +       path_put(&nd.path);
20113 +       return 0;
20114 +}
20115 +
20116 +static inline int __mapping_mode(dev_t device, dev_t target,
20117 +       umode_t device_mode, umode_t target_mode, umode_t *mode)
20118 +{
20119 +       if (device)
20120 +               *mode = device_mode & S_IFMT;
20121 +       else if (target)
20122 +               *mode = target_mode & S_IFMT;
20123 +       else
20124 +               return -EINVAL;
20125 +
20126 +       /* if both given, device and target mode have to match */
20127 +       if (device && target &&
20128 +               ((device_mode ^ target_mode) & S_IFMT))
20129 +               return -EINVAL;
20130 +       return 0;
20131 +}
20132 +
20133 +
20134 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
20135 +       const char __user *target_path, int flags, int set)
20136 +{
20137 +       dev_t device = ~0, target = ~0;
20138 +       umode_t device_mode = 0, target_mode = 0, mode;
20139 +       int ret;
20140 +
20141 +       ret = __user_device(device_path, &device, &device_mode);
20142 +       if (ret)
20143 +               return ret;
20144 +       ret = __user_device(target_path, &target, &target_mode);
20145 +       if (ret)
20146 +               return ret;
20147 +
20148 +       ret = __mapping_mode(device, target,
20149 +               device_mode, target_mode, &mode);
20150 +       if (ret)
20151 +               return ret;
20152 +
20153 +       if (set)
20154 +               return do_set_mapping(vxi, device, target,
20155 +                       flags, mode);
20156 +       else
20157 +               return do_unset_mapping(vxi, device, target,
20158 +                       flags, mode);
20159 +}
20160 +
20161 +
20162 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
20163 +{
20164 +       struct vcmd_set_mapping_v0 vc_data;
20165 +
20166 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20167 +               return -EFAULT;
20168 +
20169 +       return do_mapping(vxi, vc_data.device, vc_data.target,
20170 +               vc_data.flags, 1);
20171 +}
20172 +
20173 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
20174 +{
20175 +       struct vcmd_set_mapping_v0 vc_data;
20176 +
20177 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20178 +               return -EFAULT;
20179 +
20180 +       return do_mapping(vxi, vc_data.device, vc_data.target,
20181 +               vc_data.flags, 0);
20182 +}
20183 +
20184 +
20185 +#ifdef CONFIG_COMPAT
20186 +
20187 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
20188 +{
20189 +       struct vcmd_set_mapping_v0_x32 vc_data;
20190 +
20191 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20192 +               return -EFAULT;
20193 +
20194 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
20195 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
20196 +}
20197 +
20198 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
20199 +{
20200 +       struct vcmd_set_mapping_v0_x32 vc_data;
20201 +
20202 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20203 +               return -EFAULT;
20204 +
20205 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
20206 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
20207 +}
20208 +
20209 +#endif /* CONFIG_COMPAT */
20210 +
20211 +
20212 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/dlimit.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/dlimit.c
20213 --- linux-2.6.33.1/kernel/vserver/dlimit.c      1970-01-01 01:00:00.000000000 +0100
20214 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/dlimit.c      2010-02-25 12:02:16.000000000 +0100
20215 @@ -0,0 +1,529 @@
20216 +/*
20217 + *  linux/kernel/vserver/dlimit.c
20218 + *
20219 + *  Virtual Server: Context Disk Limits
20220 + *
20221 + *  Copyright (C) 2004-2009  Herbert Pötzl
20222 + *
20223 + *  V0.01  initial version
20224 + *  V0.02  compat32 splitup
20225 + *  V0.03  extended interface
20226 + *
20227 + */
20228 +
20229 +#include <linux/statfs.h>
20230 +#include <linux/sched.h>
20231 +#include <linux/namei.h>
20232 +#include <linux/vs_tag.h>
20233 +#include <linux/vs_dlimit.h>
20234 +#include <linux/vserver/dlimit_cmd.h>
20235 +
20236 +#include <asm/uaccess.h>
20237 +
20238 +/*     __alloc_dl_info()
20239 +
20240 +       * allocate an initialized dl_info struct
20241 +       * doesn't make it visible (hash)                        */
20242 +
20243 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
20244 +{
20245 +       struct dl_info *new = NULL;
20246 +
20247 +       vxdprintk(VXD_CBIT(dlim, 5),
20248 +               "alloc_dl_info(%p,%d)*", sb, tag);
20249 +
20250 +       /* would this benefit from a slab cache? */
20251 +       new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
20252 +       if (!new)
20253 +               return 0;
20254 +
20255 +       memset(new, 0, sizeof(struct dl_info));
20256 +       new->dl_tag = tag;
20257 +       new->dl_sb = sb;
20258 +       INIT_RCU_HEAD(&new->dl_rcu);
20259 +       INIT_HLIST_NODE(&new->dl_hlist);
20260 +       spin_lock_init(&new->dl_lock);
20261 +       atomic_set(&new->dl_refcnt, 0);
20262 +       atomic_set(&new->dl_usecnt, 0);
20263 +
20264 +       /* rest of init goes here */
20265 +
20266 +       vxdprintk(VXD_CBIT(dlim, 4),
20267 +               "alloc_dl_info(%p,%d) = %p", sb, tag, new);
20268 +       return new;
20269 +}
20270 +
20271 +/*     __dealloc_dl_info()
20272 +
20273 +       * final disposal of dl_info                             */
20274 +
20275 +static void __dealloc_dl_info(struct dl_info *dli)
20276 +{
20277 +       vxdprintk(VXD_CBIT(dlim, 4),
20278 +               "dealloc_dl_info(%p)", dli);
20279 +
20280 +       dli->dl_hlist.next = LIST_POISON1;
20281 +       dli->dl_tag = -1;
20282 +       dli->dl_sb = 0;
20283 +
20284 +       BUG_ON(atomic_read(&dli->dl_usecnt));
20285 +       BUG_ON(atomic_read(&dli->dl_refcnt));
20286 +
20287 +       kfree(dli);
20288 +}
20289 +
20290 +
20291 +/*     hash table for dl_info hash */
20292 +
20293 +#define DL_HASH_SIZE   13
20294 +
20295 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
20296 +
20297 +static spinlock_t dl_info_hash_lock = SPIN_LOCK_UNLOCKED;
20298 +
20299 +
20300 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
20301 +{
20302 +       return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
20303 +}
20304 +
20305 +
20306 +
20307 +/*     __hash_dl_info()
20308 +
20309 +       * add the dli to the global hash table
20310 +       * requires the hash_lock to be held                     */
20311 +
20312 +static inline void __hash_dl_info(struct dl_info *dli)
20313 +{
20314 +       struct hlist_head *head;
20315 +
20316 +       vxdprintk(VXD_CBIT(dlim, 6),
20317 +               "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
20318 +       get_dl_info(dli);
20319 +       head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
20320 +       hlist_add_head_rcu(&dli->dl_hlist, head);
20321 +}
20322 +
20323 +/*     __unhash_dl_info()
20324 +
20325 +       * remove the dli from the global hash table
20326 +       * requires the hash_lock to be held                     */
20327 +
20328 +static inline void __unhash_dl_info(struct dl_info *dli)
20329 +{
20330 +       vxdprintk(VXD_CBIT(dlim, 6),
20331 +               "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
20332 +       hlist_del_rcu(&dli->dl_hlist);
20333 +       put_dl_info(dli);
20334 +}
20335 +
20336 +
20337 +/*     __lookup_dl_info()
20338 +
20339 +       * requires the rcu_read_lock()
20340 +       * doesn't increment the dl_refcnt                       */
20341 +
20342 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
20343 +{
20344 +       struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
20345 +       struct hlist_node *pos;
20346 +       struct dl_info *dli;
20347 +
20348 +       hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
20349 +
20350 +               if (dli->dl_tag == tag && dli->dl_sb == sb) {
20351 +                       return dli;
20352 +               }
20353 +       }
20354 +       return NULL;
20355 +}
20356 +
20357 +
20358 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
20359 +{
20360 +       struct dl_info *dli;
20361 +
20362 +       rcu_read_lock();
20363 +       dli = get_dl_info(__lookup_dl_info(sb, tag));
20364 +       vxdprintk(VXD_CBIT(dlim, 7),
20365 +               "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
20366 +       rcu_read_unlock();
20367 +       return dli;
20368 +}
20369 +
20370 +void rcu_free_dl_info(struct rcu_head *head)
20371 +{
20372 +       struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
20373 +       int usecnt, refcnt;
20374 +
20375 +       BUG_ON(!dli || !head);
20376 +
20377 +       usecnt = atomic_read(&dli->dl_usecnt);
20378 +       BUG_ON(usecnt < 0);
20379 +
20380 +       refcnt = atomic_read(&dli->dl_refcnt);
20381 +       BUG_ON(refcnt < 0);
20382 +
20383 +       vxdprintk(VXD_CBIT(dlim, 3),
20384 +               "rcu_free_dl_info(%p)", dli);
20385 +       if (!usecnt)
20386 +               __dealloc_dl_info(dli);
20387 +       else
20388 +               printk("!!! rcu didn't free\n");
20389 +}
20390 +
20391 +
20392 +
20393 +
20394 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
20395 +       uint32_t flags, int add)
20396 +{
20397 +       struct path path;
20398 +       int ret;
20399 +
20400 +       ret = user_lpath(name, &path);
20401 +       if (!ret) {
20402 +               struct super_block *sb;
20403 +               struct dl_info *dli;
20404 +
20405 +               ret = -EINVAL;
20406 +               if (!path.dentry->d_inode)
20407 +                       goto out_release;
20408 +               if (!(sb = path.dentry->d_inode->i_sb))
20409 +                       goto out_release;
20410 +
20411 +               if (add) {
20412 +                       dli = __alloc_dl_info(sb, id);
20413 +                       spin_lock(&dl_info_hash_lock);
20414 +
20415 +                       ret = -EEXIST;
20416 +                       if (__lookup_dl_info(sb, id))
20417 +                               goto out_unlock;
20418 +                       __hash_dl_info(dli);
20419 +                       dli = NULL;
20420 +               } else {
20421 +                       spin_lock(&dl_info_hash_lock);
20422 +                       dli = __lookup_dl_info(sb, id);
20423 +
20424 +                       ret = -ESRCH;
20425 +                       if (!dli)
20426 +                               goto out_unlock;
20427 +                       __unhash_dl_info(dli);
20428 +               }
20429 +               ret = 0;
20430 +       out_unlock:
20431 +               spin_unlock(&dl_info_hash_lock);
20432 +               if (add && dli)
20433 +                       __dealloc_dl_info(dli);
20434 +       out_release:
20435 +               path_put(&path);
20436 +       }
20437 +       return ret;
20438 +}
20439 +
20440 +int vc_add_dlimit(uint32_t id, void __user *data)
20441 +{
20442 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
20443 +
20444 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20445 +               return -EFAULT;
20446 +
20447 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
20448 +}
20449 +
20450 +int vc_rem_dlimit(uint32_t id, void __user *data)
20451 +{
20452 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
20453 +
20454 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20455 +               return -EFAULT;
20456 +
20457 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
20458 +}
20459 +
20460 +#ifdef CONFIG_COMPAT
20461 +
20462 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
20463 +{
20464 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20465 +
20466 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20467 +               return -EFAULT;
20468 +
20469 +       return do_addrem_dlimit(id,
20470 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
20471 +}
20472 +
20473 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
20474 +{
20475 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20476 +
20477 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20478 +               return -EFAULT;
20479 +
20480 +       return do_addrem_dlimit(id,
20481 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
20482 +}
20483 +
20484 +#endif /* CONFIG_COMPAT */
20485 +
20486 +
20487 +static inline
20488 +int do_set_dlimit(uint32_t id, const char __user *name,
20489 +       uint32_t space_used, uint32_t space_total,
20490 +       uint32_t inodes_used, uint32_t inodes_total,
20491 +       uint32_t reserved, uint32_t flags)
20492 +{
20493 +       struct path path;
20494 +       int ret;
20495 +
20496 +       ret = user_lpath(name, &path);
20497 +       if (!ret) {
20498 +               struct super_block *sb;
20499 +               struct dl_info *dli;
20500 +
20501 +               ret = -EINVAL;
20502 +               if (!path.dentry->d_inode)
20503 +                       goto out_release;
20504 +               if (!(sb = path.dentry->d_inode->i_sb))
20505 +                       goto out_release;
20506 +
20507 +               /* sanity checks */
20508 +               if ((reserved != CDLIM_KEEP &&
20509 +                       reserved > 100) ||
20510 +                       (inodes_used != CDLIM_KEEP &&
20511 +                       inodes_used > inodes_total) ||
20512 +                       (space_used != CDLIM_KEEP &&
20513 +                       space_used > space_total))
20514 +                       goto out_release;
20515 +
20516 +               ret = -ESRCH;
20517 +               dli = locate_dl_info(sb, id);
20518 +               if (!dli)
20519 +                       goto out_release;
20520 +
20521 +               spin_lock(&dli->dl_lock);
20522 +
20523 +               if (inodes_used != CDLIM_KEEP)
20524 +                       dli->dl_inodes_used = inodes_used;
20525 +               if (inodes_total != CDLIM_KEEP)
20526 +                       dli->dl_inodes_total = inodes_total;
20527 +               if (space_used != CDLIM_KEEP)
20528 +                       dli->dl_space_used = dlimit_space_32to64(
20529 +                               space_used, flags, DLIMS_USED);
20530 +
20531 +               if (space_total == CDLIM_INFINITY)
20532 +                       dli->dl_space_total = DLIM_INFINITY;
20533 +               else if (space_total != CDLIM_KEEP)
20534 +                       dli->dl_space_total = dlimit_space_32to64(
20535 +                               space_total, flags, DLIMS_TOTAL);
20536 +
20537 +               if (reserved != CDLIM_KEEP)
20538 +                       dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20539 +
20540 +               spin_unlock(&dli->dl_lock);
20541 +
20542 +               put_dl_info(dli);
20543 +               ret = 0;
20544 +
20545 +       out_release:
20546 +               path_put(&path);
20547 +       }
20548 +       return ret;
20549 +}
20550 +
20551 +int vc_set_dlimit(uint32_t id, void __user *data)
20552 +{
20553 +       struct vcmd_ctx_dlimit_v0 vc_data;
20554 +
20555 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20556 +               return -EFAULT;
20557 +
20558 +       return do_set_dlimit(id, vc_data.name,
20559 +               vc_data.space_used, vc_data.space_total,
20560 +               vc_data.inodes_used, vc_data.inodes_total,
20561 +               vc_data.reserved, vc_data.flags);
20562 +}
20563 +
20564 +#ifdef CONFIG_COMPAT
20565 +
20566 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20567 +{
20568 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20569 +
20570 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20571 +               return -EFAULT;
20572 +
20573 +       return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20574 +               vc_data.space_used, vc_data.space_total,
20575 +               vc_data.inodes_used, vc_data.inodes_total,
20576 +               vc_data.reserved, vc_data.flags);
20577 +}
20578 +
20579 +#endif /* CONFIG_COMPAT */
20580 +
20581 +
20582 +static inline
20583 +int do_get_dlimit(uint32_t id, const char __user *name,
20584 +       uint32_t *space_used, uint32_t *space_total,
20585 +       uint32_t *inodes_used, uint32_t *inodes_total,
20586 +       uint32_t *reserved, uint32_t *flags)
20587 +{
20588 +       struct path path;
20589 +       int ret;
20590 +
20591 +       ret = user_lpath(name, &path);
20592 +       if (!ret) {
20593 +               struct super_block *sb;
20594 +               struct dl_info *dli;
20595 +
20596 +               ret = -EINVAL;
20597 +               if (!path.dentry->d_inode)
20598 +                       goto out_release;
20599 +               if (!(sb = path.dentry->d_inode->i_sb))
20600 +                       goto out_release;
20601 +
20602 +               ret = -ESRCH;
20603 +               dli = locate_dl_info(sb, id);
20604 +               if (!dli)
20605 +                       goto out_release;
20606 +
20607 +               spin_lock(&dli->dl_lock);
20608 +               *inodes_used = dli->dl_inodes_used;
20609 +               *inodes_total = dli->dl_inodes_total;
20610 +
20611 +               *space_used = dlimit_space_64to32(
20612 +                       dli->dl_space_used, flags, DLIMS_USED);
20613 +
20614 +               if (dli->dl_space_total == DLIM_INFINITY)
20615 +                       *space_total = CDLIM_INFINITY;
20616 +               else
20617 +                       *space_total = dlimit_space_64to32(
20618 +                               dli->dl_space_total, flags, DLIMS_TOTAL);
20619 +
20620 +               *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20621 +               spin_unlock(&dli->dl_lock);
20622 +
20623 +               put_dl_info(dli);
20624 +               ret = -EFAULT;
20625 +
20626 +               ret = 0;
20627 +       out_release:
20628 +               path_put(&path);
20629 +       }
20630 +       return ret;
20631 +}
20632 +
20633 +
20634 +int vc_get_dlimit(uint32_t id, void __user *data)
20635 +{
20636 +       struct vcmd_ctx_dlimit_v0 vc_data;
20637 +       int ret;
20638 +
20639 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20640 +               return -EFAULT;
20641 +
20642 +       ret = do_get_dlimit(id, vc_data.name,
20643 +               &vc_data.space_used, &vc_data.space_total,
20644 +               &vc_data.inodes_used, &vc_data.inodes_total,
20645 +               &vc_data.reserved, &vc_data.flags);
20646 +       if (ret)
20647 +               return ret;
20648 +
20649 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20650 +               return -EFAULT;
20651 +       return 0;
20652 +}
20653 +
20654 +#ifdef CONFIG_COMPAT
20655 +
20656 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20657 +{
20658 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20659 +       int ret;
20660 +
20661 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20662 +               return -EFAULT;
20663 +
20664 +       ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20665 +               &vc_data.space_used, &vc_data.space_total,
20666 +               &vc_data.inodes_used, &vc_data.inodes_total,
20667 +               &vc_data.reserved, &vc_data.flags);
20668 +       if (ret)
20669 +               return ret;
20670 +
20671 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20672 +               return -EFAULT;
20673 +       return 0;
20674 +}
20675 +
20676 +#endif /* CONFIG_COMPAT */
20677 +
20678 +
20679 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20680 +{
20681 +       struct dl_info *dli;
20682 +       __u64 blimit, bfree, bavail;
20683 +       __u32 ifree;
20684 +
20685 +       dli = locate_dl_info(sb, dx_current_tag());
20686 +       if (!dli)
20687 +               return;
20688 +
20689 +       spin_lock(&dli->dl_lock);
20690 +       if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20691 +               goto no_ilim;
20692 +
20693 +       /* reduce max inodes available to limit */
20694 +       if (buf->f_files > dli->dl_inodes_total)
20695 +               buf->f_files = dli->dl_inodes_total;
20696 +
20697 +       ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20698 +       /* reduce free inodes to min */
20699 +       if (ifree < buf->f_ffree)
20700 +               buf->f_ffree = ifree;
20701 +
20702 +no_ilim:
20703 +       if (dli->dl_space_total == DLIM_INFINITY)
20704 +               goto no_blim;
20705 +
20706 +       blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20707 +
20708 +       if (dli->dl_space_total < dli->dl_space_used)
20709 +               bfree = 0;
20710 +       else
20711 +               bfree = (dli->dl_space_total - dli->dl_space_used)
20712 +                       >> sb->s_blocksize_bits;
20713 +
20714 +       bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20715 +       if (bavail < dli->dl_space_used)
20716 +               bavail = 0;
20717 +       else
20718 +               bavail = (bavail - dli->dl_space_used)
20719 +                       >> sb->s_blocksize_bits;
20720 +
20721 +       /* reduce max space available to limit */
20722 +       if (buf->f_blocks > blimit)
20723 +               buf->f_blocks = blimit;
20724 +
20725 +       /* reduce free space to min */
20726 +       if (bfree < buf->f_bfree)
20727 +               buf->f_bfree = bfree;
20728 +
20729 +       /* reduce avail space to min */
20730 +       if (bavail < buf->f_bavail)
20731 +               buf->f_bavail = bavail;
20732 +
20733 +no_blim:
20734 +       spin_unlock(&dli->dl_lock);
20735 +       put_dl_info(dli);
20736 +
20737 +       return;
20738 +}
20739 +
20740 +#include <linux/module.h>
20741 +
20742 +EXPORT_SYMBOL_GPL(locate_dl_info);
20743 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20744 +
20745 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/helper.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/helper.c
20746 --- linux-2.6.33.1/kernel/vserver/helper.c      1970-01-01 01:00:00.000000000 +0100
20747 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/helper.c      2010-02-25 12:02:16.000000000 +0100
20748 @@ -0,0 +1,223 @@
20749 +/*
20750 + *  linux/kernel/vserver/helper.c
20751 + *
20752 + *  Virtual Context Support
20753 + *
20754 + *  Copyright (C) 2004-2007  Herbert Pötzl
20755 + *
20756 + *  V0.01  basic helper
20757 + *
20758 + */
20759 +
20760 +#include <linux/kmod.h>
20761 +#include <linux/reboot.h>
20762 +#include <linux/vs_context.h>
20763 +#include <linux/vs_network.h>
20764 +#include <linux/vserver/signal.h>
20765 +
20766 +
20767 +char vshelper_path[255] = "/sbin/vshelper";
20768 +
20769 +
20770 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20771 +{
20772 +       int ret;
20773 +
20774 +       if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20775 +               printk( KERN_WARNING
20776 +                       "%s: (%s %s) returned %s with %d\n",
20777 +                       name, argv[1], argv[2],
20778 +                       sync ? "sync" : "async", ret);
20779 +       }
20780 +       vxdprintk(VXD_CBIT(switch, 4),
20781 +               "%s: (%s %s) returned %s with %d",
20782 +               name, argv[1], argv[2], sync ? "sync" : "async", ret);
20783 +       return ret;
20784 +}
20785 +
20786 +/*
20787 + *      vshelper path is set via /proc/sys
20788 + *      invoked by vserver sys_reboot(), with
20789 + *      the following arguments
20790 + *
20791 + *      argv [0] = vshelper_path;
20792 + *      argv [1] = action: "restart", "halt", "poweroff", ...
20793 + *      argv [2] = context identifier
20794 + *
20795 + *      envp [*] = type-specific parameters
20796 + */
20797 +
20798 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20799 +{
20800 +       char id_buf[8], cmd_buf[16];
20801 +       char uid_buf[16], pid_buf[16];
20802 +       int ret;
20803 +
20804 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20805 +       char *envp[] = {"HOME=/", "TERM=linux",
20806 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20807 +                       uid_buf, pid_buf, cmd_buf, 0};
20808 +
20809 +       if (vx_info_state(vxi, VXS_HELPER))
20810 +               return -EAGAIN;
20811 +       vxi->vx_state |= VXS_HELPER;
20812 +
20813 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20814 +
20815 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20816 +       snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20817 +       snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20818 +
20819 +       switch (cmd) {
20820 +       case LINUX_REBOOT_CMD_RESTART:
20821 +               argv[1] = "restart";
20822 +               break;
20823 +
20824 +       case LINUX_REBOOT_CMD_HALT:
20825 +               argv[1] = "halt";
20826 +               break;
20827 +
20828 +       case LINUX_REBOOT_CMD_POWER_OFF:
20829 +               argv[1] = "poweroff";
20830 +               break;
20831 +
20832 +       case LINUX_REBOOT_CMD_SW_SUSPEND:
20833 +               argv[1] = "swsusp";
20834 +               break;
20835 +
20836 +       case LINUX_REBOOT_CMD_OOM:
20837 +               argv[1] = "oom";
20838 +               break;
20839 +
20840 +       default:
20841 +               vxi->vx_state &= ~VXS_HELPER;
20842 +               return 0;
20843 +       }
20844 +
20845 +       ret = do_vshelper(vshelper_path, argv, envp, 0);
20846 +       vxi->vx_state &= ~VXS_HELPER;
20847 +       __wakeup_vx_info(vxi);
20848 +       return (ret) ? -EPERM : 0;
20849 +}
20850 +
20851 +
20852 +long vs_reboot(unsigned int cmd, void __user *arg)
20853 +{
20854 +       struct vx_info *vxi = current_vx_info();
20855 +       long ret = 0;
20856 +
20857 +       vxdprintk(VXD_CBIT(misc, 5),
20858 +               "vs_reboot(%p[#%d],%u)",
20859 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20860 +
20861 +       ret = vs_reboot_helper(vxi, cmd, arg);
20862 +       if (ret)
20863 +               return ret;
20864 +
20865 +       vxi->reboot_cmd = cmd;
20866 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20867 +               switch (cmd) {
20868 +               case LINUX_REBOOT_CMD_RESTART:
20869 +               case LINUX_REBOOT_CMD_HALT:
20870 +               case LINUX_REBOOT_CMD_POWER_OFF:
20871 +                       vx_info_kill(vxi, 0, SIGKILL);
20872 +                       vx_info_kill(vxi, 1, SIGKILL);
20873 +               default:
20874 +                       break;
20875 +               }
20876 +       }
20877 +       return 0;
20878 +}
20879 +
20880 +long vs_oom_action(unsigned int cmd)
20881 +{
20882 +       struct vx_info *vxi = current_vx_info();
20883 +       long ret = 0;
20884 +
20885 +       vxdprintk(VXD_CBIT(misc, 5),
20886 +               "vs_oom_action(%p[#%d],%u)",
20887 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20888 +
20889 +       ret = vs_reboot_helper(vxi, cmd, NULL);
20890 +       if (ret)
20891 +               return ret;
20892 +
20893 +       vxi->reboot_cmd = cmd;
20894 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20895 +               vx_info_kill(vxi, 0, SIGKILL);
20896 +               vx_info_kill(vxi, 1, SIGKILL);
20897 +       }
20898 +       return 0;
20899 +}
20900 +
20901 +/*
20902 + *      argv [0] = vshelper_path;
20903 + *      argv [1] = action: "startup", "shutdown"
20904 + *      argv [2] = context identifier
20905 + *
20906 + *      envp [*] = type-specific parameters
20907 + */
20908 +
20909 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20910 +{
20911 +       char id_buf[8], cmd_buf[16];
20912 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20913 +       char *envp[] = {"HOME=/", "TERM=linux",
20914 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20915 +
20916 +       if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20917 +               return 0;
20918 +
20919 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20920 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20921 +
20922 +       switch (cmd) {
20923 +       case VSC_STARTUP:
20924 +               argv[1] = "startup";
20925 +               break;
20926 +       case VSC_SHUTDOWN:
20927 +               argv[1] = "shutdown";
20928 +               break;
20929 +       default:
20930 +               return 0;
20931 +       }
20932 +
20933 +       return do_vshelper(vshelper_path, argv, envp, 1);
20934 +}
20935 +
20936 +
20937 +/*
20938 + *      argv [0] = vshelper_path;
20939 + *      argv [1] = action: "netup", "netdown"
20940 + *      argv [2] = context identifier
20941 + *
20942 + *      envp [*] = type-specific parameters
20943 + */
20944 +
20945 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20946 +{
20947 +       char id_buf[8], cmd_buf[16];
20948 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20949 +       char *envp[] = {"HOME=/", "TERM=linux",
20950 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20951 +
20952 +       if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20953 +               return 0;
20954 +
20955 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20956 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20957 +
20958 +       switch (cmd) {
20959 +       case VSC_NETUP:
20960 +               argv[1] = "netup";
20961 +               break;
20962 +       case VSC_NETDOWN:
20963 +               argv[1] = "netdown";
20964 +               break;
20965 +       default:
20966 +               return 0;
20967 +       }
20968 +
20969 +       return do_vshelper(vshelper_path, argv, envp, 1);
20970 +}
20971 +
20972 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/history.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/history.c
20973 --- linux-2.6.33.1/kernel/vserver/history.c     1970-01-01 01:00:00.000000000 +0100
20974 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/history.c     2010-02-25 12:02:16.000000000 +0100
20975 @@ -0,0 +1,258 @@
20976 +/*
20977 + *  kernel/vserver/history.c
20978 + *
20979 + *  Virtual Context History Backtrace
20980 + *
20981 + *  Copyright (C) 2004-2007  Herbert Pötzl
20982 + *
20983 + *  V0.01  basic structure
20984 + *  V0.02  hash/unhash and trace
20985 + *  V0.03  preemption fixes
20986 + *
20987 + */
20988 +
20989 +#include <linux/module.h>
20990 +#include <asm/uaccess.h>
20991 +
20992 +#include <linux/vserver/context.h>
20993 +#include <linux/vserver/debug.h>
20994 +#include <linux/vserver/debug_cmd.h>
20995 +#include <linux/vserver/history.h>
20996 +
20997 +
20998 +#ifdef CONFIG_VSERVER_HISTORY
20999 +#define VXH_SIZE       CONFIG_VSERVER_HISTORY_SIZE
21000 +#else
21001 +#define VXH_SIZE       64
21002 +#endif
21003 +
21004 +struct _vx_history {
21005 +       unsigned int counter;
21006 +
21007 +       struct _vx_hist_entry entry[VXH_SIZE + 1];
21008 +};
21009 +
21010 +
21011 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
21012 +
21013 +unsigned volatile int vxh_active = 1;
21014 +
21015 +static atomic_t sequence = ATOMIC_INIT(0);
21016 +
21017 +
21018 +/*     vxh_advance()
21019 +
21020 +       * requires disabled preemption                          */
21021 +
21022 +struct _vx_hist_entry *vxh_advance(void *loc)
21023 +{
21024 +       unsigned int cpu = smp_processor_id();
21025 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
21026 +       struct _vx_hist_entry *entry;
21027 +       unsigned int index;
21028 +
21029 +       index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
21030 +       entry = &hist->entry[index];
21031 +
21032 +       entry->seq = atomic_inc_return(&sequence);
21033 +       entry->loc = loc;
21034 +       return entry;
21035 +}
21036 +
21037 +EXPORT_SYMBOL_GPL(vxh_advance);
21038 +
21039 +
21040 +#define VXH_LOC_FMTS   "(#%04x,*%d):%p"
21041 +
21042 +#define VXH_LOC_ARGS(e)        (e)->seq, cpu, (e)->loc
21043 +
21044 +
21045 +#define VXH_VXI_FMTS   "%p[#%d,%d.%d]"
21046 +
21047 +#define VXH_VXI_ARGS(e)        (e)->vxi.ptr,                           \
21048 +                       (e)->vxi.ptr ? (e)->vxi.xid : 0,        \
21049 +                       (e)->vxi.ptr ? (e)->vxi.usecnt : 0,     \
21050 +                       (e)->vxi.ptr ? (e)->vxi.tasks : 0
21051 +
21052 +void   vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
21053 +{
21054 +       switch (e->type) {
21055 +       case VXH_THROW_OOPS:
21056 +               printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
21057 +               break;
21058 +
21059 +       case VXH_GET_VX_INFO:
21060 +       case VXH_PUT_VX_INFO:
21061 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
21062 +                       VXH_LOC_ARGS(e),
21063 +                       (e->type == VXH_GET_VX_INFO) ? "get" : "put",
21064 +                       VXH_VXI_ARGS(e));
21065 +               break;
21066 +
21067 +       case VXH_INIT_VX_INFO:
21068 +       case VXH_SET_VX_INFO:
21069 +       case VXH_CLR_VX_INFO:
21070 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
21071 +                       VXH_LOC_ARGS(e),
21072 +                       (e->type == VXH_INIT_VX_INFO) ? "init" :
21073 +                       ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
21074 +                       VXH_VXI_ARGS(e), e->sc.data);
21075 +               break;
21076 +
21077 +       case VXH_CLAIM_VX_INFO:
21078 +       case VXH_RELEASE_VX_INFO:
21079 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
21080 +                       VXH_LOC_ARGS(e),
21081 +                       (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
21082 +                       VXH_VXI_ARGS(e), e->sc.data);
21083 +               break;
21084 +
21085 +       case VXH_ALLOC_VX_INFO:
21086 +       case VXH_DEALLOC_VX_INFO:
21087 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
21088 +                       VXH_LOC_ARGS(e),
21089 +                       (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
21090 +                       VXH_VXI_ARGS(e));
21091 +               break;
21092 +
21093 +       case VXH_HASH_VX_INFO:
21094 +       case VXH_UNHASH_VX_INFO:
21095 +               printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
21096 +                       VXH_LOC_ARGS(e),
21097 +                       (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
21098 +                       VXH_VXI_ARGS(e));
21099 +               break;
21100 +
21101 +       case VXH_LOC_VX_INFO:
21102 +       case VXH_LOOKUP_VX_INFO:
21103 +       case VXH_CREATE_VX_INFO:
21104 +               printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
21105 +                       VXH_LOC_ARGS(e),
21106 +                       (e->type == VXH_CREATE_VX_INFO) ? "create" :
21107 +                       ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
21108 +                       e->ll.arg, VXH_VXI_ARGS(e));
21109 +               break;
21110 +       }
21111 +}
21112 +
21113 +static void __vxh_dump_history(void)
21114 +{
21115 +       unsigned int i, cpu;
21116 +
21117 +       printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
21118 +               atomic_read(&sequence), NR_CPUS);
21119 +
21120 +       for (i = 0; i < VXH_SIZE; i++) {
21121 +               for_each_online_cpu(cpu) {
21122 +                       struct _vx_history *hist =
21123 +                               &per_cpu(vx_history_buffer, cpu);
21124 +                       unsigned int index = (hist->counter - i) % VXH_SIZE;
21125 +                       struct _vx_hist_entry *entry = &hist->entry[index];
21126 +
21127 +                       vxh_dump_entry(entry, cpu);
21128 +               }
21129 +       }
21130 +}
21131 +
21132 +void   vxh_dump_history(void)
21133 +{
21134 +       vxh_active = 0;
21135 +#ifdef CONFIG_SMP
21136 +       local_irq_enable();
21137 +       smp_send_stop();
21138 +       local_irq_disable();
21139 +#endif
21140 +       __vxh_dump_history();
21141 +}
21142 +
21143 +
21144 +/* vserver syscall commands below here */
21145 +
21146 +
21147 +int vc_dump_history(uint32_t id)
21148 +{
21149 +       vxh_active = 0;
21150 +       __vxh_dump_history();
21151 +       vxh_active = 1;
21152 +
21153 +       return 0;
21154 +}
21155 +
21156 +
21157 +int do_read_history(struct __user _vx_hist_entry *data,
21158 +       int cpu, uint32_t *index, uint32_t *count)
21159 +{
21160 +       int pos, ret = 0;
21161 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
21162 +       int end = hist->counter;
21163 +       int start = end - VXH_SIZE + 2;
21164 +       int idx = *index;
21165 +
21166 +       /* special case: get current pos */
21167 +       if (!*count) {
21168 +               *index = end;
21169 +               return 0;
21170 +       }
21171 +
21172 +       /* have we lost some data? */
21173 +       if (idx < start)
21174 +               idx = start;
21175 +
21176 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21177 +               struct _vx_hist_entry *entry =
21178 +                       &hist->entry[idx % VXH_SIZE];
21179 +
21180 +               /* send entry to userspace */
21181 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21182 +               if (ret)
21183 +                       break;
21184 +       }
21185 +       /* save new index and count */
21186 +       *index = idx;
21187 +       *count = pos;
21188 +       return ret ? ret : (*index < end);
21189 +}
21190 +
21191 +int vc_read_history(uint32_t id, void __user *data)
21192 +{
21193 +       struct vcmd_read_history_v0 vc_data;
21194 +       int ret;
21195 +
21196 +       if (id >= NR_CPUS)
21197 +               return -EINVAL;
21198 +
21199 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21200 +               return -EFAULT;
21201 +
21202 +       ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
21203 +               id, &vc_data.index, &vc_data.count);
21204 +
21205 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21206 +               return -EFAULT;
21207 +       return ret;
21208 +}
21209 +
21210 +#ifdef CONFIG_COMPAT
21211 +
21212 +int vc_read_history_x32(uint32_t id, void __user *data)
21213 +{
21214 +       struct vcmd_read_history_v0_x32 vc_data;
21215 +       int ret;
21216 +
21217 +       if (id >= NR_CPUS)
21218 +               return -EINVAL;
21219 +
21220 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21221 +               return -EFAULT;
21222 +
21223 +       ret = do_read_history((struct __user _vx_hist_entry *)
21224 +               compat_ptr(vc_data.data_ptr),
21225 +               id, &vc_data.index, &vc_data.count);
21226 +
21227 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21228 +               return -EFAULT;
21229 +       return ret;
21230 +}
21231 +
21232 +#endif /* CONFIG_COMPAT */
21233 +
21234 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/inet.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/inet.c
21235 --- linux-2.6.33.1/kernel/vserver/inet.c        1970-01-01 01:00:00.000000000 +0100
21236 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/inet.c        2010-02-25 12:02:16.000000000 +0100
21237 @@ -0,0 +1,225 @@
21238 +
21239 +#include <linux/in.h>
21240 +#include <linux/inetdevice.h>
21241 +#include <linux/vs_inet.h>
21242 +#include <linux/vs_inet6.h>
21243 +#include <linux/vserver/debug.h>
21244 +#include <net/route.h>
21245 +#include <net/addrconf.h>
21246 +
21247 +
21248 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
21249 +{
21250 +       int ret = 0;
21251 +
21252 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
21253 +               ret = 1;
21254 +       else {
21255 +               struct nx_addr_v4 *ptr;
21256 +
21257 +               for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
21258 +                       if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
21259 +                               ret = 1;
21260 +                               break;
21261 +                       }
21262 +               }
21263 +       }
21264 +
21265 +       vxdprintk(VXD_CBIT(net, 2),
21266 +               "nx_v4_addr_conflict(%p,%p): %d",
21267 +               nxi1, nxi2, ret);
21268 +
21269 +       return ret;
21270 +}
21271 +
21272 +
21273 +#ifdef CONFIG_IPV6
21274 +
21275 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
21276 +{
21277 +       int ret = 0;
21278 +
21279 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
21280 +               ret = 1;
21281 +       else {
21282 +               struct nx_addr_v6 *ptr;
21283 +
21284 +               for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
21285 +                       if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
21286 +                               ret = 1;
21287 +                               break;
21288 +                       }
21289 +               }
21290 +       }
21291 +
21292 +       vxdprintk(VXD_CBIT(net, 2),
21293 +               "nx_v6_addr_conflict(%p,%p): %d",
21294 +               nxi1, nxi2, ret);
21295 +
21296 +       return ret;
21297 +}
21298 +
21299 +#endif
21300 +
21301 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21302 +{
21303 +       struct in_device *in_dev;
21304 +       struct in_ifaddr **ifap;
21305 +       struct in_ifaddr *ifa;
21306 +       int ret = 0;
21307 +
21308 +       if (!dev)
21309 +               goto out;
21310 +       in_dev = in_dev_get(dev);
21311 +       if (!in_dev)
21312 +               goto out;
21313 +
21314 +       for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
21315 +               ifap = &ifa->ifa_next) {
21316 +               if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
21317 +                       ret = 1;
21318 +                       break;
21319 +               }
21320 +       }
21321 +       in_dev_put(in_dev);
21322 +out:
21323 +       return ret;
21324 +}
21325 +
21326 +
21327 +#ifdef CONFIG_IPV6
21328 +
21329 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21330 +{
21331 +       struct inet6_dev *in_dev;
21332 +       struct inet6_ifaddr **ifap;
21333 +       struct inet6_ifaddr *ifa;
21334 +       int ret = 0;
21335 +
21336 +       if (!dev)
21337 +               goto out;
21338 +       in_dev = in6_dev_get(dev);
21339 +       if (!in_dev)
21340 +               goto out;
21341 +
21342 +       for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
21343 +               ifap = &ifa->if_next) {
21344 +               if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
21345 +                       ret = 1;
21346 +                       break;
21347 +               }
21348 +       }
21349 +       in6_dev_put(in_dev);
21350 +out:
21351 +       return ret;
21352 +}
21353 +
21354 +#endif
21355 +
21356 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21357 +{
21358 +       int ret = 1;
21359 +
21360 +       if (!nxi)
21361 +               goto out;
21362 +       if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
21363 +               goto out;
21364 +#ifdef CONFIG_IPV6
21365 +       ret = 2;
21366 +       if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
21367 +               goto out;
21368 +#endif
21369 +       ret = 0;
21370 +out:
21371 +       vxdprintk(VXD_CBIT(net, 3),
21372 +               "dev_in_nx_info(%p,%p[#%d]) = %d",
21373 +               dev, nxi, nxi ? nxi->nx_id : 0, ret);
21374 +       return ret;
21375 +}
21376 +
21377 +int ip_v4_find_src(struct net *net, struct nx_info *nxi,
21378 +       struct rtable **rp, struct flowi *fl)
21379 +{
21380 +       if (!nxi)
21381 +               return 0;
21382 +
21383 +       /* FIXME: handle lback only case */
21384 +       if (!NX_IPV4(nxi))
21385 +               return -EPERM;
21386 +
21387 +       vxdprintk(VXD_CBIT(net, 4),
21388 +               "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
21389 +               nxi, nxi ? nxi->nx_id : 0,
21390 +               NIPQUAD(fl->fl4_src), NIPQUAD(fl->fl4_dst));
21391 +
21392 +       /* single IP is unconditional */
21393 +       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
21394 +               (fl->fl4_src == INADDR_ANY))
21395 +               fl->fl4_src = nxi->v4.ip[0].s_addr;
21396 +
21397 +       if (fl->fl4_src == INADDR_ANY) {
21398 +               struct nx_addr_v4 *ptr;
21399 +               __be32 found = 0;
21400 +               int err;
21401 +
21402 +               err = __ip_route_output_key(net, rp, fl);
21403 +               if (!err) {
21404 +                       found = (*rp)->rt_src;
21405 +                       ip_rt_put(*rp);
21406 +                       vxdprintk(VXD_CBIT(net, 4),
21407 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21408 +                               nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(found));
21409 +                       if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
21410 +                               goto found;
21411 +               }
21412 +
21413 +               for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
21414 +                       __be32 primary = ptr->ip[0].s_addr;
21415 +                       __be32 mask = ptr->mask.s_addr;
21416 +                       __be32 neta = primary & mask;
21417 +
21418 +                       vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
21419 +                               NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
21420 +                               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
21421 +                               NIPQUAD(mask), NIPQUAD(neta));
21422 +                       if ((found & mask) != neta)
21423 +                               continue;
21424 +
21425 +                       fl->fl4_src = primary;
21426 +                       err = __ip_route_output_key(net, rp, fl);
21427 +                       vxdprintk(VXD_CBIT(net, 4),
21428 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21429 +                               nxi, nxi ? nxi->nx_id : 0, fl->oif, NIPQUAD(primary));
21430 +                       if (!err) {
21431 +                               found = (*rp)->rt_src;
21432 +                               ip_rt_put(*rp);
21433 +                               if (found == primary)
21434 +                                       goto found;
21435 +                       }
21436 +               }
21437 +               /* still no source ip? */
21438 +               found = ipv4_is_loopback(fl->fl4_dst)
21439 +                       ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
21440 +       found:
21441 +               /* assign src ip to flow */
21442 +               fl->fl4_src = found;
21443 +
21444 +       } else {
21445 +               if (!v4_addr_in_nx_info(nxi, fl->fl4_src, NXA_MASK_BIND))
21446 +                       return -EPERM;
21447 +       }
21448 +
21449 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
21450 +               if (ipv4_is_loopback(fl->fl4_dst))
21451 +                       fl->fl4_dst = nxi->v4_lback.s_addr;
21452 +               if (ipv4_is_loopback(fl->fl4_src))
21453 +                       fl->fl4_src = nxi->v4_lback.s_addr;
21454 +       } else if (ipv4_is_loopback(fl->fl4_dst) &&
21455 +               !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
21456 +               return -EPERM;
21457 +
21458 +       return 0;
21459 +}
21460 +
21461 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
21462 +
21463 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/init.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/init.c
21464 --- linux-2.6.33.1/kernel/vserver/init.c        1970-01-01 01:00:00.000000000 +0100
21465 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/init.c        2010-02-25 12:02:16.000000000 +0100
21466 @@ -0,0 +1,45 @@
21467 +/*
21468 + *  linux/kernel/init.c
21469 + *
21470 + *  Virtual Server Init
21471 + *
21472 + *  Copyright (C) 2004-2007  Herbert Pötzl
21473 + *
21474 + *  V0.01  basic structure
21475 + *
21476 + */
21477 +
21478 +#include <linux/init.h>
21479 +
21480 +int    vserver_register_sysctl(void);
21481 +void   vserver_unregister_sysctl(void);
21482 +
21483 +
21484 +static int __init init_vserver(void)
21485 +{
21486 +       int ret = 0;
21487 +
21488 +#ifdef CONFIG_VSERVER_DEBUG
21489 +       vserver_register_sysctl();
21490 +#endif
21491 +       return ret;
21492 +}
21493 +
21494 +
21495 +static void __exit exit_vserver(void)
21496 +{
21497 +
21498 +#ifdef CONFIG_VSERVER_DEBUG
21499 +       vserver_unregister_sysctl();
21500 +#endif
21501 +       return;
21502 +}
21503 +
21504 +/* FIXME: GFP_ZONETYPES gone
21505 +long vx_slab[GFP_ZONETYPES]; */
21506 +long vx_area;
21507 +
21508 +
21509 +module_init(init_vserver);
21510 +module_exit(exit_vserver);
21511 +
21512 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/inode.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/inode.c
21513 --- linux-2.6.33.1/kernel/vserver/inode.c       1970-01-01 01:00:00.000000000 +0100
21514 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/inode.c       2010-02-25 12:02:16.000000000 +0100
21515 @@ -0,0 +1,433 @@
21516 +/*
21517 + *  linux/kernel/vserver/inode.c
21518 + *
21519 + *  Virtual Server: File System Support
21520 + *
21521 + *  Copyright (C) 2004-2007  Herbert Pötzl
21522 + *
21523 + *  V0.01  separated from vcontext V0.05
21524 + *  V0.02  moved to tag (instead of xid)
21525 + *
21526 + */
21527 +
21528 +#include <linux/tty.h>
21529 +#include <linux/proc_fs.h>
21530 +#include <linux/devpts_fs.h>
21531 +#include <linux/fs.h>
21532 +#include <linux/file.h>
21533 +#include <linux/mount.h>
21534 +#include <linux/parser.h>
21535 +#include <linux/namei.h>
21536 +#include <linux/vserver/inode.h>
21537 +#include <linux/vserver/inode_cmd.h>
21538 +#include <linux/vs_base.h>
21539 +#include <linux/vs_tag.h>
21540 +
21541 +#include <asm/uaccess.h>
21542 +
21543 +
21544 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21545 +{
21546 +       struct proc_dir_entry *entry;
21547 +
21548 +       if (!in || !in->i_sb)
21549 +               return -ESRCH;
21550 +
21551 +       *flags = IATTR_TAG
21552 +               | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21553 +               | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21554 +               | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21555 +               | (IS_COW(in) ? IATTR_COW : 0);
21556 +       *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21557 +
21558 +       if (S_ISDIR(in->i_mode))
21559 +               *mask |= IATTR_BARRIER;
21560 +
21561 +       if (IS_TAGGED(in)) {
21562 +               *tag = in->i_tag;
21563 +               *mask |= IATTR_TAG;
21564 +       }
21565 +
21566 +       switch (in->i_sb->s_magic) {
21567 +       case PROC_SUPER_MAGIC:
21568 +               entry = PROC_I(in)->pde;
21569 +
21570 +               /* check for specific inodes? */
21571 +               if (entry)
21572 +                       *mask |= IATTR_FLAGS;
21573 +               if (entry)
21574 +                       *flags |= (entry->vx_flags & IATTR_FLAGS);
21575 +               else
21576 +                       *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21577 +               break;
21578 +
21579 +       case DEVPTS_SUPER_MAGIC:
21580 +               *tag = in->i_tag;
21581 +               *mask |= IATTR_TAG;
21582 +               break;
21583 +
21584 +       default:
21585 +               break;
21586 +       }
21587 +       return 0;
21588 +}
21589 +
21590 +int vc_get_iattr(void __user *data)
21591 +{
21592 +       struct path path;
21593 +       struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21594 +       int ret;
21595 +
21596 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21597 +               return -EFAULT;
21598 +
21599 +       ret = user_lpath(vc_data.name, &path);
21600 +       if (!ret) {
21601 +               ret = __vc_get_iattr(path.dentry->d_inode,
21602 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21603 +               path_put(&path);
21604 +       }
21605 +       if (ret)
21606 +               return ret;
21607 +
21608 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21609 +               ret = -EFAULT;
21610 +       return ret;
21611 +}
21612 +
21613 +#ifdef CONFIG_COMPAT
21614 +
21615 +int vc_get_iattr_x32(void __user *data)
21616 +{
21617 +       struct path path;
21618 +       struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21619 +       int ret;
21620 +
21621 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21622 +               return -EFAULT;
21623 +
21624 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21625 +       if (!ret) {
21626 +               ret = __vc_get_iattr(path.dentry->d_inode,
21627 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21628 +               path_put(&path);
21629 +       }
21630 +       if (ret)
21631 +               return ret;
21632 +
21633 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21634 +               ret = -EFAULT;
21635 +       return ret;
21636 +}
21637 +
21638 +#endif /* CONFIG_COMPAT */
21639 +
21640 +
21641 +int vc_fget_iattr(uint32_t fd, void __user *data)
21642 +{
21643 +       struct file *filp;
21644 +       struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21645 +       int ret;
21646 +
21647 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21648 +               return -EFAULT;
21649 +
21650 +       filp = fget(fd);
21651 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21652 +               return -EBADF;
21653 +
21654 +       ret = __vc_get_iattr(filp->f_dentry->d_inode,
21655 +               &vc_data.tag, &vc_data.flags, &vc_data.mask);
21656 +
21657 +       fput(filp);
21658 +
21659 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21660 +               ret = -EFAULT;
21661 +       return ret;
21662 +}
21663 +
21664 +
21665 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21666 +{
21667 +       struct inode *in = de->d_inode;
21668 +       int error = 0, is_proc = 0, has_tag = 0;
21669 +       struct iattr attr = { 0 };
21670 +
21671 +       if (!in || !in->i_sb)
21672 +               return -ESRCH;
21673 +
21674 +       is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21675 +       if ((*mask & IATTR_FLAGS) && !is_proc)
21676 +               return -EINVAL;
21677 +
21678 +       has_tag = IS_TAGGED(in) ||
21679 +               (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21680 +       if ((*mask & IATTR_TAG) && !has_tag)
21681 +               return -EINVAL;
21682 +
21683 +       mutex_lock(&in->i_mutex);
21684 +       if (*mask & IATTR_TAG) {
21685 +               attr.ia_tag = *tag;
21686 +               attr.ia_valid |= ATTR_TAG;
21687 +       }
21688 +
21689 +       if (*mask & IATTR_FLAGS) {
21690 +               struct proc_dir_entry *entry = PROC_I(in)->pde;
21691 +               unsigned int iflags = PROC_I(in)->vx_flags;
21692 +
21693 +               iflags = (iflags & ~(*mask & IATTR_FLAGS))
21694 +                       | (*flags & IATTR_FLAGS);
21695 +               PROC_I(in)->vx_flags = iflags;
21696 +               if (entry)
21697 +                       entry->vx_flags = iflags;
21698 +       }
21699 +
21700 +       if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21701 +               IATTR_BARRIER | IATTR_COW)) {
21702 +               int iflags = in->i_flags;
21703 +               int vflags = in->i_vflags;
21704 +
21705 +               if (*mask & IATTR_IMMUTABLE) {
21706 +                       if (*flags & IATTR_IMMUTABLE)
21707 +                               iflags |= S_IMMUTABLE;
21708 +                       else
21709 +                               iflags &= ~S_IMMUTABLE;
21710 +               }
21711 +               if (*mask & IATTR_IXUNLINK) {
21712 +                       if (*flags & IATTR_IXUNLINK)
21713 +                               iflags |= S_IXUNLINK;
21714 +                       else
21715 +                               iflags &= ~S_IXUNLINK;
21716 +               }
21717 +               if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21718 +                       if (*flags & IATTR_BARRIER)
21719 +                               vflags |= V_BARRIER;
21720 +                       else
21721 +                               vflags &= ~V_BARRIER;
21722 +               }
21723 +               if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21724 +                       if (*flags & IATTR_COW)
21725 +                               vflags |= V_COW;
21726 +                       else
21727 +                               vflags &= ~V_COW;
21728 +               }
21729 +               if (in->i_op && in->i_op->sync_flags) {
21730 +                       error = in->i_op->sync_flags(in, iflags, vflags);
21731 +                       if (error)
21732 +                               goto out;
21733 +               }
21734 +       }
21735 +
21736 +       if (attr.ia_valid) {
21737 +               if (in->i_op && in->i_op->setattr)
21738 +                       error = in->i_op->setattr(de, &attr);
21739 +               else {
21740 +                       error = inode_change_ok(in, &attr);
21741 +                       if (!error)
21742 +                               error = inode_setattr(in, &attr);
21743 +               }
21744 +       }
21745 +
21746 +out:
21747 +       mutex_unlock(&in->i_mutex);
21748 +       return error;
21749 +}
21750 +
21751 +int vc_set_iattr(void __user *data)
21752 +{
21753 +       struct path path;
21754 +       struct vcmd_ctx_iattr_v1 vc_data;
21755 +       int ret;
21756 +
21757 +       if (!capable(CAP_LINUX_IMMUTABLE))
21758 +               return -EPERM;
21759 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21760 +               return -EFAULT;
21761 +
21762 +       ret = user_lpath(vc_data.name, &path);
21763 +       if (!ret) {
21764 +               ret = __vc_set_iattr(path.dentry,
21765 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21766 +               path_put(&path);
21767 +       }
21768 +
21769 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21770 +               ret = -EFAULT;
21771 +       return ret;
21772 +}
21773 +
21774 +#ifdef CONFIG_COMPAT
21775 +
21776 +int vc_set_iattr_x32(void __user *data)
21777 +{
21778 +       struct path path;
21779 +       struct vcmd_ctx_iattr_v1_x32 vc_data;
21780 +       int ret;
21781 +
21782 +       if (!capable(CAP_LINUX_IMMUTABLE))
21783 +               return -EPERM;
21784 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21785 +               return -EFAULT;
21786 +
21787 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21788 +       if (!ret) {
21789 +               ret = __vc_set_iattr(path.dentry,
21790 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21791 +               path_put(&path);
21792 +       }
21793 +
21794 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21795 +               ret = -EFAULT;
21796 +       return ret;
21797 +}
21798 +
21799 +#endif /* CONFIG_COMPAT */
21800 +
21801 +int vc_fset_iattr(uint32_t fd, void __user *data)
21802 +{
21803 +       struct file *filp;
21804 +       struct vcmd_ctx_fiattr_v0 vc_data;
21805 +       int ret;
21806 +
21807 +       if (!capable(CAP_LINUX_IMMUTABLE))
21808 +               return -EPERM;
21809 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21810 +               return -EFAULT;
21811 +
21812 +       filp = fget(fd);
21813 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21814 +               return -EBADF;
21815 +
21816 +       ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21817 +               &vc_data.flags, &vc_data.mask);
21818 +
21819 +       fput(filp);
21820 +
21821 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21822 +               return -EFAULT;
21823 +       return ret;
21824 +}
21825 +
21826 +
21827 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21828 +
21829 +static match_table_t tokens = {
21830 +       {Opt_notagcheck, "notagcheck"},
21831 +#ifdef CONFIG_PROPAGATE
21832 +       {Opt_notag, "notag"},
21833 +       {Opt_tag, "tag"},
21834 +       {Opt_tagid, "tagid=%u"},
21835 +#endif
21836 +       {Opt_err, NULL}
21837 +};
21838 +
21839 +
21840 +static void __dx_parse_remove(char *string, char *opt)
21841 +{
21842 +       char *p = strstr(string, opt);
21843 +       char *q = p;
21844 +
21845 +       if (p) {
21846 +               while (*q != '\0' && *q != ',')
21847 +                       q++;
21848 +               while (*q)
21849 +                       *p++ = *q++;
21850 +               while (*p)
21851 +                       *p++ = '\0';
21852 +       }
21853 +}
21854 +
21855 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21856 +                unsigned long *flags)
21857 +{
21858 +       int set = 0;
21859 +       substring_t args[MAX_OPT_ARGS];
21860 +       int token, option = 0;
21861 +       char *s, *p, *opts;
21862 +
21863 +       if (!string)
21864 +               return 0;
21865 +       s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21866 +       if (!s)
21867 +               return 0;
21868 +
21869 +       opts = s;
21870 +       while ((p = strsep(&opts, ",")) != NULL) {
21871 +               token = match_token(p, tokens, args);
21872 +
21873 +               vxdprintk(VXD_CBIT(tag, 7),
21874 +                       "dx_parse_tag(»%s«): %d:#%d",
21875 +                       p, token, option);
21876 +
21877 +               switch (token) {
21878 +#ifdef CONFIG_PROPAGATE
21879 +               case Opt_tag:
21880 +                       if (tag)
21881 +                               *tag = 0;
21882 +                       if (remove)
21883 +                               __dx_parse_remove(s, "tag");
21884 +                       *mnt_flags |= MNT_TAGID;
21885 +                       set |= MNT_TAGID;
21886 +                       break;
21887 +               case Opt_notag:
21888 +                       if (remove)
21889 +                               __dx_parse_remove(s, "notag");
21890 +                       *mnt_flags |= MNT_NOTAG;
21891 +                       set |= MNT_NOTAG;
21892 +                       break;
21893 +               case Opt_tagid:
21894 +                       if (tag && !match_int(args, &option))
21895 +                               *tag = option;
21896 +                       if (remove)
21897 +                               __dx_parse_remove(s, "tagid");
21898 +                       *mnt_flags |= MNT_TAGID;
21899 +                       set |= MNT_TAGID;
21900 +                       break;
21901 +#endif
21902 +               case Opt_notagcheck:
21903 +                       if (remove)
21904 +                               __dx_parse_remove(s, "notagcheck");
21905 +                       *flags |= MS_NOTAGCHECK;
21906 +                       set |= MS_NOTAGCHECK;
21907 +                       break;
21908 +               }
21909 +       }
21910 +       if (set)
21911 +               strcpy(string, s);
21912 +       kfree(s);
21913 +       return set;
21914 +}
21915 +
21916 +#ifdef CONFIG_PROPAGATE
21917 +
21918 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21919 +{
21920 +       tag_t new_tag = 0;
21921 +       struct vfsmount *mnt;
21922 +       int propagate;
21923 +
21924 +       if (!nd)
21925 +               return;
21926 +       mnt = nd->path.mnt;
21927 +       if (!mnt)
21928 +               return;
21929 +
21930 +       propagate = (mnt->mnt_flags & MNT_TAGID);
21931 +       if (propagate)
21932 +               new_tag = mnt->mnt_tag;
21933 +
21934 +       vxdprintk(VXD_CBIT(tag, 7),
21935 +               "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21936 +               inode, inode->i_ino, inode->i_tag,
21937 +               new_tag, (propagate) ? 1 : 0);
21938 +
21939 +       if (propagate)
21940 +               inode->i_tag = new_tag;
21941 +}
21942 +
21943 +#include <linux/module.h>
21944 +
21945 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21946 +
21947 +#endif /* CONFIG_PROPAGATE */
21948 +
21949 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/Kconfig
21950 --- linux-2.6.33.1/kernel/vserver/Kconfig       1970-01-01 01:00:00.000000000 +0100
21951 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/Kconfig       2010-02-25 12:02:16.000000000 +0100
21952 @@ -0,0 +1,251 @@
21953 +#
21954 +# Linux VServer configuration
21955 +#
21956 +
21957 +menu "Linux VServer"
21958 +
21959 +config VSERVER_AUTO_LBACK
21960 +       bool    "Automatically Assign Loopback IP"
21961 +       default y
21962 +       help
21963 +         Automatically assign a guest specific loopback
21964 +         IP and add it to the kernel network stack on
21965 +         startup.
21966 +
21967 +config VSERVER_AUTO_SINGLE
21968 +       bool    "Automatic Single IP Special Casing"
21969 +       depends on EXPERIMENTAL
21970 +       default y
21971 +       help
21972 +         This allows network contexts with a single IP to
21973 +         automatically remap 0.0.0.0 bindings to that IP,
21974 +         avoiding further network checks and improving
21975 +         performance.
21976 +
21977 +         (note: such guests do not allow to change the ip
21978 +          on the fly and do not show loopback addresses)
21979 +
21980 +config VSERVER_COWBL
21981 +       bool    "Enable COW Immutable Link Breaking"
21982 +       default y
21983 +       help
21984 +         This enables the COW (Copy-On-Write) link break code.
21985 +         It allows you to treat unified files like normal files
21986 +         when writing to them (which will implicitely break the
21987 +         link and create a copy of the unified file)
21988 +
21989 +config VSERVER_VTIME
21990 +       bool    "Enable Virtualized Guest Time"
21991 +       depends on EXPERIMENTAL
21992 +       default n
21993 +       help
21994 +         This enables per guest time offsets to allow for
21995 +         adjusting the system clock individually per guest.
21996 +         this adds some overhead to the time functions and
21997 +         therefore should not be enabled without good reason.
21998 +
21999 +config VSERVER_DEVICE
22000 +       bool    "Enable Guest Device Mapping"
22001 +       depends on EXPERIMENTAL
22002 +       default n
22003 +       help
22004 +         This enables generic device remapping.
22005 +
22006 +config VSERVER_PROC_SECURE
22007 +       bool    "Enable Proc Security"
22008 +       depends on PROC_FS
22009 +       default y
22010 +       help
22011 +         This configures ProcFS security to initially hide
22012 +         non-process entries for all contexts except the main and
22013 +         spectator context (i.e. for all guests), which is a secure
22014 +         default.
22015 +
22016 +         (note: on 1.2x the entries were visible by default)
22017 +
22018 +config VSERVER_HARDCPU
22019 +       bool    "Enable Hard CPU Limits"
22020 +       default y
22021 +       help
22022 +         Activate the Hard CPU Limits
22023 +
22024 +         This will compile in code that allows the Token Bucket
22025 +         Scheduler to put processes on hold when a context's
22026 +         tokens are depleted (provided that its per-context
22027 +         sched_hard flag is set).
22028 +
22029 +         Processes belonging to that context will not be able
22030 +         to consume CPU resources again until a per-context
22031 +         configured minimum of tokens has been reached.
22032 +
22033 +config VSERVER_IDLETIME
22034 +       bool    "Avoid idle CPUs by skipping Time"
22035 +       depends on VSERVER_HARDCPU
22036 +       default y
22037 +       help
22038 +         This option allows the scheduler to artificially
22039 +         advance time (per cpu) when otherwise the idle
22040 +         task would be scheduled, thus keeping the cpu
22041 +         busy and sharing the available resources among
22042 +         certain contexts.
22043 +
22044 +config VSERVER_IDLELIMIT
22045 +       bool    "Limit the IDLE task"
22046 +       depends on VSERVER_HARDCPU
22047 +       default n
22048 +       help
22049 +         Limit the idle slices, so the the next context
22050 +         will be scheduled as soon as possible.
22051 +
22052 +         This might improve interactivity and latency, but
22053 +         will also marginally increase scheduling overhead.
22054 +
22055 +choice
22056 +       prompt  "Persistent Inode Tagging"
22057 +       default TAGGING_ID24
22058 +       help
22059 +         This adds persistent context information to filesystems
22060 +         mounted with the tagxid option. Tagging is a requirement
22061 +         for per-context disk limits and per-context quota.
22062 +
22063 +
22064 +config TAGGING_NONE
22065 +       bool    "Disabled"
22066 +       help
22067 +         do not store per-context information in inodes.
22068 +
22069 +config TAGGING_UID16
22070 +       bool    "UID16/GID32"
22071 +       help
22072 +         reduces UID to 16 bit, but leaves GID at 32 bit.
22073 +
22074 +config TAGGING_GID16
22075 +       bool    "UID32/GID16"
22076 +       help
22077 +         reduces GID to 16 bit, but leaves UID at 32 bit.
22078 +
22079 +config TAGGING_ID24
22080 +       bool    "UID24/GID24"
22081 +       help
22082 +         uses the upper 8bit from UID and GID for XID tagging
22083 +         which leaves 24bit for UID/GID each, which should be
22084 +         more than sufficient for normal use.
22085 +
22086 +config TAGGING_INTERN
22087 +       bool    "UID32/GID32"
22088 +       help
22089 +         this uses otherwise reserved inode fields in the on
22090 +         disk representation, which limits the use to a few
22091 +         filesystems (currently ext2 and ext3)
22092 +
22093 +endchoice
22094 +
22095 +config TAG_NFSD
22096 +       bool    "Tag NFSD User Auth and Files"
22097 +       default n
22098 +       help
22099 +         Enable this if you do want the in-kernel NFS
22100 +         Server to use the tagging specified above.
22101 +         (will require patched clients too)
22102 +
22103 +config VSERVER_PRIVACY
22104 +       bool    "Honor Privacy Aspects of Guests"
22105 +       default n
22106 +       help
22107 +         When enabled, most context checks will disallow
22108 +         access to structures assigned to a specific context,
22109 +         like ptys or loop devices.
22110 +
22111 +config VSERVER_CONTEXTS
22112 +       int     "Maximum number of Contexts (1-65533)"  if EMBEDDED
22113 +       range 1 65533
22114 +       default "768"   if 64BIT
22115 +       default "256"
22116 +       help
22117 +         This setting will optimize certain data structures
22118 +         and memory allocations according to the expected
22119 +         maximum.
22120 +
22121 +         note: this is not a strict upper limit.
22122 +
22123 +config VSERVER_WARN
22124 +       bool    "VServer Warnings"
22125 +       default y
22126 +       help
22127 +         This enables various runtime warnings, which will
22128 +         notify about potential manipulation attempts or
22129 +         resource shortage. It is generally considered to
22130 +         be a good idea to have that enabled.
22131 +
22132 +config VSERVER_DEBUG
22133 +       bool    "VServer Debugging Code"
22134 +       default n
22135 +       help
22136 +         Set this to yes if you want to be able to activate
22137 +         debugging output at runtime. It adds a very small
22138 +         overhead to all vserver related functions and
22139 +         increases the kernel size by about 20k.
22140 +
22141 +config VSERVER_HISTORY
22142 +       bool    "VServer History Tracing"
22143 +       depends on VSERVER_DEBUG
22144 +       default n
22145 +       help
22146 +         Set this to yes if you want to record the history of
22147 +         linux-vserver activities, so they can be replayed in
22148 +         the event of a kernel panic or oops.
22149 +
22150 +config VSERVER_HISTORY_SIZE
22151 +       int     "Per-CPU History Size (32-65536)"
22152 +       depends on VSERVER_HISTORY
22153 +       range 32 65536
22154 +       default 64
22155 +       help
22156 +         This allows you to specify the number of entries in
22157 +         the per-CPU history buffer.
22158 +
22159 +config VSERVER_MONITOR
22160 +       bool    "VServer Scheduling Monitor"
22161 +       depends on VSERVER_DISABLED
22162 +       default n
22163 +       help
22164 +         Set this to yes if you want to record the scheduling
22165 +         decisions, so that they can be relayed to userspace
22166 +         for detailed analysis.
22167 +
22168 +config VSERVER_MONITOR_SIZE
22169 +       int     "Per-CPU Monitor Queue Size (32-65536)"
22170 +       depends on VSERVER_MONITOR
22171 +       range 32 65536
22172 +       default 1024
22173 +       help
22174 +         This allows you to specify the number of entries in
22175 +         the per-CPU scheduling monitor buffer.
22176 +
22177 +config VSERVER_MONITOR_SYNC
22178 +       int     "Per-CPU Monitor Sync Interval (0-65536)"
22179 +       depends on VSERVER_MONITOR
22180 +       range 0 65536
22181 +       default 256
22182 +       help
22183 +         This allows you to specify the interval in ticks
22184 +         when a time sync entry is inserted.
22185 +
22186 +endmenu
22187 +
22188 +
22189 +config VSERVER
22190 +       bool
22191 +       default y
22192 +       select NAMESPACES
22193 +       select UTS_NS
22194 +       select IPC_NS
22195 +       select USER_NS
22196 +       select SYSVIPC
22197 +
22198 +config VSERVER_SECURITY
22199 +       bool
22200 +       depends on SECURITY
22201 +       default y
22202 +       select SECURITY_CAPABILITIES
22203 +
22204 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/limit.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/limit.c
22205 --- linux-2.6.33.1/kernel/vserver/limit.c       1970-01-01 01:00:00.000000000 +0100
22206 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/limit.c       2010-03-23 19:51:30.000000000 +0100
22207 @@ -0,0 +1,392 @@
22208 +/*
22209 + *  linux/kernel/vserver/limit.c
22210 + *
22211 + *  Virtual Server: Context Limits
22212 + *
22213 + *  Copyright (C) 2004-2010  Herbert Pötzl
22214 + *
22215 + *  V0.01  broken out from vcontext V0.05
22216 + *  V0.02  changed vcmds to vxi arg
22217 + *  V0.03  added memory cgroup support
22218 + *
22219 + */
22220 +
22221 +#include <linux/sched.h>
22222 +#include <linux/module.h>
22223 +#include <linux/memcontrol.h>
22224 +#include <linux/res_counter.h>
22225 +#include <linux/vs_limit.h>
22226 +#include <linux/vserver/limit.h>
22227 +#include <linux/vserver/limit_cmd.h>
22228 +
22229 +#include <asm/uaccess.h>
22230 +
22231 +
22232 +const char *vlimit_name[NUM_LIMITS] = {
22233 +       [RLIMIT_CPU]            = "CPU",
22234 +       [RLIMIT_RSS]            = "RSS",
22235 +       [RLIMIT_NPROC]          = "NPROC",
22236 +       [RLIMIT_NOFILE]         = "NOFILE",
22237 +       [RLIMIT_MEMLOCK]        = "VML",
22238 +       [RLIMIT_AS]             = "VM",
22239 +       [RLIMIT_LOCKS]          = "LOCKS",
22240 +       [RLIMIT_SIGPENDING]     = "SIGP",
22241 +       [RLIMIT_MSGQUEUE]       = "MSGQ",
22242 +
22243 +       [VLIMIT_NSOCK]          = "NSOCK",
22244 +       [VLIMIT_OPENFD]         = "OPENFD",
22245 +       [VLIMIT_ANON]           = "ANON",
22246 +       [VLIMIT_SHMEM]          = "SHMEM",
22247 +       [VLIMIT_DENTRY]         = "DENTRY",
22248 +};
22249 +
22250 +EXPORT_SYMBOL_GPL(vlimit_name);
22251 +
22252 +#define MASK_ENTRY(x)  (1 << (x))
22253 +
22254 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
22255 +               /* minimum */
22256 +       0
22257 +       ,       /* softlimit */
22258 +       MASK_ENTRY( RLIMIT_RSS          ) |
22259 +       MASK_ENTRY( VLIMIT_ANON         ) |
22260 +       0
22261 +       ,       /* maximum */
22262 +       MASK_ENTRY( RLIMIT_RSS          ) |
22263 +       MASK_ENTRY( RLIMIT_NPROC        ) |
22264 +       MASK_ENTRY( RLIMIT_NOFILE       ) |
22265 +       MASK_ENTRY( RLIMIT_MEMLOCK      ) |
22266 +       MASK_ENTRY( RLIMIT_AS           ) |
22267 +       MASK_ENTRY( RLIMIT_LOCKS        ) |
22268 +       MASK_ENTRY( RLIMIT_MSGQUEUE     ) |
22269 +
22270 +       MASK_ENTRY( VLIMIT_NSOCK        ) |
22271 +       MASK_ENTRY( VLIMIT_OPENFD       ) |
22272 +       MASK_ENTRY( VLIMIT_ANON         ) |
22273 +       MASK_ENTRY( VLIMIT_SHMEM        ) |
22274 +       MASK_ENTRY( VLIMIT_DENTRY       ) |
22275 +       0
22276 +};
22277 +               /* accounting only */
22278 +uint32_t account_mask =
22279 +       MASK_ENTRY( VLIMIT_SEMARY       ) |
22280 +       MASK_ENTRY( VLIMIT_NSEMS        ) |
22281 +       MASK_ENTRY( VLIMIT_MAPPED       ) |
22282 +       0;
22283 +
22284 +
22285 +static int is_valid_vlimit(int id)
22286 +{
22287 +       uint32_t mask = vlimit_mask.minimum |
22288 +               vlimit_mask.softlimit | vlimit_mask.maximum;
22289 +       return mask & (1 << id);
22290 +}
22291 +
22292 +static int is_accounted_vlimit(int id)
22293 +{
22294 +       if (is_valid_vlimit(id))
22295 +               return 1;
22296 +       return account_mask & (1 << id);
22297 +}
22298 +
22299 +
22300 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
22301 +{
22302 +       rlim_t limit = __rlim_soft(&vxi->limit, id);
22303 +       return VX_VLIM(limit);
22304 +}
22305 +
22306 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
22307 +{
22308 +       rlim_t limit = __rlim_hard(&vxi->limit, id);
22309 +       return VX_VLIM(limit);
22310 +}
22311 +
22312 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
22313 +       uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
22314 +{
22315 +       if (!is_valid_vlimit(id))
22316 +               return -EINVAL;
22317 +
22318 +       if (minimum)
22319 +               *minimum = CRLIM_UNSET;
22320 +       if (softlimit)
22321 +               *softlimit = vc_get_soft(vxi, id);
22322 +       if (maximum)
22323 +               *maximum = vc_get_hard(vxi, id);
22324 +       return 0;
22325 +}
22326 +
22327 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
22328 +{
22329 +       struct vcmd_ctx_rlimit_v0 vc_data;
22330 +       int ret;
22331 +
22332 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22333 +               return -EFAULT;
22334 +
22335 +       ret = do_get_rlimit(vxi, vc_data.id,
22336 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22337 +       if (ret)
22338 +               return ret;
22339 +
22340 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22341 +               return -EFAULT;
22342 +       return 0;
22343 +}
22344 +
22345 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
22346 +       uint64_t minimum, uint64_t softlimit, uint64_t maximum)
22347 +{
22348 +       if (!is_valid_vlimit(id))
22349 +               return -EINVAL;
22350 +
22351 +       if (maximum != CRLIM_KEEP)
22352 +               __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
22353 +       if (softlimit != CRLIM_KEEP)
22354 +               __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
22355 +
22356 +       /* clamp soft limit */
22357 +       if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
22358 +               __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
22359 +
22360 +       return 0;
22361 +}
22362 +
22363 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
22364 +{
22365 +       struct vcmd_ctx_rlimit_v0 vc_data;
22366 +
22367 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22368 +               return -EFAULT;
22369 +
22370 +       return do_set_rlimit(vxi, vc_data.id,
22371 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22372 +}
22373 +
22374 +#ifdef CONFIG_IA32_EMULATION
22375 +
22376 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
22377 +{
22378 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
22379 +
22380 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22381 +               return -EFAULT;
22382 +
22383 +       return do_set_rlimit(vxi, vc_data.id,
22384 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22385 +}
22386 +
22387 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
22388 +{
22389 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
22390 +       int ret;
22391 +
22392 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22393 +               return -EFAULT;
22394 +
22395 +       ret = do_get_rlimit(vxi, vc_data.id,
22396 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22397 +       if (ret)
22398 +               return ret;
22399 +
22400 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22401 +               return -EFAULT;
22402 +       return 0;
22403 +}
22404 +
22405 +#endif /* CONFIG_IA32_EMULATION */
22406 +
22407 +
22408 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
22409 +{
22410 +       if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
22411 +               return -EFAULT;
22412 +       return 0;
22413 +}
22414 +
22415 +
22416 +static inline void vx_reset_hits(struct _vx_limit *limit)
22417 +{
22418 +       int lim;
22419 +
22420 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22421 +               atomic_set(&__rlim_lhit(limit, lim), 0);
22422 +       }
22423 +}
22424 +
22425 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
22426 +{
22427 +       vx_reset_hits(&vxi->limit);
22428 +       return 0;
22429 +}
22430 +
22431 +static inline void vx_reset_minmax(struct _vx_limit *limit)
22432 +{
22433 +       rlim_t value;
22434 +       int lim;
22435 +
22436 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22437 +               value = __rlim_get(limit, lim);
22438 +               __rlim_rmax(limit, lim) = value;
22439 +               __rlim_rmin(limit, lim) = value;
22440 +       }
22441 +}
22442 +
22443 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
22444 +{
22445 +       vx_reset_minmax(&vxi->limit);
22446 +       return 0;
22447 +}
22448 +
22449 +
22450 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
22451 +{
22452 +       struct vcmd_rlimit_stat_v0 vc_data;
22453 +       struct _vx_limit *limit = &vxi->limit;
22454 +       int id;
22455 +
22456 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22457 +               return -EFAULT;
22458 +
22459 +       id = vc_data.id;
22460 +       if (!is_accounted_vlimit(id))
22461 +               return -EINVAL;
22462 +
22463 +       vx_limit_fixup(limit, id);
22464 +       vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
22465 +       vc_data.value = __rlim_get(limit, id);
22466 +       vc_data.minimum = __rlim_rmin(limit, id);
22467 +       vc_data.maximum = __rlim_rmax(limit, id);
22468 +
22469 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22470 +               return -EFAULT;
22471 +       return 0;
22472 +}
22473 +
22474 +
22475 +void vx_vsi_meminfo(struct sysinfo *val)
22476 +{
22477 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22478 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22479 +       u64 res_limit, res_usage;
22480 +
22481 +       if (!mcg)
22482 +               return;
22483 +
22484 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22485 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22486 +
22487 +       if (res_limit != RESOURCE_MAX)
22488 +               val->totalram = (res_limit >> PAGE_SHIFT);
22489 +       val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
22490 +       val->bufferram = 0;
22491 +#else  /* !CONFIG_CGROUP_MEM_RES_CTLR */
22492 +       struct vx_info *vxi = current_vx_info();
22493 +       unsigned long totalram, freeram;
22494 +       rlim_t v;
22495 +
22496 +       /* we blindly accept the max */
22497 +       v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22498 +       totalram = (v != RLIM_INFINITY) ? v : val->totalram;
22499 +
22500 +       /* total minus used equals free */
22501 +       v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22502 +       freeram = (v < totalram) ? totalram - v : 0;
22503 +
22504 +       val->totalram = totalram;
22505 +       val->freeram = freeram;
22506 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22507 +       val->totalhigh = 0;
22508 +       val->freehigh = 0;
22509 +       return;
22510 +}
22511 +
22512 +void vx_vsi_swapinfo(struct sysinfo *val)
22513 +{
22514 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22515 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
22516 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22517 +       u64 res_limit, res_usage, memsw_limit, memsw_usage;
22518 +       s64 swap_limit, swap_usage;
22519 +
22520 +       if (!mcg)
22521 +               return;
22522 +
22523 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22524 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22525 +       memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
22526 +       memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
22527 +
22528 +       if (res_limit == RESOURCE_MAX)
22529 +               return;
22530 +
22531 +       swap_limit = memsw_limit - res_limit;
22532 +       if (memsw_limit != RESOURCE_MAX)
22533 +               val->totalswap = swap_limit >> PAGE_SHIFT;
22534 +
22535 +       swap_usage = memsw_usage - res_usage;
22536 +       val->freeswap = (swap_usage < swap_limit) ?
22537 +               val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
22538 +#else  /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22539 +       val->totalswap = 0;
22540 +       val->freeswap = 0;
22541 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22542 +#else  /* !CONFIG_CGROUP_MEM_RES_CTLR */
22543 +       struct vx_info *vxi = current_vx_info();
22544 +       unsigned long totalswap, freeswap;
22545 +       rlim_t v, w;
22546 +
22547 +       v = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22548 +       if (v == RLIM_INFINITY) {
22549 +               val->freeswap = val->totalswap;
22550 +               return;
22551 +       }
22552 +
22553 +       /* we blindly accept the max */
22554 +       w = __rlim_hard(&vxi->limit, RLIMIT_RSS);
22555 +       totalswap = (w != RLIM_INFINITY) ? (w - v) : val->totalswap;
22556 +
22557 +       /* currently 'used' swap */
22558 +       w = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22559 +       w -= (w > v) ? v : w;
22560 +
22561 +       /* total minus used equals free */
22562 +       freeswap = (w < totalswap) ? totalswap - w : 0;
22563 +
22564 +       val->totalswap = totalswap;
22565 +       val->freeswap = freeswap;
22566 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22567 +       return;
22568 +}
22569 +
22570 +long vx_vsi_cached(struct sysinfo *val)
22571 +{
22572 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22573 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22574 +
22575 +       return mem_cgroup_stat_read_cache(mcg);
22576 +#else
22577 +       return 0;
22578 +#endif
22579 +}
22580 +
22581 +
22582 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22583 +{
22584 +       struct vx_info *vxi = mm->mm_vx_info;
22585 +       unsigned long points;
22586 +       rlim_t v, w;
22587 +
22588 +       if (!vxi)
22589 +               return 0;
22590 +
22591 +       points = vxi->vx_badness_bias;
22592 +
22593 +       v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22594 +       w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22595 +       points += (v > w) ? (v - w) : 0;
22596 +
22597 +       return points;
22598 +}
22599 +
22600 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/limit_init.h linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/limit_init.h
22601 --- linux-2.6.33.1/kernel/vserver/limit_init.h  1970-01-01 01:00:00.000000000 +0100
22602 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/limit_init.h  2010-02-25 12:02:16.000000000 +0100
22603 @@ -0,0 +1,31 @@
22604 +
22605 +
22606 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22607 +{
22608 +       int lim;
22609 +
22610 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22611 +               __rlim_soft(limit, lim) = RLIM_INFINITY;
22612 +               __rlim_hard(limit, lim) = RLIM_INFINITY;
22613 +               __rlim_set(limit, lim, 0);
22614 +               atomic_set(&__rlim_lhit(limit, lim), 0);
22615 +               __rlim_rmin(limit, lim) = 0;
22616 +               __rlim_rmax(limit, lim) = 0;
22617 +       }
22618 +}
22619 +
22620 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22621 +{
22622 +       rlim_t value;
22623 +       int lim;
22624 +
22625 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22626 +               if ((1 << lim) & VLIM_NOCHECK)
22627 +                       continue;
22628 +               value = __rlim_get(limit, lim);
22629 +               vxwprintk_xid(value,
22630 +                       "!!! limit: %p[%s,%d] = %ld on exit.",
22631 +                       limit, vlimit_name[lim], lim, (long)value);
22632 +       }
22633 +}
22634 +
22635 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/limit_proc.h linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/limit_proc.h
22636 --- linux-2.6.33.1/kernel/vserver/limit_proc.h  1970-01-01 01:00:00.000000000 +0100
22637 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/limit_proc.h  2010-02-25 12:02:16.000000000 +0100
22638 @@ -0,0 +1,57 @@
22639 +#ifndef _VX_LIMIT_PROC_H
22640 +#define _VX_LIMIT_PROC_H
22641 +
22642 +#include <linux/vserver/limit_int.h>
22643 +
22644 +
22645 +#define VX_LIMIT_FMT   ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22646 +#define VX_LIMIT_TOP   \
22647 +       "Limit\t current\t     min/max\t\t    soft/hard\t\thits\n"
22648 +
22649 +#define VX_LIMIT_ARG(r)                                \
22650 +       (unsigned long)__rlim_get(limit, r),    \
22651 +       (unsigned long)__rlim_rmin(limit, r),   \
22652 +       (unsigned long)__rlim_rmax(limit, r),   \
22653 +       VX_VLIM(__rlim_soft(limit, r)),         \
22654 +       VX_VLIM(__rlim_hard(limit, r)),         \
22655 +       atomic_read(&__rlim_lhit(limit, r))
22656 +
22657 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22658 +{
22659 +       vx_limit_fixup(limit, -1);
22660 +       return sprintf(buffer, VX_LIMIT_TOP
22661 +               "PROC"  VX_LIMIT_FMT
22662 +               "VM"    VX_LIMIT_FMT
22663 +               "VML"   VX_LIMIT_FMT
22664 +               "RSS"   VX_LIMIT_FMT
22665 +               "ANON"  VX_LIMIT_FMT
22666 +               "RMAP"  VX_LIMIT_FMT
22667 +               "FILES" VX_LIMIT_FMT
22668 +               "OFD"   VX_LIMIT_FMT
22669 +               "LOCKS" VX_LIMIT_FMT
22670 +               "SOCK"  VX_LIMIT_FMT
22671 +               "MSGQ"  VX_LIMIT_FMT
22672 +               "SHM"   VX_LIMIT_FMT
22673 +               "SEMA"  VX_LIMIT_FMT
22674 +               "SEMS"  VX_LIMIT_FMT
22675 +               "DENT"  VX_LIMIT_FMT,
22676 +               VX_LIMIT_ARG(RLIMIT_NPROC),
22677 +               VX_LIMIT_ARG(RLIMIT_AS),
22678 +               VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22679 +               VX_LIMIT_ARG(RLIMIT_RSS),
22680 +               VX_LIMIT_ARG(VLIMIT_ANON),
22681 +               VX_LIMIT_ARG(VLIMIT_MAPPED),
22682 +               VX_LIMIT_ARG(RLIMIT_NOFILE),
22683 +               VX_LIMIT_ARG(VLIMIT_OPENFD),
22684 +               VX_LIMIT_ARG(RLIMIT_LOCKS),
22685 +               VX_LIMIT_ARG(VLIMIT_NSOCK),
22686 +               VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22687 +               VX_LIMIT_ARG(VLIMIT_SHMEM),
22688 +               VX_LIMIT_ARG(VLIMIT_SEMARY),
22689 +               VX_LIMIT_ARG(VLIMIT_NSEMS),
22690 +               VX_LIMIT_ARG(VLIMIT_DENTRY));
22691 +}
22692 +
22693 +#endif /* _VX_LIMIT_PROC_H */
22694 +
22695 +
22696 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/Makefile linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/Makefile
22697 --- linux-2.6.33.1/kernel/vserver/Makefile      1970-01-01 01:00:00.000000000 +0100
22698 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/Makefile      2010-02-25 12:02:16.000000000 +0100
22699 @@ -0,0 +1,18 @@
22700 +#
22701 +# Makefile for the Linux vserver routines.
22702 +#
22703 +
22704 +
22705 +obj-y          += vserver.o
22706 +
22707 +vserver-y      := switch.o context.o space.o sched.o network.o inode.o \
22708 +                  limit.o cvirt.o cacct.o signal.o helper.o init.o \
22709 +                  dlimit.o tag.o
22710 +
22711 +vserver-$(CONFIG_INET) += inet.o
22712 +vserver-$(CONFIG_PROC_FS) += proc.o
22713 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
22714 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
22715 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
22716 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
22717 +
22718 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/monitor.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/monitor.c
22719 --- linux-2.6.33.1/kernel/vserver/monitor.c     1970-01-01 01:00:00.000000000 +0100
22720 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/monitor.c     2010-02-25 12:02:16.000000000 +0100
22721 @@ -0,0 +1,138 @@
22722 +/*
22723 + *  kernel/vserver/monitor.c
22724 + *
22725 + *  Virtual Context Scheduler Monitor
22726 + *
22727 + *  Copyright (C) 2006-2007 Herbert Pötzl
22728 + *
22729 + *  V0.01  basic design
22730 + *
22731 + */
22732 +
22733 +#include <linux/module.h>
22734 +#include <linux/jiffies.h>
22735 +#include <asm/uaccess.h>
22736 +#include <asm/atomic.h>
22737 +
22738 +#include <linux/vserver/monitor.h>
22739 +#include <linux/vserver/debug_cmd.h>
22740 +
22741 +
22742 +#ifdef CONFIG_VSERVER_MONITOR
22743 +#define VXM_SIZE       CONFIG_VSERVER_MONITOR_SIZE
22744 +#else
22745 +#define VXM_SIZE       64
22746 +#endif
22747 +
22748 +struct _vx_monitor {
22749 +       unsigned int counter;
22750 +
22751 +       struct _vx_mon_entry entry[VXM_SIZE+1];
22752 +};
22753 +
22754 +
22755 +DEFINE_PER_CPU(struct _vx_monitor, vx_monitor_buffer);
22756 +
22757 +unsigned volatile int vxm_active = 1;
22758 +
22759 +static atomic_t sequence = ATOMIC_INIT(0);
22760 +
22761 +
22762 +/*     vxm_advance()
22763 +
22764 +       * requires disabled preemption                          */
22765 +
22766 +struct _vx_mon_entry *vxm_advance(int cpu)
22767 +{
22768 +       struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22769 +       struct _vx_mon_entry *entry;
22770 +       unsigned int index;
22771 +
22772 +       index = vxm_active ? (mon->counter++ % VXM_SIZE) : VXM_SIZE;
22773 +       entry = &mon->entry[index];
22774 +
22775 +       entry->ev.seq = atomic_inc_return(&sequence);
22776 +       entry->ev.jif = jiffies;
22777 +       return entry;
22778 +}
22779 +
22780 +EXPORT_SYMBOL_GPL(vxm_advance);
22781 +
22782 +
22783 +int do_read_monitor(struct __user _vx_mon_entry *data,
22784 +       int cpu, uint32_t *index, uint32_t *count)
22785 +{
22786 +       int pos, ret = 0;
22787 +       struct _vx_monitor *mon = &per_cpu(vx_monitor_buffer, cpu);
22788 +       int end = mon->counter;
22789 +       int start = end - VXM_SIZE + 2;
22790 +       int idx = *index;
22791 +
22792 +       /* special case: get current pos */
22793 +       if (!*count) {
22794 +               *index = end;
22795 +               return 0;
22796 +       }
22797 +
22798 +       /* have we lost some data? */
22799 +       if (idx < start)
22800 +               idx = start;
22801 +
22802 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
22803 +               struct _vx_mon_entry *entry =
22804 +                       &mon->entry[idx % VXM_SIZE];
22805 +
22806 +               /* send entry to userspace */
22807 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
22808 +               if (ret)
22809 +                       break;
22810 +       }
22811 +       /* save new index and count */
22812 +       *index = idx;
22813 +       *count = pos;
22814 +       return ret ? ret : (*index < end);
22815 +}
22816 +
22817 +int vc_read_monitor(uint32_t id, void __user *data)
22818 +{
22819 +       struct vcmd_read_monitor_v0 vc_data;
22820 +       int ret;
22821 +
22822 +       if (id >= NR_CPUS)
22823 +               return -EINVAL;
22824 +
22825 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22826 +               return -EFAULT;
22827 +
22828 +       ret = do_read_monitor((struct __user _vx_mon_entry *)vc_data.data,
22829 +               id, &vc_data.index, &vc_data.count);
22830 +
22831 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22832 +               return -EFAULT;
22833 +       return ret;
22834 +}
22835 +
22836 +#ifdef CONFIG_COMPAT
22837 +
22838 +int vc_read_monitor_x32(uint32_t id, void __user *data)
22839 +{
22840 +       struct vcmd_read_monitor_v0_x32 vc_data;
22841 +       int ret;
22842 +
22843 +       if (id >= NR_CPUS)
22844 +               return -EINVAL;
22845 +
22846 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22847 +               return -EFAULT;
22848 +
22849 +       ret = do_read_monitor((struct __user _vx_mon_entry *)
22850 +               compat_ptr(vc_data.data_ptr),
22851 +               id, &vc_data.index, &vc_data.count);
22852 +
22853 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22854 +               return -EFAULT;
22855 +       return ret;
22856 +}
22857 +
22858 +#endif /* CONFIG_COMPAT */
22859 +
22860 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/network.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/network.c
22861 --- linux-2.6.33.1/kernel/vserver/network.c     1970-01-01 01:00:00.000000000 +0100
22862 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/network.c     2010-02-25 12:02:16.000000000 +0100
22863 @@ -0,0 +1,864 @@
22864 +/*
22865 + *  linux/kernel/vserver/network.c
22866 + *
22867 + *  Virtual Server: Network Support
22868 + *
22869 + *  Copyright (C) 2003-2007  Herbert Pötzl
22870 + *
22871 + *  V0.01  broken out from vcontext V0.05
22872 + *  V0.02  cleaned up implementation
22873 + *  V0.03  added equiv nx commands
22874 + *  V0.04  switch to RCU based hash
22875 + *  V0.05  and back to locking again
22876 + *  V0.06  changed vcmds to nxi arg
22877 + *  V0.07  have __create claim() the nxi
22878 + *
22879 + */
22880 +
22881 +#include <linux/err.h>
22882 +#include <linux/slab.h>
22883 +#include <linux/rcupdate.h>
22884 +
22885 +#include <linux/vs_network.h>
22886 +#include <linux/vs_pid.h>
22887 +#include <linux/vserver/network_cmd.h>
22888 +
22889 +
22890 +atomic_t nx_global_ctotal      = ATOMIC_INIT(0);
22891 +atomic_t nx_global_cactive     = ATOMIC_INIT(0);
22892 +
22893 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22894 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22895 +
22896 +
22897 +static int __init init_network(void)
22898 +{
22899 +       nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22900 +               sizeof(struct nx_addr_v4), 0,
22901 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22902 +       nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22903 +               sizeof(struct nx_addr_v6), 0,
22904 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22905 +       return 0;
22906 +}
22907 +
22908 +
22909 +/*     __alloc_nx_addr_v4()                                    */
22910 +
22911 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22912 +{
22913 +       struct nx_addr_v4 *nxa = kmem_cache_alloc(
22914 +               nx_addr_v4_cachep, GFP_KERNEL);
22915 +
22916 +       if (!IS_ERR(nxa))
22917 +               memset(nxa, 0, sizeof(*nxa));
22918 +       return nxa;
22919 +}
22920 +
22921 +/*     __dealloc_nx_addr_v4()                                  */
22922 +
22923 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22924 +{
22925 +       kmem_cache_free(nx_addr_v4_cachep, nxa);
22926 +}
22927 +
22928 +/*     __dealloc_nx_addr_v4_all()                              */
22929 +
22930 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22931 +{
22932 +       while (nxa) {
22933 +               struct nx_addr_v4 *next = nxa->next;
22934 +
22935 +               __dealloc_nx_addr_v4(nxa);
22936 +               nxa = next;
22937 +       }
22938 +}
22939 +
22940 +
22941 +#ifdef CONFIG_IPV6
22942 +
22943 +/*     __alloc_nx_addr_v6()                                    */
22944 +
22945 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22946 +{
22947 +       struct nx_addr_v6 *nxa = kmem_cache_alloc(
22948 +               nx_addr_v6_cachep, GFP_KERNEL);
22949 +
22950 +       if (!IS_ERR(nxa))
22951 +               memset(nxa, 0, sizeof(*nxa));
22952 +       return nxa;
22953 +}
22954 +
22955 +/*     __dealloc_nx_addr_v6()                                  */
22956 +
22957 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22958 +{
22959 +       kmem_cache_free(nx_addr_v6_cachep, nxa);
22960 +}
22961 +
22962 +/*     __dealloc_nx_addr_v6_all()                              */
22963 +
22964 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22965 +{
22966 +       while (nxa) {
22967 +               struct nx_addr_v6 *next = nxa->next;
22968 +
22969 +               __dealloc_nx_addr_v6(nxa);
22970 +               nxa = next;
22971 +       }
22972 +}
22973 +
22974 +#endif /* CONFIG_IPV6 */
22975 +
22976 +/*     __alloc_nx_info()
22977 +
22978 +       * allocate an initialized nx_info struct
22979 +       * doesn't make it visible (hash)                        */
22980 +
22981 +static struct nx_info *__alloc_nx_info(nid_t nid)
22982 +{
22983 +       struct nx_info *new = NULL;
22984 +
22985 +       vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22986 +
22987 +       /* would this benefit from a slab cache? */
22988 +       new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22989 +       if (!new)
22990 +               return 0;
22991 +
22992 +       memset(new, 0, sizeof(struct nx_info));
22993 +       new->nx_id = nid;
22994 +       INIT_HLIST_NODE(&new->nx_hlist);
22995 +       atomic_set(&new->nx_usecnt, 0);
22996 +       atomic_set(&new->nx_tasks, 0);
22997 +       new->nx_state = 0;
22998 +
22999 +       new->nx_flags = NXF_INIT_SET;
23000 +
23001 +       /* rest of init goes here */
23002 +
23003 +       new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
23004 +       new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
23005 +
23006 +       vxdprintk(VXD_CBIT(nid, 0),
23007 +               "alloc_nx_info(%d) = %p", nid, new);
23008 +       atomic_inc(&nx_global_ctotal);
23009 +       return new;
23010 +}
23011 +
23012 +/*     __dealloc_nx_info()
23013 +
23014 +       * final disposal of nx_info                             */
23015 +
23016 +static void __dealloc_nx_info(struct nx_info *nxi)
23017 +{
23018 +       vxdprintk(VXD_CBIT(nid, 0),
23019 +               "dealloc_nx_info(%p)", nxi);
23020 +
23021 +       nxi->nx_hlist.next = LIST_POISON1;
23022 +       nxi->nx_id = -1;
23023 +
23024 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
23025 +       BUG_ON(atomic_read(&nxi->nx_tasks));
23026 +
23027 +       __dealloc_nx_addr_v4_all(nxi->v4.next);
23028 +
23029 +       nxi->nx_state |= NXS_RELEASED;
23030 +       kfree(nxi);
23031 +       atomic_dec(&nx_global_ctotal);
23032 +}
23033 +
23034 +static void __shutdown_nx_info(struct nx_info *nxi)
23035 +{
23036 +       nxi->nx_state |= NXS_SHUTDOWN;
23037 +       vs_net_change(nxi, VSC_NETDOWN);
23038 +}
23039 +
23040 +/*     exported stuff                                          */
23041 +
23042 +void free_nx_info(struct nx_info *nxi)
23043 +{
23044 +       /* context shutdown is mandatory */
23045 +       BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
23046 +
23047 +       /* context must not be hashed */
23048 +       BUG_ON(nxi->nx_state & NXS_HASHED);
23049 +
23050 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
23051 +       BUG_ON(atomic_read(&nxi->nx_tasks));
23052 +
23053 +       __dealloc_nx_info(nxi);
23054 +}
23055 +
23056 +
23057 +void __nx_set_lback(struct nx_info *nxi)
23058 +{
23059 +       int nid = nxi->nx_id;
23060 +       __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
23061 +
23062 +       nxi->v4_lback.s_addr = lback;
23063 +}
23064 +
23065 +extern int __nx_inet_add_lback(__be32 addr);
23066 +extern int __nx_inet_del_lback(__be32 addr);
23067 +
23068 +
23069 +/*     hash table for nx_info hash */
23070 +
23071 +#define NX_HASH_SIZE   13
23072 +
23073 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
23074 +
23075 +static spinlock_t nx_info_hash_lock = SPIN_LOCK_UNLOCKED;
23076 +
23077 +
23078 +static inline unsigned int __hashval(nid_t nid)
23079 +{
23080 +       return (nid % NX_HASH_SIZE);
23081 +}
23082 +
23083 +
23084 +
23085 +/*     __hash_nx_info()
23086 +
23087 +       * add the nxi to the global hash table
23088 +       * requires the hash_lock to be held                     */
23089 +
23090 +static inline void __hash_nx_info(struct nx_info *nxi)
23091 +{
23092 +       struct hlist_head *head;
23093 +
23094 +       vxd_assert_lock(&nx_info_hash_lock);
23095 +       vxdprintk(VXD_CBIT(nid, 4),
23096 +               "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
23097 +
23098 +       /* context must not be hashed */
23099 +       BUG_ON(nx_info_state(nxi, NXS_HASHED));
23100 +
23101 +       nxi->nx_state |= NXS_HASHED;
23102 +       head = &nx_info_hash[__hashval(nxi->nx_id)];
23103 +       hlist_add_head(&nxi->nx_hlist, head);
23104 +       atomic_inc(&nx_global_cactive);
23105 +}
23106 +
23107 +/*     __unhash_nx_info()
23108 +
23109 +       * remove the nxi from the global hash table
23110 +       * requires the hash_lock to be held                     */
23111 +
23112 +static inline void __unhash_nx_info(struct nx_info *nxi)
23113 +{
23114 +       vxd_assert_lock(&nx_info_hash_lock);
23115 +       vxdprintk(VXD_CBIT(nid, 4),
23116 +               "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
23117 +               atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
23118 +
23119 +       /* context must be hashed */
23120 +       BUG_ON(!nx_info_state(nxi, NXS_HASHED));
23121 +       /* but without tasks */
23122 +       BUG_ON(atomic_read(&nxi->nx_tasks));
23123 +
23124 +       nxi->nx_state &= ~NXS_HASHED;
23125 +       hlist_del(&nxi->nx_hlist);
23126 +       atomic_dec(&nx_global_cactive);
23127 +}
23128 +
23129 +
23130 +/*     __lookup_nx_info()
23131 +
23132 +       * requires the hash_lock to be held
23133 +       * doesn't increment the nx_refcnt                       */
23134 +
23135 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
23136 +{
23137 +       struct hlist_head *head = &nx_info_hash[__hashval(nid)];
23138 +       struct hlist_node *pos;
23139 +       struct nx_info *nxi;
23140 +
23141 +       vxd_assert_lock(&nx_info_hash_lock);
23142 +       hlist_for_each(pos, head) {
23143 +               nxi = hlist_entry(pos, struct nx_info, nx_hlist);
23144 +
23145 +               if (nxi->nx_id == nid)
23146 +                       goto found;
23147 +       }
23148 +       nxi = NULL;
23149 +found:
23150 +       vxdprintk(VXD_CBIT(nid, 0),
23151 +               "__lookup_nx_info(#%u): %p[#%u]",
23152 +               nid, nxi, nxi ? nxi->nx_id : 0);
23153 +       return nxi;
23154 +}
23155 +
23156 +
23157 +/*     __create_nx_info()
23158 +
23159 +       * create the requested context
23160 +       * get(), claim() and hash it                            */
23161 +
23162 +static struct nx_info *__create_nx_info(int id)
23163 +{
23164 +       struct nx_info *new, *nxi = NULL;
23165 +
23166 +       vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
23167 +
23168 +       if (!(new = __alloc_nx_info(id)))
23169 +               return ERR_PTR(-ENOMEM);
23170 +
23171 +       /* required to make dynamic xids unique */
23172 +       spin_lock(&nx_info_hash_lock);
23173 +
23174 +       /* static context requested */
23175 +       if ((nxi = __lookup_nx_info(id))) {
23176 +               vxdprintk(VXD_CBIT(nid, 0),
23177 +                       "create_nx_info(%d) = %p (already there)", id, nxi);
23178 +               if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
23179 +                       nxi = ERR_PTR(-EBUSY);
23180 +               else
23181 +                       nxi = ERR_PTR(-EEXIST);
23182 +               goto out_unlock;
23183 +       }
23184 +       /* new context */
23185 +       vxdprintk(VXD_CBIT(nid, 0),
23186 +               "create_nx_info(%d) = %p (new)", id, new);
23187 +       claim_nx_info(new, NULL);
23188 +       __nx_set_lback(new);
23189 +       __hash_nx_info(get_nx_info(new));
23190 +       nxi = new, new = NULL;
23191 +
23192 +out_unlock:
23193 +       spin_unlock(&nx_info_hash_lock);
23194 +       if (new)
23195 +               __dealloc_nx_info(new);
23196 +       return nxi;
23197 +}
23198 +
23199 +
23200 +
23201 +/*     exported stuff                                          */
23202 +
23203 +
23204 +void unhash_nx_info(struct nx_info *nxi)
23205 +{
23206 +       __shutdown_nx_info(nxi);
23207 +       spin_lock(&nx_info_hash_lock);
23208 +       __unhash_nx_info(nxi);
23209 +       spin_unlock(&nx_info_hash_lock);
23210 +}
23211 +
23212 +/*     lookup_nx_info()
23213 +
23214 +       * search for a nx_info and get() it
23215 +       * negative id means current                             */
23216 +
23217 +struct nx_info *lookup_nx_info(int id)
23218 +{
23219 +       struct nx_info *nxi = NULL;
23220 +
23221 +       if (id < 0) {
23222 +               nxi = get_nx_info(current_nx_info());
23223 +       } else if (id > 1) {
23224 +               spin_lock(&nx_info_hash_lock);
23225 +               nxi = get_nx_info(__lookup_nx_info(id));
23226 +               spin_unlock(&nx_info_hash_lock);
23227 +       }
23228 +       return nxi;
23229 +}
23230 +
23231 +/*     nid_is_hashed()
23232 +
23233 +       * verify that nid is still hashed                       */
23234 +
23235 +int nid_is_hashed(nid_t nid)
23236 +{
23237 +       int hashed;
23238 +
23239 +       spin_lock(&nx_info_hash_lock);
23240 +       hashed = (__lookup_nx_info(nid) != NULL);
23241 +       spin_unlock(&nx_info_hash_lock);
23242 +       return hashed;
23243 +}
23244 +
23245 +
23246 +#ifdef CONFIG_PROC_FS
23247 +
23248 +/*     get_nid_list()
23249 +
23250 +       * get a subset of hashed nids for proc
23251 +       * assumes size is at least one                          */
23252 +
23253 +int get_nid_list(int index, unsigned int *nids, int size)
23254 +{
23255 +       int hindex, nr_nids = 0;
23256 +
23257 +       /* only show current and children */
23258 +       if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
23259 +               if (index > 0)
23260 +                       return 0;
23261 +               nids[nr_nids] = nx_current_nid();
23262 +               return 1;
23263 +       }
23264 +
23265 +       for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
23266 +               struct hlist_head *head = &nx_info_hash[hindex];
23267 +               struct hlist_node *pos;
23268 +
23269 +               spin_lock(&nx_info_hash_lock);
23270 +               hlist_for_each(pos, head) {
23271 +                       struct nx_info *nxi;
23272 +
23273 +                       if (--index > 0)
23274 +                               continue;
23275 +
23276 +                       nxi = hlist_entry(pos, struct nx_info, nx_hlist);
23277 +                       nids[nr_nids] = nxi->nx_id;
23278 +                       if (++nr_nids >= size) {
23279 +                               spin_unlock(&nx_info_hash_lock);
23280 +                               goto out;
23281 +                       }
23282 +               }
23283 +               /* keep the lock time short */
23284 +               spin_unlock(&nx_info_hash_lock);
23285 +       }
23286 +out:
23287 +       return nr_nids;
23288 +}
23289 +#endif
23290 +
23291 +
23292 +/*
23293 + *     migrate task to new network
23294 + *     gets nxi, puts old_nxi on change
23295 + */
23296 +
23297 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
23298 +{
23299 +       struct nx_info *old_nxi;
23300 +       int ret = 0;
23301 +
23302 +       if (!p || !nxi)
23303 +               BUG();
23304 +
23305 +       vxdprintk(VXD_CBIT(nid, 5),
23306 +               "nx_migrate_task(%p,%p[#%d.%d.%d])",
23307 +               p, nxi, nxi->nx_id,
23308 +               atomic_read(&nxi->nx_usecnt),
23309 +               atomic_read(&nxi->nx_tasks));
23310 +
23311 +       if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
23312 +               !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
23313 +               return -EACCES;
23314 +
23315 +       if (nx_info_state(nxi, NXS_SHUTDOWN))
23316 +               return -EFAULT;
23317 +
23318 +       /* maybe disallow this completely? */
23319 +       old_nxi = task_get_nx_info(p);
23320 +       if (old_nxi == nxi)
23321 +               goto out;
23322 +
23323 +       task_lock(p);
23324 +       if (old_nxi)
23325 +               clr_nx_info(&p->nx_info);
23326 +       claim_nx_info(nxi, p);
23327 +       set_nx_info(&p->nx_info, nxi);
23328 +       p->nid = nxi->nx_id;
23329 +       task_unlock(p);
23330 +
23331 +       vxdprintk(VXD_CBIT(nid, 5),
23332 +               "moved task %p into nxi:%p[#%d]",
23333 +               p, nxi, nxi->nx_id);
23334 +
23335 +       if (old_nxi)
23336 +               release_nx_info(old_nxi, p);
23337 +       ret = 0;
23338 +out:
23339 +       put_nx_info(old_nxi);
23340 +       return ret;
23341 +}
23342 +
23343 +
23344 +void nx_set_persistent(struct nx_info *nxi)
23345 +{
23346 +       vxdprintk(VXD_CBIT(nid, 6),
23347 +               "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
23348 +
23349 +       get_nx_info(nxi);
23350 +       claim_nx_info(nxi, NULL);
23351 +}
23352 +
23353 +void nx_clear_persistent(struct nx_info *nxi)
23354 +{
23355 +       vxdprintk(VXD_CBIT(nid, 6),
23356 +               "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
23357 +
23358 +       release_nx_info(nxi, NULL);
23359 +       put_nx_info(nxi);
23360 +}
23361 +
23362 +void nx_update_persistent(struct nx_info *nxi)
23363 +{
23364 +       if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
23365 +               nx_set_persistent(nxi);
23366 +       else
23367 +               nx_clear_persistent(nxi);
23368 +}
23369 +
23370 +/* vserver syscall commands below here */
23371 +
23372 +/* taks nid and nx_info functions */
23373 +
23374 +#include <asm/uaccess.h>
23375 +
23376 +
23377 +int vc_task_nid(uint32_t id)
23378 +{
23379 +       nid_t nid;
23380 +
23381 +       if (id) {
23382 +               struct task_struct *tsk;
23383 +
23384 +               read_lock(&tasklist_lock);
23385 +               tsk = find_task_by_real_pid(id);
23386 +               nid = (tsk) ? tsk->nid : -ESRCH;
23387 +               read_unlock(&tasklist_lock);
23388 +       } else
23389 +               nid = nx_current_nid();
23390 +       return nid;
23391 +}
23392 +
23393 +
23394 +int vc_nx_info(struct nx_info *nxi, void __user *data)
23395 +{
23396 +       struct vcmd_nx_info_v0 vc_data;
23397 +
23398 +       vc_data.nid = nxi->nx_id;
23399 +
23400 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23401 +               return -EFAULT;
23402 +       return 0;
23403 +}
23404 +
23405 +
23406 +/* network functions */
23407 +
23408 +int vc_net_create(uint32_t nid, void __user *data)
23409 +{
23410 +       struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
23411 +       struct nx_info *new_nxi;
23412 +       int ret;
23413 +
23414 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23415 +               return -EFAULT;
23416 +
23417 +       if ((nid > MAX_S_CONTEXT) || (nid < 2))
23418 +               return -EINVAL;
23419 +
23420 +       new_nxi = __create_nx_info(nid);
23421 +       if (IS_ERR(new_nxi))
23422 +               return PTR_ERR(new_nxi);
23423 +
23424 +       /* initial flags */
23425 +       new_nxi->nx_flags = vc_data.flagword;
23426 +
23427 +       ret = -ENOEXEC;
23428 +       if (vs_net_change(new_nxi, VSC_NETUP))
23429 +               goto out;
23430 +
23431 +       ret = nx_migrate_task(current, new_nxi);
23432 +       if (ret)
23433 +               goto out;
23434 +
23435 +       /* return context id on success */
23436 +       ret = new_nxi->nx_id;
23437 +
23438 +       /* get a reference for persistent contexts */
23439 +       if ((vc_data.flagword & NXF_PERSISTENT))
23440 +               nx_set_persistent(new_nxi);
23441 +out:
23442 +       release_nx_info(new_nxi, NULL);
23443 +       put_nx_info(new_nxi);
23444 +       return ret;
23445 +}
23446 +
23447 +
23448 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
23449 +{
23450 +       return nx_migrate_task(current, nxi);
23451 +}
23452 +
23453 +
23454 +
23455 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
23456 +       uint16_t type, uint16_t flags)
23457 +{
23458 +       struct nx_addr_v4 *nxa = &nxi->v4;
23459 +
23460 +       if (NX_IPV4(nxi)) {
23461 +               /* locate last entry */
23462 +               for (; nxa->next; nxa = nxa->next);
23463 +               nxa->next = __alloc_nx_addr_v4();
23464 +               nxa = nxa->next;
23465 +
23466 +               if (IS_ERR(nxa))
23467 +                       return PTR_ERR(nxa);
23468 +       }
23469 +
23470 +       if (nxi->v4.next)
23471 +               /* remove single ip for ip list */
23472 +               nxi->nx_flags &= ~NXF_SINGLE_IP;
23473 +
23474 +       nxa->ip[0].s_addr = ip;
23475 +       nxa->ip[1].s_addr = ip2;
23476 +       nxa->mask.s_addr = mask;
23477 +       nxa->type = type;
23478 +       nxa->flags = flags;
23479 +       return 0;
23480 +}
23481 +
23482 +
23483 +int vc_net_add(struct nx_info *nxi, void __user *data)
23484 +{
23485 +       struct vcmd_net_addr_v0 vc_data;
23486 +       int index, ret = 0;
23487 +
23488 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23489 +               return -EFAULT;
23490 +
23491 +       switch (vc_data.type) {
23492 +       case NXA_TYPE_IPV4:
23493 +               if ((vc_data.count < 1) || (vc_data.count > 4))
23494 +                       return -EINVAL;
23495 +
23496 +               index = 0;
23497 +               while (index < vc_data.count) {
23498 +                       ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
23499 +                               vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
23500 +                       if (ret)
23501 +                               return ret;
23502 +                       index++;
23503 +               }
23504 +               ret = index;
23505 +               break;
23506 +
23507 +       case NXA_TYPE_IPV4|NXA_MOD_BCAST:
23508 +               nxi->v4_bcast = vc_data.ip[0];
23509 +               ret = 1;
23510 +               break;
23511 +
23512 +       case NXA_TYPE_IPV4|NXA_MOD_LBACK:
23513 +               nxi->v4_lback = vc_data.ip[0];
23514 +               ret = 1;
23515 +               break;
23516 +
23517 +       default:
23518 +               ret = -EINVAL;
23519 +               break;
23520 +       }
23521 +       return ret;
23522 +}
23523 +
23524 +int vc_net_remove(struct nx_info *nxi, void __user *data)
23525 +{
23526 +       struct vcmd_net_addr_v0 vc_data;
23527 +
23528 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23529 +               return -EFAULT;
23530 +
23531 +       switch (vc_data.type) {
23532 +       case NXA_TYPE_ANY:
23533 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23534 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
23535 +               break;
23536 +
23537 +       default:
23538 +               return -EINVAL;
23539 +       }
23540 +       return 0;
23541 +}
23542 +
23543 +
23544 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
23545 +{
23546 +       struct vcmd_net_addr_ipv4_v1 vc_data;
23547 +
23548 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23549 +               return -EFAULT;
23550 +
23551 +       switch (vc_data.type) {
23552 +       case NXA_TYPE_ADDR:
23553 +       case NXA_TYPE_RANGE:
23554 +       case NXA_TYPE_MASK:
23555 +               return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
23556 +                       vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23557 +
23558 +       case NXA_TYPE_ADDR | NXA_MOD_BCAST:
23559 +               nxi->v4_bcast = vc_data.ip;
23560 +               break;
23561 +
23562 +       case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23563 +               nxi->v4_lback = vc_data.ip;
23564 +               break;
23565 +
23566 +       default:
23567 +               return -EINVAL;
23568 +       }
23569 +       return 0;
23570 +}
23571 +
23572 +int vc_net_remove_ipv4(struct nx_info *nxi, void __user *data)
23573 +{
23574 +       struct vcmd_net_addr_ipv4_v1 vc_data;
23575 +
23576 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23577 +               return -EFAULT;
23578 +
23579 +       switch (vc_data.type) {
23580 +/*     case NXA_TYPE_ADDR:
23581 +               break;          */
23582 +
23583 +       case NXA_TYPE_ANY:
23584 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23585 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
23586 +               break;
23587 +
23588 +       default:
23589 +               return -EINVAL;
23590 +       }
23591 +       return 0;
23592 +}
23593 +
23594 +
23595 +#ifdef CONFIG_IPV6
23596 +
23597 +int do_add_v6_addr(struct nx_info *nxi,
23598 +       struct in6_addr *ip, struct in6_addr *mask,
23599 +       uint32_t prefix, uint16_t type, uint16_t flags)
23600 +{
23601 +       struct nx_addr_v6 *nxa = &nxi->v6;
23602 +
23603 +       if (NX_IPV6(nxi)) {
23604 +               /* locate last entry */
23605 +               for (; nxa->next; nxa = nxa->next);
23606 +               nxa->next = __alloc_nx_addr_v6();
23607 +               nxa = nxa->next;
23608 +
23609 +               if (IS_ERR(nxa))
23610 +                       return PTR_ERR(nxa);
23611 +       }
23612 +
23613 +       nxa->ip = *ip;
23614 +       nxa->mask = *mask;
23615 +       nxa->prefix = prefix;
23616 +       nxa->type = type;
23617 +       nxa->flags = flags;
23618 +       return 0;
23619 +}
23620 +
23621 +
23622 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23623 +{
23624 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23625 +
23626 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23627 +               return -EFAULT;
23628 +
23629 +       switch (vc_data.type) {
23630 +       case NXA_TYPE_ADDR:
23631 +       case NXA_TYPE_MASK:
23632 +               return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23633 +                       vc_data.prefix, vc_data.type, vc_data.flags);
23634 +       default:
23635 +               return -EINVAL;
23636 +       }
23637 +       return 0;
23638 +}
23639 +
23640 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23641 +{
23642 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23643 +
23644 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23645 +               return -EFAULT;
23646 +
23647 +       switch (vc_data.type) {
23648 +       case NXA_TYPE_ANY:
23649 +               __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23650 +               memset(&nxi->v6, 0, sizeof(nxi->v6));
23651 +               break;
23652 +
23653 +       default:
23654 +               return -EINVAL;
23655 +       }
23656 +       return 0;
23657 +}
23658 +
23659 +#endif /* CONFIG_IPV6 */
23660 +
23661 +
23662 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23663 +{
23664 +       struct vcmd_net_flags_v0 vc_data;
23665 +
23666 +       vc_data.flagword = nxi->nx_flags;
23667 +
23668 +       /* special STATE flag handling */
23669 +       vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23670 +
23671 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23672 +               return -EFAULT;
23673 +       return 0;
23674 +}
23675 +
23676 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23677 +{
23678 +       struct vcmd_net_flags_v0 vc_data;
23679 +       uint64_t mask, trigger;
23680 +
23681 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23682 +               return -EFAULT;
23683 +
23684 +       /* special STATE flag handling */
23685 +       mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23686 +       trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23687 +
23688 +       nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23689 +               vc_data.flagword, mask);
23690 +       if (trigger & NXF_PERSISTENT)
23691 +               nx_update_persistent(nxi);
23692 +
23693 +       return 0;
23694 +}
23695 +
23696 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23697 +{
23698 +       struct vcmd_net_caps_v0 vc_data;
23699 +
23700 +       vc_data.ncaps = nxi->nx_ncaps;
23701 +       vc_data.cmask = ~0ULL;
23702 +
23703 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23704 +               return -EFAULT;
23705 +       return 0;
23706 +}
23707 +
23708 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23709 +{
23710 +       struct vcmd_net_caps_v0 vc_data;
23711 +
23712 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23713 +               return -EFAULT;
23714 +
23715 +       nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23716 +               vc_data.ncaps, vc_data.cmask);
23717 +       return 0;
23718 +}
23719 +
23720 +
23721 +#include <linux/module.h>
23722 +
23723 +module_init(init_network);
23724 +
23725 +EXPORT_SYMBOL_GPL(free_nx_info);
23726 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23727 +
23728 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/proc.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/proc.c
23729 --- linux-2.6.33.1/kernel/vserver/proc.c        1970-01-01 01:00:00.000000000 +0100
23730 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/proc.c        2010-02-25 12:02:16.000000000 +0100
23731 @@ -0,0 +1,1098 @@
23732 +/*
23733 + *  linux/kernel/vserver/proc.c
23734 + *
23735 + *  Virtual Context Support
23736 + *
23737 + *  Copyright (C) 2003-2007  Herbert Pötzl
23738 + *
23739 + *  V0.01  basic structure
23740 + *  V0.02  adaptation vs1.3.0
23741 + *  V0.03  proc permissions
23742 + *  V0.04  locking/generic
23743 + *  V0.05  next generation procfs
23744 + *  V0.06  inode validation
23745 + *  V0.07  generic rewrite vid
23746 + *  V0.08  remove inode type
23747 + *
23748 + */
23749 +
23750 +#include <linux/proc_fs.h>
23751 +#include <linux/fs_struct.h>
23752 +#include <linux/mount.h>
23753 +#include <asm/unistd.h>
23754 +
23755 +#include <linux/vs_context.h>
23756 +#include <linux/vs_network.h>
23757 +#include <linux/vs_cvirt.h>
23758 +
23759 +#include <linux/in.h>
23760 +#include <linux/inetdevice.h>
23761 +#include <linux/vs_inet.h>
23762 +#include <linux/vs_inet6.h>
23763 +
23764 +#include <linux/vserver/global.h>
23765 +
23766 +#include "cvirt_proc.h"
23767 +#include "cacct_proc.h"
23768 +#include "limit_proc.h"
23769 +#include "sched_proc.h"
23770 +#include "vci_config.h"
23771 +
23772 +
23773 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23774 +{
23775 +       unsigned __capi;
23776 +
23777 +       CAP_FOR_EACH_U32(__capi) {
23778 +               buffer += sprintf(buffer, "%08x",
23779 +                       c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23780 +       }
23781 +       return buffer;
23782 +}
23783 +
23784 +
23785 +static struct proc_dir_entry *proc_virtual;
23786 +
23787 +static struct proc_dir_entry *proc_virtnet;
23788 +
23789 +
23790 +/* first the actual feeds */
23791 +
23792 +
23793 +static int proc_vci(char *buffer)
23794 +{
23795 +       return sprintf(buffer,
23796 +               "VCIVersion:\t%04x:%04x\n"
23797 +               "VCISyscall:\t%d\n"
23798 +               "VCIKernel:\t%08x\n",
23799 +               VCI_VERSION >> 16,
23800 +               VCI_VERSION & 0xFFFF,
23801 +               __NR_vserver,
23802 +               vci_kernel_config());
23803 +}
23804 +
23805 +static int proc_virtual_info(char *buffer)
23806 +{
23807 +       return proc_vci(buffer);
23808 +}
23809 +
23810 +static int proc_virtual_status(char *buffer)
23811 +{
23812 +       return sprintf(buffer,
23813 +               "#CTotal:\t%d\n"
23814 +               "#CActive:\t%d\n"
23815 +               "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23816 +               "#InitTask:\t%d\t%d %d\n",
23817 +               atomic_read(&vx_global_ctotal),
23818 +               atomic_read(&vx_global_cactive),
23819 +               atomic_read(&vs_global_nsproxy),
23820 +               atomic_read(&vs_global_fs),
23821 +               atomic_read(&vs_global_mnt_ns),
23822 +               atomic_read(&vs_global_uts_ns),
23823 +               atomic_read(&nr_ipc_ns),
23824 +               atomic_read(&vs_global_user_ns),
23825 +               atomic_read(&vs_global_pid_ns),
23826 +               atomic_read(&init_task.usage),
23827 +               atomic_read(&init_task.nsproxy->count),
23828 +               init_task.fs->users);
23829 +}
23830 +
23831 +
23832 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23833 +{
23834 +       int length;
23835 +
23836 +       length = sprintf(buffer,
23837 +               "ID:\t%d\n"
23838 +               "Info:\t%p\n"
23839 +               "Init:\t%d\n"
23840 +               "OOM:\t%lld\n",
23841 +               vxi->vx_id,
23842 +               vxi,
23843 +               vxi->vx_initpid,
23844 +               vxi->vx_badness_bias);
23845 +       return length;
23846 +}
23847 +
23848 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23849 +{
23850 +       char *orig = buffer;
23851 +
23852 +       buffer += sprintf(buffer,
23853 +               "UseCnt:\t%d\n"
23854 +               "Tasks:\t%d\n"
23855 +               "Flags:\t%016llx\n",
23856 +               atomic_read(&vxi->vx_usecnt),
23857 +               atomic_read(&vxi->vx_tasks),
23858 +               (unsigned long long)vxi->vx_flags);
23859 +
23860 +       buffer += sprintf(buffer, "BCaps:\t");
23861 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23862 +       buffer += sprintf(buffer, "\n");
23863 +
23864 +       buffer += sprintf(buffer,
23865 +               "CCaps:\t%016llx\n"
23866 +               "Spaces:\t%08lx %08lx\n",
23867 +               (unsigned long long)vxi->vx_ccaps,
23868 +               vxi->vx_nsmask[0], vxi->vx_nsmask[1]);
23869 +       return buffer - orig;
23870 +}
23871 +
23872 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23873 +{
23874 +       return vx_info_proc_limit(&vxi->limit, buffer);
23875 +}
23876 +
23877 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23878 +{
23879 +       int cpu, length;
23880 +
23881 +       length = vx_info_proc_sched(&vxi->sched, buffer);
23882 +       for_each_online_cpu(cpu) {
23883 +               length += vx_info_proc_sched_pc(
23884 +                       &vx_per_cpu(vxi, sched_pc, cpu),
23885 +                       buffer + length, cpu);
23886 +       }
23887 +       return length;
23888 +}
23889 +
23890 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23891 +{
23892 +       return vx_info_proc_nsproxy(vxi->vx_nsproxy[0], buffer);
23893 +}
23894 +
23895 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23896 +{
23897 +       return vx_info_proc_nsproxy(vxi->vx_nsproxy[1], buffer);
23898 +}
23899 +
23900 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23901 +{
23902 +       int cpu, length;
23903 +
23904 +       vx_update_load(vxi);
23905 +       length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23906 +       for_each_online_cpu(cpu) {
23907 +               length += vx_info_proc_cvirt_pc(
23908 +                       &vx_per_cpu(vxi, cvirt_pc, cpu),
23909 +                       buffer + length, cpu);
23910 +       }
23911 +       return length;
23912 +}
23913 +
23914 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23915 +{
23916 +       return vx_info_proc_cacct(&vxi->cacct, buffer);
23917 +}
23918 +
23919 +
23920 +static int proc_virtnet_info(char *buffer)
23921 +{
23922 +       return proc_vci(buffer);
23923 +}
23924 +
23925 +static int proc_virtnet_status(char *buffer)
23926 +{
23927 +       return sprintf(buffer,
23928 +               "#CTotal:\t%d\n"
23929 +               "#CActive:\t%d\n",
23930 +               atomic_read(&nx_global_ctotal),
23931 +               atomic_read(&nx_global_cactive));
23932 +}
23933 +
23934 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23935 +{
23936 +       struct nx_addr_v4 *v4a;
23937 +#ifdef CONFIG_IPV6
23938 +       struct nx_addr_v6 *v6a;
23939 +#endif
23940 +       int length, i;
23941 +
23942 +       length = sprintf(buffer,
23943 +               "ID:\t%d\n"
23944 +               "Info:\t%p\n"
23945 +               "Bcast:\t" NIPQUAD_FMT "\n"
23946 +               "Lback:\t" NIPQUAD_FMT "\n",
23947 +               nxi->nx_id,
23948 +               nxi,
23949 +               NIPQUAD(nxi->v4_bcast.s_addr),
23950 +               NIPQUAD(nxi->v4_lback.s_addr));
23951 +
23952 +       if (!NX_IPV4(nxi))
23953 +               goto skip_v4;
23954 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23955 +               length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23956 +                       i, NXAV4(v4a));
23957 +skip_v4:
23958 +#ifdef CONFIG_IPV6
23959 +       if (!NX_IPV6(nxi))
23960 +               goto skip_v6;
23961 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23962 +               length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23963 +                       i, NXAV6(v6a));
23964 +skip_v6:
23965 +#endif
23966 +       return length;
23967 +}
23968 +
23969 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23970 +{
23971 +       int length;
23972 +
23973 +       length = sprintf(buffer,
23974 +               "UseCnt:\t%d\n"
23975 +               "Tasks:\t%d\n"
23976 +               "Flags:\t%016llx\n"
23977 +               "NCaps:\t%016llx\n",
23978 +               atomic_read(&nxi->nx_usecnt),
23979 +               atomic_read(&nxi->nx_tasks),
23980 +               (unsigned long long)nxi->nx_flags,
23981 +               (unsigned long long)nxi->nx_ncaps);
23982 +       return length;
23983 +}
23984 +
23985 +
23986 +
23987 +/* here the inode helpers */
23988 +
23989 +struct vs_entry {
23990 +       int len;
23991 +       char *name;
23992 +       mode_t mode;
23993 +       struct inode_operations *iop;
23994 +       struct file_operations *fop;
23995 +       union proc_op op;
23996 +};
23997 +
23998 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23999 +{
24000 +       struct inode *inode = new_inode(sb);
24001 +
24002 +       if (!inode)
24003 +               goto out;
24004 +
24005 +       inode->i_mode = p->mode;
24006 +       if (p->iop)
24007 +               inode->i_op = p->iop;
24008 +       if (p->fop)
24009 +               inode->i_fop = p->fop;
24010 +
24011 +       inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
24012 +       inode->i_flags |= S_IMMUTABLE;
24013 +
24014 +       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
24015 +
24016 +       inode->i_uid = 0;
24017 +       inode->i_gid = 0;
24018 +       inode->i_tag = 0;
24019 +out:
24020 +       return inode;
24021 +}
24022 +
24023 +static struct dentry *vs_proc_instantiate(struct inode *dir,
24024 +       struct dentry *dentry, int id, void *ptr)
24025 +{
24026 +       struct vs_entry *p = ptr;
24027 +       struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
24028 +       struct dentry *error = ERR_PTR(-EINVAL);
24029 +
24030 +       if (!inode)
24031 +               goto out;
24032 +
24033 +       PROC_I(inode)->op = p->op;
24034 +       PROC_I(inode)->fd = id;
24035 +       d_add(dentry, inode);
24036 +       error = NULL;
24037 +out:
24038 +       return error;
24039 +}
24040 +
24041 +/* Lookups */
24042 +
24043 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
24044 +
24045 +/*
24046 + * Fill a directory entry.
24047 + *
24048 + * If possible create the dcache entry and derive our inode number and
24049 + * file type from dcache entry.
24050 + *
24051 + * Since all of the proc inode numbers are dynamically generated, the inode
24052 + * numbers do not exist until the inode is cache.  This means creating the
24053 + * the dcache entry in readdir is necessary to keep the inode numbers
24054 + * reported by readdir in sync with the inode numbers reported
24055 + * by stat.
24056 + */
24057 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
24058 +       char *name, int len, instantiate_t instantiate, int id, void *ptr)
24059 +{
24060 +       struct dentry *child, *dir = filp->f_dentry;
24061 +       struct inode *inode;
24062 +       struct qstr qname;
24063 +       ino_t ino = 0;
24064 +       unsigned type = DT_UNKNOWN;
24065 +
24066 +       qname.name = name;
24067 +       qname.len  = len;
24068 +       qname.hash = full_name_hash(name, len);
24069 +
24070 +       child = d_lookup(dir, &qname);
24071 +       if (!child) {
24072 +               struct dentry *new;
24073 +               new = d_alloc(dir, &qname);
24074 +               if (new) {
24075 +                       child = instantiate(dir->d_inode, new, id, ptr);
24076 +                       if (child)
24077 +                               dput(new);
24078 +                       else
24079 +                               child = new;
24080 +               }
24081 +       }
24082 +       if (!child || IS_ERR(child) || !child->d_inode)
24083 +               goto end_instantiate;
24084 +       inode = child->d_inode;
24085 +       if (inode) {
24086 +               ino = inode->i_ino;
24087 +               type = inode->i_mode >> 12;
24088 +       }
24089 +       dput(child);
24090 +end_instantiate:
24091 +       if (!ino)
24092 +               ino = find_inode_number(dir, &qname);
24093 +       if (!ino)
24094 +               ino = 1;
24095 +       return filldir(dirent, name, len, filp->f_pos, ino, type);
24096 +}
24097 +
24098 +
24099 +
24100 +/* get and revalidate vx_info/xid */
24101 +
24102 +static inline
24103 +struct vx_info *get_proc_vx_info(struct inode *inode)
24104 +{
24105 +       return lookup_vx_info(PROC_I(inode)->fd);
24106 +}
24107 +
24108 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
24109 +{
24110 +       struct inode *inode = dentry->d_inode;
24111 +       xid_t xid = PROC_I(inode)->fd;
24112 +
24113 +       if (!xid || xid_is_hashed(xid))
24114 +               return 1;
24115 +       d_drop(dentry);
24116 +       return 0;
24117 +}
24118 +
24119 +
24120 +/* get and revalidate nx_info/nid */
24121 +
24122 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
24123 +{
24124 +       struct inode *inode = dentry->d_inode;
24125 +       nid_t nid = PROC_I(inode)->fd;
24126 +
24127 +       if (!nid || nid_is_hashed(nid))
24128 +               return 1;
24129 +       d_drop(dentry);
24130 +       return 0;
24131 +}
24132 +
24133 +
24134 +
24135 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
24136 +
24137 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
24138 +                         size_t count, loff_t *ppos)
24139 +{
24140 +       struct inode *inode = file->f_dentry->d_inode;
24141 +       unsigned long page;
24142 +       ssize_t length = 0;
24143 +
24144 +       if (count > PROC_BLOCK_SIZE)
24145 +               count = PROC_BLOCK_SIZE;
24146 +
24147 +       /* fade that out as soon as stable */
24148 +       WARN_ON(PROC_I(inode)->fd);
24149 +
24150 +       if (!(page = __get_free_page(GFP_KERNEL)))
24151 +               return -ENOMEM;
24152 +
24153 +       BUG_ON(!PROC_I(inode)->op.proc_vs_read);
24154 +       length = PROC_I(inode)->op.proc_vs_read((char *)page);
24155 +
24156 +       if (length >= 0)
24157 +               length = simple_read_from_buffer(buf, count, ppos,
24158 +                       (char *)page, length);
24159 +
24160 +       free_page(page);
24161 +       return length;
24162 +}
24163 +
24164 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
24165 +                         size_t count, loff_t *ppos)
24166 +{
24167 +       struct inode *inode = file->f_dentry->d_inode;
24168 +       struct vx_info *vxi = NULL;
24169 +       xid_t xid = PROC_I(inode)->fd;
24170 +       unsigned long page;
24171 +       ssize_t length = 0;
24172 +
24173 +       if (count > PROC_BLOCK_SIZE)
24174 +               count = PROC_BLOCK_SIZE;
24175 +
24176 +       /* fade that out as soon as stable */
24177 +       WARN_ON(!xid);
24178 +       vxi = lookup_vx_info(xid);
24179 +       if (!vxi)
24180 +               goto out;
24181 +
24182 +       length = -ENOMEM;
24183 +       if (!(page = __get_free_page(GFP_KERNEL)))
24184 +               goto out_put;
24185 +
24186 +       BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
24187 +       length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
24188 +
24189 +       if (length >= 0)
24190 +               length = simple_read_from_buffer(buf, count, ppos,
24191 +                       (char *)page, length);
24192 +
24193 +       free_page(page);
24194 +out_put:
24195 +       put_vx_info(vxi);
24196 +out:
24197 +       return length;
24198 +}
24199 +
24200 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
24201 +                         size_t count, loff_t *ppos)
24202 +{
24203 +       struct inode *inode = file->f_dentry->d_inode;
24204 +       struct nx_info *nxi = NULL;
24205 +       nid_t nid = PROC_I(inode)->fd;
24206 +       unsigned long page;
24207 +       ssize_t length = 0;
24208 +
24209 +       if (count > PROC_BLOCK_SIZE)
24210 +               count = PROC_BLOCK_SIZE;
24211 +
24212 +       /* fade that out as soon as stable */
24213 +       WARN_ON(!nid);
24214 +       nxi = lookup_nx_info(nid);
24215 +       if (!nxi)
24216 +               goto out;
24217 +
24218 +       length = -ENOMEM;
24219 +       if (!(page = __get_free_page(GFP_KERNEL)))
24220 +               goto out_put;
24221 +
24222 +       BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
24223 +       length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
24224 +
24225 +       if (length >= 0)
24226 +               length = simple_read_from_buffer(buf, count, ppos,
24227 +                       (char *)page, length);
24228 +
24229 +       free_page(page);
24230 +out_put:
24231 +       put_nx_info(nxi);
24232 +out:
24233 +       return length;
24234 +}
24235 +
24236 +
24237 +
24238 +/* here comes the lower level */
24239 +
24240 +
24241 +#define NOD(NAME, MODE, IOP, FOP, OP) {        \
24242 +       .len  = sizeof(NAME) - 1,       \
24243 +       .name = (NAME),                 \
24244 +       .mode = MODE,                   \
24245 +       .iop  = IOP,                    \
24246 +       .fop  = FOP,                    \
24247 +       .op   = OP,                     \
24248 +}
24249 +
24250 +
24251 +#define DIR(NAME, MODE, OTYPE)                         \
24252 +       NOD(NAME, (S_IFDIR | (MODE)),                   \
24253 +               &proc_ ## OTYPE ## _inode_operations,   \
24254 +               &proc_ ## OTYPE ## _file_operations, { } )
24255 +
24256 +#define INF(NAME, MODE, OTYPE)                         \
24257 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
24258 +               &proc_vs_info_file_operations,          \
24259 +               { .proc_vs_read = &proc_##OTYPE } )
24260 +
24261 +#define VINF(NAME, MODE, OTYPE)                                \
24262 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
24263 +               &proc_vx_info_file_operations,          \
24264 +               { .proc_vxi_read = &proc_##OTYPE } )
24265 +
24266 +#define NINF(NAME, MODE, OTYPE)                                \
24267 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
24268 +               &proc_nx_info_file_operations,          \
24269 +               { .proc_nxi_read = &proc_##OTYPE } )
24270 +
24271 +
24272 +static struct file_operations proc_vs_info_file_operations = {
24273 +       .read =         proc_vs_info_read,
24274 +};
24275 +
24276 +static struct file_operations proc_vx_info_file_operations = {
24277 +       .read =         proc_vx_info_read,
24278 +};
24279 +
24280 +static struct dentry_operations proc_xid_dentry_operations = {
24281 +       .d_revalidate = proc_xid_revalidate,
24282 +};
24283 +
24284 +static struct vs_entry vx_base_stuff[] = {
24285 +       VINF("info",    S_IRUGO, vxi_info),
24286 +       VINF("status",  S_IRUGO, vxi_status),
24287 +       VINF("limit",   S_IRUGO, vxi_limit),
24288 +       VINF("sched",   S_IRUGO, vxi_sched),
24289 +       VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
24290 +       VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
24291 +       VINF("cvirt",   S_IRUGO, vxi_cvirt),
24292 +       VINF("cacct",   S_IRUGO, vxi_cacct),
24293 +       {}
24294 +};
24295 +
24296 +
24297 +
24298 +
24299 +static struct dentry *proc_xid_instantiate(struct inode *dir,
24300 +       struct dentry *dentry, int id, void *ptr)
24301 +{
24302 +       dentry->d_op = &proc_xid_dentry_operations;
24303 +       return vs_proc_instantiate(dir, dentry, id, ptr);
24304 +}
24305 +
24306 +static struct dentry *proc_xid_lookup(struct inode *dir,
24307 +       struct dentry *dentry, struct nameidata *nd)
24308 +{
24309 +       struct vs_entry *p = vx_base_stuff;
24310 +       struct dentry *error = ERR_PTR(-ENOENT);
24311 +
24312 +       for (; p->name; p++) {
24313 +               if (p->len != dentry->d_name.len)
24314 +                       continue;
24315 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24316 +                       break;
24317 +       }
24318 +       if (!p->name)
24319 +               goto out;
24320 +
24321 +       error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
24322 +out:
24323 +       return error;
24324 +}
24325 +
24326 +static int proc_xid_readdir(struct file *filp,
24327 +       void *dirent, filldir_t filldir)
24328 +{
24329 +       struct dentry *dentry = filp->f_dentry;
24330 +       struct inode *inode = dentry->d_inode;
24331 +       struct vs_entry *p = vx_base_stuff;
24332 +       int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
24333 +       int pos, index;
24334 +       u64 ino;
24335 +
24336 +       pos = filp->f_pos;
24337 +       switch (pos) {
24338 +       case 0:
24339 +               ino = inode->i_ino;
24340 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24341 +                       goto out;
24342 +               pos++;
24343 +               /* fall through */
24344 +       case 1:
24345 +               ino = parent_ino(dentry);
24346 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24347 +                       goto out;
24348 +               pos++;
24349 +               /* fall through */
24350 +       default:
24351 +               index = pos - 2;
24352 +               if (index >= size)
24353 +                       goto out;
24354 +               for (p += index; p->name; p++) {
24355 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24356 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
24357 +                               goto out;
24358 +                       pos++;
24359 +               }
24360 +       }
24361 +out:
24362 +       filp->f_pos = pos;
24363 +       return 1;
24364 +}
24365 +
24366 +
24367 +
24368 +static struct file_operations proc_nx_info_file_operations = {
24369 +       .read =         proc_nx_info_read,
24370 +};
24371 +
24372 +static struct dentry_operations proc_nid_dentry_operations = {
24373 +       .d_revalidate = proc_nid_revalidate,
24374 +};
24375 +
24376 +static struct vs_entry nx_base_stuff[] = {
24377 +       NINF("info",    S_IRUGO, nxi_info),
24378 +       NINF("status",  S_IRUGO, nxi_status),
24379 +       {}
24380 +};
24381 +
24382 +
24383 +static struct dentry *proc_nid_instantiate(struct inode *dir,
24384 +       struct dentry *dentry, int id, void *ptr)
24385 +{
24386 +       dentry->d_op = &proc_nid_dentry_operations;
24387 +       return vs_proc_instantiate(dir, dentry, id, ptr);
24388 +}
24389 +
24390 +static struct dentry *proc_nid_lookup(struct inode *dir,
24391 +       struct dentry *dentry, struct nameidata *nd)
24392 +{
24393 +       struct vs_entry *p = nx_base_stuff;
24394 +       struct dentry *error = ERR_PTR(-ENOENT);
24395 +
24396 +       for (; p->name; p++) {
24397 +               if (p->len != dentry->d_name.len)
24398 +                       continue;
24399 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24400 +                       break;
24401 +       }
24402 +       if (!p->name)
24403 +               goto out;
24404 +
24405 +       error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
24406 +out:
24407 +       return error;
24408 +}
24409 +
24410 +static int proc_nid_readdir(struct file *filp,
24411 +       void *dirent, filldir_t filldir)
24412 +{
24413 +       struct dentry *dentry = filp->f_dentry;
24414 +       struct inode *inode = dentry->d_inode;
24415 +       struct vs_entry *p = nx_base_stuff;
24416 +       int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
24417 +       int pos, index;
24418 +       u64 ino;
24419 +
24420 +       pos = filp->f_pos;
24421 +       switch (pos) {
24422 +       case 0:
24423 +               ino = inode->i_ino;
24424 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24425 +                       goto out;
24426 +               pos++;
24427 +               /* fall through */
24428 +       case 1:
24429 +               ino = parent_ino(dentry);
24430 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24431 +                       goto out;
24432 +               pos++;
24433 +               /* fall through */
24434 +       default:
24435 +               index = pos - 2;
24436 +               if (index >= size)
24437 +                       goto out;
24438 +               for (p += index; p->name; p++) {
24439 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24440 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
24441 +                               goto out;
24442 +                       pos++;
24443 +               }
24444 +       }
24445 +out:
24446 +       filp->f_pos = pos;
24447 +       return 1;
24448 +}
24449 +
24450 +
24451 +#define MAX_MULBY10    ((~0U - 9) / 10)
24452 +
24453 +static inline int atovid(const char *str, int len)
24454 +{
24455 +       int vid, c;
24456 +
24457 +       vid = 0;
24458 +       while (len-- > 0) {
24459 +               c = *str - '0';
24460 +               str++;
24461 +               if (c > 9)
24462 +                       return -1;
24463 +               if (vid >= MAX_MULBY10)
24464 +                       return -1;
24465 +               vid *= 10;
24466 +               vid += c;
24467 +               if (!vid)
24468 +                       return -1;
24469 +       }
24470 +       return vid;
24471 +}
24472 +
24473 +/* now the upper level (virtual) */
24474 +
24475 +
24476 +static struct file_operations proc_xid_file_operations = {
24477 +       .read =         generic_read_dir,
24478 +       .readdir =      proc_xid_readdir,
24479 +};
24480 +
24481 +static struct inode_operations proc_xid_inode_operations = {
24482 +       .lookup =       proc_xid_lookup,
24483 +};
24484 +
24485 +static struct vs_entry vx_virtual_stuff[] = {
24486 +       INF("info",     S_IRUGO, virtual_info),
24487 +       INF("status",   S_IRUGO, virtual_status),
24488 +       DIR(NULL,       S_IRUGO | S_IXUGO, xid),
24489 +};
24490 +
24491 +
24492 +static struct dentry *proc_virtual_lookup(struct inode *dir,
24493 +       struct dentry *dentry, struct nameidata *nd)
24494 +{
24495 +       struct vs_entry *p = vx_virtual_stuff;
24496 +       struct dentry *error = ERR_PTR(-ENOENT);
24497 +       int id = 0;
24498 +
24499 +       for (; p->name; p++) {
24500 +               if (p->len != dentry->d_name.len)
24501 +                       continue;
24502 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24503 +                       break;
24504 +       }
24505 +       if (p->name)
24506 +               goto instantiate;
24507 +
24508 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
24509 +       if ((id < 0) || !xid_is_hashed(id))
24510 +               goto out;
24511 +
24512 +instantiate:
24513 +       error = proc_xid_instantiate(dir, dentry, id, p);
24514 +out:
24515 +       return error;
24516 +}
24517 +
24518 +static struct file_operations proc_nid_file_operations = {
24519 +       .read =         generic_read_dir,
24520 +       .readdir =      proc_nid_readdir,
24521 +};
24522 +
24523 +static struct inode_operations proc_nid_inode_operations = {
24524 +       .lookup =       proc_nid_lookup,
24525 +};
24526 +
24527 +static struct vs_entry nx_virtnet_stuff[] = {
24528 +       INF("info",     S_IRUGO, virtnet_info),
24529 +       INF("status",   S_IRUGO, virtnet_status),
24530 +       DIR(NULL,       S_IRUGO | S_IXUGO, nid),
24531 +};
24532 +
24533 +
24534 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
24535 +       struct dentry *dentry, struct nameidata *nd)
24536 +{
24537 +       struct vs_entry *p = nx_virtnet_stuff;
24538 +       struct dentry *error = ERR_PTR(-ENOENT);
24539 +       int id = 0;
24540 +
24541 +       for (; p->name; p++) {
24542 +               if (p->len != dentry->d_name.len)
24543 +                       continue;
24544 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24545 +                       break;
24546 +       }
24547 +       if (p->name)
24548 +               goto instantiate;
24549 +
24550 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
24551 +       if ((id < 0) || !nid_is_hashed(id))
24552 +               goto out;
24553 +
24554 +instantiate:
24555 +       error = proc_nid_instantiate(dir, dentry, id, p);
24556 +out:
24557 +       return error;
24558 +}
24559 +
24560 +
24561 +#define PROC_MAXVIDS 32
24562 +
24563 +int proc_virtual_readdir(struct file *filp,
24564 +       void *dirent, filldir_t filldir)
24565 +{
24566 +       struct dentry *dentry = filp->f_dentry;
24567 +       struct inode *inode = dentry->d_inode;
24568 +       struct vs_entry *p = vx_virtual_stuff;
24569 +       int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24570 +       int pos, index;
24571 +       unsigned int xid_array[PROC_MAXVIDS];
24572 +       char buf[PROC_NUMBUF];
24573 +       unsigned int nr_xids, i;
24574 +       u64 ino;
24575 +
24576 +       pos = filp->f_pos;
24577 +       switch (pos) {
24578 +       case 0:
24579 +               ino = inode->i_ino;
24580 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24581 +                       goto out;
24582 +               pos++;
24583 +               /* fall through */
24584 +       case 1:
24585 +               ino = parent_ino(dentry);
24586 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24587 +                       goto out;
24588 +               pos++;
24589 +               /* fall through */
24590 +       default:
24591 +               index = pos - 2;
24592 +               if (index >= size)
24593 +                       goto entries;
24594 +               for (p += index; p->name; p++) {
24595 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24596 +                               vs_proc_instantiate, 0, p))
24597 +                               goto out;
24598 +                       pos++;
24599 +               }
24600 +       entries:
24601 +               index = pos - size;
24602 +               p = &vx_virtual_stuff[size - 1];
24603 +               nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24604 +               for (i = 0; i < nr_xids; i++) {
24605 +                       int n, xid = xid_array[i];
24606 +                       unsigned int j = PROC_NUMBUF;
24607 +
24608 +                       n = xid;
24609 +                       do
24610 +                               buf[--j] = '0' + (n % 10);
24611 +                       while (n /= 10);
24612 +
24613 +                       if (proc_fill_cache(filp, dirent, filldir,
24614 +                               buf + j, PROC_NUMBUF - j,
24615 +                               vs_proc_instantiate, xid, p))
24616 +                               goto out;
24617 +                       pos++;
24618 +               }
24619 +       }
24620 +out:
24621 +       filp->f_pos = pos;
24622 +       return 0;
24623 +}
24624 +
24625 +static int proc_virtual_getattr(struct vfsmount *mnt,
24626 +       struct dentry *dentry, struct kstat *stat)
24627 +{
24628 +       struct inode *inode = dentry->d_inode;
24629 +
24630 +       generic_fillattr(inode, stat);
24631 +       stat->nlink = 2 + atomic_read(&vx_global_cactive);
24632 +       return 0;
24633 +}
24634 +
24635 +static struct file_operations proc_virtual_dir_operations = {
24636 +       .read =         generic_read_dir,
24637 +       .readdir =      proc_virtual_readdir,
24638 +};
24639 +
24640 +static struct inode_operations proc_virtual_dir_inode_operations = {
24641 +       .getattr =      proc_virtual_getattr,
24642 +       .lookup =       proc_virtual_lookup,
24643 +};
24644 +
24645 +
24646 +
24647 +
24648 +
24649 +int proc_virtnet_readdir(struct file *filp,
24650 +       void *dirent, filldir_t filldir)
24651 +{
24652 +       struct dentry *dentry = filp->f_dentry;
24653 +       struct inode *inode = dentry->d_inode;
24654 +       struct vs_entry *p = nx_virtnet_stuff;
24655 +       int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24656 +       int pos, index;
24657 +       unsigned int nid_array[PROC_MAXVIDS];
24658 +       char buf[PROC_NUMBUF];
24659 +       unsigned int nr_nids, i;
24660 +       u64 ino;
24661 +
24662 +       pos = filp->f_pos;
24663 +       switch (pos) {
24664 +       case 0:
24665 +               ino = inode->i_ino;
24666 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24667 +                       goto out;
24668 +               pos++;
24669 +               /* fall through */
24670 +       case 1:
24671 +               ino = parent_ino(dentry);
24672 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24673 +                       goto out;
24674 +               pos++;
24675 +               /* fall through */
24676 +       default:
24677 +               index = pos - 2;
24678 +               if (index >= size)
24679 +                       goto entries;
24680 +               for (p += index; p->name; p++) {
24681 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24682 +                               vs_proc_instantiate, 0, p))
24683 +                               goto out;
24684 +                       pos++;
24685 +               }
24686 +       entries:
24687 +               index = pos - size;
24688 +               p = &nx_virtnet_stuff[size - 1];
24689 +               nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24690 +               for (i = 0; i < nr_nids; i++) {
24691 +                       int n, nid = nid_array[i];
24692 +                       unsigned int j = PROC_NUMBUF;
24693 +
24694 +                       n = nid;
24695 +                       do
24696 +                               buf[--j] = '0' + (n % 10);
24697 +                       while (n /= 10);
24698 +
24699 +                       if (proc_fill_cache(filp, dirent, filldir,
24700 +                               buf + j, PROC_NUMBUF - j,
24701 +                               vs_proc_instantiate, nid, p))
24702 +                               goto out;
24703 +                       pos++;
24704 +               }
24705 +       }
24706 +out:
24707 +       filp->f_pos = pos;
24708 +       return 0;
24709 +}
24710 +
24711 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24712 +       struct dentry *dentry, struct kstat *stat)
24713 +{
24714 +       struct inode *inode = dentry->d_inode;
24715 +
24716 +       generic_fillattr(inode, stat);
24717 +       stat->nlink = 2 + atomic_read(&nx_global_cactive);
24718 +       return 0;
24719 +}
24720 +
24721 +static struct file_operations proc_virtnet_dir_operations = {
24722 +       .read =         generic_read_dir,
24723 +       .readdir =      proc_virtnet_readdir,
24724 +};
24725 +
24726 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24727 +       .getattr =      proc_virtnet_getattr,
24728 +       .lookup =       proc_virtnet_lookup,
24729 +};
24730 +
24731 +
24732 +
24733 +void proc_vx_init(void)
24734 +{
24735 +       struct proc_dir_entry *ent;
24736 +
24737 +       ent = proc_mkdir("virtual", 0);
24738 +       if (ent) {
24739 +               ent->proc_fops = &proc_virtual_dir_operations;
24740 +               ent->proc_iops = &proc_virtual_dir_inode_operations;
24741 +       }
24742 +       proc_virtual = ent;
24743 +
24744 +       ent = proc_mkdir("virtnet", 0);
24745 +       if (ent) {
24746 +               ent->proc_fops = &proc_virtnet_dir_operations;
24747 +               ent->proc_iops = &proc_virtnet_dir_inode_operations;
24748 +       }
24749 +       proc_virtnet = ent;
24750 +}
24751 +
24752 +
24753 +
24754 +
24755 +/* per pid info */
24756 +
24757 +
24758 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24759 +{
24760 +       struct vx_info *vxi;
24761 +       char *orig = buffer;
24762 +
24763 +       buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24764 +
24765 +       vxi = task_get_vx_info(p);
24766 +       if (!vxi)
24767 +               goto out;
24768 +
24769 +       buffer += sprintf(buffer, "BCaps:\t");
24770 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24771 +       buffer += sprintf(buffer, "\n");
24772 +       buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24773 +               (unsigned long long)vxi->vx_ccaps);
24774 +       buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24775 +               (unsigned long long)vxi->vx_flags);
24776 +       buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24777 +
24778 +       put_vx_info(vxi);
24779 +out:
24780 +       return buffer - orig;
24781 +}
24782 +
24783 +
24784 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24785 +{
24786 +       struct nx_info *nxi;
24787 +       struct nx_addr_v4 *v4a;
24788 +#ifdef CONFIG_IPV6
24789 +       struct nx_addr_v6 *v6a;
24790 +#endif
24791 +       char *orig = buffer;
24792 +       int i;
24793 +
24794 +       buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24795 +
24796 +       nxi = task_get_nx_info(p);
24797 +       if (!nxi)
24798 +               goto out;
24799 +
24800 +       buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24801 +               (unsigned long long)nxi->nx_ncaps);
24802 +       buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24803 +               (unsigned long long)nxi->nx_flags);
24804 +
24805 +       buffer += sprintf(buffer,
24806 +               "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24807 +               NIPQUAD(nxi->v4_bcast.s_addr));
24808 +       buffer += sprintf (buffer,
24809 +               "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24810 +               NIPQUAD(nxi->v4_lback.s_addr));
24811 +       if (!NX_IPV4(nxi))
24812 +               goto skip_v4;
24813 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24814 +               buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24815 +                       i, NXAV4(v4a));
24816 +skip_v4:
24817 +#ifdef CONFIG_IPV6
24818 +       if (!NX_IPV6(nxi))
24819 +               goto skip_v6;
24820 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24821 +               buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24822 +                       i, NXAV6(v6a));
24823 +skip_v6:
24824 +#endif
24825 +       put_nx_info(nxi);
24826 +out:
24827 +       return buffer - orig;
24828 +}
24829 +
24830 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/sched.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/sched.c
24831 --- linux-2.6.33.1/kernel/vserver/sched.c       1970-01-01 01:00:00.000000000 +0100
24832 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/sched.c       2010-02-25 12:02:16.000000000 +0100
24833 @@ -0,0 +1,414 @@
24834 +/*
24835 + *  linux/kernel/vserver/sched.c
24836 + *
24837 + *  Virtual Server: Scheduler Support
24838 + *
24839 + *  Copyright (C) 2004-2007  Herbert Pötzl
24840 + *
24841 + *  V0.01  adapted Sam Vilains version to 2.6.3
24842 + *  V0.02  removed legacy interface
24843 + *  V0.03  changed vcmds to vxi arg
24844 + *  V0.04  removed older and legacy interfaces
24845 + *
24846 + */
24847 +
24848 +#include <linux/vs_context.h>
24849 +#include <linux/vs_sched.h>
24850 +#include <linux/vserver/sched_cmd.h>
24851 +
24852 +#include <asm/uaccess.h>
24853 +
24854 +
24855 +#define vxd_check_range(val, min, max) do {            \
24856 +       vxlprintk((val < min) || (val > max),           \
24857 +               "check_range(%ld,%ld,%ld)",             \
24858 +               (long)val, (long)min, (long)max,        \
24859 +               __FILE__, __LINE__);                    \
24860 +       } while (0)
24861 +
24862 +
24863 +void vx_update_sched_param(struct _vx_sched *sched,
24864 +       struct _vx_sched_pc *sched_pc)
24865 +{
24866 +       unsigned int set_mask = sched->update_mask;
24867 +
24868 +       if (set_mask & VXSM_FILL_RATE)
24869 +               sched_pc->fill_rate[0] = sched->fill_rate[0];
24870 +       if (set_mask & VXSM_INTERVAL)
24871 +               sched_pc->interval[0] = sched->interval[0];
24872 +       if (set_mask & VXSM_FILL_RATE2)
24873 +               sched_pc->fill_rate[1] = sched->fill_rate[1];
24874 +       if (set_mask & VXSM_INTERVAL2)
24875 +               sched_pc->interval[1] = sched->interval[1];
24876 +       if (set_mask & VXSM_TOKENS)
24877 +               sched_pc->tokens = sched->tokens;
24878 +       if (set_mask & VXSM_TOKENS_MIN)
24879 +               sched_pc->tokens_min = sched->tokens_min;
24880 +       if (set_mask & VXSM_TOKENS_MAX)
24881 +               sched_pc->tokens_max = sched->tokens_max;
24882 +       if (set_mask & VXSM_PRIO_BIAS)
24883 +               sched_pc->prio_bias = sched->prio_bias;
24884 +
24885 +       if (set_mask & VXSM_IDLE_TIME)
24886 +               sched_pc->flags |= VXSF_IDLE_TIME;
24887 +       else
24888 +               sched_pc->flags &= ~VXSF_IDLE_TIME;
24889 +
24890 +       /* reset time */
24891 +       sched_pc->norm_time = jiffies;
24892 +}
24893 +
24894 +
24895 +/*
24896 + * recalculate the context's scheduling tokens
24897 + *
24898 + * ret > 0 : number of tokens available
24899 + * ret < 0 : on hold, check delta_min[]
24900 + *          -1 only jiffies
24901 + *          -2 also idle time
24902 + *
24903 + */
24904 +int vx_tokens_recalc(struct _vx_sched_pc *sched_pc,
24905 +       unsigned long *norm_time, unsigned long *idle_time, int delta_min[2])
24906 +{
24907 +       long delta;
24908 +       long tokens = 0;
24909 +       int flags = sched_pc->flags;
24910 +
24911 +       /* how much time did pass? */
24912 +       delta = *norm_time - sched_pc->norm_time;
24913 +       // printk("@ %ld, %ld, %ld\n", *norm_time, sched_pc->norm_time, jiffies);
24914 +       vxd_check_range(delta, 0, INT_MAX);
24915 +
24916 +       if (delta >= sched_pc->interval[0]) {
24917 +               long tokens, integral;
24918 +
24919 +               /* calc integral token part */
24920 +               tokens = delta / sched_pc->interval[0];
24921 +               integral = tokens * sched_pc->interval[0];
24922 +               tokens *= sched_pc->fill_rate[0];
24923 +#ifdef CONFIG_VSERVER_HARDCPU
24924 +               delta_min[0] = delta - integral;
24925 +               vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
24926 +#endif
24927 +               /* advance time */
24928 +               sched_pc->norm_time += delta;
24929 +
24930 +               /* add tokens */
24931 +               sched_pc->tokens += tokens;
24932 +               sched_pc->token_time += tokens;
24933 +       } else
24934 +               delta_min[0] = delta;
24935 +
24936 +#ifdef CONFIG_VSERVER_IDLETIME
24937 +       if (!(flags & VXSF_IDLE_TIME))
24938 +               goto skip_idle;
24939 +
24940 +       /* how much was the idle skip? */
24941 +       delta = *idle_time - sched_pc->idle_time;
24942 +       vxd_check_range(delta, 0, INT_MAX);
24943 +
24944 +       if (delta >= sched_pc->interval[1]) {
24945 +               long tokens, integral;
24946 +
24947 +               /* calc fair share token part */
24948 +               tokens = delta / sched_pc->interval[1];
24949 +               integral = tokens * sched_pc->interval[1];
24950 +               tokens *= sched_pc->fill_rate[1];
24951 +               delta_min[1] = delta - integral;
24952 +               vxd_check_range(delta_min[1], 0, sched_pc->interval[1]);
24953 +
24954 +               /* advance idle time */
24955 +               sched_pc->idle_time += integral;
24956 +
24957 +               /* add tokens */
24958 +               sched_pc->tokens += tokens;
24959 +               sched_pc->token_time += tokens;
24960 +       } else
24961 +               delta_min[1] = delta;
24962 +skip_idle:
24963 +#endif
24964 +
24965 +       /* clip at maximum */
24966 +       if (sched_pc->tokens > sched_pc->tokens_max)
24967 +               sched_pc->tokens = sched_pc->tokens_max;
24968 +       tokens = sched_pc->tokens;
24969 +
24970 +       if ((flags & VXSF_ONHOLD)) {
24971 +               /* can we unhold? */
24972 +               if (tokens >= sched_pc->tokens_min) {
24973 +                       flags &= ~VXSF_ONHOLD;
24974 +                       sched_pc->hold_ticks +=
24975 +                               *norm_time - sched_pc->onhold;
24976 +               } else
24977 +                       goto on_hold;
24978 +       } else {
24979 +               /* put on hold? */
24980 +               if (tokens <= 0) {
24981 +                       flags |= VXSF_ONHOLD;
24982 +                       sched_pc->onhold = *norm_time;
24983 +                       goto on_hold;
24984 +               }
24985 +       }
24986 +       sched_pc->flags = flags;
24987 +       return tokens;
24988 +
24989 +on_hold:
24990 +       tokens = sched_pc->tokens_min - tokens;
24991 +       sched_pc->flags = flags;
24992 +       // BUG_ON(tokens < 0); probably doesn't hold anymore
24993 +
24994 +#ifdef CONFIG_VSERVER_HARDCPU
24995 +       /* next interval? */
24996 +       if (!sched_pc->fill_rate[0])
24997 +               delta_min[0] = HZ;
24998 +       else if (tokens > sched_pc->fill_rate[0])
24999 +               delta_min[0] += sched_pc->interval[0] *
25000 +                       tokens / sched_pc->fill_rate[0];
25001 +       else
25002 +               delta_min[0] = sched_pc->interval[0] - delta_min[0];
25003 +       vxd_check_range(delta_min[0], 0, INT_MAX);
25004 +
25005 +#ifdef CONFIG_VSERVER_IDLETIME
25006 +       if (!(flags & VXSF_IDLE_TIME))
25007 +               return -1;
25008 +
25009 +       /* next interval? */
25010 +       if (!sched_pc->fill_rate[1])
25011 +               delta_min[1] = HZ;
25012 +       else if (tokens > sched_pc->fill_rate[1])
25013 +               delta_min[1] += sched_pc->interval[1] *
25014 +                       tokens / sched_pc->fill_rate[1];
25015 +       else
25016 +               delta_min[1] = sched_pc->interval[1] - delta_min[1];
25017 +       vxd_check_range(delta_min[1], 0, INT_MAX);
25018 +
25019 +       return -2;
25020 +#else
25021 +       return -1;
25022 +#endif /* CONFIG_VSERVER_IDLETIME */
25023 +#else
25024 +       return 0;
25025 +#endif /* CONFIG_VSERVER_HARDCPU */
25026 +}
25027 +
25028 +static inline unsigned long msec_to_ticks(unsigned long msec)
25029 +{
25030 +       return msecs_to_jiffies(msec);
25031 +}
25032 +
25033 +static inline unsigned long ticks_to_msec(unsigned long ticks)
25034 +{
25035 +       return jiffies_to_msecs(ticks);
25036 +}
25037 +
25038 +static inline unsigned long ticks_to_usec(unsigned long ticks)
25039 +{
25040 +       return jiffies_to_usecs(ticks);
25041 +}
25042 +
25043 +
25044 +static int do_set_sched(struct vx_info *vxi, struct vcmd_sched_v5 *data)
25045 +{
25046 +       unsigned int set_mask = data->mask;
25047 +       unsigned int update_mask;
25048 +       int i, cpu;
25049 +
25050 +       /* Sanity check data values */
25051 +       if (data->tokens_max <= 0)
25052 +               data->tokens_max = HZ;
25053 +       if (data->tokens_min < 0)
25054 +               data->tokens_min = HZ / 3;
25055 +       if (data->tokens_min >= data->tokens_max)
25056 +               data->tokens_min = data->tokens_max;
25057 +
25058 +       if (data->prio_bias > MAX_PRIO_BIAS)
25059 +               data->prio_bias = MAX_PRIO_BIAS;
25060 +       if (data->prio_bias < MIN_PRIO_BIAS)
25061 +               data->prio_bias = MIN_PRIO_BIAS;
25062 +
25063 +       spin_lock(&vxi->sched.tokens_lock);
25064 +
25065 +       /* sync up on delayed updates */
25066 +       for_each_cpu_mask(cpu, vxi->sched.update)
25067 +               vx_update_sched_param(&vxi->sched,
25068 +                       &vx_per_cpu(vxi, sched_pc, cpu));
25069 +
25070 +       if (set_mask & VXSM_FILL_RATE)
25071 +               vxi->sched.fill_rate[0] = data->fill_rate[0];
25072 +       if (set_mask & VXSM_FILL_RATE2)
25073 +               vxi->sched.fill_rate[1] = data->fill_rate[1];
25074 +       if (set_mask & VXSM_INTERVAL)
25075 +               vxi->sched.interval[0] = (set_mask & VXSM_MSEC) ?
25076 +                       msec_to_ticks(data->interval[0]) : data->interval[0];
25077 +       if (set_mask & VXSM_INTERVAL2)
25078 +               vxi->sched.interval[1] = (set_mask & VXSM_MSEC) ?
25079 +                       msec_to_ticks(data->interval[1]) : data->interval[1];
25080 +       if (set_mask & VXSM_TOKENS)
25081 +               vxi->sched.tokens = data->tokens;
25082 +       if (set_mask & VXSM_TOKENS_MIN)
25083 +               vxi->sched.tokens_min = data->tokens_min;
25084 +       if (set_mask & VXSM_TOKENS_MAX)
25085 +               vxi->sched.tokens_max = data->tokens_max;
25086 +       if (set_mask & VXSM_PRIO_BIAS)
25087 +               vxi->sched.prio_bias = data->prio_bias;
25088 +
25089 +       /* Sanity check rate/interval */
25090 +       for (i = 0; i < 2; i++) {
25091 +               if (data->fill_rate[i] < 0)
25092 +                       data->fill_rate[i] = 0;
25093 +               if (data->interval[i] <= 0)
25094 +                       data->interval[i] = HZ;
25095 +       }
25096 +
25097 +       update_mask = vxi->sched.update_mask & VXSM_SET_MASK;
25098 +       update_mask |= (set_mask & (VXSM_SET_MASK | VXSM_IDLE_TIME));
25099 +       vxi->sched.update_mask = update_mask;
25100 +
25101 +#ifdef CONFIG_SMP
25102 +       rmb();
25103 +       if (set_mask & VXSM_CPU_ID) {
25104 +               vxi->sched.update = cpumask_of_cpu(data->cpu_id);
25105 +               cpus_and(vxi->sched.update, cpu_online_map,
25106 +                       vxi->sched.update);
25107 +       } else
25108 +               vxi->sched.update = cpu_online_map;
25109 +
25110 +       /* forced reload? */
25111 +       if (set_mask & VXSM_FORCE) {
25112 +               for_each_cpu_mask(cpu, vxi->sched.update)
25113 +                       vx_update_sched_param(&vxi->sched,
25114 +                               &vx_per_cpu(vxi, sched_pc, cpu));
25115 +               vxi->sched.update = CPU_MASK_NONE;
25116 +       }
25117 +#else
25118 +       /* on UP we update immediately */
25119 +       vx_update_sched_param(&vxi->sched,
25120 +               &vx_per_cpu(vxi, sched_pc, 0));
25121 +#endif
25122 +
25123 +       spin_unlock(&vxi->sched.tokens_lock);
25124 +       return 0;
25125 +}
25126 +
25127 +
25128 +#define COPY_IDS(C) C(cpu_id); C(bucket_id)
25129 +#define COPY_PRI(C) C(prio_bias)
25130 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
25131 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]);   \
25132 +                   C(fill_rate[1]); C(interval[1]);
25133 +
25134 +#define COPY_VALUE(name) vc_data.name = data->name
25135 +
25136 +static int do_set_sched_v4(struct vx_info *vxi, struct vcmd_set_sched_v4 *data)
25137 +{
25138 +       struct vcmd_sched_v5 vc_data;
25139 +
25140 +       vc_data.mask = data->set_mask;
25141 +       COPY_IDS(COPY_VALUE);
25142 +       COPY_PRI(COPY_VALUE);
25143 +       COPY_TOK(COPY_VALUE);
25144 +       vc_data.fill_rate[0] = vc_data.fill_rate[1] = data->fill_rate;
25145 +       vc_data.interval[0] = vc_data.interval[1] = data->interval;
25146 +       return do_set_sched(vxi, &vc_data);
25147 +}
25148 +
25149 +int vc_set_sched_v4(struct vx_info *vxi, void __user *data)
25150 +{
25151 +       struct vcmd_set_sched_v4 vc_data;
25152 +
25153 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25154 +               return -EFAULT;
25155 +
25156 +       return do_set_sched_v4(vxi, &vc_data);
25157 +}
25158 +
25159 +       /* latest interface is v5 */
25160 +
25161 +int vc_set_sched(struct vx_info *vxi, void __user *data)
25162 +{
25163 +       struct vcmd_sched_v5 vc_data;
25164 +
25165 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25166 +               return -EFAULT;
25167 +
25168 +       return do_set_sched(vxi, &vc_data);
25169 +}
25170 +
25171 +
25172 +#define COPY_PRI(C) C(prio_bias)
25173 +#define COPY_TOK(C) C(tokens); C(tokens_min); C(tokens_max)
25174 +#define COPY_FRI(C) C(fill_rate[0]); C(interval[0]);    \
25175 +                   C(fill_rate[1]); C(interval[1]);
25176 +
25177 +#define COPY_VALUE(name) vc_data.name = data->name
25178 +
25179 +
25180 +int vc_get_sched(struct vx_info *vxi, void __user *data)
25181 +{
25182 +       struct vcmd_sched_v5 vc_data;
25183 +
25184 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25185 +               return -EFAULT;
25186 +
25187 +       if (vc_data.mask & VXSM_CPU_ID) {
25188 +               int cpu = vc_data.cpu_id;
25189 +               struct _vx_sched_pc *data;
25190 +
25191 +               if (!cpu_possible(cpu))
25192 +                       return -EINVAL;
25193 +
25194 +               data = &vx_per_cpu(vxi, sched_pc, cpu);
25195 +               COPY_TOK(COPY_VALUE);
25196 +               COPY_PRI(COPY_VALUE);
25197 +               COPY_FRI(COPY_VALUE);
25198 +
25199 +               if (data->flags & VXSF_IDLE_TIME)
25200 +                       vc_data.mask |= VXSM_IDLE_TIME;
25201 +       } else {
25202 +               struct _vx_sched *data = &vxi->sched;
25203 +
25204 +               COPY_TOK(COPY_VALUE);
25205 +               COPY_PRI(COPY_VALUE);
25206 +               COPY_FRI(COPY_VALUE);
25207 +       }
25208 +
25209 +       if (vc_data.mask & VXSM_MSEC) {
25210 +               vc_data.interval[0] = ticks_to_msec(vc_data.interval[0]);
25211 +               vc_data.interval[1] = ticks_to_msec(vc_data.interval[1]);
25212 +       }
25213 +
25214 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25215 +               return -EFAULT;
25216 +       return 0;
25217 +}
25218 +
25219 +
25220 +int vc_sched_info(struct vx_info *vxi, void __user *data)
25221 +{
25222 +       struct vcmd_sched_info vc_data;
25223 +       int cpu;
25224 +
25225 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25226 +               return -EFAULT;
25227 +
25228 +       cpu = vc_data.cpu_id;
25229 +       if (!cpu_possible(cpu))
25230 +               return -EINVAL;
25231 +
25232 +       if (vxi) {
25233 +               struct _vx_sched_pc *sched_pc =
25234 +                       &vx_per_cpu(vxi, sched_pc, cpu);
25235 +
25236 +               vc_data.user_msec = ticks_to_msec(sched_pc->user_ticks);
25237 +               vc_data.sys_msec = ticks_to_msec(sched_pc->sys_ticks);
25238 +               vc_data.hold_msec = ticks_to_msec(sched_pc->hold_ticks);
25239 +               vc_data.vavavoom = sched_pc->vavavoom;
25240 +       }
25241 +       vc_data.token_usec = ticks_to_usec(1);
25242 +
25243 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25244 +               return -EFAULT;
25245 +       return 0;
25246 +}
25247 +
25248 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/sched_init.h linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/sched_init.h
25249 --- linux-2.6.33.1/kernel/vserver/sched_init.h  1970-01-01 01:00:00.000000000 +0100
25250 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/sched_init.h  2010-02-25 12:02:16.000000000 +0100
25251 @@ -0,0 +1,50 @@
25252 +
25253 +static inline void vx_info_init_sched(struct _vx_sched *sched)
25254 +{
25255 +       static struct lock_class_key tokens_lock_key;
25256 +
25257 +       /* scheduling; hard code starting values as constants */
25258 +       sched->fill_rate[0]     = 1;
25259 +       sched->interval[0]      = 4;
25260 +       sched->fill_rate[1]     = 1;
25261 +       sched->interval[1]      = 8;
25262 +       sched->tokens           = HZ >> 2;
25263 +       sched->tokens_min       = HZ >> 4;
25264 +       sched->tokens_max       = HZ >> 1;
25265 +       sched->tokens_lock      = SPIN_LOCK_UNLOCKED;
25266 +       sched->prio_bias        = 0;
25267 +
25268 +       lockdep_set_class(&sched->tokens_lock, &tokens_lock_key);
25269 +}
25270 +
25271 +static inline
25272 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
25273 +{
25274 +       sched_pc->fill_rate[0]  = 1;
25275 +       sched_pc->interval[0]   = 4;
25276 +       sched_pc->fill_rate[1]  = 1;
25277 +       sched_pc->interval[1]   = 8;
25278 +       sched_pc->tokens        = HZ >> 2;
25279 +       sched_pc->tokens_min    = HZ >> 4;
25280 +       sched_pc->tokens_max    = HZ >> 1;
25281 +       sched_pc->prio_bias     = 0;
25282 +       sched_pc->vavavoom      = 0;
25283 +       sched_pc->token_time    = 0;
25284 +       sched_pc->idle_time     = 0;
25285 +       sched_pc->norm_time     = jiffies;
25286 +
25287 +       sched_pc->user_ticks = 0;
25288 +       sched_pc->sys_ticks = 0;
25289 +       sched_pc->hold_ticks = 0;
25290 +}
25291 +
25292 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
25293 +{
25294 +       return;
25295 +}
25296 +
25297 +static inline
25298 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
25299 +{
25300 +       return;
25301 +}
25302 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/sched_proc.h linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/sched_proc.h
25303 --- linux-2.6.33.1/kernel/vserver/sched_proc.h  1970-01-01 01:00:00.000000000 +0100
25304 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/sched_proc.h  2010-02-25 12:02:16.000000000 +0100
25305 @@ -0,0 +1,57 @@
25306 +#ifndef _VX_SCHED_PROC_H
25307 +#define _VX_SCHED_PROC_H
25308 +
25309 +
25310 +static inline
25311 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
25312 +{
25313 +       int length = 0;
25314 +
25315 +       length += sprintf(buffer,
25316 +               "FillRate:\t%8d,%d\n"
25317 +               "Interval:\t%8d,%d\n"
25318 +               "TokensMin:\t%8d\n"
25319 +               "TokensMax:\t%8d\n"
25320 +               "PrioBias:\t%8d\n",
25321 +               sched->fill_rate[0],
25322 +               sched->fill_rate[1],
25323 +               sched->interval[0],
25324 +               sched->interval[1],
25325 +               sched->tokens_min,
25326 +               sched->tokens_max,
25327 +               sched->prio_bias);
25328 +       return length;
25329 +}
25330 +
25331 +static inline
25332 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
25333 +       char *buffer, int cpu)
25334 +{
25335 +       int length = 0;
25336 +
25337 +       length += sprintf(buffer + length,
25338 +               "cpu %d: %lld %lld %lld %ld %ld", cpu,
25339 +               (unsigned long long)sched_pc->user_ticks,
25340 +               (unsigned long long)sched_pc->sys_ticks,
25341 +               (unsigned long long)sched_pc->hold_ticks,
25342 +               sched_pc->token_time,
25343 +               sched_pc->idle_time);
25344 +       length += sprintf(buffer + length,
25345 +               " %c%c %d %d %d %d/%d %d/%d",
25346 +               (sched_pc->flags & VXSF_ONHOLD) ? 'H' : 'R',
25347 +               (sched_pc->flags & VXSF_IDLE_TIME) ? 'I' : '-',
25348 +               sched_pc->tokens,
25349 +               sched_pc->tokens_min,
25350 +               sched_pc->tokens_max,
25351 +               sched_pc->fill_rate[0],
25352 +               sched_pc->interval[0],
25353 +               sched_pc->fill_rate[1],
25354 +               sched_pc->interval[1]);
25355 +       length += sprintf(buffer + length,
25356 +               " %d %d\n",
25357 +               sched_pc->prio_bias,
25358 +               sched_pc->vavavoom);
25359 +       return length;
25360 +}
25361 +
25362 +#endif /* _VX_SCHED_PROC_H */
25363 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/signal.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/signal.c
25364 --- linux-2.6.33.1/kernel/vserver/signal.c      1970-01-01 01:00:00.000000000 +0100
25365 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/signal.c      2010-02-25 12:02:16.000000000 +0100
25366 @@ -0,0 +1,132 @@
25367 +/*
25368 + *  linux/kernel/vserver/signal.c
25369 + *
25370 + *  Virtual Server: Signal Support
25371 + *
25372 + *  Copyright (C) 2003-2007  Herbert Pötzl
25373 + *
25374 + *  V0.01  broken out from vcontext V0.05
25375 + *  V0.02  changed vcmds to vxi arg
25376 + *  V0.03  adjusted siginfo for kill
25377 + *
25378 + */
25379 +
25380 +#include <asm/uaccess.h>
25381 +
25382 +#include <linux/vs_context.h>
25383 +#include <linux/vs_pid.h>
25384 +#include <linux/vserver/signal_cmd.h>
25385 +
25386 +
25387 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
25388 +{
25389 +       int retval, count = 0;
25390 +       struct task_struct *p;
25391 +       struct siginfo *sip = SEND_SIG_PRIV;
25392 +
25393 +       retval = -ESRCH;
25394 +       vxdprintk(VXD_CBIT(misc, 4),
25395 +               "vx_info_kill(%p[#%d],%d,%d)*",
25396 +               vxi, vxi->vx_id, pid, sig);
25397 +       read_lock(&tasklist_lock);
25398 +       switch (pid) {
25399 +       case  0:
25400 +       case -1:
25401 +               for_each_process(p) {
25402 +                       int err = 0;
25403 +
25404 +                       if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
25405 +                               (pid && vxi->vx_initpid == p->pid))
25406 +                               continue;
25407 +
25408 +                       err = group_send_sig_info(sig, sip, p);
25409 +                       ++count;
25410 +                       if (err != -EPERM)
25411 +                               retval = err;
25412 +               }
25413 +               break;
25414 +
25415 +       case 1:
25416 +               if (vxi->vx_initpid) {
25417 +                       pid = vxi->vx_initpid;
25418 +                       /* for now, only SIGINT to private init ... */
25419 +                       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
25420 +                               /* ... as long as there are tasks left */
25421 +                               (atomic_read(&vxi->vx_tasks) > 1))
25422 +                               sig = SIGINT;
25423 +               }
25424 +               /* fallthrough */
25425 +       default:
25426 +               p = find_task_by_real_pid(pid);
25427 +               if (p) {
25428 +                       if (vx_task_xid(p) == vxi->vx_id)
25429 +                               retval = group_send_sig_info(sig, sip, p);
25430 +               }
25431 +               break;
25432 +       }
25433 +       read_unlock(&tasklist_lock);
25434 +       vxdprintk(VXD_CBIT(misc, 4),
25435 +               "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
25436 +               vxi, vxi->vx_id, pid, sig, (long)sip, retval);
25437 +       return retval;
25438 +}
25439 +
25440 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
25441 +{
25442 +       struct vcmd_ctx_kill_v0 vc_data;
25443 +
25444 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
25445 +               return -EFAULT;
25446 +
25447 +       /* special check to allow guest shutdown */
25448 +       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
25449 +               /* forbid killall pid=0 when init is present */
25450 +               (((vc_data.pid < 1) && vxi->vx_initpid) ||
25451 +               (vc_data.pid > 1)))
25452 +               return -EACCES;
25453 +
25454 +       return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
25455 +}
25456 +
25457 +
25458 +static int __wait_exit(struct vx_info *vxi)
25459 +{
25460 +       DECLARE_WAITQUEUE(wait, current);
25461 +       int ret = 0;
25462 +
25463 +       add_wait_queue(&vxi->vx_wait, &wait);
25464 +       set_current_state(TASK_INTERRUPTIBLE);
25465 +
25466 +wait:
25467 +       if (vx_info_state(vxi,
25468 +               VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
25469 +               goto out;
25470 +       if (signal_pending(current)) {
25471 +               ret = -ERESTARTSYS;
25472 +               goto out;
25473 +       }
25474 +       schedule();
25475 +       goto wait;
25476 +
25477 +out:
25478 +       set_current_state(TASK_RUNNING);
25479 +       remove_wait_queue(&vxi->vx_wait, &wait);
25480 +       return ret;
25481 +}
25482 +
25483 +
25484 +
25485 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
25486 +{
25487 +       struct vcmd_wait_exit_v0 vc_data;
25488 +       int ret;
25489 +
25490 +       ret = __wait_exit(vxi);
25491 +       vc_data.reboot_cmd = vxi->reboot_cmd;
25492 +       vc_data.exit_code = vxi->exit_code;
25493 +
25494 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
25495 +               ret = -EFAULT;
25496 +       return ret;
25497 +}
25498 +
25499 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/space.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/space.c
25500 --- linux-2.6.33.1/kernel/vserver/space.c       1970-01-01 01:00:00.000000000 +0100
25501 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/space.c       2010-02-25 12:02:16.000000000 +0100
25502 @@ -0,0 +1,375 @@
25503 +/*
25504 + *  linux/kernel/vserver/space.c
25505 + *
25506 + *  Virtual Server: Context Space Support
25507 + *
25508 + *  Copyright (C) 2003-2007  Herbert Pötzl
25509 + *
25510 + *  V0.01  broken out from context.c 0.07
25511 + *  V0.02  added task locking for namespace
25512 + *  V0.03  broken out vx_enter_namespace
25513 + *  V0.04  added *space support and commands
25514 + *
25515 + */
25516 +
25517 +#include <linux/utsname.h>
25518 +#include <linux/nsproxy.h>
25519 +#include <linux/err.h>
25520 +#include <linux/fs_struct.h>
25521 +#include <asm/uaccess.h>
25522 +
25523 +#include <linux/vs_context.h>
25524 +#include <linux/vserver/space.h>
25525 +#include <linux/vserver/space_cmd.h>
25526 +
25527 +atomic_t vs_global_nsproxy     = ATOMIC_INIT(0);
25528 +atomic_t vs_global_fs          = ATOMIC_INIT(0);
25529 +atomic_t vs_global_mnt_ns      = ATOMIC_INIT(0);
25530 +atomic_t vs_global_uts_ns      = ATOMIC_INIT(0);
25531 +atomic_t vs_global_user_ns     = ATOMIC_INIT(0);
25532 +atomic_t vs_global_pid_ns      = ATOMIC_INIT(0);
25533 +
25534 +
25535 +/* namespace functions */
25536 +
25537 +#include <linux/mnt_namespace.h>
25538 +#include <linux/user_namespace.h>
25539 +#include <linux/pid_namespace.h>
25540 +#include <linux/ipc_namespace.h>
25541 +#include <net/net_namespace.h>
25542 +
25543 +
25544 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
25545 +       .mask = CLONE_FS |
25546 +               CLONE_NEWNS |
25547 +               CLONE_NEWUTS |
25548 +               CLONE_NEWIPC |
25549 +               CLONE_NEWUSER |
25550 +               0
25551 +};
25552 +
25553 +static const struct vcmd_space_mask_v1 space_mask = {
25554 +       .mask = CLONE_FS |
25555 +               CLONE_NEWNS |
25556 +               CLONE_NEWUTS |
25557 +               CLONE_NEWIPC |
25558 +               CLONE_NEWUSER |
25559 +#ifdef CONFIG_PID_NS
25560 +               CLONE_NEWPID |
25561 +#endif
25562 +#ifdef CONFIG_NET_NS
25563 +               CLONE_NEWNET |
25564 +#endif
25565 +               0
25566 +};
25567 +
25568 +static const struct vcmd_space_mask_v1 default_space_mask = {
25569 +       .mask = CLONE_FS |
25570 +               CLONE_NEWNS |
25571 +               CLONE_NEWUTS |
25572 +               CLONE_NEWIPC |
25573 +               CLONE_NEWUSER |
25574 +#ifdef CONFIG_PID_NS
25575 +//             CLONE_NEWPID |
25576 +#endif
25577 +               0
25578 +};
25579 +
25580 +/*
25581 + *     build a new nsproxy mix
25582 + *      assumes that both proxies are 'const'
25583 + *     does not touch nsproxy refcounts
25584 + *     will hold a reference on the result.
25585 + */
25586 +
25587 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
25588 +       struct nsproxy *new_nsproxy, unsigned long mask)
25589 +{
25590 +       struct mnt_namespace *old_ns;
25591 +       struct uts_namespace *old_uts;
25592 +       struct ipc_namespace *old_ipc;
25593 +#ifdef CONFIG_PID_NS
25594 +       struct pid_namespace *old_pid;
25595 +#endif
25596 +#ifdef CONFIG_NET_NS
25597 +       struct net *old_net;
25598 +#endif
25599 +       struct nsproxy *nsproxy;
25600 +
25601 +       nsproxy = copy_nsproxy(old_nsproxy);
25602 +       if (!nsproxy)
25603 +               goto out;
25604 +
25605 +       if (mask & CLONE_NEWNS) {
25606 +               old_ns = nsproxy->mnt_ns;
25607 +               nsproxy->mnt_ns = new_nsproxy->mnt_ns;
25608 +               if (nsproxy->mnt_ns)
25609 +                       get_mnt_ns(nsproxy->mnt_ns);
25610 +       } else
25611 +               old_ns = NULL;
25612 +
25613 +       if (mask & CLONE_NEWUTS) {
25614 +               old_uts = nsproxy->uts_ns;
25615 +               nsproxy->uts_ns = new_nsproxy->uts_ns;
25616 +               if (nsproxy->uts_ns)
25617 +                       get_uts_ns(nsproxy->uts_ns);
25618 +       } else
25619 +               old_uts = NULL;
25620 +
25621 +       if (mask & CLONE_NEWIPC) {
25622 +               old_ipc = nsproxy->ipc_ns;
25623 +               nsproxy->ipc_ns = new_nsproxy->ipc_ns;
25624 +               if (nsproxy->ipc_ns)
25625 +                       get_ipc_ns(nsproxy->ipc_ns);
25626 +       } else
25627 +               old_ipc = NULL;
25628 +
25629 +#ifdef CONFIG_PID_NS
25630 +       if (mask & CLONE_NEWPID) {
25631 +               old_pid = nsproxy->pid_ns;
25632 +               nsproxy->pid_ns = new_nsproxy->pid_ns;
25633 +               if (nsproxy->pid_ns)
25634 +                       get_pid_ns(nsproxy->pid_ns);
25635 +       } else
25636 +               old_pid = NULL;
25637 +#endif
25638 +#ifdef CONFIG_NET_NS
25639 +       if (mask & CLONE_NEWNET) {
25640 +               old_net = nsproxy->net_ns;
25641 +               nsproxy->net_ns = new_nsproxy->net_ns;
25642 +               if (nsproxy->net_ns)
25643 +                       get_net(nsproxy->net_ns);
25644 +       } else
25645 +               old_net = NULL;
25646 +#endif
25647 +       if (old_ns)
25648 +               put_mnt_ns(old_ns);
25649 +       if (old_uts)
25650 +               put_uts_ns(old_uts);
25651 +       if (old_ipc)
25652 +               put_ipc_ns(old_ipc);
25653 +#ifdef CONFIG_PID_NS
25654 +       if (old_pid)
25655 +               put_pid_ns(old_pid);
25656 +#endif
25657 +#ifdef CONFIG_NET_NS
25658 +       if (old_net)
25659 +               put_net(old_net);
25660 +#endif
25661 +out:
25662 +       return nsproxy;
25663 +}
25664 +
25665 +
25666 +/*
25667 + *     merge two nsproxy structs into a new one.
25668 + *     will hold a reference on the result.
25669 + */
25670 +
25671 +static inline
25672 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
25673 +       struct nsproxy *proxy, unsigned long mask)
25674 +{
25675 +       struct nsproxy null_proxy = { .mnt_ns = NULL };
25676 +
25677 +       if (!proxy)
25678 +               return NULL;
25679 +
25680 +       if (mask) {
25681 +               /* vs_mix_nsproxy returns with reference */
25682 +               return vs_mix_nsproxy(old ? old : &null_proxy,
25683 +                       proxy, mask);
25684 +       }
25685 +       get_nsproxy(proxy);
25686 +       return proxy;
25687 +}
25688 +
25689 +
25690 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25691 +{
25692 +       struct nsproxy *proxy, *proxy_cur, *proxy_new;
25693 +       struct fs_struct *fs_cur, *fs = NULL;
25694 +       int ret, kill = 0;
25695 +
25696 +       vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
25697 +               vxi, vxi->vx_id, mask, index);
25698 +
25699 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
25700 +               return -EACCES;
25701 +
25702 +       if (!mask)
25703 +               mask = vxi->vx_nsmask[index];
25704 +
25705 +       if ((mask & vxi->vx_nsmask[index]) != mask)
25706 +               return -EINVAL;
25707 +
25708 +       if (mask & CLONE_FS) {
25709 +               fs = copy_fs_struct(vxi->vx_fs[index]);
25710 +               if (!fs)
25711 +                       return -ENOMEM;
25712 +       }
25713 +       proxy = vxi->vx_nsproxy[index];
25714 +
25715 +       vxdprintk(VXD_CBIT(space, 9),
25716 +               "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
25717 +               vxi, vxi->vx_id, mask, index, proxy, fs);
25718 +
25719 +       task_lock(current);
25720 +       fs_cur = current->fs;
25721 +
25722 +       if (mask & CLONE_FS) {
25723 +               write_lock(&fs_cur->lock);
25724 +               current->fs = fs;
25725 +               kill = !--fs_cur->users;
25726 +               write_unlock(&fs_cur->lock);
25727 +       }
25728 +
25729 +       proxy_cur = current->nsproxy;
25730 +       get_nsproxy(proxy_cur);
25731 +       task_unlock(current);
25732 +
25733 +       if (kill)
25734 +               free_fs_struct(fs_cur);
25735 +
25736 +       proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
25737 +       if (IS_ERR(proxy_new)) {
25738 +               ret = PTR_ERR(proxy_new);
25739 +               goto out_put;
25740 +       }
25741 +
25742 +       proxy_new = xchg(&current->nsproxy, proxy_new);
25743 +       ret = 0;
25744 +
25745 +       if (proxy_new)
25746 +               put_nsproxy(proxy_new);
25747 +out_put:
25748 +       if (proxy_cur)
25749 +               put_nsproxy(proxy_cur);
25750 +       return ret;
25751 +}
25752 +
25753 +
25754 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25755 +{
25756 +       struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25757 +       struct fs_struct *fs_vxi, *fs;
25758 +       int ret, kill = 0;
25759 +
25760 +       vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
25761 +               vxi, vxi->vx_id, mask, index);
25762 +#if 0
25763 +       if (!mask)
25764 +               mask = default_space_mask.mask;
25765 +#endif
25766 +       if ((mask & space_mask.mask) != mask)
25767 +               return -EINVAL;
25768 +
25769 +       proxy_vxi = vxi->vx_nsproxy[index];
25770 +       fs_vxi = vxi->vx_fs[index];
25771 +
25772 +       if (mask & CLONE_FS) {
25773 +               fs = copy_fs_struct(current->fs);
25774 +               if (!fs)
25775 +                       return -ENOMEM;
25776 +       }
25777 +
25778 +       task_lock(current);
25779 +
25780 +       if (mask & CLONE_FS) {
25781 +               write_lock(&fs_vxi->lock);
25782 +               vxi->vx_fs[index] = fs;
25783 +               kill = !--fs_vxi->users;
25784 +               write_unlock(&fs_vxi->lock);
25785 +       }
25786 +
25787 +       proxy_cur = current->nsproxy;
25788 +       get_nsproxy(proxy_cur);
25789 +       task_unlock(current);
25790 +
25791 +       if (kill)
25792 +               free_fs_struct(fs_vxi);
25793 +
25794 +       proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25795 +       if (IS_ERR(proxy_new)) {
25796 +               ret = PTR_ERR(proxy_new);
25797 +               goto out_put;
25798 +       }
25799 +
25800 +       proxy_new = xchg(&vxi->vx_nsproxy[index], proxy_new);
25801 +       vxi->vx_nsmask[index] |= mask;
25802 +       ret = 0;
25803 +
25804 +       if (proxy_new)
25805 +               put_nsproxy(proxy_new);
25806 +out_put:
25807 +       if (proxy_cur)
25808 +               put_nsproxy(proxy_cur);
25809 +       return ret;
25810 +}
25811 +
25812 +
25813 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25814 +{
25815 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25816 +
25817 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25818 +               return -EFAULT;
25819 +
25820 +       return vx_enter_space(vxi, vc_data.mask, 0);
25821 +}
25822 +
25823 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25824 +{
25825 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25826 +
25827 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25828 +               return -EFAULT;
25829 +
25830 +       if (vc_data.index >= VX_SPACES)
25831 +               return -EINVAL;
25832 +
25833 +       return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25834 +}
25835 +
25836 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25837 +{
25838 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25839 +
25840 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25841 +               return -EFAULT;
25842 +
25843 +       return vx_set_space(vxi, vc_data.mask, 0);
25844 +}
25845 +
25846 +int vc_set_space(struct vx_info *vxi, void __user *data)
25847 +{
25848 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25849 +
25850 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25851 +               return -EFAULT;
25852 +
25853 +       if (vc_data.index >= VX_SPACES)
25854 +               return -EINVAL;
25855 +
25856 +       return vx_set_space(vxi, vc_data.mask, vc_data.index);
25857 +}
25858 +
25859 +int vc_get_space_mask(void __user *data, int type)
25860 +{
25861 +       const struct vcmd_space_mask_v1 *mask;
25862 +
25863 +       if (type == 0)
25864 +               mask = &space_mask_v0;
25865 +       else if (type == 1)
25866 +               mask = &space_mask;
25867 +       else
25868 +               mask = &default_space_mask;
25869 +
25870 +       vxdprintk(VXD_CBIT(space, 10),
25871 +               "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25872 +
25873 +       if (copy_to_user(data, mask, sizeof(*mask)))
25874 +               return -EFAULT;
25875 +       return 0;
25876 +}
25877 +
25878 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/switch.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/switch.c
25879 --- linux-2.6.33.1/kernel/vserver/switch.c      1970-01-01 01:00:00.000000000 +0100
25880 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/switch.c      2010-02-25 12:02:16.000000000 +0100
25881 @@ -0,0 +1,546 @@
25882 +/*
25883 + *  linux/kernel/vserver/switch.c
25884 + *
25885 + *  Virtual Server: Syscall Switch
25886 + *
25887 + *  Copyright (C) 2003-2007  Herbert Pötzl
25888 + *
25889 + *  V0.01  syscall switch
25890 + *  V0.02  added signal to context
25891 + *  V0.03  added rlimit functions
25892 + *  V0.04  added iattr, task/xid functions
25893 + *  V0.05  added debug/history stuff
25894 + *  V0.06  added compat32 layer
25895 + *  V0.07  vcmd args and perms
25896 + *  V0.08  added status commands
25897 + *  V0.09  added tag commands
25898 + *  V0.10  added oom bias
25899 + *  V0.11  added device commands
25900 + *
25901 + */
25902 +
25903 +#include <linux/vs_context.h>
25904 +#include <linux/vs_network.h>
25905 +#include <linux/vserver/switch.h>
25906 +
25907 +#include "vci_config.h"
25908 +
25909 +
25910 +static inline
25911 +int vc_get_version(uint32_t id)
25912 +{
25913 +       return VCI_VERSION;
25914 +}
25915 +
25916 +static inline
25917 +int vc_get_vci(uint32_t id)
25918 +{
25919 +       return vci_kernel_config();
25920 +}
25921 +
25922 +#include <linux/vserver/context_cmd.h>
25923 +#include <linux/vserver/cvirt_cmd.h>
25924 +#include <linux/vserver/cacct_cmd.h>
25925 +#include <linux/vserver/limit_cmd.h>
25926 +#include <linux/vserver/network_cmd.h>
25927 +#include <linux/vserver/sched_cmd.h>
25928 +#include <linux/vserver/debug_cmd.h>
25929 +#include <linux/vserver/inode_cmd.h>
25930 +#include <linux/vserver/dlimit_cmd.h>
25931 +#include <linux/vserver/signal_cmd.h>
25932 +#include <linux/vserver/space_cmd.h>
25933 +#include <linux/vserver/tag_cmd.h>
25934 +#include <linux/vserver/device_cmd.h>
25935 +
25936 +#include <linux/vserver/inode.h>
25937 +#include <linux/vserver/dlimit.h>
25938 +
25939 +
25940 +#ifdef CONFIG_COMPAT
25941 +#define __COMPAT(name, id, data, compat)       \
25942 +       (compat) ? name ## _x32(id, data) : name(id, data)
25943 +#define __COMPAT_NO_ID(name, data, compat)     \
25944 +       (compat) ? name ## _x32(data) : name(data)
25945 +#else
25946 +#define __COMPAT(name, id, data, compat)       \
25947 +       name(id, data)
25948 +#define __COMPAT_NO_ID(name, data, compat)     \
25949 +       name(data)
25950 +#endif
25951 +
25952 +
25953 +static inline
25954 +long do_vcmd(uint32_t cmd, uint32_t id,
25955 +       struct vx_info *vxi, struct nx_info *nxi,
25956 +       void __user *data, int compat)
25957 +{
25958 +       switch (cmd) {
25959 +
25960 +       case VCMD_get_version:
25961 +               return vc_get_version(id);
25962 +       case VCMD_get_vci:
25963 +               return vc_get_vci(id);
25964 +
25965 +       case VCMD_task_xid:
25966 +               return vc_task_xid(id);
25967 +       case VCMD_vx_info:
25968 +               return vc_vx_info(vxi, data);
25969 +
25970 +       case VCMD_task_nid:
25971 +               return vc_task_nid(id);
25972 +       case VCMD_nx_info:
25973 +               return vc_nx_info(nxi, data);
25974 +
25975 +       case VCMD_task_tag:
25976 +               return vc_task_tag(id);
25977 +
25978 +       case VCMD_set_space_v1:
25979 +               return vc_set_space_v1(vxi, data);
25980 +       /* this is version 2 */
25981 +       case VCMD_set_space:
25982 +               return vc_set_space(vxi, data);
25983 +
25984 +       case VCMD_get_space_mask_v0:
25985 +               return vc_get_space_mask(data, 0);
25986 +       /* this is version 1 */
25987 +       case VCMD_get_space_mask:
25988 +               return vc_get_space_mask(data, 1);
25989 +
25990 +       case VCMD_get_space_default:
25991 +               return vc_get_space_mask(data, -1);
25992 +
25993 +#ifdef CONFIG_IA32_EMULATION
25994 +       case VCMD_get_rlimit:
25995 +               return __COMPAT(vc_get_rlimit, vxi, data, compat);
25996 +       case VCMD_set_rlimit:
25997 +               return __COMPAT(vc_set_rlimit, vxi, data, compat);
25998 +#else
25999 +       case VCMD_get_rlimit:
26000 +               return vc_get_rlimit(vxi, data);
26001 +       case VCMD_set_rlimit:
26002 +               return vc_set_rlimit(vxi, data);
26003 +#endif
26004 +       case VCMD_get_rlimit_mask:
26005 +               return vc_get_rlimit_mask(id, data);
26006 +       case VCMD_reset_hits:
26007 +               return vc_reset_hits(vxi, data);
26008 +       case VCMD_reset_minmax:
26009 +               return vc_reset_minmax(vxi, data);
26010 +
26011 +       case VCMD_get_vhi_name:
26012 +               return vc_get_vhi_name(vxi, data);
26013 +       case VCMD_set_vhi_name:
26014 +               return vc_set_vhi_name(vxi, data);
26015 +
26016 +       case VCMD_ctx_stat:
26017 +               return vc_ctx_stat(vxi, data);
26018 +       case VCMD_virt_stat:
26019 +               return vc_virt_stat(vxi, data);
26020 +       case VCMD_sock_stat:
26021 +               return vc_sock_stat(vxi, data);
26022 +       case VCMD_rlimit_stat:
26023 +               return vc_rlimit_stat(vxi, data);
26024 +
26025 +       case VCMD_set_cflags:
26026 +               return vc_set_cflags(vxi, data);
26027 +       case VCMD_get_cflags:
26028 +               return vc_get_cflags(vxi, data);
26029 +
26030 +       /* this is version 1 */
26031 +       case VCMD_set_ccaps:
26032 +               return vc_set_ccaps(vxi, data);
26033 +       /* this is version 1 */
26034 +       case VCMD_get_ccaps:
26035 +               return vc_get_ccaps(vxi, data);
26036 +       case VCMD_set_bcaps:
26037 +               return vc_set_bcaps(vxi, data);
26038 +       case VCMD_get_bcaps:
26039 +               return vc_get_bcaps(vxi, data);
26040 +
26041 +       case VCMD_set_badness:
26042 +               return vc_set_badness(vxi, data);
26043 +       case VCMD_get_badness:
26044 +               return vc_get_badness(vxi, data);
26045 +
26046 +       case VCMD_set_nflags:
26047 +               return vc_set_nflags(nxi, data);
26048 +       case VCMD_get_nflags:
26049 +               return vc_get_nflags(nxi, data);
26050 +
26051 +       case VCMD_set_ncaps:
26052 +               return vc_set_ncaps(nxi, data);
26053 +       case VCMD_get_ncaps:
26054 +               return vc_get_ncaps(nxi, data);
26055 +
26056 +       case VCMD_set_sched_v4:
26057 +               return vc_set_sched_v4(vxi, data);
26058 +       /* this is version 5 */
26059 +       case VCMD_set_sched:
26060 +               return vc_set_sched(vxi, data);
26061 +       case VCMD_get_sched:
26062 +               return vc_get_sched(vxi, data);
26063 +       case VCMD_sched_info:
26064 +               return vc_sched_info(vxi, data);
26065 +
26066 +       case VCMD_add_dlimit:
26067 +               return __COMPAT(vc_add_dlimit, id, data, compat);
26068 +       case VCMD_rem_dlimit:
26069 +               return __COMPAT(vc_rem_dlimit, id, data, compat);
26070 +       case VCMD_set_dlimit:
26071 +               return __COMPAT(vc_set_dlimit, id, data, compat);
26072 +       case VCMD_get_dlimit:
26073 +               return __COMPAT(vc_get_dlimit, id, data, compat);
26074 +
26075 +       case VCMD_ctx_kill:
26076 +               return vc_ctx_kill(vxi, data);
26077 +
26078 +       case VCMD_wait_exit:
26079 +               return vc_wait_exit(vxi, data);
26080 +
26081 +       case VCMD_get_iattr:
26082 +               return __COMPAT_NO_ID(vc_get_iattr, data, compat);
26083 +       case VCMD_set_iattr:
26084 +               return __COMPAT_NO_ID(vc_set_iattr, data, compat);
26085 +
26086 +       case VCMD_fget_iattr:
26087 +               return vc_fget_iattr(id, data);
26088 +       case VCMD_fset_iattr:
26089 +               return vc_fset_iattr(id, data);
26090 +
26091 +       case VCMD_enter_space_v0:
26092 +               return vc_enter_space_v1(vxi, NULL);
26093 +       case VCMD_enter_space_v1:
26094 +               return vc_enter_space_v1(vxi, data);
26095 +       /* this is version 2 */
26096 +       case VCMD_enter_space:
26097 +               return vc_enter_space(vxi, data);
26098 +
26099 +       case VCMD_ctx_create_v0:
26100 +               return vc_ctx_create(id, NULL);
26101 +       case VCMD_ctx_create:
26102 +               return vc_ctx_create(id, data);
26103 +       case VCMD_ctx_migrate_v0:
26104 +               return vc_ctx_migrate(vxi, NULL);
26105 +       case VCMD_ctx_migrate:
26106 +               return vc_ctx_migrate(vxi, data);
26107 +
26108 +       case VCMD_net_create_v0:
26109 +               return vc_net_create(id, NULL);
26110 +       case VCMD_net_create:
26111 +               return vc_net_create(id, data);
26112 +       case VCMD_net_migrate:
26113 +               return vc_net_migrate(nxi, data);
26114 +
26115 +       case VCMD_tag_migrate:
26116 +               return vc_tag_migrate(id);
26117 +
26118 +       case VCMD_net_add:
26119 +               return vc_net_add(nxi, data);
26120 +       case VCMD_net_remove:
26121 +               return vc_net_remove(nxi, data);
26122 +
26123 +       case VCMD_net_add_ipv4:
26124 +               return vc_net_add_ipv4(nxi, data);
26125 +       case VCMD_net_remove_ipv4:
26126 +               return vc_net_remove_ipv4(nxi, data);
26127 +#ifdef CONFIG_IPV6
26128 +       case VCMD_net_add_ipv6:
26129 +               return vc_net_add_ipv6(nxi, data);
26130 +       case VCMD_net_remove_ipv6:
26131 +               return vc_net_remove_ipv6(nxi, data);
26132 +#endif
26133 +/*     case VCMD_add_match_ipv4:
26134 +               return vc_add_match_ipv4(nxi, data);
26135 +       case VCMD_get_match_ipv4:
26136 +               return vc_get_match_ipv4(nxi, data);
26137 +#ifdef CONFIG_IPV6
26138 +       case VCMD_add_match_ipv6:
26139 +               return vc_add_match_ipv6(nxi, data);
26140 +       case VCMD_get_match_ipv6:
26141 +               return vc_get_match_ipv6(nxi, data);
26142 +#endif */
26143 +
26144 +#ifdef CONFIG_VSERVER_DEVICE
26145 +       case VCMD_set_mapping:
26146 +               return __COMPAT(vc_set_mapping, vxi, data, compat);
26147 +       case VCMD_unset_mapping:
26148 +               return __COMPAT(vc_unset_mapping, vxi, data, compat);
26149 +#endif
26150 +#ifdef CONFIG_VSERVER_HISTORY
26151 +       case VCMD_dump_history:
26152 +               return vc_dump_history(id);
26153 +       case VCMD_read_history:
26154 +               return __COMPAT(vc_read_history, id, data, compat);
26155 +#endif
26156 +#ifdef CONFIG_VSERVER_MONITOR
26157 +       case VCMD_read_monitor:
26158 +               return __COMPAT(vc_read_monitor, id, data, compat);
26159 +#endif
26160 +       default:
26161 +               vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
26162 +                       VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
26163 +       }
26164 +       return -ENOSYS;
26165 +}
26166 +
26167 +
26168 +#define        __VCMD(vcmd, _perm, _args, _flags)              \
26169 +       case VCMD_ ## vcmd: perm = _perm;               \
26170 +               args = _args; flags = _flags; break
26171 +
26172 +
26173 +#define VCA_NONE       0x00
26174 +#define VCA_VXI                0x01
26175 +#define VCA_NXI                0x02
26176 +
26177 +#define VCF_NONE       0x00
26178 +#define VCF_INFO       0x01
26179 +#define VCF_ADMIN      0x02
26180 +#define VCF_ARES       0x06    /* includes admin */
26181 +#define VCF_SETUP      0x08
26182 +
26183 +#define VCF_ZIDOK      0x10    /* zero id okay */
26184 +
26185 +
26186 +static inline
26187 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
26188 +{
26189 +       long ret;
26190 +       int permit = -1, state = 0;
26191 +       int perm = -1, args = 0, flags = 0;
26192 +       struct vx_info *vxi = NULL;
26193 +       struct nx_info *nxi = NULL;
26194 +
26195 +       switch (cmd) {
26196 +       /* unpriviledged commands */
26197 +       __VCMD(get_version,      0, VCA_NONE,   0);
26198 +       __VCMD(get_vci,          0, VCA_NONE,   0);
26199 +       __VCMD(get_rlimit_mask,  0, VCA_NONE,   0);
26200 +       __VCMD(get_space_mask_v0,0, VCA_NONE,   0);
26201 +       __VCMD(get_space_mask,   0, VCA_NONE,   0);
26202 +       __VCMD(get_space_default,0, VCA_NONE,   0);
26203 +
26204 +       /* info commands */
26205 +       __VCMD(task_xid,         2, VCA_NONE,   0);
26206 +       __VCMD(reset_hits,       2, VCA_VXI,    0);
26207 +       __VCMD(reset_minmax,     2, VCA_VXI,    0);
26208 +       __VCMD(vx_info,          3, VCA_VXI,    VCF_INFO);
26209 +       __VCMD(get_bcaps,        3, VCA_VXI,    VCF_INFO);
26210 +       __VCMD(get_ccaps,        3, VCA_VXI,    VCF_INFO);
26211 +       __VCMD(get_cflags,       3, VCA_VXI,    VCF_INFO);
26212 +       __VCMD(get_badness,      3, VCA_VXI,    VCF_INFO);
26213 +       __VCMD(get_vhi_name,     3, VCA_VXI,    VCF_INFO);
26214 +       __VCMD(get_rlimit,       3, VCA_VXI,    VCF_INFO);
26215 +
26216 +       __VCMD(ctx_stat,         3, VCA_VXI,    VCF_INFO);
26217 +       __VCMD(virt_stat,        3, VCA_VXI,    VCF_INFO);
26218 +       __VCMD(sock_stat,        3, VCA_VXI,    VCF_INFO);
26219 +       __VCMD(rlimit_stat,      3, VCA_VXI,    VCF_INFO);
26220 +
26221 +       __VCMD(task_nid,         2, VCA_NONE,   0);
26222 +       __VCMD(nx_info,          3, VCA_NXI,    VCF_INFO);
26223 +       __VCMD(get_ncaps,        3, VCA_NXI,    VCF_INFO);
26224 +       __VCMD(get_nflags,       3, VCA_NXI,    VCF_INFO);
26225 +
26226 +       __VCMD(task_tag,         2, VCA_NONE,   0);
26227 +
26228 +       __VCMD(get_iattr,        2, VCA_NONE,   0);
26229 +       __VCMD(fget_iattr,       2, VCA_NONE,   0);
26230 +       __VCMD(get_dlimit,       3, VCA_NONE,   VCF_INFO);
26231 +       __VCMD(get_sched,        3, VCA_VXI,    VCF_INFO);
26232 +       __VCMD(sched_info,       3, VCA_VXI,    VCF_INFO | VCF_ZIDOK);
26233 +
26234 +       /* lower admin commands */
26235 +       __VCMD(wait_exit,        4, VCA_VXI,    VCF_INFO);
26236 +       __VCMD(ctx_create_v0,    5, VCA_NONE,   0);
26237 +       __VCMD(ctx_create,       5, VCA_NONE,   0);
26238 +       __VCMD(ctx_migrate_v0,   5, VCA_VXI,    VCF_ADMIN);
26239 +       __VCMD(ctx_migrate,      5, VCA_VXI,    VCF_ADMIN);
26240 +       __VCMD(enter_space_v0,   5, VCA_VXI,    VCF_ADMIN);
26241 +       __VCMD(enter_space_v1,   5, VCA_VXI,    VCF_ADMIN);
26242 +       __VCMD(enter_space,      5, VCA_VXI,    VCF_ADMIN);
26243 +
26244 +       __VCMD(net_create_v0,    5, VCA_NONE,   0);
26245 +       __VCMD(net_create,       5, VCA_NONE,   0);
26246 +       __VCMD(net_migrate,      5, VCA_NXI,    VCF_ADMIN);
26247 +
26248 +       __VCMD(tag_migrate,      5, VCA_NONE,   VCF_ADMIN);
26249 +
26250 +       /* higher admin commands */
26251 +       __VCMD(ctx_kill,         6, VCA_VXI,    VCF_ARES);
26252 +       __VCMD(set_space_v1,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26253 +       __VCMD(set_space,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26254 +
26255 +       __VCMD(set_ccaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26256 +       __VCMD(set_bcaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26257 +       __VCMD(set_cflags,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26258 +       __VCMD(set_badness,      7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26259 +
26260 +       __VCMD(set_vhi_name,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26261 +       __VCMD(set_rlimit,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26262 +       __VCMD(set_sched,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26263 +       __VCMD(set_sched_v4,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
26264 +
26265 +       __VCMD(set_ncaps,        7, VCA_NXI,    VCF_ARES | VCF_SETUP);
26266 +       __VCMD(set_nflags,       7, VCA_NXI,    VCF_ARES | VCF_SETUP);
26267 +       __VCMD(net_add,          8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26268 +       __VCMD(net_remove,       8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26269 +       __VCMD(net_add_ipv4,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26270 +       __VCMD(net_remove_ipv4,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26271 +#ifdef CONFIG_IPV6
26272 +       __VCMD(net_add_ipv6,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26273 +       __VCMD(net_remove_ipv6,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
26274 +#endif
26275 +       __VCMD(set_iattr,        7, VCA_NONE,   0);
26276 +       __VCMD(fset_iattr,       7, VCA_NONE,   0);
26277 +       __VCMD(set_dlimit,       7, VCA_NONE,   VCF_ARES);
26278 +       __VCMD(add_dlimit,       8, VCA_NONE,   VCF_ARES);
26279 +       __VCMD(rem_dlimit,       8, VCA_NONE,   VCF_ARES);
26280 +
26281 +#ifdef CONFIG_VSERVER_DEVICE
26282 +       __VCMD(set_mapping,      8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
26283 +       __VCMD(unset_mapping,    8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
26284 +#endif
26285 +       /* debug level admin commands */
26286 +#ifdef CONFIG_VSERVER_HISTORY
26287 +       __VCMD(dump_history,     9, VCA_NONE,   0);
26288 +       __VCMD(read_history,     9, VCA_NONE,   0);
26289 +#endif
26290 +#ifdef CONFIG_VSERVER_MONITOR
26291 +       __VCMD(read_monitor,     9, VCA_NONE,   0);
26292 +#endif
26293 +
26294 +       default:
26295 +               perm = -1;
26296 +       }
26297 +
26298 +       vxdprintk(VXD_CBIT(switch, 0),
26299 +               "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
26300 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
26301 +               VC_VERSION(cmd), id, data, compat,
26302 +               perm, args, flags);
26303 +
26304 +       ret = -ENOSYS;
26305 +       if (perm < 0)
26306 +               goto out;
26307 +
26308 +       state = 1;
26309 +       if (!capable(CAP_CONTEXT))
26310 +               goto out;
26311 +
26312 +       state = 2;
26313 +       /* moved here from the individual commands */
26314 +       ret = -EPERM;
26315 +       if ((perm > 1) && !capable(CAP_SYS_ADMIN))
26316 +               goto out;
26317 +
26318 +       state = 3;
26319 +       /* vcmd involves resource management  */
26320 +       ret = -EPERM;
26321 +       if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
26322 +               goto out;
26323 +
26324 +       state = 4;
26325 +       /* various legacy exceptions */
26326 +       switch (cmd) {
26327 +       /* will go away when spectator is a cap */
26328 +       case VCMD_ctx_migrate_v0:
26329 +       case VCMD_ctx_migrate:
26330 +               if (id == 1) {
26331 +                       current->xid = 1;
26332 +                       ret = 1;
26333 +                       goto out;
26334 +               }
26335 +               break;
26336 +
26337 +       /* will go away when spectator is a cap */
26338 +       case VCMD_net_migrate:
26339 +               if (id == 1) {
26340 +                       current->nid = 1;
26341 +                       ret = 1;
26342 +                       goto out;
26343 +               }
26344 +               break;
26345 +       }
26346 +
26347 +       /* vcmds are fine by default */
26348 +       permit = 1;
26349 +
26350 +       /* admin type vcmds require admin ... */
26351 +       if (flags & VCF_ADMIN)
26352 +               permit = vx_check(0, VS_ADMIN) ? 1 : 0;
26353 +
26354 +       /* ... but setup type vcmds override that */
26355 +       if (!permit && (flags & VCF_SETUP))
26356 +               permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
26357 +
26358 +       state = 5;
26359 +       ret = -EPERM;
26360 +       if (!permit)
26361 +               goto out;
26362 +
26363 +       state = 6;
26364 +       if (!id && (flags & VCF_ZIDOK))
26365 +               goto skip_id;
26366 +
26367 +       ret = -ESRCH;
26368 +       if (args & VCA_VXI) {
26369 +               vxi = lookup_vx_info(id);
26370 +               if (!vxi)
26371 +                       goto out;
26372 +
26373 +               if ((flags & VCF_ADMIN) &&
26374 +                       /* special case kill for shutdown */
26375 +                       (cmd != VCMD_ctx_kill) &&
26376 +                       /* can context be administrated? */
26377 +                       !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
26378 +                       ret = -EACCES;
26379 +                       goto out_vxi;
26380 +               }
26381 +       }
26382 +       state = 7;
26383 +       if (args & VCA_NXI) {
26384 +               nxi = lookup_nx_info(id);
26385 +               if (!nxi)
26386 +                       goto out_vxi;
26387 +
26388 +               if ((flags & VCF_ADMIN) &&
26389 +                       /* can context be administrated? */
26390 +                       !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
26391 +                       ret = -EACCES;
26392 +                       goto out_nxi;
26393 +               }
26394 +       }
26395 +skip_id:
26396 +       state = 8;
26397 +       ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
26398 +
26399 +out_nxi:
26400 +       if ((args & VCA_NXI) && nxi)
26401 +               put_nx_info(nxi);
26402 +out_vxi:
26403 +       if ((args & VCA_VXI) && vxi)
26404 +               put_vx_info(vxi);
26405 +out:
26406 +       vxdprintk(VXD_CBIT(switch, 1),
26407 +               "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
26408 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
26409 +               VC_VERSION(cmd), ret, ret, state, permit);
26410 +       return ret;
26411 +}
26412 +
26413 +asmlinkage long
26414 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
26415 +{
26416 +       return do_vserver(cmd, id, data, 0);
26417 +}
26418 +
26419 +#ifdef CONFIG_COMPAT
26420 +
26421 +asmlinkage long
26422 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
26423 +{
26424 +       return do_vserver(cmd, id, data, 1);
26425 +}
26426 +
26427 +#endif /* CONFIG_COMPAT */
26428 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/sysctl.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/sysctl.c
26429 --- linux-2.6.33.1/kernel/vserver/sysctl.c      1970-01-01 01:00:00.000000000 +0100
26430 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/sysctl.c      2010-02-25 15:14:16.000000000 +0100
26431 @@ -0,0 +1,241 @@
26432 +/*
26433 + *  kernel/vserver/sysctl.c
26434 + *
26435 + *  Virtual Context Support
26436 + *
26437 + *  Copyright (C) 2004-2007  Herbert Pötzl
26438 + *
26439 + *  V0.01  basic structure
26440 + *
26441 + */
26442 +
26443 +#include <linux/module.h>
26444 +#include <linux/ctype.h>
26445 +#include <linux/sysctl.h>
26446 +#include <linux/parser.h>
26447 +#include <asm/uaccess.h>
26448 +
26449 +enum {
26450 +       CTL_DEBUG_ERROR         = 0,
26451 +       CTL_DEBUG_SWITCH        = 1,
26452 +       CTL_DEBUG_XID,
26453 +       CTL_DEBUG_NID,
26454 +       CTL_DEBUG_TAG,
26455 +       CTL_DEBUG_NET,
26456 +       CTL_DEBUG_LIMIT,
26457 +       CTL_DEBUG_CRES,
26458 +       CTL_DEBUG_DLIM,
26459 +       CTL_DEBUG_QUOTA,
26460 +       CTL_DEBUG_CVIRT,
26461 +       CTL_DEBUG_SPACE,
26462 +       CTL_DEBUG_MISC,
26463 +};
26464 +
26465 +
26466 +unsigned int vx_debug_switch   = 0;
26467 +unsigned int vx_debug_xid      = 0;
26468 +unsigned int vx_debug_nid      = 0;
26469 +unsigned int vx_debug_tag      = 0;
26470 +unsigned int vx_debug_net      = 0;
26471 +unsigned int vx_debug_limit    = 0;
26472 +unsigned int vx_debug_cres     = 0;
26473 +unsigned int vx_debug_dlim     = 0;
26474 +unsigned int vx_debug_quota    = 0;
26475 +unsigned int vx_debug_cvirt    = 0;
26476 +unsigned int vx_debug_space    = 0;
26477 +unsigned int vx_debug_misc     = 0;
26478 +
26479 +
26480 +static struct ctl_table_header *vserver_table_header;
26481 +static ctl_table vserver_root_table[];
26482 +
26483 +
26484 +void vserver_register_sysctl(void)
26485 +{
26486 +       if (!vserver_table_header) {
26487 +               vserver_table_header = register_sysctl_table(vserver_root_table);
26488 +       }
26489 +
26490 +}
26491 +
26492 +void vserver_unregister_sysctl(void)
26493 +{
26494 +       if (vserver_table_header) {
26495 +               unregister_sysctl_table(vserver_table_header);
26496 +               vserver_table_header = NULL;
26497 +       }
26498 +}
26499 +
26500 +
26501 +static int proc_dodebug(ctl_table *table, int write,
26502 +       void __user *buffer, size_t *lenp, loff_t *ppos)
26503 +{
26504 +       char            tmpbuf[20], *p, c;
26505 +       unsigned int    value;
26506 +       size_t          left, len;
26507 +
26508 +       if ((*ppos && !write) || !*lenp) {
26509 +               *lenp = 0;
26510 +               return 0;
26511 +       }
26512 +
26513 +       left = *lenp;
26514 +
26515 +       if (write) {
26516 +               if (!access_ok(VERIFY_READ, buffer, left))
26517 +                       return -EFAULT;
26518 +               p = (char *)buffer;
26519 +               while (left && __get_user(c, p) >= 0 && isspace(c))
26520 +                       left--, p++;
26521 +               if (!left)
26522 +                       goto done;
26523 +
26524 +               if (left > sizeof(tmpbuf) - 1)
26525 +                       return -EINVAL;
26526 +               if (copy_from_user(tmpbuf, p, left))
26527 +                       return -EFAULT;
26528 +               tmpbuf[left] = '\0';
26529 +
26530 +               for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
26531 +                       value = 10 * value + (*p - '0');
26532 +               if (*p && !isspace(*p))
26533 +                       return -EINVAL;
26534 +               while (left && isspace(*p))
26535 +                       left--, p++;
26536 +               *(unsigned int *)table->data = value;
26537 +       } else {
26538 +               if (!access_ok(VERIFY_WRITE, buffer, left))
26539 +                       return -EFAULT;
26540 +               len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
26541 +               if (len > left)
26542 +                       len = left;
26543 +               if (__copy_to_user(buffer, tmpbuf, len))
26544 +                       return -EFAULT;
26545 +               if ((left -= len) > 0) {
26546 +                       if (put_user('\n', (char *)buffer + len))
26547 +                               return -EFAULT;
26548 +                       left--;
26549 +               }
26550 +       }
26551 +
26552 +done:
26553 +       *lenp -= left;
26554 +       *ppos += *lenp;
26555 +       return 0;
26556 +}
26557 +
26558 +static int zero;
26559 +
26560 +#define        CTL_ENTRY(ctl, name)                            \
26561 +       {                                               \
26562 +               .procname       = #name,                \
26563 +               .data           = &vx_ ## name,         \
26564 +               .maxlen         = sizeof(int),          \
26565 +               .mode           = 0644,                 \
26566 +               .proc_handler   = &proc_dodebug,        \
26567 +               .extra1         = &zero,                \
26568 +               .extra2         = &zero,                \
26569 +       }
26570 +
26571 +static ctl_table vserver_debug_table[] = {
26572 +       CTL_ENTRY(CTL_DEBUG_SWITCH,     debug_switch),
26573 +       CTL_ENTRY(CTL_DEBUG_XID,        debug_xid),
26574 +       CTL_ENTRY(CTL_DEBUG_NID,        debug_nid),
26575 +       CTL_ENTRY(CTL_DEBUG_TAG,        debug_tag),
26576 +       CTL_ENTRY(CTL_DEBUG_NET,        debug_net),
26577 +       CTL_ENTRY(CTL_DEBUG_LIMIT,      debug_limit),
26578 +       CTL_ENTRY(CTL_DEBUG_CRES,       debug_cres),
26579 +       CTL_ENTRY(CTL_DEBUG_DLIM,       debug_dlim),
26580 +       CTL_ENTRY(CTL_DEBUG_QUOTA,      debug_quota),
26581 +       CTL_ENTRY(CTL_DEBUG_CVIRT,      debug_cvirt),
26582 +       CTL_ENTRY(CTL_DEBUG_SPACE,      debug_space),
26583 +       CTL_ENTRY(CTL_DEBUG_MISC,       debug_misc),
26584 +       { 0 }
26585 +};
26586 +
26587 +static ctl_table vserver_root_table[] = {
26588 +       {
26589 +               .procname       = "vserver",
26590 +               .mode           = 0555,
26591 +               .child          = vserver_debug_table
26592 +       },
26593 +       { 0 }
26594 +};
26595 +
26596 +
26597 +static match_table_t tokens = {
26598 +       { CTL_DEBUG_SWITCH,     "switch=%x"     },
26599 +       { CTL_DEBUG_XID,        "xid=%x"        },
26600 +       { CTL_DEBUG_NID,        "nid=%x"        },
26601 +       { CTL_DEBUG_TAG,        "tag=%x"        },
26602 +       { CTL_DEBUG_NET,        "net=%x"        },
26603 +       { CTL_DEBUG_LIMIT,      "limit=%x"      },
26604 +       { CTL_DEBUG_CRES,       "cres=%x"       },
26605 +       { CTL_DEBUG_DLIM,       "dlim=%x"       },
26606 +       { CTL_DEBUG_QUOTA,      "quota=%x"      },
26607 +       { CTL_DEBUG_CVIRT,      "cvirt=%x"      },
26608 +       { CTL_DEBUG_SPACE,      "space=%x"      },
26609 +       { CTL_DEBUG_MISC,       "misc=%x"       },
26610 +       { CTL_DEBUG_ERROR,      NULL            }
26611 +};
26612 +
26613 +#define        HANDLE_CASE(id, name, val)                              \
26614 +       case CTL_DEBUG_ ## id:                                  \
26615 +               vx_debug_ ## name = val;                        \
26616 +               printk("vs_debug_" #name "=0x%x\n", val);       \
26617 +               break
26618 +
26619 +
26620 +static int __init vs_debug_setup(char *str)
26621 +{
26622 +       char *p;
26623 +       int token;
26624 +
26625 +       printk("vs_debug_setup(%s)\n", str);
26626 +       while ((p = strsep(&str, ",")) != NULL) {
26627 +               substring_t args[MAX_OPT_ARGS];
26628 +               unsigned int value;
26629 +
26630 +               if (!*p)
26631 +                       continue;
26632 +
26633 +               token = match_token(p, tokens, args);
26634 +               value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
26635 +
26636 +               switch (token) {
26637 +               HANDLE_CASE(SWITCH, switch, value);
26638 +               HANDLE_CASE(XID,    xid,    value);
26639 +               HANDLE_CASE(NID,    nid,    value);
26640 +               HANDLE_CASE(TAG,    tag,    value);
26641 +               HANDLE_CASE(NET,    net,    value);
26642 +               HANDLE_CASE(LIMIT,  limit,  value);
26643 +               HANDLE_CASE(CRES,   cres,   value);
26644 +               HANDLE_CASE(DLIM,   dlim,   value);
26645 +               HANDLE_CASE(QUOTA,  quota,  value);
26646 +               HANDLE_CASE(CVIRT,  cvirt,  value);
26647 +               HANDLE_CASE(SPACE,  space,  value);
26648 +               HANDLE_CASE(MISC,   misc,   value);
26649 +               default:
26650 +                       return -EINVAL;
26651 +                       break;
26652 +               }
26653 +       }
26654 +       return 1;
26655 +}
26656 +
26657 +__setup("vsdebug=", vs_debug_setup);
26658 +
26659 +
26660 +
26661 +EXPORT_SYMBOL_GPL(vx_debug_switch);
26662 +EXPORT_SYMBOL_GPL(vx_debug_xid);
26663 +EXPORT_SYMBOL_GPL(vx_debug_nid);
26664 +EXPORT_SYMBOL_GPL(vx_debug_net);
26665 +EXPORT_SYMBOL_GPL(vx_debug_limit);
26666 +EXPORT_SYMBOL_GPL(vx_debug_cres);
26667 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
26668 +EXPORT_SYMBOL_GPL(vx_debug_quota);
26669 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
26670 +EXPORT_SYMBOL_GPL(vx_debug_space);
26671 +EXPORT_SYMBOL_GPL(vx_debug_misc);
26672 +
26673 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/tag.c linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/tag.c
26674 --- linux-2.6.33.1/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
26675 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/tag.c 2010-02-25 12:02:16.000000000 +0100
26676 @@ -0,0 +1,63 @@
26677 +/*
26678 + *  linux/kernel/vserver/tag.c
26679 + *
26680 + *  Virtual Server: Shallow Tag Space
26681 + *
26682 + *  Copyright (C) 2007  Herbert Pötzl
26683 + *
26684 + *  V0.01  basic implementation
26685 + *
26686 + */
26687 +
26688 +#include <linux/sched.h>
26689 +#include <linux/vserver/debug.h>
26690 +#include <linux/vs_pid.h>
26691 +#include <linux/vs_tag.h>
26692 +
26693 +#include <linux/vserver/tag_cmd.h>
26694 +
26695 +
26696 +int dx_migrate_task(struct task_struct *p, tag_t tag)
26697 +{
26698 +       if (!p)
26699 +               BUG();
26700 +
26701 +       vxdprintk(VXD_CBIT(tag, 5),
26702 +               "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
26703 +
26704 +       task_lock(p);
26705 +       p->tag = tag;
26706 +       task_unlock(p);
26707 +
26708 +       vxdprintk(VXD_CBIT(tag, 5),
26709 +               "moved task %p into [#%d]", p, tag);
26710 +       return 0;
26711 +}
26712 +
26713 +/* vserver syscall commands below here */
26714 +
26715 +/* taks xid and vx_info functions */
26716 +
26717 +
26718 +int vc_task_tag(uint32_t id)
26719 +{
26720 +       tag_t tag;
26721 +
26722 +       if (id) {
26723 +               struct task_struct *tsk;
26724 +               read_lock(&tasklist_lock);
26725 +               tsk = find_task_by_real_pid(id);
26726 +               tag = (tsk) ? tsk->tag : -ESRCH;
26727 +               read_unlock(&tasklist_lock);
26728 +       } else
26729 +               tag = dx_current_tag();
26730 +       return tag;
26731 +}
26732 +
26733 +
26734 +int vc_tag_migrate(uint32_t tag)
26735 +{
26736 +       return dx_migrate_task(current, tag & 0xFFFF);
26737 +}
26738 +
26739 +
26740 diff -NurpP --minimal linux-2.6.33.1/kernel/vserver/vci_config.h linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/vci_config.h
26741 --- linux-2.6.33.1/kernel/vserver/vci_config.h  1970-01-01 01:00:00.000000000 +0100
26742 +++ linux-2.6.33.1-vs2.3.0.36.30.4/kernel/vserver/vci_config.h  2010-02-25 12:02:16.000000000 +0100
26743 @@ -0,0 +1,81 @@
26744 +
26745 +/*  interface version */
26746 +
26747 +#define VCI_VERSION            0x00020305
26748 +
26749 +
26750 +enum {
26751 +       VCI_KCBIT_NO_DYNAMIC = 0,
26752 +
26753 +       VCI_KCBIT_PROC_SECURE = 4,
26754 +       VCI_KCBIT_HARDCPU = 5,
26755 +       VCI_KCBIT_IDLELIMIT = 6,
26756 +       VCI_KCBIT_IDLETIME = 7,
26757 +
26758 +       VCI_KCBIT_COWBL = 8,
26759 +       VCI_KCBIT_FULLCOWBL = 9,
26760 +       VCI_KCBIT_SPACES = 10,
26761 +       VCI_KCBIT_NETV2 = 11,
26762 +
26763 +       VCI_KCBIT_DEBUG = 16,
26764 +       VCI_KCBIT_HISTORY = 20,
26765 +       VCI_KCBIT_TAGGED = 24,
26766 +       VCI_KCBIT_PPTAG = 28,
26767 +
26768 +       VCI_KCBIT_MORE = 31,
26769 +};
26770 +
26771 +
26772 +static inline uint32_t vci_kernel_config(void)
26773 +{
26774 +       return
26775 +       (1 << VCI_KCBIT_NO_DYNAMIC) |
26776 +
26777 +       /* configured features */
26778 +#ifdef CONFIG_VSERVER_PROC_SECURE
26779 +       (1 << VCI_KCBIT_PROC_SECURE) |
26780 +#endif
26781 +#ifdef CONFIG_VSERVER_HARDCPU
26782 +       (1 << VCI_KCBIT_HARDCPU) |
26783 +#endif
26784 +#ifdef CONFIG_VSERVER_IDLELIMIT
26785 +       (1 << VCI_KCBIT_IDLELIMIT) |
26786 +#endif
26787 +#ifdef CONFIG_VSERVER_IDLETIME
26788 +       (1 << VCI_KCBIT_IDLETIME) |
26789 +#endif
26790 +#ifdef CONFIG_VSERVER_COWBL
26791 +       (1 << VCI_KCBIT_COWBL) |
26792 +       (1 << VCI_KCBIT_FULLCOWBL) |
26793 +#endif
26794 +       (1 << VCI_KCBIT_SPACES) |
26795 +       (1 << VCI_KCBIT_NETV2) |
26796 +
26797 +       /* debug options */
26798 +#ifdef CONFIG_VSERVER_DEBUG
26799 +       (1 << VCI_KCBIT_DEBUG) |
26800 +#endif
26801 +#ifdef CONFIG_VSERVER_HISTORY
26802 +       (1 << VCI_KCBIT_HISTORY) |
26803 +#endif
26804 +
26805 +       /* inode context tagging */
26806 +#if    defined(CONFIG_TAGGING_NONE)
26807 +       (0 << VCI_KCBIT_TAGGED) |
26808 +#elif  defined(CONFIG_TAGGING_UID16)
26809 +       (1 << VCI_KCBIT_TAGGED) |
26810 +#elif  defined(CONFIG_TAGGING_GID16)
26811 +       (2 << VCI_KCBIT_TAGGED) |
26812 +#elif  defined(CONFIG_TAGGING_ID24)
26813 +       (3 << VCI_KCBIT_TAGGED) |
26814 +#elif  defined(CONFIG_TAGGING_INTERN)
26815 +       (4 << VCI_KCBIT_TAGGED) |
26816 +#elif  defined(CONFIG_TAGGING_RUNTIME)
26817 +       (5 << VCI_KCBIT_TAGGED) |
26818 +#else
26819 +       (7 << VCI_KCBIT_TAGGED) |
26820 +#endif
26821 +       (1 << VCI_KCBIT_PPTAG) |
26822 +       0;
26823 +}
26824 +
26825 diff -NurpP --minimal linux-2.6.33.1/mm/filemap_xip.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/filemap_xip.c
26826 --- linux-2.6.33.1/mm/filemap_xip.c     2009-12-03 20:02:58.000000000 +0100
26827 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/filemap_xip.c     2010-02-25 12:02:16.000000000 +0100
26828 @@ -17,6 +17,7 @@
26829  #include <linux/sched.h>
26830  #include <linux/seqlock.h>
26831  #include <linux/mutex.h>
26832 +#include <linux/vs_memory.h>
26833  #include <asm/tlbflush.h>
26834  #include <asm/io.h>
26835  
26836 diff -NurpP --minimal linux-2.6.33.1/mm/fremap.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/fremap.c
26837 --- linux-2.6.33.1/mm/fremap.c  2009-03-24 14:22:45.000000000 +0100
26838 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/fremap.c  2010-02-25 12:02:16.000000000 +0100
26839 @@ -16,6 +16,7 @@
26840  #include <linux/module.h>
26841  #include <linux/syscalls.h>
26842  #include <linux/mmu_notifier.h>
26843 +#include <linux/vs_memory.h>
26844  
26845  #include <asm/mmu_context.h>
26846  #include <asm/cacheflush.h>
26847 diff -NurpP --minimal linux-2.6.33.1/mm/hugetlb.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/hugetlb.c
26848 --- linux-2.6.33.1/mm/hugetlb.c 2010-02-25 11:52:09.000000000 +0100
26849 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/hugetlb.c 2010-02-25 12:16:11.000000000 +0100
26850 @@ -25,6 +25,7 @@
26851  
26852  #include <linux/hugetlb.h>
26853  #include <linux/node.h>
26854 +#include <linux/vs_memory.h>
26855  #include "internal.h"
26856  
26857  const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26858 diff -NurpP --minimal linux-2.6.33.1/mm/memcontrol.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/memcontrol.c
26859 --- linux-2.6.33.1/mm/memcontrol.c      2010-02-25 11:52:09.000000000 +0100
26860 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/memcontrol.c      2010-02-26 10:04:15.000000000 +0100
26861 @@ -555,6 +555,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26862                                 struct mem_cgroup, css);
26863  }
26864  
26865 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26866 +{
26867 +       return res_counter_read_u64(&mem->res, member);
26868 +}
26869 +
26870 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26871 +{
26872 +       return res_counter_read_u64(&mem->memsw, member);
26873 +}
26874 +
26875 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26876 +{
26877 +       return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_CACHE);
26878 +}
26879 +
26880 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26881 +{
26882 +       return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
26883 +}
26884 +
26885 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26886 +{
26887 +       return mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_FILE_MAPPED);
26888 +}
26889 +
26890  static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26891  {
26892         struct mem_cgroup *mem = NULL;
26893 diff -NurpP --minimal linux-2.6.33.1/mm/memory.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/memory.c
26894 --- linux-2.6.33.1/mm/memory.c  2010-02-25 11:52:09.000000000 +0100
26895 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/memory.c  2010-02-25 12:02:16.000000000 +0100
26896 @@ -56,6 +56,7 @@
26897  #include <linux/kallsyms.h>
26898  #include <linux/swapops.h>
26899  #include <linux/elf.h>
26900 +// #include <linux/vs_memory.h>
26901  
26902  #include <asm/io.h>
26903  #include <asm/pgalloc.h>
26904 @@ -651,6 +652,9 @@ static int copy_pte_range(struct mm_stru
26905         int rss[2];
26906         swp_entry_t entry = (swp_entry_t){0};
26907  
26908 +       if (!vx_rss_avail(dst_mm, ((end - addr)/PAGE_SIZE + 1)))
26909 +               return -ENOMEM;
26910 +
26911  again:
26912         rss[1] = rss[0] = 0;
26913         dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
26914 @@ -2670,6 +2674,8 @@ static int do_anonymous_page(struct mm_s
26915         /* Allocate our own private page. */
26916         pte_unmap(page_table);
26917  
26918 +       if (!vx_rss_avail(mm, 1))
26919 +               goto oom;
26920         if (unlikely(anon_vma_prepare(vma)))
26921                 goto oom;
26922         page = alloc_zeroed_user_highpage_movable(vma, address);
26923 @@ -2961,6 +2967,7 @@ static inline int handle_pte_fault(struc
26924  {
26925         pte_t entry;
26926         spinlock_t *ptl;
26927 +       int ret = 0, type = VXPT_UNKNOWN;
26928  
26929         entry = *pte;
26930         if (!pte_present(entry)) {
26931 @@ -2985,9 +2992,12 @@ static inline int handle_pte_fault(struc
26932         if (unlikely(!pte_same(*pte, entry)))
26933                 goto unlock;
26934         if (flags & FAULT_FLAG_WRITE) {
26935 -               if (!pte_write(entry))
26936 -                       return do_wp_page(mm, vma, address,
26937 +               if (!pte_write(entry)) {
26938 +                       ret = do_wp_page(mm, vma, address,
26939                                         pte, pmd, ptl, entry);
26940 +                       type = VXPT_WRITE;
26941 +                       goto out;
26942 +               }
26943                 entry = pte_mkdirty(entry);
26944         }
26945         entry = pte_mkyoung(entry);
26946 @@ -3005,7 +3015,10 @@ static inline int handle_pte_fault(struc
26947         }
26948  unlock:
26949         pte_unmap_unlock(pte, ptl);
26950 -       return 0;
26951 +       ret = 0;
26952 +out:
26953 +       vx_page_fault(mm, vma, type, ret);
26954 +       return ret;
26955  }
26956  
26957  /*
26958 diff -NurpP --minimal linux-2.6.33.1/mm/mlock.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/mlock.c
26959 --- linux-2.6.33.1/mm/mlock.c   2010-02-25 11:52:09.000000000 +0100
26960 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/mlock.c   2010-02-25 12:02:16.000000000 +0100
26961 @@ -18,6 +18,7 @@
26962  #include <linux/rmap.h>
26963  #include <linux/mmzone.h>
26964  #include <linux/hugetlb.h>
26965 +#include <linux/vs_memory.h>
26966  
26967  #include "internal.h"
26968  
26969 @@ -398,7 +399,7 @@ success:
26970         nr_pages = (end - start) >> PAGE_SHIFT;
26971         if (!lock)
26972                 nr_pages = -nr_pages;
26973 -       mm->locked_vm += nr_pages;
26974 +       vx_vmlocked_add(mm, nr_pages);
26975  
26976         /*
26977          * vm_flags is protected by the mmap_sem held in write mode.
26978 @@ -471,7 +472,7 @@ static int do_mlock(unsigned long start,
26979  
26980  SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
26981  {
26982 -       unsigned long locked;
26983 +       unsigned long locked, grow;
26984         unsigned long lock_limit;
26985         int error = -ENOMEM;
26986  
26987 @@ -484,8 +485,10 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
26988         len = PAGE_ALIGN(len + (start & ~PAGE_MASK));
26989         start &= PAGE_MASK;
26990  
26991 -       locked = len >> PAGE_SHIFT;
26992 -       locked += current->mm->locked_vm;
26993 +       grow = len >> PAGE_SHIFT;
26994 +       if (!vx_vmlocked_avail(current->mm, grow))
26995 +               goto out;
26996 +       locked = current->mm->locked_vm + grow;
26997  
26998         lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
26999         lock_limit >>= PAGE_SHIFT;
27000 @@ -493,6 +496,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, st
27001         /* check against resource limits */
27002         if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
27003                 error = do_mlock(start, len, 1);
27004 +out:
27005         up_write(&current->mm->mmap_sem);
27006         return error;
27007  }
27008 @@ -554,6 +558,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
27009         lock_limit >>= PAGE_SHIFT;
27010  
27011         ret = -ENOMEM;
27012 +       if (!vx_vmlocked_avail(current->mm, current->mm->total_vm))
27013 +               goto out;
27014         if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
27015             capable(CAP_IPC_LOCK))
27016                 ret = do_mlockall(flags);
27017 @@ -628,8 +634,10 @@ int account_locked_memory(struct mm_stru
27018         if (lim < vm)
27019                 goto out;
27020  
27021 -       mm->total_vm  += pgsz;
27022 -       mm->locked_vm += pgsz;
27023 +       // mm->total_vm  += pgsz;
27024 +       vx_vmpages_add(mm, pgsz);
27025 +       // mm->locked_vm += pgsz;
27026 +       vx_vmlocked_add(mm, pgsz);
27027  
27028         error = 0;
27029   out:
27030 @@ -643,8 +651,10 @@ void refund_locked_memory(struct mm_stru
27031  
27032         down_write(&mm->mmap_sem);
27033  
27034 -       mm->total_vm  -= pgsz;
27035 -       mm->locked_vm -= pgsz;
27036 +       // mm->total_vm  -= pgsz;
27037 +       vx_vmpages_sub(mm, pgsz);
27038 +       // mm->locked_vm -= pgsz;
27039 +       vx_vmlocked_sub(mm, pgsz);
27040  
27041         up_write(&mm->mmap_sem);
27042  }
27043 diff -NurpP --minimal linux-2.6.33.1/mm/mmap.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/mmap.c
27044 --- linux-2.6.33.1/mm/mmap.c    2010-02-25 11:52:09.000000000 +0100
27045 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/mmap.c    2010-02-25 12:02:16.000000000 +0100
27046 @@ -1262,7 +1262,8 @@ munmap_back:
27047  out:
27048         perf_event_mmap(vma);
27049  
27050 -       mm->total_vm += len >> PAGE_SHIFT;
27051 +       // mm->total_vm += len >> PAGE_SHIFT;
27052 +       vx_vmpages_add(mm, len >> PAGE_SHIFT);
27053         vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
27054         if (vm_flags & VM_LOCKED) {
27055                 /*
27056 @@ -1271,7 +1272,8 @@ out:
27057                 long nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
27058                 if (nr_pages < 0)
27059                         return nr_pages;        /* vma gone! */
27060 -               mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
27061 +               // mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
27062 +               vx_vmlocked_add(mm, (len >> PAGE_SHIFT) - nr_pages);
27063         } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
27064                 make_pages_present(addr, addr + len);
27065         return addr;
27066 @@ -1626,9 +1628,9 @@ static int acct_stack_growth(struct vm_a
27067                 return -ENOMEM;
27068  
27069         /* Ok, everything looks good - let it rip */
27070 -       mm->total_vm += grow;
27071 +       vx_vmpages_add(mm, grow);
27072         if (vma->vm_flags & VM_LOCKED)
27073 -               mm->locked_vm += grow;
27074 +               vx_vmlocked_add(mm, grow);
27075         vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
27076         return 0;
27077  }
27078 @@ -1803,7 +1805,8 @@ static void remove_vma_list(struct mm_st
27079         do {
27080                 long nrpages = vma_pages(vma);
27081  
27082 -               mm->total_vm -= nrpages;
27083 +               // mm->total_vm -= nrpages;
27084 +               vx_vmpages_sub(mm, nrpages);
27085                 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
27086                 vma = remove_vma(vma);
27087         } while (vma);
27088 @@ -1995,7 +1998,8 @@ int do_munmap(struct mm_struct *mm, unsi
27089                 struct vm_area_struct *tmp = vma;
27090                 while (tmp && tmp->vm_start < end) {
27091                         if (tmp->vm_flags & VM_LOCKED) {
27092 -                               mm->locked_vm -= vma_pages(tmp);
27093 +                               // mm->locked_vm -= vma_pages(tmp);
27094 +                               vx_vmlocked_sub(mm, vma_pages(tmp));
27095                                 munlock_vma_pages_all(tmp);
27096                         }
27097                         tmp = tmp->vm_next;
27098 @@ -2078,6 +2082,8 @@ unsigned long do_brk(unsigned long addr,
27099                 lock_limit >>= PAGE_SHIFT;
27100                 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
27101                         return -EAGAIN;
27102 +               if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT))
27103 +                       return -ENOMEM;
27104         }
27105  
27106         /*
27107 @@ -2104,7 +2110,8 @@ unsigned long do_brk(unsigned long addr,
27108         if (mm->map_count > sysctl_max_map_count)
27109                 return -ENOMEM;
27110  
27111 -       if (security_vm_enough_memory(len >> PAGE_SHIFT))
27112 +       if (security_vm_enough_memory(len >> PAGE_SHIFT) ||
27113 +               !vx_vmpages_avail(mm, len >> PAGE_SHIFT))
27114                 return -ENOMEM;
27115  
27116         /* Can we just expand an old private anonymous mapping? */
27117 @@ -2130,10 +2137,13 @@ unsigned long do_brk(unsigned long addr,
27118         vma->vm_page_prot = vm_get_page_prot(flags);
27119         vma_link(mm, vma, prev, rb_link, rb_parent);
27120  out:
27121 -       mm->total_vm += len >> PAGE_SHIFT;
27122 +       // mm->total_vm += len >> PAGE_SHIFT;
27123 +       vx_vmpages_add(mm, len >> PAGE_SHIFT);
27124 +
27125         if (flags & VM_LOCKED) {
27126                 if (!mlock_vma_pages_range(vma, addr, addr + len))
27127 -                       mm->locked_vm += (len >> PAGE_SHIFT);
27128 +                       // mm->locked_vm += (len >> PAGE_SHIFT);
27129 +                       vx_vmlocked_add(mm, len >> PAGE_SHIFT);
27130         }
27131         return addr;
27132  }
27133 @@ -2177,6 +2187,11 @@ void exit_mmap(struct mm_struct *mm)
27134         free_pgtables(tlb, vma, FIRST_USER_ADDRESS, 0);
27135         tlb_finish_mmu(tlb, 0, end);
27136  
27137 +       set_mm_counter(mm, file_rss, 0);
27138 +       set_mm_counter(mm, anon_rss, 0);
27139 +       vx_vmpages_sub(mm, mm->total_vm);
27140 +       vx_vmlocked_sub(mm, mm->locked_vm);
27141 +
27142         /*
27143          * Walk the list again, actually closing and freeing it,
27144          * with preemption enabled, without holding any MM locks.
27145 @@ -2216,7 +2231,8 @@ int insert_vm_struct(struct mm_struct * 
27146         if (__vma && __vma->vm_start < vma->vm_end)
27147                 return -ENOMEM;
27148         if ((vma->vm_flags & VM_ACCOUNT) &&
27149 -            security_vm_enough_memory_mm(mm, vma_pages(vma)))
27150 +               (security_vm_enough_memory_mm(mm, vma_pages(vma)) ||
27151 +               !vx_vmpages_avail(mm, vma_pages(vma))))
27152                 return -ENOMEM;
27153         vma_link(mm, vma, prev, rb_link, rb_parent);
27154         return 0;
27155 @@ -2292,6 +2308,8 @@ int may_expand_vm(struct mm_struct *mm, 
27156  
27157         if (cur + npages > lim)
27158                 return 0;
27159 +       if (!vx_vmpages_avail(mm, npages))
27160 +               return 0;
27161         return 1;
27162  }
27163  
27164 @@ -2369,7 +2387,7 @@ int install_special_mapping(struct mm_st
27165                 return -ENOMEM;
27166         }
27167  
27168 -       mm->total_vm += len >> PAGE_SHIFT;
27169 +       vx_vmpages_add(mm, len >> PAGE_SHIFT);
27170  
27171         perf_event_mmap(vma);
27172  
27173 diff -NurpP --minimal linux-2.6.33.1/mm/mremap.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/mremap.c
27174 --- linux-2.6.33.1/mm/mremap.c  2010-02-25 11:52:09.000000000 +0100
27175 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/mremap.c  2010-02-25 12:02:16.000000000 +0100
27176 @@ -20,6 +20,7 @@
27177  #include <linux/security.h>
27178  #include <linux/syscalls.h>
27179  #include <linux/mmu_notifier.h>
27180 +#include <linux/vs_memory.h>
27181  
27182  #include <asm/uaccess.h>
27183  #include <asm/cacheflush.h>
27184 @@ -234,7 +235,7 @@ static unsigned long move_vma(struct vm_
27185          * If this were a serious issue, we'd add a flag to do_munmap().
27186          */
27187         hiwater_vm = mm->hiwater_vm;
27188 -       mm->total_vm += new_len >> PAGE_SHIFT;
27189 +       vx_vmpages_add(mm, new_len >> PAGE_SHIFT);
27190         vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
27191  
27192         if (do_munmap(mm, old_addr, old_len) < 0) {
27193 @@ -252,7 +253,7 @@ static unsigned long move_vma(struct vm_
27194         }
27195  
27196         if (vm_flags & VM_LOCKED) {
27197 -               mm->locked_vm += new_len >> PAGE_SHIFT;
27198 +               vx_vmlocked_add(mm, new_len >> PAGE_SHIFT);
27199                 if (new_len > old_len)
27200                         mlock_vma_pages_range(new_vma, new_addr + old_len,
27201                                                        new_addr + new_len);
27202 @@ -463,10 +464,12 @@ unsigned long do_mremap(unsigned long ad
27203                         vma_adjust(vma, vma->vm_start,
27204                                 addr + new_len, vma->vm_pgoff, NULL);
27205  
27206 -                       mm->total_vm += pages;
27207 +                       // mm->total_vm += pages;
27208 +                       vx_vmpages_add(mm, pages);
27209                         vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
27210                         if (vma->vm_flags & VM_LOCKED) {
27211 -                               mm->locked_vm += pages;
27212 +                               // mm->locked_vm += pages;
27213 +                               vx_vmlocked_add(mm, pages);
27214                                 mlock_vma_pages_range(vma, addr + old_len,
27215                                                    addr + new_len);
27216                         }
27217 diff -NurpP --minimal linux-2.6.33.1/mm/nommu.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/nommu.c
27218 --- linux-2.6.33.1/mm/nommu.c   2010-02-25 11:52:09.000000000 +0100
27219 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/nommu.c   2010-02-25 12:02:16.000000000 +0100
27220 @@ -1349,7 +1349,7 @@ unsigned long do_mmap_pgoff(struct file 
27221         /* okay... we have a mapping; now we have to register it */
27222         result = vma->vm_start;
27223  
27224 -       current->mm->total_vm += len >> PAGE_SHIFT;
27225 +       vx_vmpages_add(current->mm, len >> PAGE_SHIFT);
27226  
27227  share:
27228         add_vma_to_mm(current->mm, vma);
27229 @@ -1637,7 +1637,7 @@ void exit_mmap(struct mm_struct *mm)
27230  
27231         kenter("");
27232  
27233 -       mm->total_vm = 0;
27234 +       vx_vmpages_sub(mm, mm->total_vm);
27235  
27236         while ((vma = mm->mmap)) {
27237                 mm->mmap = vma->vm_next;
27238 diff -NurpP --minimal linux-2.6.33.1/mm/oom_kill.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/oom_kill.c
27239 --- linux-2.6.33.1/mm/oom_kill.c        2010-02-25 11:52:09.000000000 +0100
27240 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/oom_kill.c        2010-02-25 12:20:14.000000000 +0100
27241 @@ -27,6 +27,9 @@
27242  #include <linux/notifier.h>
27243  #include <linux/memcontrol.h>
27244  #include <linux/security.h>
27245 +#include <linux/reboot.h>
27246 +#include <linux/vs_memory.h>
27247 +#include <linux/vs_context.h>
27248  
27249  int sysctl_panic_on_oom;
27250  int sysctl_oom_kill_allocating_task;
27251 @@ -186,9 +189,21 @@ unsigned long badness(struct task_struct
27252                         points >>= -(oom_adj);
27253         }
27254  
27255 +       /*
27256 +        * add points for context badness and
27257 +        * reduce badness for processes belonging to
27258 +        * a different context
27259 +        */
27260 +
27261 +       points += vx_badness(p, mm);
27262 +
27263 +       if ((vx_current_xid() > 1) &&
27264 +               vx_current_xid() != vx_task_xid(p))
27265 +               points /= 16;
27266 +
27267  #ifdef DEBUG
27268 -       printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
27269 -       p->pid, p->comm, points);
27270 +       printk(KERN_DEBUG "OOMkill: task %d:#%u (%s) got %d points\n",
27271 +               task_pid_nr(p), p->xid, p->comm, points);
27272  #endif
27273         return points;
27274  }
27275 @@ -249,6 +264,7 @@ static struct task_struct *select_bad_pr
27276         struct task_struct *p;
27277         struct task_struct *chosen = NULL;
27278         struct timespec uptime;
27279 +       unsigned xid = vx_current_xid();
27280         *ppoints = 0;
27281  
27282         do_posix_clock_monotonic_gettime(&uptime);
27283 @@ -261,11 +277,14 @@ static struct task_struct *select_bad_pr
27284                  */
27285                 if (!p->mm)
27286                         continue;
27287 -               /* skip the init task */
27288 -               if (is_global_init(p))
27289 +               /* skip the init task, global and per guest */
27290 +               if (task_is_init(p))
27291                         continue;
27292                 if (mem && !task_in_mem_cgroup(p, mem))
27293                         continue;
27294 +               /* skip other guest and host processes if oom in guest */
27295 +               if (xid && vx_task_xid(p) != xid)
27296 +                       continue;
27297  
27298                 /*
27299                  * This task already has access to memory reserves and is
27300 @@ -397,9 +416,9 @@ static void __oom_kill_task(struct task_
27301         }
27302  
27303         if (verbose)
27304 -               printk(KERN_ERR "Killed process %d (%s) "
27305 +               printk(KERN_ERR "Killed process %s(%d:#%u) "
27306                        "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
27307 -                      task_pid_nr(p), p->comm,
27308 +                      p->comm, task_pid_nr(p), p->xid,
27309                        K(p->mm->total_vm),
27310                        K(get_mm_counter(p->mm, anon_rss)),
27311                        K(get_mm_counter(p->mm, file_rss)));
27312 @@ -452,8 +471,8 @@ static int oom_kill_process(struct task_
27313                 return 0;
27314         }
27315  
27316 -       printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
27317 -                                       message, task_pid_nr(p), p->comm, points);
27318 +       printk(KERN_ERR "%s: kill process %s(%d:#%u) score %li or a child\n",
27319 +               message, p->comm, task_pid_nr(p), p->xid, points);
27320  
27321         /* Try to kill a child first */
27322         list_for_each_entry(c, &p->children, sibling) {
27323 @@ -554,6 +573,8 @@ void clear_zonelist_oom(struct zonelist 
27324         spin_unlock(&zone_scan_lock);
27325  }
27326  
27327 +long vs_oom_action(unsigned int);
27328 +
27329  /*
27330   * Must be called with tasklist_lock held for read.
27331   */
27332 @@ -580,7 +601,11 @@ retry:
27333         if (!p) {
27334                 read_unlock(&tasklist_lock);
27335                 dump_header(NULL, gfp_mask, order, NULL);
27336 -               panic("Out of memory and no killable processes...\n");
27337 +               /* avoid panic for guest OOM */
27338 +               if (current->xid)
27339 +                       vs_oom_action(LINUX_REBOOT_CMD_OOM);
27340 +               else
27341 +                       panic("Out of memory and no killable processes...\n");
27342         }
27343  
27344         if (oom_kill_process(p, gfp_mask, order, points, NULL,
27345 diff -NurpP --minimal linux-2.6.33.1/mm/page_alloc.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/page_alloc.c
27346 --- linux-2.6.33.1/mm/page_alloc.c      2010-02-25 11:52:09.000000000 +0100
27347 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/page_alloc.c      2010-02-25 12:16:45.000000000 +0100
27348 @@ -49,6 +49,8 @@
27349  #include <linux/debugobjects.h>
27350  #include <linux/kmemleak.h>
27351  #include <linux/memory.h>
27352 +#include <linux/vs_base.h>
27353 +#include <linux/vs_limit.h>
27354  #include <trace/events/kmem.h>
27355  
27356  #include <asm/tlbflush.h>
27357 @@ -2138,6 +2140,9 @@ void si_meminfo(struct sysinfo *val)
27358         val->totalhigh = totalhigh_pages;
27359         val->freehigh = nr_free_highpages();
27360         val->mem_unit = PAGE_SIZE;
27361 +
27362 +       if (vx_flags(VXF_VIRT_MEM, 0))
27363 +               vx_vsi_meminfo(val);
27364  }
27365  
27366  EXPORT_SYMBOL(si_meminfo);
27367 @@ -2158,6 +2163,9 @@ void si_meminfo_node(struct sysinfo *val
27368         val->freehigh = 0;
27369  #endif
27370         val->mem_unit = PAGE_SIZE;
27371 +
27372 +       if (vx_flags(VXF_VIRT_MEM, 0))
27373 +               vx_vsi_meminfo(val);
27374  }
27375  #endif
27376  
27377 diff -NurpP --minimal linux-2.6.33.1/mm/rmap.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/rmap.c
27378 --- linux-2.6.33.1/mm/rmap.c    2010-02-25 11:52:09.000000000 +0100
27379 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/rmap.c    2010-02-25 12:02:16.000000000 +0100
27380 @@ -56,6 +56,7 @@
27381  #include <linux/memcontrol.h>
27382  #include <linux/mmu_notifier.h>
27383  #include <linux/migrate.h>
27384 +#include <linux/vs_memory.h>
27385  
27386  #include <asm/tlbflush.h>
27387  
27388 diff -NurpP --minimal linux-2.6.33.1/mm/shmem.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/shmem.c
27389 --- linux-2.6.33.1/mm/shmem.c   2010-02-25 11:52:09.000000000 +0100
27390 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/shmem.c   2010-02-25 12:02:16.000000000 +0100
27391 @@ -1788,7 +1788,7 @@ static int shmem_statfs(struct dentry *d
27392  {
27393         struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
27394  
27395 -       buf->f_type = TMPFS_MAGIC;
27396 +       buf->f_type = TMPFS_SUPER_MAGIC;
27397         buf->f_bsize = PAGE_CACHE_SIZE;
27398         buf->f_namelen = NAME_MAX;
27399         spin_lock(&sbinfo->stat_lock);
27400 @@ -2358,7 +2358,7 @@ int shmem_fill_super(struct super_block 
27401         sb->s_maxbytes = SHMEM_MAX_BYTES;
27402         sb->s_blocksize = PAGE_CACHE_SIZE;
27403         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
27404 -       sb->s_magic = TMPFS_MAGIC;
27405 +       sb->s_magic = TMPFS_SUPER_MAGIC;
27406         sb->s_op = &shmem_ops;
27407         sb->s_time_gran = 1;
27408  #ifdef CONFIG_TMPFS_POSIX_ACL
27409 diff -NurpP --minimal linux-2.6.33.1/mm/slab.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/slab.c
27410 --- linux-2.6.33.1/mm/slab.c    2010-03-18 16:25:15.000000000 +0100
27411 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/slab.c    2010-03-18 16:54:29.000000000 +0100
27412 @@ -431,6 +431,8 @@ static void kmem_list3_init(struct kmem_
27413  #define STATS_INC_FREEMISS(x)  do { } while (0)
27414  #endif
27415  
27416 +#include "slab_vs.h"
27417 +
27418  #if DEBUG
27419  
27420  /*
27421 @@ -3273,6 +3275,7 @@ retry:
27422  
27423         obj = slab_get_obj(cachep, slabp, nodeid);
27424         check_slabp(cachep, slabp);
27425 +       vx_slab_alloc(cachep, flags);
27426         l3->free_objects--;
27427         /* move slabp to correct slabp list: */
27428         list_del(&slabp->list);
27429 @@ -3349,6 +3352,7 @@ __cache_alloc_node(struct kmem_cache *ca
27430         /* ___cache_alloc_node can fall back to other nodes */
27431         ptr = ____cache_alloc_node(cachep, flags, nodeid);
27432    out:
27433 +       vx_slab_alloc(cachep, flags);
27434         local_irq_restore(save_flags);
27435         ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
27436         kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
27437 @@ -3535,6 +3539,7 @@ static inline void __cache_free(struct k
27438         check_irq_off();
27439         kmemleak_free_recursive(objp, cachep->flags);
27440         objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
27441 +       vx_slab_free(cachep);
27442  
27443         kmemcheck_slab_free(cachep, objp, obj_size(cachep));
27444  
27445 diff -NurpP --minimal linux-2.6.33.1/mm/slab_vs.h linux-2.6.33.1-vs2.3.0.36.30.4/mm/slab_vs.h
27446 --- linux-2.6.33.1/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
27447 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/slab_vs.h 2010-02-25 12:02:16.000000000 +0100
27448 @@ -0,0 +1,29 @@
27449 +
27450 +#include <linux/vserver/context.h>
27451 +
27452 +#include <linux/vs_context.h>
27453 +
27454 +static inline
27455 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
27456 +{
27457 +       int what = gfp_zone(cachep->gfpflags);
27458 +       struct vx_info *vxi = current_vx_info();
27459 +
27460 +       if (!vxi)
27461 +               return;
27462 +
27463 +       atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
27464 +}
27465 +
27466 +static inline
27467 +void vx_slab_free(struct kmem_cache *cachep)
27468 +{
27469 +       int what = gfp_zone(cachep->gfpflags);
27470 +       struct vx_info *vxi = current_vx_info();
27471 +
27472 +       if (!vxi)
27473 +               return;
27474 +
27475 +       atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
27476 +}
27477 +
27478 diff -NurpP --minimal linux-2.6.33.1/mm/swapfile.c linux-2.6.33.1-vs2.3.0.36.30.4/mm/swapfile.c
27479 --- linux-2.6.33.1/mm/swapfile.c        2010-02-25 11:52:09.000000000 +0100
27480 +++ linux-2.6.33.1-vs2.3.0.36.30.4/mm/swapfile.c        2010-02-25 12:02:16.000000000 +0100
27481 @@ -35,6 +35,8 @@
27482  #include <asm/tlbflush.h>
27483  #include <linux/swapops.h>
27484  #include <linux/page_cgroup.h>
27485 +#include <linux/vs_base.h>
27486 +#include <linux/vs_memory.h>
27487  
27488  static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
27489                                  unsigned char);
27490 @@ -1693,6 +1695,16 @@ static int swap_show(struct seq_file *sw
27491  
27492         if (si == SEQ_START_TOKEN) {
27493                 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
27494 +               if (vx_flags(VXF_VIRT_MEM, 0)) {
27495 +                       struct sysinfo si;
27496 +
27497 +                       vx_vsi_swapinfo(&si);
27498 +                       if (si.totalswap < (1 << 10))
27499 +                               return 0;
27500 +                       seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
27501 +                               "hdv0", "partition", si.totalswap >> 10,
27502 +                               (si.totalswap - si.freeswap) >> 10, -1);
27503 +               }
27504                 return 0;
27505         }
27506  
27507 @@ -2071,6 +2083,8 @@ void si_swapinfo(struct sysinfo *val)
27508         val->freeswap = nr_swap_pages + nr_to_be_unused;
27509         val->totalswap = total_swap_pages + nr_to_be_unused;
27510         spin_unlock(&swap_lock);
27511 +       if (vx_flags(VXF_VIRT_MEM, 0))
27512 +               vx_vsi_swapinfo(val);
27513  }
27514  
27515  /*
27516 diff -NurpP --minimal linux-2.6.33.1/net/core/dev.c linux-2.6.33.1-vs2.3.0.36.30.4/net/core/dev.c
27517 --- linux-2.6.33.1/net/core/dev.c       2010-02-25 11:52:10.000000000 +0100
27518 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/core/dev.c       2010-02-25 14:02:39.000000000 +0100
27519 @@ -128,6 +128,7 @@
27520  #include <linux/in.h>
27521  #include <linux/jhash.h>
27522  #include <linux/random.h>
27523 +#include <linux/vs_inet.h>
27524  #include <trace/events/napi.h>
27525  
27526  #include "net-sysfs.h"
27527 @@ -593,7 +594,8 @@ struct net_device *__dev_get_by_name(str
27528         struct hlist_head *head = dev_name_hash(net, name);
27529  
27530         hlist_for_each_entry(dev, p, head, name_hlist)
27531 -               if (!strncmp(dev->name, name, IFNAMSIZ))
27532 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
27533 +                   nx_dev_visible(current_nx_info(), dev))
27534                         return dev;
27535  
27536         return NULL;
27537 @@ -619,7 +621,8 @@ struct net_device *dev_get_by_name_rcu(s
27538         struct hlist_head *head = dev_name_hash(net, name);
27539  
27540         hlist_for_each_entry_rcu(dev, p, head, name_hlist)
27541 -               if (!strncmp(dev->name, name, IFNAMSIZ))
27542 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
27543 +                   nx_dev_visible(current_nx_info(), dev))
27544                         return dev;
27545  
27546         return NULL;
27547 @@ -670,7 +673,8 @@ struct net_device *__dev_get_by_index(st
27548         struct hlist_head *head = dev_index_hash(net, ifindex);
27549  
27550         hlist_for_each_entry(dev, p, head, index_hlist)
27551 -               if (dev->ifindex == ifindex)
27552 +               if ((dev->ifindex == ifindex) &&
27553 +                   nx_dev_visible(current_nx_info(), dev))
27554                         return dev;
27555  
27556         return NULL;
27557 @@ -695,7 +699,8 @@ struct net_device *dev_get_by_index_rcu(
27558         struct hlist_head *head = dev_index_hash(net, ifindex);
27559  
27560         hlist_for_each_entry_rcu(dev, p, head, index_hlist)
27561 -               if (dev->ifindex == ifindex)
27562 +               if ((dev->ifindex == ifindex) &&
27563 +                   nx_dev_visible(current_nx_info(), dev))
27564                         return dev;
27565  
27566         return NULL;
27567 @@ -748,10 +753,12 @@ struct net_device *dev_getbyhwaddr(struc
27568  
27569         ASSERT_RTNL();
27570  
27571 -       for_each_netdev(net, dev)
27572 +       for_each_netdev(net, dev) {
27573                 if (dev->type == type &&
27574 -                   !memcmp(dev->dev_addr, ha, dev->addr_len))
27575 +                   !memcmp(dev->dev_addr, ha, dev->addr_len) &&
27576 +                   nx_dev_visible(current_nx_info(), dev))
27577                         return dev;
27578 +       }
27579  
27580         return NULL;
27581  }
27582 @@ -762,9 +769,11 @@ struct net_device *__dev_getfirstbyhwtyp
27583         struct net_device *dev;
27584  
27585         ASSERT_RTNL();
27586 -       for_each_netdev(net, dev)
27587 -               if (dev->type == type)
27588 +       for_each_netdev(net, dev) {
27589 +               if ((dev->type == type) &&
27590 +                   nx_dev_visible(current_nx_info(), dev))
27591                         return dev;
27592 +       }
27593  
27594         return NULL;
27595  }
27596 @@ -883,6 +892,8 @@ static int __dev_alloc_name(struct net *
27597                                 continue;
27598                         if (i < 0 || i >= max_netdevices)
27599                                 continue;
27600 +                       if (!nx_dev_visible(current_nx_info(), d))
27601 +                               continue;
27602  
27603                         /*  avoid cases where sscanf is not exact inverse of printf */
27604                         snprintf(buf, IFNAMSIZ, name, i);
27605 @@ -3115,6 +3126,8 @@ static int dev_ifconf(struct net *net, c
27606  
27607         total = 0;
27608         for_each_netdev(net, dev) {
27609 +               if (!nx_dev_visible(current_nx_info(), dev))
27610 +                       continue;
27611                 for (i = 0; i < NPROTO; i++) {
27612                         if (gifconf_list[i]) {
27613                                 int done;
27614 @@ -3185,6 +3198,9 @@ static void dev_seq_printf_stats(struct 
27615  {
27616         const struct net_device_stats *stats = dev_get_stats(dev);
27617  
27618 +       if (!nx_dev_visible(current_nx_info(), dev))
27619 +               return;
27620 +
27621         seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
27622                    "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
27623                    dev->name, stats->rx_bytes, stats->rx_packets,
27624 @@ -5528,7 +5544,6 @@ int dev_change_net_namespace(struct net_
27625         if (dev->dev.parent)
27626                 goto out;
27627  #endif
27628 -
27629         /* Ensure the device has been registrered */
27630         err = -EINVAL;
27631         if (dev->reg_state != NETREG_REGISTERED)
27632 diff -NurpP --minimal linux-2.6.33.1/net/core/rtnetlink.c linux-2.6.33.1-vs2.3.0.36.30.4/net/core/rtnetlink.c
27633 --- linux-2.6.33.1/net/core/rtnetlink.c 2010-02-25 11:52:10.000000000 +0100
27634 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/core/rtnetlink.c 2010-02-25 13:59:02.000000000 +0100
27635 @@ -695,6 +695,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
27636                 hlist_for_each_entry(dev, node, head, index_hlist) {
27637                         if (idx < s_idx)
27638                                 goto cont;
27639 +                       if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
27640 +                               continue;
27641                         if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
27642                                              NETLINK_CB(cb->skb).pid,
27643                                              cb->nlh->nlmsg_seq, 0,
27644 @@ -1252,6 +1254,9 @@ void rtmsg_ifinfo(int type, struct net_d
27645         struct sk_buff *skb;
27646         int err = -ENOBUFS;
27647  
27648 +       if (!nx_dev_visible(current_nx_info(), dev))
27649 +               return;
27650 +
27651         skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
27652         if (skb == NULL)
27653                 goto errout;
27654 diff -NurpP --minimal linux-2.6.33.1/net/core/sock.c linux-2.6.33.1-vs2.3.0.36.30.4/net/core/sock.c
27655 --- linux-2.6.33.1/net/core/sock.c      2010-02-25 11:52:10.000000000 +0100
27656 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/core/sock.c      2010-02-25 12:02:16.000000000 +0100
27657 @@ -125,6 +125,10 @@
27658  #include <linux/ipsec.h>
27659  
27660  #include <linux/filter.h>
27661 +#include <linux/vs_socket.h>
27662 +#include <linux/vs_limit.h>
27663 +#include <linux/vs_context.h>
27664 +#include <linux/vs_network.h>
27665  
27666  #ifdef CONFIG_INET
27667  #include <net/tcp.h>
27668 @@ -1008,6 +1012,8 @@ static struct sock *sk_prot_alloc(struct
27669                         goto out_free_sec;
27670                 sk_tx_queue_clear(sk);
27671         }
27672 +               sock_vx_init(sk);
27673 +               sock_nx_init(sk);
27674  
27675         return sk;
27676  
27677 @@ -1087,6 +1093,11 @@ static void __sk_free(struct sock *sk)
27678                        __func__, atomic_read(&sk->sk_omem_alloc));
27679  
27680         put_net(sock_net(sk));
27681 +       vx_sock_dec(sk);
27682 +       clr_vx_info(&sk->sk_vx_info);
27683 +       sk->sk_xid = -1;
27684 +       clr_nx_info(&sk->sk_nx_info);
27685 +       sk->sk_nid = -1;
27686         sk_prot_free(sk->sk_prot_creator, sk);
27687  }
27688  
27689 @@ -1134,6 +1145,8 @@ struct sock *sk_clone(const struct sock 
27690  
27691                 /* SANITY */
27692                 get_net(sock_net(newsk));
27693 +               sock_vx_init(newsk);
27694 +               sock_nx_init(newsk);
27695                 sk_node_init(&newsk->sk_node);
27696                 sock_lock_init(newsk);
27697                 bh_lock_sock(newsk);
27698 @@ -1188,6 +1201,12 @@ struct sock *sk_clone(const struct sock 
27699                 smp_wmb();
27700                 atomic_set(&newsk->sk_refcnt, 2);
27701  
27702 +               set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
27703 +               newsk->sk_xid = sk->sk_xid;
27704 +               vx_sock_inc(newsk);
27705 +               set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
27706 +               newsk->sk_nid = sk->sk_nid;
27707 +
27708                 /*
27709                  * Increment the counter in the same struct proto as the master
27710                  * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
27711 @@ -1910,6 +1929,12 @@ void sock_init_data(struct socket *sock,
27712  
27713         sk->sk_stamp = ktime_set(-1L, 0);
27714  
27715 +       set_vx_info(&sk->sk_vx_info, current_vx_info());
27716 +       sk->sk_xid = vx_current_xid();
27717 +       vx_sock_inc(sk);
27718 +       set_nx_info(&sk->sk_nx_info, current_nx_info());
27719 +       sk->sk_nid = nx_current_nid();
27720 +
27721         /*
27722          * Before updating sk_refcnt, we must commit prior changes to memory
27723          * (Documentation/RCU/rculist_nulls.txt for details)
27724 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/af_inet.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/af_inet.c
27725 --- linux-2.6.33.1/net/ipv4/af_inet.c   2010-02-25 11:52:10.000000000 +0100
27726 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/af_inet.c   2010-02-25 15:53:12.000000000 +0100
27727 @@ -115,6 +115,7 @@
27728  #ifdef CONFIG_IP_MROUTE
27729  #include <linux/mroute.h>
27730  #endif
27731 +#include <linux/vs_limit.h>
27732  
27733  
27734  /* The inetsw table contains everything that inet_create needs to
27735 @@ -326,9 +327,13 @@ lookup_protocol:
27736         }
27737  
27738         err = -EPERM;
27739 +       if ((protocol == IPPROTO_ICMP) &&
27740 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
27741 +               goto override;
27742 +
27743         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
27744                 goto out_rcu_unlock;
27745 -
27746 +override:
27747         err = -EAFNOSUPPORT;
27748         if (!inet_netns_ok(net, protocol))
27749                 goto out_rcu_unlock;
27750 @@ -448,6 +453,7 @@ int inet_bind(struct socket *sock, struc
27751         struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
27752         struct sock *sk = sock->sk;
27753         struct inet_sock *inet = inet_sk(sk);
27754 +       struct nx_v4_sock_addr nsa;
27755         unsigned short snum;
27756         int chk_addr_ret;
27757         int err;
27758 @@ -461,7 +467,11 @@ int inet_bind(struct socket *sock, struc
27759         if (addr_len < sizeof(struct sockaddr_in))
27760                 goto out;
27761  
27762 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27763 +       err = v4_map_sock_addr(inet, addr, &nsa);
27764 +       if (err)
27765 +               goto out;
27766 +
27767 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27768  
27769         /* Not specified by any standard per-se, however it breaks too
27770          * many applications when removed.  It is unfortunate since
27771 @@ -473,7 +483,7 @@ int inet_bind(struct socket *sock, struc
27772         err = -EADDRNOTAVAIL;
27773         if (!sysctl_ip_nonlocal_bind &&
27774             !(inet->freebind || inet->transparent) &&
27775 -           addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
27776 +           nsa.saddr != htonl(INADDR_ANY) &&
27777             chk_addr_ret != RTN_LOCAL &&
27778             chk_addr_ret != RTN_MULTICAST &&
27779             chk_addr_ret != RTN_BROADCAST)
27780 @@ -498,7 +508,7 @@ int inet_bind(struct socket *sock, struc
27781         if (sk->sk_state != TCP_CLOSE || inet->inet_num)
27782                 goto out_release_sock;
27783  
27784 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
27785 +       v4_set_sock_addr(inet, &nsa);
27786         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27787                 inet->inet_saddr = 0;  /* Use device */
27788  
27789 @@ -695,11 +705,13 @@ int inet_getname(struct socket *sock, st
27790                      peer == 1))
27791                         return -ENOTCONN;
27792                 sin->sin_port = inet->inet_dport;
27793 -               sin->sin_addr.s_addr = inet->inet_daddr;
27794 +               sin->sin_addr.s_addr =
27795 +                       nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
27796         } else {
27797                 __be32 addr = inet->inet_rcv_saddr;
27798                 if (!addr)
27799                         addr = inet->inet_saddr;
27800 +               addr = nx_map_sock_lback(sk->sk_nx_info, addr);
27801                 sin->sin_port = inet->inet_sport;
27802                 sin->sin_addr.s_addr = addr;
27803         }
27804 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/devinet.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/devinet.c
27805 --- linux-2.6.33.1/net/ipv4/devinet.c   2010-02-25 11:52:10.000000000 +0100
27806 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/devinet.c   2010-02-25 14:19:58.000000000 +0100
27807 @@ -416,6 +416,7 @@ struct in_device *inetdev_by_index(struc
27808  }
27809  EXPORT_SYMBOL(inetdev_by_index);
27810  
27811 +
27812  /* Called only from RTNL semaphored context. No locks. */
27813  
27814  struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
27815 @@ -658,6 +659,8 @@ int devinet_ioctl(struct net *net, unsig
27816  
27817         in_dev = __in_dev_get_rtnl(dev);
27818         if (in_dev) {
27819 +               struct nx_info *nxi = current_nx_info();
27820 +
27821                 if (tryaddrmatch) {
27822                         /* Matthias Andree */
27823                         /* compare label and address (4.4BSD style) */
27824 @@ -666,6 +669,8 @@ int devinet_ioctl(struct net *net, unsig
27825                            This is checked above. */
27826                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27827                              ifap = &ifa->ifa_next) {
27828 +                               if (!nx_v4_ifa_visible(nxi, ifa))
27829 +                                       continue;
27830                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
27831                                     sin_orig.sin_addr.s_addr ==
27832                                                         ifa->ifa_address) {
27833 @@ -678,9 +683,12 @@ int devinet_ioctl(struct net *net, unsig
27834                    comparing just the label */
27835                 if (!ifa) {
27836                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
27837 -                            ifap = &ifa->ifa_next)
27838 +                            ifap = &ifa->ifa_next) {
27839 +                               if (!nx_v4_ifa_visible(nxi, ifa))
27840 +                                       continue;
27841                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
27842                                         break;
27843 +                       }
27844                 }
27845         }
27846  
27847 @@ -832,6 +840,8 @@ static int inet_gifconf(struct net_devic
27848                 goto out;
27849  
27850         for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
27851 +               if (!nx_v4_ifa_visible(current_nx_info(), ifa))
27852 +                       continue;
27853                 if (!buf) {
27854                         done += sizeof(ifr);
27855                         continue;
27856 @@ -1180,6 +1190,7 @@ static int inet_dump_ifaddr(struct sk_bu
27857         struct net_device *dev;
27858         struct in_device *in_dev;
27859         struct in_ifaddr *ifa;
27860 +       struct sock *sk = skb->sk;
27861         struct hlist_head *head;
27862         struct hlist_node *node;
27863  
27864 @@ -1202,6 +1213,8 @@ static int inet_dump_ifaddr(struct sk_bu
27865  
27866                         for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
27867                              ifa = ifa->ifa_next, ip_idx++) {
27868 +                       if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
27869 +                               continue;
27870                                 if (ip_idx < s_ip_idx)
27871                                         continue;
27872                                 if (inet_fill_ifaddr(skb, ifa,
27873 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/fib_hash.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/fib_hash.c
27874 --- linux-2.6.33.1/net/ipv4/fib_hash.c  2010-02-25 11:52:10.000000000 +0100
27875 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/fib_hash.c  2010-02-25 12:02:16.000000000 +0100
27876 @@ -1016,7 +1016,7 @@ static int fib_seq_show(struct seq_file 
27877         prefix  = f->fn_key;
27878         mask    = FZ_MASK(iter->zone);
27879         flags   = fib_flag_trans(fa->fa_type, mask, fi);
27880 -       if (fi)
27881 +       if (fi && nx_dev_visible(current_nx_info(), fi->fib_dev))
27882                 seq_printf(seq,
27883                          "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
27884                          fi->fib_dev ? fi->fib_dev->name : "*", prefix,
27885 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/inet_connection_sock.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/inet_connection_sock.c
27886 --- linux-2.6.33.1/net/ipv4/inet_connection_sock.c      2010-02-25 11:52:10.000000000 +0100
27887 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/inet_connection_sock.c      2010-02-25 12:02:16.000000000 +0100
27888 @@ -49,10 +49,40 @@ void inet_get_local_port_range(int *low,
27889  }
27890  EXPORT_SYMBOL(inet_get_local_port_range);
27891  
27892 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27893 +{
27894 +       __be32  sk1_rcv_saddr = inet_rcv_saddr(sk1),
27895 +               sk2_rcv_saddr = inet_rcv_saddr(sk2);
27896 +
27897 +       if (inet_v6_ipv6only(sk2))
27898 +               return 0;
27899 +
27900 +       if (sk1_rcv_saddr &&
27901 +           sk2_rcv_saddr &&
27902 +           sk1_rcv_saddr == sk2_rcv_saddr)
27903 +               return 1;
27904 +
27905 +       if (sk1_rcv_saddr &&
27906 +           !sk2_rcv_saddr &&
27907 +           v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
27908 +               return 1;
27909 +
27910 +       if (sk2_rcv_saddr &&
27911 +           !sk1_rcv_saddr &&
27912 +           v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
27913 +               return 1;
27914 +
27915 +       if (!sk1_rcv_saddr &&
27916 +           !sk2_rcv_saddr &&
27917 +           nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
27918 +               return 1;
27919 +
27920 +       return 0;
27921 +}
27922 +
27923  int inet_csk_bind_conflict(const struct sock *sk,
27924                            const struct inet_bind_bucket *tb)
27925  {
27926 -       const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
27927         struct sock *sk2;
27928         struct hlist_node *node;
27929         int reuse = sk->sk_reuse;
27930 @@ -72,9 +102,7 @@ int inet_csk_bind_conflict(const struct 
27931                      sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
27932                         if (!reuse || !sk2->sk_reuse ||
27933                             sk2->sk_state == TCP_LISTEN) {
27934 -                               const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
27935 -                               if (!sk2_rcv_saddr || !sk_rcv_saddr ||
27936 -                                   sk2_rcv_saddr == sk_rcv_saddr)
27937 +                               if (ipv4_rcv_saddr_equal(sk, sk2))
27938                                         break;
27939                         }
27940                 }
27941 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/inet_diag.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/inet_diag.c
27942 --- linux-2.6.33.1/net/ipv4/inet_diag.c 2010-02-25 11:52:10.000000000 +0100
27943 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/inet_diag.c 2010-02-25 14:16:01.000000000 +0100
27944 @@ -32,6 +32,8 @@
27945  #include <linux/stddef.h>
27946  
27947  #include <linux/inet_diag.h>
27948 +#include <linux/vs_network.h>
27949 +#include <linux/vs_inet.h>
27950  
27951  static const struct inet_diag_handler **inet_diag_table;
27952  
27953 @@ -118,8 +120,10 @@ static int inet_csk_diag_fill(struct soc
27954  
27955         r->id.idiag_sport = inet->inet_sport;
27956         r->id.idiag_dport = inet->inet_dport;
27957 -       r->id.idiag_src[0] = inet->inet_rcv_saddr;
27958 -       r->id.idiag_dst[0] = inet->inet_daddr;
27959 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
27960 +               inet->inet_rcv_saddr);
27961 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
27962 +               inet->inet_daddr);
27963  
27964  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27965         if (r->idiag_family == AF_INET6) {
27966 @@ -204,8 +208,8 @@ static int inet_twsk_diag_fill(struct in
27967         r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
27968         r->id.idiag_sport     = tw->tw_sport;
27969         r->id.idiag_dport     = tw->tw_dport;
27970 -       r->id.idiag_src[0]    = tw->tw_rcv_saddr;
27971 -       r->id.idiag_dst[0]    = tw->tw_daddr;
27972 +       r->id.idiag_src[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
27973 +       r->id.idiag_dst[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
27974         r->idiag_state        = tw->tw_substate;
27975         r->idiag_timer        = 3;
27976         r->idiag_expires      = DIV_ROUND_UP(tmo * 1000, HZ);
27977 @@ -262,6 +266,7 @@ static int inet_diag_get_exact(struct sk
27978         err = -EINVAL;
27979  
27980         if (req->idiag_family == AF_INET) {
27981 +               /* TODO: lback */
27982                 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
27983                                  req->id.idiag_dport, req->id.idiag_src[0],
27984                                  req->id.idiag_sport, req->id.idiag_if);
27985 @@ -504,6 +509,7 @@ static int inet_csk_diag_dump(struct soc
27986                 } else
27987  #endif
27988                 {
27989 +                       /* TODO: lback */
27990                         entry.saddr = &inet->inet_rcv_saddr;
27991                         entry.daddr = &inet->inet_daddr;
27992                 }
27993 @@ -540,6 +546,7 @@ static int inet_twsk_diag_dump(struct in
27994                 } else
27995  #endif
27996                 {
27997 +                       /* TODO: lback */
27998                         entry.saddr = &tw->tw_rcv_saddr;
27999                         entry.daddr = &tw->tw_daddr;
28000                 }
28001 @@ -586,8 +593,8 @@ static int inet_diag_fill_req(struct sk_
28002  
28003         r->id.idiag_sport = inet->inet_sport;
28004         r->id.idiag_dport = ireq->rmt_port;
28005 -       r->id.idiag_src[0] = ireq->loc_addr;
28006 -       r->id.idiag_dst[0] = ireq->rmt_addr;
28007 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
28008 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
28009         r->idiag_expires = jiffies_to_msecs(tmo);
28010         r->idiag_rqueue = 0;
28011         r->idiag_wqueue = 0;
28012 @@ -657,6 +664,7 @@ static int inet_diag_dump_reqs(struct sk
28013                                 continue;
28014  
28015                         if (bc) {
28016 +                               /* TODO: lback */
28017                                 entry.saddr =
28018  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
28019                                         (entry.family == AF_INET6) ?
28020 @@ -727,6 +735,8 @@ static int inet_diag_dump(struct sk_buff
28021                         sk_nulls_for_each(sk, node, &ilb->head) {
28022                                 struct inet_sock *inet = inet_sk(sk);
28023  
28024 +                               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28025 +                                       continue;
28026                                 if (num < s_num) {
28027                                         num++;
28028                                         continue;
28029 @@ -793,6 +803,8 @@ skip_listen_ht:
28030                 sk_nulls_for_each(sk, node, &head->chain) {
28031                         struct inet_sock *inet = inet_sk(sk);
28032  
28033 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28034 +                               continue;
28035                         if (num < s_num)
28036                                 goto next_normal;
28037                         if (!(r->idiag_states & (1 << sk->sk_state)))
28038 @@ -817,6 +829,8 @@ next_normal:
28039                         inet_twsk_for_each(tw, node,
28040                                     &head->twchain) {
28041  
28042 +                               if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
28043 +                                       continue;
28044                                 if (num < s_num)
28045                                         goto next_dying;
28046                                 if (r->id.idiag_sport != tw->tw_sport &&
28047 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/inet_hashtables.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/inet_hashtables.c
28048 --- linux-2.6.33.1/net/ipv4/inet_hashtables.c   2010-02-25 11:52:10.000000000 +0100
28049 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/inet_hashtables.c   2010-02-25 12:02:16.000000000 +0100
28050 @@ -21,6 +21,7 @@
28051  
28052  #include <net/inet_connection_sock.h>
28053  #include <net/inet_hashtables.h>
28054 +#include <net/route.h>
28055  #include <net/ip.h>
28056  
28057  /*
28058 @@ -134,6 +135,11 @@ static inline int compute_score(struct s
28059                         if (rcv_saddr != daddr)
28060                                 return -1;
28061                         score += 2;
28062 +               } else {
28063 +                       /* block non nx_info ips */
28064 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
28065 +                               daddr, NXA_MASK_BIND))
28066 +                               return -1;
28067                 }
28068                 if (sk->sk_bound_dev_if) {
28069                         if (sk->sk_bound_dev_if != dif)
28070 @@ -151,7 +157,6 @@ static inline int compute_score(struct s
28071   * wildcarded during the search since they can never be otherwise.
28072   */
28073  
28074 -
28075  struct sock *__inet_lookup_listener(struct net *net,
28076                                     struct inet_hashinfo *hashinfo,
28077                                     const __be32 daddr, const unsigned short hnum,
28078 @@ -174,6 +179,7 @@ begin:
28079                         hiscore = score;
28080                 }
28081         }
28082 +
28083         /*
28084          * if the nulls value we got at the end of this lookup is
28085          * not the expected one, we must restart lookup.
28086 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/netfilter/nf_nat_helper.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/netfilter/nf_nat_helper.c
28087 --- linux-2.6.33.1/net/ipv4/netfilter/nf_nat_helper.c   2010-02-25 11:52:10.000000000 +0100
28088 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/netfilter/nf_nat_helper.c   2010-02-25 12:02:16.000000000 +0100
28089 @@ -19,6 +19,7 @@
28090  #include <net/route.h>
28091  
28092  #include <linux/netfilter_ipv4.h>
28093 +#include <net/route.h>
28094  #include <net/netfilter/nf_conntrack.h>
28095  #include <net/netfilter/nf_conntrack_helper.h>
28096  #include <net/netfilter/nf_conntrack_ecache.h>
28097 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/netfilter.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/netfilter.c
28098 --- linux-2.6.33.1/net/ipv4/netfilter.c 2010-02-25 11:52:10.000000000 +0100
28099 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/netfilter.c 2010-02-25 12:02:16.000000000 +0100
28100 @@ -4,7 +4,7 @@
28101  #include <linux/netfilter_ipv4.h>
28102  #include <linux/ip.h>
28103  #include <linux/skbuff.h>
28104 -#include <net/route.h>
28105 +// #include <net/route.h>
28106  #include <net/xfrm.h>
28107  #include <net/ip.h>
28108  #include <net/netfilter/nf_queue.h>
28109 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/raw.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/raw.c
28110 --- linux-2.6.33.1/net/ipv4/raw.c       2010-02-25 11:52:10.000000000 +0100
28111 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/raw.c       2010-02-25 14:07:52.000000000 +0100
28112 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
28113  
28114                 if (net_eq(sock_net(sk), net) && inet->inet_num == num  &&
28115                     !(inet->inet_daddr && inet->inet_daddr != raddr)    &&
28116 -                   !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
28117 +                   v4_sock_addr_match(sk->sk_nx_info, inet, laddr)     &&
28118                     !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
28119                         goto found; /* gotcha */
28120         }
28121 @@ -382,6 +382,12 @@ static int raw_send_hdrinc(struct sock *
28122                 icmp_out_count(net, ((struct icmphdr *)
28123                         skb_transport_header(skb))->type);
28124  
28125 +       err = -EPERM;
28126 +       if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
28127 +               sk->sk_nx_info &&
28128 +               !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
28129 +               goto error_free;
28130 +
28131         err = NF_HOOK(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
28132                       dst_output);
28133         if (err > 0)
28134 @@ -562,6 +568,13 @@ static int raw_sendmsg(struct kiocb *ioc
28135                 }
28136  
28137                 security_sk_classify_flow(sk, &fl);
28138 +               if (sk->sk_nx_info) {
28139 +                       err = ip_v4_find_src(sock_net(sk),
28140 +                               sk->sk_nx_info, &rt, &fl);
28141 +
28142 +                       if (err)
28143 +                               goto done;
28144 +               }
28145                 err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
28146         }
28147         if (err)
28148 @@ -634,17 +647,19 @@ static int raw_bind(struct sock *sk, str
28149  {
28150         struct inet_sock *inet = inet_sk(sk);
28151         struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
28152 +       struct nx_v4_sock_addr nsa = { 0 };
28153         int ret = -EINVAL;
28154         int chk_addr_ret;
28155  
28156         if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
28157                 goto out;
28158 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
28159 +       v4_map_sock_addr(inet, addr, &nsa);
28160 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
28161         ret = -EADDRNOTAVAIL;
28162 -       if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
28163 +       if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
28164             chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
28165                 goto out;
28166 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
28167 +       v4_set_sock_addr(inet, &nsa);
28168         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
28169                 inet->inet_saddr = 0;  /* Use device */
28170         sk_dst_reset(sk);
28171 @@ -696,7 +711,8 @@ static int raw_recvmsg(struct kiocb *ioc
28172         /* Copy the address. */
28173         if (sin) {
28174                 sin->sin_family = AF_INET;
28175 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
28176 +               sin->sin_addr.s_addr =
28177 +                       nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
28178                 sin->sin_port = 0;
28179                 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
28180         }
28181 @@ -874,7 +890,8 @@ static struct sock *raw_get_first(struct
28182                 struct hlist_node *node;
28183  
28184                 sk_for_each(sk, node, &state->h->ht[state->bucket])
28185 -                       if (sock_net(sk) == seq_file_net(seq))
28186 +                       if ((sock_net(sk) == seq_file_net(seq)) &&
28187 +                               nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28188                                 goto found;
28189         }
28190         sk = NULL;
28191 @@ -890,7 +907,8 @@ static struct sock *raw_get_next(struct 
28192                 sk = sk_next(sk);
28193  try_again:
28194                 ;
28195 -       } while (sk && sock_net(sk) != seq_file_net(seq));
28196 +       } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
28197 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
28198  
28199         if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
28200                 sk = sk_head(&state->h->ht[state->bucket]);
28201 @@ -949,7 +967,10 @@ static void raw_sock_seq_show(struct seq
28202  
28203         seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
28204                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d\n",
28205 -               i, src, srcp, dest, destp, sp->sk_state,
28206 +               i,
28207 +               nx_map_sock_lback(current_nx_info(), src), srcp,
28208 +               nx_map_sock_lback(current_nx_info(), dest), destp,
28209 +               sp->sk_state,
28210                 sk_wmem_alloc_get(sp),
28211                 sk_rmem_alloc_get(sp),
28212                 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
28213 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/tcp.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/tcp.c
28214 --- linux-2.6.33.1/net/ipv4/tcp.c       2010-02-25 11:52:10.000000000 +0100
28215 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/tcp.c       2010-02-25 14:03:32.000000000 +0100
28216 @@ -265,6 +265,7 @@
28217  #include <linux/err.h>
28218  #include <linux/crypto.h>
28219  #include <linux/time.h>
28220 +#include <linux/in.h>
28221  
28222  #include <net/icmp.h>
28223  #include <net/tcp.h>
28224 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/tcp_ipv4.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/tcp_ipv4.c
28225 --- linux-2.6.33.1/net/ipv4/tcp_ipv4.c  2010-02-25 11:52:10.000000000 +0100
28226 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/tcp_ipv4.c  2010-02-25 14:08:55.000000000 +0100
28227 @@ -1988,6 +1988,12 @@ static void *listening_get_next(struct s
28228                 req = req->dl_next;
28229                 while (1) {
28230                         while (req) {
28231 +                               vxdprintk(VXD_CBIT(net, 6),
28232 +                                       "sk,req: %p [#%d] (from %d)", req->sk,
28233 +                                       (req->sk)?req->sk->sk_nid:0, nx_current_nid());
28234 +                               if (req->sk &&
28235 +                                       !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
28236 +                                       continue;
28237                                 if (req->rsk_ops->family == st->family) {
28238                                         cur = req;
28239                                         goto out;
28240 @@ -2012,6 +2018,10 @@ get_req:
28241         }
28242  get_sk:
28243         sk_nulls_for_each_from(sk, node) {
28244 +               vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
28245 +                       sk, sk->sk_nid, nx_current_nid());
28246 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28247 +                       continue;
28248                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) {
28249                         cur = sk;
28250                         goto out;
28251 @@ -2075,6 +2085,11 @@ static void *established_get_first(struc
28252  
28253                 spin_lock_bh(lock);
28254                 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
28255 +                       vxdprintk(VXD_CBIT(net, 6),
28256 +                               "sk,egf: %p [#%d] (from %d)",
28257 +                               sk, sk->sk_nid, nx_current_nid());
28258 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28259 +                               continue;
28260                         if (sk->sk_family != st->family ||
28261                             !net_eq(sock_net(sk), net)) {
28262                                 continue;
28263 @@ -2085,6 +2100,11 @@ static void *established_get_first(struc
28264                 st->state = TCP_SEQ_STATE_TIME_WAIT;
28265                 inet_twsk_for_each(tw, node,
28266                                    &tcp_hashinfo.ehash[st->bucket].twchain) {
28267 +                       vxdprintk(VXD_CBIT(net, 6),
28268 +                               "tw: %p [#%d] (from %d)",
28269 +                               tw, tw->tw_nid, nx_current_nid());
28270 +                       if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
28271 +                               continue;
28272                         if (tw->tw_family != st->family ||
28273                             !net_eq(twsk_net(tw), net)) {
28274                                 continue;
28275 @@ -2113,7 +2133,9 @@ static void *established_get_next(struct
28276                 tw = cur;
28277                 tw = tw_next(tw);
28278  get_tw:
28279 -               while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
28280 +               while (tw && (tw->tw_family != st->family ||
28281 +                       !net_eq(twsk_net(tw), net) ||
28282 +                       !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
28283                         tw = tw_next(tw);
28284                 }
28285                 if (tw) {
28286 @@ -2136,6 +2158,11 @@ get_tw:
28287                 sk = sk_nulls_next(sk);
28288  
28289         sk_nulls_for_each_from(sk, node) {
28290 +               vxdprintk(VXD_CBIT(net, 6),
28291 +                       "sk,egn: %p [#%d] (from %d)",
28292 +                       sk, sk->sk_nid, nx_current_nid());
28293 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28294 +                       continue;
28295                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
28296                         goto found;
28297         }
28298 @@ -2287,9 +2314,9 @@ static void get_openreq4(struct sock *sk
28299         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
28300                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
28301                 i,
28302 -               ireq->loc_addr,
28303 +               nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
28304                 ntohs(inet_sk(sk)->inet_sport),
28305 -               ireq->rmt_addr,
28306 +               nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
28307                 ntohs(ireq->rmt_port),
28308                 TCP_SYN_RECV,
28309                 0, 0, /* could print option size, but that is af dependent. */
28310 @@ -2341,7 +2368,10 @@ static void get_tcp4_sock(struct sock *s
28311  
28312         seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
28313                         "%08X %5d %8d %lu %d %p %lu %lu %u %u %d%n",
28314 -               i, src, srcp, dest, destp, sk->sk_state,
28315 +               i,
28316 +               nx_map_sock_lback(current_nx_info(), src), srcp,
28317 +               nx_map_sock_lback(current_nx_info(), dest), destp,
28318 +               sk->sk_state,
28319                 tp->write_seq - tp->snd_una,
28320                 rx_queue,
28321                 timer_active,
28322 @@ -2376,7 +2406,10 @@ static void get_timewait4_sock(struct in
28323  
28324         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
28325                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
28326 -               i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
28327 +               i,
28328 +               nx_map_sock_lback(current_nx_info(), src), srcp,
28329 +               nx_map_sock_lback(current_nx_info(), dest), destp,
28330 +               tw->tw_substate, 0, 0,
28331                 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
28332                 atomic_read(&tw->tw_refcnt), tw, len);
28333  }
28334 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/tcp_minisocks.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/tcp_minisocks.c
28335 --- linux-2.6.33.1/net/ipv4/tcp_minisocks.c     2010-02-25 11:52:10.000000000 +0100
28336 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/tcp_minisocks.c     2010-02-25 14:03:06.000000000 +0100
28337 @@ -22,6 +22,9 @@
28338  #include <linux/module.h>
28339  #include <linux/sysctl.h>
28340  #include <linux/workqueue.h>
28341 +#include <linux/vs_limit.h>
28342 +#include <linux/vs_socket.h>
28343 +#include <linux/vs_context.h>
28344  #include <net/tcp.h>
28345  #include <net/inet_common.h>
28346  #include <net/xfrm.h>
28347 @@ -289,6 +292,11 @@ void tcp_time_wait(struct sock *sk, int 
28348                 tcptw->tw_ts_recent     = tp->rx_opt.ts_recent;
28349                 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
28350  
28351 +               tw->tw_xid              = sk->sk_xid;
28352 +               tw->tw_vx_info          = NULL;
28353 +               tw->tw_nid              = sk->sk_nid;
28354 +               tw->tw_nx_info          = NULL;
28355 +
28356  #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
28357                 if (tw->tw_family == PF_INET6) {
28358                         struct ipv6_pinfo *np = inet6_sk(sk);
28359 diff -NurpP --minimal linux-2.6.33.1/net/ipv4/udp.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/udp.c
28360 --- linux-2.6.33.1/net/ipv4/udp.c       2010-02-25 11:52:10.000000000 +0100
28361 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv4/udp.c       2010-02-25 14:18:12.000000000 +0100
28362 @@ -294,14 +294,7 @@ fail:
28363  }
28364  EXPORT_SYMBOL(udp_lib_get_port);
28365  
28366 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
28367 -{
28368 -       struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
28369 -
28370 -       return  (!ipv6_only_sock(sk2)  &&
28371 -                (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
28372 -                  inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
28373 -}
28374 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
28375  
28376  static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
28377                                        unsigned int port)
28378 @@ -336,6 +329,11 @@ static inline int compute_score(struct s
28379                         if (inet->inet_rcv_saddr != daddr)
28380                                 return -1;
28381                         score += 2;
28382 +               } else {
28383 +                       /* block non nx_info ips */
28384 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
28385 +                               daddr, NXA_MASK_BIND))
28386 +                               return -1;
28387                 }
28388                 if (inet->inet_daddr) {
28389                         if (inet->inet_daddr != saddr)
28390 @@ -439,6 +437,7 @@ exact_match:
28391         return result;
28392  }
28393  
28394 +
28395  /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
28396   * harder than this. -DaveM
28397   */
28398 @@ -484,6 +483,11 @@ begin:
28399         sk_nulls_for_each_rcu(sk, node, &hslot->head) {
28400                 score = compute_score(sk, net, saddr, hnum, sport,
28401                                       daddr, dport, dif);
28402 +               /* FIXME: disabled?
28403 +               if (score == 9) {
28404 +                       result = sk;
28405 +                       break;
28406 +               } else */
28407                 if (score > badness) {
28408                         result = sk;
28409                         badness = score;
28410 @@ -497,6 +501,7 @@ begin:
28411         if (get_nulls_value(node) != slot)
28412                 goto begin;
28413  
28414 +
28415         if (result) {
28416                 if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt)))
28417                         result = NULL;
28418 @@ -506,6 +511,7 @@ begin:
28419                         goto begin;
28420                 }
28421         }
28422 +
28423         rcu_read_unlock();
28424         return result;
28425  }
28426 @@ -548,8 +554,7 @@ static inline struct sock *udp_v4_mcast_
28427                     udp_sk(s)->udp_port_hash != hnum ||
28428                     (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
28429                     (inet->inet_dport != rmt_port && inet->inet_dport) ||
28430 -                   (inet->inet_rcv_saddr &&
28431 -                    inet->inet_rcv_saddr != loc_addr) ||
28432 +                   !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
28433                     ipv6_only_sock(s) ||
28434                     (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
28435                         continue;
28436 @@ -898,8 +903,13 @@ int udp_sendmsg(struct kiocb *iocb, stru
28437                                                { .sport = inet->inet_sport,
28438                                                  .dport = dport } } };
28439                 struct net *net = sock_net(sk);
28440 +               struct nx_info *nxi = sk->sk_nx_info;
28441  
28442                 security_sk_classify_flow(sk, &fl);
28443 +               err = ip_v4_find_src(net, nxi, &rt, &fl);
28444 +               if (err)
28445 +                       goto out;
28446 +
28447                 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
28448                 if (err) {
28449                         if (err == -ENETUNREACH)
28450 @@ -1180,7 +1190,8 @@ try_again:
28451         if (sin) {
28452                 sin->sin_family = AF_INET;
28453                 sin->sin_port = udp_hdr(skb)->source;
28454 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
28455 +               sin->sin_addr.s_addr = nx_map_sock_lback(
28456 +                       skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
28457                 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
28458         }
28459         if (inet->cmsg_flags)
28460 @@ -1865,6 +1876,8 @@ static struct sock *udp_get_first(struct
28461                 sk_nulls_for_each(sk, node, &hslot->head) {
28462                         if (!net_eq(sock_net(sk), net))
28463                                 continue;
28464 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
28465 +                               continue;
28466                         if (sk->sk_family == state->family)
28467                                 goto found;
28468                 }
28469 @@ -1882,7 +1895,9 @@ static struct sock *udp_get_next(struct 
28470  
28471         do {
28472                 sk = sk_nulls_next(sk);
28473 -       } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
28474 +       } while (sk && (!net_eq(sock_net(sk), net) ||
28475 +               sk->sk_family != state->family ||
28476 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
28477  
28478         if (!sk) {
28479                 if (state->bucket <= state->udp_table->mask)
28480 @@ -1989,7 +2004,10 @@ static void udp4_format_sock(struct sock
28481  
28482         seq_printf(f, "%5d: %08X:%04X %08X:%04X"
28483                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %d%n",
28484 -               bucket, src, srcp, dest, destp, sp->sk_state,
28485 +               bucket,
28486 +               nx_map_sock_lback(current_nx_info(), src), srcp,
28487 +               nx_map_sock_lback(current_nx_info(), dest), destp,
28488 +               sp->sk_state,
28489                 sk_wmem_alloc_get(sp),
28490                 sk_rmem_alloc_get(sp),
28491                 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
28492 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/addrconf.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/addrconf.c
28493 --- linux-2.6.33.1/net/ipv6/addrconf.c  2010-02-25 11:52:10.000000000 +0100
28494 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/addrconf.c  2010-02-25 13:40:38.000000000 +0100
28495 @@ -86,6 +86,8 @@
28496  
28497  #include <linux/proc_fs.h>
28498  #include <linux/seq_file.h>
28499 +#include <linux/vs_network.h>
28500 +#include <linux/vs_inet6.h>
28501  
28502  /* Set to 3 to get tracing... */
28503  #define ACONF_DEBUG 2
28504 @@ -1120,7 +1122,7 @@ out:
28505  
28506  int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
28507                        const struct in6_addr *daddr, unsigned int prefs,
28508 -                      struct in6_addr *saddr)
28509 +                      struct in6_addr *saddr, struct nx_info *nxi)
28510  {
28511         struct ipv6_saddr_score scores[2],
28512                                 *score = &scores[0], *hiscore = &scores[1];
28513 @@ -1192,6 +1194,8 @@ int ipv6_dev_get_saddr(struct net *net, 
28514                                                dev->name);
28515                                 continue;
28516                         }
28517 +                       if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
28518 +                               continue;
28519  
28520                         score->rule = -1;
28521                         bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
28522 @@ -2999,7 +3003,10 @@ static void if6_seq_stop(struct seq_file
28523  static int if6_seq_show(struct seq_file *seq, void *v)
28524  {
28525         struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
28526 -       seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
28527 +
28528 +       if (nx_check(0, VS_ADMIN|VS_WATCH) ||
28529 +           v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
28530 +               seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
28531                    &ifp->addr,
28532                    ifp->idev->dev->ifindex,
28533                    ifp->prefix_len,
28534 @@ -3494,6 +3501,11 @@ static int in6_dump_addrs(struct inet6_d
28535         struct ifacaddr6 *ifaca;
28536         int err = 1;
28537         int ip_idx = *p_ip_idx;
28538 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
28539 +
28540 +       /* disable ipv6 on non v6 guests */
28541 +       if (nxi && !nx_info_has_v6(nxi))
28542 +               return skb->len;
28543  
28544         read_lock_bh(&idev->lock);
28545         switch (type) {
28546 @@ -3503,6 +3515,8 @@ static int in6_dump_addrs(struct inet6_d
28547                      ifa = ifa->if_next, ip_idx++) {
28548                         if (ip_idx < s_ip_idx)
28549                                 continue;
28550 +                               if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
28551 +                                       continue;
28552                         err = inet6_fill_ifaddr(skb, ifa,
28553                                                 NETLINK_CB(cb->skb).pid,
28554                                                 cb->nlh->nlmsg_seq,
28555 @@ -3518,6 +3532,8 @@ static int in6_dump_addrs(struct inet6_d
28556                      ifmca = ifmca->next, ip_idx++) {
28557                         if (ip_idx < s_ip_idx)
28558                                 continue;
28559 +                               if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
28560 +                                       continue;
28561                         err = inet6_fill_ifmcaddr(skb, ifmca,
28562                                                   NETLINK_CB(cb->skb).pid,
28563                                                   cb->nlh->nlmsg_seq,
28564 @@ -3533,6 +3549,8 @@ static int in6_dump_addrs(struct inet6_d
28565                      ifaca = ifaca->aca_next, ip_idx++) {
28566                         if (ip_idx < s_ip_idx)
28567                                 continue;
28568 +                               if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
28569 +                                       continue;
28570                         err = inet6_fill_ifacaddr(skb, ifaca,
28571                                                   NETLINK_CB(cb->skb).pid,
28572                                                   cb->nlh->nlmsg_seq,
28573 @@ -3861,6 +3879,11 @@ static int inet6_dump_ifinfo(struct sk_b
28574         struct inet6_dev *idev;
28575         struct hlist_head *head;
28576         struct hlist_node *node;
28577 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
28578 +
28579 +       /* FIXME: maybe disable ipv6 on non v6 guests?
28580 +       if (skb->sk && skb->sk->sk_vx_info)
28581 +               return skb->len; */
28582  
28583         s_h = cb->args[0];
28584         s_idx = cb->args[1];
28585 @@ -3872,6 +3895,8 @@ static int inet6_dump_ifinfo(struct sk_b
28586                 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
28587                         if (idx < s_idx)
28588                                 goto cont;
28589 +                       if (!v6_dev_in_nx_info(dev, nxi))
28590 +                               goto cont;
28591                         idev = __in6_dev_get(dev);
28592                         if (!idev)
28593                                 goto cont;
28594 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/af_inet6.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/af_inet6.c
28595 --- linux-2.6.33.1/net/ipv6/af_inet6.c  2010-02-25 11:52:10.000000000 +0100
28596 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/af_inet6.c  2010-02-25 15:54:53.000000000 +0100
28597 @@ -41,6 +41,8 @@
28598  #include <linux/netdevice.h>
28599  #include <linux/icmpv6.h>
28600  #include <linux/netfilter_ipv6.h>
28601 +#include <linux/vs_inet.h>
28602 +#include <linux/vs_inet6.h>
28603  
28604  #include <net/ip.h>
28605  #include <net/ipv6.h>
28606 @@ -159,9 +161,12 @@ lookup_protocol:
28607         }
28608  
28609         err = -EPERM;
28610 +       if ((protocol == IPPROTO_ICMPV6) &&
28611 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
28612 +               goto override;
28613         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
28614                 goto out_rcu_unlock;
28615 -
28616 +override:
28617         sock->ops = answer->ops;
28618         answer_prot = answer->prot;
28619         answer_no_check = answer->no_check;
28620 @@ -260,6 +265,7 @@ int inet6_bind(struct socket *sock, stru
28621         struct inet_sock *inet = inet_sk(sk);
28622         struct ipv6_pinfo *np = inet6_sk(sk);
28623         struct net *net = sock_net(sk);
28624 +       struct nx_v6_sock_addr nsa;
28625         __be32 v4addr = 0;
28626         unsigned short snum;
28627         int addr_type = 0;
28628 @@ -271,6 +277,11 @@ int inet6_bind(struct socket *sock, stru
28629  
28630         if (addr_len < SIN6_LEN_RFC2133)
28631                 return -EINVAL;
28632 +
28633 +       err = v6_map_sock_addr(inet, addr, &nsa);
28634 +       if (err)
28635 +               return err;
28636 +
28637         addr_type = ipv6_addr_type(&addr->sin6_addr);
28638         if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
28639                 return -EINVAL;
28640 @@ -302,6 +313,7 @@ int inet6_bind(struct socket *sock, stru
28641                 /* Reproduce AF_INET checks to make the bindings consitant */
28642                 v4addr = addr->sin6_addr.s6_addr32[3];
28643                 chk_addr_ret = inet_addr_type(net, v4addr);
28644 +
28645                 if (!sysctl_ip_nonlocal_bind &&
28646                     !(inet->freebind || inet->transparent) &&
28647                     v4addr != htonl(INADDR_ANY) &&
28648 @@ -311,6 +323,10 @@ int inet6_bind(struct socket *sock, stru
28649                         err = -EADDRNOTAVAIL;
28650                         goto out;
28651                 }
28652 +               if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
28653 +                       err = -EADDRNOTAVAIL;
28654 +                       goto out;
28655 +               }
28656         } else {
28657                 if (addr_type != IPV6_ADDR_ANY) {
28658                         struct net_device *dev = NULL;
28659 @@ -337,6 +353,11 @@ int inet6_bind(struct socket *sock, stru
28660                                 }
28661                         }
28662  
28663 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28664 +                               err = -EADDRNOTAVAIL;
28665 +                               goto out;
28666 +                       }
28667 +
28668                         /* ipv4 addr of the socket is invalid.  Only the
28669                          * unspecified and mapped address have a v4 equivalent.
28670                          */
28671 @@ -352,6 +373,9 @@ int inet6_bind(struct socket *sock, stru
28672                 }
28673         }
28674  
28675 +       /* what's that for? */
28676 +       v6_set_sock_addr(inet, &nsa);
28677 +
28678         inet->inet_rcv_saddr = v4addr;
28679         inet->inet_saddr = v4addr;
28680  
28681 @@ -450,9 +474,11 @@ int inet6_getname(struct socket *sock, s
28682                         return -ENOTCONN;
28683                 sin->sin6_port = inet->inet_dport;
28684                 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
28685 +               /* FIXME: remap lback? */
28686                 if (np->sndflow)
28687                         sin->sin6_flowinfo = np->flow_label;
28688         } else {
28689 +               /* FIXME: remap lback? */
28690                 if (ipv6_addr_any(&np->rcv_saddr))
28691                         ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
28692                 else
28693 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/fib6_rules.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/fib6_rules.c
28694 --- linux-2.6.33.1/net/ipv6/fib6_rules.c        2010-02-25 11:52:10.000000000 +0100
28695 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/fib6_rules.c        2010-02-25 12:02:16.000000000 +0100
28696 @@ -96,7 +96,7 @@ static int fib6_rule_action(struct fib_r
28697                         if (ipv6_dev_get_saddr(net,
28698                                                ip6_dst_idev(&rt->u.dst)->dev,
28699                                                &flp->fl6_dst, srcprefs,
28700 -                                              &saddr))
28701 +                                              &saddr, NULL))
28702                                 goto again;
28703                         if (!ipv6_prefix_equal(&saddr, &r->src.addr,
28704                                                r->src.plen))
28705 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/inet6_hashtables.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/inet6_hashtables.c
28706 --- linux-2.6.33.1/net/ipv6/inet6_hashtables.c  2010-02-25 11:52:10.000000000 +0100
28707 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/inet6_hashtables.c  2010-02-25 12:02:16.000000000 +0100
28708 @@ -16,6 +16,7 @@
28709  
28710  #include <linux/module.h>
28711  #include <linux/random.h>
28712 +#include <linux/vs_inet6.h>
28713  
28714  #include <net/inet_connection_sock.h>
28715  #include <net/inet_hashtables.h>
28716 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
28717         unsigned int slot = hash & hashinfo->ehash_mask;
28718         struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
28719  
28720 -
28721         rcu_read_lock();
28722  begin:
28723         sk_nulls_for_each_rcu(sk, node, &head->chain) {
28724 @@ -94,7 +94,7 @@ begin:
28725                                 sock_put(sk);
28726                                 goto begin;
28727                         }
28728 -               goto out;
28729 +                       goto out;
28730                 }
28731         }
28732         if (get_nulls_value(node) != slot)
28733 @@ -140,6 +140,9 @@ static int inline compute_score(struct s
28734                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28735                                 return -1;
28736                         score++;
28737 +               } else {
28738 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28739 +                               return -1;
28740                 }
28741                 if (sk->sk_bound_dev_if) {
28742                         if (sk->sk_bound_dev_if != dif)
28743 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/ip6_output.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/ip6_output.c
28744 --- linux-2.6.33.1/net/ipv6/ip6_output.c        2010-02-25 11:52:10.000000000 +0100
28745 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/ip6_output.c        2010-02-25 12:02:16.000000000 +0100
28746 @@ -933,7 +933,7 @@ static int ip6_dst_lookup_tail(struct so
28747                 err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
28748                                          &fl->fl6_dst,
28749                                          sk ? inet6_sk(sk)->srcprefs : 0,
28750 -                                        &fl->fl6_src);
28751 +                                        &fl->fl6_src, sk->sk_nx_info);
28752                 if (err)
28753                         goto out_err_release;
28754         }
28755 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/Kconfig linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/Kconfig
28756 --- linux-2.6.33.1/net/ipv6/Kconfig     2010-02-25 11:52:10.000000000 +0100
28757 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/Kconfig     2010-02-25 12:02:16.000000000 +0100
28758 @@ -4,8 +4,8 @@
28759  
28760  #   IPv6 as module will cause a CRASH if you try to unload it
28761  menuconfig IPV6
28762 -       tristate "The IPv6 protocol"
28763 -       default m
28764 +       bool "The IPv6 protocol"
28765 +       default n
28766         ---help---
28767           This is complemental support for the IP version 6.
28768           You will still be able to do traditional IPv4 networking as well.
28769 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/ndisc.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/ndisc.c
28770 --- linux-2.6.33.1/net/ipv6/ndisc.c     2010-02-25 11:52:10.000000000 +0100
28771 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/ndisc.c     2010-02-25 12:02:16.000000000 +0100
28772 @@ -589,7 +589,7 @@ static void ndisc_send_na(struct net_dev
28773         } else {
28774                 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
28775                                        inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
28776 -                                      &tmpaddr))
28777 +                                      &tmpaddr, NULL /* FIXME: ? */ ))
28778                         return;
28779                 src_addr = &tmpaddr;
28780         }
28781 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/raw.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/raw.c
28782 --- linux-2.6.33.1/net/ipv6/raw.c       2010-02-25 11:52:11.000000000 +0100
28783 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/raw.c       2010-02-25 12:02:16.000000000 +0100
28784 @@ -29,6 +29,7 @@
28785  #include <linux/icmpv6.h>
28786  #include <linux/netfilter.h>
28787  #include <linux/netfilter_ipv6.h>
28788 +#include <linux/vs_inet6.h>
28789  #include <linux/skbuff.h>
28790  #include <asm/uaccess.h>
28791  #include <asm/ioctls.h>
28792 @@ -282,6 +283,13 @@ static int rawv6_bind(struct sock *sk, s
28793                                 goto out_unlock;
28794                 }
28795  
28796 +               if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
28797 +                       err = -EADDRNOTAVAIL;
28798 +                       if (dev)
28799 +                               dev_put(dev);
28800 +                       goto out;
28801 +               }
28802 +
28803                 /* ipv4 addr of the socket is invalid.  Only the
28804                  * unspecified and mapped address have a v4 equivalent.
28805                  */
28806 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/route.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/route.c
28807 --- linux-2.6.33.1/net/ipv6/route.c     2010-02-25 11:52:11.000000000 +0100
28808 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/route.c     2010-02-25 12:02:16.000000000 +0100
28809 @@ -2258,7 +2258,8 @@ static int rt6_fill_node(struct net *net
28810                 struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst);
28811                 struct in6_addr saddr_buf;
28812                 if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
28813 -                                      dst, 0, &saddr_buf) == 0)
28814 +                       dst, 0, &saddr_buf,
28815 +                       (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
28816                         NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
28817         }
28818  
28819 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/tcp_ipv6.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/tcp_ipv6.c
28820 --- linux-2.6.33.1/net/ipv6/tcp_ipv6.c  2010-02-25 11:52:11.000000000 +0100
28821 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/tcp_ipv6.c  2010-02-25 12:02:16.000000000 +0100
28822 @@ -68,6 +68,7 @@
28823  
28824  #include <linux/crypto.h>
28825  #include <linux/scatterlist.h>
28826 +#include <linux/vs_inet6.h>
28827  
28828  static void    tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
28829  static void    tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
28830 @@ -156,8 +157,15 @@ static int tcp_v6_connect(struct sock *s
28831          *      connect() to INADDR_ANY means loopback (BSD'ism).
28832          */
28833  
28834 -       if(ipv6_addr_any(&usin->sin6_addr))
28835 -               usin->sin6_addr.s6_addr[15] = 0x1;
28836 +       if(ipv6_addr_any(&usin->sin6_addr)) {
28837 +               struct nx_info *nxi =  sk->sk_nx_info;
28838 +
28839 +               if (nxi && nx_info_has_v6(nxi))
28840 +                       /* FIXME: remap lback? */
28841 +                       usin->sin6_addr = nxi->v6.ip;
28842 +               else
28843 +                       usin->sin6_addr.s6_addr[15] = 0x1;
28844 +       }
28845  
28846         addr_type = ipv6_addr_type(&usin->sin6_addr);
28847  
28848 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/udp.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/udp.c
28849 --- linux-2.6.33.1/net/ipv6/udp.c       2010-02-25 11:52:11.000000000 +0100
28850 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/udp.c       2010-02-25 15:58:22.000000000 +0100
28851 @@ -47,13 +47,14 @@
28852  
28853  #include <linux/proc_fs.h>
28854  #include <linux/seq_file.h>
28855 +#include <linux/vs_inet6.h>
28856  #include "udp_impl.h"
28857  
28858  int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
28859  {
28860         const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
28861         const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
28862 -       __be32 sk1_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28863 +       __be32 sk_rcv_saddr = inet_sk(sk)->inet_rcv_saddr;
28864         __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
28865         int sk_ipv6only = ipv6_only_sock(sk);
28866         int sk2_ipv6only = inet_v6_ipv6only(sk2);
28867 @@ -61,24 +62,49 @@ int ipv6_rcv_saddr_equal(const struct so
28868         int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
28869  
28870         /* if both are mapped, treat as IPv4 */
28871 -       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
28872 -               return (!sk2_ipv6only &&
28873 -                       (!sk1_rcv_saddr || !sk2_rcv_saddr ||
28874 -                         sk1_rcv_saddr == sk2_rcv_saddr));
28875 +       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
28876 +               if (!sk2_ipv6only &&
28877 +                       (!sk_rcv_saddr || !sk2_rcv_saddr ||
28878 +                         sk_rcv_saddr == sk2_rcv_saddr))
28879 +                       goto vs_v4;
28880 +               else
28881 +                       return 0;
28882 +       }
28883  
28884         if (addr_type2 == IPV6_ADDR_ANY &&
28885             !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
28886 -               return 1;
28887 +               goto vs;
28888  
28889         if (addr_type == IPV6_ADDR_ANY &&
28890             !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
28891 -               return 1;
28892 +               goto vs;
28893  
28894         if (sk2_rcv_saddr6 &&
28895             ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
28896 -               return 1;
28897 +               goto vs;
28898  
28899         return 0;
28900 +
28901 +vs_v4:
28902 +       if (!sk_rcv_saddr && !sk2_rcv_saddr)
28903 +               return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28904 +       if (!sk2_rcv_saddr)
28905 +               return v4_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr, -1);
28906 +       if (!sk_rcv_saddr)
28907 +               return v4_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr, -1);
28908 +       return 1;
28909 +vs:
28910 +       if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
28911 +               return nx_v6_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28912 +       else if (addr_type2 == IPV6_ADDR_ANY)
28913 +               return v6_addr_in_nx_info(sk2->sk_nx_info, sk_rcv_saddr6, -1);
28914 +       else if (addr_type == IPV6_ADDR_ANY) {
28915 +               if (addr_type2 == IPV6_ADDR_MAPPED)
28916 +                       return nx_v4_addr_conflict(sk->sk_nx_info, sk2->sk_nx_info);
28917 +               else
28918 +                       return v6_addr_in_nx_info(sk->sk_nx_info, sk2_rcv_saddr6, -1);
28919 +       }
28920 +       return 1;
28921  }
28922  
28923  static unsigned int udp6_portaddr_hash(struct net *net,
28924 @@ -133,6 +159,10 @@ static inline int compute_score(struct s
28925                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
28926                                 return -1;
28927                         score++;
28928 +               } else {
28929 +                       /* block non nx_info ips */
28930 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
28931 +                               return -1;
28932                 }
28933                 if (!ipv6_addr_any(&np->daddr)) {
28934                         if (!ipv6_addr_equal(&np->daddr, saddr))
28935 diff -NurpP --minimal linux-2.6.33.1/net/ipv6/xfrm6_policy.c linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/xfrm6_policy.c
28936 --- linux-2.6.33.1/net/ipv6/xfrm6_policy.c      2010-02-25 11:52:11.000000000 +0100
28937 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/ipv6/xfrm6_policy.c      2010-02-25 12:02:16.000000000 +0100
28938 @@ -62,7 +62,7 @@ static int xfrm6_get_saddr(struct net *n
28939         dev = ip6_dst_idev(dst)->dev;
28940         ipv6_dev_get_saddr(dev_net(dev), dev,
28941                            (struct in6_addr *)&daddr->a6, 0,
28942 -                          (struct in6_addr *)&saddr->a6);
28943 +                          (struct in6_addr *)&saddr->a6, NULL);
28944         dst_release(dst);
28945         return 0;
28946  }
28947 diff -NurpP --minimal linux-2.6.33.1/net/netlink/af_netlink.c linux-2.6.33.1-vs2.3.0.36.30.4/net/netlink/af_netlink.c
28948 --- linux-2.6.33.1/net/netlink/af_netlink.c     2010-02-25 11:52:11.000000000 +0100
28949 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/netlink/af_netlink.c     2010-02-25 12:02:16.000000000 +0100
28950 @@ -55,6 +55,9 @@
28951  #include <linux/types.h>
28952  #include <linux/audit.h>
28953  #include <linux/mutex.h>
28954 +#include <linux/vs_context.h>
28955 +#include <linux/vs_network.h>
28956 +#include <linux/vs_limit.h>
28957  
28958  #include <net/net_namespace.h>
28959  #include <net/sock.h>
28960 @@ -1905,6 +1908,8 @@ static struct sock *netlink_seq_socket_i
28961                         sk_for_each(s, node, &hash->table[j]) {
28962                                 if (sock_net(s) != seq_file_net(seq))
28963                                         continue;
28964 +                               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28965 +                                       continue;
28966                                 if (off == pos) {
28967                                         iter->link = i;
28968                                         iter->hash_idx = j;
28969 @@ -1939,7 +1944,8 @@ static void *netlink_seq_next(struct seq
28970         s = v;
28971         do {
28972                 s = sk_next(s);
28973 -       } while (s && sock_net(s) != seq_file_net(seq));
28974 +       } while (s && (sock_net(s) != seq_file_net(seq) ||
28975 +               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28976         if (s)
28977                 return s;
28978  
28979 @@ -1951,7 +1957,8 @@ static void *netlink_seq_next(struct seq
28980  
28981                 for (; j <= hash->mask; j++) {
28982                         s = sk_head(&hash->table[j]);
28983 -                       while (s && sock_net(s) != seq_file_net(seq))
28984 +                       while (s && (sock_net(s) != seq_file_net(seq) ||
28985 +                               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28986                                 s = sk_next(s);
28987                         if (s) {
28988                                 iter->link = i;
28989 diff -NurpP --minimal linux-2.6.33.1/net/sctp/ipv6.c linux-2.6.33.1-vs2.3.0.36.30.4/net/sctp/ipv6.c
28990 --- linux-2.6.33.1/net/sctp/ipv6.c      2010-02-25 11:52:12.000000000 +0100
28991 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/sctp/ipv6.c      2010-02-25 12:02:16.000000000 +0100
28992 @@ -316,7 +316,8 @@ static void sctp_v6_get_saddr(struct sct
28993                                    dst ? ip6_dst_idev(dst)->dev : NULL,
28994                                    &daddr->v6.sin6_addr,
28995                                    inet6_sk(&sk->inet.sk)->srcprefs,
28996 -                                  &saddr->v6.sin6_addr);
28997 +                                  &saddr->v6.sin6_addr,
28998 +                                  asoc->base.sk->sk_nx_info);
28999                 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: %pI6\n",
29000                                   &saddr->v6.sin6_addr);
29001                 return;
29002 diff -NurpP --minimal linux-2.6.33.1/net/socket.c linux-2.6.33.1-vs2.3.0.36.30.4/net/socket.c
29003 --- linux-2.6.33.1/net/socket.c 2010-02-25 11:52:12.000000000 +0100
29004 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/socket.c 2010-02-25 13:51:25.000000000 +0100
29005 @@ -96,6 +96,10 @@
29006  
29007  #include <net/sock.h>
29008  #include <linux/netfilter.h>
29009 +#include <linux/vs_base.h>
29010 +#include <linux/vs_socket.h>
29011 +#include <linux/vs_inet.h>
29012 +#include <linux/vs_inet6.h>
29013  
29014  #include <linux/if_tun.h>
29015  #include <linux/ipv6_route.h>
29016 @@ -539,7 +543,7 @@ static inline int __sock_sendmsg(struct 
29017                                  struct msghdr *msg, size_t size)
29018  {
29019         struct sock_iocb *si = kiocb_to_siocb(iocb);
29020 -       int err;
29021 +       int err, len;
29022  
29023         si->sock = sock;
29024         si->scm = NULL;
29025 @@ -550,7 +554,22 @@ static inline int __sock_sendmsg(struct 
29026         if (err)
29027                 return err;
29028  
29029 -       return sock->ops->sendmsg(iocb, sock, msg, size);
29030 +       len = sock->ops->sendmsg(iocb, sock, msg, size);
29031 +       if (sock->sk) {
29032 +               if (len == size)
29033 +                       vx_sock_send(sock->sk, size);
29034 +               else
29035 +                       vx_sock_fail(sock->sk, size);
29036 +       }
29037 +       vxdprintk(VXD_CBIT(net, 7),
29038 +               "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29039 +               sock, sock->sk,
29040 +               (sock->sk)?sock->sk->sk_nx_info:0,
29041 +               (sock->sk)?sock->sk->sk_vx_info:0,
29042 +               (sock->sk)?sock->sk->sk_xid:0,
29043 +               (sock->sk)?sock->sk->sk_nid:0,
29044 +               (unsigned int)size, len);
29045 +       return len;
29046  }
29047  
29048  int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
29049 @@ -667,6 +686,7 @@ static inline int __sock_recvmsg_nosec(s
29050                                        struct msghdr *msg, size_t size, int flags)
29051  {
29052         struct sock_iocb *si = kiocb_to_siocb(iocb);
29053 +       int len;
29054  
29055         si->sock = sock;
29056         si->scm = NULL;
29057 @@ -674,7 +694,18 @@ static inline int __sock_recvmsg_nosec(s
29058         si->size = size;
29059         si->flags = flags;
29060  
29061 -       return sock->ops->recvmsg(iocb, sock, msg, size, flags);
29062 +       len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
29063 +       if ((len >= 0) && sock->sk)
29064 +               vx_sock_recv(sock->sk, len);
29065 +       vxdprintk(VXD_CBIT(net, 7),
29066 +               "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
29067 +               sock, sock->sk,
29068 +               (sock->sk)?sock->sk->sk_nx_info:0,
29069 +               (sock->sk)?sock->sk->sk_vx_info:0,
29070 +               (sock->sk)?sock->sk->sk_xid:0,
29071 +               (sock->sk)?sock->sk->sk_nid:0,
29072 +               (unsigned int)size, len);
29073 +       return len;
29074  }
29075  
29076  static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
29077 @@ -1182,6 +1213,13 @@ static int __sock_create(struct net *net
29078         if (type < 0 || type >= SOCK_MAX)
29079                 return -EINVAL;
29080  
29081 +       if (!nx_check(0, VS_ADMIN)) {
29082 +               if (family == PF_INET && !current_nx_info_has_v4())
29083 +                       return -EAFNOSUPPORT;
29084 +               if (family == PF_INET6 && !current_nx_info_has_v6())
29085 +                       return -EAFNOSUPPORT;
29086 +       }
29087 +
29088         /* Compatibility.
29089  
29090            This uglymoron is moved from INET layer to here to avoid
29091 @@ -1314,6 +1352,7 @@ SYSCALL_DEFINE3(socket, int, family, int
29092         if (retval < 0)
29093                 goto out;
29094  
29095 +       set_bit(SOCK_USER_SOCKET, &sock->flags);
29096         retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
29097         if (retval < 0)
29098                 goto out_release;
29099 @@ -1355,10 +1394,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
29100         err = sock_create(family, type, protocol, &sock1);
29101         if (err < 0)
29102                 goto out;
29103 +       set_bit(SOCK_USER_SOCKET, &sock1->flags);
29104  
29105         err = sock_create(family, type, protocol, &sock2);
29106         if (err < 0)
29107                 goto out_release_1;
29108 +       set_bit(SOCK_USER_SOCKET, &sock2->flags);
29109  
29110         err = sock1->ops->socketpair(sock1, sock2);
29111         if (err < 0)
29112 diff -NurpP --minimal linux-2.6.33.1/net/sunrpc/auth.c linux-2.6.33.1-vs2.3.0.36.30.4/net/sunrpc/auth.c
29113 --- linux-2.6.33.1/net/sunrpc/auth.c    2010-02-25 11:52:12.000000000 +0100
29114 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/sunrpc/auth.c    2010-02-25 12:02:16.000000000 +0100
29115 @@ -14,6 +14,7 @@
29116  #include <linux/hash.h>
29117  #include <linux/sunrpc/clnt.h>
29118  #include <linux/spinlock.h>
29119 +#include <linux/vs_tag.h>
29120  
29121  #ifdef RPC_DEBUG
29122  # define RPCDBG_FACILITY       RPCDBG_AUTH
29123 @@ -363,6 +364,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
29124         memset(&acred, 0, sizeof(acred));
29125         acred.uid = cred->fsuid;
29126         acred.gid = cred->fsgid;
29127 +       acred.tag = dx_current_tag();
29128         acred.group_info = get_group_info(((struct cred *)cred)->group_info);
29129  
29130         ret = auth->au_ops->lookup_cred(auth, &acred, flags);
29131 @@ -403,6 +405,7 @@ rpcauth_bind_root_cred(struct rpc_task *
29132         struct auth_cred acred = {
29133                 .uid = 0,
29134                 .gid = 0,
29135 +               .tag = dx_current_tag(),
29136         };
29137         struct rpc_cred *ret;
29138  
29139 diff -NurpP --minimal linux-2.6.33.1/net/sunrpc/auth_unix.c linux-2.6.33.1-vs2.3.0.36.30.4/net/sunrpc/auth_unix.c
29140 --- linux-2.6.33.1/net/sunrpc/auth_unix.c       2008-12-25 00:26:37.000000000 +0100
29141 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/sunrpc/auth_unix.c       2010-02-25 12:02:16.000000000 +0100
29142 @@ -11,12 +11,14 @@
29143  #include <linux/module.h>
29144  #include <linux/sunrpc/clnt.h>
29145  #include <linux/sunrpc/auth.h>
29146 +#include <linux/vs_tag.h>
29147  
29148  #define NFS_NGROUPS    16
29149  
29150  struct unx_cred {
29151         struct rpc_cred         uc_base;
29152         gid_t                   uc_gid;
29153 +       tag_t                   uc_tag;
29154         gid_t                   uc_gids[NFS_NGROUPS];
29155  };
29156  #define uc_uid                 uc_base.cr_uid
29157 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
29158                 groups = NFS_NGROUPS;
29159  
29160         cred->uc_gid = acred->gid;
29161 +       cred->uc_tag = acred->tag;
29162         for (i = 0; i < groups; i++)
29163                 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
29164         if (i < NFS_NGROUPS)
29165 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
29166         unsigned int i;
29167  
29168  
29169 -       if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
29170 +       if (cred->uc_uid != acred->uid ||
29171 +               cred->uc_gid != acred->gid ||
29172 +               cred->uc_tag != acred->tag)
29173                 return 0;
29174  
29175         if (acred->group_info != NULL)
29176 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
29177         struct rpc_clnt *clnt = task->tk_client;
29178         struct unx_cred *cred = container_of(task->tk_msg.rpc_cred, struct unx_cred, uc_base);
29179         __be32          *base, *hold;
29180 -       int             i;
29181 +       int             i, tag;
29182  
29183         *p++ = htonl(RPC_AUTH_UNIX);
29184         base = p++;
29185 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
29186          * Copy the UTS nodename captured when the client was created.
29187          */
29188         p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
29189 +       tag = task->tk_client->cl_tag;
29190  
29191 -       *p++ = htonl((u32) cred->uc_uid);
29192 -       *p++ = htonl((u32) cred->uc_gid);
29193 +       *p++ = htonl((u32) TAGINO_UID(tag,
29194 +               cred->uc_uid, cred->uc_tag));
29195 +       *p++ = htonl((u32) TAGINO_GID(tag,
29196 +               cred->uc_gid, cred->uc_tag));
29197         hold = p++;
29198         for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
29199                 *p++ = htonl((u32) cred->uc_gids[i]);
29200 diff -NurpP --minimal linux-2.6.33.1/net/sunrpc/clnt.c linux-2.6.33.1-vs2.3.0.36.30.4/net/sunrpc/clnt.c
29201 --- linux-2.6.33.1/net/sunrpc/clnt.c    2010-02-25 11:52:12.000000000 +0100
29202 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/sunrpc/clnt.c    2010-02-25 12:02:16.000000000 +0100
29203 @@ -33,6 +33,7 @@
29204  #include <linux/utsname.h>
29205  #include <linux/workqueue.h>
29206  #include <linux/in6.h>
29207 +#include <linux/vs_cvirt.h>
29208  
29209  #include <linux/sunrpc/clnt.h>
29210  #include <linux/sunrpc/rpc_pipe_fs.h>
29211 @@ -358,6 +359,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
29212         if (!(args->flags & RPC_CLNT_CREATE_QUIET))
29213                 clnt->cl_chatty = 1;
29214  
29215 +       /* TODO: handle RPC_CLNT_CREATE_TAGGED
29216 +       if (args->flags & RPC_CLNT_CREATE_TAGGED)
29217 +               clnt->cl_tag = 1; */
29218         return clnt;
29219  }
29220  EXPORT_SYMBOL_GPL(rpc_create);
29221 diff -NurpP --minimal linux-2.6.33.1/net/unix/af_unix.c linux-2.6.33.1-vs2.3.0.36.30.4/net/unix/af_unix.c
29222 --- linux-2.6.33.1/net/unix/af_unix.c   2010-02-25 11:52:12.000000000 +0100
29223 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/unix/af_unix.c   2010-02-25 12:02:16.000000000 +0100
29224 @@ -114,6 +114,8 @@
29225  #include <linux/mount.h>
29226  #include <net/checksum.h>
29227  #include <linux/security.h>
29228 +#include <linux/vs_context.h>
29229 +#include <linux/vs_limit.h>
29230  
29231  static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
29232  static DEFINE_SPINLOCK(unix_table_lock);
29233 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
29234                 if (!net_eq(sock_net(s), net))
29235                         continue;
29236  
29237 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
29238 +                       continue;
29239                 if (u->addr->len == len &&
29240                     !memcmp(u->addr->name, sunname, len))
29241                         goto found;
29242 @@ -2115,6 +2119,8 @@ static struct sock *unix_seq_idx(struct 
29243         for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
29244                 if (sock_net(s) != seq_file_net(seq))
29245                         continue;
29246 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
29247 +                       continue;
29248                 if (off == pos)
29249                         return s;
29250                 ++off;
29251 @@ -2139,7 +2145,8 @@ static void *unix_seq_next(struct seq_fi
29252                 sk = first_unix_socket(&iter->i);
29253         else
29254                 sk = next_unix_socket(&iter->i, sk);
29255 -       while (sk && (sock_net(sk) != seq_file_net(seq)))
29256 +       while (sk && (sock_net(sk) != seq_file_net(seq) ||
29257 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
29258                 sk = next_unix_socket(&iter->i, sk);
29259         return sk;
29260  }
29261 diff -NurpP --minimal linux-2.6.33.1/net/x25/af_x25.c linux-2.6.33.1-vs2.3.0.36.30.4/net/x25/af_x25.c
29262 --- linux-2.6.33.1/net/x25/af_x25.c     2010-02-25 11:52:12.000000000 +0100
29263 +++ linux-2.6.33.1-vs2.3.0.36.30.4/net/x25/af_x25.c     2010-02-25 12:02:16.000000000 +0100
29264 @@ -526,7 +526,10 @@ static int x25_create(struct net *net, s
29265  
29266         x25 = x25_sk(sk);
29267  
29268 -       sock_init_data(sock, sk);
29269 +       sk->sk_socket = sock;
29270 +       sk->sk_type = sock->type;
29271 +       sk->sk_sleep = &sock->wait;
29272 +       sock->sk = sk;
29273  
29274         x25_init_timers(sk);
29275  
29276 diff -NurpP --minimal linux-2.6.33.1/scripts/checksyscalls.sh linux-2.6.33.1-vs2.3.0.36.30.4/scripts/checksyscalls.sh
29277 --- linux-2.6.33.1/scripts/checksyscalls.sh     2009-09-10 15:26:31.000000000 +0200
29278 +++ linux-2.6.33.1-vs2.3.0.36.30.4/scripts/checksyscalls.sh     2010-02-25 12:02:16.000000000 +0100
29279 @@ -194,7 +194,6 @@ cat << EOF
29280  #define __IGNORE_afs_syscall
29281  #define __IGNORE_getpmsg
29282  #define __IGNORE_putpmsg
29283 -#define __IGNORE_vserver
29284  EOF
29285  }
29286  
29287 diff -NurpP --minimal linux-2.6.33.1/security/commoncap.c linux-2.6.33.1-vs2.3.0.36.30.4/security/commoncap.c
29288 --- linux-2.6.33.1/security/commoncap.c 2010-02-25 11:52:12.000000000 +0100
29289 +++ linux-2.6.33.1-vs2.3.0.36.30.4/security/commoncap.c 2010-03-05 15:30:01.000000000 +0100
29290 @@ -27,6 +27,7 @@
29291  #include <linux/sched.h>
29292  #include <linux/prctl.h>
29293  #include <linux/securebits.h>
29294 +#include <linux/vs_context.h>
29295  
29296  /*
29297   * If a non-root user executes a setuid-root binary in
29298 @@ -52,7 +53,7 @@ static void warn_setuid_and_fcaps_mixed(
29299  
29300  int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
29301  {
29302 -       NETLINK_CB(skb).eff_cap = current_cap();
29303 +       NETLINK_CB(skb).eff_cap = vx_mbcaps(current_cap());
29304         return 0;
29305  }
29306  
29307 @@ -62,6 +63,7 @@ int cap_netlink_recv(struct sk_buff *skb
29308                 return -EPERM;
29309         return 0;
29310  }
29311 +
29312  EXPORT_SYMBOL(cap_netlink_recv);
29313  
29314  /**
29315 @@ -82,7 +84,22 @@ EXPORT_SYMBOL(cap_netlink_recv);
29316  int cap_capable(struct task_struct *tsk, const struct cred *cred, int cap,
29317                 int audit)
29318  {
29319 -       return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
29320 +       struct vx_info *vxi = tsk->vx_info;
29321 +
29322 +#if 0
29323 +       printk("cap_capable() VXF_STATE_SETUP = %llx, raised = %x, eff = %08x:%08x\n",
29324 +               vx_info_flags(vxi, VXF_STATE_SETUP, 0),
29325 +               cap_raised(tsk->cap_effective, cap),
29326 +               tsk->cap_effective.cap[1], tsk->cap_effective.cap[0]);
29327 +#endif
29328 +
29329 +       /* special case SETUP */
29330 +       if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
29331 +               /* FIXME: maybe use cred instead? */
29332 +               cap_raised(tsk->cred->cap_effective, cap))
29333 +               return 0;
29334 +
29335 +       return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
29336  }
29337  
29338  /**
29339 @@ -570,7 +587,7 @@ int cap_inode_setxattr(struct dentry *de
29340  
29341         if (!strncmp(name, XATTR_SECURITY_PREFIX,
29342                      sizeof(XATTR_SECURITY_PREFIX) - 1)  &&
29343 -           !capable(CAP_SYS_ADMIN))
29344 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
29345                 return -EPERM;
29346         return 0;
29347  }
29348 @@ -596,7 +613,7 @@ int cap_inode_removexattr(struct dentry 
29349  
29350         if (!strncmp(name, XATTR_SECURITY_PREFIX,
29351                      sizeof(XATTR_SECURITY_PREFIX) - 1)  &&
29352 -           !capable(CAP_SYS_ADMIN))
29353 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
29354                 return -EPERM;
29355         return 0;
29356  }
29357 @@ -894,7 +911,8 @@ error:
29358   */
29359  int cap_syslog(int type)
29360  {
29361 -       if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
29362 +       if ((type != 3 && type != 10) &&
29363 +               !vx_capable(CAP_SYS_ADMIN, VXC_SYSLOG))
29364                 return -EPERM;
29365         return 0;
29366  }
29367 @@ -946,3 +964,4 @@ int cap_file_mmap(struct file *file, uns
29368         }
29369         return ret;
29370  }
29371 +
29372 diff -NurpP --minimal linux-2.6.33.1/security/selinux/av_permissions.h linux-2.6.33.1-vs2.3.0.36.30.4/security/selinux/av_permissions.h
29373 --- linux-2.6.33.1/security/selinux/av_permissions.h    1970-01-01 01:00:00.000000000 +0100
29374 +++ linux-2.6.33.1-vs2.3.0.36.30.4/security/selinux/av_permissions.h    2010-02-27 15:49:05.000000000 +0100
29375 @@ -0,0 +1,827 @@
29376 +/* This file is automatically generated.  Do not edit. */
29377 +#ifndef _SELINUX_AV_PERMISSIONS_H_
29378 +#define _SELINUX_AV_PERMISSIONS_H_
29379 +
29380 +#define SECURITY__COMPUTE_AV                      0x00000001UL
29381 +#define SECURITY__COMPUTE_CREATE                  0x00000002UL
29382 +#define SECURITY__COMPUTE_MEMBER                  0x00000004UL
29383 +#define SECURITY__CHECK_CONTEXT                   0x00000008UL
29384 +#define SECURITY__LOAD_POLICY                     0x00000010UL
29385 +#define SECURITY__COMPUTE_RELABEL                 0x00000020UL
29386 +#define SECURITY__COMPUTE_USER                    0x00000040UL
29387 +#define SECURITY__SETENFORCE                      0x00000080UL
29388 +#define SECURITY__SETBOOL                         0x00000100UL
29389 +#define SECURITY__SETSECPARAM                     0x00000200UL
29390 +#define SECURITY__SETCHECKREQPROT                 0x00000400UL
29391 +#define PROCESS__FORK                             0x00000001UL
29392 +#define PROCESS__TRANSITION                       0x00000002UL
29393 +#define PROCESS__SIGCHLD                          0x00000004UL
29394 +#define PROCESS__SIGKILL                          0x00000008UL
29395 +#define PROCESS__SIGSTOP                          0x00000010UL
29396 +#define PROCESS__SIGNULL                          0x00000020UL
29397 +#define PROCESS__SIGNAL                           0x00000040UL
29398 +#define PROCESS__PTRACE                           0x00000080UL
29399 +#define PROCESS__GETSCHED                         0x00000100UL
29400 +#define PROCESS__SETSCHED                         0x00000200UL
29401 +#define PROCESS__GETSESSION                       0x00000400UL
29402 +#define PROCESS__GETPGID                          0x00000800UL
29403 +#define PROCESS__SETPGID                          0x00001000UL
29404 +#define PROCESS__GETCAP                           0x00002000UL
29405 +#define PROCESS__SETCAP                           0x00004000UL
29406 +#define PROCESS__SHARE                            0x00008000UL
29407 +#define PROCESS__GETATTR                          0x00010000UL
29408 +#define PROCESS__SETEXEC                          0x00020000UL
29409 +#define PROCESS__SETFSCREATE                      0x00040000UL
29410 +#define PROCESS__NOATSECURE                       0x00080000UL
29411 +#define PROCESS__SIGINH                           0x00100000UL
29412 +#define PROCESS__SETRLIMIT                        0x00200000UL
29413 +#define PROCESS__RLIMITINH                        0x00400000UL
29414 +#define PROCESS__DYNTRANSITION                    0x00800000UL
29415 +#define PROCESS__SETCURRENT                       0x01000000UL
29416 +#define PROCESS__EXECMEM                          0x02000000UL
29417 +#define PROCESS__EXECSTACK                        0x04000000UL
29418 +#define PROCESS__EXECHEAP                         0x08000000UL
29419 +#define PROCESS__SETKEYCREATE                     0x10000000UL
29420 +#define PROCESS__SETSOCKCREATE                    0x20000000UL
29421 +#define SYSTEM__IPC_INFO                          0x00000001UL
29422 +#define SYSTEM__SYSLOG_READ                       0x00000002UL
29423 +#define SYSTEM__SYSLOG_MOD                        0x00000004UL
29424 +#define SYSTEM__SYSLOG_CONSOLE                    0x00000008UL
29425 +#define SYSTEM__MODULE_REQUEST                    0x00000010UL
29426 +#define CAPABILITY__CHOWN                         0x00000001UL
29427 +#define CAPABILITY__DAC_OVERRIDE                  0x00000002UL
29428 +#define CAPABILITY__DAC_READ_SEARCH               0x00000004UL
29429 +#define CAPABILITY__FOWNER                        0x00000008UL
29430 +#define CAPABILITY__FSETID                        0x00000010UL
29431 +#define CAPABILITY__KILL                          0x00000020UL
29432 +#define CAPABILITY__SETGID                        0x00000040UL
29433 +#define CAPABILITY__SETUID                        0x00000080UL
29434 +#define CAPABILITY__SETPCAP                       0x00000100UL
29435 +#define CAPABILITY__LINUX_IMMUTABLE               0x00000200UL
29436 +#define CAPABILITY__NET_BIND_SERVICE              0x00000400UL
29437 +#define CAPABILITY__NET_BROADCAST                 0x00000800UL
29438 +#define CAPABILITY__NET_ADMIN                     0x00001000UL
29439 +#define CAPABILITY__NET_RAW                       0x00002000UL
29440 +#define CAPABILITY__IPC_LOCK                      0x00004000UL
29441 +#define CAPABILITY__IPC_OWNER                     0x00008000UL
29442 +#define CAPABILITY__SYS_MODULE                    0x00010000UL
29443 +#define CAPABILITY__SYS_RAWIO                     0x00020000UL
29444 +#define CAPABILITY__SYS_CHROOT                    0x00040000UL
29445 +#define CAPABILITY__SYS_PTRACE                    0x00080000UL
29446 +#define CAPABILITY__SYS_PACCT                     0x00100000UL
29447 +#define CAPABILITY__SYS_ADMIN                     0x00200000UL
29448 +#define CAPABILITY__SYS_BOOT                      0x00400000UL
29449 +#define CAPABILITY__SYS_NICE                      0x00800000UL
29450 +#define CAPABILITY__SYS_RESOURCE                  0x01000000UL
29451 +#define CAPABILITY__SYS_TIME                      0x02000000UL
29452 +#define CAPABILITY__SYS_TTY_CONFIG                0x04000000UL
29453 +#define CAPABILITY__MKNOD                         0x08000000UL
29454 +#define CAPABILITY__LEASE                         0x10000000UL
29455 +#define CAPABILITY__AUDIT_WRITE                   0x20000000UL
29456 +#define CAPABILITY__AUDIT_CONTROL                 0x40000000UL
29457 +#define CAPABILITY__SETFCAP                       0x80000000UL
29458 +#define FILESYSTEM__MOUNT                         0x00000001UL
29459 +#define FILESYSTEM__REMOUNT                       0x00000002UL
29460 +#define FILESYSTEM__UNMOUNT                       0x00000004UL
29461 +#define FILESYSTEM__GETATTR                       0x00000008UL
29462 +#define FILESYSTEM__RELABELFROM                   0x00000010UL
29463 +#define FILESYSTEM__RELABELTO                     0x00000020UL
29464 +#define FILESYSTEM__TRANSITION                    0x00000040UL
29465 +#define FILESYSTEM__ASSOCIATE                     0x00000080UL
29466 +#define FILESYSTEM__QUOTAMOD                      0x00000100UL
29467 +#define FILESYSTEM__QUOTAGET                      0x00000200UL
29468 +#define FILE__IOCTL                               0x00000001UL
29469 +#define FILE__READ                                0x00000002UL
29470 +#define FILE__WRITE                               0x00000004UL
29471 +#define FILE__CREATE                              0x00000008UL
29472 +#define FILE__GETATTR                             0x00000010UL
29473 +#define FILE__SETATTR                             0x00000020UL
29474 +#define FILE__LOCK                                0x00000040UL
29475 +#define FILE__RELABELFROM                         0x00000080UL
29476 +#define FILE__RELABELTO                           0x00000100UL
29477 +#define FILE__APPEND                              0x00000200UL
29478 +#define FILE__UNLINK                              0x00000400UL
29479 +#define FILE__LINK                                0x00000800UL
29480 +#define FILE__RENAME                              0x00001000UL
29481 +#define FILE__EXECUTE                             0x00002000UL
29482 +#define FILE__SWAPON                              0x00004000UL
29483 +#define FILE__QUOTAON                             0x00008000UL
29484 +#define FILE__MOUNTON                             0x00010000UL
29485 +#define FILE__EXECUTE_NO_TRANS                    0x00020000UL
29486 +#define FILE__ENTRYPOINT                          0x00040000UL
29487 +#define FILE__EXECMOD                             0x00080000UL
29488 +#define FILE__OPEN                                0x00100000UL
29489 +#define DIR__IOCTL                                0x00000001UL
29490 +#define DIR__READ                                 0x00000002UL
29491 +#define DIR__WRITE                                0x00000004UL
29492 +#define DIR__CREATE                               0x00000008UL
29493 +#define DIR__GETATTR                              0x00000010UL
29494 +#define DIR__SETATTR                              0x00000020UL
29495 +#define DIR__LOCK                                 0x00000040UL
29496 +#define DIR__RELABELFROM                          0x00000080UL
29497 +#define DIR__RELABELTO                            0x00000100UL
29498 +#define DIR__APPEND                               0x00000200UL
29499 +#define DIR__UNLINK                               0x00000400UL
29500 +#define DIR__LINK                                 0x00000800UL
29501 +#define DIR__RENAME                               0x00001000UL
29502 +#define DIR__EXECUTE                              0x00002000UL
29503 +#define DIR__SWAPON                               0x00004000UL
29504 +#define DIR__QUOTAON                              0x00008000UL
29505 +#define DIR__MOUNTON                              0x00010000UL
29506 +#define DIR__ADD_NAME                             0x00020000UL
29507 +#define DIR__REMOVE_NAME                          0x00040000UL
29508 +#define DIR__REPARENT                             0x00080000UL
29509 +#define DIR__SEARCH                               0x00100000UL
29510 +#define DIR__RMDIR                                0x00200000UL
29511 +#define DIR__OPEN                                 0x00400000UL
29512 +#define FD__USE                                   0x00000001UL
29513 +#define LNK_FILE__IOCTL                           0x00000001UL
29514 +#define LNK_FILE__READ                            0x00000002UL
29515 +#define LNK_FILE__WRITE                           0x00000004UL
29516 +#define LNK_FILE__CREATE                          0x00000008UL
29517 +#define LNK_FILE__GETATTR                         0x00000010UL
29518 +#define LNK_FILE__SETATTR                         0x00000020UL
29519 +#define LNK_FILE__LOCK                            0x00000040UL
29520 +#define LNK_FILE__RELABELFROM                     0x00000080UL
29521 +#define LNK_FILE__RELABELTO                       0x00000100UL
29522 +#define LNK_FILE__APPEND                          0x00000200UL
29523 +#define LNK_FILE__UNLINK                          0x00000400UL
29524 +#define LNK_FILE__LINK                            0x00000800UL
29525 +#define LNK_FILE__RENAME                          0x00001000UL
29526 +#define LNK_FILE__EXECUTE                         0x00002000UL
29527 +#define LNK_FILE__SWAPON                          0x00004000UL
29528 +#define LNK_FILE__QUOTAON                         0x00008000UL
29529 +#define LNK_FILE__MOUNTON                         0x00010000UL
29530 +#define CHR_FILE__IOCTL                           0x00000001UL
29531 +#define CHR_FILE__READ                            0x00000002UL
29532 +#define CHR_FILE__WRITE                           0x00000004UL
29533 +#define CHR_FILE__CREATE                          0x00000008UL
29534 +#define CHR_FILE__GETATTR                         0x00000010UL
29535 +#define CHR_FILE__SETATTR                         0x00000020UL
29536 +#define CHR_FILE__LOCK                            0x00000040UL
29537 +#define CHR_FILE__RELABELFROM                     0x00000080UL
29538 +#define CHR_FILE__RELABELTO                       0x00000100UL
29539 +#define CHR_FILE__APPEND                          0x00000200UL
29540 +#define CHR_FILE__UNLINK                          0x00000400UL
29541 +#define CHR_FILE__LINK                            0x00000800UL
29542 +#define CHR_FILE__RENAME                          0x00001000UL
29543 +#define CHR_FILE__EXECUTE                         0x00002000UL
29544 +#define CHR_FILE__SWAPON                          0x00004000UL
29545 +#define CHR_FILE__QUOTAON                         0x00008000UL
29546 +#define CHR_FILE__MOUNTON                         0x00010000UL
29547 +#define CHR_FILE__EXECUTE_NO_TRANS                0x00020000UL
29548 +#define CHR_FILE__ENTRYPOINT                      0x00040000UL
29549 +#define CHR_FILE__EXECMOD                         0x00080000UL
29550 +#define CHR_FILE__OPEN                            0x00100000UL
29551 +#define BLK_FILE__IOCTL                           0x00000001UL
29552 +#define BLK_FILE__READ                            0x00000002UL
29553 +#define BLK_FILE__WRITE                           0x00000004UL
29554 +#define BLK_FILE__CREATE                          0x00000008UL
29555 +#define BLK_FILE__GETATTR                         0x00000010UL
29556 +#define BLK_FILE__SETATTR                         0x00000020UL
29557 +#define BLK_FILE__LOCK                            0x00000040UL
29558 +#define BLK_FILE__RELABELFROM                     0x00000080UL
29559 +#define BLK_FILE__RELABELTO                       0x00000100UL
29560 +#define BLK_FILE__APPEND                          0x00000200UL
29561 +#define BLK_FILE__UNLINK                          0x00000400UL
29562 +#define BLK_FILE__LINK                            0x00000800UL
29563 +#define BLK_FILE__RENAME                          0x00001000UL
29564 +#define BLK_FILE__EXECUTE                         0x00002000UL
29565 +#define BLK_FILE__SWAPON                          0x00004000UL
29566 +#define BLK_FILE__QUOTAON                         0x00008000UL
29567 +#define BLK_FILE__MOUNTON                         0x00010000UL
29568 +#define BLK_FILE__OPEN                            0x00020000UL
29569 +#define SOCK_FILE__IOCTL                          0x00000001UL
29570 +#define SOCK_FILE__READ                           0x00000002UL
29571 +#define SOCK_FILE__WRITE                          0x00000004UL
29572 +#define SOCK_FILE__CREATE                         0x00000008UL
29573 +#define SOCK_FILE__GETATTR                        0x00000010UL
29574 +#define SOCK_FILE__SETATTR                        0x00000020UL
29575 +#define SOCK_FILE__LOCK                           0x00000040UL
29576 +#define SOCK_FILE__RELABELFROM                    0x00000080UL
29577 +#define SOCK_FILE__RELABELTO                      0x00000100UL
29578 +#define SOCK_FILE__APPEND                         0x00000200UL
29579 +#define SOCK_FILE__UNLINK                         0x00000400UL
29580 +#define SOCK_FILE__LINK                           0x00000800UL
29581 +#define SOCK_FILE__RENAME                         0x00001000UL
29582 +#define SOCK_FILE__EXECUTE                        0x00002000UL
29583 +#define SOCK_FILE__SWAPON                         0x00004000UL
29584 +#define SOCK_FILE__QUOTAON                        0x00008000UL
29585 +#define SOCK_FILE__MOUNTON                        0x00010000UL
29586 +#define SOCK_FILE__OPEN                           0x00020000UL
29587 +#define FIFO_FILE__IOCTL                          0x00000001UL
29588 +#define FIFO_FILE__READ                           0x00000002UL
29589 +#define FIFO_FILE__WRITE                          0x00000004UL
29590 +#define FIFO_FILE__CREATE                         0x00000008UL
29591 +#define FIFO_FILE__GETATTR                        0x00000010UL
29592 +#define FIFO_FILE__SETATTR                        0x00000020UL
29593 +#define FIFO_FILE__LOCK                           0x00000040UL
29594 +#define FIFO_FILE__RELABELFROM                    0x00000080UL
29595 +#define FIFO_FILE__RELABELTO                      0x00000100UL
29596 +#define FIFO_FILE__APPEND                         0x00000200UL
29597 +#define FIFO_FILE__UNLINK                         0x00000400UL
29598 +#define FIFO_FILE__LINK                           0x00000800UL
29599 +#define FIFO_FILE__RENAME                         0x00001000UL
29600 +#define FIFO_FILE__EXECUTE                        0x00002000UL
29601 +#define FIFO_FILE__SWAPON                         0x00004000UL
29602 +#define FIFO_FILE__QUOTAON                        0x00008000UL
29603 +#define FIFO_FILE__MOUNTON                        0x00010000UL
29604 +#define FIFO_FILE__OPEN                           0x00020000UL
29605 +#define SOCKET__IOCTL                             0x00000001UL
29606 +#define SOCKET__READ                              0x00000002UL
29607 +#define SOCKET__WRITE                             0x00000004UL
29608 +#define SOCKET__CREATE                            0x00000008UL
29609 +#define SOCKET__GETATTR                           0x00000010UL
29610 +#define SOCKET__SETATTR                           0x00000020UL
29611 +#define SOCKET__LOCK                              0x00000040UL
29612 +#define SOCKET__RELABELFROM                       0x00000080UL
29613 +#define SOCKET__RELABELTO                         0x00000100UL
29614 +#define SOCKET__APPEND                            0x00000200UL
29615 +#define SOCKET__BIND                              0x00000400UL
29616 +#define SOCKET__CONNECT                           0x00000800UL
29617 +#define SOCKET__LISTEN                            0x00001000UL
29618 +#define SOCKET__ACCEPT                            0x00002000UL
29619 +#define SOCKET__GETOPT                            0x00004000UL
29620 +#define SOCKET__SETOPT                            0x00008000UL
29621 +#define SOCKET__SHUTDOWN                          0x00010000UL
29622 +#define SOCKET__RECVFROM                          0x00020000UL
29623 +#define SOCKET__SENDTO                            0x00040000UL
29624 +#define SOCKET__RECV_MSG                          0x00080000UL
29625 +#define SOCKET__SEND_MSG                          0x00100000UL
29626 +#define SOCKET__NAME_BIND                         0x00200000UL
29627 +#define TCP_SOCKET__IOCTL                         0x00000001UL
29628 +#define TCP_SOCKET__READ                          0x00000002UL
29629 +#define TCP_SOCKET__WRITE                         0x00000004UL
29630 +#define TCP_SOCKET__CREATE                        0x00000008UL
29631 +#define TCP_SOCKET__GETATTR                       0x00000010UL
29632 +#define TCP_SOCKET__SETATTR                       0x00000020UL
29633 +#define TCP_SOCKET__LOCK                          0x00000040UL
29634 +#define TCP_SOCKET__RELABELFROM                   0x00000080UL
29635 +#define TCP_SOCKET__RELABELTO                     0x00000100UL
29636 +#define TCP_SOCKET__APPEND                        0x00000200UL
29637 +#define TCP_SOCKET__BIND                          0x00000400UL
29638 +#define TCP_SOCKET__CONNECT                       0x00000800UL
29639 +#define TCP_SOCKET__LISTEN                        0x00001000UL
29640 +#define TCP_SOCKET__ACCEPT                        0x00002000UL
29641 +#define TCP_SOCKET__GETOPT                        0x00004000UL
29642 +#define TCP_SOCKET__SETOPT                        0x00008000UL
29643 +#define TCP_SOCKET__SHUTDOWN                      0x00010000UL
29644 +#define TCP_SOCKET__RECVFROM                      0x00020000UL
29645 +#define TCP_SOCKET__SENDTO                        0x00040000UL
29646 +#define TCP_SOCKET__RECV_MSG                      0x00080000UL
29647 +#define TCP_SOCKET__SEND_MSG                      0x00100000UL
29648 +#define TCP_SOCKET__NAME_BIND                     0x00200000UL
29649 +#define TCP_SOCKET__CONNECTTO                     0x00400000UL
29650 +#define TCP_SOCKET__NEWCONN                       0x00800000UL
29651 +#define TCP_SOCKET__ACCEPTFROM                    0x01000000UL
29652 +#define TCP_SOCKET__NODE_BIND                     0x02000000UL
29653 +#define TCP_SOCKET__NAME_CONNECT                  0x04000000UL
29654 +#define UDP_SOCKET__IOCTL                         0x00000001UL
29655 +#define UDP_SOCKET__READ                          0x00000002UL
29656 +#define UDP_SOCKET__WRITE                         0x00000004UL
29657 +#define UDP_SOCKET__CREATE                        0x00000008UL
29658 +#define UDP_SOCKET__GETATTR                       0x00000010UL
29659 +#define UDP_SOCKET__SETATTR                       0x00000020UL
29660 +#define UDP_SOCKET__LOCK                          0x00000040UL
29661 +#define UDP_SOCKET__RELABELFROM                   0x00000080UL
29662 +#define UDP_SOCKET__RELABELTO                     0x00000100UL
29663 +#define UDP_SOCKET__APPEND                        0x00000200UL
29664 +#define UDP_SOCKET__BIND                          0x00000400UL
29665 +#define UDP_SOCKET__CONNECT                       0x00000800UL
29666 +#define UDP_SOCKET__LISTEN                        0x00001000UL
29667 +#define UDP_SOCKET__ACCEPT                        0x00002000UL
29668 +#define UDP_SOCKET__GETOPT                        0x00004000UL
29669 +#define UDP_SOCKET__SETOPT                        0x00008000UL
29670 +#define UDP_SOCKET__SHUTDOWN                      0x00010000UL
29671 +#define UDP_SOCKET__RECVFROM                      0x00020000UL
29672 +#define UDP_SOCKET__SENDTO                        0x00040000UL
29673 +#define UDP_SOCKET__RECV_MSG                      0x00080000UL
29674 +#define UDP_SOCKET__SEND_MSG                      0x00100000UL
29675 +#define UDP_SOCKET__NAME_BIND                     0x00200000UL
29676 +#define UDP_SOCKET__NODE_BIND                     0x00400000UL
29677 +#define RAWIP_SOCKET__IOCTL                       0x00000001UL
29678 +#define RAWIP_SOCKET__READ                        0x00000002UL
29679 +#define RAWIP_SOCKET__WRITE                       0x00000004UL
29680 +#define RAWIP_SOCKET__CREATE                      0x00000008UL
29681 +#define RAWIP_SOCKET__GETATTR                     0x00000010UL
29682 +#define RAWIP_SOCKET__SETATTR                     0x00000020UL
29683 +#define RAWIP_SOCKET__LOCK                        0x00000040UL
29684 +#define RAWIP_SOCKET__RELABELFROM                 0x00000080UL
29685 +#define RAWIP_SOCKET__RELABELTO                   0x00000100UL
29686 +#define RAWIP_SOCKET__APPEND                      0x00000200UL
29687 +#define RAWIP_SOCKET__BIND                        0x00000400UL
29688 +#define RAWIP_SOCKET__CONNECT                     0x00000800UL
29689 +#define RAWIP_SOCKET__LISTEN                      0x00001000UL
29690 +#define RAWIP_SOCKET__ACCEPT                      0x00002000UL
29691 +#define RAWIP_SOCKET__GETOPT                      0x00004000UL
29692 +#define RAWIP_SOCKET__SETOPT                      0x00008000UL
29693 +#define RAWIP_SOCKET__SHUTDOWN                    0x00010000UL
29694 +#define RAWIP_SOCKET__RECVFROM                    0x00020000UL
29695 +#define RAWIP_SOCKET__SENDTO                      0x00040000UL
29696 +#define RAWIP_SOCKET__RECV_MSG                    0x00080000UL
29697 +#define RAWIP_SOCKET__SEND_MSG                    0x00100000UL
29698 +#define RAWIP_SOCKET__NAME_BIND                   0x00200000UL
29699 +#define RAWIP_SOCKET__NODE_BIND                   0x00400000UL
29700 +#define NODE__TCP_RECV                            0x00000001UL
29701 +#define NODE__TCP_SEND                            0x00000002UL
29702 +#define NODE__UDP_RECV                            0x00000004UL
29703 +#define NODE__UDP_SEND                            0x00000008UL
29704 +#define NODE__RAWIP_RECV                          0x00000010UL
29705 +#define NODE__RAWIP_SEND                          0x00000020UL
29706 +#define NODE__ENFORCE_DEST                        0x00000040UL
29707 +#define NODE__DCCP_RECV                           0x00000080UL
29708 +#define NODE__DCCP_SEND                           0x00000100UL
29709 +#define NODE__RECVFROM                            0x00000200UL
29710 +#define NODE__SENDTO                              0x00000400UL
29711 +#define NETIF__TCP_RECV                           0x00000001UL
29712 +#define NETIF__TCP_SEND                           0x00000002UL
29713 +#define NETIF__UDP_RECV                           0x00000004UL
29714 +#define NETIF__UDP_SEND                           0x00000008UL
29715 +#define NETIF__RAWIP_RECV                         0x00000010UL
29716 +#define NETIF__RAWIP_SEND                         0x00000020UL
29717 +#define NETIF__DCCP_RECV                          0x00000040UL
29718 +#define NETIF__DCCP_SEND                          0x00000080UL
29719 +#define NETIF__INGRESS                            0x00000100UL
29720 +#define NETIF__EGRESS                             0x00000200UL
29721 +#define NETLINK_SOCKET__IOCTL                     0x00000001UL
29722 +#define NETLINK_SOCKET__READ                      0x00000002UL
29723 +#define NETLINK_SOCKET__WRITE                     0x00000004UL
29724 +#define NETLINK_SOCKET__CREATE                    0x00000008UL
29725 +#define NETLINK_SOCKET__GETATTR                   0x00000010UL
29726 +#define NETLINK_SOCKET__SETATTR                   0x00000020UL
29727 +#define NETLINK_SOCKET__LOCK                      0x00000040UL
29728 +#define NETLINK_SOCKET__RELABELFROM               0x00000080UL
29729 +#define NETLINK_SOCKET__RELABELTO                 0x00000100UL
29730 +#define NETLINK_SOCKET__APPEND                    0x00000200UL
29731 +#define NETLINK_SOCKET__BIND                      0x00000400UL
29732 +#define NETLINK_SOCKET__CONNECT                   0x00000800UL
29733 +#define NETLINK_SOCKET__LISTEN                    0x00001000UL
29734 +#define NETLINK_SOCKET__ACCEPT                    0x00002000UL
29735 +#define NETLINK_SOCKET__GETOPT                    0x00004000UL
29736 +#define NETLINK_SOCKET__SETOPT                    0x00008000UL
29737 +#define NETLINK_SOCKET__SHUTDOWN                  0x00010000UL
29738 +#define NETLINK_SOCKET__RECVFROM                  0x00020000UL
29739 +#define NETLINK_SOCKET__SENDTO                    0x00040000UL
29740 +#define NETLINK_SOCKET__RECV_MSG                  0x00080000UL
29741 +#define NETLINK_SOCKET__SEND_MSG                  0x00100000UL
29742 +#define NETLINK_SOCKET__NAME_BIND                 0x00200000UL
29743 +#define PACKET_SOCKET__IOCTL                      0x00000001UL
29744 +#define PACKET_SOCKET__READ                       0x00000002UL
29745 +#define PACKET_SOCKET__WRITE                      0x00000004UL
29746 +#define PACKET_SOCKET__CREATE                     0x00000008UL
29747 +#define PACKET_SOCKET__GETATTR                    0x00000010UL
29748 +#define PACKET_SOCKET__SETATTR                    0x00000020UL
29749 +#define PACKET_SOCKET__LOCK                       0x00000040UL
29750 +#define PACKET_SOCKET__RELABELFROM                0x00000080UL
29751 +#define PACKET_SOCKET__RELABELTO                  0x00000100UL
29752 +#define PACKET_SOCKET__APPEND                     0x00000200UL
29753 +#define PACKET_SOCKET__BIND                       0x00000400UL
29754 +#define PACKET_SOCKET__CONNECT                    0x00000800UL
29755 +#define PACKET_SOCKET__LISTEN                     0x00001000UL
29756 +#define PACKET_SOCKET__ACCEPT                     0x00002000UL
29757 +#define PACKET_SOCKET__GETOPT                     0x00004000UL
29758 +#define PACKET_SOCKET__SETOPT                     0x00008000UL
29759 +#define PACKET_SOCKET__SHUTDOWN                   0x00010000UL
29760 +#define PACKET_SOCKET__RECVFROM                   0x00020000UL
29761 +#define PACKET_SOCKET__SENDTO                     0x00040000UL
29762 +#define PACKET_SOCKET__RECV_MSG                   0x00080000UL
29763 +#define PACKET_SOCKET__SEND_MSG                   0x00100000UL
29764 +#define PACKET_SOCKET__NAME_BIND                  0x00200000UL
29765 +#define KEY_SOCKET__IOCTL                         0x00000001UL
29766 +#define KEY_SOCKET__READ                          0x00000002UL
29767 +#define KEY_SOCKET__WRITE                         0x00000004UL
29768 +#define KEY_SOCKET__CREATE                        0x00000008UL
29769 +#define KEY_SOCKET__GETATTR                       0x00000010UL
29770 +#define KEY_SOCKET__SETATTR                       0x00000020UL
29771 +#define KEY_SOCKET__LOCK                          0x00000040UL
29772 +#define KEY_SOCKET__RELABELFROM                   0x00000080UL
29773 +#define KEY_SOCKET__RELABELTO                     0x00000100UL
29774 +#define KEY_SOCKET__APPEND                        0x00000200UL
29775 +#define KEY_SOCKET__BIND                          0x00000400UL
29776 +#define KEY_SOCKET__CONNECT                       0x00000800UL
29777 +#define KEY_SOCKET__LISTEN                        0x00001000UL
29778 +#define KEY_SOCKET__ACCEPT                        0x00002000UL
29779 +#define KEY_SOCKET__GETOPT                        0x00004000UL
29780 +#define KEY_SOCKET__SETOPT                        0x00008000UL
29781 +#define KEY_SOCKET__SHUTDOWN                      0x00010000UL
29782 +#define KEY_SOCKET__RECVFROM                      0x00020000UL
29783 +#define KEY_SOCKET__SENDTO                        0x00040000UL
29784 +#define KEY_SOCKET__RECV_MSG                      0x00080000UL
29785 +#define KEY_SOCKET__SEND_MSG                      0x00100000UL
29786 +#define KEY_SOCKET__NAME_BIND                     0x00200000UL
29787 +#define UNIX_STREAM_SOCKET__IOCTL                 0x00000001UL
29788 +#define UNIX_STREAM_SOCKET__READ                  0x00000002UL
29789 +#define UNIX_STREAM_SOCKET__WRITE                 0x00000004UL
29790 +#define UNIX_STREAM_SOCKET__CREATE                0x00000008UL
29791 +#define UNIX_STREAM_SOCKET__GETATTR               0x00000010UL
29792 +#define UNIX_STREAM_SOCKET__SETATTR               0x00000020UL
29793 +#define UNIX_STREAM_SOCKET__LOCK                  0x00000040UL
29794 +#define UNIX_STREAM_SOCKET__RELABELFROM           0x00000080UL
29795 +#define UNIX_STREAM_SOCKET__RELABELTO             0x00000100UL
29796 +#define UNIX_STREAM_SOCKET__APPEND                0x00000200UL
29797 +#define UNIX_STREAM_SOCKET__BIND                  0x00000400UL
29798 +#define UNIX_STREAM_SOCKET__CONNECT               0x00000800UL
29799 +#define UNIX_STREAM_SOCKET__LISTEN                0x00001000UL
29800 +#define UNIX_STREAM_SOCKET__ACCEPT                0x00002000UL
29801 +#define UNIX_STREAM_SOCKET__GETOPT                0x00004000UL
29802 +#define UNIX_STREAM_SOCKET__SETOPT                0x00008000UL
29803 +#define UNIX_STREAM_SOCKET__SHUTDOWN              0x00010000UL
29804 +#define UNIX_STREAM_SOCKET__RECVFROM              0x00020000UL
29805 +#define UNIX_STREAM_SOCKET__SENDTO                0x00040000UL
29806 +#define UNIX_STREAM_SOCKET__RECV_MSG              0x00080000UL
29807 +#define UNIX_STREAM_SOCKET__SEND_MSG              0x00100000UL
29808 +#define UNIX_STREAM_SOCKET__NAME_BIND             0x00200000UL
29809 +#define UNIX_STREAM_SOCKET__CONNECTTO             0x00400000UL
29810 +#define UNIX_STREAM_SOCKET__NEWCONN               0x00800000UL
29811 +#define UNIX_STREAM_SOCKET__ACCEPTFROM            0x01000000UL
29812 +#define UNIX_DGRAM_SOCKET__IOCTL                  0x00000001UL
29813 +#define UNIX_DGRAM_SOCKET__READ                   0x00000002UL
29814 +#define UNIX_DGRAM_SOCKET__WRITE                  0x00000004UL
29815 +#define UNIX_DGRAM_SOCKET__CREATE                 0x00000008UL
29816 +#define UNIX_DGRAM_SOCKET__GETATTR                0x00000010UL
29817 +#define UNIX_DGRAM_SOCKET__SETATTR                0x00000020UL
29818 +#define UNIX_DGRAM_SOCKET__LOCK                   0x00000040UL
29819 +#define UNIX_DGRAM_SOCKET__RELABELFROM            0x00000080UL
29820 +#define UNIX_DGRAM_SOCKET__RELABELTO              0x00000100UL
29821 +#define UNIX_DGRAM_SOCKET__APPEND                 0x00000200UL
29822 +#define UNIX_DGRAM_SOCKET__BIND                   0x00000400UL
29823 +#define UNIX_DGRAM_SOCKET__CONNECT                0x00000800UL
29824 +#define UNIX_DGRAM_SOCKET__LISTEN                 0x00001000UL
29825 +#define UNIX_DGRAM_SOCKET__ACCEPT                 0x00002000UL
29826 +#define UNIX_DGRAM_SOCKET__GETOPT                 0x00004000UL
29827 +#define UNIX_DGRAM_SOCKET__SETOPT                 0x00008000UL
29828 +#define UNIX_DGRAM_SOCKET__SHUTDOWN               0x00010000UL
29829 +#define UNIX_DGRAM_SOCKET__RECVFROM               0x00020000UL
29830 +#define UNIX_DGRAM_SOCKET__SENDTO                 0x00040000UL
29831 +#define UNIX_DGRAM_SOCKET__RECV_MSG               0x00080000UL
29832 +#define UNIX_DGRAM_SOCKET__SEND_MSG               0x00100000UL
29833 +#define UNIX_DGRAM_SOCKET__NAME_BIND              0x00200000UL
29834 +#define SEM__CREATE                               0x00000001UL
29835 +#define SEM__DESTROY                              0x00000002UL
29836 +#define SEM__GETATTR                              0x00000004UL
29837 +#define SEM__SETATTR                              0x00000008UL
29838 +#define SEM__READ                                 0x00000010UL
29839 +#define SEM__WRITE                                0x00000020UL
29840 +#define SEM__ASSOCIATE                            0x00000040UL
29841 +#define SEM__UNIX_READ                            0x00000080UL
29842 +#define SEM__UNIX_WRITE                           0x00000100UL
29843 +#define MSG__SEND                                 0x00000001UL
29844 +#define MSG__RECEIVE                              0x00000002UL
29845 +#define MSGQ__CREATE                              0x00000001UL
29846 +#define MSGQ__DESTROY                             0x00000002UL
29847 +#define MSGQ__GETATTR                             0x00000004UL
29848 +#define MSGQ__SETATTR                             0x00000008UL
29849 +#define MSGQ__READ                                0x00000010UL
29850 +#define MSGQ__WRITE                               0x00000020UL
29851 +#define MSGQ__ASSOCIATE                           0x00000040UL
29852 +#define MSGQ__UNIX_READ                           0x00000080UL
29853 +#define MSGQ__UNIX_WRITE                          0x00000100UL
29854 +#define MSGQ__ENQUEUE                             0x00000200UL
29855 +#define SHM__CREATE                               0x00000001UL
29856 +#define SHM__DESTROY                              0x00000002UL
29857 +#define SHM__GETATTR                              0x00000004UL
29858 +#define SHM__SETATTR                              0x00000008UL
29859 +#define SHM__READ                                 0x00000010UL
29860 +#define SHM__WRITE                                0x00000020UL
29861 +#define SHM__ASSOCIATE                            0x00000040UL
29862 +#define SHM__UNIX_READ                            0x00000080UL
29863 +#define SHM__UNIX_WRITE                           0x00000100UL
29864 +#define SHM__LOCK                                 0x00000200UL
29865 +#define IPC__CREATE                               0x00000001UL
29866 +#define IPC__DESTROY                              0x00000002UL
29867 +#define IPC__GETATTR                              0x00000004UL
29868 +#define IPC__SETATTR                              0x00000008UL
29869 +#define IPC__READ                                 0x00000010UL
29870 +#define IPC__WRITE                                0x00000020UL
29871 +#define IPC__ASSOCIATE                            0x00000040UL
29872 +#define IPC__UNIX_READ                            0x00000080UL
29873 +#define IPC__UNIX_WRITE                           0x00000100UL
29874 +#define NETLINK_ROUTE_SOCKET__IOCTL               0x00000001UL
29875 +#define NETLINK_ROUTE_SOCKET__READ                0x00000002UL
29876 +#define NETLINK_ROUTE_SOCKET__WRITE               0x00000004UL
29877 +#define NETLINK_ROUTE_SOCKET__CREATE              0x00000008UL
29878 +#define NETLINK_ROUTE_SOCKET__GETATTR             0x00000010UL
29879 +#define NETLINK_ROUTE_SOCKET__SETATTR             0x00000020UL
29880 +#define NETLINK_ROUTE_SOCKET__LOCK                0x00000040UL
29881 +#define NETLINK_ROUTE_SOCKET__RELABELFROM         0x00000080UL
29882 +#define NETLINK_ROUTE_SOCKET__RELABELTO           0x00000100UL
29883 +#define NETLINK_ROUTE_SOCKET__APPEND              0x00000200UL
29884 +#define NETLINK_ROUTE_SOCKET__BIND                0x00000400UL
29885 +#define NETLINK_ROUTE_SOCKET__CONNECT             0x00000800UL
29886 +#define NETLINK_ROUTE_SOCKET__LISTEN              0x00001000UL
29887 +#define NETLINK_ROUTE_SOCKET__ACCEPT              0x00002000UL
29888 +#define NETLINK_ROUTE_SOCKET__GETOPT              0x00004000UL
29889 +#define NETLINK_ROUTE_SOCKET__SETOPT              0x00008000UL
29890 +#define NETLINK_ROUTE_SOCKET__SHUTDOWN            0x00010000UL
29891 +#define NETLINK_ROUTE_SOCKET__RECVFROM            0x00020000UL
29892 +#define NETLINK_ROUTE_SOCKET__SENDTO              0x00040000UL
29893 +#define NETLINK_ROUTE_SOCKET__RECV_MSG            0x00080000UL
29894 +#define NETLINK_ROUTE_SOCKET__SEND_MSG            0x00100000UL
29895 +#define NETLINK_ROUTE_SOCKET__NAME_BIND           0x00200000UL
29896 +#define NETLINK_ROUTE_SOCKET__NLMSG_READ          0x00400000UL
29897 +#define NETLINK_ROUTE_SOCKET__NLMSG_WRITE         0x00800000UL
29898 +#define NETLINK_FIREWALL_SOCKET__IOCTL            0x00000001UL
29899 +#define NETLINK_FIREWALL_SOCKET__READ             0x00000002UL
29900 +#define NETLINK_FIREWALL_SOCKET__WRITE            0x00000004UL
29901 +#define NETLINK_FIREWALL_SOCKET__CREATE           0x00000008UL
29902 +#define NETLINK_FIREWALL_SOCKET__GETATTR          0x00000010UL
29903 +#define NETLINK_FIREWALL_SOCKET__SETATTR          0x00000020UL
29904 +#define NETLINK_FIREWALL_SOCKET__LOCK             0x00000040UL
29905 +#define NETLINK_FIREWALL_SOCKET__RELABELFROM      0x00000080UL
29906 +#define NETLINK_FIREWALL_SOCKET__RELABELTO        0x00000100UL
29907 +#define NETLINK_FIREWALL_SOCKET__APPEND           0x00000200UL
29908 +#define NETLINK_FIREWALL_SOCKET__BIND             0x00000400UL
29909 +#define NETLINK_FIREWALL_SOCKET__CONNECT          0x00000800UL
29910 +#define NETLINK_FIREWALL_SOCKET__LISTEN           0x00001000UL
29911 +#define NETLINK_FIREWALL_SOCKET__ACCEPT           0x00002000UL
29912 +#define NETLINK_FIREWALL_SOCKET__GETOPT           0x00004000UL
29913 +#define NETLINK_FIREWALL_SOCKET__SETOPT           0x00008000UL
29914 +#define NETLINK_FIREWALL_SOCKET__SHUTDOWN         0x00010000UL
29915 +#define NETLINK_FIREWALL_SOCKET__RECVFROM         0x00020000UL
29916 +#define NETLINK_FIREWALL_SOCKET__SENDTO           0x00040000UL
29917 +#define NETLINK_FIREWALL_SOCKET__RECV_MSG         0x00080000UL
29918 +#define NETLINK_FIREWALL_SOCKET__SEND_MSG         0x00100000UL
29919 +#define NETLINK_FIREWALL_SOCKET__NAME_BIND        0x00200000UL
29920 +#define NETLINK_FIREWALL_SOCKET__NLMSG_READ       0x00400000UL
29921 +#define NETLINK_FIREWALL_SOCKET__NLMSG_WRITE      0x00800000UL
29922 +#define NETLINK_TCPDIAG_SOCKET__IOCTL             0x00000001UL
29923 +#define NETLINK_TCPDIAG_SOCKET__READ              0x00000002UL
29924 +#define NETLINK_TCPDIAG_SOCKET__WRITE             0x00000004UL
29925 +#define NETLINK_TCPDIAG_SOCKET__CREATE            0x00000008UL
29926 +#define NETLINK_TCPDIAG_SOCKET__GETATTR           0x00000010UL
29927 +#define NETLINK_TCPDIAG_SOCKET__SETATTR           0x00000020UL
29928 +#define NETLINK_TCPDIAG_SOCKET__LOCK              0x00000040UL
29929 +#define NETLINK_TCPDIAG_SOCKET__RELABELFROM       0x00000080UL
29930 +#define NETLINK_TCPDIAG_SOCKET__RELABELTO         0x00000100UL
29931 +#define NETLINK_TCPDIAG_SOCKET__APPEND            0x00000200UL
29932 +#define NETLINK_TCPDIAG_SOCKET__BIND              0x00000400UL
29933 +#define NETLINK_TCPDIAG_SOCKET__CONNECT           0x00000800UL
29934 +#define NETLINK_TCPDIAG_SOCKET__LISTEN            0x00001000UL
29935 +#define NETLINK_TCPDIAG_SOCKET__ACCEPT            0x00002000UL
29936 +#define NETLINK_TCPDIAG_SOCKET__GETOPT            0x00004000UL
29937 +#define NETLINK_TCPDIAG_SOCKET__SETOPT            0x00008000UL
29938 +#define NETLINK_TCPDIAG_SOCKET__SHUTDOWN          0x00010000UL
29939 +#define NETLINK_TCPDIAG_SOCKET__RECVFROM          0x00020000UL
29940 +#define NETLINK_TCPDIAG_SOCKET__SENDTO            0x00040000UL
29941 +#define NETLINK_TCPDIAG_SOCKET__RECV_MSG          0x00080000UL
29942 +#define NETLINK_TCPDIAG_SOCKET__SEND_MSG          0x00100000UL
29943 +#define NETLINK_TCPDIAG_SOCKET__NAME_BIND         0x00200000UL
29944 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_READ        0x00400000UL
29945 +#define NETLINK_TCPDIAG_SOCKET__NLMSG_WRITE       0x00800000UL
29946 +#define NETLINK_NFLOG_SOCKET__IOCTL               0x00000001UL
29947 +#define NETLINK_NFLOG_SOCKET__READ                0x00000002UL
29948 +#define NETLINK_NFLOG_SOCKET__WRITE               0x00000004UL
29949 +#define NETLINK_NFLOG_SOCKET__CREATE              0x00000008UL
29950 +#define NETLINK_NFLOG_SOCKET__GETATTR             0x00000010UL
29951 +#define NETLINK_NFLOG_SOCKET__SETATTR             0x00000020UL
29952 +#define NETLINK_NFLOG_SOCKET__LOCK                0x00000040UL
29953 +#define NETLINK_NFLOG_SOCKET__RELABELFROM         0x00000080UL
29954 +#define NETLINK_NFLOG_SOCKET__RELABELTO           0x00000100UL
29955 +#define NETLINK_NFLOG_SOCKET__APPEND              0x00000200UL
29956 +#define NETLINK_NFLOG_SOCKET__BIND                0x00000400UL
29957 +#define NETLINK_NFLOG_SOCKET__CONNECT             0x00000800UL
29958 +#define NETLINK_NFLOG_SOCKET__LISTEN              0x00001000UL
29959 +#define NETLINK_NFLOG_SOCKET__ACCEPT              0x00002000UL
29960 +#define NETLINK_NFLOG_SOCKET__GETOPT              0x00004000UL
29961 +#define NETLINK_NFLOG_SOCKET__SETOPT              0x00008000UL
29962 +#define NETLINK_NFLOG_SOCKET__SHUTDOWN            0x00010000UL
29963 +#define NETLINK_NFLOG_SOCKET__RECVFROM            0x00020000UL
29964 +#define NETLINK_NFLOG_SOCKET__SENDTO              0x00040000UL
29965 +#define NETLINK_NFLOG_SOCKET__RECV_MSG            0x00080000UL
29966 +#define NETLINK_NFLOG_SOCKET__SEND_MSG            0x00100000UL
29967 +#define NETLINK_NFLOG_SOCKET__NAME_BIND           0x00200000UL
29968 +#define NETLINK_XFRM_SOCKET__IOCTL                0x00000001UL
29969 +#define NETLINK_XFRM_SOCKET__READ                 0x00000002UL
29970 +#define NETLINK_XFRM_SOCKET__WRITE                0x00000004UL
29971 +#define NETLINK_XFRM_SOCKET__CREATE               0x00000008UL
29972 +#define NETLINK_XFRM_SOCKET__GETATTR              0x00000010UL
29973 +#define NETLINK_XFRM_SOCKET__SETATTR              0x00000020UL
29974 +#define NETLINK_XFRM_SOCKET__LOCK                 0x00000040UL
29975 +#define NETLINK_XFRM_SOCKET__RELABELFROM          0x00000080UL
29976 +#define NETLINK_XFRM_SOCKET__RELABELTO            0x00000100UL
29977 +#define NETLINK_XFRM_SOCKET__APPEND               0x00000200UL
29978 +#define NETLINK_XFRM_SOCKET__BIND                 0x00000400UL
29979 +#define NETLINK_XFRM_SOCKET__CONNECT              0x00000800UL
29980 +#define NETLINK_XFRM_SOCKET__LISTEN               0x00001000UL
29981 +#define NETLINK_XFRM_SOCKET__ACCEPT               0x00002000UL
29982 +#define NETLINK_XFRM_SOCKET__GETOPT               0x00004000UL
29983 +#define NETLINK_XFRM_SOCKET__SETOPT               0x00008000UL
29984 +#define NETLINK_XFRM_SOCKET__SHUTDOWN             0x00010000UL
29985 +#define NETLINK_XFRM_SOCKET__RECVFROM             0x00020000UL
29986 +#define NETLINK_XFRM_SOCKET__SENDTO               0x00040000UL
29987 +#define NETLINK_XFRM_SOCKET__RECV_MSG             0x00080000UL
29988 +#define NETLINK_XFRM_SOCKET__SEND_MSG             0x00100000UL
29989 +#define NETLINK_XFRM_SOCKET__NAME_BIND            0x00200000UL
29990 +#define NETLINK_XFRM_SOCKET__NLMSG_READ           0x00400000UL
29991 +#define NETLINK_XFRM_SOCKET__NLMSG_WRITE          0x00800000UL
29992 +#define NETLINK_SELINUX_SOCKET__IOCTL             0x00000001UL
29993 +#define NETLINK_SELINUX_SOCKET__READ              0x00000002UL
29994 +#define NETLINK_SELINUX_SOCKET__WRITE             0x00000004UL
29995 +#define NETLINK_SELINUX_SOCKET__CREATE            0x00000008UL
29996 +#define NETLINK_SELINUX_SOCKET__GETATTR           0x00000010UL
29997 +#define NETLINK_SELINUX_SOCKET__SETATTR           0x00000020UL
29998 +#define NETLINK_SELINUX_SOCKET__LOCK              0x00000040UL
29999 +#define NETLINK_SELINUX_SOCKET__RELABELFROM       0x00000080UL
30000 +#define NETLINK_SELINUX_SOCKET__RELABELTO         0x00000100UL
30001 +#define NETLINK_SELINUX_SOCKET__APPEND            0x00000200UL
30002 +#define NETLINK_SELINUX_SOCKET__BIND              0x00000400UL
30003 +#define NETLINK_SELINUX_SOCKET__CONNECT           0x00000800UL
30004 +#define NETLINK_SELINUX_SOCKET__LISTEN            0x00001000UL
30005 +#define NETLINK_SELINUX_SOCKET__ACCEPT            0x00002000UL
30006 +#define NETLINK_SELINUX_SOCKET__GETOPT            0x00004000UL
30007 +#define NETLINK_SELINUX_SOCKET__SETOPT            0x00008000UL
30008 +#define NETLINK_SELINUX_SOCKET__SHUTDOWN          0x00010000UL
30009 +#define NETLINK_SELINUX_SOCKET__RECVFROM          0x00020000UL
30010 +#define NETLINK_SELINUX_SOCKET__SENDTO            0x00040000UL
30011 +#define NETLINK_SELINUX_SOCKET__RECV_MSG          0x00080000UL
30012 +#define NETLINK_SELINUX_SOCKET__SEND_MSG          0x00100000UL
30013 +#define NETLINK_SELINUX_SOCKET__NAME_BIND         0x00200000UL
30014 +#define NETLINK_AUDIT_SOCKET__IOCTL               0x00000001UL
30015 +#define NETLINK_AUDIT_SOCKET__READ                0x00000002UL
30016 +#define NETLINK_AUDIT_SOCKET__WRITE               0x00000004UL
30017 +#define NETLINK_AUDIT_SOCKET__CREATE              0x00000008UL
30018 +#define NETLINK_AUDIT_SOCKET__GETATTR             0x00000010UL
30019 +#define NETLINK_AUDIT_SOCKET__SETATTR             0x00000020UL
30020 +#define NETLINK_AUDIT_SOCKET__LOCK                0x00000040UL
30021 +#define NETLINK_AUDIT_SOCKET__RELABELFROM         0x00000080UL
30022 +#define NETLINK_AUDIT_SOCKET__RELABELTO           0x00000100UL
30023 +#define NETLINK_AUDIT_SOCKET__APPEND              0x00000200UL
30024 +#define NETLINK_AUDIT_SOCKET__BIND                0x00000400UL
30025 +#define NETLINK_AUDIT_SOCKET__CONNECT             0x00000800UL
30026 +#define NETLINK_AUDIT_SOCKET__LISTEN              0x00001000UL
30027 +#define NETLINK_AUDIT_SOCKET__ACCEPT              0x00002000UL
30028 +#define NETLINK_AUDIT_SOCKET__GETOPT              0x00004000UL
30029 +#define NETLINK_AUDIT_SOCKET__SETOPT              0x00008000UL
30030 +#define NETLINK_AUDIT_SOCKET__SHUTDOWN            0x00010000UL
30031 +#define NETLINK_AUDIT_SOCKET__RECVFROM            0x00020000UL
30032 +#define NETLINK_AUDIT_SOCKET__SENDTO              0x00040000UL
30033 +#define NETLINK_AUDIT_SOCKET__RECV_MSG            0x00080000UL
30034 +#define NETLINK_AUDIT_SOCKET__SEND_MSG            0x00100000UL
30035 +#define NETLINK_AUDIT_SOCKET__NAME_BIND           0x00200000UL
30036 +#define NETLINK_AUDIT_SOCKET__NLMSG_READ          0x00400000UL
30037 +#define NETLINK_AUDIT_SOCKET__NLMSG_WRITE         0x00800000UL
30038 +#define NETLINK_AUDIT_SOCKET__NLMSG_RELAY         0x01000000UL
30039 +#define NETLINK_AUDIT_SOCKET__NLMSG_READPRIV      0x02000000UL
30040 +#define NETLINK_AUDIT_SOCKET__NLMSG_TTY_AUDIT     0x04000000UL
30041 +#define NETLINK_IP6FW_SOCKET__IOCTL               0x00000001UL
30042 +#define NETLINK_IP6FW_SOCKET__READ                0x00000002UL
30043 +#define NETLINK_IP6FW_SOCKET__WRITE               0x00000004UL
30044 +#define NETLINK_IP6FW_SOCKET__CREATE              0x00000008UL
30045 +#define NETLINK_IP6FW_SOCKET__GETATTR             0x00000010UL
30046 +#define NETLINK_IP6FW_SOCKET__SETATTR             0x00000020UL
30047 +#define NETLINK_IP6FW_SOCKET__LOCK                0x00000040UL
30048 +#define NETLINK_IP6FW_SOCKET__RELABELFROM         0x00000080UL
30049 +#define NETLINK_IP6FW_SOCKET__RELABELTO           0x00000100UL
30050 +#define NETLINK_IP6FW_SOCKET__APPEND              0x00000200UL
30051 +#define NETLINK_IP6FW_SOCKET__BIND                0x00000400UL
30052 +#define NETLINK_IP6FW_SOCKET__CONNECT             0x00000800UL
30053 +#define NETLINK_IP6FW_SOCKET__LISTEN              0x00001000UL
30054 +#define NETLINK_IP6FW_SOCKET__ACCEPT              0x00002000UL
30055 +#define NETLINK_IP6FW_SOCKET__GETOPT              0x00004000UL
30056 +#define NETLINK_IP6FW_SOCKET__SETOPT              0x00008000UL
30057 +#define NETLINK_IP6FW_SOCKET__SHUTDOWN            0x00010000UL
30058 +#define NETLINK_IP6FW_SOCKET__RECVFROM            0x00020000UL
30059 +#define NETLINK_IP6FW_SOCKET__SENDTO              0x00040000UL
30060 +#define NETLINK_IP6FW_SOCKET__RECV_MSG            0x00080000UL
30061 +#define NETLINK_IP6FW_SOCKET__SEND_MSG            0x00100000UL
30062 +#define NETLINK_IP6FW_SOCKET__NAME_BIND           0x00200000UL
30063 +#define NETLINK_IP6FW_SOCKET__NLMSG_READ          0x00400000UL
30064 +#define NETLINK_IP6FW_SOCKET__NLMSG_WRITE         0x00800000UL
30065 +#define NETLINK_DNRT_SOCKET__IOCTL                0x00000001UL
30066 +#define NETLINK_DNRT_SOCKET__READ                 0x00000002UL
30067 +#define NETLINK_DNRT_SOCKET__WRITE                0x00000004UL
30068 +#define NETLINK_DNRT_SOCKET__CREATE               0x00000008UL
30069 +#define NETLINK_DNRT_SOCKET__GETATTR              0x00000010UL
30070 +#define NETLINK_DNRT_SOCKET__SETATTR              0x00000020UL
30071 +#define NETLINK_DNRT_SOCKET__LOCK                 0x00000040UL
30072 +#define NETLINK_DNRT_SOCKET__RELABELFROM          0x00000080UL
30073 +#define NETLINK_DNRT_SOCKET__RELABELTO            0x00000100UL
30074 +#define NETLINK_DNRT_SOCKET__APPEND               0x00000200UL
30075 +#define NETLINK_DNRT_SOCKET__BIND                 0x00000400UL
30076 +#define NETLINK_DNRT_SOCKET__CONNECT              0x00000800UL
30077 +#define NETLINK_DNRT_SOCKET__LISTEN               0x00001000UL
30078 +#define NETLINK_DNRT_SOCKET__ACCEPT               0x00002000UL
30079 +#define NETLINK_DNRT_SOCKET__GETOPT               0x00004000UL
30080 +#define NETLINK_DNRT_SOCKET__SETOPT               0x00008000UL
30081 +#define NETLINK_DNRT_SOCKET__SHUTDOWN             0x00010000UL
30082 +#define NETLINK_DNRT_SOCKET__RECVFROM             0x00020000UL
30083 +#define NETLINK_DNRT_SOCKET__SENDTO               0x00040000UL
30084 +#define NETLINK_DNRT_SOCKET__RECV_MSG             0x00080000UL
30085 +#define NETLINK_DNRT_SOCKET__SEND_MSG             0x00100000UL
30086 +#define NETLINK_DNRT_SOCKET__NAME_BIND            0x00200000UL
30087 +#define ASSOCIATION__SENDTO                       0x00000001UL
30088 +#define ASSOCIATION__RECVFROM                     0x00000002UL
30089 +#define ASSOCIATION__SETCONTEXT                   0x00000004UL
30090 +#define ASSOCIATION__POLMATCH                     0x00000008UL
30091 +#define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL      0x00000001UL
30092 +#define NETLINK_KOBJECT_UEVENT_SOCKET__READ       0x00000002UL
30093 +#define NETLINK_KOBJECT_UEVENT_SOCKET__WRITE      0x00000004UL
30094 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CREATE     0x00000008UL
30095 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETATTR    0x00000010UL
30096 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETATTR    0x00000020UL
30097 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LOCK       0x00000040UL
30098 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELFROM 0x00000080UL
30099 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RELABELTO  0x00000100UL
30100 +#define NETLINK_KOBJECT_UEVENT_SOCKET__APPEND     0x00000200UL
30101 +#define NETLINK_KOBJECT_UEVENT_SOCKET__BIND       0x00000400UL
30102 +#define NETLINK_KOBJECT_UEVENT_SOCKET__CONNECT    0x00000800UL
30103 +#define NETLINK_KOBJECT_UEVENT_SOCKET__LISTEN     0x00001000UL
30104 +#define NETLINK_KOBJECT_UEVENT_SOCKET__ACCEPT     0x00002000UL
30105 +#define NETLINK_KOBJECT_UEVENT_SOCKET__GETOPT     0x00004000UL
30106 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SETOPT     0x00008000UL
30107 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SHUTDOWN   0x00010000UL
30108 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECVFROM   0x00020000UL
30109 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SENDTO     0x00040000UL
30110 +#define NETLINK_KOBJECT_UEVENT_SOCKET__RECV_MSG   0x00080000UL
30111 +#define NETLINK_KOBJECT_UEVENT_SOCKET__SEND_MSG   0x00100000UL
30112 +#define NETLINK_KOBJECT_UEVENT_SOCKET__NAME_BIND  0x00200000UL
30113 +#define APPLETALK_SOCKET__IOCTL                   0x00000001UL
30114 +#define APPLETALK_SOCKET__READ                    0x00000002UL
30115 +#define APPLETALK_SOCKET__WRITE                   0x00000004UL
30116 +#define APPLETALK_SOCKET__CREATE                  0x00000008UL
30117 +#define APPLETALK_SOCKET__GETATTR                 0x00000010UL
30118 +#define APPLETALK_SOCKET__SETATTR                 0x00000020UL
30119 +#define APPLETALK_SOCKET__LOCK                    0x00000040UL
30120 +#define APPLETALK_SOCKET__RELABELFROM             0x00000080UL
30121 +#define APPLETALK_SOCKET__RELABELTO               0x00000100UL
30122 +#define APPLETALK_SOCKET__APPEND                  0x00000200UL
30123 +#define APPLETALK_SOCKET__BIND                    0x00000400UL
30124 +#define APPLETALK_SOCKET__CONNECT                 0x00000800UL
30125 +#define APPLETALK_SOCKET__LISTEN                  0x00001000UL
30126 +#define APPLETALK_SOCKET__ACCEPT                  0x00002000UL
30127 +#define APPLETALK_SOCKET__GETOPT                  0x00004000UL
30128 +#define APPLETALK_SOCKET__SETOPT                  0x00008000UL
30129 +#define APPLETALK_SOCKET__SHUTDOWN                0x00010000UL
30130 +#define APPLETALK_SOCKET__RECVFROM                0x00020000UL
30131 +#define APPLETALK_SOCKET__SENDTO                  0x00040000UL
30132 +#define APPLETALK_SOCKET__RECV_MSG                0x00080000UL
30133 +#define APPLETALK_SOCKET__SEND_MSG                0x00100000UL
30134 +#define APPLETALK_SOCKET__NAME_BIND               0x00200000UL
30135 +#define PACKET__SEND                              0x00000001UL
30136 +#define PACKET__RECV                              0x00000002UL
30137 +#define PACKET__RELABELTO                         0x00000004UL
30138 +#define PACKET__FLOW_IN                           0x00000008UL
30139 +#define PACKET__FLOW_OUT                          0x00000010UL
30140 +#define PACKET__FORWARD_IN                        0x00000020UL
30141 +#define PACKET__FORWARD_OUT                       0x00000040UL
30142 +#define KEY__VIEW                                 0x00000001UL
30143 +#define KEY__READ                                 0x00000002UL
30144 +#define KEY__WRITE                                0x00000004UL
30145 +#define KEY__SEARCH                               0x00000008UL
30146 +#define KEY__LINK                                 0x00000010UL
30147 +#define KEY__SETATTR                              0x00000020UL
30148 +#define KEY__CREATE                               0x00000040UL
30149 +#define DCCP_SOCKET__IOCTL                        0x00000001UL
30150 +#define DCCP_SOCKET__READ                         0x00000002UL
30151 +#define DCCP_SOCKET__WRITE                        0x00000004UL
30152 +#define DCCP_SOCKET__CREATE                       0x00000008UL
30153 +#define DCCP_SOCKET__GETATTR                      0x00000010UL
30154 +#define DCCP_SOCKET__SETATTR                      0x00000020UL
30155 +#define DCCP_SOCKET__LOCK                         0x00000040UL
30156 +#define DCCP_SOCKET__RELABELFROM                  0x00000080UL
30157 +#define DCCP_SOCKET__RELABELTO                    0x00000100UL
30158 +#define DCCP_SOCKET__APPEND                       0x00000200UL
30159 +#define DCCP_SOCKET__BIND                         0x00000400UL
30160 +#define DCCP_SOCKET__CONNECT                      0x00000800UL
30161 +#define DCCP_SOCKET__LISTEN                       0x00001000UL
30162 +#define DCCP_SOCKET__ACCEPT                       0x00002000UL
30163 +#define DCCP_SOCKET__GETOPT                       0x00004000UL
30164 +#define DCCP_SOCKET__SETOPT                       0x00008000UL
30165 +#define DCCP_SOCKET__SHUTDOWN                     0x00010000UL
30166 +#define DCCP_SOCKET__RECVFROM                     0x00020000UL
30167 +#define DCCP_SOCKET__SENDTO                       0x00040000UL
30168 +#define DCCP_SOCKET__RECV_MSG                     0x00080000UL
30169 +#define DCCP_SOCKET__SEND_MSG                     0x00100000UL
30170 +#define DCCP_SOCKET__NAME_BIND                    0x00200000UL
30171 +#define DCCP_SOCKET__NODE_BIND                    0x00400000UL
30172 +#define DCCP_SOCKET__NAME_CONNECT                 0x00800000UL
30173 +#define MEMPROTECT__MMAP_ZERO                     0x00000001UL
30174 +#define PEER__RECV                                0x00000001UL
30175 +#define CAPABILITY2__MAC_OVERRIDE                 0x00000001UL
30176 +#define CAPABILITY2__MAC_ADMIN                    0x00000002UL
30177 +#define KERNEL_SERVICE__USE_AS_OVERRIDE           0x00000001UL
30178 +#define KERNEL_SERVICE__CREATE_FILES_AS           0x00000002UL
30179 +#define TUN_SOCKET__IOCTL                         0x00000001UL
30180 +#define TUN_SOCKET__READ                          0x00000002UL
30181 +#define TUN_SOCKET__WRITE                         0x00000004UL
30182 +#define TUN_SOCKET__CREATE                        0x00000008UL
30183 +#define TUN_SOCKET__GETATTR                       0x00000010UL
30184 +#define TUN_SOCKET__SETATTR                       0x00000020UL
30185 +#define TUN_SOCKET__LOCK                          0x00000040UL
30186 +#define TUN_SOCKET__RELABELFROM                   0x00000080UL
30187 +#define TUN_SOCKET__RELABELTO                     0x00000100UL
30188 +#define TUN_SOCKET__APPEND                        0x00000200UL
30189 +#define TUN_SOCKET__BIND                          0x00000400UL
30190 +#define TUN_SOCKET__CONNECT                       0x00000800UL
30191 +#define TUN_SOCKET__LISTEN                        0x00001000UL
30192 +#define TUN_SOCKET__ACCEPT                        0x00002000UL
30193 +#define TUN_SOCKET__GETOPT                        0x00004000UL
30194 +#define TUN_SOCKET__SETOPT                        0x00008000UL
30195 +#define TUN_SOCKET__SHUTDOWN                      0x00010000UL
30196 +#define TUN_SOCKET__RECVFROM                      0x00020000UL
30197 +#define TUN_SOCKET__SENDTO                        0x00040000UL
30198 +#define TUN_SOCKET__RECV_MSG                      0x00080000UL
30199 +#define TUN_SOCKET__SEND_MSG                      0x00100000UL
30200 +#define TUN_SOCKET__NAME_BIND                     0x00200000UL
30201 +
30202 +#endif
30203 diff -NurpP --minimal linux-2.6.33.1/security/selinux/hooks.c linux-2.6.33.1-vs2.3.0.36.30.4/security/selinux/hooks.c
30204 --- linux-2.6.33.1/security/selinux/hooks.c     2010-02-25 11:52:12.000000000 +0100
30205 +++ linux-2.6.33.1-vs2.3.0.36.30.4/security/selinux/hooks.c     2010-02-25 12:02:16.000000000 +0100
30206 @@ -64,7 +64,6 @@
30207  #include <linux/dccp.h>
30208  #include <linux/quota.h>
30209  #include <linux/un.h>          /* for Unix socket types */
30210 -#include <net/af_unix.h>       /* for Unix socket types */
30211  #include <linux/parser.h>
30212  #include <linux/nfs_mount.h>
30213  #include <net/ipv6.h>
This page took 2.297967 seconds and 2 git commands to generate.